You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2020/02/28 11:36:47 UTC
[mynewt-core] 01/06: Update NRFX to release 2.0.0
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit e9b5e83f232126dc58d3db628db2a206a55d2a73
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Nov 21 08:43:15 2019 +0100
Update NRFX to release 2.0.0
---
hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md | 74 +
hw/mcu/nordic/src/ext/nrfx/README.md | 13 +-
.../src/ext/nrfx/drivers/include/nrf_bitmask.h | 53 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_adc.h | 46 +-
.../src/ext/nrfx/drivers/include/nrfx_clock.h | 28 +-
.../src/ext/nrfx/drivers/include/nrfx_comp.h | 73 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_egu.h | 157 +
.../src/ext/nrfx/drivers/include/nrfx_gpiote.h | 72 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h | 57 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h | 218 +
.../src/ext/nrfx/drivers/include/nrfx_lpcomp.h | 37 +-
.../src/ext/nrfx/drivers/include/nrfx_nfct.h | 23 +-
.../src/ext/nrfx/drivers/include/nrfx_nvmc.h | 31 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h | 57 +-
.../src/ext/nrfx/drivers/include/nrfx_power.h | 12 +-
.../ext/nrfx/drivers/include/nrfx_power_clock.h | 13 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h | 74 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h | 147 +-
.../src/ext/nrfx/drivers/include/nrfx_qdec.h | 60 +-
.../src/ext/nrfx/drivers/include/nrfx_qspi.h | 84 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_rng.h | 11 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h | 93 +-
.../src/ext/nrfx/drivers/include/nrfx_saadc.h | 362 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_spi.h | 46 +-
.../src/ext/nrfx/drivers/include/nrfx_spim.h | 132 +-
.../src/ext/nrfx/drivers/include/nrfx_spis.h | 62 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_swi.h | 236 -
.../src/ext/nrfx/drivers/include/nrfx_temp.h | 10 +-
.../src/ext/nrfx/drivers/include/nrfx_timer.h | 146 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_twi.h | 161 +-
.../nrf_ecb.c => drivers/include/nrfx_twi_twim.h} | 57 +-
.../src/ext/nrfx/drivers/include/nrfx_twim.h | 170 +-
.../src/ext/nrfx/drivers/include/nrfx_twis.h | 42 +-
.../src/ext/nrfx/drivers/include/nrfx_uart.h | 68 +-
.../src/ext/nrfx/drivers/include/nrfx_uarte.h | 68 +-
.../src/ext/nrfx/drivers/include/nrfx_usbd.h | 4 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h | 132 +-
hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h | 51 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c | 64 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_clock.c | 72 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c | 64 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c | 6 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c | 215 +
.../nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c | 199 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c | 6 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c | 162 +
.../nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c | 31 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c | 396 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c | 11 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c | 54 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_power.c | 57 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c | 50 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c | 50 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c | 56 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c | 17 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c | 22 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c | 70 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c | 1052 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c | 8 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c | 116 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c | 16 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_swi.c | 430 -
.../nordic/src/ext/nrfx/drivers/src/nrfx_timer.c | 68 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c | 229 +-
.../{hal/nrf_ecb.c => drivers/src/nrfx_twi_twim.c} | 85 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c | 125 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c | 17 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c | 16 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c | 187 +-
.../src/ext/nrfx/drivers/src/nrfx_usbd_errata.h | 79 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c | 129 +-
.../nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h | 22 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h | 149 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h | 40 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h | 135 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h | 24 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h | 404 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h | 153 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h | 233 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h | 209 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h | 134 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h | 108 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h | 250 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h | 28 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h | 156 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h | 203 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h | 411 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h | 215 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h | 497 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h | 219 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h | 40 +-
.../ext/nrfx/hal/{nrf_regulators.h => nrf_mutex.h} | 61 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h | 193 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h | 569 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.c | 124 -
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h | 169 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h | 258 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h | 477 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h | 285 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h | 254 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h | 319 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h | 214 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h | 737 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h | 16 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h | 128 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h | 133 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h | 162 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h | 497 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h | 117 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h | 365 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h | 284 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h | 233 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h | 32 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h | 99 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h | 267 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h | 157 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h | 250 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h | 304 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h | 232 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h | 312 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h | 689 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h | 88 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h | 204 +-
hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h | 586 +
...m_startup_nrf52810.s => arm_startup_nrf52805.s} | 16 +-
.../nordic/src/ext/nrfx/mdk/arm_startup_nrf52810.s | 23 +
...m_startup_nrf52810.s => arm_startup_nrf52833.s} | 102 +-
...rf52810.s => arm_startup_nrf5340_application.s} | 279 +-
...up_nrf52810.s => arm_startup_nrf5340_network.s} | 136 +-
.../nordic/src/ext/nrfx/mdk/compiler_abstraction.h | 20 +
...c_startup_nrf52810.S => gcc_startup_nrf52805.S} | 12 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S | 23 +
...c_startup_nrf52810.S => gcc_startup_nrf52833.S} | 74 +-
...rf52810.S => gcc_startup_nrf5340_application.S} | 233 +-
...up_nrf52810.S => gcc_startup_nrf5340_network.S} | 107 +-
...r_startup_nrf52810.s => iar_startup_nrf52805.s} | 28 +-
.../nordic/src/ext/nrfx/mdk/iar_startup_nrf52810.s | 23 +
...r_startup_nrf52810.s => iar_startup_nrf52833.s} | 140 +-
...rf52810.s => iar_startup_nrf5340_application.s} | 313 +-
...up_nrf52810.s => iar_startup_nrf5340_network.s} | 153 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h | 60 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h | 11 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51422_erratas.h | 2579 +
.../nordic/src/ext/nrfx/mdk/nrf51422_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51801_erratas.h | 635 +
.../nordic/src/ext/nrfx/mdk/nrf51801_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51802_erratas.h | 635 +
.../nordic/src/ext/nrfx/mdk/nrf51802_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51822_erratas.h | 2993 +
.../nordic/src/ext/nrfx/mdk/nrf51822_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51824_erratas.h | 743 +
.../nordic/src/ext/nrfx/mdk/nrf51824_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_erratas.h | 3309 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_xxaa.ld | 2 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_xxab.ld | 2 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_xxac.ld | 2 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52.h | 12 +-
.../src/ext/nrfx/mdk/{nrf52810.h => nrf52805.h} | 330 +-
.../ext/nrfx/mdk/{nrf52810.svd => nrf52805.svd} | 5675 +-
.../{nrf52810_bitfields.h => nrf52805_bitfields.h} | 1478 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52805_erratas.h | 1427 +
...f52811_peripherals.h => nrf52805_peripherals.h} | 34 +-
.../mdk/{nrf51801_xxab.ld => nrf52805_xxaa.ld} | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52810.h | 21 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52810.svd | 25 +-
.../nordic/src/ext/nrfx/mdk/nrf52810_bitfields.h | 11 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52810_erratas.h | 1611 +
.../nordic/src/ext/nrfx/mdk/nrf52810_name_change.h | 2 +-
.../nordic/src/ext/nrfx/mdk/nrf52810_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52810_xxaa.ld | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811.h | 23 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811.svd | 40 +-
.../nordic/src/ext/nrfx/mdk/nrf52811_bitfields.h | 35 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811_erratas.h | 1481 +
.../nordic/src/ext/nrfx/mdk/nrf52811_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811_xxaa.ld | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52832_erratas.h | 4268 ++
.../nordic/src/ext/nrfx/mdk/nrf52832_peripherals.h | 6 +
.../nrfx/mdk/{nrf52_xxaa.ld => nrf52832_xxaa.ld} | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52832_xxab.ld | 3 +-
.../src/ext/nrfx/mdk/{nrf52840.h => nrf52833.h} | 356 +-
.../ext/nrfx/mdk/{nrf52840.svd => nrf52833.svd} | 2771 +-
.../{nrf52840_bitfields.h => nrf52833_bitfields.h} | 1065 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52833_erratas.h | 1471 +
...f52840_peripherals.h => nrf52833_peripherals.h} | 32 +-
.../nrfx/mdk/{nrf52_xxaa.ld => nrf52833_xxaa.ld} | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840.h | 52 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840.svd | 62 +-
.../nordic/src/ext/nrfx/mdk/nrf52840_bitfields.h | 52 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840_erratas.h | 3239 +
.../nordic/src/ext/nrfx/mdk/nrf52840_peripherals.h | 7 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840_xxaa.ld | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52_to_nrf52833.h | 150 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52_xxaa.ld | 3 +-
.../nrfx/mdk/{nrf9160.h => nrf5340_application.h} | 1893 +-
.../mdk/{nrf52840.svd => nrf5340_application.svd} | 65658 ++++++++++---------
...bitfields.h => nrf5340_application_bitfields.h} | 14809 +++--
.../src/ext/nrfx/mdk/nrf5340_application_erratas.h | 801 +
...pherals.h => nrf5340_application_peripherals.h} | 182 +-
.../ext/nrfx/mdk/{nrf9160.h => nrf5340_network.h} | 2654 +-
.../nrfx/mdk/{nrf52811.svd => nrf5340_network.svd} | 41713 ++++++------
...811_bitfields.h => nrf5340_network_bitfields.h} | 9812 +--
.../src/ext/nrfx/mdk/nrf5340_network_erratas.h | 619 +
...peripherals.h => nrf5340_network_peripherals.h} | 134 +-
...rf52840_xxaa.ld => nrf5340_xxaa_application.ld} | 3 +-
.../{nrf51801_xxab.ld => nrf5340_xxaa_network.ld} | 4 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160.h | 138 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160.svd | 651 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160_bitfields.h | 277 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160_erratas.h | 561 +
...rf52810_name_change.h => nrf9160_name_change.h} | 29 +-
.../nordic/src/ext/nrfx/mdk/nrf9160_peripherals.h | 9 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160_xxaa.ld | 4 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf91_common.ld | 163 -
hw/mcu/nordic/src/ext/nrfx/mdk/nrf_erratas.h | 100 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf_peripherals.h | 13 +-
hw/mcu/nordic/src/ext/nrfx/mdk/ses_startup_nrf51.s | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/ses_startup_nrf52.s | 3 +-
...s_startup_nrf52810.s => ses_startup_nrf52805.s} | 23 +-
.../nordic/src/ext/nrfx/mdk/ses_startup_nrf52810.s | 26 +-
.../nordic/src/ext/nrfx/mdk/ses_startup_nrf52811.s | 3 +-
...s_startup_nrf52840.s => ses_startup_nrf52833.s} | 13 +-
.../nordic/src/ext/nrfx/mdk/ses_startup_nrf52840.s | 3 +-
...nrf9160.s => ses_startup_nrf5340_application.s} | 97 +-
...up_nrf52811.s => ses_startup_nrf5340_network.s} | 142 +-
.../nordic/src/ext/nrfx/mdk/ses_startup_nrf9160.s | 3 +-
.../src/ext/nrfx/mdk/ses_startup_nrf_common.s | 5 +-
.../nrfx/mdk/{system_nrf9160.h => system_nrf.h} | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf51.c | 70 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf51.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52.c | 192 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52805.c | 126 +
.../mdk/{startup_config.h => system_nrf52805.h} | 25 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52810.c | 308 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52810.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52811.c | 185 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52811.h | 71 +-
.../mdk/{system_nrf52840.c => system_nrf52833.c} | 162 +-
.../{nrf52810_name_change.h => system_nrf52833.h} | 37 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52840.c | 139 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52840.h | 71 +-
.../src/ext/nrfx/mdk/system_nrf5340_application.c | 227 +
..._name_change.h => system_nrf5340_application.h} | 37 +-
.../src/ext/nrfx/mdk/system_nrf5340_network.c | 89 +
...2810_name_change.h => system_nrf5340_network.h} | 37 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf9160.c | 208 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf9160.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_coredep.h | 30 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs.h | 6 +
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf51.h | 8 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52810.h | 10 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52811.h | 10 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52832.h | 14 +-
.../{nrfx_irqs_nrf52840.h => nrfx_irqs_nrf52833.h} | 26 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52840.h | 14 +-
.../ext/nrfx/soc/nrfx_irqs_nrf5340_application.h | 168 +
...fx_irqs_nrf51.h => nrfx_irqs_nrf5340_network.h} | 88 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf9160.h | 14 +-
.../src/ext/nrfx/templates/nRF51/nrfx_config.h | 475 +-
.../src/ext/nrfx/templates/nRF52810/nrfx_config.h | 786 +-
.../src/ext/nrfx/templates/nRF52811/nrfx_config.h | 786 +-
.../src/ext/nrfx/templates/nRF52832/nrfx_config.h | 1019 +-
.../templates/{nRF52811 => nRF52833}/nrfx_config.h | 1167 +-
.../src/ext/nrfx/templates/nRF52840/nrfx_config.h | 1140 +-
.../{nRF9160 => nRF5340_application}/nrfx_config.h | 1117 +-
.../nrfx/templates/nRF5340_network/nrfx_config.h | 1200 +
.../src/ext/nrfx/templates/nRF9160/nrfx_config.h | 707 +-
hw/mcu/nordic/src/ext/nrfx/templates/nrfx_glue.h | 4 +-
271 files changed, 119908 insertions(+), 90003 deletions(-)
diff --git a/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md b/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md
index e17a19d..7d7773f 100644
--- a/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md
+++ b/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md
@@ -1,6 +1,80 @@
# Changelog
All notable changes to this project are documented in this file.
+## [2.0.0] - 2019-11-06
+### Added
+- Added support for nRF5340.
+- Added HALs for: CACHE, FPU, MUTEX, and RESET.
+- Added driver and HAL for IPC.
+- Added possibility to configure in UART and UARTE the number of stop bits and the type of parity, when a given SoC allows it.
+- Added function in the GPIO HAL for selecting the MCU to control the specified pin.
+- Added support for ONESHOT register in the TIMER HAL.
+- Added support for LIST feature in HALs for SPIS and TWIS.
+- Added possibility to choose TIMER instance used for workarounds in the NFCT driver.
+
+### Changed
+- Updated MDK to 8.29.0.
+- Enhanced PWM driver API: added the "p_context" parameter to the event handler.
+- Updated address and task getters in all HALs to return values as uint32_t type.
+- Updated all HAL functions to take the pointer to the structure of registers of the peripheral as their first argument.
+- Changed __STATIC_INLINE symbol to NRF_STATIC_INLINE for HALs and NRFX_STATIC_INLINE for drivers.
+- Refactored the SAADC driver and HAL.
+- Refactored the WDT driver and HAL to support multiple instances.
+- Changed nrfx_gpiote_init() function to take the interrupt priority as its parameter. Previously this priority was an nrfx_config option.
+- Changed nrf_usbd_ep_all_disable() function to disable really all endpoints. Use nrf_usbd_ep_default_config() to restore the default endpoint configuration.
+- Updated nrfx_gpiote_out_init() and nrfx_gpiote_in_init() return codes. Now NRFX_ERROR_INVALID_STATE is changed to NRFX_ERROR_BUSY.
+- Replaced the SWI/EGU driver with one for EGU only.
+- Aligned symbol names for default IRQ priority in nrfx_config. These symbols are now adhering to the following standard: NRFX_xxx_DEFAULT_CONFIG_IRQ_PRIORITY.
+- Changed the way of configuring the MISO pin pull setting in SPI and SPIM drivers. Now it can be set separately for each instance.
+
+### Removed
+- Removed deprecated functions from drivers: TWI and TWIM. See migration guide for details.
+- Removed deprecated functions from HALs: ECB, NVMC, and TEMP. See migration guide for details.
+- Removed redundant bariers in the nrfx_usbd driver.
+- Removed the default configuration values for drivers from the nrfx_config header files.
+
+## [1.8.1] - 2019-10-21
+### Added
+- Added functions in the GPIOTE driver for getting task or event for the specified GPIO pin.
+
+### Changed
+- Updated MDK to version 8.27.1.
+- Moved the nrfx_gppi helper from helpers/nrfx_gppi/ to helpers/.
+- Changed the interrupt initialization in the GPIOTE driver, so that mapping of the GPIOTEx_IRQn enumeration values is no longer needed for nRF9160.
+
+## [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.
diff --git a/hw/mcu/nordic/src/ext/nrfx/README.md b/hw/mcu/nordic/src/ext/nrfx/README.md
index ab233c0..8864720 100644
--- a/hw/mcu/nordic/src/ext/nrfx/README.md
+++ b/hw/mcu/nordic/src/ext/nrfx/README.md
@@ -16,7 +16,9 @@ SoCs, as well as startup and initialization files for them.
* nRF52810
* nRF52811
* nRF52832
+* nRF52833
* nRF52840
+* nRF5340
* nRF9160
## Directories
@@ -24,12 +26,13 @@ SoCs, as well as startup and initialization files for them.
```
.
├── doc # Project documentation files
- ├── drivers # nrfx drivers files
- │ └── include # nrfx drivers headers
- │ └── src # nrfx drivers sources
+ ├── drivers # nrfx driver files
+ │ └── include # nrfx driver headers
+ │ └── src # nrfx driver sources
├── hal # Hardware Access Layer files
- ├── mdk # Nordic MDK files
- ├── soc # Nordic SoC related files
+ ├── helpers # nrfx driver helper files
+ ├── mdk # nRF MDK files
+ ├── soc # SoC specific files
└── templates # Templates of nrfx integration files
```
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrf_bitmask.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrf_bitmask.h
index 2fa69ac..abb281a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrf_bitmask.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrf_bitmask.h
@@ -57,21 +57,22 @@ extern "C" {
* @param[in] bit Bit index.
* @param[in] p_mask Pointer to mask with bit fields.
*
- * @return 0 if bit is not set, positive value otherwise.
+ * @retval true If the specified bit is set.
+ * @retval false If the specified bit is cleared.
*/
-__STATIC_INLINE uint32_t nrf_bitmask_bit_is_set(uint32_t bit, void const * p_mask)
+__STATIC_INLINE bool nrf_bitmask_bit_is_set(uint32_t bit, void const * p_mask)
{
uint8_t const * p_mask8 = (uint8_t const *)p_mask;
uint32_t byte_idx = BITMASK_BYTE_GET(bit);
bit = BITMASK_RELBIT_GET(bit);
- return (1 << bit) & p_mask8[byte_idx];
+ return ((1U << bit) & p_mask8[byte_idx]) != 0U;
}
/**
* @brief Function for setting a bit in the multi-byte bit mask.
*
- * @param[in] bit Bit index.
- * @param[in] p_mask Pointer to mask with bit fields.
+ * @param[in] bit Bit index.
+ * @param[in,out] p_mask Pointer to mask with bit fields.
*/
__STATIC_INLINE void nrf_bitmask_bit_set(uint32_t bit, void * p_mask)
{
@@ -84,8 +85,8 @@ __STATIC_INLINE void nrf_bitmask_bit_set(uint32_t bit, void * p_mask)
/**
* @brief Function for clearing a bit in the multi-byte bit mask.
*
- * @param[in] bit Bit index.
- * @param[in] p_mask Pointer to mask with bit fields.
+ * @param[in] bit Bit index.
+ * @param[in,out] p_mask Pointer to mask with bit fields.
*/
__STATIC_INLINE void nrf_bitmask_bit_clear(uint32_t bit, void * p_mask)
{
@@ -98,21 +99,20 @@ __STATIC_INLINE void nrf_bitmask_bit_clear(uint32_t bit, void * p_mask)
/**
* @brief Function for performing bitwise OR operation on two multi-byte bit masks.
*
- * @param[in] p_mask1 Pointer to the first bit mask.
- * @param[in] p_mask2 Pointer to the second bit mask.
- * @param[in] p_out_mask Pointer to the output bit mask.
- * @param[in] length Length of output mask in bytes.
+ * @param[in] p_mask1 Pointer to the first bit mask.
+ * @param[in] p_mask2 Pointer to the second bit mask.
+ * @param[out] p_out_mask Pointer to the output bit mask.
+ * @param[in] length Length of output mask in bytes.
*/
-__STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
- void const * p_mask2,
- void * p_out_mask,
- uint32_t length)
+__STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
+ void const * p_mask2,
+ void * p_out_mask,
+ size_t length)
{
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
- uint32_t i;
- for (i = 0; i < length; i++)
+ for (size_t i = 0; i < length; i++)
{
p_mask8_out[i] = p_mask8_1[i] | p_mask8_2[i];
}
@@ -121,21 +121,20 @@ __STATIC_INLINE void nrf_bitmask_masks_or(void const * p_mask1,
/**
* @brief Function for performing bitwise AND operation on two multi-byte bit masks.
*
- * @param[in] p_mask1 Pointer to the first bit mask.
- * @param[in] p_mask2 Pointer to the second bit mask.
- * @param[in] p_out_mask Pointer to the output bit mask.
- * @param[in] length Length of output mask in bytes.
+ * @param[in] p_mask1 Pointer to the first bit mask.
+ * @param[in] p_mask2 Pointer to the second bit mask.
+ * @param[out] p_out_mask Pointer to the output bit mask.
+ * @param[in] length Length of output mask in bytes.
*/
-__STATIC_INLINE void nrf_bitmask_masks_and(void const * p_mask1,
- void const * p_mask2,
- void * p_out_mask,
- uint32_t length)
+__STATIC_INLINE void nrf_bitmask_masks_and(void const * p_mask1,
+ void const * p_mask2,
+ void * p_out_mask,
+ size_t length)
{
uint8_t const * p_mask8_1 = (uint8_t const *)p_mask1;
uint8_t const * p_mask8_2 = (uint8_t const *)p_mask2;
uint8_t * p_mask8_out = (uint8_t *)p_out_mask;
- uint32_t i;
- for (i = 0; i < length; i++)
+ for (size_t i = 0; i < length; i++)
{
p_mask8_out[i] = p_mask8_1[i] & p_mask8_2[i];
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_adc.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_adc.h
index a042d87..78ef700 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_adc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_adc.h
@@ -77,18 +77,28 @@ typedef struct
} data; ///< Union to store event data.
} nrfx_adc_evt_t;
-/** @brief Macro for initializing the ADC channel with the default configuration. */
+/**
+ * @brief ADC channel default configuration.
+ *
+ * This configuration sets up ADC channel with the following options:
+ * - 10 bits resolution
+ * - full scale input
+ * - reference voltage: 1.2 V
+ * - external reference input disabled
+ *
+ * @param[in] analog_input Analog input.
+ */
#define NRFX_ADC_DEFAULT_CHANNEL(analog_input) \
- { \
- NULL, \
- { \
+{ \
+ NULL, \
+ { \
.resolution = NRF_ADC_CONFIG_RES_10BIT, \
.scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
.reference = NRF_ADC_CONFIG_REF_VBG, \
- .input = (analog_input), \
+ .input = (nrf_adc_config_input_t)analog_input, \
.extref = NRF_ADC_CONFIG_EXTREFSEL_NONE \
- } \
- }
+ } \
+}
/** @brief Forward declaration of the nrfx_adc_channel_t type. */
typedef struct nrfx_adc_channel_s nrfx_adc_channel_t;
@@ -112,9 +122,9 @@ typedef struct
} nrfx_adc_config_t;
/** @brief ADC default configuration. */
-#define NRFX_ADC_DEFAULT_CONFIG \
-{ \
- .interrupt_priority = NRFX_ADC_CONFIG_IRQ_PRIORITY \
+#define NRFX_ADC_DEFAULT_CONFIG \
+{ \
+ .interrupt_priority = NRFX_ADC_DEFAULT_CONFIG_IRQ_PRIORITY \
}
/**
@@ -206,8 +216,8 @@ void nrfx_adc_sample(void);
* @retval NRFX_SUCCESS Conversion was successful.
* @retval NRFX_ERROR_BUSY The ADC driver is busy.
*/
-nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
- nrf_adc_value_t * p_value);
+nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * p_channel,
+ nrf_adc_value_t * p_value);
/**
* @brief Function for converting data to the buffer.
@@ -256,16 +266,14 @@ bool nrfx_adc_is_busy(void);
*
* @return Start task address.
*/
-__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
+NRFX_STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
-__STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
{
- return nrf_adc_task_address_get(NRF_ADC_TASK_START);
+ return nrf_adc_task_address_get(NRF_ADC, NRF_ADC_TASK_START);
}
-
-#endif
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_clock.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_clock.h
index c782b02..4dbeb80 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_clock.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_clock.h
@@ -97,7 +97,7 @@ void nrfx_clock_lfclk_stop(void);
* @retval true The LFCLK is running.
* @retval false The LFCLK is not running.
*/
-__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void);
+NRFX_STATIC_INLINE bool nrfx_clock_lfclk_is_running(void);
/** @brief Function for starting the high-accuracy source HFCLK. */
void nrfx_clock_hfclk_start(void);
@@ -111,7 +111,7 @@ void nrfx_clock_hfclk_stop(void);
* @retval true The HFCLK is running (XTAL source).
* @retval false The HFCLK is not running.
*/
-__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
+NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
/**
* @brief Function for starting the calibration of internal LFCLK.
@@ -151,7 +151,7 @@ void nrfx_clock_calibration_timer_stop(void);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
+NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
/**@brief Function for returning a requested event address for the clock driver module.
*
@@ -159,30 +159,30 @@ __STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
+NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-__STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
{
- return nrf_clock_task_address_get(task);
+ return nrf_clock_task_address_get(NRF_CLOCK, task);
}
-__STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
{
- return nrf_clock_event_address_get(event);
+ return nrf_clock_event_address_get(NRF_CLOCK, event);
}
-__STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
+NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
{
- return nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
+ return nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY);
}
-__STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
+NRFX_STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
{
- return nrf_clock_lf_is_running();
+ return nrf_clock_lf_is_running(NRF_CLOCK);
}
-#endif //SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_comp.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_comp.h
index 91efd42..7621f48 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_comp.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_comp.h
@@ -104,31 +104,42 @@ typedef struct
.th_up = NRFX_VOLTAGE_THRESHOLD_TO_INT(1.5, 1.8) \
}
-/** @brief COMP driver default configuration including the COMP HAL configuration. */
+/**
+ * @brief COMP driver default configuration.
+ *
+ * This configuration sets up COMP with the following options:
+ * - single-ended mode
+ * - reference voltage: internal 1.8 V
+ * - lower threshold: 0.5 V
+ * - upper threshold: 1.5 V
+ * - high speed mode
+ * - hysteresis disabled
+ * - current source disabled
+ *
+ * @param[in] _input Analog input.
+ */
#if defined (COMP_ISOURCE_ISOURCE_Msk) || defined (__NRFX_DOXYGEN__)
-#define NRFX_COMP_DEFAULT_CONFIG(_input) \
-{ \
- .reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
- .ext_ref = NRF_COMP_EXT_REF_0, \
- .main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
- .threshold = NRFX_COMP_CONFIG_TH, \
- .speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
- .hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
- .isource = (nrf_isource_t)NRFX_COMP_CONFIG_ISOURCE, \
- .input = (nrf_comp_input_t)_input, \
- .interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
+#define NRFX_COMP_DEFAULT_CONFIG(_input) \
+{ \
+ .reference = NRF_COMP_REF_Int1V8, \
+ .main_mode = NRF_COMP_MAIN_MODE_SE, \
+ .threshold = NRFX_COMP_CONFIG_TH, \
+ .speed_mode = NRF_COMP_SP_MODE_High, \
+ .hyst = NRF_COMP_HYST_NoHyst, \
+ .isource = NRF_COMP_ISOURCE_Off, \
+ .input = (nrf_comp_input_t)_input, \
+ .interrupt_priority = NRFX_COMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
#else
-#define NRFX_COMP_DEFAULT_CONFIG(_input) \
-{ \
- .reference = (nrf_comp_ref_t)NRFX_COMP_CONFIG_REF, \
- .ext_ref = NRF_COMP_EXT_REF_0, \
- .main_mode = (nrf_comp_main_mode_t)NRFX_COMP_CONFIG_MAIN_MODE, \
- .threshold = NRFX_COMP_CONFIG_TH, \
- .speed_mode = (nrf_comp_sp_mode_t)NRFX_COMP_CONFIG_SPEED_MODE, \
- .hyst = (nrf_comp_hyst_t)NRFX_COMP_CONFIG_HYST, \
- .input = (nrf_comp_input_t)_input, \
- .interrupt_priority = NRFX_COMP_CONFIG_IRQ_PRIORITY \
+#define NRFX_COMP_DEFAULT_CONFIG(_input) \
+{ \
+ .reference = NRF_COMP_REF_Int1V8, \
+ .main_mode = NRF_COMP_MAIN_MODE_SE, \
+ .threshold = NRFX_COMP_CONFIG_TH, \
+ .speed_mode = NRF_COMP_SP_MODE_High, \
+ .hyst = NRF_COMP_HYST_NoHyst, \
+ .input = (nrf_comp_input_t)_input, \
+ .interrupt_priority = NRFX_COMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
#endif
@@ -209,10 +220,7 @@ uint32_t nrfx_comp_sample(void);
*
* @return Address of the given COMP task.
*/
-__STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
-{
- return (uint32_t)nrf_comp_task_address_get(task);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task);
/**
* @brief Function for getting the address of a COMP event.
@@ -221,10 +229,19 @@ __STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
*
* @return Address of the given COMP event.
*/
-__STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event);
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_comp_task_address_get(nrf_comp_task_t task)
+{
+ return nrf_comp_task_address_get(NRF_COMP, task);
+}
+
+NRFX_STATIC_INLINE uint32_t nrfx_comp_event_address_get(nrf_comp_event_t event)
{
- return (uint32_t)nrf_comp_event_address_get(event);
+ return nrf_comp_event_address_get(NRF_COMP, event);
}
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_egu.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_egu.h
new file mode 100644
index 0000000..1470778
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_egu.h
@@ -0,0 +1,157 @@
+/*
+ * 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 must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NRFX_EGU_H__
+#define NRFX_EGU_H__
+
+#include <nrfx.h>
+#include <hal/nrf_egu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup nrfx_egu EGU driver
+ * @{
+ * @ingroup nrf_egu
+ *
+ * @brief Event Generator Unit (EGU) peripheral driver.
+ */
+
+/** @brief Structure for the EGU driver instance. */
+typedef struct
+{
+ NRF_EGU_Type * p_reg; ///< Pointer to a structure with EGU registers.
+ uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only.
+} nrfx_egu_t;
+
+#ifndef __NRFX_DOXYGEN__
+enum {
+#if NRFX_CHECK(NRFX_EGU0_ENABLED)
+ NRFX_EGU0_INST_IDX,
+#endif
+#if NRFX_CHECK(NRFX_EGU1_ENABLED)
+ NRFX_EGU1_INST_IDX,
+#endif
+#if NRFX_CHECK(NRFX_EGU2_ENABLED)
+ NRFX_EGU2_INST_IDX,
+#endif
+#if NRFX_CHECK(NRFX_EGU3_ENABLED)
+ NRFX_EGU3_INST_IDX,
+#endif
+#if NRFX_CHECK(NRFX_EGU4_ENABLED)
+ NRFX_EGU4_INST_IDX,
+#endif
+#if NRFX_CHECK(NRFX_EGU5_ENABLED)
+ NRFX_EGU5_INST_IDX,
+#endif
+ NRFX_EGU_ENABLED_COUNT
+};
+#endif
+
+/** @brief Macro for creating an EGU driver instance. */
+#define NRFX_EGU_INSTANCE(id) \
+{ \
+ .p_reg = NRFX_CONCAT_2(NRF_EGU, id), \
+ .drv_inst_idx = NRFX_CONCAT_3(NRFX_EGU, id, _INST_IDX), \
+}
+
+/**
+ * @brief EGU driver event handler.
+ *
+ * @param[in] event_idx Index of the event that generated the interrupt.
+ * @param[in] p_context Context passed to the event handler. Set on initialization.
+ */
+typedef void (*nrfx_egu_event_handler_t)(uint8_t event_idx, void * p_context);
+
+/**
+ * @brief Function for initializing the EGU driver instance.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
+ * @param[in] interrupt_priority Interrupt priority.
+ * @param[in] event_handler Event handler provided by the user. In case of providing NULL,
+ * event notifications are not done and EGU interrupts are disabled.
+ * @param[in] p_context Context passed to the event handler.
+ *
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_INVALID_STATE Driver is already initialized.
+ */
+nrfx_err_t nrfx_egu_init(nrfx_egu_t const * p_instance,
+ uint8_t interrupt_priority,
+ nrfx_egu_event_handler_t event_handler,
+ void * p_context);
+
+/**
+ * @brief Function for enabling interrupts on specified events of a given EGU driver instance.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
+ * @param[in] mask Mask of events with interrupts to be enabled.
+ */
+void nrfx_egu_int_enable(nrfx_egu_t const * p_instance, uint32_t mask);
+
+/**
+ * @brief Function for disabling interrupts on specified events of a given EGU driver instance.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
+ * @param[in] mask Mask of events with interrupts to be disabled.
+ */
+void nrfx_egu_int_disable(nrfx_egu_t const * p_instance, uint32_t mask);
+
+/**
+ * @brief Function for triggering an event specified by @c event_idx of a given EGU driver instance.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
+ * @param[in] event_idx Index of the event to be triggered.
+ */
+void nrfx_egu_trigger(nrfx_egu_t const * p_instance, uint8_t event_idx);
+
+/**
+ * @brief Function for uninitializing the EGU driver instance.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
+ */
+void nrfx_egu_uninit(nrfx_egu_t const * p_instance);
+
+/** @} */
+
+void nrfx_egu_0_irq_handler(void);
+void nrfx_egu_1_irq_handler(void);
+void nrfx_egu_2_irq_handler(void);
+void nrfx_egu_3_irq_handler(void);
+void nrfx_egu_4_irq_handler(void);
+void nrfx_egu_5_irq_handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NRFX_EGU_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_gpiote.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_gpiote.h
index 126f0f5..ad1abec 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_gpiote.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_gpiote.h
@@ -205,10 +205,12 @@ typedef void (*nrfx_gpiote_evt_handler_t)(nrfx_gpiote_pin_t pin, nrf_gpiote_pola
* @details Only static configuration is supported to prevent the shared
* resource being customized by the initiator.
*
+ * @param[in] interrupt_priority Interrupt priority.
+ *
* @retval NRFX_SUCCESS Initialization was successful.
* @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
*/
-nrfx_err_t nrfx_gpiote_init(void);
+nrfx_err_t nrfx_gpiote_init(uint8_t interrupt_priority);
/**
* @brief Function for checking if the GPIOTE module is initialized.
@@ -234,9 +236,9 @@ void nrfx_gpiote_uninit(void);
* @param[in] pin Pin.
* @param[in] p_config Initial configuration.
*
- * @retval NRFX_SUCCESS Initialization was successful.
- * @retval NRFX_ERROR_INVALID_STATE The driver is not initialized or the pin is already used.
- * @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_BUSY The pin is already used.
+ * @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
*/
nrfx_err_t nrfx_gpiote_out_init(nrfx_gpiote_pin_t pin,
nrfx_gpiote_out_config_t const * p_config);
@@ -285,7 +287,19 @@ void nrfx_gpiote_out_task_enable(nrfx_gpiote_pin_t pin);
void nrfx_gpiote_out_task_disable(nrfx_gpiote_pin_t pin);
/**
- * @brief Function for getting the address of a configurable GPIOTE task.
+ * @brief Function for getting the OUT task for the specified output pin.
+ *
+ * @details The returned task identifier can be used within @ref nrf_gpiote_hal,
+ * for example, to configure a DPPI channel.
+ *
+ * @param[in] pin Pin.
+ *
+ * @return OUT task associated with the specified output pin.
+ */
+nrf_gpiote_task_t nrfx_gpiote_out_task_get(nrfx_gpiote_pin_t pin);
+
+/**
+ * @brief Function for getting the address of the OUT task for the specified output pin.
*
* @param[in] pin Pin.
*
@@ -295,7 +309,19 @@ uint32_t nrfx_gpiote_out_task_addr_get(nrfx_gpiote_pin_t pin);
#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
/**
- * @brief Function for getting the address of a configurable GPIOTE task.
+ * @brief Function for getting the SET task for the specified output pin.
+ *
+ * @details The returned task identifier can be used within @ref nrf_gpiote_hal,
+ * for example, to configure a DPPI channel.
+ *
+ * @param[in] pin Pin.
+ *
+ * @return SET task associated with the specified output pin.
+ */
+nrf_gpiote_task_t nrfx_gpiote_set_task_get(nrfx_gpiote_pin_t pin);
+
+/**
+ * @brief Function for getting the address of the SET task for the specified output pin.
*
* @param[in] pin Pin.
*
@@ -306,7 +332,19 @@ uint32_t nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin);
#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
/**
- * @brief Function for getting the address of a configurable GPIOTE task.
+ * @brief Function for getting the CLR task for the specified output pin.
+ *
+ * @details The returned task identifier can be used within @ref nrf_gpiote_hal,
+ * for example, to configure a DPPI channel.
+ *
+ * @param[in] pin Pin.
+ *
+ * @return CLR task associated with the specified output pin.
+ */
+nrf_gpiote_task_t nrfx_gpiote_clr_task_get(nrfx_gpiote_pin_t pin);
+
+/**
+ * @brief Function for getting the address of the SET task for the specified output pin.
*
* @param[in] pin Pin.
*
@@ -334,9 +372,9 @@ uint32_t nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin);
* @param[in] p_config Initial configuration.
* @param[in] evt_handler User function to be called when the configured transition occurs.
*
- * @retval NRFX_SUCCESS Initialization was successful.
- * @retval NRFX_ERROR_INVALID_STATE The driver is not initialized or the pin is already used.
- * @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_BUSY The pin is already used.
+ * @retval NRFX_ERROR_NO_MEM No GPIOTE channel is available.
*/
nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
nrfx_gpiote_in_config_t const * p_config,
@@ -380,6 +418,20 @@ void nrfx_gpiote_in_event_disable(nrfx_gpiote_pin_t pin);
bool nrfx_gpiote_in_is_set(nrfx_gpiote_pin_t pin);
/**
+ * @brief Function for getting the GPIOTE event for the specified input pin.
+ *
+ * @details The returned event identifier can be used within @ref nrf_gpiote_hal,
+ * for example, to configure a DPPI channel.
+ * If the pin is configured to use low-accuracy mode, the PORT event
+ * is returned.
+ *
+ * @param[in] pin Pin.
+ *
+ * @return Event associated with the specified input pin.
+ */
+nrf_gpiote_event_t nrfx_gpiote_in_event_get(nrfx_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.
*
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h
index 24acbdc..0476a63 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h
@@ -46,7 +46,6 @@ extern "C" {
* @brief Inter-IC Sound (I2S) peripheral driver.
*/
-
/**
* @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
@@ -86,25 +85,41 @@ typedef struct
uint32_t const * p_tx_buffer; ///< Pointer to the buffer with data to be sent.
} nrfx_i2s_buffers_t;
-/** @brief I2S driver default configuration. */
-#define NRFX_I2S_DEFAULT_CONFIG \
-{ \
- .sck_pin = NRFX_I2S_CONFIG_SCK_PIN, \
- .lrck_pin = NRFX_I2S_CONFIG_LRCK_PIN, \
- .mck_pin = NRFX_I2S_CONFIG_MCK_PIN, \
- .sdout_pin = NRFX_I2S_CONFIG_SDOUT_PIN, \
- .sdin_pin = NRFX_I2S_CONFIG_SDIN_PIN, \
- .irq_priority = NRFX_I2S_CONFIG_IRQ_PRIORITY, \
- .mode = (nrf_i2s_mode_t)NRFX_I2S_CONFIG_MASTER, \
- .format = (nrf_i2s_format_t)NRFX_I2S_CONFIG_FORMAT, \
- .alignment = (nrf_i2s_align_t)NRFX_I2S_CONFIG_ALIGN, \
- .sample_width = (nrf_i2s_swidth_t)NRFX_I2S_CONFIG_SWIDTH, \
- .channels = (nrf_i2s_channels_t)NRFX_I2S_CONFIG_CHANNELS, \
- .mck_setup = (nrf_i2s_mck_t)NRFX_I2S_CONFIG_MCK_SETUP, \
- .ratio = (nrf_i2s_ratio_t)NRFX_I2S_CONFIG_RATIO, \
+/**
+ * @brief I2S driver default configuration.
+ *
+ * This configuration sets up I2S with the following options:
+ * - master mode
+ * - i2s data format
+ * - left alignment
+ * - sample width 16 bit
+ * - left channel enabled
+ * - MCK frequency 4 MHz
+ * - LRCK frequency 125 kHz
+ *
+ * @param[in] _pin_sck SCK pin number.
+ * @param[in] _pin_lrck LRCK pin number.
+ * @param[in] _pin_mck MCK pin number.
+ * @param[in] _pin_sdout SDOUT pin number.
+ * @param[in] _pin_sdin SDIN pin number.
+ */
+#define NRFX_I2S_DEFAULT_CONFIG(_pin_sck, _pin_lrck, _pin_mck, _pin_sdout, _pin_sdin) \
+{ \
+ .sck_pin = _pin_sck, \
+ .lrck_pin = _pin_lrck, \
+ .mck_pin = _pin_mck, \
+ .sdout_pin = _pin_sdout, \
+ .sdin_pin = _pin_sdin, \
+ .irq_priority = NRFX_I2S_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .mode = NRF_I2S_MODE_MASTER, \
+ .format = NRF_I2S_FORMAT_I2S, \
+ .alignment = NRF_I2S_ALIGN_LEFT, \
+ .sample_width = NRF_I2S_SWIDTH_16BIT, \
+ .channels = NRF_I2S_CHANNELS_LEFT, \
+ .mck_setup = NRF_I2S_MCK_32MDIV8, \
+ .ratio = NRF_I2S_RATIO_32X, \
}
-
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
/**< The application must provide buffers that are to be used in the next
* part of the transfer. A call to @ref nrfx_i2s_next_buffers_set must
@@ -152,7 +167,6 @@ typedef struct
typedef void (* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const * p_released,
uint32_t status);
-
/**
* @brief Function for initializing the I2S driver.
*
@@ -219,11 +233,14 @@ nrfx_err_t nrfx_i2s_start(nrfx_i2s_buffers_t const * p_initial_buffers,
* but it has to be done before the I2S peripheral finishes processing the
* buffers supplied previously. Otherwise, data corruption will occur.
*
- * @sa nrfx_i2s_data_handler_t
+ * @param[in] p_buffers Pointer to a structure specifying the buffers
+ * to be used in the upcoming part of the transfer.
*
* @retval NRFX_SUCCESS If the operation was successful.
* @retval NRFX_ERROR_INVALID_STATE If the buffers were already supplied or
* the peripheral is currently being stopped.
+ *
+ * @sa nrfx_i2s_data_handler_t
*/
nrfx_err_t nrfx_i2s_next_buffers_set(nrfx_i2s_buffers_t const * p_buffers);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h
new file mode 100644
index 0000000..fb4abab
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h
@@ -0,0 +1,218 @@
+/*
+ * 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 must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef NRFX_IPC_H__
+#define NRFX_IPC_H__
+
+#include <nrfx.h>
+#include <hal/nrf_ipc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup nrfx_ipc IPC driver
+ * @{
+ * @ingroup nrf_ipc
+ * @brief Interprocessor Communication (IPC) peripheral driver.
+ */
+
+/**
+ * @brief IPC driver handler type.
+ *
+ * @param[in] event_mask Bitmask with events that triggered the interrupt.
+ * @param[in] p_context Context passed to the interrupt handler, set on initialization.
+ */
+typedef void (*nrfx_ipc_handler_t)(uint32_t event_mask, void * p_context);
+
+/** @brief IPC configuration structure. */
+typedef struct
+{
+ uint32_t send_task_config[IPC_CONF_NUM]; ///< Configuration of the connection between signals and IPC channels.
+ uint32_t receive_event_config[IPC_CONF_NUM]; ///< Configuration of the connection between events and IPC channels.
+ uint32_t receive_events_enabled; ///< Bitmask with events to be enabled to generate interrupt.
+} nrfx_ipc_config_t;
+
+/**
+ * @brief Function for initializing the IPC driver.
+ *
+ * @param irq_priority Interrupt priority.
+ * @param handler Event handler provided by the user. Cannot be NULL.
+ * @param p_context Context passed to event handler.
+ *
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_INVALID_STATE Driver is already initialized.
+ */
+nrfx_err_t nrfx_ipc_init(uint8_t irq_priority, nrfx_ipc_handler_t handler, void * p_context);
+
+/**
+ * @brief Function for loading configuration directly into IPC peripheral.
+ *
+ * @param p_config Pointer to the structure with the initial configuration.
+ */
+void nrfx_ipc_config_load(nrfx_ipc_config_t const * p_config);
+
+/**
+ * @brief Function for convey signal on configured channels.
+ *
+ * Events connected to the IPC channels configured within this signal will
+ * be set and can generate interrupts when configured.
+ *
+ * @param send_index Index of the SEND task to trigger.
+ */
+NRFX_STATIC_INLINE void nrfx_ipc_signal(uint8_t send_index);
+
+/**
+ * @brief Function for storing data in GPMEM register in the IPC peripheral.
+ *
+ * @param mem_index Index of the memory cell.
+ * @param data Data to be saved.
+ */
+NRFX_STATIC_INLINE void nrfx_ipc_gpmem_set(uint8_t mem_index, uint32_t data);
+
+/**
+ * @brief Function for getting data from the GPMEM register in the IPC peripheral.
+ *
+ * @param mem_index Index of the memory cell.
+ *
+ * @return Saved data.
+ */
+NRFX_STATIC_INLINE uint32_t nrfx_ipc_mem_get(uint8_t mem_index);
+
+/** @brief Function for uninitializing the IPC module. */
+void nrfx_ipc_uninit(void);
+
+/**
+ * @brief Function for enabling events to generate interrupt.
+ *
+ * @param event_index Index of event to be enabled.
+ */
+void nrfx_ipc_receive_event_enable(uint8_t event_index);
+
+/**
+ * @brief Function for disabling events from generate interrupt.
+ *
+ * @param event_index Index of event to be disabled.
+ */
+void nrfx_ipc_receive_event_disable(uint8_t event_index);
+
+/**
+ * @brief Function for enabling set of events to generate interrupt.
+ *
+ * @param event_bitmask Bitmask with events to be enabled.
+ */
+void nrfx_ipc_receive_event_group_enable(uint32_t event_bitmask);
+
+/**
+ * @brief Function for disabling set of events from generate interrupt.
+ *
+ * @param event_bitmask Bitmask with events to be disabled.
+ */
+void nrfx_ipc_receive_event_group_disable(uint32_t event_bitmask);
+
+/**
+ * @brief Function for assigning event to the IPC channel.
+ *
+ * @param event_index Index of the event to be configured.
+ * @param channel_index Index of the channel to which event will be connected.
+ */
+void nrfx_ipc_receive_event_channel_assign(uint8_t event_index, uint8_t channel_index);
+
+/**
+ * @brief Function for assigning signal to the IPC channel.
+ *
+ * @param send_index Index of the signal to be configured.
+ * @param channel_index Index of the instance of channel.
+ */
+void nrfx_ipc_send_task_channel_assign(uint8_t send_index, uint8_t channel_index);
+
+/**
+ * @brief Function for assigning event to the IPC channels.
+ *
+ * @param event_index Index of the event to be configured.
+ * @param channel_bitmask Bitmask with channels to which event will be connected.
+ */
+NRFX_STATIC_INLINE void nrfx_ipc_receive_config_set(uint8_t event_index, uint32_t channel_bitmask);
+
+/**
+ * @brief Function for assigning signal to the IPC channels.
+ *
+ * @param send_index Index of the signal to be configured.
+ * @param channel_bitmask Bitmask with channels to which signal will be connected.
+ */
+NRFX_STATIC_INLINE void nrfx_ipc_send_config_set(uint8_t send_index, uint32_t channel_bitmask);
+
+/** @} */
+
+
+#ifndef NRFX_DECLARE_ONLY
+
+NRFX_STATIC_INLINE void nrfx_ipc_gpmem_set(uint8_t mem_index, uint32_t data)
+{
+ NRFX_ASSERT(mem_index < NRFX_ARRAY_SIZE(NRF_IPC->GPMEM));
+ nrf_ipc_gpmem_set(NRF_IPC, mem_index, data);
+}
+
+NRFX_STATIC_INLINE uint32_t nrfx_ipc_mem_get(uint8_t mem_index)
+{
+ NRFX_ASSERT(mem_index < NRFX_ARRAY_SIZE(NRF_IPC->GPMEM));
+ return nrf_ipc_gpmem_get(NRF_IPC, mem_index);
+}
+
+NRFX_STATIC_INLINE void nrfx_ipc_signal(uint8_t send_index)
+{
+ NRFX_ASSERT(send_index < IPC_CONF_NUM);
+ nrf_ipc_task_trigger(NRF_IPC, nrf_ipc_send_task_get(send_index));
+}
+
+NRFX_STATIC_INLINE void nrfx_ipc_receive_config_set(uint8_t event_index, uint32_t channel_bitmask)
+{
+ NRFX_ASSERT(event_index < IPC_CONF_NUM);
+ nrf_ipc_receive_config_set(NRF_IPC, event_index, channel_bitmask);
+}
+
+NRFX_STATIC_INLINE void nrfx_ipc_send_config_set(uint8_t send_index, uint32_t channel_bitmask)
+{
+ NRFX_ASSERT(send_index < IPC_CONF_NUM);
+ nrf_ipc_send_config_set(NRF_IPC, send_index, channel_bitmask);
+}
+
+#endif // NRFX_DECLARE_ONLY
+
+
+void nrfx_ipc_irq_handler(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NRFX_IPC_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_lpcomp.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_lpcomp.h
index f68ef1f..03a8370 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_lpcomp.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_lpcomp.h
@@ -60,23 +60,32 @@ typedef struct
uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */
} nrfx_lpcomp_config_t;
-/** @brief LPCOMP driver default configuration, including the LPCOMP HAL configuration. */
+/**
+ * @brief LPCOMP driver default configuration.
+ *
+ * This configuration sets up LPCOMP with the following options:
+ * - reference voltage: 4/8 of supply voltage
+ * - detection of both up and down crossings
+ * - hysteresis disabled
+ *
+ * @param[in] _input Comparator input pin.
+ */
#ifdef NRF52_SERIES
-#define NRFX_LPCOMP_DEFAULT_CONFIG \
-{ \
- .hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
- (nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION, \
- (nrf_lpcomp_hysteresis_t)NRFX_LPCOMP_CONFIG_HYST }, \
- .input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
- .interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
+#define NRFX_LPCOMP_DEFAULT_CONFIG(_input) \
+{ \
+ .hal = { NRF_LPCOMP_REF_SUPPLY_4_8, \
+ NRF_LPCOMP_DETECT_CROSS, \
+ NRF_LPCOMP_HYST_NOHYST }, \
+ .input = _input, \
+ .interrupt_priority = NRFX_LPCOMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
#else
-#define NRFX_LPCOMP_DEFAULT_CONFIG \
-{ \
- .hal = { (nrf_lpcomp_ref_t)NRFX_LPCOMP_CONFIG_REFERENCE , \
- (nrf_lpcomp_detect_t)NRFX_LPCOMP_CONFIG_DETECTION }, \
- .input = (nrf_lpcomp_input_t)NRFX_LPCOMP_CONFIG_INPUT, \
- .interrupt_priority = NRFX_LPCOMP_CONFIG_IRQ_PRIORITY \
+#define NRFX_LPCOMP_DEFAULT_CONFIG(_input) \
+{ \
+ .hal = { NRF_LPCOMP_REF_SUPPLY_4_8, \
+ NRF_LPCOMP_DETECT_CROSS }, \
+ .input = _input, \
+ .interrupt_priority = NRFX_LPCOMP_DEFAULT_CONFIG_IRQ_PRIORITY \
}
#endif
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nfct.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nfct.h
index 2bfa882..963a935 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nfct.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nfct.h
@@ -116,9 +116,9 @@ typedef struct
nrfx_nfct_param_id_t id; ///< Type of parameter.
union
{
- uint32_t fdt; ///< NFC-A Frame Delay Time. Filled when nrfx_nfct_param_t::id is @ref NRFX_NFCT_PARAM_ID_FDT.
- uint8_t sel_res_protocol; ///< NFC-A value of the 'Protocol' field in the SEL_RES frame. Filled when nrfx_nfct_param_t::id is @ref NRFX_NFCT_PARAM_ID_SEL_RES.
- nrfx_nfct_nfcid1_t nfcid1; ///< NFC-A NFCID1 value (tag identifier). Filled when nrfx_nfct_param_t::id is @ref NRFX_NFCT_PARAM_ID_NFCID1.
+ uint32_t fdt; ///< NFC-A Frame Delay Time. Filled when nrfx_nfct_param_t.id is @ref NRFX_NFCT_PARAM_ID_FDT.
+ uint8_t sel_res_protocol; ///< NFC-A value of the 'Protocol' field in the SEL_RES frame. Filled when nrfx_nfct_param_t.id is @ref NRFX_NFCT_PARAM_ID_SEL_RES.
+ nrfx_nfct_nfcid1_t nfcid1; ///< NFC-A NFCID1 value (tag identifier). Filled when nrfx_nfct_param_t.id is @ref NRFX_NFCT_PARAM_ID_NFCID1.
} data; ///< Union to store parameter data.
} nrfx_nfct_param_t;
@@ -154,9 +154,9 @@ typedef struct
nrfx_nfct_evt_id_t evt_id; ///< Type of event.
union
{
- nrfx_nfct_evt_rx_frameend_t rx_frameend; ///< End of the RX frame data. Filled when nrfx_nfct_evt_t::evt_id is @ref NRFX_NFCT_EVT_RX_FRAMEEND.
- nrfx_nfct_evt_tx_framestart_t tx_framestart; ///< Start of the TX frame data. Filled when nrfx_nfct_evt_t::evt_id is @ref NRFX_NFCT_EVT_TX_FRAMESTART.
- nrfx_nfct_evt_error_t error; ///< Error data. Filled when nrfx_nfct_evt_t::evt_id is @ref NRFX_NFCT_EVT_ERROR.
+ nrfx_nfct_evt_rx_frameend_t rx_frameend; ///< End of the RX frame data. Filled when nrfx_nfct_evt_t.evt_id is @ref NRFX_NFCT_EVT_RX_FRAMEEND.
+ nrfx_nfct_evt_tx_framestart_t tx_framestart; ///< Start of the TX frame data. Filled when nrfx_nfct_evt_t.evt_id is @ref NRFX_NFCT_EVT_TX_FRAMESTART.
+ nrfx_nfct_evt_error_t error; ///< Error data. Filled when nrfx_nfct_evt_t.evt_id is @ref NRFX_NFCT_EVT_ERROR.
} params; ///< Union to store event data.
} nrfx_nfct_evt_t;
@@ -320,22 +320,13 @@ void nrfx_nfct_irq_handler(void);
* To implement the second workaround, power reset is used to release the clock acquired by NFCT
* after the field is turned off. Note that the NFCT register configuration is restored to defaults.
*
- * If you are using the nRF52840 chip, rev. Engineering A, the workarounds for the following anomalies
- * are applied:
- * - 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.
- * - 144. NFCT: Not optimal NFC performance
- *
- * If you are using the nRF52840 chip, rev. 1, or rev. Engineering B or C, the workarounds for the following
+ * If you are using the nRF52833, nRF52840 or nRF5340 chips, the workarounds for the following
* anomalies are applied:
* - 190. NFCT: Event FIELDDETECTED can be generated too early.
* To implement this workaround, an instance of NRF_TIMER is used. After the NFC field is detected,
* the timing module measures the necessary waiting period after which NFCT can be activated.
* This debouncing technique is used to filter possible field instabilities.
*
- * The application of the implemented workarounds for the nRF52840 chip is determined at runtime and depends
- * on the chip variant.
- *
* The current code contains a patch for the anomaly 25 (NFCT: Reset value of
* SENSRES register is incorrect), so that the module now works on Windows Phone.
* @}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nvmc.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nvmc.h
index 991864b..2a030e5 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nvmc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_nvmc.h
@@ -102,9 +102,14 @@ nrfx_err_t nrfx_nvmc_page_partial_erase_init(uint32_t address, uint32_t duration
/**
* @brief Function for performing a part of the complete page erase (also known as partial erase).
*
- * Each part takes the amount of time specified during the initialization.
* This function must be called several times to erase the whole page, once for each erase part.
*
+ * @note The actual time needed to perform each part of the page erase is longer than the partial
+ * erase duration specified in the call to @ref nrfx_nvmc_page_partial_erase_init,
+ * since the NVMC peripheral needs certain additional amount of time to handle the process.
+ * For details regarding this additional time, see the "Electrical specification" section
+ * for the NVMC peripheral in the Product Specification.
+ *
* @note Using a page that was not completely erased leads to undefined behavior.
* Depending on the source of the code being executed,
* the CPU may be halted during the operation.
@@ -237,40 +242,40 @@ uint32_t nrfx_nvmc_flash_page_count_get(void);
* @retval true Last write completed successfully.
* @retval false Last write is still in progress.
*/
-__STATIC_INLINE bool nrfx_nvmc_write_done_check(void);
+NRFX_STATIC_INLINE bool nrfx_nvmc_write_done_check(void);
-#if defined(NRF_NVMC_ICACHE_PRESENT)
+#if defined(NVMC_FEATURE_CACHE_PRESENT)
/**
* @brief Function for enabling the Instruction Cache (ICache).
*
* Enabling ICache reduces the amount of accesses to flash memory,
* which can boost performance and lower power consumption.
*/
-__STATIC_INLINE void nrfx_nvmc_icache_enable(void);
+NRFX_STATIC_INLINE void nrfx_nvmc_icache_enable(void);
/** @brief Function for disabling ICache. */
-__STATIC_INLINE void nrfx_nvmc_icache_disable(void);
+NRFX_STATIC_INLINE void nrfx_nvmc_icache_disable(void);
-#endif // defined(NRF_NVMC_ICACHE_PRESENT)
+#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-__STATIC_INLINE bool nrfx_nvmc_write_done_check(void)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE bool nrfx_nvmc_write_done_check(void)
{
return nrf_nvmc_ready_check(NRF_NVMC);
}
-#if defined(NRF_NVMC_ICACHE_PRESENT)
-__STATIC_INLINE void nrfx_nvmc_icache_enable(void)
+#if defined(NVMC_FEATURE_CACHE_PRESENT)
+NRFX_STATIC_INLINE void nrfx_nvmc_icache_enable(void)
{
nrf_nvmc_icache_config_set(NRF_NVMC, NRF_NVMC_ICACHE_ENABLE_WITH_PROFILING);
}
-__STATIC_INLINE void nrfx_nvmc_icache_disable(void)
+NRFX_STATIC_INLINE void nrfx_nvmc_icache_disable(void)
{
nrf_nvmc_icache_config_set(NRF_NVMC, NRF_NVMC_ICACHE_DISABLE);
}
-#endif // defined(NRF_NVMC_ICACHE_PRESENT)
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // defined(NVMC_FEATURE_CACHE_PRESENT)
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h
index 1fc2ee7..246c0d6 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h
@@ -78,22 +78,27 @@ typedef struct
} nrfx_pdm_config_t;
/**
- * @brief Macro for setting @ref nrfx_pdm_config_t to default settings
- * in the single-ended mode.
+ * @brief PDM driver default configuration.
*
- * @param _pin_clk CLK output pin.
- * @param _pin_din DIN input pin.
+ * This configuration sets up PDM with the following options:
+ * - mono mode
+ * - data sampled on the clock falling edge
+ * - frequency: 1.032 MHz
+ * - standard gain
+ *
+ * @param[in] _pin_clk CLK output pin.
+ * @param[in] _pin_din DIN input pin.
*/
-#define NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din) \
-{ \
- .mode = (nrf_pdm_mode_t)NRFX_PDM_CONFIG_MODE, \
- .edge = (nrf_pdm_edge_t)NRFX_PDM_CONFIG_EDGE, \
- .pin_clk = _pin_clk, \
- .pin_din = _pin_din, \
- .clock_freq = (nrf_pdm_freq_t)NRFX_PDM_CONFIG_CLOCK_FREQ, \
- .gain_l = NRF_PDM_GAIN_DEFAULT, \
- .gain_r = NRF_PDM_GAIN_DEFAULT, \
- .interrupt_priority = NRFX_PDM_CONFIG_IRQ_PRIORITY \
+#define NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din) \
+{ \
+ .mode = NRF_PDM_MODE_MONO, \
+ .edge = NRF_PDM_EDGE_LEFTFALLING, \
+ .pin_clk = _pin_clk, \
+ .pin_din = _pin_din, \
+ .clock_freq = NRF_PDM_FREQ_1032K, \
+ .gain_l = NRF_PDM_GAIN_DEFAULT, \
+ .gain_r = NRF_PDM_GAIN_DEFAULT, \
+ .interrupt_priority = NRFX_PDM_DEFAULT_CONFIG_IRQ_PRIORITY \
}
/**
@@ -104,7 +109,7 @@ typedef struct
*
* @param[in] p_evt Pointer to the PDM event structure.
*/
-typedef void (*nrfx_pdm_event_handler_t)(nrfx_pdm_evt_t const * const p_evt);
+typedef void (*nrfx_pdm_event_handler_t)(nrfx_pdm_evt_t const * p_evt);
/**
@@ -134,10 +139,7 @@ void nrfx_pdm_uninit(void);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task)
-{
- return nrf_pdm_task_address_get(task);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task);
/**
* @brief Function for getting the state of the PDM interface.
@@ -145,10 +147,7 @@ __STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task)
* @retval true The PDM interface is enabled.
* @retval false The PDM interface is disabled.
*/
-__STATIC_INLINE bool nrfx_pdm_enable_check(void)
-{
- return nrf_pdm_enable_check();
-}
+NRFX_STATIC_INLINE bool nrfx_pdm_enable_check(void);
/**
* @brief Function for starting the PDM sampling.
@@ -185,6 +184,18 @@ nrfx_err_t nrfx_pdm_stop(void);
*/
nrfx_err_t nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length);
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_pdm_task_address_get(nrf_pdm_task_t task)
+{
+ return nrf_pdm_task_address_get(NRF_PDM, task);
+}
+
+NRFX_STATIC_INLINE bool nrfx_pdm_enable_check(void)
+{
+ return nrf_pdm_enable_check(NRF_PDM);
+}
+#endif // NRFX_DECLARE_ONLY
+
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power.h
index adb65de..2220fd6 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power.h
@@ -334,16 +334,15 @@ void nrfx_power_usbevt_uninit(void);
*
* @return Current USB power status.
*/
-__STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void);
+NRFX_STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void);
#endif /* NRF_POWER_HAS_USBREG */
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
+#ifndef NRFX_DECLARE_ONLY
#if NRF_POWER_HAS_USBREG
-__STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
+NRFX_STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
{
- uint32_t status = nrf_power_usbregstatus_get();
+ uint32_t status = nrf_power_usbregstatus_get(NRF_POWER);
if(0 == (status & NRF_POWER_USBREGSTATUS_VBUSDETECT_MASK))
{
return NRFX_POWER_USB_STATE_DISCONNECTED;
@@ -355,8 +354,7 @@ __STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
return NRFX_POWER_USB_STATE_READY;
}
#endif /* NRF_POWER_HAS_USBREG */
-
-#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
+#endif /* NRFX_DECLARE_ONLY */
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_clock.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_clock.h
index e188582..c1af4bd 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_clock.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_clock.h
@@ -39,21 +39,18 @@ extern "C" {
#endif
-__STATIC_INLINE void nrfx_power_clock_irq_init(void);
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
__STATIC_INLINE void nrfx_power_clock_irq_init(void)
{
uint8_t priority;
#if NRFX_CHECK(NRFX_POWER_ENABLED) && NRFX_CHECK(NRFX_CLOCK_ENABLED)
- #if NRFX_POWER_CONFIG_IRQ_PRIORITY != NRFX_CLOCK_CONFIG_IRQ_PRIORITY
+ #if NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY != NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
#error "IRQ priorities for POWER and CLOCK must be the same. Check <nrfx_config.h>."
#endif
- priority = NRFX_POWER_CONFIG_IRQ_PRIORITY;
+ priority = NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY;
#elif NRFX_CHECK(NRFX_POWER_ENABLED)
- priority = NRFX_POWER_CONFIG_IRQ_PRIORITY;
+ priority = NRFX_POWER_DEFAULT_CONFIG_IRQ_PRIORITY;
#elif NRFX_CHECK(NRFX_CLOCK_ENABLED)
- priority = NRFX_CLOCK_CONFIG_IRQ_PRIORITY;
+ priority = NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY;
#else
#error "This code is not supposed to be compiled when neither POWER nor CLOCK is enabled."
#endif
@@ -64,8 +61,6 @@ __STATIC_INLINE void nrfx_power_clock_irq_init(void)
NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_CLOCK));
}
}
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
-
#if NRFX_CHECK(NRFX_POWER_ENABLED) && NRFX_CHECK(NRFX_CLOCK_ENABLED)
void nrfx_power_clock_irq_handler(void);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h
index e2f22cd..0696249 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h
@@ -174,10 +174,7 @@ nrfx_err_t nrfx_ppi_group_free(nrf_ppi_channel_group_t group);
*
* @return Channel mask.
*/
-__STATIC_INLINE uint32_t nrfx_ppi_channel_to_mask(nrf_ppi_channel_t channel)
-{
- return (1uL << (uint32_t) channel);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_channel_to_mask(nrf_ppi_channel_t channel);
/**
* @brief Function for including multiple PPI channels in a channel group.
@@ -204,11 +201,8 @@ nrfx_err_t nrfx_ppi_channels_include_in_group(uint32_t channel_ma
* application channel.
* @retval NRFX_ERROR_INVALID_STATE Group is not an allocated group.
*/
-__STATIC_INLINE nrfx_err_t nrfx_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
- nrf_ppi_channel_group_t group)
-{
- return nrfx_ppi_channels_include_in_group(nrfx_ppi_channel_to_mask(channel), group);
-}
+NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
+ nrf_ppi_channel_group_t group);
/**
* @brief Function for removing multiple PPI channels from a channel group.
@@ -235,11 +229,8 @@ nrfx_err_t nrfx_ppi_channels_remove_from_group(uint32_t channel_m
* application channel.
* @retval NRFX_ERROR_INVALID_STATE Group is not an allocated group.
*/
-__STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
- nrf_ppi_channel_group_t group)
-{
- return nrfx_ppi_channels_remove_from_group(nrfx_ppi_channel_to_mask(channel), group);
-}
+NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
+ nrf_ppi_channel_group_t group);
/**
* @brief Function for clearing a PPI channel group.
@@ -250,10 +241,7 @@ __STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t
* @retval NRFX_ERROR_INVALID_PARAM Group is not an application group.
* @retval NRFX_ERROR_INVALID_STATE Group is not an allocated group.
*/
-__STATIC_INLINE nrfx_err_t nrfx_ppi_group_clear(nrf_ppi_channel_group_t group)
-{
- return nrfx_ppi_channels_remove_from_group(NRFX_PPI_ALL_APP_CHANNELS_MASK, group);
-}
+NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_group_clear(nrf_ppi_channel_group_t group);
/**
* @brief Function for enabling a PPI channel group.
@@ -284,10 +272,7 @@ nrfx_err_t nrfx_ppi_group_disable(nrf_ppi_channel_group_t group);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task)
-{
- return (uint32_t) nrf_ppi_task_address_get(task);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task);
/**
* @brief Function for getting the address of the enable task of a PPI group.
@@ -296,10 +281,7 @@ __STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task)
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group)
-{
- return (uint32_t) nrf_ppi_task_group_enable_address_get(group);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group);
/**
* @brief Function for getting the address of the enable task of a PPI group.
@@ -308,10 +290,46 @@ __STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_gro
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group)
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group);
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_channel_to_mask(nrf_ppi_channel_t channel)
+{
+ return (1uL << (uint32_t) channel);
+}
+
+NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
+ nrf_ppi_channel_group_t group)
+{
+ return nrfx_ppi_channels_include_in_group(nrfx_ppi_channel_to_mask(channel), group);
+}
+
+NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
+ nrf_ppi_channel_group_t group)
+{
+ return nrfx_ppi_channels_remove_from_group(nrfx_ppi_channel_to_mask(channel), group);
+}
+
+NRFX_STATIC_INLINE nrfx_err_t nrfx_ppi_group_clear(nrf_ppi_channel_group_t group)
+{
+ return nrfx_ppi_channels_remove_from_group(NRFX_PPI_ALL_APP_CHANNELS_MASK, group);
+}
+
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_get(nrf_ppi_task_t task)
+{
+ return nrf_ppi_task_address_get(NRF_PPI, task);
+}
+
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group)
+{
+ return nrf_ppi_task_group_enable_address_get(NRF_PPI, group);
+}
+
+NRFX_STATIC_INLINE uint32_t nrfx_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group)
{
- return (uint32_t) nrf_ppi_task_group_disable_address_get(group);
+ return nrf_ppi_task_group_disable_address_get(NRF_PPI, group);
}
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h
index 60cb6c5..b3d4a49 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h
@@ -102,22 +102,37 @@ typedef struct
nrf_pwm_dec_step_t step_mode; ///< Mode of advancing the active sequence.
} nrfx_pwm_config_t;
-/** @brief PWM driver default configuration. */
-#define NRFX_PWM_DEFAULT_CONFIG \
-{ \
- .output_pins = { NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN, \
- NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN, \
- NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN, \
- NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN }, \
- .irq_priority = NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .base_clock = (nrf_pwm_clk_t)NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK, \
- .count_mode = (nrf_pwm_mode_t)NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE, \
- .top_value = NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE, \
- .load_mode = (nrf_pwm_dec_load_t)NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE, \
- .step_mode = (nrf_pwm_dec_step_t)NRFX_PWM_DEFAULT_CONFIG_STEP_MODE, \
+/**
+ * @brief PWM driver default configuration.
+ *
+ * This configuration sets up PWM with the following options:
+ * - clock frequency: 1 MHz
+ * - count up
+ * - top value: 1000 clock ticks
+ * - load mode: common
+ * - step mode: auto
+ *
+ * @param[in] _out_0 PWM output 0 pin.
+ * @param[in] _out_1 PWM output 1 pin.
+ * @param[in] _out_2 PWM output 2 pin.
+ * @param[in] _out_3 PWM output 3 pin.
+ */
+#define NRFX_PWM_DEFAULT_CONFIG(_out_0, _out_1, _out_2, _out_3) \
+{ \
+ .output_pins = { _out_0, \
+ _out_1, \
+ _out_2, \
+ _out_3 \
+ }, \
+ .irq_priority = NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .base_clock = NRF_PWM_CLK_1MHz, \
+ .count_mode = NRF_PWM_MODE_UP, \
+ .top_value = 1000, \
+ .load_mode = NRF_PWM_LOAD_COMMON, \
+ .step_mode = NRF_PWM_STEP_AUTO, \
}
-/** @brief PWM flags that provide additional playback options. */
+/** @brief PWM flags providing additional playback options. */
typedef enum
{
NRFX_PWM_FLAG_STOP = 0x01, /**< When the requested playback is finished,
@@ -175,7 +190,7 @@ typedef enum
} nrfx_pwm_evt_type_t;
/** @brief PWM driver event handler type. */
-typedef void (* nrfx_pwm_handler_t)(nrfx_pwm_evt_type_t event_type);
+typedef void (* nrfx_pwm_handler_t)(nrfx_pwm_evt_type_t event_type, void * p_context);
/**
* @brief Function for initializing the PWM driver.
@@ -185,13 +200,15 @@ typedef void (* nrfx_pwm_handler_t)(nrfx_pwm_evt_type_t event_type);
* @param[in] handler Event handler provided by the user. If NULL is passed
* instead, event notifications are not done and PWM
* interrupts are disabled.
+ * @param[in] p_context Context passed to the event handler.
*
* @retval NRFX_SUCCESS Initialization was successful.
* @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
*/
-nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
+nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * p_instance,
nrfx_pwm_config_t const * p_config,
- nrfx_pwm_handler_t handler);
+ nrfx_pwm_handler_t handler,
+ void * p_context);
/**
* @brief Function for uninitializing the PWM driver.
@@ -200,7 +217,7 @@ nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_pwm_uninit(nrfx_pwm_t const * const p_instance);
+void nrfx_pwm_uninit(nrfx_pwm_t const * p_instance);
/**
* @brief Function for starting a single sequence playback.
@@ -234,7 +251,7 @@ void nrfx_pwm_uninit(nrfx_pwm_t const * const p_instance);
* @return Address of the task to be triggered to start the playback if the @ref
* NRFX_PWM_FLAG_START_VIA_TASK flag was used, 0 otherwise.
*/
-uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
+uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * p_instance,
nrf_pwm_sequence_t const * p_sequence,
uint16_t playback_count,
uint32_t flags);
@@ -262,7 +279,7 @@ uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
* @return Address of the task to be triggered to start the playback if the @ref
* NRFX_PWM_FLAG_START_VIA_TASK flag was used, 0 otherwise.
*/
-uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * const p_instance,
+uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * p_instance,
nrf_pwm_sequence_t const * p_sequence_0,
nrf_pwm_sequence_t const * p_sequence_1,
uint16_t playback_count,
@@ -275,7 +292,7 @@ uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-__STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * const p_instance);
+NRFX_STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * p_instance);
/**
* @brief Function for stopping the sequence playback.
@@ -300,7 +317,7 @@ __STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * const p_instance);
* @retval true The PWM peripheral is stopped.
* @retval false The PWM peripheral is not stopped.
*/
-bool nrfx_pwm_stop(nrfx_pwm_t const * const p_instance, bool wait_until_stopped);
+bool nrfx_pwm_stop(nrfx_pwm_t const * p_instance, bool wait_until_stopped);
/**
* @brief Function for checking the status of the PWM peripheral.
@@ -310,7 +327,7 @@ bool nrfx_pwm_stop(nrfx_pwm_t const * const p_instance, bool wait_until_stopped)
* @retval true The PWM peripheral is stopped.
* @retval false The PWM peripheral is not stopped.
*/
-bool nrfx_pwm_is_stopped(nrfx_pwm_t const * const p_instance);
+bool nrfx_pwm_is_stopped(nrfx_pwm_t const * p_instance);
/**
* @brief Function for updating the sequence data during playback.
@@ -319,9 +336,9 @@ bool nrfx_pwm_is_stopped(nrfx_pwm_t const * const p_instance);
* @param[in] seq_id Identifier of the sequence (0 or 1).
* @param[in] p_sequence Pointer to the new sequence definition.
*/
-__STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- nrf_pwm_sequence_t const * p_sequence);
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t 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
@@ -331,9 +348,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * const p_insta
* @param[in] seq_id Identifier of the sequence (0 or 1).
* @param[in] values New pointer to the duty cycle values.
*/
-__STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- nrf_pwm_values_t values);
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * p_instance,
+ uint8_t seq_id,
+ nrf_pwm_values_t values);
/**
* @brief Function for updating the number of duty cycle values
@@ -343,9 +360,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t const * const p_
* @param[in] seq_id Identifier of the sequence (0 or 1).
* @param[in] length New number of the duty cycle values.
*/
-__STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- uint16_t length);
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * p_instance,
+ uint8_t seq_id,
+ uint16_t length);
/**
* @brief Function for updating the number of repeats for duty cycle values
@@ -355,9 +372,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t const * const p_
* @param[in] seq_id Identifier of the sequence (0 or 1).
* @param[in] repeats New number of repeats.
*/
-__STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- uint32_t repeats);
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * p_instance,
+ uint8_t seq_id,
+ uint32_t repeats);
/**
* @brief Function for updating the additional delay after the specified
@@ -367,9 +384,9 @@ __STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * const p
* @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 nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- uint32_t end_delay);
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * p_instance,
+ uint8_t seq_id,
+ uint32_t end_delay);
/**
* @brief Function for returning the address of a specified PWM task that can
@@ -380,8 +397,8 @@ __STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * const
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * const p_instance,
- nrf_pwm_task_t task);
+NRFX_STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * p_instance,
+ nrf_pwm_task_t task);
/**
* @brief Function for returning the address of a specified PWM event that can
@@ -392,64 +409,62 @@ __STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * const p_in
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * const p_instance,
- nrf_pwm_event_t event);
+NRFX_STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * p_instance,
+ nrf_pwm_event_t event);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
-__STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * const p_instance)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE void nrfx_pwm_step(nrfx_pwm_t const * p_instance)
{
nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_NEXTSTEP);
}
-__STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- nrf_pwm_sequence_t const * p_sequence)
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_update(nrfx_pwm_t 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 nrfx_pwm_sequence_values_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- nrf_pwm_values_t values)
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_values_update(nrfx_pwm_t 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 nrfx_pwm_sequence_length_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- uint16_t length)
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_length_update(nrfx_pwm_t 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 nrfx_pwm_sequence_repeats_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- uint32_t repeats)
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_repeats_update(nrfx_pwm_t 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 nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t const * const p_instance,
- uint8_t seq_id,
- uint32_t end_delay)
+NRFX_STATIC_INLINE void nrfx_pwm_sequence_end_delay_update(nrfx_pwm_t 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 nrfx_pwm_task_address_get(nrfx_pwm_t const * const p_instance,
- nrf_pwm_task_t task)
+NRFX_STATIC_INLINE uint32_t nrfx_pwm_task_address_get(nrfx_pwm_t const * p_instance,
+ nrf_pwm_task_t task)
{
return nrf_pwm_task_address_get(p_instance->p_registers, task);
}
-__STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * const p_instance,
- nrf_pwm_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_pwm_event_address_get(nrfx_pwm_t const * p_instance,
+ nrf_pwm_event_t event)
{
return nrf_pwm_event_address_get(p_instance->p_registers, event);
}
-
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qdec.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qdec.h
index a86fd60..0591e73 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qdec.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qdec.h
@@ -61,20 +61,34 @@ typedef struct
uint8_t interrupt_priority; /**< QDEC interrupt priority. */
} nrfx_qdec_config_t;
-/**@brief QDEC default configuration. */
-#define NRFX_QDEC_DEFAULT_CONFIG \
-{ \
- .reportper = (nrf_qdec_reportper_t)NRFX_QDEC_CONFIG_REPORTPER, \
- .sampleper = (nrf_qdec_sampleper_t)NRFX_QDEC_CONFIG_SAMPLEPER, \
- .psela = NRFX_QDEC_CONFIG_PIO_A, \
- .pselb = NRFX_QDEC_CONFIG_PIO_B, \
- .pselled = NRFX_QDEC_CONFIG_PIO_LED, \
- .ledpre = NRFX_QDEC_CONFIG_LEDPRE, \
- .ledpol = (nrf_qdec_ledpol_t)NRFX_QDEC_CONFIG_LEDPOL, \
- .dbfen = NRFX_QDEC_CONFIG_DBFEN, \
- .sample_inten = NRFX_QDEC_CONFIG_SAMPLE_INTEN, \
- .interrupt_priority = NRFX_QDEC_CONFIG_IRQ_PRIORITY, \
-}
+/**
+ * @brief QDEC driver default configuration.
+ *
+ * This configuration sets up QDEC with the following options:
+ * - report period: 10 samples
+ * - sampling period: 16384 us
+ * - LED enabled for 500 us before sampling
+ * - LED polarity: active high
+ * - debouncing filter disabled
+ * - sample ready interrupt disabled
+ *
+ * @param[in] _pin_a Pin for A encoder channel input.
+ * @param[in] _pin_b Pin for B encoder channel input.
+ * @param[in] _pin_led Pin for LED output.
+ */
+#define NRFX_QDEC_DEFAULT_CONFIG(_pin_a, _pin_b, _pin_led) \
+ { \
+ .reportper = NRF_QDEC_REPORTPER_10, \
+ .sampleper = NRF_QDEC_SAMPLEPER_16384us, \
+ .psela = _pin_a, \
+ .pselb = _pin_b, \
+ .pselled = _pin_led, \
+ .ledpre = 500, \
+ .ledpol = NRF_QDEC_LEPOL_ACTIVE_HIGH, \
+ .dbfen = NRF_QDEC_DBFEN_DISABLE, \
+ .sample_inten = false, \
+ .interrupt_priority = NRFX_QDEC_DEFAULT_CONFIG_IRQ_PRIORITY \
+ }
/** @brief QDEC sample event data. */
typedef struct
@@ -159,10 +173,7 @@ void nrfx_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
-{
- return (uint32_t)nrf_qdec_task_address_get(task);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task);
/**
* @brief Function for returning the address of the specified QDEC event.
@@ -171,10 +182,19 @@ __STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event);
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
+{
+ return nrf_qdec_task_address_get(NRF_QDEC, task);
+}
+
+NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event)
{
- return (uint32_t)nrf_qdec_event_address_get(event);
+ return nrf_qdec_event_address_get(NRF_QDEC, event);
}
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qspi.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qspi.h
index af86166..f435738 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qspi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_qspi.h
@@ -56,31 +56,52 @@ typedef struct
uint8_t irq_priority; /**< Interrupt priority. */
} nrfx_qspi_config_t;
-/** @brief QSPI instance default configuration. */
-#define NRFX_QSPI_DEFAULT_CONFIG \
-{ \
- .xip_offset = NRFX_QSPI_CONFIG_XIP_OFFSET, \
- .pins = { \
- .sck_pin = NRFX_QSPI_PIN_SCK, \
- .csn_pin = NRFX_QSPI_PIN_CSN, \
- .io0_pin = NRFX_QSPI_PIN_IO0, \
- .io1_pin = NRFX_QSPI_PIN_IO1, \
- .io2_pin = NRFX_QSPI_PIN_IO2, \
- .io3_pin = NRFX_QSPI_PIN_IO3, \
- }, \
- .prot_if = { \
- .readoc = (nrf_qspi_readoc_t)NRFX_QSPI_CONFIG_READOC, \
- .writeoc = (nrf_qspi_writeoc_t)NRFX_QSPI_CONFIG_WRITEOC, \
- .addrmode = (nrf_qspi_addrmode_t)NRFX_QSPI_CONFIG_ADDRMODE, \
- .dpmconfig = false, \
- }, \
- .phy_if = { \
- .sck_delay = (uint8_t)NRFX_QSPI_CONFIG_SCK_DELAY, \
- .dpmen = false, \
- .spi_mode = (nrf_qspi_spi_mode_t)NRFX_QSPI_CONFIG_MODE, \
- .sck_freq = (nrf_qspi_frequency_t)NRFX_QSPI_CONFIG_FREQUENCY, \
- }, \
- .irq_priority = (uint8_t)NRFX_QSPI_CONFIG_IRQ_PRIORITY, \
+/**
+ * @brief QSPI instance default configuration.
+ *
+ * This configuration sets up QSPI with the following options:
+ * - no offset for address in the external memory for Execute in Place operation
+ * - single data line
+ * - FAST_READ opcode for reading
+ * - PP opcode for writing
+ * - 24 bit addressing mode
+ * - Deep Power-down disabled
+ * - clock frequency 2 MHz
+ * - SCK delay 5 clock ticks
+ * - mode 0 (data captured on the clock rising edge and transmitted on a falling edge. Clock base level is '0')
+ *
+ * @param[in] _pin_sck Pin for clock signal.
+ * @param[in] _pin_csn Pin for chip select signal.
+ * @param[in] _pin_io0 Pin 0 for I/O data.
+ * @param[in] _pin_io1 Pin 1 for I/O data.
+ * @param[in] _pin_io2 Pin 2 for I/O data.
+ * @param[in] _pin_io3 Pin 3 for I/O data.
+ */
+#define NRFX_QSPI_DEFAULT_CONFIG(_pin_sck, _pin_csn, _pin_io0, \
+ _pin_io1, _pin_io2, _pin_io3) \
+{ \
+ .xip_offset = 0, \
+ .pins = { \
+ .sck_pin = _pin_sck, \
+ .csn_pin = _pin_csn, \
+ .io0_pin = _pin_io0, \
+ .io1_pin = _pin_io1, \
+ .io2_pin = _pin_io2, \
+ .io3_pin = _pin_io3 \
+ }, \
+ .prot_if = { \
+ .readoc = NRF_QSPI_READOC_FASTREAD, \
+ .writeoc = NRF_QSPI_WRITEOC_PP, \
+ .addrmode = NRF_QSPI_ADDRMODE_24BIT, \
+ .dpmconfig = false, \
+ }, \
+ .phy_if = { \
+ .sck_delay = 0x05, \
+ .dpmen = false, \
+ .spi_mode = NRF_QSPI_MODE_0, \
+ .sck_freq = NRF_QSPI_FREQ_32MDIV16, \
+ }, \
+ .irq_priority = (uint8_t)NRFX_QSPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
}
/** @brief QSPI custom instruction helper with the default configuration. */
@@ -155,7 +176,8 @@ void nrfx_qspi_uninit(void);
* @retval NRFX_SUCCESS The operation was successful (blocking mode) or operation
* was commissioned (handler mode).
* @retval NRFX_ERROR_BUSY The driver currently handles another operation.
- * @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not placed in the Data RAM region.
+ * @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not placed in the Data RAM region
+ * or its address is not aligned to a 32-bit word.
*/
nrfx_err_t nrfx_qspi_read(void * p_rx_buffer,
size_t rx_buffer_length,
@@ -182,7 +204,8 @@ nrfx_err_t nrfx_qspi_read(void * p_rx_buffer,
* @retval NRFX_SUCCESS The operation was successful (blocking mode) or operation
* was commissioned (handler mode).
* @retval NRFX_ERROR_BUSY The driver currently handles other operation.
- * @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not placed in the Data RAM region.
+ * @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not placed in the Data RAM region
+ * or its address is not aligned to a 32-bit word.
*/
nrfx_err_t nrfx_qspi_write(void const * p_tx_buffer,
size_t tx_buffer_length,
@@ -206,9 +229,10 @@ nrfx_err_t nrfx_qspi_write(void const * p_tx_buffer,
* @param[in] start_address Memory address to start erasing. If chip erase is performed, address
* field is ommited.
*
- * @retval NRFX_SUCCESS The operation was successful (blocking mode) or operation
- * was commissioned (handler mode).
- * @retval NRFX_ERROR_BUSY The driver currently handles another operation.
+ * @retval NRFX_SUCCESS The operation was successful (blocking mode) or operation
+ * was commissioned (handler mode).
+ * @retval NRFX_ERROR_INVALID_ADDR The provided start address is not aligned to a 32-bit word.
+ * @retval NRFX_ERROR_BUSY The driver currently handles another operation.
*/
nrfx_err_t nrfx_qspi_erase(nrf_qspi_erase_len_t length,
uint32_t start_address);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rng.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rng.h
index 11968f3..cd88f7d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rng.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rng.h
@@ -60,11 +60,14 @@ typedef struct
* if (nrfx_rng_init(&config, handler)
* { ...
* @endcode
+ *
+ * This configuration sets up randon number generator with the following options:
+ * - error correction enabled
*/
-#define NRFX_RNG_DEFAULT_CONFIG \
-{ \
- .error_correction = NRFX_RNG_CONFIG_ERROR_CORRECTION, \
- .interrupt_priority = NRFX_RNG_CONFIG_IRQ_PRIORITY, \
+#define NRFX_RNG_DEFAULT_CONFIG \
+{ \
+ .error_correction = true, \
+ .interrupt_priority = NRFX_RNG_DEFAULT_CONFIG_IRQ_PRIORITY, \
}
/** @brief RNG driver event handler type. */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h
index 5cc5d81..b641a89 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h
@@ -102,14 +102,20 @@ typedef struct
bool reliable; /**< Reliable mode flag. */
} nrfx_rtc_config_t;
-/** @brief RTC instance default configuration. */
-#define NRFX_RTC_DEFAULT_CONFIG \
-{ \
- .prescaler = RTC_FREQ_TO_PRESCALER(NRFX_RTC_DEFAULT_CONFIG_FREQUENCY), \
- .interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .tick_latency = NRFX_RTC_US_TO_TICKS(NRFX_RTC_MAXIMUM_LATENCY_US, \
- NRFX_RTC_DEFAULT_CONFIG_FREQUENCY), \
- .reliable = NRFX_RTC_DEFAULT_CONFIG_RELIABLE, \
+/**
+ * @brief RTC driver default configuration.
+ *
+ * This configuration sets up RTC with the following options:
+ * - frequency 32.768 kHz
+ * - maximum latency 2000 us
+ * - reliability checks disabled
+ */
+#define NRFX_RTC_DEFAULT_CONFIG \
+{ \
+ .prescaler = RTC_FREQ_TO_PRESCALER(32768), \
+ .interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .tick_latency = NRFX_RTC_US_TO_TICKS(2000, 32768), \
+ .reliable = false, \
}
/** @brief RTC driver instance handler type. */
@@ -128,7 +134,7 @@ typedef void (*nrfx_rtc_handler_t)(nrfx_rtc_int_type_t int_type);
* @retval NRFX_SUCCESS Successfully initialized.
* @retval NRFX_ERROR_INVALID_STATE The instance is already initialized.
*/
-nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * const p_instance,
+nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * p_instance,
nrfx_rtc_config_t const * p_config,
nrfx_rtc_handler_t handler);
@@ -140,21 +146,21 @@ nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_rtc_uninit(nrfx_rtc_t const * const p_instance);
+void nrfx_rtc_uninit(nrfx_rtc_t const * p_instance);
/**
* @brief Function for enabling the RTC driver instance.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_rtc_enable(nrfx_rtc_t const * const p_instance);
+void nrfx_rtc_enable(nrfx_rtc_t const * p_instance);
/**
* @brief Function for disabling the RTC driver instance.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_rtc_disable(nrfx_rtc_t const * const p_instance);
+void nrfx_rtc_disable(nrfx_rtc_t const * p_instance);
/**
* @brief Function for setting a compare channel.
@@ -182,10 +188,10 @@ void nrfx_rtc_disable(nrfx_rtc_t const * const p_instance);
* current counter value. This error can only be reported
* if the reliable mode is enabled.
*/
-nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
- uint32_t channel,
- uint32_t val,
- bool enable_irq);
+nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * p_instance,
+ uint32_t channel,
+ uint32_t val,
+ bool enable_irq);
/**
* @brief Function for disabling a channel.
@@ -198,7 +204,7 @@ nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
* @retval NRFX_SUCCESS The procedure is successful.
* @retval NRFX_ERROR_TIMEOUT Interrupt is pending on the requested channel.
*/
-nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * const p_instance, uint32_t channel);
+nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * p_instance, uint32_t channel);
/**
* @brief Function for enabling the TICK event.
@@ -208,7 +214,7 @@ nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * const p_instance, uint32_t cha
* @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 nrfx_rtc_tick_enable(nrfx_rtc_t const * const p_instance, bool enable_irq);
+void nrfx_rtc_tick_enable(nrfx_rtc_t const * p_instance, bool enable_irq);
/**
* @brief Function for disabling the TICK event.
@@ -217,7 +223,7 @@ void nrfx_rtc_tick_enable(nrfx_rtc_t const * const p_instance, bool enable_irq);
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_rtc_tick_disable(nrfx_rtc_t const * const p_instance);
+void nrfx_rtc_tick_disable(nrfx_rtc_t const * p_instance);
/**
* @brief Function for enabling overflow.
@@ -227,7 +233,7 @@ void nrfx_rtc_tick_disable(nrfx_rtc_t const * const p_instance);
* @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 nrfx_rtc_overflow_enable(nrfx_rtc_t const * const p_instance, bool enable_irq);
+void nrfx_rtc_overflow_enable(nrfx_rtc_t const * p_instance, bool enable_irq);
/**
* @brief Function for disabling overflow.
@@ -236,7 +242,7 @@ void nrfx_rtc_overflow_enable(nrfx_rtc_t const * const p_instance, bool enable_i
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_rtc_overflow_disable(nrfx_rtc_t const * const p_instance);
+void nrfx_rtc_overflow_disable(nrfx_rtc_t const * p_instance);
/**
* @brief Function for getting the maximum relative tick value that can be set in the compare channel.
@@ -251,7 +257,7 @@ void nrfx_rtc_overflow_disable(nrfx_rtc_t const * const p_instance);
*
* @return Maximum ticks value.
*/
-uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * const p_instance);
+uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * p_instance);
/**
* @brief Function for disabling all instance interrupts.
@@ -259,8 +265,8 @@ uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * const p_instance);
* @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 nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
- uint32_t * p_mask);
+NRFX_STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * p_instance,
+ uint32_t * p_mask);
/**
* @brief Function for enabling instance interrupts.
@@ -268,7 +274,7 @@ __STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] mask Mask of interrupts to enable.
*/
-__STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * const p_instance, uint32_t mask);
+NRFX_STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * p_instance, uint32_t mask);
/**
* @brief Function for retrieving the current counter value.
@@ -277,14 +283,14 @@ __STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * const p_instance, ui
*
* @return Counter value.
*/
-__STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * const p_instance);
+NRFX_STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * p_instance);
/**
* @brief Function for clearing the counter value.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-__STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * const p_instance);
+NRFX_STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * p_instance);
/**
* @brief Function for returning a requested task address for the RTC driver instance.
@@ -296,8 +302,8 @@ __STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * const p_instance)
*
* @return Address of task register.
*/
-__STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * const p_instance,
- nrf_rtc_task_t task);
+NRFX_STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * p_instance,
+ nrf_rtc_task_t task);
/**
* @brief Function for returning a requested event address for the RTC driver instance.
@@ -309,15 +315,14 @@ __STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * const p_in
*
* @return Address of event register.
*/
-__STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * const p_instance,
- nrf_rtc_event_t event);
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
+NRFX_STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * p_instance,
+ nrf_rtc_event_t event);
-__STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
- uint32_t * p_mask)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * p_instance,
+ uint32_t * p_mask)
{
- *p_mask = nrf_rtc_int_get(p_instance->p_reg);
+ *p_mask = nrf_rtc_int_enable_check(p_instance->p_reg, ~0uL);
nrf_rtc_int_disable(p_instance->p_reg, NRF_RTC_INT_TICK_MASK |
NRF_RTC_INT_OVERFLOW_MASK |
NRF_RTC_INT_COMPARE0_MASK |
@@ -326,33 +331,33 @@ __STATIC_INLINE void nrfx_rtc_int_disable(nrfx_rtc_t const * const p_instance,
NRF_RTC_INT_COMPARE3_MASK);
}
-__STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * const p_instance, uint32_t mask)
+NRFX_STATIC_INLINE void nrfx_rtc_int_enable(nrfx_rtc_t const * p_instance, uint32_t mask)
{
nrf_rtc_int_enable(p_instance->p_reg, mask);
}
-__STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * const p_instance)
+NRFX_STATIC_INLINE uint32_t nrfx_rtc_counter_get(nrfx_rtc_t const * p_instance)
{
return nrf_rtc_counter_get(p_instance->p_reg);
}
-__STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * const p_instance)
+NRFX_STATIC_INLINE void nrfx_rtc_counter_clear(nrfx_rtc_t const * p_instance)
{
nrf_rtc_task_trigger(p_instance->p_reg, NRF_RTC_TASK_CLEAR);
}
-__STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * const p_instance,
- nrf_rtc_task_t task)
+NRFX_STATIC_INLINE uint32_t nrfx_rtc_task_address_get(nrfx_rtc_t const * p_instance,
+ nrf_rtc_task_t task)
{
return nrf_rtc_task_address_get(p_instance->p_reg, task);
}
-__STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * const p_instance,
- nrf_rtc_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_rtc_event_address_get(nrfx_rtc_t const * p_instance,
+ nrf_rtc_event_t event)
{
return nrf_rtc_event_address_get(p_instance->p_reg, event);
}
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_saadc.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_saadc.h
index addb974..82f7d03 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_saadc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_saadc.h
@@ -46,80 +46,128 @@ extern "C" {
* @brief Successive Approximation Analog-to-Digital Converter (SAADC) peripheral driver.
*/
-/** @brief Value to be set as high limit to disable limit detection. */
-#define NRFX_SAADC_LIMITH_DISABLED (2047)
-/** @brief Value to be set as low limit to disable limit detection. */
-#define NRFX_SAADC_LIMITL_DISABLED (-2048)
-/** @brief Macro for setting @ref nrfx_saadc_config_t to default settings. */
-#define NRFX_SAADC_DEFAULT_CONFIG \
-{ \
- .resolution = (nrf_saadc_resolution_t)NRFX_SAADC_CONFIG_RESOLUTION, \
- .oversample = (nrf_saadc_oversample_t)NRFX_SAADC_CONFIG_OVERSAMPLE, \
- .interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY, \
- .low_power_mode = NRFX_SAADC_CONFIG_LP_MODE \
+/**
+ * @brief SAADC channel default configuration for the single-ended mode.
+ *
+ * This configuration sets up single-ended SAADC channel with the following options:
+ * - resistor ladder disabled
+ * - gain: 1/6
+ * - reference voltage: internal 0.6 V
+ * - sample acquisition time: 10 us
+ * - burst disabled
+ *
+ * @param[in] _pin_p Positive input analog pin.
+ * @param[in] _index Channel index.
+ *
+ * @sa nrfx_saadc_channel_t
+ */
+#define NRFX_SAADC_DEFAULT_CHANNEL_SE(_pin_p, _index) \
+{ \
+ .channel_config = \
+ { \
+ .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, \
+ .channel_index = _index, \
}
/**
- * @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
- * in single-ended mode.
+ * @brief SAADC channel default configuration for the differential mode.
*
- * @param PIN_P Analog input.
+ * This configuration sets up differential SAADC channel with the following options:
+ * - resistor ladder disabled
+ * - gain: 1/6
+ * - reference voltage: internal 0.6 V
+ * - sample acquisition time: 10 us
+ * - burst disabled
+ *
+ * @param[in] _pin_p Positive input analog pin.
+ * @param[in] _pin_n Negative input analog pin.
+ * @param[in] _index Channel index.
+ *
+ * @sa nrfx_saadc_channel_t
*/
-#define NRFX_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 \
+#define NRFX_SAADC_DEFAULT_CHANNEL_DIFFERENTIAL(_pin_p, _pin_n, _index) \
+{ \
+ .channel_config = \
+ { \
+ .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, \
+ .burst = NRF_SAADC_BURST_DISABLED, \
+ }, \
+ .pin_p = (nrf_saadc_input_t)_pin_p, \
+ .pin_n = (nrf_saadc_input_t)_pin_n, \
+ .channel_index = _index, \
}
/**
- * @brief Macro for setting @ref nrf_saadc_channel_config_t to default settings
- * in differential mode.
+ * @brief SAADC driver advanced mode default configuration.
+ *
+ * This configuration sets up advanced mode of the SAADC driver with the following options:
+ * - oversampling disabled
+ * - burst disabled
+ * - internal sampling timer disabled
+ * - triggering of the START task on the END event disabled
*
- * @param PIN_P Positive analog input.
- * @param PIN_N Negative analog input.
+ * @param[in] _pin_p Positive input analog pin.
+ * @param[in] _pin_n Negative input analog pin.
+ * @param[in] _index Channel index.
+ *
+ * @sa nrfx_saadc_adv_config_t
*/
-#define NRFX_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, \
- .burst = NRF_SAADC_BURST_DISABLED, \
- .pin_p = (nrf_saadc_input_t)(PIN_P), \
- .pin_n = (nrf_saadc_input_t)(PIN_N) \
+#define NRFX_SAADC_DEFAULT_ADV_CONFIG \
+{ \
+ .oversampling = NRF_SAADC_OVERSAMPLE_DISABLED, \
+ .burst = NRF_SAADC_BURST_DISABLED, \
+ .internal_timer_cc = 0, \
+ .start_on_end = false, \
}
-/** @brief SAADC driver configuration structure. */
+/** @brief SAADC channel 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.
-} nrfx_saadc_config_t;
+ nrf_saadc_channel_config_t channel_config; ///< Channel hardware configuration.
+ nrf_saadc_input_t pin_p; ///< Input positive pin selection.
+ nrf_saadc_input_t pin_n; ///< Input negative pin selection.
+ uint8_t channel_index; ///< Channel index.
+} nrfx_saadc_channel_t;
+
+/** @brief SAADC driver advanced mode configuration structure. */
+typedef struct
+{
+ nrf_saadc_oversample_t oversampling; ///< Oversampling configuration.
+ nrf_saadc_burst_t burst; ///< Burst configuration.
+ uint16_t internal_timer_cc; ///< Internal timer capture and compare value.
+ bool start_on_end; ///< Flag indicating if the START task is to be triggered on the END event.
+} nrfx_saadc_adv_config_t;
/** @brief SAADC driver event types. */
typedef enum
{
- NRFX_SAADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
- NRFX_SAADC_EVT_LIMIT, ///< Event generated after one of the limits is reached.
- NRFX_SAADC_EVT_CALIBRATEDONE ///< Event generated when the calibration is complete.
+ NRFX_SAADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
+ NRFX_SAADC_EVT_LIMIT, ///< Event generated when one of the limits is reached.
+ NRFX_SAADC_EVT_CALIBRATEDONE, ///< Event generated when the calibration is complete.
+ NRFX_SAADC_EVT_BUF_REQ, ///< Event generated when the next buffer for continuous conversion is requested.
+ NRFX_SAADC_EVT_READY, ///< Event generated when the first buffer is acquired by the peripheral and sampling can be started.
+ NRFX_SAADC_EVT_FINISHED, ///< Event generated when all supplied buffers are filled with results.
} nrfx_saadc_evt_type_t;
/** @brief SAADC driver done event data. */
typedef struct
{
- nrf_saadc_value_t * p_buffer; ///< Pointer to buffer with converted samples.
+ nrf_saadc_value_t * p_buffer; ///< Pointer to the buffer with converted samples.
uint16_t size; ///< Number of samples in the buffer.
} nrfx_saadc_done_evt_t;
@@ -144,129 +192,137 @@ typedef struct
/**
* @brief SAADC driver event handler.
*
+ * When operating in the advanced mode:
+ * - when the sampling is performed by the external timer, the external timer can be safely started
+ * on @ref NRFX_SAADC_EVT_READY and stopped on @ref NRFX_SAADC_EVT_FINISHED.
+ * - call the @ref nrfx_saadc_buffer_set() on @ref NRFX_SAADC_EVT_BUF_REQ to achieve the continuous conversion.
+ *
* @param[in] p_event Pointer to an SAADC driver event. The event structure is allocated on
* the stack, so it is valid only within the context of the event handler.
*/
typedef void (* nrfx_saadc_event_handler_t)(nrfx_saadc_evt_t const * p_event);
/**
- * @brief Function for initializing the SAADC.
+ * @brief Function for initializing the SAADC driver.
*
- * @param[in] p_config Pointer to the structure with initial configuration.
- * @param[in] event_handler Event handler provided by the user.
- * Must not be NULL.
+ * @param[in] interrupt_priority Interrupt priority.
*
* @retval NRFX_SUCCESS Initialization was successful.
* @retval NRFX_ERROR_INVALID_STATE The driver is already initialized.
*/
-nrfx_err_t nrfx_saadc_init(nrfx_saadc_config_t const * p_config,
- nrfx_saadc_event_handler_t event_handler);
+nrfx_err_t nrfx_saadc_init(uint8_t interrupt_priority);
/**
- * @brief Function for uninitializing the SAADC.
+ * @brief Function for uninitializing the SAADC driver.
*
* This function stops all ongoing conversions and disables all channels.
*/
void nrfx_saadc_uninit(void);
-
/**
- * @brief Function for getting the address of a SAMPLE SAADC task.
+ * @brief Function for configuring the SAADC channels.
*
- * @return Task address.
- */
-uint32_t nrfx_saadc_sample_task_get(void);
-
-/**
- * @brief Function for initializing an SAADC channel.
- *
- * This function configures and enables the channel.
+ * @note The values of the @ref nrf_saadc_channel_config_t.burst fields in channel configurations
+ * are ignored. They will be overridden with the value suitable for the selected driver
+ * operation mode.
+ * @note The desired mode (simple or advanced) must be set after the channels are configured.
*
- * @param[in] channel Channel index.
- * @param[in] p_config Pointer to the structure with the initial configuration.
+ * @param[in] p_channels Pointer to the array of channel configuration structures.
+ * @param[in] channel_count Number of channels to be configured.
*
- * @retval NRFX_SUCCESS Initialization was successful.
- * @retval NRFX_ERROR_INVALID_STATE The SAADC was not initialized.
- * @retval NRFX_ERROR_NO_MEM The specified channel was already allocated.
+ * @retval NRFX_SUCCESS Configuration was successful.
+ * @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
+ * @retval NRFX_ERROR_INVALID_PARAM Attempt to configure the same channel more than once.
*/
-nrfx_err_t nrfx_saadc_channel_init(uint8_t channel,
- nrf_saadc_channel_config_t const * const p_config);
+nrfx_err_t nrfx_saadc_channels_config(nrfx_saadc_channel_t const * p_channels,
+ uint32_t channel_count);
/**
- * @brief Function for uninitializing an SAADC channel.
+ * @brief Function for setting the SAADC driver in the simple mode.
*
- * @param[in] channel Channel index.
+ * The simple mode allows obtaining a single sample from each requested channel.
+ * The conversion can be done in a blocking or non-blocking manner.
+ * Sampling is initiated by calling @ref nrfx_saadc_mode_trigger() once.
*
- * @retval NRFX_SUCCESS Uninitialization was successful.
- * @retval NRFX_ERROR_BUSY The SAADC is busy.
- */
-nrfx_err_t nrfx_saadc_channel_uninit(uint8_t channel);
-
-/**
- * @brief Function for starting the SAADC sampling.
+ * @param[in] channel_mask Bitmask of channels to be used in the simple mode.
+ * @param[in] resolution Resolution configuration.
+ * @param[in] oversampling Oversampling configuration.
+ * @param[in] event_handler Event handler provided by the user. In case of providing NULL,
+ * the conversion will be performed in the blocking manner.
*
- * @retval NRFX_SUCCESS The SAADC sampling was triggered.
- * @retval NRFX_ERROR_INVALID_STATE The SAADC is in idle state.
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
+ * @retval NRFX_ERROR_INVALID_PARAM Attempt to activate channel that is not configured.
*/
-nrfx_err_t nrfx_saadc_sample(void);
+nrfx_err_t nrfx_saadc_simple_mode_set(uint32_t channel_mask,
+ nrf_saadc_resolution_t resolution,
+ nrf_saadc_oversample_t oversampling,
+ nrfx_saadc_event_handler_t event_handler);
/**
- * @brief Blocking function for executing a single SAADC conversion.
+ * @brief Function for setting the SAADC driver in the advanced mode.
*
- * This function selects the desired input, starts a single conversion,
- * waits for it to finish, and returns the result.
+ * The advanced mode allows performing double-buffered conversions of arbitrary length.
+ * The conversions can be done in a blocking or non-blocking manner. When performing conversions
+ * in the non-blocking manner and @ref nrfx_saadc_adv_config_t.internal_timer_cc is set to 0,
+ * sampling needs to be done by triggering @ref NRF_SAADC_TASK_SAMPLE externally
+ * (for example by using the TIMER and/or the PPI/DPPI).
+ * When performing conversions in the non-blocking manner and @ref nrfx_saadc_adv_config_t.start_on_end
+ * is false, the @ref NRF_SAADC_TASK_START needs to be triggered on @ref NRF_SAADC_EVENT_END
+ * externally (for example by using the PPI/DPPI).
+ * Sampling is initiated by calling @ref nrfx_saadc_mode_trigger(). In case of performing
+ * conversions in the blocking manner, @ref nrfx_saadc_mode_trigger() may need to be called several
+ * times as each call sample each requested channel once.
*
- * The function fails if the SAADC is busy.
+ * @note The internal timer can only be used when a single input channel is enabled.
+ * @note The internal timer can only be used in the non-blocking mode.
*
- * @param[in] channel Channel.
- * @param[out] p_value Pointer to the location where the result is to be placed.
+ * @param[in] channel_mask Bitmask of channels to be used in the advanced mode.
+ * @param[in] resolution Resolution configuration.
+ * @param[in] p_config Pointer to the structure with the advanced mode configuration.
+ * @param[in] event_handler Event handler provided by the user. In case of providing NULL,
+ * the conversion will be performed in the blocking manner.
*
- * @retval NRFX_SUCCESS The conversion was successful.
- * @retval NRFX_ERROR_BUSY The SAADC driver is busy.
- */
-nrfx_err_t nrfx_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 SAADC is in idle state, the
- * function will set up EasyDMA for the conversion. The SAADC will be ready for sampling and wait
- * for the SAMPLE task. It can be triggered manually by the @ref nrfx_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 NRFX_SUCCESS The conversion was successful.
- * @retval NRFX_ERROR_BUSY The driver already has two buffers set or the calibration is in progress.
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
+ * @retval NRFX_ERROR_INVALID_PARAM Attempt to activate channel that is not configured.
+ * @retval NRFX_ERROR_NOT_SUPPORTED Attempt to activate internal timer or oversampling without burst
+ * with multiple channels enabled.
*/
-nrfx_err_t nrfx_saadc_buffer_convert(nrf_saadc_value_t * buffer, uint16_t size);
+nrfx_err_t nrfx_saadc_advanced_mode_set(uint32_t channel_mask,
+ nrf_saadc_resolution_t resolution,
+ nrfx_saadc_adv_config_t const * p_config,
+ nrfx_saadc_event_handler_t event_handler);
/**
- * @brief Function for triggering the SAADC 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.
+ * @brief Function for supplying the buffer to be used in the next part of
+ * the conversion.
*
- * The function will fail if the SAADC is busy or calibration is already in progress.
+ * @param[in] p_buffer Pointer to the buffer to be filled with conversion results.
+ * @param[in] size Number of @ref nrf_saadc_value_t samples in buffer.
*
- * @retval NRFX_SUCCESS The calibration was started successfully.
- * @retval NRFX_ERROR_BUSY The SAADC driver is busy.
+ * @retval NRFX_SUCCESS Buffer was supplied successfully.
+ * @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not in the Data RAM region.
+ * @retval NRFX_ERROR_INVALID_LENGTH The provided buffer is not aligned to the number of activated channels
+ * or is too long for the EasyDMA to handle.
+ * @retval NRFX_ERROR_INVALID_STATE The driver is in the idle mode.
+ * @retval NRFX_ERROR_ALREADY_INITIALIZED Both buffers for double-buffered conversions are already set.
*/
-nrfx_err_t nrfx_saadc_calibrate_offset(void);
+nrfx_err_t nrfx_saadc_buffer_set(nrf_saadc_value_t * p_buffer, uint16_t size);
/**
- * @brief Function for retrieving the SAADC state.
+ * @brief Function for triggering the conversion in the configured mode.
*
- * @retval true The SAADC is busy.
- * @retval false The SAADC is ready.
+ * @retval NRFX_SUCCESS Operation finished successfully in the blocking manner or started
+ * successfully in the non-blocking manner.
+ * @retval NRFX_ERROR_BUSY The driver is performing the conversion in the advanced blocking mode.
+ * Call the function again to continue the conversion.
+ * @retval NRFX_ERROR_NO_MEM There is no buffer provided.
+ * Supply the buffer using @ref nrfx_saadc_buffer_set() and try again.
+ * @retval NRFX_ERROR_INVALID_STATE There is an ongoing conversion being performed in the non-blocking manner
+ * or the driver is in the idle mode.
*/
-bool nrfx_saadc_is_busy(void);
+nrfx_err_t nrfx_saadc_mode_trigger(void);
/**
* @brief Function for aborting the ongoing and buffered conversions.
@@ -278,27 +334,47 @@ void nrfx_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 NRFX_SAADC_LIMITL_DISABLED to
- * @ref NRFX_SAADC_LIMITH_DISABLED). Conversion results below this value will
- * trigger the handler function. Set to @ref NRFX_SAADC_LIMITL_DISABLED
- * to disable this limit.
- * @param[in] limit_high Upper limit (valid values from @ref NRFX_SAADC_LIMITL_DISABLED to
- * @ref NRFX_SAADC_LIMITH_DISABLED). Conversion results above this value will
- * trigger the handler function. Set to @ref NRFX_SAADC_LIMITH_DISABLED
- * to disable this limit.
+ *
+ * When limits are enabled and the conversion result exceeds the defined bounds,
+ * the handler function is called with the corresponding event as parameter.
+ *
+ * @note Before the limits are set, the driver operation mode (simple or advanced) has
+ * to be configured. Only non-blocking conversions can be monitored.
+ *
+ * @note Changing of the driver operation mode disables all configured limits.
+ *
+ * @param[in] channel Channel index.
+ * @param[in] limit_low Limit low value to generate interrupt. Use @c INT16_MIN
+ * to disable interrupt generation.
+ * @param[in] limit_high Limit high value to generate interrupt. Use @c INT16_MAX
+ * to disable interrupt generation.
+ *
+ * @retval NRFX_SUCCESS Requested channel limits were set.
+ * @retval NRFX_ERROR_INVALID_PARAM Attempt to activate the limits on disabled channel.
+ * @retval NRFX_ERROR_FORBIDDEN Attempt to activate the limits for blocking conversions.
+ * @retval NRFX_ERROR_INVALID_STATE Attempt to activate the limits without configured mode.
*/
-void nrfx_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high);
+nrfx_err_t nrfx_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high);
-/** @} */
+/**
+ * @brief Function for starting the SAADC offset calibration.
+ *
+ * @note This function cancels the currently selected driver operation mode, if any.
+ * The desired mode (simple or advanced) must be set after the calibration process completes.
+ *
+ * @param[in] event_handler Event handler provided by the user. In case of providing NULL,
+ * the calibration will be performed in the blocking manner.
+ *
+ * @retval NRFX_SUCCESS Calibration finished successfully in the blocking manner
+ * or started successfully in the non-blocking manner.
+ * @retval NRFX_ERROR_BUSY There is a conversion or calibration ongoing.
+ */
+nrfx_err_t nrfx_saadc_offset_calibrate(nrfx_saadc_event_handler_t event_handler);
+/** @} */
void nrfx_saadc_irq_handler(void);
-
#ifdef __cplusplus
}
#endif
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spi.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spi.h
index 9128a2f..3dea9f0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spi.h
@@ -34,6 +34,7 @@
#include <nrfx.h>
#include <hal/nrf_spi.h>
+#include <hal/nrf_gpio.h>
#ifdef __cplusplus
extern "C" {
@@ -53,6 +54,7 @@ typedef struct
uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only.
} nrfx_spi_t;
+#ifndef __NRFX_DOXYGEN__
enum {
#if NRFX_CHECK(NRFX_SPI0_ENABLED)
NRFX_SPI0_INST_IDX,
@@ -65,6 +67,7 @@ enum {
#endif
NRFX_SPI_ENABLED_COUNT
};
+#endif
/** @brief Macro for creating an instance of the SPI master driver. */
#define NRFX_SPI_INSTANCE(id) \
@@ -103,20 +106,33 @@ typedef struct
nrf_spi_frequency_t frequency; ///< SPI frequency.
nrf_spi_mode_t mode; ///< SPI mode.
nrf_spi_bit_order_t bit_order; ///< SPI bit order.
+ nrf_gpio_pin_pull_t miso_pull; ///< MISO pull up configuration.
} nrfx_spi_config_t;
-/** @brief SPI master instance default configuration. */
-#define NRFX_SPI_DEFAULT_CONFIG \
-{ \
- .sck_pin = NRFX_SPI_PIN_NOT_USED, \
- .mosi_pin = NRFX_SPI_PIN_NOT_USED, \
- .miso_pin = NRFX_SPI_PIN_NOT_USED, \
- .ss_pin = NRFX_SPI_PIN_NOT_USED, \
- .irq_priority = NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .orc = 0xFF, \
- .frequency = NRF_SPI_FREQ_4M, \
- .mode = NRF_SPI_MODE_0, \
- .bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
+/**
+ * @brief SPI master instance default configuration.
+ * This configuration sets up SPI with the following options:
+ * - over-run character set to 0xFF
+ * - clock frequency 4 MHz
+ * - mode 0 enabled (SCK active high, sample on leading edge of clock)
+ * - MSB shifted out first
+ *
+ * @param[in] _pin_sck SCK pin.
+ * @param[in] _pin_mosi MOSI pin.
+ * @param[in] _pin_miso MISO pin.
+ * @param[in] _pin_ss SS pin.
+ */
+#define NRFX_SPI_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_ss) \
+{ \
+ .sck_pin = _pin_sck, \
+ .mosi_pin = _pin_mosi, \
+ .miso_pin = _pin_miso, \
+ .ss_pin = _pin_ss, \
+ .irq_priority = NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .orc = 0xFF, \
+ .frequency = NRF_SPI_FREQ_4M, \
+ .mode = NRF_SPI_MODE_0, \
+ .bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
}
/** @brief Single transfer descriptor structure. */
@@ -191,7 +207,7 @@ typedef void (* nrfx_spi_evt_handler_t)(nrfx_spi_evt_t const * p_event,
* possible only if @ref nrfx_prs module
* is enabled.
*/
-nrfx_err_t nrfx_spi_init(nrfx_spi_t const * const p_instance,
+nrfx_err_t nrfx_spi_init(nrfx_spi_t const * p_instance,
nrfx_spi_config_t const * p_config,
nrfx_spi_evt_handler_t handler,
void * p_context);
@@ -201,7 +217,7 @@ nrfx_err_t nrfx_spi_init(nrfx_spi_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_spi_uninit(nrfx_spi_t const * const p_instance);
+void nrfx_spi_uninit(nrfx_spi_t const * p_instance);
/**
* @brief Function for starting the SPI data transfer.
@@ -220,7 +236,7 @@ void nrfx_spi_uninit(nrfx_spi_t const * const p_instance);
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
* @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
*/
-nrfx_err_t nrfx_spi_xfer(nrfx_spi_t const * const p_instance,
+nrfx_err_t nrfx_spi_xfer(nrfx_spi_t const * p_instance,
nrfx_spi_xfer_desc_t const * p_xfer_desc,
uint32_t flags);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spim.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spim.h
index 3efd4bd..5c22db3 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spim.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spim.h
@@ -34,6 +34,7 @@
#include <nrfx.h>
#include <hal/nrf_spim.h>
+#include <hal/nrf_gpio.h>
#ifdef __cplusplus
extern "C" {
@@ -88,67 +89,90 @@ enum {
/** @brief Configuration structure of the SPIM driver instance. */
typedef struct
{
- uint8_t sck_pin; ///< SCK pin number.
- uint8_t mosi_pin; ///< MOSI pin number (optional).
- /**< Set to @ref NRFX_SPIM_PIN_NOT_USED
- * if this signal is not needed. */
- uint8_t miso_pin; ///< MISO pin number (optional).
- /**< Set to @ref NRFX_SPIM_PIN_NOT_USED
- * if this signal is not needed. */
- uint8_t ss_pin; ///< Slave Select pin number (optional).
- /**< Set to @ref NRFX_SPIM_PIN_NOT_USED
- * if this signal is not needed. */
- bool ss_active_high; ///< Polarity of the Slave Select pin during transmission.
- uint8_t irq_priority; ///< Interrupt priority.
- uint8_t orc; ///< Overrun character.
- /**< This character is used when all bytes from the TX buffer are sent,
- but the transfer continues due to RX. */
- nrf_spim_frequency_t frequency; ///< SPIM frequency.
- nrf_spim_mode_t mode; ///< SPIM mode.
- nrf_spim_bit_order_t bit_order; ///< SPIM bit order.
+ uint8_t sck_pin; ///< SCK pin number.
+ uint8_t mosi_pin; ///< MOSI pin number (optional).
+ /**< Set to @ref NRFX_SPIM_PIN_NOT_USED
+ * if this signal is not needed. */
+ uint8_t miso_pin; ///< MISO pin number (optional).
+ /**< Set to @ref NRFX_SPIM_PIN_NOT_USED
+ * if this signal is not needed. */
+ uint8_t ss_pin; ///< Slave Select pin number (optional).
+ /**< Set to @ref NRFX_SPIM_PIN_NOT_USED
+ * if this signal is not needed. */
+ bool ss_active_high; ///< Polarity of the Slave Select pin during transmission.
+ uint8_t irq_priority; ///< Interrupt priority.
+ uint8_t orc; ///< Overrun character.
+ /**< This character is used when all bytes from the TX buffer are sent,
+ but the transfer continues due to RX. */
+ nrf_spim_frequency_t frequency; ///< SPIM frequency.
+ nrf_spim_mode_t mode; ///< SPIM mode.
+ nrf_spim_bit_order_t bit_order; ///< SPIM bit order.
+ nrf_gpio_pin_pull_t miso_pull; ///< MISO pull up configuration.
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__)
- uint8_t dcx_pin; ///< D/CX pin number (optional).
- uint8_t rx_delay; ///< Sample delay for input serial data on MISO.
- /**< The value specifies the delay, in number of 64 MHz clock cycles
- * (15.625 ns), 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. */
- bool use_hw_ss; ///< Indication to use software or hardware controlled Slave Select pin.
- uint8_t ss_duration; ///< Slave Select duration before and after transmission.
- /**< Minimum duration between the edge of CSN and the edge of SCK and minimum
- * duration of CSN must stay inactive between transactions.
- * The value is specified in number of 64 MHz clock cycles (15.625 ns).
- * Supported only for hardware-controlled Slave Select. */
+ uint8_t dcx_pin; ///< D/CX pin number (optional).
+ uint8_t rx_delay; ///< Sample delay for input serial data on MISO.
+ /**< The value specifies the delay, in number of 64 MHz clock cycles
+ * (15.625 ns), 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. */
+ bool use_hw_ss; ///< Indication to use software or hardware controlled Slave Select pin.
+ uint8_t ss_duration; ///< Slave Select duration before and after transmission.
+ /**< Minimum duration between the edge of CSN and the edge of SCK.
+ * Also, minimum duration of CSN inactivity between transactions.
+ * The value is specified in number of 64 MHz clock cycles (15.625 ns).
+ * Supported only for hardware-controlled Slave Select. */
#endif
} nrfx_spim_config_t;
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__)
/**
- * @brief Extended default configuration of the SPIM instance.
+ * @brief SPIM driver extended default configuration.
+ *
+ * This configuration sets up SPIM additional options with the following values:
+ * - DCX pin disabled
+ * - RX sampling delay: 2 clock cycles
+ * - hardware SS disabled
+ * - hardware SS duration before and after transmission: 2 clock cycles
*/
- #define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
- .dcx_pin = NRFX_SPIM_PIN_NOT_USED, \
- .rx_delay = 0x02, \
- .use_hw_ss = false, \
- .ss_duration = 0x02,
+#define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
+ .dcx_pin = NRFX_SPIM_PIN_NOT_USED, \
+ .rx_delay = 0x02, \
+ .use_hw_ss = false, \
+ .ss_duration = 0x02,
#else
#define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG
#endif
-/** @brief The default configuration of the SPIM master instance. */
-#define NRFX_SPIM_DEFAULT_CONFIG \
-{ \
- .sck_pin = NRFX_SPIM_PIN_NOT_USED, \
- .mosi_pin = NRFX_SPIM_PIN_NOT_USED, \
- .miso_pin = NRFX_SPIM_PIN_NOT_USED, \
- .ss_pin = NRFX_SPIM_PIN_NOT_USED, \
- .ss_active_high = false, \
- .irq_priority = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .orc = 0xFF, \
- .frequency = NRF_SPIM_FREQ_4M, \
- .mode = NRF_SPIM_MODE_0, \
- .bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \
- NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
+/**
+ * @brief SPIM driver default configuration.
+ *
+ * This configuration sets up SPIM with the following options:
+ * - SS pin active low
+ * - over-run character set to 0xFF
+ * - clock frequency: 4 MHz
+ * - mode: 0 (SCK active high, sample on leading edge of the clock signa;)
+ * - MSB shifted out first
+ * - MISO pull-up disabled
+ *
+ * @param[in] _pin_sck SCK pin.
+ * @param[in] _pin_mosi MOSI pin.
+ * @param[in] _pin_miso MISO pin.
+ * @param[in] _pin_ss SS pin.
+ */
+#define NRFX_SPIM_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_ss) \
+{ \
+ .sck_pin = _pin_sck, \
+ .mosi_pin = _pin_mosi, \
+ .miso_pin = _pin_miso, \
+ .ss_pin = _pin_ss, \
+ .ss_active_high = false, \
+ .irq_priority = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .orc = 0xFF, \
+ .frequency = NRF_SPIM_FREQ_4M, \
+ .mode = NRF_SPIM_MODE_0, \
+ .bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \
+ .miso_pull = NRF_GPIO_PIN_NOPULL, \
+ NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \
}
/** @brief Flag indicating that TX buffer address will be incremented after transfer. */
@@ -236,7 +260,7 @@ typedef void (* nrfx_spim_evt_handler_t)(nrfx_spim_evt_t const * p_event,
* @retval NRFX_ERROR_NOT_SUPPORTED Requested configuration is not supported
* by the SPIM instance.
*/
-nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
+nrfx_err_t nrfx_spim_init(nrfx_spim_t const * p_instance,
nrfx_spim_config_t const * p_config,
nrfx_spim_evt_handler_t handler,
void * p_context);
@@ -246,7 +270,7 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_spim_uninit(nrfx_spim_t const * const p_instance);
+void nrfx_spim_uninit(nrfx_spim_t const * p_instance);
/**
* @brief Function for starting the SPIM data transfer.
@@ -290,7 +314,7 @@ void nrfx_spim_uninit(nrfx_spim_t const * const p_instance);
* @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data
* RAM region.
*/
-nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * const p_instance,
+nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * p_instance,
nrfx_spim_xfer_desc_t const * p_xfer_desc,
uint32_t flags);
@@ -323,7 +347,7 @@ nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * const p_instance,
* @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data
* RAM region.
*/
-nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * const p_instance,
+nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * p_instance,
nrfx_spim_xfer_desc_t const * p_xfer_desc,
uint32_t flags,
uint8_t cmd_length);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spis.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spis.h
index aa68ce4..442901f 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spis.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_spis.h
@@ -86,11 +86,6 @@ enum {
*/
#define NRFX_SPIS_PIN_NOT_USED 0xFF
-/** @brief Default pull-up configuration of the SPI CS. */
-#define NRFX_SPIS_DEFAULT_CSN_PULLUP NRF_GPIO_PIN_NOPULL
-/** @brief Default drive configuration of the SPI MISO. */
-#define NRFX_SPIS_DEFAULT_MISO_DRIVE NRF_GPIO_PIN_S0S1
-
/** @brief SPI slave driver event types. */
typedef enum
{
@@ -107,20 +102,35 @@ typedef struct
size_t tx_amount; //!< Number of bytes transmitted in the last transaction. This parameter is only valid for @ref NRFX_SPIS_XFER_DONE events.
} nrfx_spis_evt_t;
-/** @brief The default configuration of the SPI slave instance. */
-#define NRFX_SPIS_DEFAULT_CONFIG \
-{ \
- .miso_pin = NRFX_SPIS_PIN_NOT_USED, \
- .mosi_pin = NRFX_SPIS_PIN_NOT_USED, \
- .sck_pin = NRFX_SPIS_PIN_NOT_USED, \
- .csn_pin = NRFX_SPIS_PIN_NOT_USED, \
- .mode = NRF_SPIS_MODE_0, \
- .bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST, \
- .csn_pullup = NRFX_SPIS_DEFAULT_CSN_PULLUP, \
- .miso_drive = NRFX_SPIS_DEFAULT_MISO_DRIVE, \
- .def = NRFX_SPIS_DEFAULT_DEF, \
- .orc = NRFX_SPIS_DEFAULT_ORC, \
- .irq_priority = NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY, \
+/**
+ * @brief SPIS driver default configuration.
+ *
+ * This configuration sets up SPIS with the following options:
+ * - mode: 0 (SCK active high, sample on leading edge of the clock signal)
+ * - MSB shifted out first
+ * - CSN pull-up disabled
+ * - MISO pin drive set to standard '0' and standard '1'
+ * - default character set to 0xFF
+ * - over-read character set to 0xFE
+ *
+ * @param[in] _pin_sck SCK pin.
+ * @param[in] _pin_mosi MOSI pin.
+ * @param[in] _pin_miso MISO pin.
+ * @param[in] _pin_csn CSN pin.
+ */
+#define NRFX_SPIS_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_csn) \
+{ \
+ .miso_pin = _pin_miso, \
+ .mosi_pin = _pin_mosi, \
+ .sck_pin = _pin_sck, \
+ .csn_pin = _pin_csn, \
+ .mode = NRF_SPIS_MODE_0, \
+ .bit_order = NRF_SPIS_BIT_ORDER_MSB_FIRST, \
+ .csn_pullup = NRF_GPIO_PIN_NOPULL, \
+ .miso_drive = NRF_GPIO_PIN_S0S1, \
+ .def = 0xFF, \
+ .orc = 0xFE, \
+ .irq_priority = NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY, \
}
/** @brief SPI peripheral device configuration data. */
@@ -179,7 +189,7 @@ typedef void (*nrfx_spis_event_handler_t)(nrfx_spis_evt_t const * p_event,
* on CSN pin cannot be initialized. Possible
* only when using nRF52 Anomaly 109 workaround.
*/
-nrfx_err_t nrfx_spis_init(nrfx_spis_t const * const p_instance,
+nrfx_err_t nrfx_spis_init(nrfx_spis_t const * p_instance,
nrfx_spis_config_t const * p_config,
nrfx_spis_event_handler_t event_handler,
void * p_context);
@@ -189,7 +199,7 @@ nrfx_err_t nrfx_spis_init(nrfx_spis_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_spis_uninit(nrfx_spis_t const * const p_instance);
+void nrfx_spis_uninit(nrfx_spis_t const * p_instance);
/**
* @brief Function for preparing the SPI slave instance for a single SPI transaction.
@@ -224,11 +234,11 @@ void nrfx_spis_uninit(nrfx_spis_t const * const p_instance);
* @retval NRFX_ERROR_INVALID_LENGTH Provided lengths exceed the EasyDMA limits for the peripheral.
* @retval NRFX_ERROR_INTERNAL The operation failed because of an internal error.
*/
-nrfx_err_t nrfx_spis_buffers_set(nrfx_spis_t const * const p_instance,
- uint8_t const * p_tx_buffer,
- size_t tx_buffer_length,
- uint8_t * p_rx_buffer,
- size_t rx_buffer_length);
+nrfx_err_t nrfx_spis_buffers_set(nrfx_spis_t const * p_instance,
+ uint8_t const * p_tx_buffer,
+ size_t tx_buffer_length,
+ uint8_t * p_rx_buffer,
+ size_t rx_buffer_length);
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_swi.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_swi.h
deleted file mode 100644
index 16778a2..0000000
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_swi.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * 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 must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NRFX_SWI_H__
-#define NRFX_SWI_H__
-
-#include <nrfx.h>
-
-#if NRFX_CHECK(NRFX_EGU_ENABLED)
-#include <hal/nrf_egu.h>
-#endif
-
-#ifndef SWI_COUNT
-#define SWI_COUNT EGU_COUNT
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup nrfx_swi SWI driver
- * @{
- * @ingroup nrf_swi_egu
- *
- * @brief Driver for managing software interrupts (SWI).
- */
-
-/** @brief SWI instance. */
-typedef uint8_t nrfx_swi_t;
-
-/**
- * @brief SWI user flags.
- *
- * User flags are set during the SWI trigger and passed to the callback function as an argument.
- */
-typedef uint16_t nrfx_swi_flags_t;
-
-/** @brief Unallocated instance value. */
-#define NRFX_SWI_UNALLOCATED ((nrfx_swi_t)0xFFuL)
-
-/** @brief Default SWI priority. */
-#define NRFX_SWI_DEFAULT_PRIORITY APP_IRQ_PRIORITY_LOWEST
-
-/**
- * @brief SWI handler function.
- *
- * @param swi SWI instance.
- * @param flags User flags.
- */
-typedef void (*nrfx_swi_handler_t)(nrfx_swi_t swi, nrfx_swi_flags_t flags);
-
-/**
- * @brief Function for allocating the first unused SWI instance and setting a handler.
- *
- * If provided handler is not NULL, an allocated SWI has its interrupt enabled by default.
- * The interrupt can be disabled by @ref nrfx_swi_int_disable.
- *
- * @param[out] p_swi Points to a place where the allocated SWI instance
- * number is to be stored.
- * @param[in] event_handler Event handler function.
- * If NULL, no interrupt will be enabled.
- * It can be NULL only if the EGU driver is enabled.
- * For classic SWI, it must be a valid handler pointer.
- * @param[in] irq_priority Interrupt priority.
- *
- * @retval NRFX_SUCCESS The SWI was successfully allocated.
- * @retval NRFX_ERROR_NO_MEM There is no available SWI to be used.
- */
-nrfx_err_t nrfx_swi_alloc(nrfx_swi_t * p_swi,
- nrfx_swi_handler_t event_handler,
- uint32_t irq_priority);
-
-/**
- * @brief Function for disabling an allocated SWI interrupt.
- *
- * Use @ref nrfx_swi_int_enable to re-enable the interrupt.
- *
- * @param[in] swi SWI instance.
- */
-void nrfx_swi_int_disable(nrfx_swi_t swi);
-
-/**
- * @brief Function for enabling an allocated SWI interrupt.
- *
- * @param[in] swi SWI instance.
- */
-void nrfx_swi_int_enable(nrfx_swi_t swi);
-
-/**
- * @brief Function for freeing a previously allocated SWI.
- *
- * @param[in,out] p_swi SWI instance to free. The value is changed to
- * @ref NRFX_SWI_UNALLOCATED on success.
- */
-void nrfx_swi_free(nrfx_swi_t * p_swi);
-
-/** @brief Function for freeing all allocated SWIs. */
-void nrfx_swi_all_free(void);
-
-/**
- * @brief Function for triggering the SWI.
- *
- * @param[in] swi SWI to trigger.
- * @param[in] flag_number Number of user flag to trigger.
- */
-void nrfx_swi_trigger(nrfx_swi_t swi,
- uint8_t flag_number);
-
-/**
- * @brief Function for checking if the specified SWI is currently allocated.
- *
- * @param[in] swi SWI instance.
- *
- * @retval true The SWI instance is allocated.
- * @retval false The SWI instance is not allocated.
- */
-bool nrfx_swi_is_allocated(nrfx_swi_t swi);
-
-#if NRFX_CHECK(NRFX_EGU_ENABLED) || defined(__NRFX_DOXYGEN__)
-
-/**
- * @brief Function for returning the base address of the EGU peripheral
- * associated with the specified SWI instance.
- *
- * @param[in] swi SWI instance.
- *
- * @return EGU base address or NULL if the specified SWI instance number
- * is too high.
- */
-__STATIC_INLINE NRF_EGU_Type * nrfx_swi_egu_instance_get(nrfx_swi_t swi)
-{
-#if (EGU_COUNT < SWI_COUNT)
- if (swi >= EGU_COUNT)
- {
- return NULL;
- }
-#endif
- uint32_t offset = ((uint32_t)swi) * ((uint32_t)NRF_EGU1 - (uint32_t)NRF_EGU0);
- return (NRF_EGU_Type *)((uint32_t)NRF_EGU0 + offset);
-}
-
-/**
- * @brief Function for returning the EGU trigger task address.
- *
- * @param[in] swi SWI instance.
- * @param[in] channel Number of the EGU channel.
- *
- * @return Address of the EGU trigger task.
- */
-__STATIC_INLINE uint32_t nrfx_swi_task_trigger_address_get(nrfx_swi_t swi,
- uint8_t channel)
-{
- NRFX_ASSERT(nrfx_swi_is_allocated(swi));
-
- NRF_EGU_Type * p_egu = nrfx_swi_egu_instance_get(swi);
-#if (EGU_COUNT < SWI_COUNT)
- if (p_egu == NULL)
- {
- return 0;
- }
-#endif
-
- return (uint32_t)nrf_egu_task_trigger_address_get(p_egu, channel);
-}
-
-/**
- * @brief Function for returning the EGU-triggered event address.
- *
- * @param[in] swi SWI instance.
- * @param[in] channel Number of the EGU channel.
- *
- * @return Address of the EGU-triggered event.
- */
-__STATIC_INLINE uint32_t nrfx_swi_event_triggered_address_get(nrfx_swi_t swi,
- uint8_t channel)
-{
- NRFX_ASSERT(nrfx_swi_is_allocated(swi));
-
- NRF_EGU_Type * p_egu = nrfx_swi_egu_instance_get(swi);
-#if (EGU_COUNT < SWI_COUNT)
- if (p_egu == NULL)
- {
- return 0;
- }
-#endif
-
- return (uint32_t)nrf_egu_event_triggered_address_get(p_egu, channel);
-}
-
-#endif // NRFX_CHECK(NRFX_EGU_ENABLED) || defined(__NRFX_DOXYGEN__)
-
-/** @} */
-
-
-void nrfx_swi_0_irq_handler(void);
-void nrfx_swi_1_irq_handler(void);
-void nrfx_swi_2_irq_handler(void);
-void nrfx_swi_3_irq_handler(void);
-void nrfx_swi_4_irq_handler(void);
-void nrfx_swi_5_irq_handler(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // NRFX_SWI_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_temp.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_temp.h
index e67a9fd..95ac547 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_temp.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_temp.h
@@ -94,7 +94,7 @@ void nrfx_temp_uninit(void);
* @return Temperature measurement result in a 2's complement signed value
* representation.
*/
-__STATIC_INLINE int32_t nrfx_temp_result_get(void);
+NRFX_STATIC_INLINE int32_t nrfx_temp_result_get(void);
/**
* @brief Function for calculating the temperature value in Celsius scale from raw data.
@@ -133,14 +133,12 @@ int32_t nrfx_temp_calculate(int32_t raw_measurement);
*/
nrfx_err_t nrfx_temp_measure(void);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
-__STATIC_INLINE int32_t nrfx_temp_result_get(void)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE int32_t nrfx_temp_result_get(void)
{
return nrf_temp_result_get(NRF_TEMP);
}
-
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_timer.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_timer.h
index 057bbd2..9da6b5c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_timer.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_timer.h
@@ -95,14 +95,21 @@ typedef struct
void * p_context; ///< Context passed to interrupt handler.
} nrfx_timer_config_t;
-/** @brief Timer driver instance default configuration. */
-#define NRFX_TIMER_DEFAULT_CONFIG \
-{ \
- .frequency = (nrf_timer_frequency_t)NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY,\
- .mode = (nrf_timer_mode_t)NRFX_TIMER_DEFAULT_CONFIG_MODE, \
- .bit_width = (nrf_timer_bit_width_t)NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH,\
- .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .p_context = NULL \
+/**
+ * @brief TIMER driver default configuration.
+ *
+ * This configuration sets up TIMER with the following options:
+ * - frequency: 16 MHz
+ * - works as timer
+ * - width: 16 bit
+ */
+#define NRFX_TIMER_DEFAULT_CONFIG \
+{ \
+ .frequency = NRF_TIMER_FREQ_16MHz, \
+ .mode = NRF_TIMER_MODE_TIMER, \
+ .bit_width = NRF_TIMER_BIT_WIDTH_16, \
+ .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .p_context = NULL \
}
/**
@@ -128,7 +135,7 @@ typedef void (* nrfx_timer_event_handler_t)(nrf_timer_event_t event_type,
* @retval NRFX_SUCCESS Initialization was successful.
* @retval NRFX_ERROR_INVALID_STATE The instance is already initialized.
*/
-nrfx_err_t nrfx_timer_init(nrfx_timer_t const * const p_instance,
+nrfx_err_t nrfx_timer_init(nrfx_timer_t const * p_instance,
nrfx_timer_config_t const * p_config,
nrfx_timer_event_handler_t timer_event_handler);
@@ -137,14 +144,14 @@ nrfx_err_t nrfx_timer_init(nrfx_timer_t const * const p_instance,
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_uninit(nrfx_timer_t const * const p_instance);
+void nrfx_timer_uninit(nrfx_timer_t const * p_instance);
/**
* @brief Function for turning on the timer.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_enable(nrfx_timer_t const * const p_instance);
+void nrfx_timer_enable(nrfx_timer_t const * p_instance);
/**
* @brief Function for turning off the timer.
@@ -154,7 +161,7 @@ void nrfx_timer_enable(nrfx_timer_t const * const p_instance);
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_disable(nrfx_timer_t const * const p_instance);
+void nrfx_timer_disable(nrfx_timer_t const * p_instance);
/**
* @brief Function for checking the timer state.
@@ -164,35 +171,35 @@ void nrfx_timer_disable(nrfx_timer_t const * const p_instance);
* @retval true Timer is enabled.
* @retval false Timer is not enabled.
*/
-bool nrfx_timer_is_enabled(nrfx_timer_t const * const p_instance);
+bool nrfx_timer_is_enabled(nrfx_timer_t const * p_instance);
/**
* @brief Function for pausing the timer.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_pause(nrfx_timer_t const * const p_instance);
+void nrfx_timer_pause(nrfx_timer_t const * p_instance);
/**
* @brief Function for resuming the timer.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_resume(nrfx_timer_t const * const p_instance);
+void nrfx_timer_resume(nrfx_timer_t const * p_instance);
/**
* @brief Function for clearing the timer.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_clear(nrfx_timer_t const * const p_instance);
+void nrfx_timer_clear(nrfx_timer_t const * p_instance);
/**
* @brief Function for incrementing the timer.
*
* @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_timer_increment(nrfx_timer_t const * const p_instance);
+void nrfx_timer_increment(nrfx_timer_t const * p_instance);
/**
* @brief Function for returning the address of the specified timer task.
@@ -202,8 +209,8 @@ void nrfx_timer_increment(nrfx_timer_t const * const p_instance);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * const p_instance,
- nrf_timer_task_t timer_task);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * p_instance,
+ nrf_timer_task_t timer_task);
/**
* @brief Function for returning the address of the specified timer capture task.
@@ -213,8 +220,8 @@ __STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * const
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * const p_instance,
- uint32_t channel);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * p_instance,
+ uint32_t channel);
/**
* @brief Function for returning the address of the specified timer event.
@@ -224,8 +231,8 @@ __STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * const p_instance,
- nrf_timer_event_t timer_event);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * p_instance,
+ nrf_timer_event_t timer_event);
/**
* @brief Function for returning the address of the specified timer compare event.
@@ -235,8 +242,8 @@ __STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * const
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * const p_instance,
- uint32_t channel);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * p_instance,
+ uint32_t channel);
/**
* @brief Function for capturing the timer value.
@@ -246,8 +253,8 @@ __STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const
*
* @return Captured value.
*/
-uint32_t nrfx_timer_capture(nrfx_timer_t const * const p_instance,
- nrf_timer_cc_channel_t cc_channel);
+uint32_t nrfx_timer_capture(nrfx_timer_t const * p_instance,
+ nrf_timer_cc_channel_t cc_channel);
/**
* @brief Function for returning the capture value from the specified channel.
@@ -259,8 +266,8 @@ uint32_t nrfx_timer_capture(nrfx_timer_t const * const p_instance,
*
* @return Captured value.
*/
-__STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * const p_instance,
- nrf_timer_cc_channel_t cc_channel);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * p_instance,
+ nrf_timer_cc_channel_t cc_channel);
/**
* @brief Function for setting the timer channel in compare mode.
@@ -270,10 +277,10 @@ __STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * const p_ins
* @param[in] cc_value Compare value.
* @param[in] enable_int Enable or disable the interrupt for the compare channel.
*/
-void nrfx_timer_compare(nrfx_timer_t const * const p_instance,
- nrf_timer_cc_channel_t cc_channel,
- uint32_t cc_value,
- bool enable_int);
+void nrfx_timer_compare(nrfx_timer_t 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 the extended compare mode.
@@ -285,11 +292,11 @@ void nrfx_timer_compare(nrfx_timer_t const * const p_instance,
* and the timer task (STOP or CLEAR).
* @param[in] enable_int Enable or disable the interrupt for the compare channel.
*/
-void nrfx_timer_extended_compare(nrfx_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);
+void nrfx_timer_extended_compare(nrfx_timer_t 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.
@@ -299,8 +306,8 @@ void nrfx_timer_extended_compare(nrfx_timer_t const * const p_instance,
*
* @return Number of ticks.
*/
-__STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * const p_instance,
- uint32_t time_us);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * p_instance,
+ uint32_t time_us);
/**
* @brief Function for converting time in milliseconds to timer ticks.
@@ -310,8 +317,8 @@ __STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * const p_ins
*
* @return Number of ticks.
*/
-__STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * const p_instance,
- uint32_t time_ms);
+NRFX_STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * p_instance,
+ uint32_t time_ms);
/**
* @brief Function for enabling timer compare interrupt.
@@ -319,8 +326,8 @@ __STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t const * const p_ins
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] channel Compare channel.
*/
-void nrfx_timer_compare_int_enable(nrfx_timer_t const * const p_instance,
- uint32_t channel);
+void nrfx_timer_compare_int_enable(nrfx_timer_t const * p_instance,
+ uint32_t channel);
/**
* @brief Function for disabling timer compare interrupt.
@@ -328,59 +335,54 @@ void nrfx_timer_compare_int_enable(nrfx_timer_t const * const p_instance,
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] channel Compare channel.
*/
-void nrfx_timer_compare_int_disable(nrfx_timer_t const * const p_instance,
- uint32_t channel);
+void nrfx_timer_compare_int_disable(nrfx_timer_t const * p_instance,
+ uint32_t channel);
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
-__STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * const p_instance,
- nrf_timer_task_t timer_task)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_timer_task_address_get(nrfx_timer_t const * p_instance,
+ nrf_timer_task_t timer_task)
{
- return (uint32_t)nrf_timer_task_address_get(p_instance->p_reg, timer_task);
+ return nrf_timer_task_address_get(p_instance->p_reg, timer_task);
}
-__STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * const p_instance,
- uint32_t channel)
+NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get(nrfx_timer_t const * p_instance,
+ uint32_t channel)
{
NRFX_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));
+ return nrf_timer_task_address_get(p_instance->p_reg, nrf_timer_capture_task_get(channel));
}
-__STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * const p_instance,
- nrf_timer_event_t timer_event)
+NRFX_STATIC_INLINE uint32_t nrfx_timer_event_address_get(nrfx_timer_t const * p_instance,
+ nrf_timer_event_t timer_event)
{
- return (uint32_t)nrf_timer_event_address_get(p_instance->p_reg, timer_event);
+ return nrf_timer_event_address_get(p_instance->p_reg, timer_event);
}
-__STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * const p_instance,
- uint32_t channel)
+NRFX_STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get(nrfx_timer_t const * p_instance,
+ uint32_t channel)
{
NRFX_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));
+ return nrf_timer_event_address_get(p_instance->p_reg, nrf_timer_compare_event_get(channel));
}
-__STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * const p_instance,
- nrf_timer_cc_channel_t cc_channel)
+NRFX_STATIC_INLINE uint32_t nrfx_timer_capture_get(nrfx_timer_t const * p_instance,
+ nrf_timer_cc_channel_t cc_channel)
{
- return nrf_timer_cc_read(p_instance->p_reg, cc_channel);
+ return nrf_timer_cc_get(p_instance->p_reg, cc_channel);
}
-__STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t const * const p_instance,
- uint32_t timer_us)
+NRFX_STATIC_INLINE uint32_t nrfx_timer_us_to_ticks(nrfx_timer_t 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 nrfx_timer_ms_to_ticks(nrfx_timer_t const * const p_instance,
- uint32_t timer_ms)
+NRFX_STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks(nrfx_timer_t 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
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi.h
index a2613ff..ca1bd5a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi.h
@@ -33,6 +33,7 @@
#define NRFX_TWI_H__
#include <nrfx.h>
+#include <nrfx_twi_twim.h>
#include <hal/nrf_twi.h>
#ifdef __cplusplus
@@ -84,27 +85,39 @@ typedef struct
bool hold_bus_uninit; ///< Hold pull up state on GPIO pins after uninit.
} nrfx_twi_config_t;
-/** @brief The default configuration of the TWI master driver instance. */
-#define NRFX_TWI_DEFAULT_CONFIG \
-{ \
- .frequency = (nrf_twi_frequency_t)NRFX_TWI_DEFAULT_CONFIG_FREQUENCY, \
- .scl = 31, \
- .sda = 31, \
- .interrupt_priority = NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .hold_bus_uninit = NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \
+/**
+ * @brief TWI master driver instance default configuration.
+ *
+ * This configuration sets up TWI with the following options:
+ * - clock frequency: 100 kHz
+ * - disable bus holding after uninit
+ *
+ * @param[in] _pin_scl SCL pin.
+ * @param[in] _pin_sda SDA pin.
+ */
+#define NRFX_TWI_DEFAULT_CONFIG(_pin_scl, _pin_sda) \
+{ \
+ .scl = _pin_scl, \
+ .sda = _pin_sda, \
+ .frequency = NRF_TWI_FREQ_100K, \
+ .interrupt_priority = NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .hold_bus_uninit = false, \
}
/** @brief Flag indicating that the interrupt after each transfer will be suppressed, and the event handler will not be called. */
#define NRFX_TWI_FLAG_NO_XFER_EVT_HANDLER (1UL << 2)
/** @brief Flag indicating that the TX transfer will not end with a stop condition. */
#define NRFX_TWI_FLAG_TX_NO_STOP (1UL << 5)
+/** @brief Flag indicating that the transfer will be suspended. */
+#define NRFX_TWI_FLAG_SUSPEND (1UL << 6)
/** @brief TWI master driver event types. */
typedef enum
{
NRFX_TWI_EVT_DONE, ///< Transfer completed event.
NRFX_TWI_EVT_ADDRESS_NACK, ///< Error event: NACK received after sending the address.
- NRFX_TWI_EVT_DATA_NACK ///< Error event: NACK received after sending a data byte.
+ NRFX_TWI_EVT_DATA_NACK, ///< Error event: NACK received after sending a data byte.
+ NRFX_TWI_EVT_OVERRUN ///< Error event: The unread data is replaced by new data.
} nrfx_twi_evt_type_t;
/** @brief TWI master driver transfer types. */
@@ -131,45 +144,45 @@ typedef struct
/** @brief Macro for setting the TX transfer descriptor. */
#define NRFX_TWI_XFER_DESC_TX(addr, p_data, length) \
{ \
- .type = NRFX_TWI_XFER_TX, \
- .address = addr, \
- .primary_length = length, \
+ .type = NRFX_TWI_XFER_TX, \
+ .address = (addr), \
+ .primary_length = (length), \
.secondary_length = 0, \
- .p_primary_buf = p_data, \
+ .p_primary_buf = (p_data), \
.p_secondary_buf = NULL, \
}
/** @brief Macro for setting the RX transfer descriptor. */
#define NRFX_TWI_XFER_DESC_RX(addr, p_data, length) \
{ \
- .type = NRFX_TWI_XFER_RX, \
- .address = addr, \
- .primary_length = length, \
+ .type = NRFX_TWI_XFER_RX, \
+ .address = (addr), \
+ .primary_length = (length), \
.secondary_length = 0, \
- .p_primary_buf = p_data, \
+ .p_primary_buf = (p_data), \
.p_secondary_buf = NULL, \
}
/** @brief Macro for setting the TX-RX transfer descriptor. */
#define NRFX_TWI_XFER_DESC_TXRX(addr, p_tx, tx_len, p_rx, rx_len) \
{ \
- .type = NRFX_TWI_XFER_TXRX, \
- .address = addr, \
- .primary_length = tx_len, \
- .secondary_length = rx_len, \
- .p_primary_buf = p_tx, \
- .p_secondary_buf = p_rx, \
+ .type = NRFX_TWI_XFER_TXRX, \
+ .address = (addr), \
+ .primary_length = (tx_len), \
+ .secondary_length = (rx_len), \
+ .p_primary_buf = (p_tx), \
+ .p_secondary_buf = (p_rx), \
}
/** @brief Macro for setting the TX-TX transfer descriptor. */
#define NRFX_TWI_XFER_DESC_TXTX(addr, p_tx, tx_len, p_tx2, tx_len2) \
{ \
- .type = NRFX_TWI_XFER_TXTX, \
- .address = addr, \
- .primary_length = tx_len, \
- .secondary_length = tx_len2, \
- .p_primary_buf = p_tx, \
- .p_secondary_buf = p_tx2, \
+ .type = NRFX_TWI_XFER_TXTX, \
+ .address = (addr), \
+ .primary_length = (tx_len), \
+ .secondary_length = (tx_len2), \
+ .p_primary_buf = (p_tx), \
+ .p_secondary_buf = (p_tx2), \
}
/** @brief Structure for a TWI event. */
@@ -225,58 +238,9 @@ void nrfx_twi_enable(nrfx_twi_t const * p_instance);
void nrfx_twi_disable(nrfx_twi_t const * p_instance);
/**
- * @brief Function for sending data to a TWI slave.
- *
- * The transmission will be stopped when an error occurs. If a transfer is ongoing,
- * the function returns the error code @ref NRFX_ERROR_BUSY.
- *
- * @param[in] p_instance Pointer to the driver instance structure.
- * @param[in] address Address of a specific slave device (only 7 LSB).
- * @param[in] p_data Pointer to a transmit buffer.
- * @param[in] length Number of bytes to send.
- * @param[in] no_stop If set, the stop condition is not generated on the bus
- * after the transfer has completed successfully (allowing
- * for a repeated start in the next transfer).
- *
- * @retval NRFX_SUCCESS The procedure is successful.
- * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
- * @retval NRFX_ERROR_INTERNAL An error is detected by hardware.
- * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address in polling mode.
- * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte in polling mode.
- */
-nrfx_err_t nrfx_twi_tx(nrfx_twi_t const * p_instance,
- uint8_t address,
- uint8_t const * p_data,
- size_t length,
- bool no_stop);
-
-/**
- * @brief Function for reading data from a TWI slave.
- *
- * The transmission will be stopped when an error occurs. If a transfer is ongoing,
- * the function returns the error code @ref NRFX_ERROR_BUSY.
- *
- * @param[in] p_instance Pointer to the driver instance structure.
- * @param[in] address Address of a specific slave device (only 7 LSB).
- * @param[in] p_data Pointer to a receive buffer.
- * @param[in] length Number of bytes to be received.
- *
- * @retval NRFX_SUCCESS The procedure is successful.
- * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
- * @retval NRFX_ERROR_INTERNAL An error is detected by hardware.
- * @retval NRFX_ERROR_DRV_TWI_ERR_OVERRUN The unread data is replaced by new data.
- * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address in polling mode.
- * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte in polling mode.
- */
-nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
- uint8_t address,
- uint8_t * p_data,
- size_t length);
-
-/**
- * @brief Function for preparing a TWI transfer.
+ * @brief Function for performing a TWI transfer.
*
- * The following transfer types can be configured (@ref nrfx_twi_xfer_desc_t::type):
+ * The following transfer types can be configured (@ref nrfx_twi_xfer_desc_t.type):
* - @ref NRFX_TWI_XFER_TXRX - Write operation followed by a read operation (without STOP condition in between).
* - @ref NRFX_TWI_XFER_TXTX - Write operation followed by a write operation (without STOP condition in between).
* - @ref NRFX_TWI_XFER_TX - Write operation (with or without STOP condition).
@@ -287,10 +251,12 @@ nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
* Additional options are provided using the flags parameter:
* - @ref NRFX_TWI_FLAG_NO_XFER_EVT_HANDLER - No user event handler after transfer completion. In most cases, this also means no interrupt at the end of the transfer.
* - @ref NRFX_TWI_FLAG_TX_NO_STOP - No stop condition after TX transfer.
+ * - @ref NRFX_TWI_FLAG_SUSPEND - Transfer will be suspended. This allows for combining multiple transfers into one transaction.
+ * Only transactions with the same direction can be combined. To finish the transaction, call the function without this flag.
*
* @note
* Some flag combinations are invalid:
- * - @ref NRFX_TWI_FLAG_TX_NO_STOP with @ref nrfx_twi_xfer_desc_t::type different than @ref NRFX_TWI_XFER_TX
+ * - @ref NRFX_TWI_FLAG_TX_NO_STOP with @ref nrfx_twi_xfer_desc_t.type different than @ref NRFX_TWI_XFER_TX
*
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] p_xfer_desc Pointer to the transfer descriptor.
@@ -300,9 +266,12 @@ nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
* @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
* @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
* @retval NRFX_ERROR_INTERNAL An error is detected by hardware.
+ * @retval NRFX_ERROR_INVALID_STATE Other direction of transaction is suspended on the bus.
* @retval NRFX_ERROR_DRV_TWI_ERR_OVERRUN The unread data is replaced by new data (TXRX and RX)
- * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address.
- * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte.
+ * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK Negative acknowledgement (NACK) is received after sending
+ * the address in polling mode.
+ * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK Negative acknowledgement (NACK) is received after sending
+ * a data byte in polling mode.
*/
nrfx_err_t nrfx_twi_xfer(nrfx_twi_t const * p_instance,
nrfx_twi_xfer_desc_t const * p_xfer_desc,
@@ -325,7 +294,7 @@ bool nrfx_twi_is_busy(nrfx_twi_t const * p_instance);
*
* @return Data count.
*/
-size_t nrfx_twi_data_count_get(nrfx_twi_t const * const p_instance);
+size_t nrfx_twi_data_count_get(nrfx_twi_t const * p_instance);
/**
* @brief Function for returning the address of a STOPPED TWI event.
@@ -339,6 +308,30 @@ size_t nrfx_twi_data_count_get(nrfx_twi_t const * const p_instance);
*/
uint32_t nrfx_twi_stopped_event_get(nrfx_twi_t const * p_instance);
+/**
+ * @brief Function for recovering the bus.
+ *
+ * This function checks if the bus is not stuck because of a slave holding the SDA line in the low state,
+ * and if needed it performs required number of pulses on the SCL line to make the slave release the SDA line.
+ * Finally, the function generates a STOP condition on the bus to put it into a known state.
+ *
+ * @note This function can be used only if the TWI driver is uninitialized.
+ *
+ * @param[in] scl_pin SCL pin number.
+ * @param[in] sda_pin SDA pin number.
+ *
+ * @retval NRFX_SUCCESS Bus recovery was successful.
+ * @retval NRFX_ERROR_INTERNAL Bus recovery failed.
+ */
+NRFX_STATIC_INLINE nrfx_err_t nrfx_twi_bus_recover(uint32_t scl_pin, uint32_t sda_pin);
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE nrfx_err_t nrfx_twi_bus_recover(uint32_t scl_pin, uint32_t sda_pin)
+{
+ return nrfx_twi_twim_bus_recover(scl_pin, sda_pin);
+}
+#endif
+
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.c b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h
similarity index 57%
copy from hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.c
copy to hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h
index 76fbf1e..1c6ebcd 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,54 +29,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <nrfx.h>
-#include "nrf_ecb.h"
-#include <string.h>
-
-static uint8_t ecb_data[48]; ///< ECB data structure for RNG peripheral to access.
-static uint8_t* ecb_key; ///< Key: Starts at ecb_data
-static uint8_t* ecb_cleartext; ///< Cleartext: Starts at ecb_data + 16 bytes.
-static uint8_t* ecb_ciphertext; ///< Ciphertext: Starts at ecb_data + 32 bytes.
+#ifndef NRFX_TWI_TWIM_H
+#define NRFX_TWI_TWIM_H
-bool nrf_ecb_init(void)
-{
- ecb_key = ecb_data;
- ecb_cleartext = ecb_data + 16;
- ecb_ciphertext = ecb_data + 32;
-
- NRF_ECB->ECBDATAPTR = (uint32_t)ecb_data;
- return true;
-}
+#include <nrfx.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
-bool nrf_ecb_crypt(uint8_t * dest_buf, const uint8_t * src_buf)
-{
- uint32_t counter = 0x1000000;
- if (src_buf != ecb_cleartext)
- {
- memcpy(ecb_cleartext,src_buf,16);
- }
- NRF_ECB->EVENTS_ENDECB = 0;
- NRF_ECB->TASKS_STARTECB = 1;
- while (NRF_ECB->EVENTS_ENDECB == 0)
- {
- counter--;
- if (counter == 0)
- {
- return false;
- }
- }
- NRF_ECB->EVENTS_ENDECB = 0;
- if (dest_buf != ecb_ciphertext)
- {
- memcpy(dest_buf,ecb_ciphertext,16);
- }
- return true;
-}
+nrfx_err_t nrfx_twi_twim_bus_recover(uint32_t scl_pin, uint32_t sda_pin);
-void nrf_ecb_set_key(const uint8_t * key)
-{
- memcpy(ecb_key,key,16);
+#ifdef __cplusplus
}
+#endif
-
+#endif // NRFX_TWI_TWIM_H
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twim.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twim.h
index 11662e5..78bc802 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twim.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twim.h
@@ -33,6 +33,7 @@
#define NRFX_TWIM_H__
#include <nrfx.h>
+#include <nrfx_twi_twim.h>
#include <hal/nrf_twim.h>
#ifdef __cplusplus
@@ -88,14 +89,23 @@ typedef struct
bool hold_bus_uninit; ///< Hold pull up state on GPIO pins after uninit.
} nrfx_twim_config_t;
-/** @brief TWI master driver instance default configuration. */
-#define NRFX_TWIM_DEFAULT_CONFIG \
-{ \
- .scl = 31, \
- .sda = 31, \
- .frequency = (nrf_twim_frequency_t)NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY, \
- .interrupt_priority = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
- .hold_bus_uninit = NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT, \
+/**
+ * @brief TWIM driver default configuration.
+ *
+ * This configuration sets up TWIM with the following options:
+ * - clock frequency: 100 kHz
+ * - disable bus holding after uninit
+ *
+ * @param[in] _pin_scl SCL pin.
+ * @param[in] _pin_sda SDA pin.
+ */
+#define NRFX_TWIM_DEFAULT_CONFIG(_pin_scl, _pin_sda) \
+{ \
+ .scl = _pin_scl, \
+ .sda = _pin_sda, \
+ .frequency = NRF_TWIM_FREQ_100K, \
+ .interrupt_priority = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .hold_bus_uninit = false, \
}
/** @brief Flag indicating that TX buffer address will be incremented after the transfer. */
@@ -116,7 +126,9 @@ typedef enum
{
NRFX_TWIM_EVT_DONE, ///< Transfer completed event.
NRFX_TWIM_EVT_ADDRESS_NACK, ///< Error event: NACK received after sending the address.
- NRFX_TWIM_EVT_DATA_NACK ///< Error event: NACK received after sending a data byte.
+ NRFX_TWIM_EVT_DATA_NACK, ///< Error event: NACK received after sending a data byte.
+ NRFX_TWIM_EVT_OVERRUN, ///< Error event: The unread data is replaced by new data.
+ NRFX_TWIM_EVT_BUS_ERROR ///< Error event: An unexpected transition occurred on the bus.
} nrfx_twim_evt_type_t;
/** @brief TWI master driver transfer types. */
@@ -144,10 +156,10 @@ typedef struct
#define NRFX_TWIM_XFER_DESC_TX(addr, p_data, length) \
{ \
.type = NRFX_TWIM_XFER_TX, \
- .address = addr, \
- .primary_length = length, \
+ .address = (addr), \
+ .primary_length = (length), \
.secondary_length = 0, \
- .p_primary_buf = p_data, \
+ .p_primary_buf = (p_data), \
.p_secondary_buf = NULL, \
}
@@ -155,10 +167,10 @@ typedef struct
#define NRFX_TWIM_XFER_DESC_RX(addr, p_data, length) \
{ \
.type = NRFX_TWIM_XFER_RX, \
- .address = addr, \
- .primary_length = length, \
+ .address = (addr), \
+ .primary_length = (length), \
.secondary_length = 0, \
- .p_primary_buf = p_data, \
+ .p_primary_buf = (p_data), \
.p_secondary_buf = NULL, \
}
@@ -166,22 +178,22 @@ typedef struct
#define NRFX_TWIM_XFER_DESC_TXRX(addr, p_tx, tx_len, p_rx, rx_len) \
{ \
.type = NRFX_TWIM_XFER_TXRX, \
- .address = addr, \
- .primary_length = tx_len, \
- .secondary_length = rx_len, \
- .p_primary_buf = p_tx, \
- .p_secondary_buf = p_rx, \
+ .address = (addr), \
+ .primary_length = (tx_len), \
+ .secondary_length = (rx_len), \
+ .p_primary_buf = (p_tx), \
+ .p_secondary_buf = (p_rx), \
}
/** @brief Macro for setting the TX-TX transfer descriptor. */
#define NRFX_TWIM_XFER_DESC_TXTX(addr, p_tx, tx_len, p_tx2, tx_len2) \
{ \
.type = NRFX_TWIM_XFER_TXTX, \
- .address = addr, \
- .primary_length = tx_len, \
- .secondary_length = tx_len2, \
- .p_primary_buf = p_tx, \
- .p_secondary_buf = p_tx2, \
+ .address = (addr), \
+ .primary_length = (tx_len), \
+ .secondary_length = (tx_len2), \
+ .p_primary_buf = (p_tx), \
+ .p_secondary_buf = (p_tx2), \
}
/** @brief Structure for a TWI event. */
@@ -237,68 +249,9 @@ void nrfx_twim_enable(nrfx_twim_t const * p_instance);
void nrfx_twim_disable(nrfx_twim_t const * p_instance);
/**
- * @brief Function for sending data to a TWI slave.
- *
- * The transmission will be stopped when an error occurs. If a transfer is ongoing,
- * the function returns the error code @ref NRFX_ERROR_BUSY.
- *
- * @note Peripherals using EasyDMA (including TWIM) require the transfer buffers
- * to be placed in the Data RAM region. If this condition is not met,
- * this function fails with the error code NRFX_ERROR_INVALID_ADDR.
- *
- * @param[in] p_instance Pointer to the driver instance structure.
- * @param[in] address Address of a specific slave device (only 7 LSB).
- * @param[in] p_data Pointer to a transmit buffer.
- * @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 driver
- * checks it with assertion.
- * @param[in] no_stop If set, the stop condition is not generated on the bus
- * after the transfer has completed successfully (allowing
- * for a repeated start in the next transfer).
- *
- * @retval NRFX_SUCCESS The procedure is successful.
- * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
- * @retval NRFX_ERROR_INTERNAL Error is detected by hardware.
- * @retval NRFX_ERROR_INVALID_ADDR The provided buffer is not placed in the Data RAM region.
- * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address in polling mode.
- * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte in polling mode.
- */
-nrfx_err_t nrfx_twim_tx(nrfx_twim_t const * p_instance,
- uint8_t address,
- uint8_t const * p_data,
- size_t length,
- bool no_stop);
-
-/**
- * @brief Function for reading data from a TWI slave.
- *
- * The transmission will be stopped when an error occurs. If a transfer is ongoing,
- * the function returns the error code @ref NRFX_ERROR_BUSY.
- *
- * @param[in] p_instance Pointer to the driver instance structure.
- * @param[in] address Address of a specific slave device (only 7 LSB).
- * @param[in] p_data Pointer to a receive buffer.
- * @param[in] length Number of bytes to be received. Maximum possible length
- * is dependent on the used SoC (see the MAXCNT register
- * description in the Product Specification). The driver
- * checks it with assertion.
- *
- * @retval NRFX_SUCCESS The procedure is successful.
- * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
- * @retval NRFX_ERROR_INTERNAL Error is detected by hardware.
- * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address in polling mode.
- * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte in polling mode.
- */
-nrfx_err_t nrfx_twim_rx(nrfx_twim_t const * p_instance,
- uint8_t address,
- uint8_t * p_data,
- size_t length);
-
-/**
- * @brief Function for preparing a TWI transfer.
+ * @brief Function for performing a TWI transfer.
*
- * The following transfer types can be configured (@ref nrfx_twim_xfer_desc_t::type):
+ * The following transfer types can be configured (@ref nrfx_twim_xfer_desc_t.type):
* - @ref NRFX_TWIM_XFER_TXRX - Write operation followed by a read operation (without STOP condition in between).
* - @ref NRFX_TWIM_XFER_TXTX - Write operation followed by a write operation (without STOP condition in between).
* - @ref NRFX_TWIM_XFER_TX - Write operation (with or without STOP condition).
@@ -322,10 +275,10 @@ nrfx_err_t nrfx_twim_rx(nrfx_twim_t const * p_instance,
*
* @note
* Some flag combinations are invalid:
- * - @ref NRFX_TWIM_FLAG_TX_NO_STOP with @ref nrfx_twim_xfer_desc_t::type different than @ref NRFX_TWIM_XFER_TX
- * - @ref NRFX_TWIM_FLAG_REPEATED_XFER with @ref nrfx_twim_xfer_desc_t::type set to @ref NRFX_TWIM_XFER_TXTX
+ * - @ref NRFX_TWIM_FLAG_TX_NO_STOP with @ref nrfx_twim_xfer_desc_t.type different than @ref NRFX_TWIM_XFER_TX
+ * - @ref NRFX_TWIM_FLAG_REPEATED_XFER with @ref nrfx_twim_xfer_desc_t.type set to @ref NRFX_TWIM_XFER_TXTX
*
- * If @ref nrfx_twim_xfer_desc_t::type is set to @ref NRFX_TWIM_XFER_TX and the @ref NRFX_TWIM_FLAG_TX_NO_STOP and @ref NRFX_TWIM_FLAG_REPEATED_XFER
+ * If @ref nrfx_twim_xfer_desc_t.type is set to @ref NRFX_TWIM_XFER_TX and the @ref NRFX_TWIM_FLAG_TX_NO_STOP and @ref NRFX_TWIM_FLAG_REPEATED_XFER
* flags are set, two tasks must be used to trigger a transfer: TASKS_RESUME followed by TASKS_STARTTX. If no stop condition is generated,
* TWIM is in SUSPENDED state. Therefore, it must be resumed before the transfer can be started.
*
@@ -337,13 +290,14 @@ nrfx_err_t nrfx_twim_rx(nrfx_twim_t const * p_instance,
* @param[in] p_xfer_desc Pointer to the transfer descriptor.
* @param[in] flags Transfer options (0 for default settings).
*
- * @retval NRFX_SUCCESS The procedure is successful.
- * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
- * @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
- * @retval NRFX_ERROR_INTERNAL Error is detected by hardware.
- * @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data RAM region.
- * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address.
- * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte.
+ * @retval NRFX_SUCCESS The procedure is successful.
+ * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer.
+ * @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported.
+ * @retval NRFX_ERROR_INTERNAL An unexpected transition occurred on the bus.
+ * @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data RAM region.
+ * @retval NRFX_ERROR_DRV_TWI_ERR_OVERRUN The unread data is replaced by new data.
+ * @retval NRFX_ERROR_DRV_TWI_ERR_ANACK NACK is received after sending the address.
+ * @retval NRFX_ERROR_DRV_TWI_ERR_DNACK NACK is received after sending a data byte.
*/
nrfx_err_t nrfx_twim_xfer(nrfx_twim_t const * p_instance,
nrfx_twim_xfer_desc_t const * p_xfer_desc,
@@ -385,6 +339,30 @@ uint32_t nrfx_twim_start_task_get(nrfx_twim_t const * p_instance, nrfx_twim_xfer
*/
uint32_t nrfx_twim_stopped_event_get(nrfx_twim_t const * p_instance);
+/**
+ * @brief Function for recovering the bus.
+ *
+ * This function checks if the bus is not stuck because of a slave holding the SDA line in the low state,
+ * and if needed it performs required number of pulses on the SCL line to make the slave release the SDA line.
+ * Finally, the function generates a STOP condition on the bus to put it into a known state.
+ *
+ * @note This function can be used only if the TWIM driver is uninitialized.
+ *
+ * @param[in] scl_pin SCL pin number.
+ * @param[in] sda_pin SDA pin number.
+ *
+ * @retval NRFX_SUCCESS Bus recovery was successful.
+ * @retval NRFX_ERROR_INTERNAL Bus recovery failed.
+ */
+NRFX_STATIC_INLINE nrfx_err_t nrfx_twim_bus_recover(uint32_t scl_pin, uint32_t sda_pin);
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE nrfx_err_t nrfx_twim_bus_recover(uint32_t scl_pin, uint32_t sda_pin)
+{
+ return nrfx_twi_twim_bus_recover(scl_pin, sda_pin);
+}
+#endif
+
/** @} */
void nrfx_twim_0_irq_handler(void);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twis.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twis.h
index 4c3d0ca..cf6833f 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twis.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twis.h
@@ -145,16 +145,26 @@ typedef struct
uint8_t interrupt_priority; //!< The priority of interrupt for the module to be set.
} nrfx_twis_config_t;
-/** @brief Generate the default configuration for the TWIS driver instance. */
-#define NRFX_TWIS_DEFAULT_CONFIG \
-{ \
- .addr = { NRFX_TWIS_DEFAULT_CONFIG_ADDR0, \
- NRFX_TWIS_DEFAULT_CONFIG_ADDR1 }, \
- .scl = 31, \
- .sda = 31, \
- .scl_pull = (nrf_gpio_pin_pull_t)NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL, \
- .sda_pull = (nrf_gpio_pin_pull_t)NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL, \
- .interrupt_priority = NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
+/**
+ * @brief TWIS driver default configuration.
+ *
+ * This configuration sets up TWIS with the following options:
+ * - second slave address disabled
+ * - SCL pull-up disabled
+ * - SDA pull-up disabled
+ *
+ * @param[in] _pin_scl SCL pin.
+ * @param[in] _pin_sda SDA pin.
+ * @param[in] _addr Slave address on TWI bus.
+ */
+#define NRFX_TWIS_DEFAULT_CONFIG(_pin_scl, _pin_sda, _addr) \
+{ \
+ .addr = { _addr, 0x00 }, \
+ .scl = _pin_scl, \
+ .scl_pull = NRF_GPIO_PIN_NOPULL, \
+ .sda = _pin_sda, \
+ .sda_pull = NRF_GPIO_PIN_NOPULL, \
+ .interrupt_priority = NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY \
}
/**
@@ -267,7 +277,7 @@ nrfx_err_t nrfx_twis_tx_prepare(nrfx_twis_t const * p_instance,
*
* @return Number of bytes sent.
*/
-__STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance);
+NRFX_STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance);
/**
* @brief Function for preparing the data for receiving.
@@ -301,7 +311,7 @@ nrfx_err_t nrfx_twis_rx_prepare(nrfx_twis_t const * p_instance,
*
* @return Number of bytes received.
*/
-__STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance);
+NRFX_STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance);
/**
* @brief Function for checking if the driver is busy right now.
@@ -366,17 +376,17 @@ bool nrfx_twis_is_pending_tx(nrfx_twis_t const * p_instance);
*/
bool nrfx_twis_is_pending_rx(nrfx_twis_t const * p_instance);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-__STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE size_t nrfx_twis_tx_amount(nrfx_twis_t const * p_instance)
{
return nrf_twis_tx_amount_get(p_instance->p_reg);
}
-__STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance)
+NRFX_STATIC_INLINE size_t nrfx_twis_rx_amount(nrfx_twis_t const * p_instance)
{
return nrf_twis_rx_amount_get(p_instance->p_reg);
}
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uart.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uart.h
index a96df3c..8f2105a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uart.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uart.h
@@ -85,24 +85,54 @@ typedef struct
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; ///< Baud rate.
uint8_t interrupt_priority; ///< Interrupt priority.
+ nrf_uart_config_t hal_cfg; ///< Parity, flow control and stop bits settings.
} nrfx_uart_config_t;
-/** @brief UART default configuration. */
-#define NRFX_UART_DEFAULT_CONFIG \
+#if defined(UART_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
+ /** @brief UART additional stop bits configuration. */
+ #define NRFX_UART_DEFAULT_EXTENDED_STOP_CONFIG \
+ .stop = NRF_UART_STOP_ONE,
+#else
+ #define NRFX_UART_DEFAULT_EXTENDED_STOP_CONFIG
+#endif
+
+#if defined(UART_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
+ /** @brief UART additional parity type configuration. */
+ #define NRFX_UART_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
+ .paritytype = NRF_UART_PARITYTYPE_EVEN,
+#else
+ #define NRFX_UART_DEFAULT_EXTENDED_PARITYTYPE_CONFIG
+#endif
+
+/**
+ * @brief UART driver default configuration.
+ *
+ * This configuration sets up UART with the following options:
+ * - hardware flow control disabled
+ * - no parity bit
+ * - one stop bit
+ * - baudrate: 115200
+ *
+ * @param[in] _pin_tx TX pin.
+ * @param[in] _pin_rx RX pin.
+ */
+#define NRFX_UART_DEFAULT_CONFIG(_pin_tx, _pin_rx) \
{ \
- .pseltxd = NRF_UART_PSEL_DISCONNECTED, \
- .pselrxd = NRF_UART_PSEL_DISCONNECTED, \
+ .pseltxd = _pin_tx, \
+ .pselrxd = _pin_rx, \
.pselcts = NRF_UART_PSEL_DISCONNECTED, \
.pselrts = NRF_UART_PSEL_DISCONNECTED, \
.p_context = NULL, \
- .hwfc = (nrf_uart_hwfc_t)NRFX_UART_DEFAULT_CONFIG_HWFC, \
- .parity = (nrf_uart_parity_t)NRFX_UART_DEFAULT_CONFIG_PARITY, \
- .baudrate = (nrf_uart_baudrate_t)NRFX_UART_DEFAULT_CONFIG_BAUDRATE, \
+ .baudrate = NRF_UART_BAUDRATE_115200, \
.interrupt_priority = NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .hal_cfg = { \
+ .hwfc = NRF_UART_HWFC_DISABLED, \
+ .parity = NRF_UART_PARITY_EXCLUDED, \
+ NRFX_UART_DEFAULT_EXTENDED_STOP_CONFIG \
+ NRFX_UART_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
+ } \
}
/** @brief Structure for the UART transfer completion event. */
@@ -176,8 +206,8 @@ void nrfx_uart_uninit(nrfx_uart_t const * p_instance);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
- nrf_uart_task_t task);
+NRFX_STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
+ nrf_uart_task_t task);
/**
* @brief Function for getting the address of the specified UART event.
@@ -187,8 +217,8 @@ __STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instan
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
- nrf_uart_event_t event);
+NRFX_STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
+ nrf_uart_event_t event);
/**
* @brief Function for sending data over UART.
@@ -324,19 +354,19 @@ void nrfx_uart_rx_abort(nrfx_uart_t const * p_instance);
uint32_t nrfx_uart_errorsrc_get(nrfx_uart_t const * p_instance);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-__STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
- nrf_uart_task_t task)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_uart_task_address_get(nrfx_uart_t const * p_instance,
+ nrf_uart_task_t task)
{
return nrf_uart_task_address_get(p_instance->p_reg, task);
}
-__STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
- nrf_uart_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_uart_event_address_get(nrfx_uart_t const * p_instance,
+ nrf_uart_event_t event)
{
return nrf_uart_event_address_get(p_instance->p_reg, event);
}
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uarte.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uarte.h
index b5eb109..48945fa 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uarte.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_uarte.h
@@ -94,24 +94,54 @@ typedef struct
uint32_t pselcts; ///< CTS pin number.
uint32_t pselrts; ///< RTS pin number.
void * p_context; ///< Context passed to interrupt handler.
- nrf_uarte_hwfc_t hwfc; ///< Flow control configuration.
- nrf_uarte_parity_t parity; ///< Parity configuration.
nrf_uarte_baudrate_t baudrate; ///< Baud rate.
uint8_t interrupt_priority; ///< Interrupt priority.
+ nrf_uarte_config_t hal_cfg; ///< Parity, flow control and stop bits settings.
} nrfx_uarte_config_t;
-/** @brief UARTE default configuration. */
-#define NRFX_UARTE_DEFAULT_CONFIG \
+#if defined(UARTE_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
+ /** @brief UARTE additional stop bits configuration. */
+ #define NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG \
+ .stop = (nrf_uarte_stop_t)NRF_UARTE_STOP_ONE,
+#else
+ #define NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG
+#endif
+
+#if defined(UARTE_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
+ /** @brief UARTE additional parity type configuration. */
+ #define NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
+ .paritytype = NRF_UARTE_PARITYTYPE_EVEN,
+#else
+ #define NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG
+#endif
+
+/**
+ * @brief UARTE driver default configuration.
+ *
+ * This configuration sets up UARTE with the following options:
+ * - hardware flow control disabled
+ * - no parity bit
+ * - one stop bit
+ * - baudrate: 115200
+ *
+ * @param[in] _pin_tx TX pin.
+ * @param[in] _pin_rx RX pin.
+ */
+#define NRFX_UARTE_DEFAULT_CONFIG(_pin_tx, _pin_rx) \
{ \
- .pseltxd = NRF_UARTE_PSEL_DISCONNECTED, \
- .pselrxd = NRF_UARTE_PSEL_DISCONNECTED, \
+ .pseltxd = _pin_tx, \
+ .pselrxd = _pin_rx, \
.pselcts = NRF_UARTE_PSEL_DISCONNECTED, \
.pselrts = NRF_UARTE_PSEL_DISCONNECTED, \
.p_context = NULL, \
- .hwfc = (nrf_uarte_hwfc_t)NRFX_UARTE_DEFAULT_CONFIG_HWFC, \
- .parity = (nrf_uarte_parity_t)NRFX_UARTE_DEFAULT_CONFIG_PARITY, \
- .baudrate = (nrf_uarte_baudrate_t)NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE, \
+ .baudrate = NRF_UARTE_BAUDRATE_115200, \
.interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ .hal_cfg = { \
+ .hwfc = NRF_UARTE_HWFC_DISABLED, \
+ .parity = NRF_UARTE_PARITY_EXCLUDED, \
+ NRFX_UARTE_DEFAULT_EXTENDED_STOP_CONFIG \
+ NRFX_UARTE_DEFAULT_EXTENDED_PARITYTYPE_CONFIG \
+ } \
}
/** @brief Structure for the UARTE transfer completion event. */
@@ -185,8 +215,8 @@ void nrfx_uarte_uninit(nrfx_uarte_t const * p_instance);
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_task_t task);
+NRFX_STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
+ nrf_uarte_task_t task);
/**
* @brief Function for getting the address of the specified UARTE event.
@@ -196,8 +226,8 @@ __STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_inst
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_event_t event);
+NRFX_STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
+ nrf_uarte_event_t event);
/**
* @brief Function for sending data over UARTE.
@@ -320,19 +350,19 @@ void nrfx_uarte_rx_abort(nrfx_uarte_t const * p_instance);
uint32_t nrfx_uarte_errorsrc_get(nrfx_uarte_t const * p_instance);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-__STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_task_t task)
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
+ nrf_uarte_task_t task)
{
return nrf_uarte_task_address_get(p_instance->p_reg, task);
}
-__STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
+ nrf_uarte_event_t event)
{
return nrf_uarte_event_address_get(p_instance->p_reg, event);
}
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
+#endif // NRFX_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbd.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbd.h
index ec34c55..1069df4 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbd.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbd.h
@@ -187,11 +187,11 @@ typedef struct
} sof; /**< Data available for @ref NRFX_USBD_EVT_SOF. */
struct {
nrfx_usbd_ep_t ep; /**< Endpoint number. */
- } isocrc;
+ } isocrc; /**< Isochronouns channel endpoint number. */
struct {
nrfx_usbd_ep_t ep; /**< Endpoint number. */
nrfx_usbd_ep_status_t status; /**< Status for the endpoint. */
- } eptransfer;
+ } eptransfer; /**< Endpoint transfer status. */
} data; /**< Union to store event data. */
} nrfx_usbd_evt_t;
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h
index c3d1c61..fc46857 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h
@@ -39,6 +39,10 @@
extern "C" {
#endif
+#ifndef NRF_WDT0
+#define NRF_WDT0 NRF_WDT
+#endif
+
/**
* @defgroup nrfx_wdt WDT driver
* @{
@@ -48,11 +52,43 @@ extern "C" {
#if !NRFX_CHECK(NRFX_WDT_CONFIG_NO_IRQ) || defined(__NRFX_DOXYGEN__)
/** @brief WDT instance interrupt priority configuration. */
- #define NRFX_WDT_IRQ_CONFIG .interrupt_priority = NRFX_WDT_CONFIG_IRQ_PRIORITY
+ #define NRFX_WDT_IRQ_CONFIG .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY
#else
#define NRFX_WDT_IRQ_CONFIG
#endif
+/** @brief WDT event handler function type. */
+typedef void (*nrfx_wdt_event_handler_t)(void);
+
+/** @brief WDT channel ID type. */
+typedef nrf_wdt_rr_register_t nrfx_wdt_channel_id;
+
+/** @brief Data structure of the Watchdog (WDT) driver instance. */
+typedef struct
+{
+ NRF_WDT_Type * p_reg; ///< Pointer to a structure with WDT registers.
+ uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only.
+} nrfx_wdt_t;
+
+#ifndef __NRFX_DOXYGEN__
+enum {
+#if NRFX_CHECK(NRFX_WDT0_ENABLED)
+ NRFX_WDT0_INST_IDX,
+#endif
+#if NRFX_CHECK(NRFX_WDT1_ENABLED)
+ NRFX_WDT1_INST_IDX,
+#endif
+ NRFX_WDT_ENABLED_COUNT
+};
+#endif
+
+/** @brief Macro for creating an instance of the WDT driver. */
+#define NRFX_WDT_INSTANCE(id) \
+{ \
+ .p_reg = NRF_WDT##id, \
+ .drv_inst_idx = NRFX_CONCAT_3(NRFX_WDT, id, _INST_IDX), \
+}
+
/**@brief Struct for WDT initialization. */
typedef struct
{
@@ -63,92 +99,119 @@ typedef struct
#endif
} nrfx_wdt_config_t;
-/** @brief WDT event handler function type. */
-typedef void (*nrfx_wdt_event_handler_t)(void);
-
-/** @brief WDT channel ID type. */
-typedef nrf_wdt_rr_register_t nrfx_wdt_channel_id;
+/**
+ * @brief WDT driver default configuration.
+ *
+ * This configuration sets up WDT with the following options:
+ * - run when CPU is in SLEEP mode, pause when in HALT mode
+ * - reload value: 2000 ms
+ */
+#define NRFX_WDT_DEFAULT_CONFIG \
+{ \
+ .behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP, \
+ .reload_value = 2000, \
+ NRFX_WDT_IRQ_CONFIG \
+}
-/** @brief WDT driver default configuration. */
-#define NRFX_WDT_DEAFULT_CONFIG \
- { \
- .behaviour = (nrf_wdt_behaviour_t)NRFX_WDT_CONFIG_BEHAVIOUR, \
- .reload_value = NRFX_WDT_CONFIG_RELOAD_VALUE, \
- NRFX_WDT_IRQ_CONFIG \
- }
/**
- * @brief This function initializes the watchdog.
+ * @brief Function for initializing the WDT driver instance.
*
+ * @param[in] p_instance Pointer to the driver instance structure.
* @param[in] p_config Pointer to the structure with the initial configuration.
* @param[in] wdt_event_handler Event handler provided by the user. Ignored when
* @ref NRFX_WDT_CONFIG_NO_IRQ option is enabled.
*
- * @return NRFX_SUCCESS on success, otherwise an error code.
+ * @retval NRFX_SUCCESS Initialization was successful.
+ * @retval NRFX_ERROR_INVALID_STATE The driver was already initialized.
*/
-nrfx_err_t nrfx_wdt_init(nrfx_wdt_config_t const * p_config,
+nrfx_err_t nrfx_wdt_init(nrfx_wdt_t const * p_instance,
+ nrfx_wdt_config_t const * p_config,
nrfx_wdt_event_handler_t wdt_event_handler);
/**
* @brief Function for allocating a watchdog channel.
*
- * @note This function can not be called after nrfx_wdt_start(void).
+ * @note This function can not be called after nrfx_wdt_start().
*
+ * @param[in] p_instance Pointer to the driver instance structure.
* @param[out] p_channel_id ID of granted channel.
*
- * @return NRFX_SUCCESS on success, otherwise an error code.
+ * @retval NRFX_SUCCESS The channel was successfully allocated.
+ * @retval NRFX_ERROR_NO_MEM There is no available channel to be used.
*/
-nrfx_err_t nrfx_wdt_channel_alloc(nrfx_wdt_channel_id * p_channel_id);
+nrfx_err_t nrfx_wdt_channel_alloc(nrfx_wdt_t const * p_instance,
+ nrfx_wdt_channel_id * p_channel_id);
/**
* @brief Function for starting the watchdog.
*
- * @note After calling this function the watchdog is started, so the user needs to feed all allocated
- * watchdog channels to avoid reset. At least one watchdog channel must be allocated.
+ * @note After calling this function the watchdog is started, so the user needs to feed
+ * all allocated watchdog channels to avoid reset. At least one watchdog channel
+ * must be allocated.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_wdt_enable(void);
+void nrfx_wdt_enable(nrfx_wdt_t const * p_instance);
/**
* @brief Function for feeding the watchdog.
*
* @details Function feeds all allocated watchdog channels.
+ *
+ * @param[in] p_instance Pointer to the driver instance structure.
*/
-void nrfx_wdt_feed(void);
+void nrfx_wdt_feed(nrfx_wdt_t const * p_instance);
/**
* @brief Function for feeding an invidual watchdog channel.
*
+ * @param[in] p_instance Pointer to the driver instance structure.
* @param[in] channel_id ID of watchdog channel.
*/
-void nrfx_wdt_channel_feed(nrfx_wdt_channel_id channel_id);
+void nrfx_wdt_channel_feed(nrfx_wdt_t const * p_instance, nrfx_wdt_channel_id channel_id);
/**
* @brief Function for returning a requested task address for the WDT driver module.
*
- * @param[in] task One of the peripheral tasks.
+ * @param[in] p_instance Pointer to the driver instance structure.
+ * @param[in] task One of the WDT tasks.
*
* @return Task address.
*/
-__STATIC_INLINE uint32_t nrfx_wdt_ppi_task_addr(nrf_wdt_task_t task)
-{
- return nrf_wdt_task_address_get(task);
-}
+NRFX_STATIC_INLINE uint32_t nrfx_wdt_task_address_get(nrfx_wdt_t const * p_instance,
+ nrf_wdt_task_t task);
/**
- * @brief Function for returning a requested event address for the wdt driver module.
+ * @brief Function for returning a requested event address for the WDT driver module.
*
- * @param[in] event One of the peripheral events.
+ * @param[in] p_instance Pointer to the driver instance structure.
+ * @param[in] event One of the WDT events.
*
* @return Event address.
*/
-__STATIC_INLINE uint32_t nrfx_wdt_ppi_event_addr(nrf_wdt_event_t event)
+NRFX_STATIC_INLINE uint32_t nrfx_wdt_event_address_get(nrfx_wdt_t const * p_instance,
+ nrf_wdt_event_t event);
+
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE uint32_t nrfx_wdt_task_address_get(nrfx_wdt_t const * p_instance,
+ nrf_wdt_task_t task)
{
- return nrf_wdt_event_address_get(event);
+ return nrf_wdt_task_address_get(p_instance->p_reg, task);
}
+NRFX_STATIC_INLINE uint32_t nrfx_wdt_event_address_get(nrfx_wdt_t const * p_instance,
+ nrf_wdt_event_t event)
+{
+ return nrf_wdt_event_address_get(p_instance->p_reg, event);
+}
+#endif // NRFX_DECLARE_ONLY
+
/** @} */
-void nrfx_wdt_irq_handler(void);
+void nrfx_wdt_0_irq_handler(void);
+void nrfx_wdt_1_irq_handler(void);
#ifdef __cplusplus
@@ -156,4 +219,3 @@ void nrfx_wdt_irq_handler(void);
#endif
#endif
-
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h b/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h
index db1cdfd..320fb29 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h
@@ -43,6 +43,22 @@
extern "C" {
#endif
+#ifndef NRFX_STATIC_INLINE
+#ifdef NRFX_DECLARE_ONLY
+#define NRFX_STATIC_INLINE
+#else
+#define NRFX_STATIC_INLINE __STATIC_INLINE
+#endif
+#endif // NRFX_STATIC_INLINE
+
+#ifndef NRF_STATIC_INLINE
+#ifdef NRF_DECLARE_ONLY
+#define NRF_STATIC_INLINE
+#else
+#define NRF_STATIC_INLINE __STATIC_INLINE
+#endif
+#endif // NRF_STATIC_INLINE
+
/**
* @defgroup nrfx_common Common module
* @{
@@ -136,6 +152,17 @@ extern "C" {
*/
#define NRFX_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+/**
+ * @brief Macro for getting the offset (in bytes) from the beginning of a structure
+ * of the specified type to its specified member.
+ *
+ * @param[in] type Structure type.
+ * @param[in] member Structure member whose offset is searched for.
+ *
+ * @return Member offset in bytes.
+ */
+#define NRFX_OFFSETOF(type, member) ((size_t)&(((type *)0)->member))
+
/**@brief Macro for checking if given lengths of EasyDMA transfers do not exceed
* the limit of the specified peripheral.
*
@@ -224,7 +251,7 @@ typedef enum
* @retval true The pointed object is located in the Data RAM region.
* @retval false The pointed object is not located in the Data RAM region.
*/
-__STATIC_INLINE bool nrfx_is_in_ram(void const * p_object);
+NRF_STATIC_INLINE bool nrfx_is_in_ram(void const * p_object);
/**
* @brief Function for checking if an object is aligned to a 32-bit word
@@ -238,7 +265,7 @@ __STATIC_INLINE bool nrfx_is_in_ram(void const * p_object);
* @retval true The pointed object is aligned to a 32-bit word.
* @retval false The pointed object is not aligned to a 32-bit word.
*/
-__STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object);
+NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object);
/**
* @brief Function for getting the interrupt number for the specified peripheral.
@@ -247,7 +274,7 @@ __STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object);
*
* @return Interrupt number associated with the pointed peripheral.
*/
-__STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg);
+NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg);
/**
* @brief Function for converting an INTEN register bit position to the
@@ -263,7 +290,7 @@ __STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg);
*
* @sa nrfx_event_to_bitpos
*/
-__STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit);
+NRF_STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit);
/**
* @brief Function for converting an event identifier to the corresponding
@@ -279,39 +306,39 @@ __STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit);
*
* @sa nrfx_bitpos_to_event
*/
-__STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event);
+NRF_STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event);
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
+#ifndef NRF_DECLARE_ONLY
-__STATIC_INLINE bool nrfx_is_in_ram(void const * p_object)
+NRF_STATIC_INLINE bool nrfx_is_in_ram(void const * p_object)
{
return ((((uint32_t)p_object) & 0xE0000000u) == 0x20000000u);
}
-__STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
+NRF_STATIC_INLINE bool nrfx_is_word_aligned(void const * p_object)
{
return ((((uint32_t)p_object) & 0x3u) == 0u);
}
-__STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
+NRF_STATIC_INLINE IRQn_Type nrfx_get_irq_number(void const * p_reg)
{
return (IRQn_Type)NRFX_IRQ_NUMBER_GET(p_reg);
}
-__STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit)
+NRF_STATIC_INLINE uint32_t nrfx_bitpos_to_event(uint32_t bit)
{
static const uint32_t event_reg_offset = 0x100u;
return event_reg_offset + (bit * sizeof(uint32_t));
}
-__STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event)
+NRF_STATIC_INLINE uint32_t nrfx_event_to_bitpos(uint32_t event)
{
static const uint32_t event_reg_offset = 0x100u;
return (event - event_reg_offset) / sizeof(uint32_t);
}
-#endif
+#endif // NRF_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c
index 59c2fae..6dfe7c8 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c
@@ -68,7 +68,7 @@ nrfx_err_t nrfx_adc_init(nrfx_adc_config_t const * p_config,
return err_code;
}
- nrf_adc_event_clear(NRF_ADC_EVENT_END);
+ nrf_adc_event_clear(NRF_ADC, NRF_ADC_EVENT_END);
if (event_handler)
{
NRFX_IRQ_PRIORITY_SET(ADC_IRQn, p_config->interrupt_priority);
@@ -85,8 +85,8 @@ nrfx_err_t nrfx_adc_init(nrfx_adc_config_t const * p_config,
void nrfx_adc_uninit(void)
{
NRFX_IRQ_DISABLE(ADC_IRQn);
- nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
- nrf_adc_task_trigger(NRF_ADC_TASK_STOP);
+ nrf_adc_int_disable(NRF_ADC, NRF_ADC_INT_END_MASK);
+ nrf_adc_task_trigger(NRF_ADC, NRF_ADC_TASK_STOP);
// Disable all channels. This must be done after the interrupt is disabled
// because adc_sample_process() dereferences this pointer when it needs to
@@ -155,12 +155,12 @@ void nrfx_adc_all_channels_disable(void)
void nrfx_adc_sample(void)
{
NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_ASSERT(!nrf_adc_busy_check());
- nrf_adc_task_trigger(NRF_ADC_TASK_START);
+ NRFX_ASSERT(!nrf_adc_busy_check(NRF_ADC));
+ nrf_adc_task_trigger(NRF_ADC, NRF_ADC_TASK_START);
}
-nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
- nrf_adc_value_t * p_value)
+nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * p_channel,
+ nrf_adc_value_t * p_value)
{
nrfx_err_t err_code;
@@ -177,16 +177,16 @@ nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
{
m_cb.state = NRFX_DRV_STATE_POWERED_ON;
- nrf_adc_init(&p_channel->config);
- nrf_adc_enable();
- nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
- nrf_adc_task_trigger(NRF_ADC_TASK_START);
+ nrf_adc_init(NRF_ADC, &p_channel->config);
+ nrf_adc_enable(NRF_ADC);
+ nrf_adc_int_disable(NRF_ADC, NRF_ADC_INT_END_MASK);
+ nrf_adc_task_trigger(NRF_ADC, NRF_ADC_TASK_START);
if (p_value)
{
- while (!nrf_adc_event_check(NRF_ADC_EVENT_END)) {}
- nrf_adc_event_clear(NRF_ADC_EVENT_END);
- *p_value = (nrf_adc_value_t)nrf_adc_result_get();
- nrf_adc_disable();
+ while (!nrf_adc_event_check(NRF_ADC, NRF_ADC_EVENT_END)) {}
+ nrf_adc_event_clear(NRF_ADC, NRF_ADC_EVENT_END);
+ *p_value = (nrf_adc_value_t)nrf_adc_result_get(NRF_ADC);
+ nrf_adc_disable(NRF_ADC);
m_cb.state = NRFX_DRV_STATE_INITIALIZED;
}
@@ -194,7 +194,7 @@ nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
{
NRFX_ASSERT(m_cb.event_handler);
m_cb.p_buffer = NULL;
- nrf_adc_int_enable(NRF_ADC_INT_END_MASK);
+ nrf_adc_int_enable(NRF_ADC, NRF_ADC_INT_END_MASK);
}
err_code = NRFX_SUCCESS;
NRFX_LOG_INFO("Function: %s, error code: %s.",
@@ -206,9 +206,9 @@ nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
static bool adc_sample_process()
{
- nrf_adc_event_clear(NRF_ADC_EVENT_END);
- nrf_adc_disable();
- m_cb.p_buffer[m_cb.idx] = (nrf_adc_value_t)nrf_adc_result_get();
+ nrf_adc_event_clear(NRF_ADC, NRF_ADC_EVENT_END);
+ nrf_adc_disable(NRF_ADC);
+ m_cb.p_buffer[m_cb.idx] = (nrf_adc_value_t)nrf_adc_result_get(NRF_ADC);
m_cb.idx++;
if (m_cb.idx < m_cb.size)
{
@@ -226,11 +226,11 @@ static bool adc_sample_process()
m_cb.p_current_conv = m_cb.p_current_conv->p_next;
task_trigger = true;
}
- nrf_adc_init(&m_cb.p_current_conv->config);
- nrf_adc_enable();
+ nrf_adc_init(NRF_ADC, &m_cb.p_current_conv->config);
+ nrf_adc_enable(NRF_ADC);
if (task_trigger)
{
- nrf_adc_task_trigger(NRF_ADC_TASK_START);
+ nrf_adc_task_trigger(NRF_ADC, NRF_ADC_TASK_START);
}
return false;
}
@@ -263,18 +263,18 @@ nrfx_err_t nrfx_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size)
m_cb.size = size;
m_cb.idx = 0;
m_cb.p_buffer = buffer;
- nrf_adc_init(&m_cb.p_current_conv->config);
- nrf_adc_event_clear(NRF_ADC_EVENT_END);
- nrf_adc_enable();
+ nrf_adc_init(NRF_ADC, &m_cb.p_current_conv->config);
+ nrf_adc_event_clear(NRF_ADC, NRF_ADC_EVENT_END);
+ nrf_adc_enable(NRF_ADC);
if (m_cb.event_handler)
{
- nrf_adc_int_enable(NRF_ADC_INT_END_MASK);
+ nrf_adc_int_enable(NRF_ADC, NRF_ADC_INT_END_MASK);
}
else
{
while (1)
{
- while (!nrf_adc_event_check(NRF_ADC_EVENT_END)){}
+ while (!nrf_adc_event_check(NRF_ADC, NRF_ADC_EVENT_END)){}
if (adc_sample_process())
{
@@ -301,13 +301,13 @@ void nrfx_adc_irq_handler(void)
{
if (m_cb.p_buffer == NULL)
{
- nrf_adc_event_clear(NRF_ADC_EVENT_END);
+ nrf_adc_event_clear(NRF_ADC, NRF_ADC_EVENT_END);
NRFX_LOG_DEBUG("Event: %s.",NRFX_LOG_ERROR_STRING_GET(NRF_ADC_EVENT_END));
- nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
- nrf_adc_disable();
+ nrf_adc_int_disable(NRF_ADC, NRF_ADC_INT_END_MASK);
+ nrf_adc_disable(NRF_ADC);
nrfx_adc_evt_t evt;
evt.type = NRFX_ADC_EVT_SAMPLE;
- evt.data.sample.sample = (nrf_adc_value_t)nrf_adc_result_get();
+ evt.data.sample.sample = (nrf_adc_value_t)nrf_adc_result_get(NRF_ADC);
NRFX_LOG_DEBUG("ADC data:");
NRFX_LOG_HEXDUMP_DEBUG((uint8_t *)(&evt.data.sample.sample), sizeof(nrf_adc_value_t));
m_cb.state = NRFX_DRV_STATE_INITIALIZED;
@@ -316,7 +316,7 @@ void nrfx_adc_irq_handler(void)
else if (adc_sample_process())
{
NRFX_LOG_DEBUG("Event: %s.", NRFX_LOG_ERROR_STRING_GET(NRF_ADC_EVENT_END));
- nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
+ nrf_adc_int_disable(NRF_ADC, NRF_ADC_INT_END_MASK);
nrfx_adc_evt_t evt;
evt.type = NRFX_ADC_EVT_DONE;
evt.data.done.p_buffer = m_cb.p_buffer;
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_clock.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_clock.c
index 1769c38..4659421 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_clock.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_clock.c
@@ -179,7 +179,7 @@ void nrfx_clock_enable(void)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
nrfx_power_clock_irq_init();
- nrf_clock_lf_src_set((nrf_clock_lfclk_t)NRFX_CLOCK_CONFIG_LF_SRC);
+ nrf_clock_lf_src_set(NRF_CLOCK, (nrf_clock_lfclk_t)NRFX_CLOCK_CONFIG_LF_SRC);
#if NRFX_CHECK(NRFX_POWER_ENABLED)
nrfx_clock_irq_enabled = true;
@@ -198,11 +198,11 @@ void nrfx_clock_disable(void)
{
NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_CLOCK));
}
- nrf_clock_int_disable(CLOCK_INTENSET_HFCLKSTARTED_Msk |
- CLOCK_INTENSET_LFCLKSTARTED_Msk |
+ nrf_clock_int_disable(NRF_CLOCK, CLOCK_INTENSET_HFCLKSTARTED_Msk |
+ CLOCK_INTENSET_LFCLKSTARTED_Msk |
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
- CLOCK_INTENSET_DONE_Msk |
- CLOCK_INTENSET_CTTO_Msk |
+ CLOCK_INTENSET_DONE_Msk |
+ CLOCK_INTENSET_CTTO_Msk |
#endif
0);
#if NRFX_CHECK(NRFX_POWER_ENABLED)
@@ -223,37 +223,37 @@ void nrfx_clock_uninit(void)
void nrfx_clock_lfclk_start(void)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED);
- nrf_clock_int_enable(NRF_CLOCK_INT_LF_STARTED_MASK);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED);
+ nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_LF_STARTED_MASK);
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_132)
nrfx_clock_anomaly_132();
#endif
- nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART);
}
void nrfx_clock_lfclk_stop(void)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTOP);
- while (nrf_clock_lf_is_running())
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTOP);
+ while (nrf_clock_lf_is_running(NRF_CLOCK))
{}
}
void nrfx_clock_hfclk_start(void)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- 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);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
+ nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_HF_STARTED_MASK);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART);
}
void nrfx_clock_hfclk_stop(void)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP);
- while (nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY))
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
+ while (nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY))
{}
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_201)
m_clock_cb.hfclk_started = false;
@@ -277,13 +277,13 @@ nrfx_err_t nrfx_clock_calibration_start(void)
if (m_clock_cb.cal_state == CAL_STATE_IDLE)
{
- nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE);
- nrf_clock_int_enable(NRF_CLOCK_INT_DONE_MASK);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_DONE);
+ nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_DONE_MASK);
m_clock_cb.cal_state = CAL_STATE_CAL;
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_192)
*(volatile uint32_t *)0x40000C34 = 0x00000002;
#endif
- nrf_clock_task_trigger(NRF_CLOCK_TASK_CAL);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_CAL);
}
else
{
@@ -311,28 +311,28 @@ nrfx_err_t nrfx_clock_is_calibrating(void)
void nrfx_clock_calibration_timer_start(uint8_t interval)
{
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
- 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);
+ nrf_clock_cal_timer_timeout_set(NRF_CLOCK, interval);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_CTTO);
+ nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_CTTO_MASK);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_CTSTART);
#endif
}
void nrfx_clock_calibration_timer_stop(void)
{
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
- nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTOP);
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_CTTO_MASK);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_CTSTOP);
#endif
}
void nrfx_clock_irq_handler(void)
{
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED))
+ if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED))
{
- nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_HFCLKSTARTED));
- nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK);
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_HF_STARTED_MASK);
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_201)
if (!m_clock_cb.hfclk_started)
@@ -344,33 +344,33 @@ void nrfx_clock_irq_handler(void)
m_clock_cb.event_handler(NRFX_CLOCK_EVT_HFCLK_STARTED);
#endif
}
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED))
+ if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED))
{
- nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_LFCLKSTARTED));
- nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK);
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_LF_STARTED_MASK);
m_clock_cb.event_handler(NRFX_CLOCK_EVT_LFCLK_STARTED);
}
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO))
+ if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_CTTO))
{
- nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_CTTO);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_CTTO));
- nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK);
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_CTTO_MASK);
m_clock_cb.event_handler(NRFX_CLOCK_EVT_CTTO);
}
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE))
+ if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_DONE))
{
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_192)
*(volatile uint32_t *)0x40000C34 = 0x00000000;
#endif
- nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE);
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_DONE);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_DONE));
- nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK);
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_DONE_MASK);
m_clock_cb.cal_state = CAL_STATE_IDLE;
m_clock_cb.event_handler(NRFX_CLOCK_EVT_CAL_DONE);
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c
index 801b476..c8ebb4d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c
@@ -52,9 +52,9 @@ static nrfx_drv_state_t m_state = NRFX_DRV_STATE_UNINITIALIZED;
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))
+ if (nrf_comp_event_check(NRF_COMP, event) && nrf_comp_int_enable_check(NRF_COMP, event_mask))
{
- nrf_comp_event_clear(event);
+ nrf_comp_event_clear(NRF_COMP, event);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(event));
m_comp_event_handler(event);
@@ -99,39 +99,39 @@ nrfx_err_t nrfx_comp_init(nrfx_comp_config_t const * p_config,
}
#endif
- nrf_comp_task_trigger(NRF_COMP_TASK_STOP);
- nrf_comp_enable();
+ nrf_comp_task_trigger(NRF_COMP, NRF_COMP_TASK_STOP);
+ nrf_comp_enable(NRF_COMP);
// 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_event_clear(NRF_COMP, NRF_COMP_EVENT_READY);
+ nrf_comp_event_clear(NRF_COMP, NRF_COMP_EVENT_DOWN);
+ nrf_comp_event_clear(NRF_COMP, NRF_COMP_EVENT_UP);
+ nrf_comp_event_clear(NRF_COMP, NRF_COMP_EVENT_CROSS);
- nrf_comp_ref_set(p_config->reference);
+ nrf_comp_ref_set(NRF_COMP, 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_ext_ref_set(NRF_COMP, 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);
+ nrf_comp_th_set(NRF_COMP, p_config->threshold);
+ nrf_comp_main_mode_set(NRF_COMP, p_config->main_mode);
+ nrf_comp_speed_mode_set(NRF_COMP, p_config->speed_mode);
+ nrf_comp_hysteresis_set(NRF_COMP, p_config->hyst);
#if defined (COMP_ISOURCE_ISOURCE_Msk)
- nrf_comp_isource_set(p_config->isource);
+ nrf_comp_isource_set(NRF_COMP, p_config->isource);
#endif
- nrf_comp_shorts_disable(NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT |
+ nrf_comp_shorts_disable(NRF_COMP, NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT |
NRFX_COMP_SHORT_STOP_AFTER_UP_EVT |
NRFX_COMP_SHORT_STOP_AFTER_DOWN_EVT);
- nrf_comp_int_disable(COMP_INTENCLR_CROSS_Msk |
+ nrf_comp_int_disable(NRF_COMP, COMP_INTENCLR_CROSS_Msk |
COMP_INTENCLR_UP_Msk |
COMP_INTENCLR_DOWN_Msk |
COMP_INTENCLR_READY_Msk);
- nrf_comp_input_select(p_config->input);
+ nrf_comp_input_select(NRF_COMP, p_config->input);
NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_COMP), p_config->interrupt_priority);
NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_COMP));
@@ -147,7 +147,7 @@ void nrfx_comp_uninit(void)
{
NRFX_ASSERT(m_state != NRFX_DRV_STATE_UNINITIALIZED);
NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_COMP));
- nrf_comp_disable();
+ nrf_comp_disable(NRF_COMP);
#if NRFX_CHECK(NRFX_PRS_ENABLED)
nrfx_prs_release(NRF_COMP);
#endif
@@ -158,26 +158,26 @@ void nrfx_comp_uninit(void)
void nrfx_comp_pin_select(nrf_comp_input_t psel)
{
- bool comp_enable_state = nrf_comp_enable_check();
- nrf_comp_task_trigger(NRF_COMP_TASK_STOP);
+ bool comp_enable_state = nrf_comp_enable_check(NRF_COMP);
+ nrf_comp_task_trigger(NRF_COMP, NRF_COMP_TASK_STOP);
if (m_state == NRFX_DRV_STATE_POWERED_ON)
{
m_state = NRFX_DRV_STATE_INITIALIZED;
}
- nrf_comp_disable();
- nrf_comp_input_select(psel);
+ nrf_comp_disable(NRF_COMP);
+ nrf_comp_input_select(NRF_COMP, psel);
if (comp_enable_state == true)
{
- nrf_comp_enable();
+ nrf_comp_enable(NRF_COMP);
}
}
void nrfx_comp_start(uint32_t comp_int_mask, uint32_t comp_shorts_mask)
{
NRFX_ASSERT(m_state == NRFX_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);
+ nrf_comp_int_enable(NRF_COMP, comp_int_mask);
+ nrf_comp_shorts_enable(NRF_COMP, comp_shorts_mask);
+ nrf_comp_task_trigger(NRF_COMP, NRF_COMP_TASK_START);
m_state = NRFX_DRV_STATE_POWERED_ON;
NRFX_LOG_INFO("Enabled.");
}
@@ -185,9 +185,9 @@ void nrfx_comp_start(uint32_t comp_int_mask, uint32_t comp_shorts_mask)
void nrfx_comp_stop(void)
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_POWERED_ON);
- nrf_comp_shorts_disable(UINT32_MAX);
- nrf_comp_int_disable(UINT32_MAX);
- nrf_comp_task_trigger(NRF_COMP_TASK_STOP);
+ nrf_comp_shorts_disable(NRF_COMP, UINT32_MAX);
+ nrf_comp_int_disable(NRF_COMP, UINT32_MAX);
+ nrf_comp_task_trigger(NRF_COMP, NRF_COMP_TASK_STOP);
m_state = NRFX_DRV_STATE_INITIALIZED;
NRFX_LOG_INFO("Disabled.");
}
@@ -195,8 +195,8 @@ void nrfx_comp_stop(void)
uint32_t nrfx_comp_sample()
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_POWERED_ON);
- nrf_comp_task_trigger(NRF_COMP_TASK_SAMPLE);
- return nrf_comp_result_get();
+ nrf_comp_task_trigger(NRF_COMP, NRF_COMP_TASK_SAMPLE);
+ return nrf_comp_result_get(NRF_COMP);
}
#endif // NRFX_CHECK(NRFX_COMP_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c
index b6b6380..3c7df6a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c
@@ -49,7 +49,7 @@
#endif
#define DPPI_AVAILABLE_CHANNELS_MASK \
- (((1UL << DPPI_CH_NUM) - 1) & (~NRFX_DPPI_CHANNELS_USED))
+ ((uint32_t)(((1ULL << DPPI_CH_NUM) - 1) & (~NRFX_DPPI_CHANNELS_USED)))
#define DPPI_AVAILABLE_GROUPS_MASK \
(((1UL << DPPI_GROUP_NUM) - 1) & (~NRFX_DPPI_GROUPS_USED))
@@ -61,12 +61,12 @@ static uint32_t m_allocated_channels;
static uint8_t m_allocated_groups;
-__STATIC_INLINE bool channel_is_allocated(uint8_t channel)
+static bool channel_is_allocated(uint8_t channel)
{
return ((m_allocated_channels & DPPI_BIT_SET(channel)) != 0);
}
-__STATIC_INLINE bool group_is_allocated(nrf_dppi_channel_group_t group)
+static bool group_is_allocated(nrf_dppi_channel_group_t group)
{
return ((m_allocated_groups & DPPI_BIT_SET(group)) != 0);
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c
new file mode 100644
index 0000000..9948f39
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c
@@ -0,0 +1,215 @@
+/*
+ * 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 must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <nrfx.h>
+
+#if NRFX_CHECK(NRFX_EGU_ENABLED)
+
+#if !(NRFX_CHECK(NRFX_EGU0_ENABLED) || \
+ NRFX_CHECK(NRFX_EGU1_ENABLED) || \
+ NRFX_CHECK(NRFX_EGU2_ENABLED) || \
+ NRFX_CHECK(NRFX_EGU3_ENABLED) || \
+ NRFX_CHECK(NRFX_EGU4_ENABLED) || \
+ NRFX_CHECK(NRFX_EGU5_ENABLED))
+#error "No enabled EGU instances. Check <nrfx_config.h>."
+#endif
+
+#if NRFX_CHECK(NRFX_EGU0_ENABLED) && ((1 << 0) & NRFX_EGUS_USED)
+ #error "EGU instance 0 is reserved for use outside of nrfx."
+#endif
+#if NRFX_CHECK(NRFX_EGU1_ENABLED) && ((1 << 1) & NRFX_EGUS_USED)
+ #error "EGU instance 1 is reserved for use outside of nrfx."
+#endif
+#if NRFX_CHECK(NRFX_EGU2_ENABLED) && ((1 << 2) & NRFX_EGUS_USED)
+ #error "EGU instance 2 is reserved for use outside of nrfx."
+#endif
+#if NRFX_CHECK(NRFX_EGU3_ENABLED) && ((1 << 3) & NRFX_EGUS_USED)
+ #error "EGU instance 3 is reserved for use outside of nrfx."
+#endif
+#if NRFX_CHECK(NRFX_EGU4_ENABLED) && ((1 << 4) & NRFX_EGUS_USED)
+ #error "EGU instance 4 is reserved for use outside of nrfx."
+#endif
+#if NRFX_CHECK(NRFX_EGU5_ENABLED) && ((1 << 5) & NRFX_EGUS_USED)
+ #error "EGU instance 5 is reserved for use outside of nrfx."
+#endif
+
+#include <nrfx_egu.h>
+
+typedef struct
+{
+ nrfx_egu_event_handler_t handler;
+ void * p_context;
+ nrfx_drv_state_t state;
+} egu_control_block_t;
+
+static egu_control_block_t m_cb[NRFX_EGU_ENABLED_COUNT];
+
+static uint32_t egu_event_mask_get_and_clear(NRF_EGU_Type * p_reg, uint32_t int_mask)
+{
+ uint32_t event_mask = 0;
+ while (int_mask)
+ {
+ uint8_t event_idx = __CLZ(__RBIT(int_mask));
+ int_mask &= ~(1uL << event_idx);
+
+ nrf_egu_event_t event = nrf_egu_triggered_event_get(event_idx);
+ if (nrf_egu_event_check(p_reg, event))
+ {
+ nrf_egu_event_clear(p_reg, event);
+ event_mask |= (1uL << event_idx);
+ }
+ }
+ return event_mask;
+}
+
+nrfx_err_t nrfx_egu_init(nrfx_egu_t const * p_instance,
+ uint8_t interrupt_priority,
+ nrfx_egu_event_handler_t event_handler,
+ void * p_context)
+{
+ NRFX_ASSERT(p_instance);
+
+ egu_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
+
+ if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED)
+ {
+ return NRFX_ERROR_INVALID_STATE;
+ }
+
+ p_cb->state = NRFX_DRV_STATE_INITIALIZED;
+ p_cb->p_context = p_context;
+ p_cb->handler = event_handler;
+ if (event_handler)
+ {
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(p_instance->p_reg));
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(p_instance->p_reg), interrupt_priority);
+ }
+
+ return NRFX_SUCCESS;
+}
+
+void nrfx_egu_int_enable(nrfx_egu_t const * p_instance, uint32_t mask)
+{
+ NRFX_ASSERT(p_instance);
+ NRFX_ASSERT(m_cb[p_instance->drv_inst_idx].state == NRFX_DRV_STATE_INITIALIZED);
+ NRFX_ASSERT(m_cb[p_instance->drv_inst_idx].handler);
+
+ (void)egu_event_mask_get_and_clear(p_instance->p_reg, mask);
+ nrf_egu_int_enable(p_instance->p_reg, mask);
+}
+
+void nrfx_egu_int_disable(nrfx_egu_t const * p_instance, uint32_t mask)
+{
+ NRFX_ASSERT(p_instance);
+ NRFX_ASSERT(m_cb[p_instance->drv_inst_idx].state == NRFX_DRV_STATE_INITIALIZED);
+
+ nrf_egu_int_disable(p_instance->p_reg, mask);
+}
+
+void nrfx_egu_trigger(nrfx_egu_t const * p_instance, uint8_t event_idx)
+{
+ NRFX_ASSERT(p_instance);
+ NRFX_ASSERT(m_cb[p_instance->drv_inst_idx].state == NRFX_DRV_STATE_INITIALIZED);
+ NRFX_ASSERT(event_idx < nrf_egu_channel_count(p_instance->p_reg));
+
+ nrf_egu_task_trigger(p_instance->p_reg, nrf_egu_trigger_task_get(event_idx));
+}
+
+void nrfx_egu_uninit(nrfx_egu_t const * p_instance)
+{
+ NRFX_ASSERT(p_instance);
+
+ egu_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
+
+ nrf_egu_int_disable(p_instance->p_reg, ~0uL);
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(p_instance->p_reg));
+
+ p_cb->state = NRFX_DRV_STATE_UNINITIALIZED;
+}
+
+static void egu_irq_handler(NRF_EGU_Type * p_reg, egu_control_block_t * p_cb)
+{
+ uint32_t int_mask = nrf_egu_int_enable_check(p_reg, ~0uL);
+
+ /* Check (and clear) only the events that are set to generate interrupts.
+ Leave the other ones untouched. */
+ uint32_t event_mask = egu_event_mask_get_and_clear(p_reg, int_mask);
+ while (event_mask)
+ {
+ uint8_t event_idx = __CLZ(__RBIT(event_mask));
+ event_mask &= ~(1uL << event_idx);
+ p_cb->handler(event_idx, p_cb->p_context);
+ }
+}
+
+#if NRFX_CHECK(NRFX_EGU0_ENABLED)
+void nrfx_egu_0_irq_handler(void)
+{
+ egu_irq_handler(NRF_EGU0, &m_cb[NRFX_EGU0_INST_IDX]);
+}
+#endif
+
+#if NRFX_CHECK(NRFX_EGU1_ENABLED)
+void nrfx_egu_1_irq_handler(void)
+{
+ egu_irq_handler(NRF_EGU1, &m_cb[NRFX_EGU1_INST_IDX]);
+}
+#endif
+
+#if NRFX_CHECK(NRFX_EGU2_ENABLED)
+void nrfx_egu_2_irq_handler(void)
+{
+ egu_irq_handler(NRF_EGU2, &m_cb[NRFX_EGU2_INST_IDX]);
+}
+#endif
+
+#if NRFX_CHECK(NRFX_EGU3_ENABLED)
+void nrfx_egu_3_irq_handler(void)
+{
+ egu_irq_handler(NRF_EGU3, &m_cb[NRFX_EGU3_INST_IDX]);
+}
+#endif
+
+#if NRFX_CHECK(NRFX_EGU4_ENABLED)
+void nrfx_egu_4_irq_handler(void)
+{
+ egu_irq_handler(NRF_EGU4, &m_cb[NRFX_EGU4_INST_IDX]);
+}
+#endif
+
+#if NRFX_CHECK(NRFX_EGU5_ENABLED)
+void nrfx_egu_5_irq_handler(void)
+{
+ egu_irq_handler(NRF_EGU5, &m_cb[NRFX_EGU5_INST_IDX]);
+}
+#endif
+
+#endif // NRFX_CHECK(NRFX_EGU_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c
index e68fdcb..515b289 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c
@@ -50,44 +50,6 @@
/* Check if every pin can be encoded on provided number of bits. */
NRFX_STATIC_ASSERT(NUMBER_OF_PINS <= (1 << SENSE_FIELD_POS));
-/**
- * @brief Macro for converting task-event index to an address of an event register.
- *
- * Macro utilizes the fact that registers are grouped together in ascending order.
- */
-#define TE_IDX_TO_EVENT_ADDR(idx) (nrf_gpiote_events_t)((uint32_t)NRF_GPIOTE_EVENTS_IN_0 + \
- (sizeof(uint32_t) * (idx)))
-
-/**
- * @brief Macro for converting task-event index of OUT task to an address of a task register.
- *
- * Macro utilizes the fact that registers are grouped together in ascending order.
- */
-#define TE_OUT_IDX_TO_TASK_ADDR(idx) (nrf_gpiote_tasks_t)((uint32_t)NRF_GPIOTE_TASKS_OUT_0 + \
- (sizeof(uint32_t) * (idx)))
-
-#if defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
-/**
- * @brief Macro for converting task-event index of SET task to an address of a task register.
- *
- * Macro utilizes the fact that registers are grouped together in ascending order.
- */
-#define TE_SET_IDX_TO_TASK_ADDR(idx) (nrf_gpiote_tasks_t)((uint32_t)NRF_GPIOTE_TASKS_SET_0 + \
- (sizeof(uint32_t) * (idx)))
-
-#endif // defined(GPIOTE_FEATURE_SET_PRESENT) || defined(__NRFX_DOXYGEN__)
-
-#if defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
-/**
- * @brief Macro for converting task-event index of CLR task to an address of a task register.
- *
- * Macro utilizes the fact that registers are grouped together in ascending order.
- */
-#define TE_CLR_IDX_TO_TASK_ADDR(idx) (nrf_gpiote_tasks_t)((uint32_t)NRF_GPIOTE_TASKS_CLR_0 + \
- (sizeof(uint32_t) * (idx)))
-
-#endif // defined(GPIOTE_FEATURE_CLR_PRESENT) || defined(__NRFX_DOXYGEN__)
-
/*lint -save -e571*/ /* Suppress "Warning 571: Suspicious cast" */
typedef struct
{
@@ -100,41 +62,41 @@ typedef struct
static gpiote_control_block_t m_cb;
-__STATIC_INLINE bool pin_in_use(uint32_t pin)
+static bool pin_in_use(uint32_t pin)
{
return (m_cb.pin_assignments[pin] != PIN_NOT_USED);
}
-__STATIC_INLINE bool pin_in_use_as_non_task_out(uint32_t pin)
+static bool pin_in_use_as_non_task_out(uint32_t pin)
{
return (m_cb.pin_assignments[pin] == PIN_USED);
}
-__STATIC_INLINE bool pin_in_use_by_te(uint32_t pin)
+static bool pin_in_use_by_te(uint32_t pin)
{
return (m_cb.pin_assignments[pin] >= 0 && m_cb.pin_assignments[pin] < GPIOTE_CH_NUM) ?
true : false;
}
-__STATIC_INLINE bool pin_in_use_by_port(uint32_t pin)
+static bool pin_in_use_by_port(uint32_t pin)
{
return (m_cb.pin_assignments[pin] >= GPIOTE_CH_NUM);
}
-__STATIC_INLINE bool pin_in_use_by_gpiote(uint32_t pin)
+static bool pin_in_use_by_gpiote(uint32_t pin)
{
return (m_cb.pin_assignments[pin] >= 0);
}
-__STATIC_INLINE void pin_in_use_by_te_set(uint32_t pin,
- uint32_t channel_id,
- nrfx_gpiote_evt_handler_t handler,
- bool is_channel)
+static void pin_in_use_by_te_set(uint32_t pin,
+ uint32_t channel_id,
+ nrfx_gpiote_evt_handler_t handler,
+ bool is_channel)
{
m_cb.pin_assignments[pin] = channel_id;
m_cb.handlers[channel_id] = handler;
@@ -145,40 +107,40 @@ __STATIC_INLINE void pin_in_use_by_te_set(uint32_t pin,
}
-__STATIC_INLINE void pin_in_use_set(uint32_t pin)
+static void pin_in_use_set(uint32_t pin)
{
m_cb.pin_assignments[pin] = PIN_USED;
}
-__STATIC_INLINE void pin_in_use_clear(uint32_t pin)
+static void pin_in_use_clear(uint32_t pin)
{
m_cb.pin_assignments[pin] = PIN_NOT_USED;
}
-__STATIC_INLINE void pin_configured_set(uint32_t pin)
+static void pin_configured_set(uint32_t pin)
{
nrf_bitmask_bit_set(pin, m_cb.configured_pins);
}
-__STATIC_INLINE void pin_configured_clear(uint32_t pin)
+static void pin_configured_clear(uint32_t pin)
{
nrf_bitmask_bit_clear(pin, m_cb.configured_pins);
}
-__STATIC_INLINE bool pin_configured_check(uint32_t pin)
+static bool pin_configured_check(uint32_t pin)
{
return 0 != nrf_bitmask_bit_is_set(pin, m_cb.configured_pins);
}
-__STATIC_INLINE int8_t channel_port_get(uint32_t pin)
+static int8_t channel_port_get(uint32_t pin)
{
return m_cb.pin_assignments[pin];
}
-__STATIC_INLINE nrfx_gpiote_evt_handler_t channel_handler_get(uint32_t channel)
+static nrfx_gpiote_evt_handler_t channel_handler_get(uint32_t channel)
{
return m_cb.handlers[channel];
}
@@ -219,7 +181,7 @@ static void channel_free(uint8_t channel_id)
}
-nrfx_err_t nrfx_gpiote_init(void)
+nrfx_err_t nrfx_gpiote_init(uint8_t interrupt_priority)
{
nrfx_err_t err_code;
@@ -246,10 +208,10 @@ nrfx_err_t nrfx_gpiote_init(void)
memset(m_cb.configured_pins, 0, sizeof(m_cb.configured_pins));
- NRFX_IRQ_PRIORITY_SET(GPIOTE_IRQn, NRFX_GPIOTE_CONFIG_IRQ_PRIORITY);
- NRFX_IRQ_ENABLE(GPIOTE_IRQn);
- nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_PORT);
- nrf_gpiote_int_enable(GPIOTE_INTENSET_PORT_Msk);
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_GPIOTE), interrupt_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_GPIOTE));
+ nrf_gpiote_event_clear(NRF_GPIOTE, NRF_GPIOTE_EVENT_PORT);
+ nrf_gpiote_int_enable(NRF_GPIOTE, GPIOTE_INTENSET_PORT_Msk);
m_cb.state = NRFX_DRV_STATE_INITIALIZED;
err_code = NRFX_SUCCESS;
@@ -300,7 +262,7 @@ nrfx_err_t nrfx_gpiote_out_init(nrfx_gpiote_pin_t pin,
if (pin_in_use(pin))
{
- err_code = NRFX_ERROR_INVALID_STATE;
+ err_code = NRFX_ERROR_BUSY;
}
else
{
@@ -310,7 +272,8 @@ nrfx_err_t nrfx_gpiote_out_init(nrfx_gpiote_pin_t pin,
if (channel != NO_CHANNELS)
{
- nrf_gpiote_task_configure((uint32_t)channel,
+ nrf_gpiote_task_configure(NRF_GPIOTE,
+ (uint32_t)channel,
pin,
p_config->action,
p_config->init_state);
@@ -354,7 +317,7 @@ void nrfx_gpiote_out_uninit(nrfx_gpiote_pin_t pin)
if (pin_in_use_by_te(pin))
{
channel_free((uint8_t)channel_port_get(pin));
- nrf_gpiote_te_default((uint32_t)channel_port_get(pin));
+ nrf_gpiote_te_default(NRF_GPIOTE, (uint32_t)channel_port_get(pin));
}
pin_in_use_clear(pin);
@@ -402,7 +365,7 @@ void nrfx_gpiote_out_task_enable(nrfx_gpiote_pin_t pin)
NRFX_ASSERT(pin_in_use(pin));
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_task_enable((uint32_t)m_cb.pin_assignments[pin]);
+ nrf_gpiote_task_enable(NRF_GPIOTE, (uint32_t)m_cb.pin_assignments[pin]);
}
@@ -412,46 +375,62 @@ void nrfx_gpiote_out_task_disable(nrfx_gpiote_pin_t pin)
NRFX_ASSERT(pin_in_use(pin));
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_task_disable((uint32_t)m_cb.pin_assignments[pin]);
+ nrf_gpiote_task_disable(NRF_GPIOTE, (uint32_t)m_cb.pin_assignments[pin]);
}
-uint32_t nrfx_gpiote_out_task_addr_get(nrfx_gpiote_pin_t pin)
+nrf_gpiote_task_t nrfx_gpiote_out_task_get(nrfx_gpiote_pin_t pin)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_tasks_t task = TE_OUT_IDX_TO_TASK_ADDR((uint32_t)channel_port_get(pin));
- return nrf_gpiote_task_addr_get(task);
+ return nrf_gpiote_out_task_get((uint8_t)channel_port_get(pin));
+}
+
+
+uint32_t nrfx_gpiote_out_task_addr_get(nrfx_gpiote_pin_t pin)
+{
+ nrf_gpiote_task_t task = nrfx_gpiote_out_task_get(pin);
+ return nrf_gpiote_task_address_get(NRF_GPIOTE, task);
}
#if defined(GPIOTE_FEATURE_SET_PRESENT)
-uint32_t nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin)
+nrf_gpiote_task_t nrfx_gpiote_set_task_get(nrfx_gpiote_pin_t pin)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_tasks_t task = TE_SET_IDX_TO_TASK_ADDR((uint32_t)channel_port_get(pin));
- return nrf_gpiote_task_addr_get(task);
+ return nrf_gpiote_set_task_get((uint8_t)channel_port_get(pin));
}
+uint32_t nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin)
+{
+ nrf_gpiote_task_t task = nrfx_gpiote_set_task_get(pin);
+ return nrf_gpiote_task_address_get(NRF_GPIOTE, task);
+}
#endif // defined(GPIOTE_FEATURE_SET_PRESENT)
+
#if defined(GPIOTE_FEATURE_CLR_PRESENT)
-uint32_t nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin)
+nrf_gpiote_task_t nrfx_gpiote_clr_task_get(nrfx_gpiote_pin_t pin)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_tasks_t task = TE_CLR_IDX_TO_TASK_ADDR((uint32_t)channel_port_get(pin));
- return nrf_gpiote_task_addr_get(task);
+ return nrf_gpiote_clr_task_get((uint8_t)channel_port_get(pin));
}
+uint32_t nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin)
+{
+ nrf_gpiote_task_t task = nrfx_gpiote_clr_task_get(pin);
+ return nrf_gpiote_task_address_get(NRF_GPIOTE, task);
+}
#endif // defined(GPIOTE_FEATURE_CLR_PRESENT)
+
void nrfx_gpiote_out_task_force(nrfx_gpiote_pin_t pin, uint8_t state)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
@@ -460,7 +439,7 @@ void nrfx_gpiote_out_task_force(nrfx_gpiote_pin_t pin, uint8_t state)
nrf_gpiote_outinit_t init_val =
state ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW;
- nrf_gpiote_task_force((uint32_t)m_cb.pin_assignments[pin], init_val);
+ nrf_gpiote_task_force(NRF_GPIOTE, (uint32_t)m_cb.pin_assignments[pin], init_val);
}
@@ -470,8 +449,8 @@ void nrfx_gpiote_out_task_trigger(nrfx_gpiote_pin_t pin)
NRFX_ASSERT(pin_in_use(pin));
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_tasks_t task = TE_OUT_IDX_TO_TASK_ADDR((uint32_t)channel_port_get(pin));
- nrf_gpiote_task_set(task);
+ nrf_gpiote_task_t task = nrf_gpiote_out_task_get((uint8_t)channel_port_get(pin));
+ nrf_gpiote_task_trigger(NRF_GPIOTE, task);
}
@@ -482,8 +461,8 @@ void nrfx_gpiote_set_task_trigger(nrfx_gpiote_pin_t pin)
NRFX_ASSERT(pin_in_use(pin));
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_tasks_t task = TE_SET_IDX_TO_TASK_ADDR((uint32_t)channel_port_get(pin));
- nrf_gpiote_task_set(task);
+ nrf_gpiote_task_t task = nrf_gpiote_set_task_get((uint8_t)channel_port_get(pin));
+ nrf_gpiote_task_trigger(NRF_GPIOTE, task);
}
@@ -496,8 +475,8 @@ void nrfx_gpiote_clr_task_trigger(nrfx_gpiote_pin_t pin)
NRFX_ASSERT(pin_in_use(pin));
NRFX_ASSERT(pin_in_use_by_te(pin));
- nrf_gpiote_tasks_t task = TE_CLR_IDX_TO_TASK_ADDR((uint32_t)channel_port_get(pin));
- nrf_gpiote_task_set(task);
+ nrf_gpiote_task_t task = nrf_gpiote_clr_task_get((uint8_t)channel_port_get(pin));
+ nrf_gpiote_task_trigger(NRF_GPIOTE, task);
}
@@ -508,12 +487,15 @@ nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
nrfx_gpiote_evt_handler_t evt_handler)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
+ NRFX_ASSERT(m_cb.state == NRFX_DRV_STATE_INITIALIZED);
+ NRFX_ASSERT(p_config);
+
nrfx_err_t err_code = NRFX_SUCCESS;
/* Only one GPIOTE channel can be assigned to one physical pin. */
if (pin_in_use_by_gpiote(pin))
{
- err_code = NRFX_ERROR_INVALID_STATE;
+ err_code = NRFX_ERROR_BUSY;
}
else
{
@@ -535,12 +517,12 @@ nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
if (p_config->hi_accuracy)
{
- nrf_gpiote_event_configure((uint32_t)channel, pin, p_config->sense);
+ nrf_gpiote_event_configure(NRF_GPIOTE, (uint32_t)channel, pin, p_config->sense);
}
else
{
- m_cb.port_handlers_pins[channel -
- GPIOTE_CH_NUM] |= (p_config->sense) << SENSE_FIELD_POS;
+ m_cb.port_handlers_pins[channel - GPIOTE_CH_NUM] |= (p_config->sense) <<
+ SENSE_FIELD_POS;
}
}
else
@@ -579,19 +561,19 @@ void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable)
}
else if (pin_in_use_by_te(pin))
{
- int32_t channel = (int32_t)channel_port_get(pin);
- nrf_gpiote_events_t event = TE_IDX_TO_EVENT_ADDR((uint32_t)channel);
+ int32_t channel = (int32_t)channel_port_get(pin);
+ nrf_gpiote_event_t event = nrf_gpiote_in_event_get((uint8_t)channel);
- nrf_gpiote_event_enable((uint32_t)channel);
+ nrf_gpiote_event_enable(NRF_GPIOTE, (uint32_t)channel);
- nrf_gpiote_event_clear(event);
+ nrf_gpiote_event_clear(NRF_GPIOTE, event);
if (int_enable)
{
nrfx_gpiote_evt_handler_t handler = channel_handler_get((uint32_t)channel_port_get(pin));
// Enable the interrupt only if event handler was provided.
if (handler)
{
- nrf_gpiote_int_enable(1 << channel);
+ nrf_gpiote_int_enable(NRF_GPIOTE, 1 << channel);
}
}
}
@@ -609,8 +591,8 @@ void nrfx_gpiote_in_event_disable(nrfx_gpiote_pin_t pin)
else if (pin_in_use_by_te(pin))
{
int32_t channel = (int32_t)channel_port_get(pin);
- nrf_gpiote_event_disable((uint32_t)channel);
- nrf_gpiote_int_disable(1 << channel);
+ nrf_gpiote_event_disable(NRF_GPIOTE, (uint32_t)channel);
+ nrf_gpiote_int_disable(NRF_GPIOTE, 1 << channel);
}
}
@@ -622,7 +604,7 @@ void nrfx_gpiote_in_uninit(nrfx_gpiote_pin_t pin)
nrfx_gpiote_in_event_disable(pin);
if (pin_in_use_by_te(pin))
{
- nrf_gpiote_te_default((uint32_t)channel_port_get(pin));
+ nrf_gpiote_te_default(NRF_GPIOTE, (uint32_t)channel_port_get(pin));
}
if (pin_configured_check(pin))
{
@@ -641,18 +623,24 @@ bool nrfx_gpiote_in_is_set(nrfx_gpiote_pin_t pin)
}
-uint32_t nrfx_gpiote_in_event_addr_get(nrfx_gpiote_pin_t pin)
+nrf_gpiote_event_t nrfx_gpiote_in_event_get(nrfx_gpiote_pin_t pin)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
NRFX_ASSERT(pin_in_use_by_port(pin) || pin_in_use_by_te(pin));
- nrf_gpiote_events_t event = NRF_GPIOTE_EVENTS_PORT;
-
if (pin_in_use_by_te(pin))
{
- event = TE_IDX_TO_EVENT_ADDR((uint32_t)channel_port_get(pin));
+ return nrf_gpiote_in_event_get((uint8_t)channel_port_get(pin));
}
- return nrf_gpiote_event_addr_get(event);
+
+ return NRF_GPIOTE_EVENT_PORT;
+}
+
+
+uint32_t nrfx_gpiote_in_event_addr_get(nrfx_gpiote_pin_t pin)
+{
+ nrf_gpiote_event_t event = nrfx_gpiote_in_event_get(pin);
+ return nrf_gpiote_event_address_get(NRF_GPIOTE, event);
}
@@ -663,27 +651,28 @@ void nrfx_gpiote_irq_handler(void)
/* collect status of all GPIOTE pin events. Processing is done once all are collected and cleared.*/
uint32_t i;
- nrf_gpiote_events_t event = NRF_GPIOTE_EVENTS_IN_0;
+ nrf_gpiote_event_t event = NRF_GPIOTE_EVENT_IN_0;
uint32_t mask = (uint32_t)NRF_GPIOTE_INT_IN0_MASK;
for (i = 0; i < GPIOTE_CH_NUM; i++)
{
- if (nrf_gpiote_event_is_set(event) && nrf_gpiote_int_is_enabled(mask))
+ if (nrf_gpiote_event_check(NRF_GPIOTE, event) &&
+ nrf_gpiote_int_enable_check(NRF_GPIOTE, mask))
{
- nrf_gpiote_event_clear(event);
+ nrf_gpiote_event_clear(NRF_GPIOTE, event);
status |= mask;
}
mask <<= 1;
/* Incrementing to next event, utilizing the fact that events are grouped together
* in ascending order. */
- event = (nrf_gpiote_events_t)((uint32_t)event + sizeof(uint32_t));
+ event = (nrf_gpiote_event_t)((uint32_t)event + sizeof(uint32_t));
}
/* collect PORT status event, if event is set read pins state. Processing is postponed to the
* end of interrupt. */
- if (nrf_gpiote_event_is_set(NRF_GPIOTE_EVENTS_PORT))
+ if (nrf_gpiote_event_check(NRF_GPIOTE, NRF_GPIOTE_EVENT_PORT))
{
- nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_PORT);
+ nrf_gpiote_event_clear(NRF_GPIOTE, NRF_GPIOTE_EVENT_PORT);
status |= (uint32_t)NRF_GPIOTE_INT_PORT_MASK;
nrf_gpio_ports_read(0, GPIO_COUNT, input);
}
@@ -697,9 +686,9 @@ void nrfx_gpiote_irq_handler(void)
{
if (mask & status)
{
- nrfx_gpiote_pin_t pin = nrf_gpiote_event_pin_get(i);
+ nrfx_gpiote_pin_t pin = nrf_gpiote_event_pin_get(NRF_GPIOTE, i);
NRFX_LOG_DEBUG("Event in number: %d.", i);
- nrf_gpiote_polarity_t polarity = nrf_gpiote_event_polarity_get(i);
+ nrf_gpiote_polarity_t polarity = nrf_gpiote_event_polarity_get(NRF_GPIOTE, i);
nrfx_gpiote_evt_handler_t handler = channel_handler_get(i);
NRFX_LOG_DEBUG("Pin: %d, polarity: %d.", pin, polarity);
if (handler)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c
index eed5f1e..d90d6f0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c
@@ -171,8 +171,8 @@ nrfx_err_t nrfx_i2s_init(nrfx_i2s_config_t const * p_config,
m_cb.handler = handler;
- NRFX_IRQ_PRIORITY_SET(I2S_IRQn, p_config->irq_priority);
- NRFX_IRQ_ENABLE(I2S_IRQn);
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_I2S), p_config->irq_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_I2S));
m_cb.state = NRFX_DRV_STATE_INITIALIZED;
@@ -187,7 +187,7 @@ void nrfx_i2s_uninit(void)
nrfx_i2s_stop();
- NRFX_IRQ_DISABLE(I2S_IRQn);
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_I2S));
nrf_i2s_pins_set(NRF_I2S,
NRF_I2S_PIN_NOT_CONNECTED,
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c
new file mode 100644
index 0000000..dcfd28a
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c
@@ -0,0 +1,162 @@
+/*
+ * 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 must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <nrfx.h>
+
+#if NRFX_CHECK(NRFX_IPC_ENABLED)
+
+#include <nrfx_ipc.h>
+
+// Control block - driver instance local data.
+typedef struct
+{
+ nrfx_ipc_handler_t handler;
+ nrfx_drv_state_t state;
+ void * p_context;
+} ipc_control_block_t;
+
+static ipc_control_block_t m_ipc_cb;
+
+nrfx_err_t nrfx_ipc_init(uint8_t irq_priority, nrfx_ipc_handler_t handler, void * p_context)
+{
+ NRFX_ASSERT(handler);
+ if (m_ipc_cb.state != NRFX_DRV_STATE_UNINITIALIZED)
+ {
+ return NRFX_ERROR_ALREADY_INITIALIZED;
+ }
+
+ NRFX_IRQ_PRIORITY_SET(IPC_IRQn, irq_priority);
+ NRFX_IRQ_ENABLE(IPC_IRQn);
+
+ m_ipc_cb.state = NRFX_DRV_STATE_INITIALIZED;
+ m_ipc_cb.handler = handler;
+ m_ipc_cb.p_context = p_context;
+
+ return NRFX_SUCCESS;
+}
+
+void nrfx_ipc_config_load(const nrfx_ipc_config_t * p_config)
+{
+ NRFX_ASSERT(p_config);
+ NRFX_ASSERT(m_ipc_cb.state == NRFX_DRV_STATE_INITIALIZED);
+
+ uint32_t i;
+ for (i = 0; i < IPC_CONF_NUM; ++i)
+ {
+ nrf_ipc_send_config_set(NRF_IPC, i, p_config->send_task_config[i]);
+ }
+
+ for (i = 0; i < IPC_CONF_NUM; ++i)
+ {
+ nrf_ipc_receive_config_set(NRF_IPC, i, p_config->receive_event_config[i]);
+ }
+
+ nrf_ipc_int_enable(NRF_IPC, p_config->receive_events_enabled);
+}
+
+void nrfx_ipc_uninit(void)
+{
+ NRFX_ASSERT(m_ipc_cb.state == NRFX_DRV_STATE_INITIALIZED);
+
+ uint32_t i;
+ for (i = 0; i < IPC_CONF_NUM; ++i)
+ {
+ nrf_ipc_send_config_set(NRF_IPC, i, 0);
+ }
+
+ for (i = 0; i < IPC_CONF_NUM; ++i)
+ {
+ nrf_ipc_receive_config_set(NRF_IPC, i, 0);
+ }
+
+ nrf_ipc_int_disable(NRF_IPC, 0xFFFFFFFF);
+ m_ipc_cb.state = NRFX_DRV_STATE_UNINITIALIZED;
+}
+
+void nrfx_ipc_receive_event_enable(uint8_t event_index)
+{
+ NRFX_ASSERT(m_ipc_cb.state == NRFX_DRV_STATE_INITIALIZED);
+ nrf_ipc_int_enable(NRF_IPC, (1UL << event_index));
+}
+
+void nrfx_ipc_receive_event_disable(uint8_t event_index)
+{
+ NRFX_ASSERT(m_ipc_cb.state == NRFX_DRV_STATE_INITIALIZED);
+ nrf_ipc_int_disable(NRF_IPC, (1UL << event_index));
+}
+
+void nrfx_ipc_receive_event_group_enable(uint32_t event_bitmask)
+{
+ NRFX_ASSERT(m_ipc_cb.state == NRFX_DRV_STATE_INITIALIZED);
+ nrf_ipc_int_enable(NRF_IPC, event_bitmask);
+}
+
+void nrfx_ipc_receive_event_group_disable(uint32_t event_bitmask)
+{
+ NRFX_ASSERT(m_ipc_cb.state == NRFX_DRV_STATE_INITIALIZED);
+ nrf_ipc_int_disable(NRF_IPC, event_bitmask);
+}
+
+void nrfx_ipc_receive_event_channel_assign(uint8_t event_index, uint8_t channel_index)
+{
+ NRFX_ASSERT(channel_index < IPC_CH_NUM);
+ uint32_t channel_bitmask = (1UL << channel_index);
+ channel_bitmask |= nrf_ipc_receive_config_get(NRF_IPC, event_index);
+ nrf_ipc_receive_config_set(NRF_IPC, event_index, channel_bitmask);
+}
+
+void nrfx_ipc_send_task_channel_assign(uint8_t send_index, uint8_t channel_index)
+{
+ NRFX_ASSERT(channel_index < IPC_CH_NUM);
+ uint32_t channel_bitmask = (1UL << channel_index);
+ channel_bitmask |= nrf_ipc_send_config_get(NRF_IPC, send_index);
+ nrf_ipc_send_config_set(NRF_IPC, send_index, channel_bitmask);
+}
+
+void nrfx_ipc_irq_handler(void)
+{
+ // Get the information about events that fire this interrupt
+ uint32_t events_map = nrf_ipc_int_pending_get(NRF_IPC);
+
+ // Clear these events
+ uint32_t bitmask = events_map;
+ while (bitmask)
+ {
+ uint8_t event_idx = __CLZ(__RBIT(bitmask));
+ bitmask &= ~(1UL << event_idx);
+ nrf_ipc_event_clear(NRF_IPC, nrf_ipc_receive_event_get(event_idx));
+ }
+
+ // Execute interrupt handler to provide information about events to app
+ m_ipc_cb.handler(events_map, m_ipc_cb.p_context);
+}
+
+#endif // NRFX_CHECK(NRFX_IPC_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c
index 019513c..9e654e4 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c
@@ -52,9 +52,10 @@ static nrfx_drv_state_t m_state = NRFX_DRV_STATE_UNINITIALIZED;
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))
+ if (nrf_lpcomp_event_check(NRF_LPCOMP, event) &&
+ nrf_lpcomp_int_enable_check(NRF_LPCOMP, event_mask))
{
- nrf_lpcomp_event_clear(event);
+ nrf_lpcomp_event_clear(NRF_LPCOMP, event);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(event));
m_lpcomp_event_handler(event);
@@ -98,31 +99,31 @@ nrfx_err_t nrfx_lpcomp_init(nrfx_lpcomp_config_t const * p_config,
}
#endif
- nrf_lpcomp_configure(&(p_config->hal));
+ nrf_lpcomp_configure(NRF_LPCOMP, &(p_config->hal));
- nrf_lpcomp_input_select(p_config->input);
+ nrf_lpcomp_input_select(NRF_LPCOMP, p_config->input);
switch (p_config->hal.detection)
{
case NRF_LPCOMP_DETECT_UP:
- nrf_lpcomp_int_enable(LPCOMP_INTENSET_UP_Msk);
+ nrf_lpcomp_int_enable(NRF_LPCOMP, LPCOMP_INTENSET_UP_Msk);
break;
case NRF_LPCOMP_DETECT_DOWN:
- nrf_lpcomp_int_enable(LPCOMP_INTENSET_DOWN_Msk);
+ nrf_lpcomp_int_enable(NRF_LPCOMP, LPCOMP_INTENSET_DOWN_Msk);
break;
case NRF_LPCOMP_DETECT_CROSS:
- nrf_lpcomp_int_enable(LPCOMP_INTENSET_CROSS_Msk);
+ nrf_lpcomp_int_enable(NRF_LPCOMP, LPCOMP_INTENSET_CROSS_Msk);
break;
default:
break;
}
- nrf_lpcomp_shorts_enable(NRF_LPCOMP_SHORT_READY_SAMPLE_MASK);
+ nrf_lpcomp_shorts_enable(NRF_LPCOMP, NRF_LPCOMP_SHORT_READY_SAMPLE_MASK);
- NRFX_IRQ_PRIORITY_SET(LPCOMP_IRQn, p_config->interrupt_priority);
- NRFX_IRQ_ENABLE(LPCOMP_IRQn);
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_LPCOMP), p_config->interrupt_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_LPCOMP));
m_state = NRFX_DRV_STATE_INITIALIZED;
@@ -134,7 +135,7 @@ nrfx_err_t nrfx_lpcomp_init(nrfx_lpcomp_config_t const * p_config,
void nrfx_lpcomp_uninit(void)
{
NRFX_ASSERT(m_state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_IRQ_DISABLE(LPCOMP_IRQn);
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_LPCOMP));
nrfx_lpcomp_disable();
#if NRFX_CHECK(NRFX_PRS_ENABLED)
nrfx_prs_release(NRF_LPCOMP);
@@ -147,8 +148,8 @@ void nrfx_lpcomp_uninit(void)
void nrfx_lpcomp_enable(void)
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_INITIALIZED);
- nrf_lpcomp_enable();
- nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_START);
+ nrf_lpcomp_enable(NRF_LPCOMP);
+ nrf_lpcomp_task_trigger(NRF_LPCOMP, NRF_LPCOMP_TASK_START);
m_state = NRFX_DRV_STATE_POWERED_ON;
NRFX_LOG_INFO("Enabled.");
}
@@ -156,8 +157,8 @@ void nrfx_lpcomp_enable(void)
void nrfx_lpcomp_disable(void)
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_POWERED_ON);
- nrf_lpcomp_disable();
- nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_STOP);
+ nrf_lpcomp_disable(NRF_LPCOMP);
+ nrf_lpcomp_task_trigger(NRF_LPCOMP, NRF_LPCOMP_TASK_STOP);
m_state = NRFX_DRV_STATE_INITIALIZED;
NRFX_LOG_INFO("Disabled.");
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c
index de1c066..fa8116e 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c
@@ -38,43 +38,53 @@
#define NRFX_LOG_MODULE NFCT
#include <nrfx_log.h>
-#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB) || defined(NRF52840_XXAA)
-#define USE_TIMER_WORKAROUND
+#if !defined(USE_WORKAROUND_FOR_ANOMALY_79) && \
+ (defined(NRF52832_XXAA) || defined(NRF52832_XXAB))
+#define USE_WORKAROUND_FOR_ANOMALY_79 1
#endif
-#ifdef USE_TIMER_WORKAROUND
+#if !defined(USE_WORKAROUND_FOR_ANOMALY_190) && \
+ (defined(NRF52833_XXAA) || defined(NRF52840_XXAA) || \
+ defined(NRF5340_XXAA_APPLICATION))
+#define USE_WORKAROUND_FOR_ANOMALY_190 1
+#endif
+
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_79) || NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
+#define NFCT_WORKAROUND_USES_TIMER 1
+#endif
+
+#if NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
#include <nrfx_timer.h>
typedef struct
{
const nrfx_timer_t timer; /**< Timer instance that supports the correct NFC field detection. */
-#ifdef NRF52840_XXAA
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
bool fieldevents_filter_active; /**< Flag that indicates that the field events are ignored. */
bool is_hfclk_on; /**< HFCLK has started - one of the NFC activation conditions. */
bool is_delayed; /**< Required time delay has passed - one of the NFC activation conditions. */
#else
uint32_t field_state_cnt; /**< Counter of the FIELDLOST events. */
-#endif // NRF52840_XXAA
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
} nrfx_nfct_timer_workaround_t;
-#ifdef NRF52840_XXAA
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
#define NRFX_NFCT_ACTIVATE_DELAY 1000 /**< Minimal delay in us between NFC field detection and activation of NFCT. */
#define NRFX_NFCT_TIMER_PERIOD NRFX_NFCT_ACTIVATE_DELAY
#else
#define NRFX_NFCT_FIELDLOST_THR 7
#define NRFX_NFCT_FIELD_TIMER_PERIOD 100 /**< Field polling period in us. */
#define NRFX_NFCT_TIMER_PERIOD NRFX_NFCT_FIELD_TIMER_PERIOD
-#endif // NRF52840_XXAA
-#define NRFX_NFCT_TIMER_INSTANCE 4 /**< Timer instance used for various workarounds for the NFCT HW issues.*/
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
-static nrfx_nfct_timer_workaround_t m_timer_workaround =
+static nrfx_nfct_timer_workaround_t m_timer_workaround =
{
- .timer = NRFX_TIMER_INSTANCE(NRFX_NFCT_TIMER_INSTANCE),
+ .timer = NRFX_TIMER_INSTANCE(NRFX_NFCT_CONFIG_TIMER_INSTANCE_ID),
};
-#endif // USE_TIMER_WORKAROUND
+#endif // NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
-#define NRFX_NFCT_FRAMEDELAYMAX_52840S (0xFFFFUL) /**< Bit mask of the FRAMEDELAYMAX field for the first sample of 52840.*/
-#define NRFX_NFCT_FWT_MAX_DIFF 1u /**< The maximal difference between the requested FWT and HW-limited FWT settings.*/
+#define NRFX_NFCT_FWT_MAX_DIFF 1u /**< The maximal difference between the requested FWT and HW-limited FWT settings.*/
+#define NFCT_FRAMEDELAYMAX_DEFAULT (0x00001000UL) /**< Default value of the FRAMEDELAYMAX. */
/* Mask of all possible interrupts that are relevant for data reception. */
#define NRFX_NFCT_RX_INT_MASK (NRF_NFCT_INT_RXFRAMESTART_MASK | \
@@ -105,8 +115,9 @@ static nrfx_nfct_timer_workaround_t m_timer_workaround =
#define NRFX_NFCT_BITS_TO_BYTES(_bits) ((_bits) >> 3)
/* Macro for checking whether the NFCT interrupt is active. */
-#define NRFX_NFCT_EVT_ACTIVE(_name) (nrf_nfct_event_check(NRFX_CONCAT_2(NRF_NFCT_EVENT_, _name)) && \
- nrf_nfct_int_enable_check(NRFX_CONCAT_3(NRF_NFCT_INT_, _name, _MASK)))
+#define NRFX_NFCT_EVT_ACTIVE(_name) \
+ (nrf_nfct_event_check(NRF_NFCT, NRFX_CONCAT_2(NRF_NFCT_EVENT_, _name)) && \
+ nrf_nfct_int_enable_check(NRF_NFCT, NRFX_CONCAT_3(NRF_NFCT_INT_, _name, _MASK)))
/* Macro for callback execution. */
#define NRFX_NFCT_CB_HANDLE(_cb, _evt) \
@@ -123,62 +134,13 @@ typedef enum
NRFX_NFC_FIELD_STATE_UNKNOWN /**< Both NFCT field events have been set - ambiguous state. */
} nrfx_nfct_field_state_t;
-#ifdef NRF52840_XXAA
-/**
- * @brief Internal auxiliary function for checking whether the program is running on the NRF52840 chip.
- *
- * @retval true It is NRF52480 chip.
- * @retval false It is an other chip.
- */
-static inline bool nrfx_nfct_type_52840_check(void)
-{
- return ((((*(uint32_t *)0xF0000FE0) & 0xFF) == 0x08) &&
- (((*(uint32_t *)0xF0000FE4) & 0x0F) == 0x0));
-}
-
-/**
- * @brief Internal auxiliary function for checking whether the program is running on the first sample of
- * the nRF52840 chip.
- *
- * @retval true It is the nRF52480 chip and it is the first sample version.
- * @retval false It is an other chip.
- */
-static inline bool nrfx_nfct_type_52840_sample_check(void)
-{
- return ( nrfx_nfct_type_52840_check() &&
- ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x00 ) &&
- ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) );
-}
-
-/**
- * @brief Internal auxiliary function for checking whether the program is running on the final version of
- * the nRF52840 chip.
- *
- * @retval true It is the nRF52480 chip and it is the final version.
- * @retval false It is an other chip.
- */
-static inline bool nrfx_nfct_type_52840_final_check(void)
-{
- return ( nrfx_nfct_type_52840_check() &&
- ( ( ((*(uint32_t *)0xF0000FE8) & 0xF0) != 0x00 ) ||
- ( ((*(uint32_t *)0xF0000FEC) & 0xF0) != 0x00 ) ));
-}
-
-typedef struct
-{
- bool eng_a; /**< Engineering sample A of the NRF52840 chip. */
- bool eng_bc; /**< Engineering sample B, C of the NRF52840 chip, or its final version. */
-} nrfx_nfct_nrf52840_ver_t;
-
-static nrfx_nfct_nrf52840_ver_t m_nrf52840;
-#endif // NRF52840_XXAA
-
/**@brief NFCT control block. */
typedef struct
{
nrfx_nfct_config_t config;
nrfx_drv_state_t state;
volatile bool field_on;
+ uint32_t frame_delay_max;
} nrfx_nfct_control_block_t;
static nrfx_nfct_control_block_t m_nfct_cb;
@@ -188,30 +150,28 @@ static nrfx_nfct_control_block_t m_nfct_cb;
*/
static void nrfx_nfct_hw_init_setup(void)
{
-#ifdef NRF52840_XXAA
- if (m_nrf52840.eng_a)
- {
- /* 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 // NRF52840_XXAA
-
// Use Window Grid frame delay mode.
- nrf_nfct_frame_delay_mode_set(NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID);
+ nrf_nfct_frame_delay_mode_set(NRF_NFCT, NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID);
/* Begin: Bugfix for FTPAN-25 (IC-9929) */
/* Workaround for wrong SENSRES values require using SDD00001, but here SDD00100 is used
because it is required to operate with Windows Phone */
- nrf_nfct_sensres_bit_frame_sdd_set(NRF_NFCT_SENSRES_BIT_FRAME_SDD_00100);
+ nrf_nfct_sensres_bit_frame_sdd_set(NRF_NFCT, NRF_NFCT_SENSRES_BIT_FRAME_SDD_00100);
/* End: Bugfix for FTPAN-25 (IC-9929) */
}
+static void nrfx_nfct_frame_delay_max_set(bool default_delay)
+{
+ if (default_delay)
+ {
+ nrf_nfct_frame_delay_max_set(NRF_NFCT, NFCT_FRAMEDELAYMAX_DEFAULT);
+ }
+ else
+ {
+ nrf_nfct_frame_delay_max_set(NRF_NFCT, m_nfct_cb.frame_delay_max);
+ }
+}
+
/**@brief Function for evaluating and handling the NFC field events.
*
* @param[in] field_state Current field state.
@@ -220,17 +180,18 @@ static void nrfx_nfct_field_event_handler(volatile nrfx_nfct_field_state_t field
{
nrfx_nfct_evt_t nfct_evt;
-#ifdef NRF52840_XXAA
- if((!m_nrf52840.eng_a) && (m_timer_workaround.fieldevents_filter_active))
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
+ if(m_timer_workaround.fieldevents_filter_active)
{
return;
}
-#endif // NRF52840_XXAA
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
if (field_state == NRFX_NFC_FIELD_STATE_UNKNOWN)
{
/* Probe NFC field */
- field_state = (nrfx_nfct_field_check()) ? NRFX_NFC_FIELD_STATE_ON : NRFX_NFC_FIELD_STATE_OFF;
+ field_state = (nrfx_nfct_field_check()) ? NRFX_NFC_FIELD_STATE_ON :
+ NRFX_NFC_FIELD_STATE_OFF;
}
/* Field event service */
@@ -239,23 +200,22 @@ static void nrfx_nfct_field_event_handler(volatile nrfx_nfct_field_state_t field
case NRFX_NFC_FIELD_STATE_ON:
if (!m_nfct_cb.field_on)
{
-#ifdef NRF52840_XXAA
+#if NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
/* Begin: Bugfix for FTPAN-190 */
- if (!m_nrf52840.eng_a)
- {
- m_timer_workaround.is_hfclk_on = false;
- m_timer_workaround.is_delayed = false;
- m_timer_workaround.fieldevents_filter_active = true;
-
- nrfx_timer_clear(&m_timer_workaround.timer);
- nrfx_timer_enable(&m_timer_workaround.timer);
- }
+ m_timer_workaround.is_hfclk_on = false;
+ m_timer_workaround.is_delayed = false;
+ m_timer_workaround.fieldevents_filter_active = true;
+
+ nrfx_timer_clear(&m_timer_workaround.timer);
+ nrfx_timer_enable(&m_timer_workaround.timer);
/* END: Bugfix for FTPAN-190 */
-#elif defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
+#elif NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_79)
nrfx_timer_clear(&m_timer_workaround.timer);
nrfx_timer_enable(&m_timer_workaround.timer);
- m_timer_workaround.field_state_cnt = 0;
-#endif // NRF52840_XXAA
+ m_timer_workaround.field_state_cnt = 0;
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
+#endif // NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
m_nfct_cb.field_on = true;
nfct_evt.evt_id = NRFX_NFCT_EVT_FIELD_DETECTED;
@@ -265,18 +225,12 @@ static void nrfx_nfct_field_event_handler(volatile nrfx_nfct_field_state_t field
case NRFX_NFC_FIELD_STATE_OFF:
nrfx_nfct_state_force(NRFX_NFCT_STATE_SENSING);
-#ifdef NRF52840_XXAA
- /* Begin: Bugfix for FTPAN-116 (IC-12886) */
- if (m_nrf52840.eng_a)
- {
- *(volatile uint32_t *)0x40005010 = 1;
- }
- /* END: Bugfix for FTPAN-116 (IC-12886) */
-#endif // NRF52840_XXAA
- nrf_nfct_int_disable(NRFX_NFCT_RX_INT_MASK | NRFX_NFCT_TX_INT_MASK);
+ nrf_nfct_int_disable(NRF_NFCT, NRFX_NFCT_RX_INT_MASK | NRFX_NFCT_TX_INT_MASK);
m_nfct_cb.field_on = false;
nfct_evt.evt_id = NRFX_NFCT_EVT_FIELD_LOST;
+ nrfx_nfct_frame_delay_max_set(true);
+
NRFX_NFCT_CB_HANDLE(m_nfct_cb.config.cb, nfct_evt);
break;
@@ -286,9 +240,9 @@ static void nrfx_nfct_field_event_handler(volatile nrfx_nfct_field_state_t field
}
}
-#ifdef USE_TIMER_WORKAROUND
+#if NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
-#ifdef NRF52840_XXAA
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
static void nrfx_nfct_activate_check(void)
{
static bool is_field_validation_pending = false;
@@ -305,7 +259,7 @@ static void nrfx_nfct_activate_check(void)
if ((m_timer_workaround.is_hfclk_on) && (m_timer_workaround.is_delayed))
{
- nrf_nfct_task_trigger(NRF_NFCT_TASK_ACTIVATE);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_ACTIVATE);
is_field_validation_pending = true;
// Start the timer second time to validate whether the tag has locked to the field.
@@ -313,9 +267,9 @@ static void nrfx_nfct_activate_check(void)
nrfx_timer_enable(&m_timer_workaround.timer);
}
}
-#endif // NRF52840_XXAA
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
-#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_79)
static inline void nrfx_nfct_reset(void)
{
uint32_t fdm;
@@ -325,10 +279,10 @@ static inline void nrfx_nfct_reset(void)
nrf_nfct_selres_protocol_t protocol;
// Save parameter settings before the reset of the NFCT peripheral.
- fdm = nrf_nfct_frame_delay_max_get();
- nfcid1_size = nrf_nfct_nfcid1_get(nfcid1);
- protocol = nrf_nfct_selsres_protocol_get();
- int_enabled = nrf_nfct_int_enable_get();
+ fdm = nrf_nfct_frame_delay_max_get(NRF_NFCT);
+ nfcid1_size = nrf_nfct_nfcid1_get(NRF_NFCT, nfcid1);
+ protocol = nrf_nfct_selres_protocol_get(NRF_NFCT);
+ int_enabled = nrf_nfct_int_enable_get(NRF_NFCT);
// Reset the NFCT peripheral.
*(volatile uint32_t *)0x40005FFC = 0;
@@ -336,18 +290,18 @@ static inline void nrfx_nfct_reset(void)
*(volatile uint32_t *)0x40005FFC = 1;
// Restore parameter settings after the reset of the NFCT peripheral.
- nrf_nfct_frame_delay_max_set(fdm);
- nrf_nfct_nfcid1_set(nfcid1, nfcid1_size);
- nrf_nfct_selres_protocol_set(protocol);
+ nrf_nfct_frame_delay_max_set(NRF_NFCT, fdm);
+ nrf_nfct_nfcid1_set(NRF_NFCT, nfcid1, nfcid1_size);
+ nrf_nfct_selres_protocol_set(NRF_NFCT, protocol);
// Restore general HW configuration.
nrfx_nfct_hw_init_setup();
// Restore interrupts.
- nrf_nfct_int_enable(int_enabled);
+ nrf_nfct_int_enable(NRF_NFCT, int_enabled);
// Disable interrupts associated with data exchange.
- nrf_nfct_int_disable(NRFX_NFCT_RX_INT_MASK | NRFX_NFCT_TX_INT_MASK);
+ nrf_nfct_int_disable(NRF_NFCT, NRFX_NFCT_RX_INT_MASK | NRFX_NFCT_TX_INT_MASK);
NRFX_LOG_INFO("Reinitialize");
}
@@ -366,6 +320,8 @@ static void nrfx_nfct_field_poll(void)
nrfx_timer_disable(&m_timer_workaround.timer);
m_nfct_cb.field_on = false;
+ nrfx_nfct_frame_delay_max_set(true);
+
/* Begin: Bugfix for FTPAN-116 */
// resume the NFCT to initialized state
nrfx_nfct_reset();
@@ -378,7 +334,7 @@ static void nrfx_nfct_field_poll(void)
m_timer_workaround.field_state_cnt = 0;
}
-#endif // defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_79)
static void nrfx_nfct_field_timer_handler(nrf_timer_event_t event_type, void * p_context)
{
@@ -389,28 +345,30 @@ static void nrfx_nfct_field_timer_handler(nrf_timer_event_t event_type, void * p
return;
}
-#ifdef NRF52840_XXAA
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
m_timer_workaround.is_delayed = true;
nrfx_timer_disable(&m_timer_workaround.timer);
nrfx_nfct_activate_check();
#else
nrfx_nfct_field_poll();
-#endif //NRF52840_XXAA
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
}
static inline nrfx_err_t nrfx_nfct_field_timer_config(void)
{
nrfx_err_t err_code;
- nrfx_timer_config_t timer_cfg =
+ nrfx_timer_config_t timer_cfg =
{
.frequency = NRF_TIMER_FREQ_1MHz,
.mode = NRF_TIMER_MODE_TIMER,
.bit_width = NRF_TIMER_BIT_WIDTH_16,
- .interrupt_priority = NRFX_NFCT_CONFIG_IRQ_PRIORITY
+ .interrupt_priority = NRFX_NFCT_DEFAULT_CONFIG_IRQ_PRIORITY
};
- err_code = nrfx_timer_init(&m_timer_workaround.timer, &timer_cfg, nrfx_nfct_field_timer_handler);
+ err_code = nrfx_timer_init(&m_timer_workaround.timer,
+ &timer_cfg,
+ nrfx_nfct_field_timer_handler);
if (err_code != NRFX_SUCCESS)
{
return err_code;
@@ -418,15 +376,17 @@ static inline nrfx_err_t nrfx_nfct_field_timer_config(void)
nrfx_timer_extended_compare(&m_timer_workaround.timer,
NRF_TIMER_CC_CHANNEL0,
- nrfx_timer_us_to_ticks(&m_timer_workaround.timer, NRFX_NFCT_TIMER_PERIOD),
+ nrfx_timer_us_to_ticks(&m_timer_workaround.timer,
+ NRFX_NFCT_TIMER_PERIOD),
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
true);
return err_code;
}
-#endif // USE_TIMER_WORKAROUND
+#endif // NFCT_WORKAROUND_USES_TIMER
-static inline nrf_nfct_sensres_nfcid1_size_t nrf_nfct_nfcid1_size_to_sensres_size(uint8_t nfcid1_size)
+static inline
+nrf_nfct_sensres_nfcid1_size_t nrf_nfct_nfcid1_size_to_sensres_size(uint8_t nfcid1_size)
{
switch (nfcid1_size)
{
@@ -446,7 +406,7 @@ static inline nrf_nfct_sensres_nfcid1_size_t nrf_nfct_nfcid1_size_to_sensres_siz
static inline void nrfx_nfct_rxtx_int_enable(uint32_t rxtx_int_mask)
{
- nrf_nfct_int_enable(rxtx_int_mask & m_nfct_cb.config.rxtx_int_mask);
+ nrf_nfct_int_enable(NRF_NFCT, rxtx_int_mask & m_nfct_cb.config.rxtx_int_mask);
}
nrfx_err_t nrfx_nfct_init(nrfx_nfct_config_t const * p_config)
@@ -460,41 +420,32 @@ nrfx_err_t nrfx_nfct_init(nrfx_nfct_config_t const * p_config)
return NRFX_ERROR_INVALID_STATE;
}
-#ifdef NRF52840_XXAA
- m_nrf52840.eng_a = nrfx_nfct_type_52840_sample_check();
- m_nrf52840.eng_bc = nrfx_nfct_type_52840_final_check();
-#endif // NRF52840_XXAA
-
m_nfct_cb.config = *p_config;
nrfx_nfct_hw_init_setup();
NRFX_IRQ_PENDING_CLEAR(NFCT_IRQn);
- NRFX_IRQ_PRIORITY_SET(NFCT_IRQn, NRFX_NFCT_CONFIG_IRQ_PRIORITY);
+ NRFX_IRQ_PRIORITY_SET(NFCT_IRQn, NRFX_NFCT_DEFAULT_CONFIG_IRQ_PRIORITY);
NRFX_IRQ_ENABLE(NFCT_IRQn);
-#ifdef USE_TIMER_WORKAROUND
+#if NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
/* Initialize Timer module as the workaround for NFCT HW issues. */
- #ifdef NRF52840_XXAA
- if (!m_nrf52840.eng_a)
- #endif // NRF52840_XXAA
- {
- err_code = nrfx_nfct_field_timer_config();
- }
-#endif // USE_TIMER_WORKAROUND
+ err_code = nrfx_nfct_field_timer_config();
+#endif // NFCT_WORKAROUND_USES_TIMER
if (err_code == NRFX_SUCCESS)
{
uint8_t default_nfcid1[NRFX_NFCT_NFCID1_DEFAULT_LEN];
err_code = nrfx_nfct_nfcid1_default_bytes_get(default_nfcid1, sizeof(default_nfcid1));
NRFX_ASSERT(err_code == NRFX_SUCCESS);
- nrf_nfct_nfcid1_set(default_nfcid1, NRF_NFCT_SENSRES_NFCID1_SIZE_DEFAULT);
+ nrf_nfct_nfcid1_set(NRF_NFCT, default_nfcid1, NRF_NFCT_SENSRES_NFCID1_SIZE_DEFAULT);
}
else
{
return err_code;
}
- m_nfct_cb.state = NRFX_DRV_STATE_INITIALIZED;
+ m_nfct_cb.state = NRFX_DRV_STATE_INITIALIZED;
+ m_nfct_cb.frame_delay_max = NFCT_FRAMEDELAYMAX_DEFAULT;
NRFX_LOG_INFO("Initialized");
return err_code;
@@ -507,28 +458,24 @@ void nrfx_nfct_uninit(void)
NRFX_IRQ_DISABLE(NFCT_IRQn);
NRFX_IRQ_PENDING_CLEAR(NFCT_IRQn);
-#ifdef USE_TIMER_WORKAROUND
- /* Initialize Timer module as the workaround for NFCT HW issues. */
- #ifdef NRF52840_XXAA
- if (!m_nrf52840.eng_a)
- #endif // NRF52840_XXAA
- {
- nrfx_timer_uninit(&m_timer_workaround.timer);
- }
-#endif // USE_TIMER_WORKAROUND
+#if NRFX_CHECK(NFCT_WORKAROUND_USES_TIMER)
+ /* De-initialize Timer module as the workaround for NFCT HW issues. */
+ nrfx_timer_uninit(&m_timer_workaround.timer);
+#endif // NFCT_WORKAROUND_USES_TIMER
m_nfct_cb.state = NRFX_DRV_STATE_UNINITIALIZED;
}
void nrfx_nfct_enable(void)
{
- nrf_nfct_error_status_clear(NRFX_NFCT_ERROR_STATUS_ALL_MASK);
- nrf_nfct_task_trigger(NRF_NFCT_TASK_SENSE);
+ nrf_nfct_error_status_clear(NRF_NFCT, NRFX_NFCT_ERROR_STATUS_ALL_MASK);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_SENSE);
- nrf_nfct_int_enable(NRF_NFCT_INT_FIELDDETECTED_MASK | NRF_NFCT_INT_ERROR_MASK |
- NRF_NFCT_INT_SELECTED_MASK);
+ nrf_nfct_int_enable(NRF_NFCT, NRF_NFCT_INT_FIELDDETECTED_MASK |
+ NRF_NFCT_INT_ERROR_MASK |
+ NRF_NFCT_INT_SELECTED_MASK);
#if !defined(NRF52832_XXAA) && !defined(NRF52832_XXAB)
- nrf_nfct_int_enable(NRF_NFCT_INT_FIELDLOST_MASK);
+ nrf_nfct_int_enable(NRF_NFCT, NRF_NFCT_INT_FIELDLOST_MASK);
#endif //!defined(NRF52832_XXAA) && !defined(NRF52832_XXAB)
NRFX_LOG_INFO("Start");
@@ -536,15 +483,15 @@ void nrfx_nfct_enable(void)
void nrfx_nfct_disable(void)
{
- nrf_nfct_int_disable(NRF_NFCT_DISABLE_ALL_INT);
- nrf_nfct_task_trigger(NRF_NFCT_TASK_DISABLE);
+ nrf_nfct_int_disable(NRF_NFCT, NRF_NFCT_DISABLE_ALL_INT);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_DISABLE);
NRFX_LOG_INFO("Stop");
}
bool nrfx_nfct_field_check(void)
{
- uint32_t const field_state = nrf_nfct_field_status_get();
+ uint32_t const field_state = nrf_nfct_field_status_get(NRF_NFCT);
if (((field_state & NRF_NFCT_FIELD_STATE_PRESENT_MASK) == 0) &&
((field_state & NRF_NFCT_FIELD_STATE_LOCK_MASK) == 0))
@@ -560,10 +507,10 @@ void nrfx_nfct_rx(nrfx_nfct_data_desc_t const * p_tx_data)
{
NRFX_ASSERT(p_tx_data);
- nrf_nfct_rxtx_buffer_set((uint8_t *) p_tx_data->p_data, p_tx_data->data_size);
+ nrf_nfct_rxtx_buffer_set(NRF_NFCT, (uint8_t *) p_tx_data->p_data, p_tx_data->data_size);
nrfx_nfct_rxtx_int_enable(NRFX_NFCT_RX_INT_MASK);
- nrf_nfct_task_trigger(NRF_NFCT_TASK_ENABLERXDATA);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_ENABLERXDATA);
}
nrfx_err_t nrfx_nfct_tx(nrfx_nfct_data_desc_t const * p_tx_data,
@@ -577,12 +524,12 @@ nrfx_err_t nrfx_nfct_tx(nrfx_nfct_data_desc_t const * p_tx_data,
return NRFX_ERROR_INVALID_LENGTH;
}
- nrf_nfct_rxtx_buffer_set((uint8_t *) p_tx_data->p_data, p_tx_data->data_size);
- nrf_nfct_tx_bits_set(NRFX_NFCT_BYTES_TO_BITS(p_tx_data->data_size));
- nrf_nfct_frame_delay_mode_set((nrf_nfct_frame_delay_mode_t) delay_mode);
+ nrf_nfct_rxtx_buffer_set(NRF_NFCT, (uint8_t *) p_tx_data->p_data, p_tx_data->data_size);
+ nrf_nfct_tx_bits_set(NRF_NFCT, NRFX_NFCT_BYTES_TO_BITS(p_tx_data->data_size));
+ nrf_nfct_frame_delay_mode_set(NRF_NFCT, (nrf_nfct_frame_delay_mode_t) delay_mode);
nrfx_nfct_rxtx_int_enable(NRFX_NFCT_TX_INT_MASK);
- nrf_nfct_task_trigger(NRF_NFCT_TASK_STARTTX);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_STARTTX);
NRFX_LOG_INFO("Tx start");
return NRFX_SUCCESS;
@@ -590,16 +537,14 @@ nrfx_err_t nrfx_nfct_tx(nrfx_nfct_data_desc_t const * p_tx_data,
void nrfx_nfct_state_force(nrfx_nfct_state_t state)
{
-#ifdef NRF52840_XXAA
- if ((m_nrf52840.eng_bc) && (state == NRFX_NFCT_STATE_ACTIVATED))
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
+ if (state == NRFX_NFCT_STATE_ACTIVATED)
{
m_timer_workaround.is_hfclk_on = true;
nrfx_nfct_activate_check();
}
-#endif
- {
- nrf_nfct_task_trigger((nrf_nfct_task_t) state);
- }
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_190)
+ nrf_nfct_task_trigger(NRF_NFCT, (nrf_nfct_task_t) state);
}
void nrfx_nfct_init_substate_force(nrfx_nfct_active_state_t sub_state)
@@ -609,25 +554,27 @@ void nrfx_nfct_init_substate_force(nrfx_nfct_active_state_t sub_state)
#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
if (((*(uint32_t volatile *)(0x40005420)) & 0x1UL) == (1UL))
#else
- if (nrf_nfct_sleep_state_get() == NRF_NFCT_SLEEP_STATE_SLEEP_A)
+ if (nrf_nfct_sleep_state_get(NRF_NFCT) == NRF_NFCT_SLEEP_STATE_SLEEP_A)
#endif //defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
{
// Default state is SLEEP_A
- nrf_nfct_task_trigger(NRF_NFCT_TASK_GOSLEEP);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_GOSLEEP);
}
else
{
// Default state is IDLE
- nrf_nfct_task_trigger(NRF_NFCT_TASK_GOIDLE);
+ nrf_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_GOIDLE);
}
}
else
{
- nrf_nfct_task_trigger((nrf_nfct_task_t) sub_state);
+ nrf_nfct_task_trigger(NRF_NFCT, (nrf_nfct_task_t) sub_state);
}
+ nrfx_nfct_frame_delay_max_set(true);
+
/* Disable TX/RX here (will be enabled at SELECTED) */
- nrf_nfct_int_disable(NRFX_NFCT_RX_INT_MASK | NRFX_NFCT_TX_INT_MASK);
+ nrf_nfct_int_disable(NRF_NFCT, NRFX_NFCT_RX_INT_MASK | NRFX_NFCT_TX_INT_MASK);
}
nrfx_err_t nrfx_nfct_parameter_set(nrfx_nfct_param_t const * p_param)
@@ -641,10 +588,6 @@ nrfx_err_t nrfx_nfct_parameter_set(nrfx_nfct_param_t const * p_param)
uint32_t delay = p_param->data.fdt;
uint32_t delay_thr = NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Msk;
-#ifdef NRF52840_XXAA
- delay_thr = (m_nrf52840.eng_a) ? NRFX_NFCT_FRAMEDELAYMAX_52840S : delay_thr;
-#endif // NRF52840_XXAA
-
// Delay validation.
if (delay > (delay_thr + NRFX_NFCT_FWT_MAX_DIFF))
{
@@ -652,7 +595,7 @@ nrfx_err_t nrfx_nfct_parameter_set(nrfx_nfct_param_t const * p_param)
}
delay = (delay > delay_thr) ? delay_thr : delay;
- nrf_nfct_frame_delay_max_set(delay);
+ m_nfct_cb.frame_delay_max = delay;
break;
}
@@ -662,7 +605,8 @@ nrfx_err_t nrfx_nfct_parameter_set(nrfx_nfct_param_t const * p_param)
return NRFX_ERROR_INVALID_PARAM;
}
- nrf_nfct_selres_protocol_set((nrf_nfct_selres_protocol_t) p_param->data.sel_res_protocol);
+ nrf_nfct_selres_protocol_set(NRF_NFCT,
+ (nrf_nfct_selres_protocol_t) p_param->data.sel_res_protocol);
break;
case NRFX_NFCT_PARAM_ID_NFCID1:
@@ -670,7 +614,7 @@ nrfx_err_t nrfx_nfct_parameter_set(nrfx_nfct_param_t const * p_param)
nrf_nfct_sensres_nfcid1_size_t id_size_mask;
id_size_mask = nrf_nfct_nfcid1_size_to_sensres_size(p_param->data.nfcid1.id_size);
- nrf_nfct_nfcid1_set(p_param->data.nfcid1.p_id, id_size_mask);
+ nrf_nfct_nfcid1_set(NRF_NFCT, p_param->data.nfcid1.p_id, id_size_mask);
break;
}
@@ -691,10 +635,16 @@ nrfx_err_t nrfx_nfct_nfcid1_default_bytes_get(uint8_t * const p_nfcid1_buff,
return NRFX_ERROR_INVALID_LENGTH;
}
+#if defined(FICR_NFC_TAGHEADER0_MFGID_Msk)
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;
+#else
+ uint32_t nfc_tag_header0 = 0x5F;
+ uint32_t nfc_tag_header1 = 0;
+ uint32_t nfc_tag_header2 = 0;
+#endif
p_nfcid1_buff[0] = (uint8_t) (nfc_tag_header0 >> 0);
p_nfcid1_buff[1] = (uint8_t) (nfc_tag_header0 >> 8);
p_nfcid1_buff[2] = (uint8_t) (nfc_tag_header0 >> 16);
@@ -713,7 +663,7 @@ nrfx_err_t nrfx_nfct_nfcid1_default_bytes_get(uint8_t * const p_nfcid1_buff,
p_nfcid1_buff[9] = (uint8_t) (nfc_tag_header2 >> 16);
}
/* Begin: Bugfix for FTPAN-181. */
- /* Workaround for wrong value in NFCID1. Value 0x88 cannot be used as byte 3
+ /* Workaround for wrong value in NFCID1. Value 0x88 cannot be used as byte 3
of a double-size NFCID1, according to the NFC Forum Digital Protocol specification. */
else if (p_nfcid1_buff[3] == 0x88)
{
@@ -730,7 +680,7 @@ void nrfx_nfct_autocolres_enable(void)
#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
(*(uint32_t *)(0x4000559C)) &= (~(0x1UL));
#else
- nrf_nfct_autocolres_enable();
+ nrf_nfct_autocolres_enable(NRF_NFCT);
#endif //defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
}
@@ -739,7 +689,7 @@ void nrfx_nfct_autocolres_disable(void)
#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
(*(uint32_t *)(0x4000559C)) |= (0x1UL);
#else
- nrf_nfct_autocolres_disable();
+ nrf_nfct_autocolres_disable(NRF_NFCT);
#endif //defined(NRF52832_XXAA) || defined(NRF52832_XXAB)
}
@@ -749,22 +699,22 @@ void nrfx_nfct_irq_handler(void)
if (NRFX_NFCT_EVT_ACTIVE(FIELDDETECTED))
{
- nrf_nfct_event_clear(NRF_NFCT_EVENT_FIELDDETECTED);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_FIELDDETECTED);
current_field = NRFX_NFC_FIELD_STATE_ON;
NRFX_LOG_DEBUG("Field detected");
}
-#if !defined(NRF52832_XXAA) && !defined(NRF52832_XXAB)
+#if !NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_79)
if (NRFX_NFCT_EVT_ACTIVE(FIELDLOST))
{
- nrf_nfct_event_clear(NRF_NFCT_EVENT_FIELDLOST);
- current_field = (current_field == NRFX_NFC_FIELD_STATE_NONE) ?
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_FIELDLOST);
+ current_field = (current_field == NRFX_NFC_FIELD_STATE_NONE) ?
NRFX_NFC_FIELD_STATE_OFF : NRFX_NFC_FIELD_STATE_UNKNOWN;
NRFX_LOG_DEBUG("Field lost");
}
-#endif //!defined(NRF52832_XXAA) && !defined(NRF52832_XXAB)
+#endif //!NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_79)
/* Perform actions if any FIELD event is active */
if (current_field != NRFX_NFC_FIELD_STATE_NONE)
@@ -774,7 +724,7 @@ void nrfx_nfct_irq_handler(void)
if (NRFX_NFCT_EVT_ACTIVE(RXFRAMEEND))
{
- nrf_nfct_event_clear(NRF_NFCT_EVENT_RXFRAMEEND);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_RXFRAMEEND);
nrfx_nfct_evt_t nfct_evt =
{
@@ -783,32 +733,33 @@ void nrfx_nfct_irq_handler(void)
/* Take into account only the number of whole bytes. */
nfct_evt.params.rx_frameend.rx_status = 0;
- nfct_evt.params.rx_frameend.rx_data.p_data = nrf_nfct_rxtx_buffer_get();
- nfct_evt.params.rx_frameend.rx_data.data_size = NRFX_NFCT_BITS_TO_BYTES(nrf_nfct_rx_bits_get(true));
+ nfct_evt.params.rx_frameend.rx_data.p_data = nrf_nfct_rxtx_buffer_get(NRF_NFCT);
+ nfct_evt.params.rx_frameend.rx_data.data_size =
+ NRFX_NFCT_BITS_TO_BYTES(nrf_nfct_rx_bits_get(NRF_NFCT, true));
if (NRFX_NFCT_EVT_ACTIVE(RXERROR))
{
- nfct_evt.params.rx_frameend.rx_status =
- (nrf_nfct_rx_frame_status_get() & NRFX_NFCT_FRAME_STATUS_RX_ALL_MASK);
- nrf_nfct_event_clear(NRF_NFCT_EVENT_RXERROR);
+ nfct_evt.params.rx_frameend.rx_status =
+ (nrf_nfct_rx_frame_status_get(NRF_NFCT) & NRFX_NFCT_FRAME_STATUS_RX_ALL_MASK);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_RXERROR);
NRFX_LOG_DEBUG("Rx error (0x%x)", (unsigned int) nfct_evt.params.rx_frameend.rx_status);
/* Clear rx frame status */
- nrf_nfct_rx_frame_status_clear(NRFX_NFCT_FRAME_STATUS_RX_ALL_MASK);
+ nrf_nfct_rx_frame_status_clear(NRF_NFCT, NRFX_NFCT_FRAME_STATUS_RX_ALL_MASK);
}
NRFX_NFCT_CB_HANDLE(m_nfct_cb.config.cb, nfct_evt);
/* Clear TXFRAMESTART EVENT so it can be checked in hal_nfc_send */
- nrf_nfct_event_clear(NRF_NFCT_EVENT_TXFRAMESTART);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_TXFRAMESTART);
NRFX_LOG_DEBUG("Rx fend");
}
if (NRFX_NFCT_EVT_ACTIVE(TXFRAMEEND))
{
- nrf_nfct_event_clear(NRF_NFCT_EVENT_TXFRAMEEND);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_TXFRAMEEND);
nrfx_nfct_evt_t nfct_evt =
{
@@ -816,7 +767,7 @@ void nrfx_nfct_irq_handler(void)
};
/* Disable TX END event to ignore frame transmission other than READ response */
- nrf_nfct_int_disable(NRFX_NFCT_TX_INT_MASK);
+ nrf_nfct_int_disable(NRF_NFCT, NRFX_NFCT_TX_INT_MASK);
NRFX_NFCT_CB_HANDLE(m_nfct_cb.config.cb, nfct_evt);
@@ -825,17 +776,19 @@ void nrfx_nfct_irq_handler(void)
if (NRFX_NFCT_EVT_ACTIVE(SELECTED))
{
- nrf_nfct_event_clear(NRF_NFCT_EVENT_SELECTED);
- /* Clear also RX END and RXERROR events because SW does not take care of
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_SELECTED);
+ /* Clear also RX END and RXERROR events because SW does not take care of
commands that were received before selecting the tag. */
- nrf_nfct_event_clear(NRF_NFCT_EVENT_RXFRAMEEND);
- nrf_nfct_event_clear(NRF_NFCT_EVENT_RXERROR);
- nrf_nfct_event_clear(NRF_NFCT_EVENT_TXFRAMESTART);
- nrf_nfct_event_clear(NRF_NFCT_EVENT_TXFRAMEEND);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_RXFRAMEEND);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_RXERROR);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_TXFRAMESTART);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_TXFRAMEEND);
+
+ nrfx_nfct_frame_delay_max_set(false);
/* At this point any previous error status can be ignored. */
- nrf_nfct_rx_frame_status_clear(NRFX_NFCT_FRAME_STATUS_RX_ALL_MASK);
- nrf_nfct_error_status_clear(NRFX_NFCT_ERROR_STATUS_ALL_MASK);
+ nrf_nfct_rx_frame_status_clear(NRF_NFCT, NRFX_NFCT_FRAME_STATUS_RX_ALL_MASK);
+ nrf_nfct_error_status_clear(NRF_NFCT, NRFX_NFCT_ERROR_STATUS_ALL_MASK);
nrfx_nfct_evt_t nfct_evt =
{
@@ -848,8 +801,8 @@ void nrfx_nfct_irq_handler(void)
if (NRFX_NFCT_EVT_ACTIVE(ERROR))
{
- uint32_t err_status = nrf_nfct_error_status_get();
- nrf_nfct_event_clear(NRF_NFCT_EVENT_ERROR);
+ uint32_t err_status = nrf_nfct_error_status_get(NRF_NFCT);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_ERROR);
nrfx_nfct_evt_t nfct_evt =
{
@@ -859,7 +812,7 @@ void nrfx_nfct_irq_handler(void)
/* Clear FRAMEDELAYTIMEOUT error (expected HW behaviour) when SLP_REQ command was received. */
if (err_status & NRF_NFCT_ERROR_FRAMEDELAYTIMEOUT_MASK)
{
- nrf_nfct_error_status_clear(NRF_NFCT_ERROR_FRAMEDELAYTIMEOUT_MASK);
+ nrf_nfct_error_status_clear(NRF_NFCT, NRF_NFCT_ERROR_FRAMEDELAYTIMEOUT_MASK);
nfct_evt.params.error.reason = NRFX_NFCT_ERROR_FRAMEDELAYTIMEOUT;
NRFX_NFCT_CB_HANDLE(m_nfct_cb.config.cb, nfct_evt);
@@ -873,20 +826,21 @@ void nrfx_nfct_irq_handler(void)
}
/* Clear error status. */
- nrf_nfct_error_status_clear(NRFX_NFCT_ERROR_STATUS_ALL_MASK);
+ nrf_nfct_error_status_clear(NRF_NFCT, NRFX_NFCT_ERROR_STATUS_ALL_MASK);
}
if (NRFX_NFCT_EVT_ACTIVE(TXFRAMESTART))
{
- nrf_nfct_event_clear(NRF_NFCT_EVENT_TXFRAMESTART);
+ nrf_nfct_event_clear(NRF_NFCT, NRF_NFCT_EVENT_TXFRAMESTART);
if (m_nfct_cb.config.cb != NULL)
{
nrfx_nfct_evt_t nfct_evt;
nfct_evt.evt_id = NRFX_NFCT_EVT_TX_FRAMESTART;
- nfct_evt.params.tx_framestart.tx_data.p_data = nrf_nfct_rxtx_buffer_get();
- nfct_evt.params.tx_framestart.tx_data.data_size = NRFX_NFCT_BITS_TO_BYTES(nrf_nfct_tx_bits_get());
+ nfct_evt.params.tx_framestart.tx_data.p_data = nrf_nfct_rxtx_buffer_get(NRF_NFCT);
+ nfct_evt.params.tx_framestart.tx_data.data_size =
+ NRFX_NFCT_BITS_TO_BYTES(nrf_nfct_tx_bits_get(NRF_NFCT));
m_nfct_cb.config.cb(&nfct_evt);
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c
index 343f8d7..f4e93ca 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c
@@ -49,8 +49,10 @@
* This symbol is needed to determine NVM page count for chips that cannot
* always access FICR for this information.
*/
-#if defined(NRF9160_XXAA)
+#if defined(NRF9160_XXAA) || defined(NRF5340_XXAA_APPLICATION)
#define NVMC_FLASH_PAGE_COUNT 256
+#elif defined(NRF5340_XXAA_NETWORK)
+ #define NVMC_FLASH_PAGE_COUNT 128
#endif
/**
@@ -59,8 +61,10 @@
* This symbol is needed to determine NVM page size for chips that cannot
* always access FICR for this information.
*/
-#if defined(NRF9160_XXAA)
+#if defined(NRF9160_XXAA) || defined(NRF5340_XXAA_APPLICATION)
#define NVMC_FLASH_PAGE_SIZE 0x1000 ///< 4 kB
+#elif defined(NRF5340_XXAA_NETWORK)
+ #define NVMC_FLASH_PAGE_SIZE 0x800 ///< 2 kB
#endif
#if defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
@@ -71,7 +75,8 @@
*/
#if defined(NRF52810_XXAA) || defined(NRF52811_XXAA) || defined(NRF52840_XXAA)
#define NVMC_PAGE_ERASE_DURATION_MS 85
-#elif defined(NRF9160_XXAA)
+#elif defined(NRF52833_XXAA) || defined(NRF9160_XXAA) || \
+ defined(NRF5340_XXAA_APPLICATION) || defined(NRF5340_XXAA_NETWORK)
#define NVMC_PAGE_ERASE_DURATION_MS 87
#else
#error "Page partial erase present but could not determine its total duration for given SoC"
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c
index 1789e44..8b14b33 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c
@@ -73,9 +73,9 @@ static nrfx_pdm_cb_t m_cb;
void nrfx_pdm_irq_handler(void)
{
- if (nrf_pdm_event_check(NRF_PDM_EVENT_STARTED))
+ if (nrf_pdm_event_check(NRF_PDM, NRF_PDM_EVENT_STARTED))
{
- nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED);
+ nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STARTED);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_PDM_EVENT_STARTED));
uint8_t finished_buffer = m_cb.active_buffer;
@@ -125,11 +125,11 @@ void nrfx_pdm_irq_handler(void)
m_cb.op_state = NRFX_PDM_STATE_RUNNING;
}
}
- else if (nrf_pdm_event_check(NRF_PDM_EVENT_STOPPED))
+ else if (nrf_pdm_event_check(NRF_PDM, NRF_PDM_EVENT_STOPPED))
{
- nrf_pdm_event_clear(NRF_PDM_EVENT_STOPPED);
+ nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STOPPED);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_PDM_EVENT_STOPPED));
- nrf_pdm_disable();
+ nrf_pdm_disable(NRF_PDM);
m_cb.op_state = NRFX_PDM_STATE_IDLE;
// Release the buffers.
@@ -200,21 +200,21 @@ nrfx_err_t nrfx_pdm_init(nrfx_pdm_config_t const * p_config,
m_cb.event_handler = event_handler;
m_cb.op_state = NRFX_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_pdm_clock_set(NRF_PDM, p_config->clock_freq);
+ nrf_pdm_mode_set(NRF_PDM, p_config->mode, p_config->edge);
+ nrf_pdm_gain_set(NRF_PDM, 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);
- NRFX_IRQ_PRIORITY_SET(PDM_IRQn, p_config->interrupt_priority);
- NRFX_IRQ_ENABLE(PDM_IRQn);
+ nrf_pdm_psel_connect(NRF_PDM, p_config->pin_clk, p_config->pin_din);
+
+ nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STARTED);
+ nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_END);
+ nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STOPPED);
+ nrf_pdm_int_enable(NRF_PDM, NRF_PDM_INT_STARTED | NRF_PDM_INT_STOPPED);
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_PDM), p_config->interrupt_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_PDM));
m_cb.drv_state = NRFX_DRV_STATE_INITIALIZED;
err_code = NRFX_SUCCESS;
@@ -226,8 +226,8 @@ nrfx_err_t nrfx_pdm_init(nrfx_pdm_config_t const * p_config,
void nrfx_pdm_uninit(void)
{
- nrf_pdm_disable();
- nrf_pdm_psel_disconnect();
+ nrf_pdm_disable(NRF_PDM);
+ nrf_pdm_psel_disconnect(NRF_PDM);
m_cb.drv_state = NRFX_DRV_STATE_UNINITIALIZED;
NRFX_LOG_INFO("Uninitialized.");
}
@@ -235,15 +235,15 @@ void nrfx_pdm_uninit(void)
static void pdm_start()
{
m_cb.drv_state = NRFX_DRV_STATE_POWERED_ON;
- nrf_pdm_enable();
- nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED);
- nrf_pdm_task_trigger(NRF_PDM_TASK_START);
+ nrf_pdm_enable(NRF_PDM);
+ nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STARTED);
+ nrf_pdm_task_trigger(NRF_PDM, NRF_PDM_TASK_START);
}
static void pdm_buf_request()
{
m_cb.irq_buff_request = 1;
- NRFX_IRQ_PENDING_SET(PDM_IRQn);
+ NRFX_IRQ_PENDING_SET(nrfx_get_irq_number(NRF_PDM));
}
nrfx_err_t nrfx_pdm_start(void)
@@ -296,7 +296,7 @@ nrfx_err_t nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length)
nrfx_err_t err_code = NRFX_SUCCESS;
// Enter the PDM critical section.
- NRFX_IRQ_DISABLE(PDM_IRQn);
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_PDM));
uint8_t next_buffer = (~m_cb.active_buffer) & 0x01;
if (m_cb.op_state == NRFX_PDM_STATE_STARTING)
@@ -313,7 +313,7 @@ nrfx_err_t nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length)
{
m_cb.buff_address[next_buffer] = buffer;
m_cb.buff_length[next_buffer] = buffer_length;
- nrf_pdm_buffer_set((uint32_t *)buffer, buffer_length);
+ nrf_pdm_buffer_set(NRF_PDM, (uint32_t *)buffer, buffer_length);
if (m_cb.drv_state != NRFX_DRV_STATE_POWERED_ON)
{
@@ -321,7 +321,7 @@ nrfx_err_t nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length)
}
}
- NRFX_IRQ_ENABLE(PDM_IRQn);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_PDM));
return err_code;
}
@@ -335,7 +335,7 @@ nrfx_err_t nrfx_pdm_stop(void)
if (m_cb.op_state == NRFX_PDM_STATE_IDLE ||
m_cb.op_state == NRFX_PDM_STATE_STARTING)
{
- nrf_pdm_disable();
+ nrf_pdm_disable(NRF_PDM);
m_cb.op_state = NRFX_PDM_STATE_IDLE;
err_code = NRFX_SUCCESS;
NRFX_LOG_INFO("Function: %s, error code: %s.",
@@ -352,7 +352,7 @@ nrfx_err_t nrfx_pdm_stop(void)
m_cb.drv_state = NRFX_DRV_STATE_INITIALIZED;
m_cb.op_state = NRFX_PDM_STATE_STOPPING;
- nrf_pdm_task_trigger(NRF_PDM_TASK_STOP);
+ nrf_pdm_task_trigger(NRF_PDM, NRF_PDM_TASK_STOP);
err_code = NRFX_SUCCESS;
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_power.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_power.c
index 44963c2..5bb5da8 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_power.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_power.c
@@ -106,12 +106,12 @@ nrfx_err_t nrfx_power_init(nrfx_power_config_t const * p_config)
return NRFX_ERROR_ALREADY_INITIALIZED;
}
-#if NRF_POWER_HAS_VDDH
- nrf_power_dcdcen_vddh_set(p_config->dcdcenhv);
+#if NRF_POWER_HAS_DCDCEN_VDDH
+ nrf_power_dcdcen_vddh_set(NRF_POWER, p_config->dcdcenhv);
#endif
#if NRF_POWER_HAS_DCDCEN
- nrf_power_dcdcen_set(p_config->dcdcen);
-#else
+ nrf_power_dcdcen_set(NRF_POWER, p_config->dcdcen);
+#elif defined(REGULATORS_PRESENT)
nrf_regulators_dcdcen_set(NRF_REGULATORS, p_config->dcdcen);
#endif
@@ -159,20 +159,20 @@ void nrfx_power_pof_init(nrfx_power_pofwarn_config_t const * p_config)
void nrfx_power_pof_enable(nrfx_power_pofwarn_config_t const * p_config)
{
- nrf_power_pofcon_set(true, p_config->thr);
+ nrf_power_pofcon_set(NRF_POWER, true, p_config->thr);
#if NRF_POWER_HAS_VDDH
- nrf_power_pofcon_vddh_set(p_config->thrvddh);
+ nrf_power_pofcon_vddh_set(NRF_POWER, p_config->thrvddh);
#endif
if (m_pofwarn_handler != NULL)
{
- nrf_power_int_enable(NRF_POWER_INT_POFWARN_MASK);
+ nrf_power_int_enable(NRF_POWER, NRF_POWER_INT_POFWARN_MASK);
}
}
void nrfx_power_pof_disable(void)
{
- nrf_power_pofcon_set(false, NRF_POWER_POFTHR_V27);
- nrf_power_int_disable(NRF_POWER_INT_POFWARN_MASK);
+ nrf_power_pofcon_set(NRF_POWER, false, NRF_POWER_POFTHR_V27);
+ nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_POFWARN_MASK);
}
void nrfx_power_pof_uninit(void)
@@ -199,21 +199,20 @@ void nrfx_power_sleepevt_enable(nrfx_power_sleepevt_config_t const * p_config)
if (p_config->en_enter)
{
enmask |= NRF_POWER_INT_SLEEPENTER_MASK;
- nrf_power_event_clear(NRF_POWER_EVENT_SLEEPENTER);
+ nrf_power_event_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPENTER);
}
if (p_config->en_exit)
{
enmask |= NRF_POWER_INT_SLEEPEXIT_MASK;
- nrf_power_event_clear(NRF_POWER_EVENT_SLEEPEXIT);
+ nrf_power_event_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPEXIT);
}
- nrf_power_int_enable(enmask);
+ nrf_power_int_enable(NRF_POWER, enmask);
}
void nrfx_power_sleepevt_disable(void)
{
- nrf_power_int_disable(
- NRF_POWER_INT_SLEEPENTER_MASK |
- NRF_POWER_INT_SLEEPEXIT_MASK);
+ nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_SLEEPENTER_MASK |
+ NRF_POWER_INT_SLEEPEXIT_MASK);
}
void nrfx_power_sleepevt_uninit(void)
@@ -236,18 +235,16 @@ void nrfx_power_usbevt_init(nrfx_power_usbevt_config_t const * p_config)
void nrfx_power_usbevt_enable(void)
{
- nrf_power_int_enable(
- NRF_POWER_INT_USBDETECTED_MASK |
- NRF_POWER_INT_USBREMOVED_MASK |
- NRF_POWER_INT_USBPWRRDY_MASK);
+ nrf_power_int_enable(NRF_POWER, NRF_POWER_INT_USBDETECTED_MASK |
+ NRF_POWER_INT_USBREMOVED_MASK |
+ NRF_POWER_INT_USBPWRRDY_MASK);
}
void nrfx_power_usbevt_disable(void)
{
- nrf_power_int_disable(
- NRF_POWER_INT_USBDETECTED_MASK |
- NRF_POWER_INT_USBREMOVED_MASK |
- NRF_POWER_INT_USBPWRRDY_MASK);
+ nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_USBDETECTED_MASK |
+ NRF_POWER_INT_USBREMOVED_MASK |
+ NRF_POWER_INT_USBPWRRDY_MASK);
}
void nrfx_power_usbevt_uninit(void)
@@ -259,11 +256,11 @@ void nrfx_power_usbevt_uninit(void)
void nrfx_power_irq_handler(void)
{
- uint32_t enabled = nrf_power_int_enable_get();
+ uint32_t enabled = nrf_power_int_enable_get(NRF_POWER);
#if NRF_POWER_HAS_POFCON
if ((0 != (enabled & NRF_POWER_INT_POFWARN_MASK)) &&
- nrf_power_event_get_and_clear(NRF_POWER_EVENT_POFWARN))
+ nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_POFWARN))
{
/* Cannot be null if event is enabled */
NRFX_ASSERT(m_pofwarn_handler != NULL);
@@ -272,14 +269,14 @@ void nrfx_power_irq_handler(void)
#endif
#if NRF_POWER_HAS_SLEEPEVT
if ((0 != (enabled & NRF_POWER_INT_SLEEPENTER_MASK)) &&
- nrf_power_event_get_and_clear(NRF_POWER_EVENT_SLEEPENTER))
+ nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPENTER))
{
/* Cannot be null if event is enabled */
NRFX_ASSERT(m_sleepevt_handler != NULL);
m_sleepevt_handler(NRFX_POWER_SLEEP_EVT_ENTER);
}
if ((0 != (enabled & NRF_POWER_INT_SLEEPEXIT_MASK)) &&
- nrf_power_event_get_and_clear(NRF_POWER_EVENT_SLEEPEXIT))
+ nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_SLEEPEXIT))
{
/* Cannot be null if event is enabled */
NRFX_ASSERT(m_sleepevt_handler != NULL);
@@ -288,21 +285,21 @@ void nrfx_power_irq_handler(void)
#endif
#if NRF_POWER_HAS_USBREG
if ((0 != (enabled & NRF_POWER_INT_USBDETECTED_MASK)) &&
- nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBDETECTED))
+ nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_USBDETECTED))
{
/* Cannot be null if event is enabled */
NRFX_ASSERT(m_usbevt_handler != NULL);
m_usbevt_handler(NRFX_POWER_USB_EVT_DETECTED);
}
if ((0 != (enabled & NRF_POWER_INT_USBREMOVED_MASK)) &&
- nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBREMOVED))
+ nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_USBREMOVED))
{
/* Cannot be null if event is enabled */
NRFX_ASSERT(m_usbevt_handler != NULL);
m_usbevt_handler(NRFX_POWER_USB_EVT_REMOVED);
}
if ((0 != (enabled & NRF_POWER_INT_USBPWRRDY_MASK)) &&
- nrf_power_event_get_and_clear(NRF_POWER_EVENT_USBPWRRDY))
+ nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_USBPWRRDY))
{
/* Cannot be null if event is enabled */
NRFX_ASSERT(m_usbevt_handler != NULL);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c
index 8c563ff..7981c1e 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c
@@ -50,7 +50,7 @@ static uint8_t m_groups_allocated; /**< Bitmap representing groups av
*
* @retval Group mask.
*/
-__STATIC_INLINE uint32_t group_to_mask(nrf_ppi_channel_group_t group)
+static uint32_t group_to_mask(nrf_ppi_channel_group_t group)
{
return (1uL << (uint32_t) group);
}
@@ -64,7 +64,7 @@ __STATIC_INLINE uint32_t group_to_mask(nrf_ppi_channel_group_t group)
* @retval true The channel is a programmable application channel.
* @retval false The channel is used by a stack (for example SoftDevice) or is preprogrammed.
*/
-__STATIC_INLINE bool is_programmable_app_channel(nrf_ppi_channel_t channel)
+static bool is_programmable_app_channel(nrf_ppi_channel_t channel)
{
return ((NRFX_PPI_PROG_APP_CHANNELS_MASK & nrfx_ppi_channel_to_mask(channel)) != 0);
}
@@ -78,7 +78,7 @@ __STATIC_INLINE bool is_programmable_app_channel(nrf_ppi_channel_t channel)
* @retval true All specified channels can be used by an application.
* @retval false At least one specified channel is used by a stack (for example SoftDevice).
*/
-__STATIC_INLINE bool are_app_channels(uint32_t channel_mask)
+static bool are_app_channels(uint32_t channel_mask)
{
//lint -e(587)
return ((~(NRFX_PPI_ALL_APP_CHANNELS_MASK) & channel_mask) == 0);
@@ -93,7 +93,7 @@ __STATIC_INLINE bool are_app_channels(uint32_t channel_mask)
* @retval true The channel can be used by an application.
* @retval false The channel is used by a stack (for example SoftDevice).
*/
-__STATIC_INLINE bool is_app_channel(nrf_ppi_channel_t channel)
+static bool is_app_channel(nrf_ppi_channel_t channel)
{
return are_app_channels(nrfx_ppi_channel_to_mask(channel));
}
@@ -108,7 +108,7 @@ __STATIC_INLINE bool is_app_channel(nrf_ppi_channel_t channel)
* @retval false The group is not an application group (this group either does not exist or
* it is used by a stack (for example SoftDevice)).
*/
-__STATIC_INLINE bool is_app_group(nrf_ppi_channel_group_t group)
+static bool is_app_group(nrf_ppi_channel_group_t group)
{
return ((NRFX_PPI_ALL_APP_GROUPS_MASK & group_to_mask(group)) != 0);
}
@@ -122,7 +122,7 @@ __STATIC_INLINE bool is_app_group(nrf_ppi_channel_group_t group)
* @retval true The channel is allocated.
* @retval false The channel is not allocated.
*/
-__STATIC_INLINE bool is_allocated_channel(nrf_ppi_channel_t channel)
+static bool is_allocated_channel(nrf_ppi_channel_t channel)
{
return ((m_channels_allocated & nrfx_ppi_channel_to_mask(channel)) != 0);
}
@@ -133,7 +133,7 @@ __STATIC_INLINE bool is_allocated_channel(nrf_ppi_channel_t channel)
*
* @param[in] channel_num Specifies the channel to set the "allocated" indication.
*/
-__STATIC_INLINE void channel_allocated_set(nrf_ppi_channel_t channel)
+static void channel_allocated_set(nrf_ppi_channel_t channel)
{
m_channels_allocated |= nrfx_ppi_channel_to_mask(channel);
}
@@ -144,7 +144,7 @@ __STATIC_INLINE void channel_allocated_set(nrf_ppi_channel_t channel)
*
* @param[in] channel_num Specifies the channel to clear the "allocated" indication.
*/
-__STATIC_INLINE void channel_allocated_clr(nrf_ppi_channel_t channel)
+static void channel_allocated_clr(nrf_ppi_channel_t channel)
{
m_channels_allocated &= ~nrfx_ppi_channel_to_mask(channel);
}
@@ -153,7 +153,7 @@ __STATIC_INLINE void channel_allocated_clr(nrf_ppi_channel_t channel)
/**
* @brief Clear all allocated channels.
*/
-__STATIC_INLINE void channel_allocated_clr_all(void)
+static void channel_allocated_clr_all(void)
{
m_channels_allocated &= ~NRFX_PPI_ALL_APP_CHANNELS_MASK;
}
@@ -167,7 +167,7 @@ __STATIC_INLINE void channel_allocated_clr_all(void)
* @retval true The group is allocated.
* false The group is not allocated.
*/
-__STATIC_INLINE bool is_allocated_group(nrf_ppi_channel_group_t group)
+static bool is_allocated_group(nrf_ppi_channel_group_t group)
{
return ((m_groups_allocated & group_to_mask(group)) != 0);
}
@@ -178,7 +178,7 @@ __STATIC_INLINE bool is_allocated_group(nrf_ppi_channel_group_t group)
*
* @param[in] group_num Specifies the group to set the "allocated" indication.
*/
-__STATIC_INLINE void group_allocated_set(nrf_ppi_channel_group_t group)
+static void group_allocated_set(nrf_ppi_channel_group_t group)
{
m_groups_allocated |= group_to_mask(group);
}
@@ -189,7 +189,7 @@ __STATIC_INLINE void group_allocated_set(nrf_ppi_channel_group_t group)
*
* @param[in] group_num Specifies the group to clear the "allocated" indication.
*/
-__STATIC_INLINE void group_allocated_clr(nrf_ppi_channel_group_t group)
+static void group_allocated_clr(nrf_ppi_channel_group_t group)
{
m_groups_allocated &= ~group_to_mask(group);
}
@@ -198,7 +198,7 @@ __STATIC_INLINE void group_allocated_clr(nrf_ppi_channel_group_t group)
/**
* @brief Clear all allocated groups.
*/
-__STATIC_INLINE void group_allocated_clr_all()
+static void group_allocated_clr_all()
{
m_groups_allocated &= ~NRFX_PPI_ALL_APP_GROUPS_MASK;
}
@@ -210,13 +210,13 @@ void nrfx_ppi_free_all(void)
nrf_ppi_channel_group_t group;
// Disable all channels and groups
- nrf_ppi_channels_disable(NRFX_PPI_ALL_APP_CHANNELS_MASK);
+ nrf_ppi_channels_disable(NRF_PPI, NRFX_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);
+ nrf_ppi_group_clear(NRF_PPI, group);
}
}
channel_allocated_clr_all();
@@ -267,7 +267,7 @@ nrfx_err_t nrfx_ppi_channel_free(nrf_ppi_channel_t channel)
else
{
// First disable this channel
- nrf_ppi_channel_disable(channel);
+ nrf_ppi_channel_disable(NRF_PPI, channel);
NRFX_CRITICAL_SECTION_ENTER();
channel_allocated_clr(channel);
NRFX_CRITICAL_SECTION_EXIT();
@@ -296,7 +296,7 @@ nrfx_err_t nrfx_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint
}
else
{
- nrf_ppi_channel_endpoint_setup(channel, eep, tep);
+ nrf_ppi_channel_endpoint_setup(NRF_PPI, channel, eep, tep);
NRFX_LOG_INFO("Assigned channel: %d, event end point: %x, task end point: %x.",
channel,
eep,
@@ -316,7 +316,7 @@ nrfx_err_t nrfx_ppi_channel_fork_assign(nrf_ppi_channel_t channel, uint32_t fork
}
else
{
- nrf_ppi_fork_endpoint_setup(channel, fork_tep);
+ nrf_ppi_fork_endpoint_setup(NRF_PPI, channel, fork_tep);
NRFX_LOG_INFO("Fork assigned channel: %d, task end point: %d.", channel, fork_tep);
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
@@ -344,7 +344,7 @@ nrfx_err_t nrfx_ppi_channel_enable(nrf_ppi_channel_t channel)
}
else
{
- nrf_ppi_channel_enable(channel);
+ nrf_ppi_channel_enable(NRF_PPI, channel);
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
@@ -365,7 +365,7 @@ nrfx_err_t nrfx_ppi_channel_disable(nrf_ppi_channel_t channel)
}
else
{
- nrf_ppi_channel_disable(channel);
+ nrf_ppi_channel_disable(NRF_PPI, channel);
err_code = NRFX_SUCCESS;
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
@@ -418,7 +418,7 @@ nrfx_err_t nrfx_ppi_group_free(nrf_ppi_channel_group_t group)
}
else
{
- nrf_ppi_group_disable(group);
+ nrf_ppi_group_disable(NRF_PPI, group);
NRFX_CRITICAL_SECTION_ENTER();
group_allocated_clr(group);
NRFX_CRITICAL_SECTION_EXIT();
@@ -442,7 +442,7 @@ nrfx_err_t nrfx_ppi_group_enable(nrf_ppi_channel_group_t group)
}
else
{
- nrf_ppi_group_enable(group);
+ nrf_ppi_group_enable(NRF_PPI, group);
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
@@ -459,7 +459,7 @@ nrfx_err_t nrfx_ppi_group_disable(nrf_ppi_channel_group_t group)
}
else
{
- nrf_ppi_group_disable(group);
+ nrf_ppi_group_disable(NRF_PPI, group);
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
@@ -485,7 +485,7 @@ nrfx_err_t nrfx_ppi_channels_remove_from_group(uint32_t channel_m
else
{
NRFX_CRITICAL_SECTION_ENTER();
- nrf_ppi_channels_remove_from_group(channel_mask, group);
+ nrf_ppi_channels_remove_from_group(NRF_PPI, channel_mask, group);
NRFX_CRITICAL_SECTION_EXIT();
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
@@ -512,7 +512,7 @@ nrfx_err_t nrfx_ppi_channels_include_in_group(uint32_t channel_ma
else
{
NRFX_CRITICAL_SECTION_ENTER();
- nrf_ppi_channels_include_in_group(channel_mask, group);
+ nrf_ppi_channels_include_in_group(NRF_PPI, channel_mask, group);
NRFX_CRITICAL_SECTION_EXIT();
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c
index 7fa811c..c3eb7e7 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c
@@ -58,7 +58,7 @@
#define EGU_IRQn(i) EGU_IRQn_(i)
#define EGU_IRQn_(i) SWI##i##_EGU##i##_IRQn
#define EGU_IRQHandler(i) EGU_IRQHandler_(i)
-#define EGU_IRQHandler_(i) nrfx_swi_##i##_irq_handler
+#define EGU_IRQHandler_(i) nrfx_egu_##i##_irq_handler
#define DMA_ISSUE_EGU_IDX NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE
#define DMA_ISSUE_EGU NRFX_CONCAT_2(NRF_EGU, DMA_ISSUE_EGU_IDX)
#define DMA_ISSUE_EGU_IRQn EGU_IRQn(DMA_ISSUE_EGU_IDX)
@@ -72,12 +72,13 @@ typedef struct
uint32_t starting_task_address;
#endif
nrfx_pwm_handler_t handler;
+ void * p_context;
nrfx_drv_state_t volatile state;
uint8_t flags;
} pwm_control_block_t;
static pwm_control_block_t m_cb[NRFX_PWM_ENABLED_COUNT];
-static void configure_pins(nrfx_pwm_t const * const p_instance,
+static void configure_pins(nrfx_pwm_t const * p_instance,
nrfx_pwm_config_t const * p_config)
{
uint32_t out_pins[NRF_PWM_CHANNEL_COUNT];
@@ -112,9 +113,10 @@ static void configure_pins(nrfx_pwm_t const * const p_instance,
}
-nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
+nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * p_instance,
nrfx_pwm_config_t const * p_config,
- nrfx_pwm_handler_t handler)
+ nrfx_pwm_handler_t handler,
+ void * p_context)
{
NRFX_ASSERT(p_config);
@@ -132,6 +134,7 @@ nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
}
p_cb->handler = handler;
+ p_cb->p_context = p_context;
configure_pins(p_instance, p_config);
@@ -173,7 +176,7 @@ nrfx_err_t nrfx_pwm_init(nrfx_pwm_t const * const p_instance,
}
-void nrfx_pwm_uninit(nrfx_pwm_t const * const p_instance)
+void nrfx_pwm_uninit(nrfx_pwm_t const * p_instance)
{
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED);
@@ -189,7 +192,7 @@ void nrfx_pwm_uninit(nrfx_pwm_t const * const p_instance)
}
-static uint32_t start_playback(nrfx_pwm_t const * const p_instance,
+static uint32_t start_playback(nrfx_pwm_t const * p_instance,
pwm_control_block_t * p_cb,
uint8_t flags,
nrf_pwm_task_t starting_task)
@@ -250,10 +253,9 @@ static uint32_t start_playback(nrfx_pwm_t const * const p_instance,
// the PWM by triggering the proper task from EGU interrupt handler,
// it is not safe to do it directly via PPI.
p_cb->starting_task_address = starting_task_address;
- nrf_egu_int_enable(DMA_ISSUE_EGU,
- nrf_egu_int_get(DMA_ISSUE_EGU, p_instance->drv_inst_idx));
- return (uint32_t)nrf_egu_task_trigger_address_get(DMA_ISSUE_EGU,
- p_instance->drv_inst_idx);
+ nrf_egu_int_enable(DMA_ISSUE_EGU, nrf_egu_channel_int_get(p_instance->drv_inst_idx));
+ return nrf_egu_task_address_get(DMA_ISSUE_EGU,
+ nrf_egu_trigger_task_get(p_instance->drv_inst_idx));
#else
return starting_task_address;
#endif
@@ -264,7 +266,7 @@ static uint32_t start_playback(nrfx_pwm_t const * const p_instance,
}
-uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
+uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * p_instance,
nrf_pwm_sequence_t const * p_sequence,
uint16_t playback_count,
uint32_t flags)
@@ -309,7 +311,7 @@ uint32_t nrfx_pwm_simple_playback(nrfx_pwm_t const * const p_instance,
}
-uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * const p_instance,
+uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * p_instance,
nrf_pwm_sequence_t const * p_sequence_0,
nrf_pwm_sequence_t const * p_sequence_1,
uint16_t playback_count,
@@ -356,8 +358,8 @@ uint32_t nrfx_pwm_complex_playback(nrfx_pwm_t const * const p_instance,
}
-bool nrfx_pwm_stop(nrfx_pwm_t const * const p_instance,
- bool wait_until_stopped)
+bool nrfx_pwm_stop(nrfx_pwm_t const * p_instance,
+ bool wait_until_stopped)
{
NRFX_ASSERT(m_cb[p_instance->drv_inst_idx].state != NRFX_DRV_STATE_UNINITIALIZED);
@@ -385,7 +387,7 @@ bool nrfx_pwm_stop(nrfx_pwm_t const * const p_instance,
}
-bool nrfx_pwm_is_stopped(nrfx_pwm_t const * const p_instance)
+bool nrfx_pwm_is_stopped(nrfx_pwm_t const * p_instance)
{
pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED);
@@ -420,7 +422,7 @@ static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb)
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND0);
if ((p_cb->flags & NRFX_PWM_FLAG_SIGNAL_END_SEQ0) && p_cb->handler)
{
- p_cb->handler(NRFX_PWM_EVT_END_SEQ0);
+ p_cb->handler(NRFX_PWM_EVT_END_SEQ0, p_cb->p_context);
}
}
if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND1))
@@ -428,7 +430,7 @@ static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb)
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND1);
if ((p_cb->flags & NRFX_PWM_FLAG_SIGNAL_END_SEQ1) && p_cb->handler)
{
- p_cb->handler(NRFX_PWM_EVT_END_SEQ1);
+ p_cb->handler(NRFX_PWM_EVT_END_SEQ1, p_cb->p_context);
}
}
// For LOOPSDONE the handler is called by default, but the user can disable
@@ -438,7 +440,7 @@ static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb)
nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_LOOPSDONE);
if (!(p_cb->flags & NRFX_PWM_FLAG_NO_EVT_FINISHED) && p_cb->handler)
{
- p_cb->handler(NRFX_PWM_EVT_FINISHED);
+ p_cb->handler(NRFX_PWM_EVT_FINISHED, p_cb->p_context);
}
}
@@ -450,7 +452,7 @@ static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb)
p_cb->state = NRFX_DRV_STATE_INITIALIZED;
if (p_cb->handler)
{
- p_cb->handler(NRFX_PWM_EVT_STOPPED);
+ p_cb->handler(NRFX_PWM_EVT_STOPPED, p_cb->p_context);
}
}
}
@@ -460,14 +462,12 @@ static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb)
// See 'start_playback' why this is needed.
void DMA_ISSUE_EGU_IRQHandler(void)
{
- int i;
- for (i = 0; i < NRFX_PWM_ENABLED_COUNT; ++i)
+ for (uint8_t i = 0; i < NRFX_PWM_ENABLED_COUNT; i++)
{
- volatile uint32_t * p_event_reg =
- nrf_egu_event_triggered_address_get(DMA_ISSUE_EGU, i);
- if (*p_event_reg)
+ nrf_egu_event_t event = nrf_egu_triggered_event_get(i);
+ if (nrf_egu_event_check(DMA_ISSUE_EGU, event))
{
- *p_event_reg = 0;
+ nrf_egu_event_clear(DMA_ISSUE_EGU, event);
*(volatile uint32_t *)(m_cb[i].starting_task_address) = 1;
}
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c
index 78c88b9..81937e0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c
@@ -52,34 +52,34 @@ static nrfx_drv_state_t m_state = NRFX_DRV_STATE_UNINITIALIZED;
void nrfx_qdec_irq_handler(void)
{
nrfx_qdec_event_t event;
- if ( nrf_qdec_event_check(NRF_QDEC_EVENT_SAMPLERDY) &&
- nrf_qdec_int_enable_check(NRF_QDEC_INT_SAMPLERDY_MASK) )
+ if ( nrf_qdec_event_check(NRF_QDEC, NRF_QDEC_EVENT_SAMPLERDY) &&
+ nrf_qdec_int_enable_check(NRF_QDEC, NRF_QDEC_INT_SAMPLERDY_MASK) )
{
- nrf_qdec_event_clear(NRF_QDEC_EVENT_SAMPLERDY);
+ nrf_qdec_event_clear(NRF_QDEC, NRF_QDEC_EVENT_SAMPLERDY);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_QDEC_EVENT_SAMPLERDY));
event.type = NRF_QDEC_EVENT_SAMPLERDY;
- event.data.sample.value = (int8_t)nrf_qdec_sample_get();
+ event.data.sample.value = (int8_t)nrf_qdec_sample_get(NRF_QDEC);
m_qdec_event_handler(event);
}
- if ( nrf_qdec_event_check(NRF_QDEC_EVENT_REPORTRDY) &&
- nrf_qdec_int_enable_check(NRF_QDEC_INT_REPORTRDY_MASK) )
+ if ( nrf_qdec_event_check(NRF_QDEC, NRF_QDEC_EVENT_REPORTRDY) &&
+ nrf_qdec_int_enable_check(NRF_QDEC, NRF_QDEC_INT_REPORTRDY_MASK) )
{
- nrf_qdec_event_clear(NRF_QDEC_EVENT_REPORTRDY);
+ nrf_qdec_event_clear(NRF_QDEC, NRF_QDEC_EVENT_REPORTRDY);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_QDEC_EVENT_REPORTRDY));
event.type = NRF_QDEC_EVENT_REPORTRDY;
- event.data.report.acc = (int16_t)nrf_qdec_accread_get();
- event.data.report.accdbl = (uint16_t)nrf_qdec_accdblread_get();
+ event.data.report.acc = (int16_t)nrf_qdec_accread_get(NRF_QDEC);
+ event.data.report.accdbl = (uint16_t)nrf_qdec_accdblread_get(NRF_QDEC);
m_qdec_event_handler(event);
}
- if ( nrf_qdec_event_check(NRF_QDEC_EVENT_ACCOF) &&
- nrf_qdec_int_enable_check(NRF_QDEC_INT_ACCOF_MASK) )
+ if ( nrf_qdec_event_check(NRF_QDEC, NRF_QDEC_EVENT_ACCOF) &&
+ nrf_qdec_int_enable_check(NRF_QDEC, NRF_QDEC_INT_ACCOF_MASK) )
{
- nrf_qdec_event_clear(NRF_QDEC_EVENT_ACCOF);
+ nrf_qdec_event_clear(NRF_QDEC, NRF_QDEC_EVENT_ACCOF);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_QDEC_EVENT_ACCOF));
event.type = NRF_QDEC_EVENT_ACCOF;
@@ -106,32 +106,32 @@ nrfx_err_t nrfx_qdec_init(nrfx_qdec_config_t const * p_config,
m_qdec_event_handler = event_handler;
- nrf_qdec_sampleper_set(p_config->sampleper);
+ nrf_qdec_sampleper_set(NRF_QDEC, p_config->sampleper);
nrf_gpio_cfg_input(p_config->psela, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(p_config->pselb, NRF_GPIO_PIN_NOPULL);
if (p_config->pselled != NRF_QDEC_LED_NOT_CONNECTED)
{
nrf_gpio_cfg_input(p_config->pselled, NRF_GPIO_PIN_NOPULL);
- nrf_qdec_ledpre_set(p_config->ledpre);
- nrf_qdec_ledpol_set(p_config->ledpol);
+ nrf_qdec_ledpre_set(NRF_QDEC, p_config->ledpre);
+ nrf_qdec_ledpol_set(NRF_QDEC, p_config->ledpol);
}
- nrf_qdec_pio_assign(p_config->psela, p_config->pselb, p_config->pselled);
- nrf_qdec_shorts_enable(NRF_QDEC_SHORT_REPORTRDY_READCLRACC_MASK);
+ nrf_qdec_pio_assign(NRF_QDEC, p_config->psela, p_config->pselb, p_config->pselled);
+ nrf_qdec_shorts_enable(NRF_QDEC, NRF_QDEC_SHORT_REPORTRDY_READCLRACC_MASK);
if (p_config->dbfen)
{
- nrf_qdec_dbfen_enable();
+ nrf_qdec_dbfen_enable(NRF_QDEC);
}
else
{
- nrf_qdec_dbfen_disable();
+ nrf_qdec_dbfen_disable(NRF_QDEC);
}
uint32_t int_mask = NRF_QDEC_INT_ACCOF_MASK;
if (p_config->reportper != NRF_QDEC_REPORTPER_DISABLED)
{
- nrf_qdec_reportper_set(p_config->reportper);
+ nrf_qdec_reportper_set(NRF_QDEC, p_config->reportper);
int_mask |= NRF_QDEC_INT_REPORTRDY_MASK;
}
@@ -140,7 +140,7 @@ nrfx_err_t nrfx_qdec_init(nrfx_qdec_config_t const * p_config,
int_mask |= NRF_QDEC_INT_SAMPLERDY_MASK;
}
- nrf_qdec_int_enable(int_mask);
+ nrf_qdec_int_enable(NRF_QDEC, int_mask);
NRFX_IRQ_PRIORITY_SET(QDEC_IRQn, p_config->interrupt_priority);
NRFX_IRQ_ENABLE(QDEC_IRQn);
@@ -163,8 +163,8 @@ void nrfx_qdec_uninit(void)
void nrfx_qdec_enable(void)
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_INITIALIZED);
- nrf_qdec_enable();
- nrf_qdec_task_trigger(NRF_QDEC_TASK_START);
+ nrf_qdec_enable(NRF_QDEC);
+ nrf_qdec_task_trigger(NRF_QDEC, NRF_QDEC_TASK_START);
m_state = NRFX_DRV_STATE_POWERED_ON;
NRFX_LOG_INFO("Enabled.");
}
@@ -172,8 +172,8 @@ void nrfx_qdec_enable(void)
void nrfx_qdec_disable(void)
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_POWERED_ON);
- nrf_qdec_task_trigger(NRF_QDEC_TASK_STOP);
- nrf_qdec_disable();
+ nrf_qdec_task_trigger(NRF_QDEC, NRF_QDEC_TASK_STOP);
+ nrf_qdec_disable(NRF_QDEC);
m_state = NRFX_DRV_STATE_INITIALIZED;
NRFX_LOG_INFO("Disabled.");
}
@@ -181,10 +181,10 @@ void nrfx_qdec_disable(void)
void nrfx_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl)
{
NRFX_ASSERT(m_state == NRFX_DRV_STATE_POWERED_ON);
- nrf_qdec_task_trigger(NRF_QDEC_TASK_READCLRACC);
+ nrf_qdec_task_trigger(NRF_QDEC, NRF_QDEC_TASK_READCLRACC);
- *p_acc = (int16_t)nrf_qdec_accread_get();
- *p_accdbl = (int16_t)nrf_qdec_accdblread_get();
+ *p_acc = (int16_t)nrf_qdec_accread_get(NRF_QDEC);
+ *p_accdbl = (int16_t)nrf_qdec_accdblread_get(NRF_QDEC);
NRFX_LOG_DEBUG("Accumulators data, ACC register:");
NRFX_LOG_HEXDUMP_DEBUG((uint8_t *)p_acc, sizeof(p_acc[0]));
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c
index 8ceb05f..4583017 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c
@@ -179,6 +179,7 @@ nrfx_err_t nrfx_qspi_cinstr_xfer(nrf_qspi_cinstr_conf_t const * p_config,
{
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);
@@ -193,7 +194,6 @@ nrfx_err_t nrfx_qspi_cinstr_xfer(nrf_qspi_cinstr_conf_t const * p_config,
return NRFX_ERROR_TIMEOUT;
}
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)
{
@@ -349,17 +349,14 @@ nrfx_err_t nrfx_qspi_write(void const * p_tx_buffer,
{
NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
NRFX_ASSERT(p_tx_buffer != NULL);
- NRFX_ASSERT(nrfx_is_in_ram(p_tx_buffer));
- NRFX_ASSERT(nrfx_is_word_aligned(p_tx_buffer));
- if (!nrfx_is_in_ram(p_tx_buffer))
+ if (!nrfx_is_in_ram(p_tx_buffer) || !nrfx_is_word_aligned(p_tx_buffer))
{
return NRFX_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);
-
}
nrfx_err_t nrfx_qspi_read(void * p_rx_buffer,
@@ -368,10 +365,8 @@ nrfx_err_t nrfx_qspi_read(void * p_rx_buffer,
{
NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
NRFX_ASSERT(p_rx_buffer != NULL);
- NRFX_ASSERT(nrfx_is_in_ram(p_rx_buffer));
- NRFX_ASSERT(nrfx_is_word_aligned(p_rx_buffer));
- if (!nrfx_is_in_ram(p_rx_buffer))
+ if (!nrfx_is_in_ram(p_rx_buffer) || !nrfx_is_word_aligned(p_rx_buffer))
{
return NRFX_ERROR_INVALID_ADDR;
}
@@ -384,6 +379,12 @@ nrfx_err_t nrfx_qspi_erase(nrf_qspi_erase_len_t length,
uint32_t start_address)
{
NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
+
+ if (!nrfx_is_word_aligned((void const *)start_address))
+ {
+ return NRFX_ERROR_INVALID_ADDR;
+ }
+
nrf_qspi_erase_ptr_set(NRF_QSPI, start_address, length);
return qspi_task_perform(NRF_QSPI_TASK_ERASESTART);
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c
index cc6583c..8343866 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c
@@ -61,9 +61,9 @@ nrfx_err_t nrfx_rng_init(nrfx_rng_config_t const * p_config, nrfx_rng_evt_handle
if (p_config->error_correction)
{
- nrf_rng_error_correction_enable();
+ nrf_rng_error_correction_enable(NRF_RNG);
}
- nrf_rng_shorts_disable(NRF_RNG_SHORT_VALRDY_STOP_MASK);
+ nrf_rng_shorts_disable(NRF_RNG, NRF_RNG_SHORT_VALRDY_STOP_MASK);
NRFX_IRQ_PRIORITY_SET(RNG_IRQn, p_config->interrupt_priority);
NRFX_IRQ_ENABLE(RNG_IRQn);
@@ -75,24 +75,24 @@ nrfx_err_t nrfx_rng_init(nrfx_rng_config_t const * p_config, nrfx_rng_evt_handle
void nrfx_rng_start(void)
{
NRFX_ASSERT(m_rng_state == NRFX_DRV_STATE_INITIALIZED);
- 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);
+ nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY);
+ nrf_rng_int_enable(NRF_RNG, NRF_RNG_INT_VALRDY_MASK);
+ nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_START);
}
void nrfx_rng_stop(void)
{
NRFX_ASSERT(m_rng_state == NRFX_DRV_STATE_INITIALIZED);
- nrf_rng_int_disable(NRF_RNG_INT_VALRDY_MASK);
- nrf_rng_task_trigger(NRF_RNG_TASK_STOP);
+ nrf_rng_int_disable(NRF_RNG, NRF_RNG_INT_VALRDY_MASK);
+ nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_STOP);
}
void nrfx_rng_uninit(void)
{
NRFX_ASSERT(m_rng_state == NRFX_DRV_STATE_INITIALIZED);
- nrf_rng_int_disable(NRF_RNG_INT_VALRDY_MASK);
- nrf_rng_task_trigger(NRF_RNG_TASK_STOP);
+ nrf_rng_int_disable(NRF_RNG, NRF_RNG_INT_VALRDY_MASK);
+ nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_STOP);
NRFX_IRQ_DISABLE(RNG_IRQn);
m_rng_state = NRFX_DRV_STATE_UNINITIALIZED;
@@ -101,9 +101,9 @@ void nrfx_rng_uninit(void)
void nrfx_rng_irq_handler(void)
{
- nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY);
+ nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY);
- uint8_t rng_value = nrf_rng_random_value_get();
+ uint8_t rng_value = nrf_rng_random_value_get(NRF_RNG);
m_rng_hndl(rng_value);
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c
index 73cbdfd..53a0ed9 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c
@@ -65,7 +65,7 @@ typedef struct
static nrfx_rtc_handler_t m_handlers[NRFX_RTC_ENABLED_COUNT];
static nrfx_rtc_cb_t m_cb[NRFX_RTC_ENABLED_COUNT];
-nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * const p_instance,
+nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * p_instance,
nrfx_rtc_config_t const * p_config,
nrfx_rtc_handler_t handler)
{
@@ -96,7 +96,7 @@ nrfx_err_t nrfx_rtc_init(nrfx_rtc_t const * const p_instance,
return err_code;
}
-void nrfx_rtc_uninit(nrfx_rtc_t const * const p_instance)
+void nrfx_rtc_uninit(nrfx_rtc_t const * p_instance)
{
uint32_t mask = NRF_RTC_INT_TICK_MASK |
NRF_RTC_INT_OVERFLOW_MASK |
@@ -116,7 +116,7 @@ void nrfx_rtc_uninit(nrfx_rtc_t const * const p_instance)
NRFX_LOG_INFO("Uninitialized.");
}
-void nrfx_rtc_enable(nrfx_rtc_t const * const p_instance)
+void nrfx_rtc_enable(nrfx_rtc_t const * p_instance)
{
NRFX_ASSERT(m_cb[p_instance->instance_id].state == NRFX_DRV_STATE_INITIALIZED);
@@ -125,7 +125,7 @@ void nrfx_rtc_enable(nrfx_rtc_t const * const p_instance)
NRFX_LOG_INFO("Enabled.");
}
-void nrfx_rtc_disable(nrfx_rtc_t const * const p_instance)
+void nrfx_rtc_disable(nrfx_rtc_t const * p_instance)
{
NRFX_ASSERT(m_cb[p_instance->instance_id].state != NRFX_DRV_STATE_UNINITIALIZED);
@@ -134,22 +134,22 @@ void nrfx_rtc_disable(nrfx_rtc_t const * const p_instance)
NRFX_LOG_INFO("Disabled.");
}
-nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * const p_instance, uint32_t channel)
+nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * p_instance, uint32_t channel)
{
NRFX_ASSERT(m_cb[p_instance->instance_id].state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_ASSERT(channel<p_instance->cc_channel_count);
+ NRFX_ASSERT(channel < p_instance->cc_channel_count);
nrfx_err_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_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_event_disable(p_instance->p_reg, int_mask);
+ if (nrf_rtc_int_enable_check(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_int_disable(p_instance->p_reg, int_mask);
+ if (nrf_rtc_event_check(p_instance->p_reg, event))
{
- nrf_rtc_event_clear(p_instance->p_reg,event);
+ nrf_rtc_event_clear(p_instance->p_reg, event);
err_code = NRFX_ERROR_TIMEOUT;
NRFX_LOG_WARNING("Function: %s, error code: %s.",
__func__,
@@ -163,17 +163,17 @@ nrfx_err_t nrfx_rtc_cc_disable(nrfx_rtc_t const * const p_instance, uint32_t cha
return err_code;
}
-nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
- uint32_t channel,
- uint32_t val,
- bool enable_irq)
+nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * p_instance,
+ uint32_t channel,
+ uint32_t val,
+ bool enable_irq)
{
NRFX_ASSERT(m_cb[p_instance->instance_id].state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_ASSERT(channel<p_instance->cc_channel_count);
+ NRFX_ASSERT(channel < p_instance->cc_channel_count);
nrfx_err_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_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);
@@ -181,7 +181,7 @@ nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
val = RTC_WRAP(val);
if (m_cb[p_instance->instance_id].reliable)
{
- nrf_rtc_cc_set(p_instance->p_reg,channel,val);
+ 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)
@@ -204,7 +204,7 @@ nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
if (enable_irq)
{
- nrf_rtc_event_clear(p_instance->p_reg,event);
+ 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);
@@ -218,7 +218,7 @@ nrfx_err_t nrfx_rtc_cc_set(nrfx_rtc_t const * const p_instance,
return err_code;
}
-void nrfx_rtc_tick_enable(nrfx_rtc_t const * const p_instance, bool enable_irq)
+void nrfx_rtc_tick_enable(nrfx_rtc_t const * p_instance, bool enable_irq)
{
nrf_rtc_event_t event = NRF_RTC_EVENT_TICK;
uint32_t mask = NRF_RTC_INT_TICK_MASK;
@@ -232,7 +232,7 @@ void nrfx_rtc_tick_enable(nrfx_rtc_t const * const p_instance, bool enable_irq)
NRFX_LOG_INFO("Tick events enabled.");
}
-void nrfx_rtc_tick_disable(nrfx_rtc_t const * const p_instance)
+void nrfx_rtc_tick_disable(nrfx_rtc_t const * p_instance)
{
uint32_t mask = NRF_RTC_INT_TICK_MASK;
@@ -241,7 +241,7 @@ void nrfx_rtc_tick_disable(nrfx_rtc_t const * const p_instance)
NRFX_LOG_INFO("Tick events disabled.");
}
-void nrfx_rtc_overflow_enable(nrfx_rtc_t const * const p_instance, bool enable_irq)
+void nrfx_rtc_overflow_enable(nrfx_rtc_t const * p_instance, bool enable_irq)
{
nrf_rtc_event_t event = NRF_RTC_EVENT_OVERFLOW;
uint32_t mask = NRF_RTC_INT_OVERFLOW_MASK;
@@ -254,14 +254,14 @@ void nrfx_rtc_overflow_enable(nrfx_rtc_t const * const p_instance, bool enable_i
}
}
-void nrfx_rtc_overflow_disable(nrfx_rtc_t const * const p_instance)
+void nrfx_rtc_overflow_disable(nrfx_rtc_t 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 nrfx_rtc_max_ticks_get(nrfx_rtc_t const * const p_instance)
+uint32_t nrfx_rtc_max_ticks_get(nrfx_rtc_t const * p_instance)
{
uint32_t ticks;
if (m_cb[p_instance->instance_id].reliable)
@@ -285,20 +285,20 @@ static void irq_handler(NRF_RTC_Type * p_reg,
for (i = 0; i < channel_count; i++)
{
- if (nrf_rtc_int_is_enabled(p_reg,int_mask) && nrf_rtc_event_pending(p_reg,event))
+ if (nrf_rtc_int_enable_check(p_reg, int_mask) && nrf_rtc_event_check(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_rtc_event_disable(p_reg, int_mask);
+ nrf_rtc_int_disable(p_reg, int_mask);
+ nrf_rtc_event_clear(p_reg, event);
NRFX_LOG_DEBUG("Event: %s, instance id: %lu.", EVT_TO_STR(event), instance_id);
m_handlers[instance_id]((nrfx_rtc_int_type_t)i);
}
int_mask <<= 1;
- event = (nrf_rtc_event_t)((uint32_t)event + sizeof(uint32_t));
+ 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))
+ if (nrf_rtc_int_enable_check(p_reg, NRF_RTC_INT_TICK_MASK) && nrf_rtc_event_check(p_reg, event))
{
nrf_rtc_event_clear(p_reg, event);
NRFX_LOG_DEBUG("Event: %s, instance id: %lu.", EVT_TO_STR(event), instance_id);
@@ -306,10 +306,10 @@ static void irq_handler(NRF_RTC_Type * p_reg,
}
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))
+ if (nrf_rtc_int_enable_check(p_reg, NRF_RTC_INT_OVERFLOW_MASK) &&
+ nrf_rtc_event_check(p_reg, event))
{
- nrf_rtc_event_clear(p_reg,event);
+ nrf_rtc_event_clear(p_reg, event);
NRFX_LOG_DEBUG("Event: %s, instance id: %lu.", EVT_TO_STR(event), instance_id);
m_handlers[instance_id](NRFX_RTC_INT_OVERFLOW);
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c
index 9c54745..371cdc9 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c
@@ -45,586 +45,816 @@
(event == NRF_SAADC_EVENT_STOPPED ? "NRF_SAADC_EVENT_STOPPED" : \
"UNKNOWN EVENT"))))))
-
+#if defined(NRF52_SERIES) && !defined(USE_WORKAROUND_FOR_ANOMALY_212)
+ // ANOMALY 212 - SAADC events are missing when switching from single channel
+ // to multi channel configuration with burst enabled.
+ #define USE_WORKAROUND_FOR_ANOMALY_212 1
+#endif
+
+#if defined(NRF91_SERIES) || defined(NRF53_SERIES)
+ // Make sure that SAADC is stopped before channel configuration.
+ #define STOP_SAADC_ON_CHANNEL_CONFIG 1
+#endif
+
+/** @brief SAADC driver states.*/
typedef enum
{
- NRF_SAADC_STATE_IDLE = 0,
- NRF_SAADC_STATE_BUSY = 1,
- NRF_SAADC_STATE_CALIBRATION = 2
+ NRF_SAADC_STATE_UNINITIALIZED = 0,
+ NRF_SAADC_STATE_IDLE,
+ NRF_SAADC_STATE_SIMPLE_MODE,
+ NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE,
+ NRF_SAADC_STATE_ADV_MODE,
+ NRF_SAADC_STATE_ADV_MODE_SAMPLE,
+ NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED,
+ NRF_SAADC_STATE_CALIBRATION
} nrf_saadc_state_t;
-
-typedef struct
-{
- nrf_saadc_input_t pselp;
- nrf_saadc_input_t pseln;
-} nrf_saadc_psel_buffer;
-
/** @brief SAADC control block.*/
typedef struct
{
- nrfx_saadc_event_handler_t event_handler; ///< Event handler function pointer.
- volatile nrf_saadc_value_t * p_buffer; ///< Sample buffer.
- volatile uint16_t buffer_size; ///< Size of the sample buffer.
- volatile nrf_saadc_value_t * p_secondary_buffer; ///< Secondary sample buffer.
- volatile nrf_saadc_state_t adc_state; ///< State of the SAADC.
- uint32_t limits_enabled_flags; ///< Enabled limits flags.
- uint16_t secondary_buffer_size; ///< Size of the secondary buffer.
- uint16_t buffer_size_left; ///< When low power mode is active indicates how many samples left to convert on current buffer.
- nrf_saadc_psel_buffer psel[NRF_SAADC_CHANNEL_COUNT]; ///< Pin configurations of SAADC channels.
- nrfx_drv_state_t state; ///< Driver initialization state.
- uint8_t active_channels; ///< Number of enabled SAADC channels.
- bool low_power_mode; ///< Indicates if low power mode is active.
- bool conversions_end; ///< When low power mode is active indicates end of conversions on current buffer.
+ nrfx_saadc_event_handler_t event_handler; ///< Event handler function pointer.
+ nrf_saadc_value_t * p_buffer_primary; ///< Pointer to the primary result buffer.
+ nrf_saadc_value_t * p_buffer_secondary; ///< Pointer to the secondary result buffer.
+ uint16_t size_primary; ///< Size of the primary result buffer.
+ uint16_t size_secondary; ///< Size of the secondary result buffer.
+ uint16_t samples_per_trigger; ///< Samples to take per one trigger in the blocking mode.
+ nrf_saadc_input_t channels_pselp[SAADC_CH_NUM]; ///< Array holding each channel positive input.
+ nrf_saadc_input_t channels_pseln[SAADC_CH_NUM]; ///< Array holding each channel negative input.
+ nrf_saadc_state_t saadc_state; ///< State of the SAADC driver.
+ uint8_t channels_configured; ///< Bitmask of the configured channels.
+ uint8_t channels_activated; ///< Bitmask of the activated channels.
+ uint8_t channels_activated_count; ///< Number of the activated channels.
+ uint8_t limits_low_activated; ///< Bitmask of the activated low limits.
+ uint8_t limits_high_activated; ///< Bitmask of the activated high limits.
+ bool start_on_end; ///< Flag indicating if the START task is to be triggered on the END event.
} nrfx_saadc_cb_t;
static nrfx_saadc_cb_t m_cb;
-#define LOW_LIMIT_TO_FLAG(channel) ((2 * channel + 1))
-#define HIGH_LIMIT_TO_FLAG(channel) ((2 * channel))
-#define FLAG_IDX_TO_EVENT(idx) ((nrf_saadc_event_t)((uint32_t)NRF_SAADC_EVENT_CH0_LIMITH + \
- 4 * idx))
-#define LIMIT_EVENT_TO_CHANNEL(event) (uint8_t)(((uint32_t)event - \
- (uint32_t)NRF_SAADC_EVENT_CH0_LIMITH) / 8)
-#define LIMIT_EVENT_TO_LIMIT_TYPE(event)((((uint32_t)event - (uint32_t)NRF_SAADC_EVENT_CH0_LIMITH) & 4) \
- ? NRF_SAADC_LIMIT_LOW : NRF_SAADC_LIMIT_HIGH)
-#define HW_TIMEOUT 10000
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_212)
+static void saadc_anomaly_212_workaround_apply(void)
+{
+ uint32_t c[SAADC_CH_NUM];
+ uint32_t l[SAADC_CH_NUM];
-void nrfx_saadc_irq_handler(void)
+ for (uint32_t i = 0; i < SAADC_CH_NUM; i++)
+ {
+ c[i] = NRF_SAADC->CH[i].CONFIG;
+ l[i] = NRF_SAADC->CH[i].LIMIT;
+ }
+ nrf_saadc_resolution_t resolution = nrf_saadc_resolution_get(NRF_SAADC);
+ uint32_t u640 = *(volatile uint32_t *)0x40007640;
+ uint32_t u644 = *(volatile uint32_t *)0x40007644;
+ uint32_t u648 = *(volatile uint32_t *)0x40007648;
+
+ *(volatile uint32_t *)0x40007FFC = 0;
+ *(volatile uint32_t *)0x40007FFC = 1;
+
+ for (uint32_t i = 0; i < SAADC_CH_NUM; i++)
+ {
+ NRF_SAADC->CH[i].CONFIG = c[i];
+ NRF_SAADC->CH[i].LIMIT = l[i];
+ }
+ *(volatile uint32_t *)0x40007640 = u640;
+ *(volatile uint32_t *)0x40007644 = u644;
+ *(volatile uint32_t *)0x40007648 = u648;
+ nrf_saadc_resolution_set(NRF_SAADC, resolution);
+}
+#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_212)
+
+static void saadc_enabled_channels_sample(void)
{
- if (nrf_saadc_event_check(NRF_SAADC_EVENT_END))
+ for (uint32_t sample_idx = 0; sample_idx < m_cb.samples_per_trigger; sample_idx++)
{
- nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_SAADC_EVENT_END));
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_DONE))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_DONE);
+ }
+}
- if (!m_cb.low_power_mode || m_cb.conversions_end)
- {
- nrfx_saadc_evt_t evt;
- evt.type = NRFX_SAADC_EVT_DONE;
- evt.data.done.p_buffer = (nrf_saadc_value_t *)m_cb.p_buffer;
- evt.data.done.size = m_cb.buffer_size;
+static nrfx_err_t saadc_channel_count_get(uint32_t ch_to_activate_mask,
+ uint8_t * p_active_ch_count)
+{
+ NRFX_ASSERT(ch_to_activate_mask);
+ NRFX_ASSERT(ch_to_activate_mask < (1 << SAADC_CH_NUM));
- if (m_cb.p_secondary_buffer == NULL)
- {
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
- }
- else
+ uint8_t active_ch_count = 0;
+ for (uint32_t ch_mask = 1; ch_mask < (1 << SAADC_CH_NUM); ch_mask <<= 1)
+ {
+ if (ch_to_activate_mask & ch_mask)
+ {
+ // Check if requested channels are configured.
+ if (!(m_cb.channels_configured & ch_mask))
{
- m_cb.buffer_size_left = m_cb.secondary_buffer_size;
- m_cb.p_buffer = m_cb.p_secondary_buffer;
- m_cb.buffer_size = m_cb.secondary_buffer_size;
- m_cb.p_secondary_buffer = NULL;
- if (!m_cb.low_power_mode)
- {
- nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
- }
+ return NRFX_ERROR_INVALID_PARAM;
}
- m_cb.event_handler(&evt);
- m_cb.conversions_end = false;
+ active_ch_count++;
}
}
- if (m_cb.low_power_mode && nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED))
- {
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_SAADC_EVENT_STARTED));
- if (m_cb.buffer_size_left > m_cb.active_channels)
- {
- // More samples to convert than for single event.
- m_cb.buffer_size_left -= m_cb.active_channels;
- nrf_saadc_buffer_init((nrf_saadc_value_t *)&m_cb.p_buffer[m_cb.buffer_size -
- m_cb.buffer_size_left],
- m_cb.active_channels);
- }
- else if ((m_cb.buffer_size_left == m_cb.active_channels) &&
+ *p_active_ch_count = active_ch_count;
+ return NRFX_SUCCESS;
+}
- (m_cb.p_secondary_buffer != NULL))
- {
- // Samples to convert for one event, prepare next buffer.
- m_cb.conversions_end = true;
- m_cb.buffer_size_left = 0;
- nrf_saadc_buffer_init((nrf_saadc_value_t *)m_cb.p_secondary_buffer,
- m_cb.active_channels);
- }
- else if (m_cb.buffer_size_left == m_cb.active_channels)
- {
- // Samples to convert for one event, but no second buffer.
- m_cb.conversions_end = true;
- m_cb.buffer_size_left = 0;
- }
- nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
+static bool saadc_busy_check(void)
+{
+ if ((m_cb.saadc_state == NRF_SAADC_STATE_IDLE) ||
+ (m_cb.saadc_state == NRF_SAADC_STATE_ADV_MODE) ||
+ (m_cb.saadc_state == NRF_SAADC_STATE_SIMPLE_MODE))
+ {
+ return false;
}
- if (nrf_saadc_event_check(NRF_SAADC_EVENT_CALIBRATEDONE))
+ else
{
- nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE);
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_SAADC_EVENT_CALIBRATEDONE));
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
+ return true;
+ }
+}
+
+static void saadc_generic_mode_set(uint32_t ch_to_activate_mask,
+ nrf_saadc_resolution_t resolution,
+ nrf_saadc_oversample_t oversampling,
+ nrf_saadc_burst_t burst,
+ nrfx_saadc_event_handler_t event_handler)
+{
+#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_212)
+ saadc_anomaly_212_workaround_apply();
+#endif
- nrfx_saadc_evt_t evt;
- evt.type = NRFX_SAADC_EVT_CALIBRATEDONE;
- m_cb.event_handler(&evt);
+#if NRFX_CHECK(STOP_SAADC_ON_CHANNEL_CONFIG)
+ nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_STOPPED);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED))
+ {
}
- if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED))
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
+#endif
+
+ m_cb.limits_low_activated = 0;
+ m_cb.limits_high_activated = 0;
+
+ m_cb.p_buffer_primary = NULL;
+ m_cb.p_buffer_secondary = NULL;
+ m_cb.event_handler = event_handler;
+ m_cb.channels_activated = ch_to_activate_mask;
+
+ nrf_saadc_resolution_set(NRF_SAADC, resolution);
+ nrf_saadc_oversample_set(NRF_SAADC, oversampling);
+ if (event_handler)
{
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_SAADC_EVENT_STOPPED));
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+ nrf_saadc_int_enable(NRF_SAADC,
+ NRF_SAADC_INT_STARTED |
+ NRF_SAADC_INT_STOPPED |
+ NRF_SAADC_INT_END);
}
else
{
- uint32_t limit_flags = m_cb.limits_enabled_flags;
- uint32_t flag_idx;
- nrf_saadc_event_t event;
+ nrf_saadc_int_disable(NRF_SAADC,
+ NRF_SAADC_INT_STARTED |
+ NRF_SAADC_INT_STOPPED |
+ NRF_SAADC_INT_END);
+ }
- while (limit_flags)
+ for (uint32_t ch_pos = 0; ch_pos < SAADC_CH_NUM; ch_pos++)
+ {
+ nrf_saadc_burst_t burst_to_set;
+ nrf_saadc_input_t pselp;
+ nrf_saadc_input_t pseln;
+ if (ch_to_activate_mask & (1 << ch_pos))
{
- flag_idx = __CLZ(limit_flags);
- limit_flags &= ~((1UL << 31) >> flag_idx);
- event = FLAG_IDX_TO_EVENT(flag_idx);
- if (nrf_saadc_event_check(event))
- {
- nrf_saadc_event_clear(event);
- nrfx_saadc_evt_t evt;
- evt.type = NRFX_SAADC_EVT_LIMIT;
- evt.data.limit.channel = LIMIT_EVENT_TO_CHANNEL(event);
- evt.data.limit.limit_type = LIMIT_EVENT_TO_LIMIT_TYPE(event);
- NRFX_LOG_DEBUG("Event limit, channel: %d, limit type: %d.",
- evt.data.limit.channel,
- evt.data.limit.limit_type);
- m_cb.event_handler(&evt);
- }
+ pselp = m_cb.channels_pselp[ch_pos];
+ pseln = m_cb.channels_pseln[ch_pos];
+ burst_to_set = burst;
+ }
+ else
+ {
+ pselp = NRF_SAADC_INPUT_DISABLED;
+ pseln = NRF_SAADC_INPUT_DISABLED;
+ burst_to_set = NRF_SAADC_BURST_DISABLED;
}
+ nrf_saadc_burst_set(NRF_SAADC, ch_pos, burst_to_set);
+ nrf_saadc_channel_input_set(NRF_SAADC, ch_pos, pselp, pseln);
}
}
-
-nrfx_err_t nrfx_saadc_init(nrfx_saadc_config_t const * p_config,
- nrfx_saadc_event_handler_t event_handler)
+nrfx_err_t nrfx_saadc_init(uint8_t interrupt_priority)
{
- NRFX_ASSERT(p_config);
- NRFX_ASSERT(event_handler);
- nrfx_err_t err_code;
-
- if (m_cb.state != NRFX_DRV_STATE_UNINITIALIZED)
+ if (m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED)
{
- err_code = NRFX_ERROR_INVALID_STATE;
NRFX_LOG_WARNING("Function: %s, error code: %s.",
__func__,
NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_ERROR_INVALID_STATE;
}
+ m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
- m_cb.event_handler = event_handler;
- nrf_saadc_resolution_set(p_config->resolution);
- nrf_saadc_oversample_set(p_config->oversample);
- m_cb.low_power_mode = p_config->low_power_mode;
- m_cb.state = NRFX_DRV_STATE_INITIALIZED;
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
- m_cb.active_channels = 0;
- m_cb.limits_enabled_flags = 0;
- m_cb.conversions_end = false;
-
- nrf_saadc_int_disable(NRF_SAADC_INT_ALL);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
- NRFX_IRQ_PRIORITY_SET(SAADC_IRQn, p_config->interrupt_priority);
+ nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_ALL);
NRFX_IRQ_ENABLE(SAADC_IRQn);
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
+ NRFX_IRQ_PRIORITY_SET(SAADC_IRQn, interrupt_priority);
- if (m_cb.low_power_mode)
- {
- nrf_saadc_int_enable(NRF_SAADC_INT_STARTED);
- }
-
- nrf_saadc_enable();
-
- err_code = NRFX_SUCCESS;
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_SUCCESS;
}
-
void nrfx_saadc_uninit(void)
{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
-
- nrf_saadc_int_disable(NRF_SAADC_INT_ALL);
+ nrfx_saadc_abort();
NRFX_IRQ_DISABLE(SAADC_IRQn);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
+ nrf_saadc_disable(NRF_SAADC);
+ m_cb.saadc_state = NRF_SAADC_STATE_UNINITIALIZED;
+}
- // Wait for ADC being stopped.
- bool result;
- NRFX_WAIT_FOR(nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED), HW_TIMEOUT, 0, result);
- NRFX_ASSERT(result);
+nrfx_err_t nrfx_saadc_channels_config(nrfx_saadc_channel_t const * p_channels,
+ uint32_t channel_count)
+{
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
+ NRFX_ASSERT(channel_count <= SAADC_CH_NUM);
- nrf_saadc_disable();
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
+ if (saadc_busy_check())
+ {
+ return NRFX_ERROR_BUSY;
+ }
+
+ m_cb.channels_configured = 0;
+ uint8_t i = 0;
+
+ for (; i < SAADC_CH_NUM; i++)
+ {
+ m_cb.channels_pselp[i] = NRF_SAADC_INPUT_DISABLED;
+ m_cb.channels_pseln[i] = NRF_SAADC_INPUT_DISABLED;
+ }
- for (uint32_t channel = 0; channel < NRF_SAADC_CHANNEL_COUNT; ++channel)
+ for (i = 0; i < channel_count; i++)
{
- if (m_cb.psel[channel].pselp != NRF_SAADC_INPUT_DISABLED)
+ if (m_cb.channels_configured & (1 << p_channels[i].channel_index))
{
- nrfx_err_t err_code = nrfx_saadc_channel_uninit(channel);
- NRFX_ASSERT(err_code == NRFX_SUCCESS);
+ // This channel is already configured!
+ return NRFX_ERROR_INVALID_PARAM;
}
+ nrf_saadc_channel_init(NRF_SAADC,
+ p_channels[i].channel_index,
+ &p_channels[i].channel_config);
+
+ NRFX_ASSERT(p_channels[i].pin_p);
+ m_cb.channels_pselp[p_channels[i].channel_index] = p_channels[i].pin_p;
+ m_cb.channels_pseln[p_channels[i].channel_index] = p_channels[i].pin_n;
+ m_cb.channels_configured |= 1U << p_channels[i].channel_index;
}
- m_cb.state = NRFX_DRV_STATE_UNINITIALIZED;
+ return NRFX_SUCCESS;
}
-
-nrfx_err_t nrfx_saadc_channel_init(uint8_t channel,
- nrf_saadc_channel_config_t const * const p_config)
+nrfx_err_t nrfx_saadc_simple_mode_set(uint32_t channel_mask,
+ nrf_saadc_resolution_t resolution,
+ nrf_saadc_oversample_t oversampling,
+ nrfx_saadc_event_handler_t event_handler)
{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
- // Oversampling can be used only with one channel.
- NRFX_ASSERT((nrf_saadc_oversample_get() == NRF_SAADC_OVERSAMPLE_DISABLED) ||
- (m_cb.active_channels == 0));
- NRFX_ASSERT((p_config->pin_p <= NRF_SAADC_INPUT_VDD) &&
- (p_config->pin_p > NRF_SAADC_INPUT_DISABLED));
- NRFX_ASSERT(p_config->pin_n <= NRF_SAADC_INPUT_VDD);
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
- nrfx_err_t err_code;
-
- // A channel can only be initialized if the driver is in the idle state.
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
+ if (saadc_busy_check())
{
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_ERROR_BUSY;
}
-#ifdef NRF52_PAN_74
- if ((p_config->acq_time == NRF_SAADC_ACQTIME_3US) ||
- (p_config->acq_time == NRF_SAADC_ACQTIME_5US))
+ uint8_t active_ch_count;
+ nrfx_err_t err = saadc_channel_count_get(channel_mask, &active_ch_count);
+ if (err != NRFX_SUCCESS)
{
- nrf_saadc_disable();
+ return err;
}
-#endif //NRF52_PAN_74
- if (m_cb.psel[channel].pselp == NRF_SAADC_INPUT_DISABLED)
+ nrf_saadc_burst_t burst;
+ if (oversampling == NRF_SAADC_OVERSAMPLE_DISABLED)
{
- ++m_cb.active_channels;
+ burst = NRF_SAADC_BURST_DISABLED;
}
- m_cb.psel[channel].pselp = p_config->pin_p;
- m_cb.psel[channel].pseln = p_config->pin_n;
- nrf_saadc_channel_init(channel, p_config);
+ else
+ {
+ burst = NRF_SAADC_BURST_ENABLED;
+ }
+
+ saadc_generic_mode_set(channel_mask,
+ resolution,
+ oversampling,
+ burst,
+ event_handler);
-#ifdef NRF52_PAN_74
- if ((p_config->acq_time == NRF_SAADC_ACQTIME_3US) ||
- (p_config->acq_time == NRF_SAADC_ACQTIME_5US))
+ if (event_handler)
{
- nrf_saadc_enable();
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_RESULTDONE);
+ nrf_saadc_int_enable(NRF_SAADC, NRF_SAADC_INT_RESULTDONE);
+ }
+ else
+ {
+ nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_RESULTDONE);
}
-#endif //NRF52_PAN_74
- NRFX_LOG_INFO("Channel initialized: %d.", channel);
- err_code = NRFX_SUCCESS;
- NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
+ m_cb.samples_per_trigger = active_ch_count;
+ m_cb.channels_activated_count = active_ch_count;
+ m_cb.saadc_state = NRF_SAADC_STATE_SIMPLE_MODE;
+ return NRFX_SUCCESS;
+}
-nrfx_err_t nrfx_saadc_channel_uninit(uint8_t channel)
+nrfx_err_t nrfx_saadc_advanced_mode_set(uint32_t channel_mask,
+ nrf_saadc_resolution_t resolution,
+ nrfx_saadc_adv_config_t const * p_config,
+ nrfx_saadc_event_handler_t event_handler)
{
- NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
+ NRFX_ASSERT(p_config);
- nrfx_err_t err_code;
+ if (saadc_busy_check())
+ {
+ return NRFX_ERROR_BUSY;
+ }
- // A channel can only be uninitialized if the driver is in the idle state.
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
+ uint8_t active_ch_count;
+ nrfx_err_t err = saadc_channel_count_get(channel_mask, &active_ch_count);
+ if (err != NRFX_SUCCESS)
{
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return err;
}
- if (m_cb.psel[channel].pselp != NRF_SAADC_INPUT_DISABLED)
+ if ((p_config->internal_timer_cc) && ((active_ch_count > 1) || (!event_handler)))
{
- --m_cb.active_channels;
+ return NRFX_ERROR_NOT_SUPPORTED;
}
- m_cb.psel[channel].pselp = NRF_SAADC_INPUT_DISABLED;
- m_cb.psel[channel].pseln = NRF_SAADC_INPUT_DISABLED;
- nrf_saadc_channel_input_set(channel, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
- nrfx_saadc_limits_set(channel, NRFX_SAADC_LIMITL_DISABLED, NRFX_SAADC_LIMITH_DISABLED);
- NRFX_LOG_INFO("Channel denitialized: %d.", channel);
- err_code = NRFX_SUCCESS;
- NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
+ if ((p_config->oversampling != NRF_SAADC_OVERSAMPLE_DISABLED) &&
+ (p_config->burst == NRF_SAADC_BURST_DISABLED))
+ {
+ // Oversampling without burst
+ if (active_ch_count > 1)
+ {
+ return NRFX_ERROR_NOT_SUPPORTED;
+ }
+ else
+ {
+ m_cb.samples_per_trigger =
+ nrf_saadc_oversample_sample_count_get(p_config->oversampling);
+ }
+ }
+ else
+ {
+ m_cb.samples_per_trigger = active_ch_count;
+ }
+ saadc_generic_mode_set(channel_mask,
+ resolution,
+ p_config->oversampling,
+ p_config->burst,
+ event_handler);
-uint32_t nrfx_saadc_sample_task_get(void)
-{
- return nrf_saadc_task_address_get(
- m_cb.low_power_mode ? NRF_SAADC_TASK_START : NRF_SAADC_TASK_SAMPLE);
-}
+ if (p_config->internal_timer_cc)
+ {
+ nrf_saadc_continuous_mode_enable(NRF_SAADC, p_config->internal_timer_cc);
+ }
+ else
+ {
+ nrf_saadc_continuous_mode_disable(NRF_SAADC);
+ }
+
+ m_cb.channels_activated_count = active_ch_count;
+ m_cb.start_on_end = p_config->start_on_end;
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE;
-nrfx_err_t nrfx_saadc_sample_convert(uint8_t channel, nrf_saadc_value_t * p_value)
+ return NRFX_SUCCESS;
+}
+
+nrfx_err_t nrfx_saadc_buffer_set(nrf_saadc_value_t * p_buffer, uint16_t size)
{
- nrfx_err_t err_code;
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
+ if (m_cb.p_buffer_secondary)
{
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_ERROR_ALREADY_INITIALIZED;
}
- m_cb.adc_state = NRF_SAADC_STATE_BUSY;
- nrf_saadc_int_disable(NRF_SAADC_INT_STARTED | NRF_SAADC_INT_END);
- nrf_saadc_buffer_init(p_value, 1);
- if (m_cb.active_channels > 1)
+
+ if (!nrfx_is_in_ram(p_buffer))
{
- for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; ++i)
- {
- nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
- }
+ return NRFX_ERROR_INVALID_ADDR;
+ }
+
+ if ((size % m_cb.channels_activated_count != 0) ||
+ (size >= (1 << SAADC_EASYDMA_MAXCNT_SIZE)) ||
+ (!size))
+ {
+ return NRFX_ERROR_INVALID_LENGTH;
}
- nrf_saadc_channel_input_set(channel, m_cb.psel[channel].pselp, m_cb.psel[channel].pseln);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
- bool result;
- NRFX_WAIT_FOR(nrf_saadc_event_check(NRF_SAADC_EVENT_END), HW_TIMEOUT, 0, result);
- NRFX_ASSERT(result);
+ switch (m_cb.saadc_state)
+ {
+ case NRF_SAADC_STATE_SIMPLE_MODE:
+ if (m_cb.channels_activated_count != size)
+ {
+ return NRFX_ERROR_INVALID_LENGTH;
+ }
+ m_cb.p_buffer_primary = p_buffer;
+ m_cb.size_primary = size;
+ nrf_saadc_buffer_init(NRF_SAADC, p_buffer, size);
+ break;
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
+ nrf_saadc_buffer_init(NRF_SAADC, p_buffer, size);
+ /* fall-through */
- NRFX_LOG_INFO("Conversion value: %d, channel %d.", *p_value, channel);
+ case NRF_SAADC_STATE_ADV_MODE:
+ /* fall-through */
- if (m_cb.active_channels > 1)
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE:
+ if (m_cb.p_buffer_primary)
+ {
+ m_cb.p_buffer_secondary = p_buffer;
+ m_cb.size_secondary = size;
+ }
+ else
+ {
+ m_cb.p_buffer_primary = p_buffer;
+ m_cb.size_primary = size;
+ nrf_saadc_buffer_init(NRF_SAADC, p_buffer, size);
+ }
+ break;
+
+ default:
+ return NRFX_ERROR_INVALID_STATE;
+ }
+
+ return NRFX_SUCCESS;
+}
+
+nrfx_err_t nrfx_saadc_mode_trigger(void)
+{
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_IDLE);
+
+ if (!m_cb.p_buffer_primary)
{
- for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; ++i)
- {
- nrf_saadc_channel_input_set(i, m_cb.psel[i].pselp, m_cb.psel[i].pseln);
- }
+ return NRFX_ERROR_NO_MEM;
+ }
+
+ nrfx_err_t result = NRFX_SUCCESS;
+ switch (m_cb.saadc_state) {
+ case NRF_SAADC_STATE_SIMPLE_MODE:
+ nrf_saadc_enable(NRF_SAADC);
+ if (m_cb.event_handler)
+ {
+ m_cb.saadc_state = NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE;
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ }
+ else
+ {
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STARTED))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
+
+ saadc_enabled_channels_sample();
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+ nrf_saadc_disable(NRF_SAADC);
+ }
+ break;
+
+ case NRF_SAADC_STATE_ADV_MODE:
+ nrf_saadc_enable(NRF_SAADC);
+ if (m_cb.event_handler)
+ {
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE_SAMPLE;
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ break;
+ }
+
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED;
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STARTED))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
+ /* fall-through */
+
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
+ if (m_cb.event_handler)
+ {
+ result = NRFX_ERROR_INVALID_STATE;
+ break;
+ }
+
+ saadc_enabled_channels_sample();
+ if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END))
+ {
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE;
+ m_cb.p_buffer_primary = m_cb.p_buffer_secondary;
+ m_cb.size_primary = m_cb.size_secondary;
+ m_cb.p_buffer_secondary = NULL;
+ if (m_cb.p_buffer_primary)
+ {
+ nrf_saadc_buffer_init(NRF_SAADC,
+ m_cb.p_buffer_primary,
+ m_cb.size_primary);
+ }
+ else
+ {
+ nrf_saadc_disable(NRF_SAADC);
+ }
+ result = NRFX_SUCCESS;
+ }
+ else
+ {
+ result = NRFX_ERROR_BUSY;
+ }
+ break;
+
+ default:
+ result = NRFX_ERROR_INVALID_STATE;
+ break;
}
- if (m_cb.low_power_mode)
+ return result;
+}
+
+void nrfx_saadc_abort(void)
+{
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
+
+ if (!saadc_busy_check())
{
- nrf_saadc_int_enable(NRF_SAADC_INT_STARTED | NRF_SAADC_INT_END);
+ return;
}
- else
+
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
+
+ if (m_cb.saadc_state == NRF_SAADC_STATE_CALIBRATION)
{
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
+ // STOPPED event does not appear when the calibration is ongoing
+ m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
}
+ else if (!m_cb.event_handler)
+ {
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+
+ m_cb.p_buffer_primary = NULL;
+ m_cb.p_buffer_secondary = NULL;
+ switch (m_cb.saadc_state)
+ {
+ case NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE:
+ m_cb.saadc_state = NRF_SAADC_STATE_SIMPLE_MODE;
+ break;
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE:
+ /* fall-through */
- err_code = NRFX_SUCCESS;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE;
+ break;
+ default:
+ break;
+ }
+ }
+}
-nrfx_err_t nrfx_saadc_buffer_convert(nrf_saadc_value_t * p_buffer, uint16_t size)
+nrfx_err_t nrfx_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high)
{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_ASSERT((size % m_cb.active_channels) == 0);
- nrfx_err_t err_code;
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
+ NRFX_ASSERT(limit_high <= limit_low);
- nrf_saadc_int_disable(NRF_SAADC_INT_END | NRF_SAADC_INT_CALIBRATEDONE);
- if (m_cb.adc_state == NRF_SAADC_STATE_CALIBRATION)
+ if (!m_cb.event_handler)
{
- nrf_saadc_int_enable(NRF_SAADC_INT_END | NRF_SAADC_INT_CALIBRATEDONE);
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_ERROR_FORBIDDEN;
}
- if (m_cb.adc_state == NRF_SAADC_STATE_BUSY)
+
+ if ((m_cb.saadc_state == NRF_SAADC_STATE_IDLE) ||
+ (m_cb.saadc_state == NRF_SAADC_STATE_CALIBRATION))
{
- if ( m_cb.p_secondary_buffer)
- {
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
- else
- {
- m_cb.p_secondary_buffer = p_buffer;
- m_cb.secondary_buffer_size = size;
- if (!m_cb.low_power_mode)
- {
- while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- nrf_saadc_buffer_init(p_buffer, size);
- }
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
- err_code = NRFX_SUCCESS;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
+ return NRFX_ERROR_INVALID_STATE;
+ }
+
+ if (!(m_cb.channels_activated & (1 << channel)))
+ {
+ return NRFX_ERROR_INVALID_PARAM;
}
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
- m_cb.adc_state = NRF_SAADC_STATE_BUSY;
- m_cb.p_buffer = p_buffer;
- m_cb.buffer_size = size;
- m_cb.p_secondary_buffer = NULL;
+ nrf_saadc_channel_limits_set(NRF_SAADC, channel, limit_low, limit_high);
- NRFX_LOG_INFO("Function: %s, buffer length: %d, active channels: %d.",
- __func__,
- size,
- m_cb.active_channels);
+ uint32_t int_mask = nrf_saadc_limit_int_get(channel, NRF_SAADC_LIMIT_LOW);
+ if (limit_low == INT16_MIN)
+ {
+ m_cb.limits_low_activated &= ~(1 << channel);
+ nrf_saadc_int_disable(NRF_SAADC, int_mask);
+ }
+ else
+ {
+ m_cb.limits_low_activated |= (1 << channel);
+ nrf_saadc_int_enable(NRF_SAADC, int_mask);
+ }
- if (m_cb.low_power_mode)
+ int_mask = nrf_saadc_limit_int_get(channel, NRF_SAADC_LIMIT_HIGH);
+ if (limit_high == INT16_MAX)
{
- m_cb.buffer_size_left = size;
- nrf_saadc_buffer_init(p_buffer, m_cb.active_channels);
+ m_cb.limits_high_activated &= ~(1 << channel);
+ nrf_saadc_int_disable(NRF_SAADC, int_mask);
}
else
{
- nrf_saadc_buffer_init(p_buffer, size);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
+ m_cb.limits_high_activated |= (1 << channel);
+ nrf_saadc_int_enable(NRF_SAADC, int_mask);
}
- err_code = NRFX_SUCCESS;
- NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_SUCCESS;
}
-
-nrfx_err_t nrfx_saadc_sample()
+nrfx_err_t nrfx_saadc_offset_calibrate(nrfx_saadc_event_handler_t event_handler)
{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
+ NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
- nrfx_err_t err_code = NRFX_SUCCESS;
- if (m_cb.adc_state != NRF_SAADC_STATE_BUSY)
+ if (saadc_busy_check())
{
- err_code = NRFX_ERROR_INVALID_STATE;
+ return NRFX_ERROR_BUSY;
}
- else if (m_cb.low_power_mode)
+
+ m_cb.saadc_state = NRF_SAADC_STATE_CALIBRATION;
+ m_cb.event_handler = event_handler;
+
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
+ nrf_saadc_enable(NRF_SAADC);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET);
+ if (event_handler)
{
- nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
+ nrf_saadc_int_enable(NRF_SAADC, NRF_SAADC_INT_CALIBRATEDONE);
}
else
{
- nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
+ nrf_saadc_disable(NRF_SAADC);
+ m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
}
- NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
+ return NRFX_SUCCESS;
}
-
-nrfx_err_t nrfx_saadc_calibrate_offset()
+static void saadc_event_started_handle(void)
{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
-
- nrfx_err_t err_code;
+ nrfx_saadc_evt_t evt_data;
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
+ switch (m_cb.saadc_state)
{
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE:
+ evt_data.type = NRFX_SAADC_EVT_READY;
+ m_cb.event_handler(&evt_data);
- m_cb.adc_state = NRF_SAADC_STATE_CALIBRATION;
+ if (nrf_saadc_continuous_mode_enable_check(NRF_SAADC))
+ {
+ // Trigger internal timer
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ }
- nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE);
- nrf_saadc_int_enable(NRF_SAADC_INT_CALIBRATEDONE);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_CALIBRATEOFFSET);
- err_code = NRFX_SUCCESS;
- NRFX_LOG_INFO("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED;
+ if (m_cb.p_buffer_secondary)
+ {
+ nrf_saadc_buffer_init(NRF_SAADC,
+ m_cb.p_buffer_secondary,
+ m_cb.size_secondary);
+ }
+ /* fall-through */
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
+ evt_data.type = NRFX_SAADC_EVT_BUF_REQ;
+ m_cb.event_handler(&evt_data);
+ break;
-bool nrfx_saadc_is_busy(void)
-{
- return (m_cb.adc_state != NRF_SAADC_STATE_IDLE);
+ case NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE:
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ break;
+
+ default:
+ break;
+ }
}
+static void saadc_event_end_handle(void)
+{
+ nrfx_saadc_evt_t evt_data;
+ evt_data.type = NRFX_SAADC_EVT_DONE;
+ evt_data.data.done.p_buffer = m_cb.p_buffer_primary;
+ evt_data.data.done.size = m_cb.size_primary;
+ m_cb.event_handler(&evt_data);
+
+ switch (m_cb.saadc_state)
+ {
+ case NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE:
+ nrf_saadc_disable(NRF_SAADC);
+ m_cb.saadc_state = NRF_SAADC_STATE_SIMPLE_MODE;
+ break;
+
+ case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
+ m_cb.p_buffer_primary = m_cb.p_buffer_secondary;
+ m_cb.size_primary = m_cb.size_secondary;
+ m_cb.p_buffer_secondary = NULL;
+ if (m_cb.p_buffer_primary)
+ {
+ if (m_cb.start_on_end)
+ {
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ }
+ }
+ else
+ {
+ nrf_saadc_disable(NRF_SAADC);
+ m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE;
+ evt_data.type = NRFX_SAADC_EVT_FINISHED;
+ m_cb.event_handler(&evt_data);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
... 268062 lines suppressed ...