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:46 UTC
[mynewt-core] branch master updated (e43f996 -> 26a9a52)
This is an automated email from the ASF dual-hosted git repository.
janc pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.
from e43f996 [STM32] Add UART2 initialization
new e9b5e83 Update NRFX to release 2.0.0
new bcd372f hw/drivers/pwm: Update nrf52_pwm for nrfx 2.0.0
new 55dc8b7 hw/drivers/adc: Update nrf52_adc driver for nrfx 2.0.0
new 87ad09d hw/drivers/adc: Update nrf51_adc driver for nrfx 2.0.0
new c05a096 Update NRFX to release 2.1.0
new 26a9a52 adc_nrf52: Fix buffer size when initializing buffers.
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
hw/drivers/adc/adc_nrf51/src/adc_nrf51.c | 109 +-
.../adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h | 63 +-
hw/drivers/adc/adc_nrf52/src/adc_nrf52.c | 590 +-
hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c | 99 +-
hw/mcu/nordic/nrf52xxx/src/nrfx_saadc_mod.c | 651 -
hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md | 107 +
hw/mcu/nordic/src/ext/nrfx/LICENSE | 2 +-
hw/mcu/nordic/src/ext/nrfx/README.md | 13 +-
.../src/ext/nrfx/drivers/include/nrf_bitmask.h | 55 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_adc.h | 48 +-
.../src/ext/nrfx/drivers/include/nrfx_clock.h | 221 +-
.../src/ext/nrfx/drivers/include/nrfx_comp.h | 75 +-
.../src/ext/nrfx/drivers/include/nrfx_dppi.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_egu.h | 157 +
.../src/ext/nrfx/drivers/include/nrfx_gpiote.h | 74 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h | 110 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h | 218 +
.../src/ext/nrfx/drivers/include/nrfx_lpcomp.h | 41 +-
.../src/ext/nrfx/drivers/include/nrfx_nfct.h | 25 +-
.../src/ext/nrfx/drivers/include/nrfx_nvmc.h | 33 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h | 100 +-
.../src/ext/nrfx/drivers/include/nrfx_power.h | 58 +-
.../ext/nrfx/drivers/include/nrfx_power_clock.h | 15 +-
.../ext/nrfx/drivers/include/nrfx_power_compat.h | 106 +
.../nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h | 76 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h | 154 +-
.../src/ext/nrfx/drivers/include/nrfx_qdec.h | 62 +-
.../src/ext/nrfx/drivers/include/nrfx_qspi.h | 112 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_rng.h | 13 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h | 95 +-
.../src/ext/nrfx/drivers/include/nrfx_saadc.h | 364 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_spi.h | 50 +-
.../src/ext/nrfx/drivers/include/nrfx_spim.h | 138 +-
.../src/ext/nrfx/drivers/include/nrfx_spis.h | 64 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_swi.h | 236 -
.../src/ext/nrfx/drivers/include/nrfx_systick.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_temp.h | 12 +-
.../src/ext/nrfx/drivers/include/nrfx_timer.h | 148 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_twi.h | 166 +-
.../nrf_ecb.c => drivers/include/nrfx_twi_twim.h} | 57 +-
.../src/ext/nrfx/drivers/include/nrfx_twim.h | 190 +-
.../src/ext/nrfx/drivers/include/nrfx_twis.h | 44 +-
.../src/ext/nrfx/drivers/include/nrfx_uart.h | 70 +-
.../src/ext/nrfx/drivers/include/nrfx_uarte.h | 70 +-
.../src/ext/nrfx/drivers/include/nrfx_usbd.h | 6 +-
.../src/ext/nrfx/drivers/include/nrfx_usbreg.h | 151 +
.../nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h | 130 +-
hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h | 53 +-
hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_errors.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c | 66 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_clock.c | 289 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c | 66 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c | 8 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c | 215 +
.../nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c | 480 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c | 22 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c | 162 +
.../nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c | 33 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c | 398 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c | 34 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c | 63 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_power.c | 92 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c | 52 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c | 83 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c | 64 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c | 63 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c | 24 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c | 72 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c | 1065 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c | 10 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c | 149 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c | 18 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_swi.c | 430 -
.../nordic/src/ext/nrfx/drivers/src/nrfx_systick.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_temp.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_timer.c | 70 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c | 283 +-
.../{hal/nrf_ecb.c => drivers/src/nrfx_twi_twim.c} | 85 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c | 280 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twis.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c | 19 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c | 65 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c | 265 +-
.../src/ext/nrfx/drivers/src/nrfx_usbd_errata.h | 57 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_usbreg.c | 97 +
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c | 131 +-
.../nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h | 28 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h | 151 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h | 42 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h | 137 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h | 29 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h | 401 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h | 175 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h | 832 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h | 211 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_dcnf.h | 200 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h | 136 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h | 110 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h | 252 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h | 30 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h | 156 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h | 281 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h | 413 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h | 294 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h | 497 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h | 73 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h | 221 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h | 45 +-
.../ext/nrfx/hal/{nrf_regulators.h => nrf_mutex.h} | 61 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h | 195 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h | 571 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.c | 124 -
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h | 189 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_oscillators.h | 121 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h | 341 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h | 544 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h | 287 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h | 258 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h | 321 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h | 420 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h | 747 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h | 263 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h | 128 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h | 135 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h | 164 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h | 517 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h | 119 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h | 370 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h | 286 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h | 235 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h | 34 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h | 101 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h | 269 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h | 159 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h | 275 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h | 306 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h | 234 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h | 314 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h | 700 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbreg.h | 173 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h | 90 +-
.../nrfx/hal/{nrf_regulators.h => nrf_vreqctrl.h} | 50 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h | 210 +-
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} | 287 +-
...up_nrf52810.s => arm_startup_nrf5340_network.s} | 136 +-
.../nordic/src/ext/nrfx/mdk/compiler_abstraction.h | 20 +
hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf51.S | 2 +-
hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52.S | 2 +-
...c_startup_nrf52810.S => gcc_startup_nrf52805.S} | 14 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S | 25 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52811.S | 2 +-
...c_startup_nrf52840.S => gcc_startup_nrf52833.S} | 8 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52840.S | 2 +-
...nrf9160.S => gcc_startup_nrf5340_application.S} | 66 +-
...up_nrf52811.S => gcc_startup_nrf5340_network.S} | 109 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf9160.S | 2 +-
...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} | 333 +-
...up_nrf52810.s => iar_startup_nrf5340_network.s} | 153 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h | 72 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h | 11 +-
.../nordic/src/ext/nrfx/mdk/nrf51422_peripherals.h | 6 +
.../nordic/src/ext/nrfx/mdk/nrf51801_peripherals.h | 6 +
.../nordic/src/ext/nrfx/mdk/nrf51802_peripherals.h | 6 +
.../nordic/src/ext/nrfx/mdk/nrf51822_peripherals.h | 6 +
.../nordic/src/ext/nrfx/mdk/nrf51824_peripherals.h | 6 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_erratas.h | 3621 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_peripherals.h | 5 +
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 +-
...f52811_peripherals.h => nrf52805_peripherals.h} | 36 +-
.../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 +-
.../nordic/src/ext/nrfx/mdk/nrf52810_name_change.h | 2 +-
.../nordic/src/ext/nrfx/mdk/nrf52810_peripherals.h | 6 +
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 +-
.../nordic/src/ext/nrfx/mdk/nrf52811_peripherals.h | 7 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811_xxaa.ld | 3 +-
.../nordic/src/ext/nrfx/mdk/nrf52832_peripherals.h | 8 +
.../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} | 362 +-
.../ext/nrfx/mdk/{nrf52840.svd => nrf52833.svd} | 2841 +-
.../{nrf52840_bitfields.h => nrf52833_bitfields.h} | 1112 +-
...f52840_peripherals.h => nrf52833_peripherals.h} | 36 +-
.../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 +-
.../nordic/src/ext/nrfx/mdk/nrf52840_peripherals.h | 11 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840_xxaa.ld | 3 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52_erratas.h | 7787 +++
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} | 1916 +-
.../mdk/{nrf52840.svd => nrf5340_application.svd} | 66664 ++++++++++---------
...bitfields.h => nrf5340_application_bitfields.h} | 14821 +++--
...pherals.h => nrf5340_application_peripherals.h} | 199 +-
.../ext/nrfx/mdk/{nrf9160.h => nrf5340_network.h} | 2663 +-
.../nrfx/mdk/{nrf52811.svd => nrf5340_network.svd} | 42443 ++++++------
...811_bitfields.h => nrf5340_network_bitfields.h} | 9816 +--
...peripherals.h => nrf5340_network_peripherals.h} | 138 +-
...rf52840_xxaa.ld => nrf5340_xxaa_application.ld} | 3 +-
.../{nrf51801_xxab.ld => nrf5340_xxaa_network.ld} | 4 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf53_erratas.h | 1609 +
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 +-
...rf52810_name_change.h => nrf9160_name_change.h} | 29 +-
.../nordic/src/ext/nrfx/mdk/nrf9160_peripherals.h | 51 +-
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/nrf91_erratas.h | 639 +
.../nrfx/mdk/{startup_config.h => nrf_erratas.h} | 24 +-
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} | 103 +-
...up_nrf52810.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 | 214 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52805.c | 126 +
.../ext/nrfx/{LICENSE => mdk/system_nrf52805.h} | 27 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52810.c | 332 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52810.h | 71 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52811.c | 197 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52811.h | 71 +-
.../mdk/{system_nrf52840.c => system_nrf52833.c} | 168 +-
.../ext/nrfx/{LICENSE => mdk/system_nrf52833.h} | 27 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52840.c | 153 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52840.h | 71 +-
.../src/ext/nrfx/mdk/system_nrf5340_application.c | 233 +
.../{LICENSE => mdk/system_nrf5340_application.h} | 27 +-
.../src/ext/nrfx/mdk/system_nrf5340_network.c | 89 +
.../nrfx/{LICENSE => mdk/system_nrf5340_network.h} | 27 +-
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/nrfx.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_atomic.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_atomic.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_atomic_internal.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_coredep.h | 32 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs.h | 8 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf51.h | 10 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52810.h | 12 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52811.h | 12 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52832.h | 16 +-
.../{nrfx_irqs_nrf52840.h => nrfx_irqs_nrf52833.h} | 26 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52840.h | 16 +-
.../ext/nrfx/soc/nrfx_irqs_nrf5340_application.h | 196 +
...fx_irqs_nrf51.h => nrfx_irqs_nrf5340_network.h} | 88 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf9160.h | 16 +-
.../src/ext/nrfx/templates/nRF52840/nrfx_config.h | 3180 -
.../{soc/nrfx_irqs.h => templates/nrfx_config.h} | 26 +-
.../{nRF51/nrfx_config.h => nrfx_config_nrf51.h} | 572 +-
.../nrfx_config.h => nrfx_config_nrf52810.h} | 903 +-
.../nrfx_config.h => nrfx_config_nrf52811.h} | 906 +-
.../nrfx_config.h => nrfx_config_nrf52832.h} | 1174 +-
.../nrfx_config.h => nrfx_config_nrf52833.h} | 1298 +-
.../nrfx_config.h => nrfx_config_nrf52840.h} | 1322 +-
..._config.h => nrfx_config_nrf5340_application.h} | 1369 +-
.../nrfx/templates/nrfx_config_nrf5340_network.h | 1248 +
.../nrfx_config.h => nrfx_config_nrf9160.h} | 852 +-
hw/mcu/nordic/src/ext/nrfx/templates/nrfx_glue.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/templates/nrfx_log.h | 2 +-
292 files changed, 113637 insertions(+), 95385 deletions(-)
delete mode 100644 hw/mcu/nordic/nrf52xxx/src/nrfx_saadc_mod.c
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_egu.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_compat.h
delete mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_swi.h
copy hw/mcu/nordic/src/ext/nrfx/{hal/nrf_ecb.c => drivers/include/nrfx_twi_twim.h} (57%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbreg.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c
delete mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_swi.c
rename hw/mcu/nordic/src/ext/nrfx/{hal/nrf_ecb.c => drivers/src/nrfx_twi_twim.c} (52%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbreg.c
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_dcnf.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h
copy hw/mcu/nordic/src/ext/nrfx/hal/{nrf_regulators.h => nrf_mutex.h} (53%)
delete mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.c
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_oscillators.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbreg.h
copy hw/mcu/nordic/src/ext/nrfx/hal/{nrf_regulators.h => nrf_vreqctrl.h} (60%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h
copy hw/mcu/nordic/src/ext/nrfx/mdk/{arm_startup_nrf52810.s => arm_startup_nrf52805.s} (96%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{arm_startup_nrf52810.s => arm_startup_nrf52833.s} (82%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{arm_startup_nrf52810.s => arm_startup_nrf5340_application.s} (50%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{arm_startup_nrf52810.s => arm_startup_nrf5340_network.s} (82%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{gcc_startup_nrf52810.S => gcc_startup_nrf52805.S} (97%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{gcc_startup_nrf52840.S => gcc_startup_nrf52833.S} (98%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{gcc_startup_nrf9160.S => gcc_startup_nrf5340_application.S} (93%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{gcc_startup_nrf52811.S => gcc_startup_nrf5340_network.S} (85%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{iar_startup_nrf52810.s => iar_startup_nrf52805.s} (95%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{iar_startup_nrf52810.s => iar_startup_nrf52833.s} (80%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{iar_startup_nrf52810.s => iar_startup_nrf5340_application.s} (52%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{iar_startup_nrf52810.s => iar_startup_nrf5340_network.s} (84%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_erratas.h
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52810.h => nrf52805.h} (85%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52810.svd => nrf52805.svd} (90%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52810_bitfields.h => nrf52805_bitfields.h} (88%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52811_peripherals.h => nrf52805_peripherals.h} (90%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf51801_xxab.ld => nrf52805_xxaa.ld} (63%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52_xxaa.ld => nrf52832_xxaa.ld} (62%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840.h => nrf52833.h} (92%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840.svd => nrf52833.svd} (97%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840_bitfields.h => nrf52833_bitfields.h} (95%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840_peripherals.h => nrf52833_peripherals.h} (92%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52_xxaa.ld => nrf52833_xxaa.ld} (62%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/nrf52_erratas.h
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/nrf52_to_nrf52833.h
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf9160.h => nrf5340_application.h} (54%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840.svd => nrf5340_application.svd} (80%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840_bitfields.h => nrf5340_application_bitfields.h} (58%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840_peripherals.h => nrf5340_application_peripherals.h} (68%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf9160.h => nrf5340_network.h} (60%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52811.svd => nrf5340_network.svd} (83%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52811_bitfields.h => nrf5340_network_bitfields.h} (61%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52810_peripherals.h => nrf5340_network_peripherals.h} (67%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52840_xxaa.ld => nrf5340_xxaa_application.ld} (63%)
rename hw/mcu/nordic/src/ext/nrfx/mdk/{nrf51801_xxab.ld => nrf5340_xxaa_network.ld} (54%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/nrf53_erratas.h
copy hw/mcu/nordic/src/ext/nrfx/mdk/{nrf52810_name_change.h => nrf9160_name_change.h} (63%)
delete mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/nrf91_common.ld
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/nrf91_erratas.h
rename hw/mcu/nordic/src/ext/nrfx/mdk/{startup_config.h => nrf_erratas.h} (55%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{ses_startup_nrf52810.s => ses_startup_nrf52805.s} (97%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{ses_startup_nrf52840.s => ses_startup_nrf52833.s} (98%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{ses_startup_nrf9160.s => ses_startup_nrf5340_application.s} (91%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{ses_startup_nrf52810.s => ses_startup_nrf5340_network.s} (85%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{system_nrf9160.h => system_nrf.h} (94%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52805.c
copy hw/mcu/nordic/src/ext/nrfx/{LICENSE => mdk/system_nrf52805.h} (71%)
copy hw/mcu/nordic/src/ext/nrfx/mdk/{system_nrf52840.c => system_nrf52833.c} (63%)
copy hw/mcu/nordic/src/ext/nrfx/{LICENSE => mdk/system_nrf52833.h} (71%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf5340_application.c
copy hw/mcu/nordic/src/ext/nrfx/{LICENSE => mdk/system_nrf5340_application.h} (70%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf5340_network.c
copy hw/mcu/nordic/src/ext/nrfx/{LICENSE => mdk/system_nrf5340_network.h} (71%)
copy hw/mcu/nordic/src/ext/nrfx/soc/{nrfx_irqs_nrf52840.h => nrfx_irqs_nrf52833.h} (90%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf5340_application.h
copy hw/mcu/nordic/src/ext/nrfx/soc/{nrfx_irqs_nrf51.h => nrfx_irqs_nrf5340_network.h} (62%)
delete mode 100644 hw/mcu/nordic/src/ext/nrfx/templates/nRF52840/nrfx_config.h
copy hw/mcu/nordic/src/ext/nrfx/{soc/nrfx_irqs.h => templates/nrfx_config.h} (75%)
rename hw/mcu/nordic/src/ext/nrfx/templates/{nRF51/nrfx_config.h => nrfx_config_nrf51.h} (66%)
copy hw/mcu/nordic/src/ext/nrfx/templates/{nRF52810/nrfx_config.h => nrfx_config_nrf52810.h} (66%)
copy hw/mcu/nordic/src/ext/nrfx/templates/{nRF52810/nrfx_config.h => nrfx_config_nrf52811.h} (66%)
rename hw/mcu/nordic/src/ext/nrfx/templates/{nRF52832/nrfx_config.h => nrfx_config_nrf52832.h} (66%)
rename hw/mcu/nordic/src/ext/nrfx/templates/{nRF52811/nrfx_config.h => nrfx_config_nrf52833.h} (67%)
rename hw/mcu/nordic/src/ext/nrfx/templates/{nRF52810/nrfx_config.h => nrfx_config_nrf52840.h} (68%)
copy hw/mcu/nordic/src/ext/nrfx/templates/{nRF9160/nrfx_config.h => nrfx_config_nrf5340_application.h} (60%)
create mode 100644 hw/mcu/nordic/src/ext/nrfx/templates/nrfx_config_nrf5340_network.h
rename hw/mcu/nordic/src/ext/nrfx/templates/{nRF9160/nrfx_config.h => nrfx_config_nrf9160.h} (66%)
[mynewt-core] 01/06: Update NRFX to release 2.0.0
Posted by ja...@apache.org.
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 ...
[mynewt-core] 02/06: hw/drivers/pwm: Update nrf52_pwm for nrfx 2.0.0
Posted by ja...@apache.org.
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 bcd372f03d97cb9b995dbc20a6d69edd8c03c027
Author: Miguel Azevedo <mi...@gmail.com>
AuthorDate: Fri Nov 22 17:12:06 2019 +0000
hw/drivers/pwm: Update nrf52_pwm for nrfx 2.0.0
---
hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c | 99 +++++++++++++++++++-------------
1 file changed, 58 insertions(+), 41 deletions(-)
diff --git a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
index f240788..cdb4c5a 100644
--- a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
+++ b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
@@ -58,7 +58,10 @@ static struct nrf52_pwm_dev_global instances[] =
[0].in_use = false,
[0].playing = false,
[0].drv_instance = NRFX_PWM_INSTANCE(0),
- [0].config = NRFX_PWM_DEFAULT_CONFIG,
+ [0].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED),
[0].flags = NRFX_PWM_FLAG_LOOP,
[0].duty_cycles = {0},
[0].n_cycles = 1,
@@ -72,7 +75,10 @@ static struct nrf52_pwm_dev_global instances[] =
[1].in_use = false,
[1].playing = false,
[1].drv_instance = NRFX_PWM_INSTANCE(1),
- [1].config = NRFX_PWM_DEFAULT_CONFIG,
+ [1].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED),
[1].flags = NRFX_PWM_FLAG_LOOP,
[1].duty_cycles = {0},
[1].n_cycles = 1,
@@ -86,7 +92,10 @@ static struct nrf52_pwm_dev_global instances[] =
[2].in_use = false,
[2].playing = false,
[2].drv_instance = NRFX_PWM_INSTANCE(2),
- [2].config = NRFX_PWM_DEFAULT_CONFIG,
+ [2].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED),
[2].flags = NRFX_PWM_FLAG_LOOP,
[2].duty_cycles = {0},
[2].n_cycles = 1,
@@ -100,7 +109,10 @@ static struct nrf52_pwm_dev_global instances[] =
[3].in_use = false,
[3].playing = false,
[3].drv_instance = NRFX_PWM_INSTANCE(3),
- [3].config = NRFX_PWM_DEFAULT_CONFIG,
+ [3].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED,
+ NRFX_PWM_PIN_NOT_USED),
[3].flags = NRFX_PWM_FLAG_LOOP,
[3].duty_cycles = {0},
[3].n_cycles = 1,
@@ -113,20 +125,20 @@ static struct nrf52_pwm_dev_global instances[] =
};
#if MYNEWT_VAL(PWM_0)
-static void handler_0(nrfx_pwm_evt_type_t event_type)
+static void
+handler_0(nrfx_pwm_evt_type_t event_type, void *unused)
{
- switch (event_type)
- {
- case NRFX_PWM_EVT_END_SEQ0 :
- case NRFX_PWM_EVT_END_SEQ1 :
+ switch (event_type) {
+ case NRFX_PWM_EVT_END_SEQ0:
+ case NRFX_PWM_EVT_END_SEQ1:
instances[0].cycle_handler(instances[0].cycle_data);
break;
- case NRFX_PWM_EVT_FINISHED :
+ case NRFX_PWM_EVT_FINISHED:
instances[0].seq_end_handler(instances[0].seq_end_data);
break;
- case NRFX_PWM_EVT_STOPPED :
+ case NRFX_PWM_EVT_STOPPED:
break;
default:
@@ -136,20 +148,20 @@ static void handler_0(nrfx_pwm_evt_type_t event_type)
#endif
#if MYNEWT_VAL(PWM_1)
-static void handler_1(nrfx_pwm_evt_type_t event_type)
+static void
+handler_1(nrfx_pwm_evt_type_t event_type, void *unused)
{
- switch (event_type)
- {
- case NRFX_PWM_EVT_END_SEQ0 :
- case NRFX_PWM_EVT_END_SEQ1 :
+ switch (event_type) {
+ case NRFX_PWM_EVT_END_SEQ0:
+ case NRFX_PWM_EVT_END_SEQ1:
instances[1].cycle_handler(instances[1].cycle_data);
break;
- case NRFX_PWM_EVT_FINISHED :
+ case NRFX_PWM_EVT_FINISHED:
instances[1].seq_end_handler(instances[1].seq_end_data);
break;
- case NRFX_PWM_EVT_STOPPED :
+ case NRFX_PWM_EVT_STOPPED:
break;
default:
@@ -159,20 +171,20 @@ static void handler_1(nrfx_pwm_evt_type_t event_type)
#endif
#if MYNEWT_VAL(PWM_2)
-static void handler_2(nrfx_pwm_evt_type_t event_type)
+static void
+handler_2(nrfx_pwm_evt_type_t event_type, void *unused)
{
- switch (event_type)
- {
- case NRFX_PWM_EVT_END_SEQ0 :
- case NRFX_PWM_EVT_END_SEQ1 :
+ switch (event_type) {
+ case NRFX_PWM_EVT_END_SEQ0:
+ case NRFX_PWM_EVT_END_SEQ1:
instances[2].cycle_handler(instances[2].cycle_data);
break;
- case NRFX_PWM_EVT_FINISHED :
+ case NRFX_PWM_EVT_FINISHED:
instances[2].seq_end_handler(instances[2].seq_end_data);
break;
- case NRFX_PWM_EVT_STOPPED :
+ case NRFX_PWM_EVT_STOPPED:
break;
default:
@@ -183,20 +195,20 @@ static void handler_2(nrfx_pwm_evt_type_t event_type)
#endif
#if MYNEWT_VAL(PWM_3)
-static void handler_3(nrfx_pwm_evt_type_t event_type)
+static void
+handler_3(nrfx_pwm_evt_type_t event_type, void *unused)
{
- switch (event_type)
- {
- case NRFX_PWM_EVT_END_SEQ0 :
- case NRFX_PWM_EVT_END_SEQ1 :
+ switch (event_type) {
+ case NRFX_PWM_EVT_END_SEQ0:
+ case NRFX_PWM_EVT_END_SEQ1:
instances[3].cycle_handler(instances[3].cycle_data);
break;
- case NRFX_PWM_EVT_FINISHED :
+ case NRFX_PWM_EVT_FINISHED:
instances[3].seq_end_handler(instances[3].seq_end_data);
break;
- case NRFX_PWM_EVT_STOPPED :
+ case NRFX_PWM_EVT_STOPPED:
break;
default:
@@ -243,11 +255,12 @@ init_instance(int inst_id, nrfx_pwm_config_t* init_conf)
config->output_pins[2] = NRFX_PWM_PIN_NOT_USED;
config->output_pins[3] = NRFX_PWM_PIN_NOT_USED;
config->irq_priority = 3; /* APP_IRQ_PRIORITY_LOW */
- config->base_clock = NRF_PWM_CLK_1MHz;
- config->count_mode = NRF_PWM_MODE_UP;
- config->top_value = 10000;
- config->load_mode = NRF_PWM_LOAD_INDIVIDUAL;
- config->step_mode = NRF_PWM_STEP_AUTO;
+ config->base_clock = NRF_PWM_CLK_1MHz;
+ config->count_mode = NRF_PWM_MODE_UP;
+ config->top_value = 10000;
+ config->load_mode = NRF_PWM_LOAD_INDIVIDUAL;
+ config->step_mode = NRF_PWM_STEP_AUTO;
+ config->skip_gpio_cfg = false;
} else {
memcpy(config, init_conf, sizeof(nrfx_pwm_config_t));
}
@@ -422,7 +435,8 @@ nrf52_pwm_configure_device(struct pwm_dev *dev, struct pwm_dev_cfg *cfg)
nrfx_pwm_uninit(&instance->drv_instance);
nrfx_pwm_init(&instance->drv_instance,
&instance->config,
- instance->internal_handler);
+ instance->internal_handler,
+ NULL);
play_current_config(instance);
}
@@ -459,7 +473,8 @@ nrf52_pwm_configure_channel(struct pwm_dev *dev,
nrfx_pwm_uninit(&instance->drv_instance);
nrfx_pwm_init(&instance->drv_instance,
&instance->config,
- instance->internal_handler);
+ instance->internal_handler,
+ NULL);
play_current_config(instance);
}
@@ -519,7 +534,8 @@ nrf52_pwm_enable(struct pwm_dev *dev)
nrfx_pwm_init(&instance->drv_instance,
&instance->config,
- instance->internal_handler);
+ instance->internal_handler,
+ NULL);
play_current_config(instance);
instance->playing = true;
@@ -623,7 +639,8 @@ nrf52_pwm_set_frequency(struct pwm_dev *dev, uint32_t freq_hz)
nrfx_pwm_uninit(&instances[inst_id].drv_instance);
nrfx_pwm_init(&instances[inst_id].drv_instance,
&instances[inst_id].config,
- instances[inst_id].internal_handler);
+ instances[inst_id].internal_handler,
+ NULL);
play_current_config(&instances[inst_id]);
}
[mynewt-core] 04/06: hw/drivers/adc: Update nrf51_adc driver for
nrfx 2.0.0
Posted by ja...@apache.org.
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 87ad09ddea808396e7b5743778e954bfa8b41d64
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Wed Feb 26 15:19:00 2020 +0100
hw/drivers/adc: Update nrf51_adc driver for nrfx 2.0.0
---
hw/drivers/adc/adc_nrf51/src/adc_nrf51.c | 109 ++++++++++++++++---------------
1 file changed, 55 insertions(+), 54 deletions(-)
diff --git a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
index bc7dda4..32ce1ad 100644
--- a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
+++ b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
@@ -172,81 +172,84 @@ static int
nrf51_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
void *cfgdata)
{
- int rc;
- nrfx_adc_channel_config_t *cc_cfg;
- int reference;
+ nrf_adc_config_t *cc_cfg;
uint16_t refmv;
uint8_t res;
if (global_adc_config == NULL) {
- rc = OS_ERROR;
- goto err;
+ return OS_ERROR;
}
- //store nrf_adc_chan for nrf51_adc_read_channel
+ /* store nrf_adc_chan for nrf51_adc_read_channel */
nrf_adc_chan = cfgdata;
nrfx_adc_channel_enable(nrf_adc_chan);
- // they play shenanigans storing the reference bit fields so we have to as well
- cc_cfg = &nrf_adc_chan->config.config;
- reference = cc_cfg->reference | (cc_cfg->external_reference << ADC_CONFIG_EXTREFSEL_Pos);
+ cc_cfg = &nrf_adc_chan->config;
/* Set the resolution and reference voltage for this channel to
- * enable conversion functions.
- */
+ * enable conversion functions.
+ */
switch (cc_cfg->resolution) {
- case NRF_ADC_CONFIG_RES_8BIT:
- res = 8;
- break;
- case NRF_ADC_CONFIG_RES_9BIT:
- res = 9;
- break;
- case NRF_ADC_CONFIG_RES_10BIT:
- res = 10;
- break;
- default:
- assert(0);
+ case NRF_ADC_CONFIG_RES_8BIT:
+ res = 8;
+ break;
+ case NRF_ADC_CONFIG_RES_9BIT:
+ res = 9;
+ break;
+ case NRF_ADC_CONFIG_RES_10BIT:
+ res = 10;
+ break;
+ default:
+ assert(0);
}
- switch (reference) {
- case NRF_ADC_CONFIG_REF_VBG:
- refmv = 1200; /* 1.2V for NRF51 */
- break;
- case NRF_ADC_CONFIG_REF_EXT_REF0:
+ switch (cc_cfg->reference) {
+ case NRF_ADC_CONFIG_REF_VBG:
+ refmv = 1200; /* 1.2V for NRF51 */
+ break;
+ case NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF:
+ refmv = init_adc_config->nadc_refmv_vdd / 2;
+ break;
+ case NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD:
+ refmv = init_adc_config->nadc_refmv_vdd / 3;
+ break;
+ case NRF_ADC_CONFIG_REF_EXT:
+ switch (cc_cfg->extref) {
+ case NRF_ADC_CONFIG_EXTREFSEL_AREF0:
refmv = init_adc_config->nadc_refmv0;
break;
- case NRF_ADC_CONFIG_REF_EXT_REF1:
+ case NRF_ADC_CONFIG_EXTREFSEL_AREF1:
refmv = init_adc_config->nadc_refmv1;
break;
- case NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF:
- refmv = init_adc_config->nadc_refmv_vdd / 2;
- break;
- case NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD:
- refmv = init_adc_config->nadc_refmv_vdd / 3;
- break;
+ case NRF_ADC_CONFIG_EXTREFSEL_NONE:
default:
assert(0);
+ break;
+ }
+ break;
+ default:
+ assert(0);
}
/* Adjust reference voltage for gain. */
- switch (cc_cfg->input) {
- case NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE:
- break;
- case NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD:
- refmv *= 3;
- break;
- case NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS:
- refmv = (refmv * 3) / 2;
- break;
- case NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD:
- refmv = refmv * 3;
- break;
- case NRF_ADC_CONFIG_SCALING_SUPPLY_TWO_THIRDS:
- refmv = (refmv * 3) / 2;
- break;
- default:
- break;
+ switch (cc_cfg->scaling) {
+ case NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE:
+ break;
+ case NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD:
+ refmv *= 3;
+ break;
+ case NRF_ADC_CONFIG_SCALING_INPUT_TWO_THIRDS:
+ refmv = (refmv * 3) / 2;
+ break;
+ case NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD:
+ refmv = refmv * 3;
+ break;
+ case NRF_ADC_CONFIG_SCALING_SUPPLY_TWO_THIRDS:
+ refmv = (refmv * 3) / 2;
+ break;
+ default:
+ break;
}
/* Store these values in channel definitions, for conversions to
@@ -257,9 +260,7 @@ nrf51_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
dev->ad_chans[cnum].c_configured = 1;
dev->ad_chans[cnum].c_cnum = cnum;
- return (0);
-err:
- return (rc);
+ return 0;
}
/**
[mynewt-core] 06/06: adc_nrf52: Fix buffer size when initializing
buffers.
Posted by ja...@apache.org.
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 26a9a5263b526f9869b8057a99be0759d601c8b7
Author: Miguel Azevedo <mi...@gmail.com>
AuthorDate: Thu Feb 27 19:28:47 2020 +0000
adc_nrf52: Fix buffer size when initializing buffers.
---
hw/drivers/adc/adc_nrf52/src/adc_nrf52.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
index 44cb266..7b1398a 100644
--- a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
+++ b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
@@ -449,6 +449,7 @@ nrf52_adc_sample(struct adc_dev *dev)
int cnum;
int cnum_last = 0;
int used_chans = 0;
+ int size;
if (nrf_saadc_busy_check(NRF_SAADC)) {
return OS_EBUSY;
@@ -478,8 +479,8 @@ nrf52_adc_sample(struct adc_dev *dev)
}
nrf_saadc_resolution_set(NRF_SAADC, g_drv_instance.resolution);
- nrf_saadc_buffer_init(NRF_SAADC, g_drv_instance.primary_buf,
- g_drv_instance.primary_size);
+ size = g_drv_instance.primary_size / sizeof(nrf_saadc_value_t);
+ nrf_saadc_buffer_init(NRF_SAADC, g_drv_instance.primary_buf, size);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
@@ -592,9 +593,9 @@ nrf52_adc_size_buffer(struct adc_dev *dev, int chans, int samples)
void
nrf52_saadc_irq_handler(void)
{
- adc_event_type_t ev = ADC_EVENT_CALIBRATED;
void *buf = NULL;
int bufsize = 0;
+ int size;
if (global_adc_dev == NULL || !global_adc_dev->ad_event_handler_func) {
++nrf52_saadc_stats.saadc_events_failed;
@@ -613,26 +614,25 @@ nrf52_saadc_irq_handler(void)
g_drv_instance.secondary_buf = NULL;
g_drv_instance.secondary_size = 0;
- nrf_saadc_buffer_init(NRF_SAADC,
- g_drv_instance.primary_buf,
- g_drv_instance.primary_size);
+ size = g_drv_instance.primary_size / sizeof(nrf_saadc_value_t);
+ nrf_saadc_buffer_init(NRF_SAADC, g_drv_instance.primary_buf, size);
} else {
nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_ALL);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
nrf_saadc_disable(NRF_SAADC);
}
-
- ev = ADC_EVENT_RESULT;
global_adc_dev->ad_event_handler_func(global_adc_dev,
global_adc_dev->ad_event_handler_arg,
- ev, buf, bufsize);
+ ADC_EVENT_RESULT,
+ buf, bufsize);
} else if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE)) {
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
global_adc_dev->ad_event_handler_func(global_adc_dev,
global_adc_dev->ad_event_handler_arg,
- ev, buf, bufsize);
+ ADC_EVENT_CALIBRATED,
+ buf, bufsize);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
[mynewt-core] 05/06: Update NRFX to release 2.1.0
Posted by ja...@apache.org.
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 c05a0967e80bf60a228a419e7d05b46f1d106d05
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Tue Feb 25 14:09:10 2020 +0100
Update NRFX to release 2.1.0
---
hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md | 33 +
hw/mcu/nordic/src/ext/nrfx/LICENSE | 2 +-
.../src/ext/nrfx/drivers/include/nrf_bitmask.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_adc.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_clock.h | 199 +-
.../src/ext/nrfx/drivers/include/nrfx_comp.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_dppi.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_egu.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_gpiote.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_i2s.h | 53 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_lpcomp.h | 4 +-
.../src/ext/nrfx/drivers/include/nrfx_nfct.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_nvmc.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_pdm.h | 49 +-
.../src/ext/nrfx/drivers/include/nrfx_power.h | 48 +-
.../ext/nrfx/drivers/include/nrfx_power_clock.h | 2 +-
.../ext/nrfx/drivers/include/nrfx_power_compat.h | 106 +
.../nordic/src/ext/nrfx/drivers/include/nrfx_ppi.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_pwm.h | 33 +-
.../src/ext/nrfx/drivers/include/nrfx_qdec.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_qspi.h | 32 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_rng.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_rtc.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_saadc.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_spi.h | 4 +-
.../src/ext/nrfx/drivers/include/nrfx_spim.h | 6 +-
.../src/ext/nrfx/drivers/include/nrfx_spis.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_systick.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_temp.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_timer.h | 2 +-
.../nordic/src/ext/nrfx/drivers/include/nrfx_twi.h | 7 +-
.../src/ext/nrfx/drivers/include/nrfx_twi_twim.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_twim.h | 20 +-
.../src/ext/nrfx/drivers/include/nrfx_twis.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_uart.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_uarte.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_usbd.h | 2 +-
.../src/ext/nrfx/drivers/include/nrfx_usbreg.h | 151 +
.../nordic/src/ext/nrfx/drivers/include/nrfx_wdt.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_errors.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_adc.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_clock.c | 237 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_comp.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_dppi.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_gpiote.c | 283 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_i2s.c | 16 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_lpcomp.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nfct.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_nvmc.c | 23 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pdm.c | 63 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_power.c | 35 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ppi.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_pwm.c | 33 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qdec.c | 8 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_qspi.c | 46 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rng.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_rtc.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_saadc.c | 275 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c | 39 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_systick.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_temp.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_timer.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c | 62 +-
.../src/ext/nrfx/drivers/src/nrfx_twi_twim.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c | 193 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twis.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c | 61 +-
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c | 78 +-
.../src/ext/nrfx/drivers/src/nrfx_usbd_errata.h | 92 +-
.../nordic/src/ext/nrfx/drivers/src/nrfx_usbreg.c | 97 +
hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.c | 2 +-
.../nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h | 8 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h | 5 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h | 11 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h | 22 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h | 627 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_dcnf.h | 200 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h | 80 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h | 79 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h | 5 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mutex.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h | 20 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_oscillators.h | 121 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h | 83 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h | 93 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h | 4 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h | 206 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h | 10 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h | 247 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h | 22 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h | 11 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h | 25 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h | 11 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbreg.h | 173 +
hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h | 2 +-
.../nrfx/hal/{nrf_regulators.h => nrf_vreqctrl.h} | 50 +-
hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h | 2 +-
.../ext/nrfx/mdk/arm_startup_nrf5340_application.s | 28 +-
hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf51.S | 2 +-
hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52.S | 2 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52805.S | 2 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S | 2 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52811.S | 2 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52833.S | 2 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf52840.S | 2 +-
.../ext/nrfx/mdk/gcc_startup_nrf5340_application.S | 22 +-
.../src/ext/nrfx/mdk/gcc_startup_nrf5340_network.S | 2 +-
.../nordic/src/ext/nrfx/mdk/gcc_startup_nrf9160.S | 2 +-
.../ext/nrfx/mdk/iar_startup_nrf5340_application.s | 40 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h | 16 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51422_erratas.h | 2579 -------
.../nordic/src/ext/nrfx/mdk/nrf51422_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51801_erratas.h | 635 --
.../nordic/src/ext/nrfx/mdk/nrf51801_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51802_erratas.h | 635 --
.../nordic/src/ext/nrfx/mdk/nrf51802_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51822_erratas.h | 2993 --------
.../nordic/src/ext/nrfx/mdk/nrf51822_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51824_erratas.h | 743 --
.../nordic/src/ext/nrfx/mdk/nrf51824_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_erratas.h | 6846 +++++++++--------
hw/mcu/nordic/src/ext/nrfx/mdk/nrf51_peripherals.h | 1 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52805.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52805_erratas.h | 1427 ----
.../nordic/src/ext/nrfx/mdk/nrf52805_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52810.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52810_erratas.h | 1611 ----
.../nordic/src/ext/nrfx/mdk/nrf52810_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52811_erratas.h | 1481 ----
.../nordic/src/ext/nrfx/mdk/nrf52811_peripherals.h | 3 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52832_erratas.h | 4268 -----------
.../nordic/src/ext/nrfx/mdk/nrf52832_peripherals.h | 2 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52833.h | 14 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52833.svd | 112 +-
.../nordic/src/ext/nrfx/mdk/nrf52833_bitfields.h | 53 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52833_erratas.h | 1471 ----
.../nordic/src/ext/nrfx/mdk/nrf52833_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52840_erratas.h | 3239 --------
.../nordic/src/ext/nrfx/mdk/nrf52840_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf52_erratas.h | 7787 ++++++++++++++++++++
.../nordic/src/ext/nrfx/mdk/nrf5340_application.h | 129 +-
.../src/ext/nrfx/mdk/nrf5340_application.svd | 404 +-
.../ext/nrfx/mdk/nrf5340_application_bitfields.h | 96 +-
.../src/ext/nrfx/mdk/nrf5340_application_erratas.h | 801 --
.../ext/nrfx/mdk/nrf5340_application_peripherals.h | 53 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf5340_network.h | 51 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf5340_network.svd | 96 +-
.../src/ext/nrfx/mdk/nrf5340_network_bitfields.h | 74 +-
.../src/ext/nrfx/mdk/nrf5340_network_erratas.h | 619 --
.../src/ext/nrfx/mdk/nrf5340_network_peripherals.h | 4 +
hw/mcu/nordic/src/ext/nrfx/mdk/nrf53_erratas.h | 1609 ++++
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160.h | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf9160_erratas.h | 561 --
.../nordic/src/ext/nrfx/mdk/nrf9160_peripherals.h | 42 +-
hw/mcu/nordic/src/ext/nrfx/mdk/nrf91_erratas.h | 639 ++
hw/mcu/nordic/src/ext/nrfx/mdk/nrf_erratas.h | 67 +-
.../ext/nrfx/mdk/ses_startup_nrf5340_application.s | 32 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf51.c | 8 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52.c | 22 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52805.c | 10 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52810.c | 26 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52811.c | 14 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52833.c | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf52840.c | 14 +-
.../src/ext/nrfx/mdk/system_nrf5340_application.c | 42 +-
.../src/ext/nrfx/mdk/system_nrf5340_network.c | 6 +-
hw/mcu/nordic/src/ext/nrfx/mdk/system_nrf9160.c | 10 +-
hw/mcu/nordic/src/ext/nrfx/nrfx.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_atomic.c | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_atomic.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_atomic_internal.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_coredep.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf51.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52810.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52811.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52832.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52833.h | 2 +-
.../nordic/src/ext/nrfx/soc/nrfx_irqs_nrf52840.h | 2 +-
.../ext/nrfx/soc/nrfx_irqs_nrf5340_application.h | 42 +-
.../src/ext/nrfx/soc/nrfx_irqs_nrf5340_network.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/soc/nrfx_irqs_nrf9160.h | 2 +-
.../{soc/nrfx_irqs.h => templates/nrfx_config.h} | 28 +-
.../{nRF51/nrfx_config.h => nrfx_config_nrf51.h} | 101 +-
.../nrfx_config.h => nrfx_config_nrf52810.h} | 144 +-
.../nrfx_config.h => nrfx_config_nrf52811.h} | 144 +-
.../nrfx_config.h => nrfx_config_nrf52832.h} | 175 +-
.../nrfx_config.h => nrfx_config_nrf52833.h} | 183 +-
.../nrfx_config.h => nrfx_config_nrf52840.h} | 185 +-
..._config.h => nrfx_config_nrf5340_application.h} | 422 +-
...nrfx_config.h => nrfx_config_nrf5340_network.h} | 130 +-
.../nrfx_config.h => nrfx_config_nrf9160.h} | 163 +-
hw/mcu/nordic/src/ext/nrfx/templates/nrfx_glue.h | 2 +-
hw/mcu/nordic/src/ext/nrfx/templates/nrfx_log.h | 2 +-
237 files changed, 19554 insertions(+), 28389 deletions(-)
diff --git a/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md b/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md
index 7d7773f..f1fb6c6 100644
--- a/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md
+++ b/hw/mcu/nordic/src/ext/nrfx/CHANGELOG.md
@@ -1,6 +1,39 @@
# Changelog
All notable changes to this project are documented in this file.
+## [2.1.0] - 2020-01-24
+### Added
+- Added HALs for DCNF, OSCILLATORS, USBREG, and VREQCTRL.
+- Added support for 1-MHz clock frequency in TWIM.
+- Introduced the NRFX_I2S_STATUS_TRANSFER_STOPPED flag in the I2S driver.
+- Introduced the nrfx_power_compat layer that allows use of the nrfx_power API with new SoC.
+- Added encryption support in the QSPI driver.
+- Added support for USBD in nRF5340.
+- Expanded HALs to cover new functions in nRF5340: GPIO, I2S, PDM, POWER, QSPI, and REGULATORS.
+- Introduced new clock management system in the CLOCK driver.
+- Introduced new audio clock configuration settings in the I2S and PDM drivers for nRF5340.
+- Implemented workaround for nRF5340 anomaly 4 in the CLOCK driver.
+- Implemented workaround for nRF5340 anomaly 10 in the CCM HAL.
+- Implemented workaround for nRF9160 anomaly 21 and nRF5340 anomaly 6 in the NVMC HAL.
+- Implemented workaround for nRF9160 anomaly 23 and nRF5340 anomaly 44 in the UARTE driver.
+- Introduced the NRFX_TWIM_NO_SPURIOUS_STOP_CHECK flag in the TWIM driver.
+- Added functions for getting shortcut configuration in the TWIM HAL.
+
+### Changed
+- Updated MDK to 8.30.2.
+- Reorganized templates of nrfx_config header files for different SoCs. Now they are included through one common file according to the selected SoC.
+- Improved the UARTE driver to consume less current after the driver uninitialization. Now all clocks are disabled properly after uninitialization.
+- Improved the GPIOTE driver robustness by setting the LATCH functionality to be used by default.
+- Changed names of the frequency divider symbols in the QSPI HAL to reflect the new frequencies in nRF5340. Old API names were preserved and are still supported.
+- Improved spurious STOP condition handling in the TWIM driver.
+- Improved sampling procedure in the advanced blocking mode in the SAADC driver.
+- Improved calibration procedure in the SAADC driver for nRF5340 and nRF9160.
+
+### Fixed
+- Fixed address assertions in NVMC driver for the nRF5340 network core.
+- Fixed an issue in the TWI 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 the stopping procedure in the PWM driver. Previously in very specific circumstances the PWM output might be not stopped at all or might be immediately restarted.
+
## [2.0.0] - 2019-11-06
### Added
- Added support for nRF5340.
diff --git a/hw/mcu/nordic/src/ext/nrfx/LICENSE b/hw/mcu/nordic/src/ext/nrfx/LICENSE
index ed92c3b..94bd0a0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/LICENSE
+++ b/hw/mcu/nordic/src/ext/nrfx/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
All rights reserved.
Redistribution and use in source and binary forms, with or without
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 abb281a..3abb6ce 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 78ef700..453cb7a 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 4dbeb80..08cbee1 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,10 +50,12 @@ extern "C" {
/** @brief Clock events. */
typedef enum
{
- NRFX_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
- NRFX_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
- NRFX_CLOCK_EVT_CTTO, ///< Calibration timeout.
- NRFX_CLOCK_EVT_CAL_DONE ///< Calibration has been done.
+ NRFX_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
+ NRFX_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
+ NRFX_CLOCK_EVT_CTTO, ///< Calibration timeout.
+ NRFX_CLOCK_EVT_CAL_DONE, ///< Calibration has been done.
+ NRFX_CLOCK_EVT_HFCLKAUDIO_STARTED, ///< HFCLKAUDIO has been started.
+ NRFX_CLOCK_EVT_HFCLK192M_STARTED, ///< HFCLK192M has been started.
} nrfx_clock_evt_type_t;
/**
@@ -85,34 +87,137 @@ void nrfx_clock_disable(void);
/** @brief Function for uninitializing the clock module. */
void nrfx_clock_uninit(void);
-/** @brief Function for starting the LFCLK. */
-void nrfx_clock_lfclk_start(void);
+/**
+ * @brief Function for starting the specified clock domain.
+ *
+ * @param[in] domain Clock domain.
+ */
+void nrfx_clock_start(nrf_clock_domain_t domain);
+
+/**
+ * @brief Function for stopping the specified clock domain.
+ *
+ * @param[in] domain Clock domain.
+ */
+void nrfx_clock_stop(nrf_clock_domain_t domain);
+
+/**
+ * @brief Function for checking the specified clock domain state.
+ *
+ * XTAL source is assumed for domains with multiple sources.
+ *
+ * @param[in] domain Clock domain.
+ * @param[out] clk_src Clock source that is running. Set to NULL if not needed.
+ * Ignored for HFCLKAUDIO domain. Typecast it to @ref nrf_clock_lfclk_t for
+ * LFCLK and @ref nrf_clock_hfclk_t for HFCLK and HFCLK192M.
+ *
+ * @retval true The clock domain is running.
+ * @retval false The clock domain is not running.
+ */
+NRFX_STATIC_INLINE bool nrfx_clock_is_running(nrf_clock_domain_t domain, void * clk_src);
-/** @brief Function for stopping the LFCLK. */
-void nrfx_clock_lfclk_stop(void);
+#if NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK_192M
+/**
+ * @brief Function for setting the specified clock domain divider.
+ *
+ * @param[in] domain Clock domain.
+ * @param[in] div New divider for the clock domain.
+ *
+ * @retval NRFX_SUCCESS Divider successfully set.
+ * @retval NRFX_ERROR_NOT_SUPPORTED Domain does not support setting the divider.
+ * @retval NRFX_ERROR_INVALID_PARAM Divider not supported by the specified domain.
+ */
+nrfx_err_t nrfx_clock_divider_set(nrf_clock_domain_t domain,
+ nrf_clock_hfclk_div_t div);
+
+/**
+ * @brief Function for getting the specified clock domain divider.
+ *
+ * @param[in] domain Clock domain.
+ *
+ * @return Current divider for the specified clock domain.
+ */
+
+NRFX_STATIC_INLINE nrf_clock_hfclk_div_t nrfx_clock_divider_get(nrf_clock_domain_t domain);
+#endif
+
+/**
+ * @brief Function for starting the LFCLK.
+ *
+ * @note This function is deprecated. Use @ref nrfx_clock_start instead.
+ */
+NRFX_STATIC_INLINE void nrfx_clock_lfclk_start(void);
+
+/**
+ * @brief Function for stopping the LFCLK.
+ *
+ * @note This function is deprecated. Use @ref nrfx_clock_stop instead.
+ */
+NRFX_STATIC_INLINE void nrfx_clock_lfclk_stop(void);
/**
* @brief Function for checking the LFCLK state.
*
+ * @note This function is deprecated. Use @ref nrfx_clock_is_running instead.
+ *
* @retval true The LFCLK is running.
* @retval false The LFCLK is not running.
*/
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);
+/**
+ * @brief Function for starting the high-accuracy source HFCLK.
+ *
+ * @note This function is deprecated. Use @ref nrfx_clock_start instead.
+ */
+NRFX_STATIC_INLINE void nrfx_clock_hfclk_start(void);
-/** @brief Function for stopping the external high-accuracy source HFCLK. */
-void nrfx_clock_hfclk_stop(void);
+/**
+ * @brief Function for stopping the external high-accuracy source HFCLK.
+ *
+ * @note This function is deprecated. Use @ref nrfx_clock_stop instead.
+ */
+NRFX_STATIC_INLINE void nrfx_clock_hfclk_stop(void);
/**
* @brief Function for checking the HFCLK state.
*
+ * @note This function is deprecated. Use @ref nrfx_clock_is_running instead.
+ *
* @retval true The HFCLK is running (XTAL source).
* @retval false The HFCLK is not running.
*/
NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void);
+
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+/**
+ * @brief Function for setting the HFCLKAUDIO configuration.
+ *
+ * The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps.
+ * To calculate @p freq_value corresponding to the chosen frequency, use the following equation:
+ * FREQ_VALUE = 2^16 * ((12 * f_out / 32M) - 4)
+ *
+ * @warning Chosen frequency must fit in 11.176 MHz - 11.402 MHz or 12.165 MHz - 12.411 MHz
+ * frequency bands.
+ *
+ * @param[in] freq_value New FREQ_VALUE for HFCLKAUDIO.
+ */
+NRFX_STATIC_INLINE void nrfx_clock_hfclkaudio_config_set(uint16_t freq_value);
+
+/**
+ * @brief Function for getting the HFCLKAUDIO configuration.
+ *
+ * The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps.
+ * To calculate frequency corresponding to the returned FREQ_VALUE, use the following equation:
+ * f_out = 32M * (4 + FREQ_VALUE * 2^(-16))/12
+ *
+ * @return Current value of FREQ_VALUE for HFCLKAUDIO.
+ */
+NRFX_STATIC_INLINE uint16_t nrfx_clock_hfclkaudio_config_get(void);
+
+#endif
+
/**
* @brief Function for starting the calibration of internal LFCLK.
*
@@ -161,8 +266,48 @@ NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task);
*/
NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event);
-
#ifndef NRFX_DECLARE_ONLY
+
+#if NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK_192M
+NRFX_STATIC_INLINE nrf_clock_hfclk_div_t nrfx_clock_divider_get(nrf_clock_domain_t domain)
+{
+ switch (domain)
+ {
+#if NRF_CLOCK_HAS_HFCLK_DIV
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ return nrf_clock_hfclk_div_get(NRF_CLOCK);
+#endif
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ return nrf_clock_hfclk192m_div_get(NRF_CLOCK);
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return 0;
+ }
+}
+#endif // NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK_192M
+
+NRFX_STATIC_INLINE void nrfx_clock_lfclk_start(void)
+{
+ nrfx_clock_start(NRF_CLOCK_DOMAIN_LFCLK);
+}
+
+NRFX_STATIC_INLINE void nrfx_clock_lfclk_stop(void)
+{
+ nrfx_clock_stop(NRF_CLOCK_DOMAIN_LFCLK);
+}
+
+NRFX_STATIC_INLINE void nrfx_clock_hfclk_start(void)
+{
+ nrfx_clock_start(NRF_CLOCK_DOMAIN_HFCLK);
+}
+
+NRFX_STATIC_INLINE void nrfx_clock_hfclk_stop(void)
+{
+ nrfx_clock_stop(NRF_CLOCK_DOMAIN_HFCLK);
+}
+
NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_task_addr(nrf_clock_task_t task)
{
return nrf_clock_task_address_get(NRF_CLOCK, task);
@@ -173,15 +318,37 @@ NRFX_STATIC_INLINE uint32_t nrfx_clock_ppi_event_addr(nrf_clock_event_t event)
return nrf_clock_event_address_get(NRF_CLOCK, event);
}
+NRFX_STATIC_INLINE bool nrfx_clock_is_running(nrf_clock_domain_t domain, void * clk_src)
+{
+ return nrf_clock_is_running(NRF_CLOCK, domain, clk_src);
+}
+
NRFX_STATIC_INLINE bool nrfx_clock_hfclk_is_running(void)
{
- return nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY);
+ nrf_clock_hfclk_t clk_src;
+ bool ret = nrfx_clock_is_running(NRF_CLOCK_DOMAIN_HFCLK, &clk_src);
+ return (ret && (clk_src == NRF_CLOCK_HFCLK_HIGH_ACCURACY));
}
NRFX_STATIC_INLINE bool nrfx_clock_lfclk_is_running(void)
{
- return nrf_clock_lf_is_running(NRF_CLOCK);
+ return nrfx_clock_is_running(NRF_CLOCK_DOMAIN_LFCLK, NULL);
}
+
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+
+NRFX_STATIC_INLINE void nrfx_clock_hfclkaudio_config_set(uint16_t freq_value)
+{
+ nrf_clock_hfclkaudio_config_set(NRF_CLOCK, freq_value);
+}
+
+NRFX_STATIC_INLINE uint16_t nrfx_clock_hfclkaudio_config_get(void)
+{
+ return nrf_clock_hfclkaudio_config_get(NRF_CLOCK);
+}
+
+#endif
+
#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 7621f48..d42f901 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_dppi.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_dppi.h
index 84b1715..e7bc202 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_dppi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_dppi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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
index 1470778..686e526 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_egu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_egu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 ad1abec..10e57ea 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 0476a63..698a7d6 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,13 +69,17 @@ typedef struct
* if this signal is not needed. */
uint8_t irq_priority; ///< Interrupt priority.
- nrf_i2s_mode_t mode; ///< Mode of operation.
- nrf_i2s_format_t format; ///< Frame format.
- nrf_i2s_align_t alignment; ///< Alignment of sample within a frame.
- nrf_i2s_swidth_t sample_width; ///< Sample width.
- nrf_i2s_channels_t channels; ///< Enabled channels.
- nrf_i2s_mck_t mck_setup; ///< Master clock setup.
- nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio.
+ nrf_i2s_mode_t mode; ///< Mode of operation.
+ nrf_i2s_format_t format; ///< Frame format.
+ nrf_i2s_align_t alignment; ///< Alignment of sample within a frame.
+ nrf_i2s_swidth_t sample_width; ///< Sample width.
+ nrf_i2s_channels_t channels; ///< Enabled channels.
+ nrf_i2s_mck_t mck_setup; ///< Master clock setup.
+ nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio.
+#if NRF_I2S_HAS_CLKCONFIG
+ nrf_i2s_clksrc_t clksrc; ///< Clock source selection.
+ bool enable_bypass; ///< Bypass clock generator. MCK will be equal to source input.
+#endif
} nrfx_i2s_config_t;
/** @brief I2S driver buffers structure. */
@@ -85,6 +89,14 @@ typedef struct
uint32_t const * p_tx_buffer; ///< Pointer to the buffer with data to be sent.
} nrfx_i2s_buffers_t;
+#if NRF_I2S_HAS_CLKCONFIG || defined(__NRFX_DOXYGEN__)
+ /** @brief I2S additional clock source configuration. */
+ #define NRF_I2S_DEFAULT_EXTENDED_CLKSRC_CONFIG \
+ .clksrc = NRF_I2S_CLKSRC_PCLK32M, \
+ .enable_bypass = false,
+#else
+ #define NRF_I2S_DEFAULT_EXTENDED_CLKSRC_CONFIG
+#endif
/**
* @brief I2S driver default configuration.
*
@@ -118,15 +130,20 @@ typedef struct
.channels = NRF_I2S_CHANNELS_LEFT, \
.mck_setup = NRF_I2S_MCK_32MDIV8, \
.ratio = NRF_I2S_RATIO_32X, \
+ NRF_I2S_DEFAULT_EXTENDED_CLKSRC_CONFIG \
}
-#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
+#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
* be done before the currently used buffers are completely processed
* (that is, the time remaining for supplying the next buffers depends on
* the used size of the buffers). */
+#define NRFX_I2S_STATUS_TRANSFER_STOPPED (1UL << 1)
+ /**< The I2S peripheral has been stopped and all buffers that were passed
+ * to the driver have been released. */
+
/**
* @brief I2S driver data handler type.
*
@@ -155,14 +172,22 @@ typedef struct
* Both pointers in this structure are NULL when the
* handler is called for the first time after a transfer
* is started, because no data has been transferred yet
- * at this point. In all successive calls the pointers
+ * at this point. In all successive calls, the pointers
* specify what has been sent (TX) and what has been
- * received (RX) in the part of transfer that has just
- * been completed (provided that a given direction is
- * enabled, see @ref nrfx_i2s_start).
+ * received (RX) in the part of the transfer that has
+ * just been completed (provided that a given direction
+ * is enabled, see @ref nrfx_i2s_start).
+ * @note Since the peripheral is stopped asynchronously,
+ * buffers that are released after the call to
+ * @ref nrfx_i2s_stop are not used entirely.
+ * In this case, only a part (if any) of the TX
+ * buffer has been actually transmitted and only
+ * a part (if any) of the RX buffer is filled with
+ * received data.
* @param[in] status Bit field describing the current status of the transfer.
* It can be 0 or a combination of the following flags:
* - @ref NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED
+ * - @ref NRFX_I2S_STATUS_TRANSFER_STOPPED
*/
typedef void (* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const * p_released,
uint32_t status);
@@ -198,7 +223,7 @@ void nrfx_i2s_uninit(void);
* word can either contain four 8-bit samples, two 16-bit samples, or one
* right-aligned 24-bit sample sign-extended to a 32-bit value.
* For a detailed memory mapping for different supported configurations,
- * see the @linkProductSpecification52.
+ * see the Product Specification.
*
* @note Peripherals using EasyDMA (including I2S) require the transfer buffers
* to be placed in the Data RAM region. If this condition is not met,
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
index fb4abab..d6331a2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_ipc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 03a8370..fa5757f 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ typedef struct
*
* @param[in] _input Comparator input pin.
*/
-#ifdef NRF52_SERIES
+#if defined(LPCOMP_FEATURE_HYST_PRESENT)
#define NRFX_LPCOMP_DEFAULT_CONFIG(_input) \
{ \
.hal = { NRF_LPCOMP_REF_SUPPLY_4_8, \
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 963a935..4d8bea0 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 2a030e5..cfea373 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 246c0d6..3396273 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,16 +67,39 @@ typedef struct
/** @brief PDM interface driver configuration structure. */
typedef struct
{
- nrf_pdm_mode_t mode; ///< Interface operation mode.
- nrf_pdm_edge_t edge; ///< Sampling mode.
- uint8_t pin_clk; ///< CLK pin.
- uint8_t pin_din; ///< DIN pin.
- nrf_pdm_freq_t clock_freq; ///< Clock frequency.
- nrf_pdm_gain_t gain_l; ///< Left channel gain.
- nrf_pdm_gain_t gain_r; ///< Right channel gain.
- uint8_t interrupt_priority; ///< Interrupt priority.
+ nrf_pdm_mode_t mode; ///< Interface operation mode.
+ nrf_pdm_edge_t edge; ///< Sampling mode.
+ uint8_t pin_clk; ///< CLK pin.
+ uint8_t pin_din; ///< DIN pin.
+ nrf_pdm_freq_t clock_freq; ///< Clock frequency.
+ nrf_pdm_gain_t gain_l; ///< Left channel gain.
+ nrf_pdm_gain_t gain_r; ///< Right channel gain.
+ uint8_t interrupt_priority; ///< Interrupt priority.
+#if NRF_PDM_HAS_RATIO_CONFIG
+ nrf_pdm_ratio_t ratio; ///< Ratio between PDM_CLK and output sample rate.
+#endif
+#if NRF_PDM_HAS_MCLKCONFIG
+ nrf_pdm_mclksrc_t mclksrc; ///< Master clock source selection.
+#endif
} nrfx_pdm_config_t;
+
+#if NRF_PDM_HAS_RATIO_CONFIG || defined(__NRFX_DOXYGEN__)
+ /** @brief PDM additional ratio configuration. */
+ #define NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG \
+ .ratio = NRF_PDM_RATIO_64X,
+#else
+ #define NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG
+#endif
+
+#if NRF_PDM_HAS_MCLKCONFIG || defined(__NRFX_DOXYGEN__)
+ /** @brief PDM additional master clock source configuration. */
+ #define NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG \
+ .mclksrc = NRF_PDM_MCLKSRC_PCLK32M,
+#else
+ #define NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG
+#endif
+
/**
* @brief PDM driver default configuration.
*
@@ -98,7 +121,9 @@ typedef struct
.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 \
+ .interrupt_priority = NRFX_PDM_DEFAULT_CONFIG_IRQ_PRIORITY, \
+ NRFX_PDM_DEFAULT_EXTENDED_RATIO_CONFIG \
+ NRFX_PDM_DEFAULT_EXTENDED_MCLKSRC_CONFIG \
}
/**
@@ -187,12 +212,12 @@ 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);
+ return nrf_pdm_task_address_get(NRF_PDM0, task);
}
NRFX_STATIC_INLINE bool nrfx_pdm_enable_check(void)
{
- return nrf_pdm_enable_check(NRF_PDM);
+ return nrf_pdm_enable_check(NRF_PDM0);
}
#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 2220fd6..d1136e5 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@
#include <nrfx.h>
#include <hal/nrf_power.h>
#include <nrfx_power_clock.h>
+#include "nrfx_power_compat.h"
#ifdef __cplusplus
extern "C" {
@@ -47,6 +48,29 @@ extern "C" {
* @brief POWER peripheral driver.
*/
+#if NRF_POWER_HAS_POFCON || NRFX_CHECK(NRF_REGULATORS_HAS_POFCON) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether the power failure comparator is supported. */
+#define NRFX_POWER_SUPPORTS_POFCON 1
+#else
+#define NRFX_POWER_SUPPORTS_POFCON 0
+#endif
+
+#if NRF_POWER_HAS_POFCON_VDDH || NRFX_CHECK(NRF_REGULATORS_HAS_POFCON_VDDH) || \
+ defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether the power failure comparator for VDDH is supported. */
+#define NRFX_POWER_SUPPORTS_POFCON_VDDH 1
+#else
+#define NRFX_POWER_SUPPORTS_POFCON_VDDH 0
+#endif
+
+#if NRF_POWER_HAS_DCDCEN_VDDH || NRFX_CHECK(NRF_REGULATORS_HAS_DCDCEN_VDDH) || \
+ defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether the VDDH regulator is supported. */
+#define NRFX_POWER_SUPPORTS_DCDCEN_VDDH 1
+#else
+#define NRFX_POWER_SUPPORTS_DCDCEN_VDDH 0
+#endif
+
/**
* @brief Power mode possible configurations
*/
@@ -96,7 +120,7 @@ typedef enum
NRFX_POWER_USB_STATE_CONNECTED, /**< The USB power is detected, but USB power regulator is not ready. */
NRFX_POWER_USB_STATE_READY /**< From the power viewpoint, USB is ready for working. */
}nrfx_power_usb_state_t;
-#endif /* NRF_POWER_HAS_USBREG */
+#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
/**
* @name Callback types
@@ -145,7 +169,7 @@ typedef struct
*/
bool dcdcen:1;
-#if NRF_POWER_HAS_VDDH || defined(__NRFX_DOXYGEN__)
+#if NRFX_POWER_SUPPORTS_DCDCEN_VDDH
/**
* @brief Enable HV DCDC regulator.
*
@@ -166,10 +190,10 @@ typedef struct
typedef struct
{
nrfx_power_pofwarn_event_handler_t handler; //!< Event handler.
-#if NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
+#if NRFX_POWER_SUPPORTS_POFCON
nrf_power_pof_thr_t thr; //!< Threshold for power failure detection
#endif
-#if NRF_POWER_HAS_VDDH || defined(__NRFX_DOXYGEN__)
+#if NRFX_POWER_SUPPORTS_POFCON_VDDH
nrf_power_pof_thrvddh_t thrvddh; //!< Threshold for power failure detection on the VDDH pin.
#endif
}nrfx_power_pofwarn_config_t;
@@ -198,7 +222,7 @@ typedef struct
{
nrfx_power_usb_event_handler_t handler; //!< Event processing.
}nrfx_power_usbevt_config_t;
-#endif /* NRF_POWER_HAS_USBREG */
+#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
/**
* @brief Function for getting the handler of the power failure comparator.
@@ -212,7 +236,7 @@ nrfx_power_pofwarn_event_handler_t nrfx_power_pof_handler_get(void);
* @return Handler of the USB power.
*/
nrfx_power_usb_event_handler_t nrfx_power_usb_handler_get(void);
-#endif
+#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
/**
* @brief Function for initializing the power module driver.
@@ -235,7 +259,7 @@ nrfx_err_t nrfx_power_init(nrfx_power_config_t const * p_config);
*/
void nrfx_power_uninit(void);
-#if NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
+#if NRFX_POWER_SUPPORTS_POFCON
/**
* @brief Function for initializing the power failure comparator.
*
@@ -271,7 +295,7 @@ void nrfx_power_pof_disable(void);
* Clears the settings of the power failure comparator.
*/
void nrfx_power_pof_uninit(void);
-#endif // NRF_POWER_HAS_POFCON || defined(__NRFX_DOXYGEN__)
+#endif // NRFX_POWER_SUPPORTS_POFCON
#if NRF_POWER_HAS_SLEEPEVT || defined(__NRFX_DOXYGEN__)
/**
@@ -336,7 +360,7 @@ void nrfx_power_usbevt_uninit(void);
*/
NRFX_STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void);
-#endif /* NRF_POWER_HAS_USBREG */
+#endif // NRF_POWER_HAS_USBREG || defined(__NRFX_DOXYGEN__)
#ifndef NRFX_DECLARE_ONLY
#if NRF_POWER_HAS_USBREG
@@ -353,8 +377,8 @@ NRFX_STATIC_INLINE nrfx_power_usb_state_t nrfx_power_usbstatus_get(void)
}
return NRFX_POWER_USB_STATE_READY;
}
-#endif /* NRF_POWER_HAS_USBREG */
-#endif /* NRFX_DECLARE_ONLY */
+#endif // NRF_POWER_HAS_USBREG
+#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 c1af4bd..50b4603 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_compat.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_compat.h
new file mode 100644
index 0000000..508a03f
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_power_compat.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 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_POWER_COMPAT_H__
+#define NRFX_POWER_COMPAT_H__
+
+/**
+ * POWER compatibility layer.
+ *
+ * The following definitions allow using of common code involving the POWER peripheral
+ * driver for different SoCs, regardless of whether certain regulator registers
+ * are located in the POWER peripheral or in separate peripherals like USBREG and REGULATORS.
+ */
+
+#if defined(REGULATORS_PRESENT)
+#include <hal/nrf_regulators.h>
+#endif
+
+#if NRF_REGULATORS_HAS_POFCON
+
+typedef nrf_regulators_pof_thr_t nrf_power_pof_thr_t;
+#define NRF_POWER_POFTHR_V19 NRF_REGULATORS_POFTHR_V19
+#define NRF_POWER_POFTHR_V20 NRF_REGULATORS_POFTHR_V20
+#define NRF_POWER_POFTHR_V21 NRF_REGULATORS_POFTHR_V21
+#define NRF_POWER_POFTHR_V22 NRF_REGULATORS_POFTHR_V22
+#define NRF_POWER_POFTHR_V23 NRF_REGULATORS_POFTHR_V23
+#define NRF_POWER_POFTHR_V24 NRF_REGULATORS_POFTHR_V24
+#define NRF_POWER_POFTHR_V25 NRF_REGULATORS_POFTHR_V25
+#define NRF_POWER_POFTHR_V26 NRF_REGULATORS_POFTHR_V26
+#define NRF_POWER_POFTHR_V27 NRF_REGULATORS_POFTHR_V27
+#define NRF_POWER_POFTHR_V28 NRF_REGULATORS_POFTHR_V28
+
+typedef nrf_regulators_pof_thrvddh_t nrf_power_pof_thrvddh_t;
+#define NRF_POWER_POFTHRVDDH_V27 NRF_REGULATORS_POFTHRVDDH_V27
+#define NRF_POWER_POFTHRVDDH_V28 NRF_REGULATORS_POFTHRVDDH_V28
+#define NRF_POWER_POFTHRVDDH_V29 NRF_REGULATORS_POFTHRVDDH_V29
+#define NRF_POWER_POFTHRVDDH_V30 NRF_REGULATORS_POFTHRVDDH_V30
+#define NRF_POWER_POFTHRVDDH_V31 NRF_REGULATORS_POFTHRVDDH_V31
+#define NRF_POWER_POFTHRVDDH_V32 NRF_REGULATORS_POFTHRVDDH_V32
+#define NRF_POWER_POFTHRVDDH_V33 NRF_REGULATORS_POFTHRVDDH_V33
+#define NRF_POWER_POFTHRVDDH_V34 NRF_REGULATORS_POFTHRVDDH_V34
+#define NRF_POWER_POFTHRVDDH_V35 NRF_REGULATORS_POFTHRVDDH_V35
+#define NRF_POWER_POFTHRVDDH_V36 NRF_REGULATORS_POFTHRVDDH_V36
+#define NRF_POWER_POFTHRVDDH_V37 NRF_REGULATORS_POFTHRVDDH_V37
+#define NRF_POWER_POFTHRVDDH_V38 NRF_REGULATORS_POFTHRVDDH_V38
+#define NRF_POWER_POFTHRVDDH_V39 NRF_REGULATORS_POFTHRVDDH_V39
+#define NRF_POWER_POFTHRVDDH_V40 NRF_REGULATORS_POFTHRVDDH_V40
+#define NRF_POWER_POFTHRVDDH_V41 NRF_REGULATORS_POFTHRVDDH_V41
+#define NRF_POWER_POFTHRVDDH_V42 NRF_REGULATORS_POFTHRVDDH_V42
+
+#endif // NRF_REGULATORS_HAS_POFCON
+
+#if defined(USBREG_PRESENT)
+#include "nrfx_usbreg.h"
+
+typedef nrfx_usbreg_event_handler_t nrfx_power_usb_event_handler_t;
+typedef nrfx_usbreg_config_t nrfx_power_usbevt_config_t;
+
+typedef nrfx_usbreg_evt_t nrfx_power_usb_evt_t;
+#define NRFX_POWER_USB_EVT_DETECTED NRFX_USBREG_EVT_DETECTED
+#define NRFX_POWER_USB_EVT_REMOVED NRFX_USBREG_EVT_REMOVED
+#define NRFX_POWER_USB_EVT_READY NRFX_USBREG_EVT_READY
+
+typedef nrfx_usbreg_state_t nrfx_power_usb_state_t;
+#define NRFX_POWER_USB_STATE_DISCONNECTED NRFX_USBREG_STATE_DISCONNECTED
+#define NRFX_POWER_USB_STATE_CONNECTED NRFX_USBREG_STATE_CONNECTED
+#define NRFX_POWER_USB_STATE_READY NRFX_USBREG_STATE_READY
+
+#define nrfx_power_usb_handler_get nrfx_usbreg_handler_get
+#define nrfx_power_usbevt_init nrfx_usbreg_init
+#define nrfx_power_usbevt_enable nrfx_usbreg_enable
+#define nrfx_power_usbevt_disable nrfx_usbreg_disable
+#define nrfx_power_usbevt_uninit nrfx_usbreg_uninit
+#define nrfx_power_usbstatus_get nrfx_usbreg_usbstatus_get
+
+#endif // defined(USBREG_PRESENT)
+
+#endif // NRFX_POWER_COMPAT_H__
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 0696249..42693bf 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 b3d4a49..a48124e 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -100,6 +100,10 @@ typedef struct
uint16_t top_value; ///< Value up to which the pulse generator counter counts.
nrf_pwm_dec_load_t load_mode; ///< Mode of loading sequence data from RAM.
nrf_pwm_dec_step_t step_mode; ///< Mode of advancing the active sequence.
+ bool skip_gpio_cfg; ///< Skip the GPIO configuration
+ /**< When this flag is set, the user is responsible for
+ * providing the proper configuration of the output pins,
+ * as the driver does not touch it at all. */
} nrfx_pwm_config_t;
/**
@@ -117,19 +121,20 @@ typedef struct
* @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, \
+#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, \
+ .skip_gpio_cfg = false \
}
/** @brief PWM flags providing additional playback options. */
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 0591e73..0ac342f 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 f435738..fb48d0d 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,7 +66,7 @@ typedef struct
* - PP opcode for writing
* - 24 bit addressing mode
* - Deep Power-down disabled
- * - clock frequency 2 MHz
+ * - clock frequency: 2 MHz for nRF52 Series, 6 MHz for nRF53 Series
* - 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')
*
@@ -99,7 +99,7 @@ typedef struct
.sck_delay = 0x05, \
.dpmen = false, \
.spi_mode = NRF_QSPI_MODE_0, \
- .sck_freq = NRF_QSPI_FREQ_32MDIV16, \
+ .sck_freq = NRF_QSPI_FREQ_DIV16, \
}, \
.irq_priority = (uint8_t)NRFX_QSPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
}
@@ -329,6 +329,32 @@ nrfx_err_t nrfx_qspi_lfm_xfer(void const * p_tx_buffer,
size_t transfer_length,
bool finalize);
+#if NRF_QSPI_HAS_XIP_ENC
+/**
+ * @brief Function for setting the XIP encryption.
+ *
+ * @param[in] p_config XIP encryption configuration structure.
+ * To disable encryption, pass NULL pointer as argument.
+ *
+ * @retval NRFX_SUCCESS Operation was successful.
+ * @retval NRFX_ERROR_BUSY Driver currently handles other operation.
+ */
+nrfx_err_t nrfx_qspi_xip_encrypt(nrf_qspi_encryption_t const * p_config);
+#endif
+
+#if NRF_QSPI_HAS_DMA_ENC
+/**
+ * @brief Function for setting the EasyDMA encryption.
+ *
+ * @param[in] p_config DMA encryption configuration structure.
+ * To disable encryption, pass NULL pointer as argument.
+ *
+ * @retval NRFX_SUCCESS Operation was successful.
+ * @retval NRFX_ERROR_BUSY Driver currently handles other operation.
+ */
+nrfx_err_t nrfx_qspi_dma_encrypt(nrf_qspi_encryption_t const * p_config);
+#endif
+
/** @} */
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 cd88f7d..ed9c70c 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 b641a89..93cabe3 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 82f7d03..bf1f78f 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 3dea9f0..80fab90 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,7 @@ typedef struct
* - clock frequency 4 MHz
* - mode 0 enabled (SCK active high, sample on leading edge of clock)
* - MSB shifted out first
+ * - MISO pull-up disabled
*
* @param[in] _pin_sck SCK pin.
* @param[in] _pin_mosi MOSI pin.
@@ -133,6 +134,7 @@ typedef struct
.frequency = NRF_SPI_FREQ_4M, \
.mode = NRF_SPI_MODE_0, \
.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST, \
+ .miso_pull = NRF_GPIO_PIN_NOPULL, \
}
/** @brief Single transfer descriptor structure. */
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 5c22db3..339ab4c 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -68,6 +68,9 @@ enum {
#if NRFX_CHECK(NRFX_SPIM3_ENABLED)
NRFX_SPIM3_INST_IDX,
#endif
+#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
+ NRFX_SPIM4_INST_IDX,
+#endif
NRFX_SPIM_ENABLED_COUNT
};
#endif
@@ -391,6 +394,7 @@ void nrfx_spim_0_irq_handler(void);
void nrfx_spim_1_irq_handler(void);
void nrfx_spim_2_irq_handler(void);
void nrfx_spim_3_irq_handler(void);
+void nrfx_spim_4_irq_handler(void);
#ifdef __cplusplus
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 442901f..9c92503 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_systick.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_systick.h
index 5e8feda..0d1b9e1 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_systick.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_systick.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 95ac547..17d962f 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 9da6b5c..3fcbbbb 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 ca1bd5a..3595a6e 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -117,7 +117,8 @@ 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_OVERRUN ///< Error event: The unread data is replaced by new data.
+ NRFX_TWI_EVT_OVERRUN, ///< Error event: The unread data is replaced by new data.
+ NRFX_TWI_EVT_BUS_ERROR ///< Error event: An unexpected transition occurred on the bus.
} nrfx_twi_evt_type_t;
/** @brief TWI master driver transfer types. */
@@ -265,7 +266,7 @@ void nrfx_twi_disable(nrfx_twi_t const * p_instance);
* @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 error is detected by hardware.
+ * @retval NRFX_ERROR_INTERNAL An unexpected transition occurred on the bus.
* @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 Negative acknowledgement (NACK) is received after sending
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h
index 1c6ebcd..1f62c62 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_twi_twim.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 78bc802..94ba080 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -109,17 +109,19 @@ typedef struct
}
/** @brief Flag indicating that TX buffer address will be incremented after the transfer. */
-#define NRFX_TWIM_FLAG_TX_POSTINC (1UL << 0)
+#define NRFX_TWIM_FLAG_TX_POSTINC (1UL << 0)
/** @brief Flag indicating that RX buffer address will be incremented after the transfer. */
-#define NRFX_TWIM_FLAG_RX_POSTINC (1UL << 1)
+#define NRFX_TWIM_FLAG_RX_POSTINC (1UL << 1)
/** @brief Flag indicating that the interrupt after each transfer will be suppressed, and the event handler will not be called. */
-#define NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER (1UL << 2)
+#define NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER (1UL << 2)
/** @brief Flag indicating that the transfer will be set up, but not started. */
-#define NRFX_TWIM_FLAG_HOLD_XFER (1UL << 3)
+#define NRFX_TWIM_FLAG_HOLD_XFER (1UL << 3)
/** @brief Flag indicating that the transfer will be executed multiple times. */
-#define NRFX_TWIM_FLAG_REPEATED_XFER (1UL << 4)
+#define NRFX_TWIM_FLAG_REPEATED_XFER (1UL << 4)
/** @brief Flag indicating that the TX transfer will not end with a stop condition. */
-#define NRFX_TWIM_FLAG_TX_NO_STOP (1UL << 5)
+#define NRFX_TWIM_FLAG_TX_NO_STOP (1UL << 5)
+/** @brief Flag indicating that checks for spurious STOP condition will not be performed. */
+#define NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK (1UL << 6)
/** @brief TWI master driver event types. */
typedef enum
@@ -272,6 +274,10 @@ void nrfx_twim_disable(nrfx_twim_t const * p_instance);
* the driver does not set the driver instance into busy state, so you must ensure that the next transfers are set up
* when TWIM is not active.
* - @ref NRFX_TWIM_FLAG_TX_NO_STOP - No stop condition after the TX transfer.
+ * - @ref NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK - Checks for spurious STOP conditions are disabled.
+ * Used together with @ref NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER can result in lower power consumption
+ * when transfers are triggered externally and CPU is sleeping.
+ * Use only with I2C standard-compliant slave devices.
*
* @note
* Some flag combinations are invalid:
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 cf6833f..9fe599c 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 8f2105a..5cd19be 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 48945fa..bfba1f8 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 1069df4..a8e36c6 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbreg.h b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbreg.h
new file mode 100644
index 0000000..a9a67d0
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/include/nrfx_usbreg.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 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_USBREG_H__
+#define NRFX_USBREG_H__
+
+#include <nrfx.h>
+#include <hal/nrf_usbreg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup nrfx_usbreg USBREG driver
+ * @{
+ * @ingroup nrf_usbd
+ * @ingroup nrf_power
+ * @brief USB regulators (USBREG) peripheral driver.
+ */
+
+/** @brief Events from USB power system */
+typedef enum {
+ NRFX_USBREG_EVT_DETECTED, /**< USB power detected on the connector (plugged in). */
+ NRFX_USBREG_EVT_REMOVED, /**< USB power removed from the connector. */
+ NRFX_USBREG_EVT_READY /**< USB power regulator ready. */
+} nrfx_usbreg_evt_t;
+
+/**
+ * @brief USB power state
+ *
+ * The single enumerator that holds all data about current state of USB
+ * related POWER.
+ *
+ * Organized this way that higher power state has higher numeric value
+ */
+typedef enum {
+ NRFX_USBREG_STATE_DISCONNECTED, /**< No power on USB lines detected. */
+ NRFX_USBREG_STATE_CONNECTED, /**< The USB power is detected, but USB power regulator is not ready. */
+ NRFX_USBREG_STATE_READY /**< From the power viewpoint, USB is ready for working. */
+} nrfx_usbreg_state_t;
+
+/**
+ * @brief Event handler for the USB-related power events.
+ *
+ * @param event Event type
+ */
+typedef void (*nrfx_usbreg_event_handler_t)(nrfx_usbreg_evt_t event);
+
+/**
+ * @brief The configuration of the USB-related power events.
+ *
+ * Configuration used to enable and configure USB power event handling.
+ */
+typedef struct
+{
+ nrfx_usbreg_event_handler_t handler; //!< Event processing.
+ uint8_t irq_priority; //!< Priority of the USBREG interrupt.
+} nrfx_usbreg_config_t;
+
+/**
+ * @brief Function for getting the USBREG handler.
+ *
+ * @return Handler of the USB power.
+ */
+nrfx_usbreg_event_handler_t nrfx_usbreg_handler_get(void);
+
+/**
+ * @brief Function for initializing the processing of USBREG events.
+ *
+ * Configures and sets up the USB power event processing.
+ *
+ * @param[in] p_config Configuration structure. Must not be NULL.
+ *
+ * @sa nrfx_usbreg_uninit
+ */
+void nrfx_usbreg_init(nrfx_usbreg_config_t const *p_config);
+
+/** @brief Function for enabling the processing of USBREG events. */
+void nrfx_usbreg_enable(void);
+
+/** @brief Function for disabling the processing of USBREG events. */
+void nrfx_usbreg_disable(void);
+
+/**
+ * @brief Function for uninitalizing the processing of USBREG events.
+ *
+ * @sa nrfx_usbreg_init
+ */
+void nrfx_usbreg_uninit(void);
+
+/**
+ * @brief Function for getting the status of USBREG.
+ *
+ * @return Current USB power status.
+ */
+NRFX_STATIC_INLINE nrfx_usbreg_state_t nrfx_usbreg_usbstatus_get(void);
+
+#ifndef NRFX_DECLARE_ONLY
+NRFX_STATIC_INLINE nrfx_usbreg_state_t nrfx_usbreg_usbstatus_get(void)
+{
+ uint32_t status = nrf_usbreg_status_get(NRF_USBREGULATOR);
+ if (0 == (status & NRF_USBREG_STATUS_VBUSDETECT_MASK))
+ {
+ return NRFX_USBREG_STATE_DISCONNECTED;
+ }
+ if (0 == (status & NRF_USBREG_STATUS_OUTPUTRDY_MASK))
+ {
+ return NRFX_USBREG_STATE_CONNECTED;
+ }
+ return NRFX_USBREG_STATE_READY;
+}
+#endif // NRFX_DECLARE_ONLY
+
+/** @} */
+
+void nrfx_usbreg_irq_handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NRFX_USBREG_H__
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 fc46857..9866c29 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,10 +39,6 @@
extern "C" {
#endif
-#ifndef NRF_WDT0
-#define NRF_WDT0 NRF_WDT
-#endif
-
/**
* @defgroup nrfx_wdt WDT driver
* @{
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 320fb29..50ce150 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_common.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_errors.h b/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_errors.h
index 35645fa..be360f7 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_errors.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/nrfx_errors.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 6dfe7c8..fbcc9b8 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 4659421..593201f 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
#if NRFX_CHECK(NRFX_CLOCK_ENABLED)
#include <nrfx_clock.h>
+#include <nrf_erratas.h>
#define NRFX_LOG_MODULE CLOCK
#include <nrfx_log.h>
@@ -42,13 +43,6 @@
extern bool nrfx_power_irq_enabled;
#endif
-#define EVT_TO_STR(event) \
- (event == NRF_CLOCK_EVENT_HFCLKSTARTED ? "NRF_CLOCK_EVENT_HFCLKSTARTED" : \
- (event == NRF_CLOCK_EVENT_LFCLKSTARTED ? "NRF_CLOCK_EVENT_LFCLKSTARTED" : \
- (event == NRF_CLOCK_EVENT_DONE ? "NRF_CLOCK_EVENT_DONE" : \
- (event == NRF_CLOCK_EVENT_CTTO ? "NRF_CLOCK_EVENT_CTTO" : \
- "UNKNOWN EVENT"))))
-
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
#if (NRF_CLOCK_HAS_CALIBRATION == 0)
#error "Calibration is not available in the SoC that is used."
@@ -180,7 +174,12 @@ void nrfx_clock_enable(void)
NRFX_ASSERT(m_clock_cb.module_initialized);
nrfx_power_clock_irq_init();
nrf_clock_lf_src_set(NRF_CLOCK, (nrf_clock_lfclk_t)NRFX_CLOCK_CONFIG_LF_SRC);
-
+#if NRF_CLOCK_HAS_HFCLKSRC
+ nrf_clock_hf_src_set(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY);
+#endif
+#if NRF_CLOCK_HAS_HFCLK192M
+ nrf_clock_hfclk192m_src_set(NRF_CLOCK, (nrf_clock_hfclk_t)NRFX_CLOCK_CONFIG_HFCLK192M_SRC);
+#endif
#if NRFX_CHECK(NRFX_POWER_ENABLED)
nrfx_clock_irq_enabled = true;
#endif
@@ -202,8 +201,10 @@ void nrfx_clock_disable(void)
CLOCK_INTENSET_LFCLKSTARTED_Msk |
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
CLOCK_INTENSET_DONE_Msk |
+#if NRF_HAS_CALIBRATION_TIMER
CLOCK_INTENSET_CTTO_Msk |
#endif
+#endif // NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
0);
#if NRFX_CHECK(NRFX_POWER_ENABLED)
nrfx_clock_irq_enabled = false;
@@ -214,49 +215,97 @@ void nrfx_clock_disable(void)
void nrfx_clock_uninit(void)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- nrfx_clock_lfclk_stop();
- nrfx_clock_hfclk_stop();
+ nrfx_clock_stop(NRF_CLOCK_DOMAIN_LFCLK);
+ nrfx_clock_stop(NRF_CLOCK_DOMAIN_HFCLK);
+#if NRF_CLOCK_HAS_HFCLK192M
+ nrfx_clock_stop(NRF_CLOCK_DOMAIN_HFCLK192M);
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ nrfx_clock_stop(NRF_CLOCK_DOMAIN_HFCLKAUDIO);
+#endif
m_clock_cb.module_initialized = false;
NRFX_LOG_INFO("Uninitialized.");
}
-void nrfx_clock_lfclk_start(void)
+void nrfx_clock_start(nrf_clock_domain_t domain)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_LFCLKSTARTED);
- nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_LF_STARTED_MASK);
-
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ 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();
+ nrfx_clock_anomaly_132();
#endif
-
- 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, 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, 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);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART);
+ break;
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ 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);
+ break;
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLK192MSTARTED);
+ nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_HF192M_STARTED_MASK);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLK192MSTART);
+ break;
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKAUDIOSTARTED);
+ nrf_clock_int_enable(NRF_CLOCK, NRF_CLOCK_INT_HFAUDIO_STARTED_MASK);
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKAUDIOSTART);
+ break;
+#endif
+ default:
+ NRFX_ASSERT(0);
+ break;
+ }
}
-void nrfx_clock_hfclk_stop(void)
+void nrfx_clock_stop(nrf_clock_domain_t domain)
{
NRFX_ASSERT(m_clock_cb.module_initialized);
- nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
- while (nrf_clock_hf_is_running(NRF_CLOCK, NRF_CLOCK_HFCLK_HIGH_ACCURACY))
- {}
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTOP);
+ break;
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
+ break;
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLK192MSTOP);
+ break;
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKAUDIOSTOP);
+ break;
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return;
+ }
+ if (domain == NRF_CLOCK_DOMAIN_HFCLK)
+ {
+ nrf_clock_hfclk_t clk_src = NRF_CLOCK_HFCLK_HIGH_ACCURACY;
+ while (nrfx_clock_is_running(domain, &clk_src) && (clk_src == NRF_CLOCK_HFCLK_HIGH_ACCURACY))
+ {}
+ }
+ else
+ {
+ while (nrfx_clock_is_running(domain, NULL))
+ {}
+ }
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_201)
- m_clock_cb.hfclk_started = false;
+ if (domain == NRF_CLOCK_DOMAIN_HFCLK)
+ {
+ m_clock_cb.hfclk_started = false;
+ }
#endif
}
@@ -265,12 +314,18 @@ nrfx_err_t nrfx_clock_calibration_start(void)
nrfx_err_t err_code = NRFX_SUCCESS;
#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
- if (nrfx_clock_hfclk_is_running() == false)
+ nrf_clock_hfclk_t clk_src;
+ if (!nrfx_clock_is_running(NRF_CLOCK_DOMAIN_HFCLK, &clk_src))
+ {
+ return NRFX_ERROR_INVALID_STATE;
+ }
+
+ if (clk_src != NRF_CLOCK_HFCLK_HIGH_ACCURACY)
{
return NRFX_ERROR_INVALID_STATE;
}
- if (nrfx_clock_lfclk_is_running() == false)
+ if (!nrfx_clock_is_running(NRF_CLOCK_DOMAIN_LFCLK, NULL))
{
return NRFX_ERROR_INVALID_STATE;
}
@@ -310,7 +365,7 @@ 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)
+#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED) && NRF_CLOCK_HAS_CALIBRATION_TIMER
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);
@@ -320,18 +375,80 @@ void nrfx_clock_calibration_timer_start(uint8_t interval)
void nrfx_clock_calibration_timer_stop(void)
{
-#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
+#if NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED) && NRF_CLOCK_HAS_CALIBRATION_TIMER
nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_CTTO_MASK);
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_CTSTOP);
#endif
}
+#if NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK192M
+nrfx_err_t nrfx_clock_divider_set(nrf_clock_domain_t domain,
+ nrf_clock_hfclk_div_t div)
+{
+ switch(domain)
+ {
+#if NRF_CLOCK_HAS_HFCLK_DIV
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ switch (div)
+ {
+ case NRF_CLOCK_HFCLK_DIV_2:
+ NRFX_CRITICAL_SECTION_ENTER();
+ if (nrf53_errata_4())
+ {
+ __DSB();
+ }
+ nrf_clock_hfclk_div_set(NRF_CLOCK, div);
+ if (nrf53_errata_4())
+ {
+ *(volatile uint32_t *)0x5084450C = 0x0;
+ *(volatile uint32_t *)0x50026548 = 0x0;
+ *(volatile uint32_t *)0x50081EE4 = 0x0D;
+ }
+ NRFX_CRITICAL_SECTION_EXIT();
+ break;
+ case NRF_CLOCK_HFCLK_DIV_1:
+ NRFX_CRITICAL_SECTION_ENTER();
+ if (nrf53_errata_4())
+ {
+ __DSB();
+ *(volatile uint32_t *)0x5084450C = 0x4040;
+ *(volatile uint32_t *)0x50026548 = 0x40;
+ *(volatile uint32_t *)0x50081EE4 = 0x4D;
+ }
+ nrf_clock_hfclk_div_set(NRF_CLOCK, div);
+ NRFX_CRITICAL_SECTION_EXIT();
+ break;
+ default:
+ return NRFX_ERROR_INVALID_PARAM;
+ }
+ SystemCoreClockUpdate();
+ return NRFX_SUCCESS;
+#endif
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ if (div > NRF_CLOCK_HFCLK_DIV_4)
+ {
+ return NRFX_ERROR_INVALID_PARAM;
+ }
+ else
+ {
+ nrf_clock_hfclk192m_div_set(NRF_CLOCK, div);
+ }
+ return NRFX_SUCCESS;
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return NRFX_ERROR_NOT_SUPPORTED;
+ }
+}
+#endif
+
void nrfx_clock_irq_handler(void)
{
if (nrf_clock_event_check(NRF_CLOCK, 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));
+ NRFX_LOG_DEBUG("Event: NRF_CLOCK_EVENT_HFCLKSTARTED");
nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_HF_STARTED_MASK);
#if NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_201)
@@ -347,21 +464,23 @@ void nrfx_clock_irq_handler(void)
if (nrf_clock_event_check(NRF_CLOCK, 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));
+ NRFX_LOG_DEBUG("Event: NRF_CLOCK_EVENT_LFCLKSTARTED");
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_HAS_CALIBRATION_TIMER
if (nrf_clock_event_check(NRF_CLOCK, 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));
+ NRFX_LOG_DEBUG("Event: NRF_CLOCK_EVENT_CTTO");
nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_CTTO_MASK);
m_clock_cb.event_handler(NRFX_CLOCK_EVT_CTTO);
}
+#endif // NRF_CLOCK_HAS_CALIBRATION_TIMER
if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_DONE))
{
@@ -369,12 +488,34 @@ void nrfx_clock_irq_handler(void)
*(volatile uint32_t *)0x40000C34 = 0x00000000;
#endif
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_DONE);
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_CLOCK_EVENT_DONE));
+ NRFX_LOG_DEBUG("Event: NRF_CLOCK_EVENT_DONE");
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);
}
-#endif // NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
+#endif // NRFX_CHECK(NRFX_CLOCK_CONFIG_LF_CAL_ENABLED)
+
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKAUDIOSTARTED))
+ {
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKAUDIOSTARTED);
+ NRFX_LOG_DEBUG("Event: NRF_CLOCK_EVENT_HFCLKAUDIOSTARTED");
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_HFAUDIO_STARTED_MASK);
+
+ m_clock_cb.event_handler(NRFX_CLOCK_EVT_HFCLKAUDIO_STARTED);
+ }
+#endif
+
+#if NRF_CLOCK_HAS_HFCLK192M
+ if (nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLK192MSTARTED))
+ {
+ nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLK192MSTARTED);
+ NRFX_LOG_DEBUG("Event: NRF_CLOCK_EVENT_HFCLK192MSTARTED");
+ nrf_clock_int_disable(NRF_CLOCK, NRF_CLOCK_INT_HF192M_STARTED_MASK);
+
+ m_clock_cb.event_handler(NRFX_CLOCK_EVT_HFCLK192M_STARTED);
+ }
+#endif
}
#endif // NRFX_CHECK(NRFX_CLOCK_ENABLED)
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 c8ebb4d..84c23d1 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 3c7df6a..a845867 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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
index 9948f39..07fccaf 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_egu.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 515b289..73f8e44 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,11 +44,11 @@
#define PIN_NOT_USED (-1)
#define PIN_USED (-2)
#define NO_CHANNELS (-1)
-#define SENSE_FIELD_POS (6)
-#define SENSE_FIELD_MASK (0xC0)
+#define POLARITY_FIELD_POS (6)
+#define POLARITY_FIELD_MASK (0xC0)
/* Check if every pin can be encoded on provided number of bits. */
-NRFX_STATIC_ASSERT(NUMBER_OF_PINS <= (1 << SENSE_FIELD_POS));
+NRFX_STATIC_ASSERT(NUMBER_OF_PINS <= (1 << POLARITY_FIELD_POS));
/*lint -save -e571*/ /* Suppress "Warning 571: Suspicious cast" */
typedef struct
@@ -145,6 +145,17 @@ static nrfx_gpiote_evt_handler_t channel_handler_get(uint32_t channel)
return m_cb.handlers[channel];
}
+static nrfx_gpiote_pin_t port_handler_pin_get(uint32_t handler_idx)
+{
+ uint8_t pin_and_polarity = (uint8_t)m_cb.port_handlers_pins[handler_idx];
+ return (nrfx_gpiote_pin_t)(pin_and_polarity & ~POLARITY_FIELD_MASK);
+}
+
+static nrf_gpiote_polarity_t port_handler_polarity_get(uint32_t handler_idx)
+{
+ uint8_t pin_and_polarity = (uint8_t)m_cb.port_handlers_pins[handler_idx];
+ return (nrf_gpiote_polarity_t)((pin_and_polarity & POLARITY_FIELD_MASK) >> POLARITY_FIELD_POS);
+}
static int8_t channel_port_alloc(uint32_t pin, nrfx_gpiote_evt_handler_t handler, bool channel)
{
@@ -522,7 +533,7 @@ nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
else
{
m_cb.port_handlers_pins[channel - GPIOTE_CH_NUM] |= (p_config->sense) <<
- SENSE_FIELD_POS;
+ POLARITY_FIELD_POS;
}
}
else
@@ -541,10 +552,8 @@ void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable)
NRFX_ASSERT(pin_in_use_by_gpiote(pin));
if (pin_in_use_by_port(pin))
{
- uint8_t pin_and_sense = (uint8_t)
- m_cb.port_handlers_pins[channel_port_get(pin) - GPIOTE_CH_NUM];
nrf_gpiote_polarity_t polarity =
- (nrf_gpiote_polarity_t)(pin_and_sense >> SENSE_FIELD_POS);
+ port_handler_polarity_get(channel_port_get(pin) - GPIOTE_CH_NUM);
nrf_gpio_pin_sense_t sense;
if (polarity == NRF_GPIOTE_POLARITY_TOGGLE)
{
@@ -643,6 +652,159 @@ uint32_t nrfx_gpiote_in_event_addr_get(nrfx_gpiote_pin_t pin)
return nrf_gpiote_event_address_get(NRF_GPIOTE, event);
}
+#if defined(NRF_GPIO_LATCH_PRESENT)
+static bool latch_pending_read_and_check(uint32_t * latch)
+{
+ nrf_gpio_latches_read_and_clear(0, GPIO_COUNT, latch);
+
+ for (uint32_t port_idx = 0; port_idx < GPIO_COUNT; port_idx++)
+ {
+ if (latch[port_idx])
+ {
+ /* If any of the latch bits is still set, it means another edge has been captured
+ * before or during the interrupt processing. Therefore event-processing loop
+ * should be executed again. */
+ return true;
+ }
+ }
+ return false;
+}
+
+static void port_event_handle(uint32_t * latch)
+{
+ do {
+ for (uint32_t i = 0; i < NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS; i++)
+ {
+ if (m_cb.port_handlers_pins[i] == PIN_NOT_USED)
+ {
+ continue;
+ }
+
+ /* Process pin further only if LATCH bit associated with this pin was set. */
+ nrfx_gpiote_pin_t pin = port_handler_pin_get(i);
+ if (nrf_bitmask_bit_is_set(pin, latch))
+ {
+ nrf_gpiote_polarity_t polarity = port_handler_polarity_get(i);
+ nrf_gpio_pin_sense_t sense = nrf_gpio_pin_sense_get(pin);
+
+ NRFX_LOG_DEBUG("PORT event for pin: %d, polarity: %d.", pin, polarity);
+
+ /* Reconfigure sense to the opposite level, so the internal PINx.DETECT signal
+ * can be deasserted. Therefore PORT event generated again,
+ * unless some other PINx.DETECT signal is still active. */
+ nrf_gpio_pin_sense_t next_sense =
+ (sense == NRF_GPIO_PIN_SENSE_HIGH) ? NRF_GPIO_PIN_SENSE_LOW :
+ NRF_GPIO_PIN_SENSE_HIGH;
+ nrf_gpio_cfg_sense_set(pin, next_sense);
+
+ /* Try to clear LATCH bit corresponding to currently processed pin.
+ * This may not succeed if the pin's state changed during the interrupt processing
+ * and now it matches the new sense configuration. In such case,
+ * the pin will be processed again in another iteration of the outer loop. */
+ nrf_gpio_pin_latch_clear(pin);
+
+ /* Invoke user handler only if the sensed pin level
+ * matches its polarity configuration. */
+ nrfx_gpiote_evt_handler_t handler =
+ channel_handler_get((uint32_t)channel_port_get(pin));
+ if (handler &&
+ ((polarity == NRF_GPIOTE_POLARITY_TOGGLE) ||
+ (sense == NRF_GPIO_PIN_SENSE_HIGH && polarity == NRF_GPIOTE_POLARITY_LOTOHI) ||
+ (sense == NRF_GPIO_PIN_SENSE_LOW && polarity == NRF_GPIOTE_POLARITY_HITOLO)))
+ {
+ handler(pin, polarity);
+ }
+ }
+ }
+ } while (latch_pending_read_and_check(latch));
+}
+
+#else
+
+static bool input_read_and_check(uint32_t * input, uint32_t * pins_to_check)
+{
+ bool process_inputs_again;
+ uint32_t new_input[GPIO_COUNT];
+
+ nrf_gpio_ports_read(0, GPIO_COUNT, new_input);
+
+ process_inputs_again = false;
+ for (uint32_t port_idx = 0; port_idx < GPIO_COUNT; port_idx++)
+ {
+ /* Execute XOR to find out which inputs have changed. */
+ uint32_t input_diff = input[port_idx] ^ new_input[port_idx];
+ input[port_idx] = new_input[port_idx];
+ if (input_diff)
+ {
+ /* If any differences among inputs were found, mark those pins
+ * to be processed again. */
+ pins_to_check[port_idx] = input_diff;
+ process_inputs_again = true;
+ }
+ else
+ {
+ pins_to_check[port_idx] = 0;
+ }
+ }
+ return process_inputs_again;
+}
+
+static void port_event_handle(uint32_t * input)
+{
+ uint32_t pins_to_check[GPIO_COUNT];
+
+ for (uint32_t port_idx = 0; port_idx < GPIO_COUNT; port_idx++)
+ {
+ pins_to_check[port_idx] = 0xFFFFFFFF;
+ }
+
+ do {
+ for (uint32_t i = 0; i < NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS; i++)
+ {
+ if (m_cb.port_handlers_pins[i] == PIN_NOT_USED)
+ {
+ continue;
+ }
+
+ nrfx_gpiote_pin_t pin = port_handler_pin_get(i);
+ if (nrf_bitmask_bit_is_set(pin, pins_to_check))
+ {
+ nrf_gpiote_polarity_t polarity = port_handler_polarity_get(i);
+ nrf_gpio_pin_sense_t sense = nrf_gpio_pin_sense_get(pin);
+ bool pin_state = nrf_bitmask_bit_is_set(pin, input);
+
+ /* Process pin further only if its state matches its sense level. */
+ if ((pin_state && (sense == NRF_GPIO_PIN_SENSE_HIGH)) ||
+ (!pin_state && (sense == NRF_GPIO_PIN_SENSE_LOW)) )
+ {
+ /* Reconfigure sense to the opposite level, so the internal PINx.DETECT signal
+ * can be deasserted. Therefore PORT event can be generated again,
+ * unless some other PINx.DETECT signal is still active. */
+ NRFX_LOG_DEBUG("PORT event for pin: %d, polarity: %d.", pin, polarity);
+ nrf_gpio_pin_sense_t next_sense =
+ (sense == NRF_GPIO_PIN_SENSE_HIGH) ? NRF_GPIO_PIN_SENSE_LOW :
+ NRF_GPIO_PIN_SENSE_HIGH;
+ nrf_gpio_cfg_sense_set(pin, next_sense);
+
+ /* Invoke user handler only if the sensed pin level
+ * matches its polarity configuration. */
+ nrfx_gpiote_evt_handler_t handler =
+ channel_handler_get((uint32_t)channel_port_get(pin));
+ if (handler &&
+ ((polarity == NRF_GPIOTE_POLARITY_TOGGLE) ||
+ (sense == NRF_GPIO_PIN_SENSE_HIGH &&
+ polarity == NRF_GPIOTE_POLARITY_LOTOHI) ||
+ (sense == NRF_GPIO_PIN_SENSE_LOW &&
+ polarity == NRF_GPIOTE_POLARITY_HITOLO)))
+ {
+ handler(pin, polarity);
+ }
+ }
+ }
+ }
+ } while (input_read_and_check(input, pins_to_check));
+}
+#endif // defined(NRF_GPIO_LATCH_PRESENT)
void nrfx_gpiote_irq_handler(void)
{
@@ -674,7 +836,11 @@ void nrfx_gpiote_irq_handler(void)
{
nrf_gpiote_event_clear(NRF_GPIOTE, NRF_GPIOTE_EVENT_PORT);
status |= (uint32_t)NRF_GPIOTE_INT_PORT_MASK;
+#if defined(NRF_GPIO_LATCH_PRESENT)
+ nrf_gpio_latches_read_and_clear(0, GPIO_COUNT, input);
+#else
nrf_gpio_ports_read(0, GPIO_COUNT, input);
+#endif
}
/* Process pin events. */
@@ -700,107 +866,10 @@ void nrfx_gpiote_irq_handler(void)
}
}
+ /* Process PORT event. */
if (status & (uint32_t)NRF_GPIOTE_INT_PORT_MASK)
{
- /* Process port event. */
- uint32_t port_idx;
- uint8_t repeat = 0;
- uint32_t toggle_mask[GPIO_COUNT] = {0};
- uint32_t pins_to_check[GPIO_COUNT];
-
- // Faster way of doing memset because in interrupt context.
- for (port_idx = 0; port_idx < GPIO_COUNT; port_idx++)
- {
- pins_to_check[port_idx] = 0xFFFFFFFF;
- }
-
- do
- {
- repeat = 0;
-
- for (i = 0; i < NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS; i++)
- {
- uint8_t pin_and_sense = (uint8_t)m_cb.port_handlers_pins[i];
- nrfx_gpiote_pin_t pin = (pin_and_sense & ~SENSE_FIELD_MASK);
-
- if ((m_cb.port_handlers_pins[i] != PIN_NOT_USED)
- && nrf_bitmask_bit_is_set(pin, pins_to_check))
- {
- nrf_gpiote_polarity_t polarity =
- (nrf_gpiote_polarity_t)((pin_and_sense &
- SENSE_FIELD_MASK) >> SENSE_FIELD_POS);
- nrfx_gpiote_evt_handler_t handler =
- channel_handler_get((uint32_t)channel_port_get(pin));
- if (handler || (polarity == NRF_GPIOTE_POLARITY_TOGGLE))
- {
- if (polarity == NRF_GPIOTE_POLARITY_TOGGLE)
- {
- nrf_bitmask_bit_set(pin, toggle_mask);
- }
- nrf_gpio_pin_sense_t sense = nrf_gpio_pin_sense_get(pin);
- uint32_t pin_state = nrf_bitmask_bit_is_set(pin, input);
- if ((pin_state && (sense == NRF_GPIO_PIN_SENSE_HIGH)) ||
- (!pin_state && (sense == NRF_GPIO_PIN_SENSE_LOW)) )
- {
- NRFX_LOG_DEBUG("PORT event for pin: %d, polarity: %d.", pin, polarity);
- if (polarity == NRF_GPIOTE_POLARITY_TOGGLE)
- {
- nrf_gpio_pin_sense_t next_sense =
- (sense == NRF_GPIO_PIN_SENSE_HIGH) ?
- NRF_GPIO_PIN_SENSE_LOW :
- NRF_GPIO_PIN_SENSE_HIGH;
- nrf_gpio_cfg_sense_set(pin, next_sense);
- ++repeat;
-
- }
- if (handler)
- {
- handler(pin, polarity);
- }
- }
- }
- }
- }
-
- if (repeat)
- {
- // When one of the pins in low-accuracy and toggle mode becomes active,
- // it's sense mode is inverted to clear the internal SENSE signal.
- // State of any other enabled low-accuracy input in toggle mode must be checked
- // explicitly, because it does not trigger the interrput when SENSE signal is active.
- // For more information about SENSE functionality, refer to Product Specification.
-
- uint32_t new_input[GPIO_COUNT];
- bool input_unchanged = true;
- nrf_gpio_ports_read(0, GPIO_COUNT, new_input);
-
- // Faster way of doing memcmp because in interrupt context.
- for (port_idx = 0; port_idx < GPIO_COUNT; port_idx++)
- {
- if (new_input[port_idx] != input[port_idx])
- {
- input_unchanged = false;
- break;
- }
- }
-
- if (input_unchanged)
- {
- // No change.
- repeat = 0;
- }
- else
- {
- // Faster way of doing memcpy because in interrupt context.
- for (port_idx = 0; port_idx < GPIO_COUNT; port_idx++)
- {
- input[port_idx] = new_input[port_idx];
- pins_to_check[port_idx] = toggle_mask[port_idx];
- }
- }
- }
- }
- while (repeat);
+ port_event_handle(input);
}
}
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 d90d6f0..6072083 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -167,6 +167,10 @@ nrfx_err_t nrfx_i2s_init(nrfx_i2s_config_t const * p_config,
NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
}
+
+#if NRF_I2S_HAS_CLKCONFIG
+ nrf_i2s_clk_configure(NRF_I2S, p_config->clksrc, p_config->enable_bypass);
+#endif
configure_pins(p_config);
m_cb.handler = handler;
@@ -377,12 +381,18 @@ void nrfx_i2s_irq_handler(void)
nrf_i2s_disable(NRF_I2S);
// When stopped, release all buffers, including these scheduled for
- // the next transfer.
+ // the next part of the transfer, and signal that the transfer has
+ // finished.
+
m_cb.handler(&m_cb.current_buffers, 0);
- m_cb.handler(&m_cb.next_buffers, 0);
+ // Change the state of the driver before calling the handler with
+ // the flag signaling that the transfer has finished, so that it is
+ // possible to start a new transfer directly from the handler function.
m_cb.state = NRFX_DRV_STATE_INITIALIZED;
NRFX_LOG_INFO("Stopped.");
+
+ m_cb.handler(&m_cb.next_buffers, NRFX_I2S_STATUS_TRANSFER_STOPPED);
}
else
{
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
index dcfd28a..f47b70c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_ipc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 9e654e4..bbc51c8 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 fa8116e..952ba64 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 f4e93ca..7eff994 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,13 @@
*/
#define NVMC_BYTES_IN_WORD 4
+/** Value representing non-volatile memory (NVM) base address. */
+#if defined(NRF5340_XXAA_NETWORK)
+ #define NVMC_FLASH_BASE_ADDRESS 0x01000000uL
+#else
+ #define NVMC_FLASH_BASE_ADDRESS 0
+#endif
+
/**
* Value representing non-volatile memory (NVM) page count.
*
@@ -211,7 +218,7 @@ static void nvmc_words_write(uint32_t addr, void const * src, uint32_t num_words
nrfx_err_t nrfx_nvmc_page_erase(uint32_t addr)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
if (!is_page_aligned_check(addr))
{
@@ -253,7 +260,7 @@ void nrfx_nvmc_all_erase(void)
#if defined(NRF_NVMC_PARTIAL_ERASE_PRESENT)
nrfx_err_t nrfx_nvmc_page_partial_erase_init(uint32_t addr, uint32_t duration_ms)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
if (!is_page_aligned_check(addr))
{
@@ -299,7 +306,7 @@ bool nrfx_nvmc_page_partial_erase_continue(void)
bool nrfx_nvmc_byte_writable_check(uint32_t addr, uint8_t val_to_check)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
uint8_t val_on_addr = *(uint8_t const *)addr;
return (val_to_check & val_on_addr) == val_to_check;
@@ -307,7 +314,7 @@ bool nrfx_nvmc_byte_writable_check(uint32_t addr, uint8_t val_to_check)
bool nrfx_nvmc_word_writable_check(uint32_t addr, uint32_t val_to_check)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
NRFX_ASSERT(nrfx_is_word_aligned((void const *)addr));
uint32_t val_on_addr = *(uint32_t const *)addr;
@@ -323,7 +330,7 @@ void nrfx_nvmc_byte_write(uint32_t addr, uint8_t value)
void nrfx_nvmc_word_write(uint32_t addr, uint32_t value)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
NRFX_ASSERT(nrfx_is_word_aligned((void const *)addr));
nvmc_write_mode_set();
@@ -335,7 +342,7 @@ void nrfx_nvmc_word_write(uint32_t addr, uint32_t value)
void nrfx_nvmc_bytes_write(uint32_t addr, void const * src, uint32_t num_bytes)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
nvmc_write_mode_set();
@@ -397,7 +404,7 @@ void nrfx_nvmc_bytes_write(uint32_t addr, void const * src, uint32_t num_bytes)
void nrfx_nvmc_words_write(uint32_t addr, void const * src, uint32_t num_words)
{
- NRFX_ASSERT(addr < flash_total_size_get());
+ NRFX_ASSERT((addr - NVMC_FLASH_BASE_ADDRESS) < flash_total_size_get());
NRFX_ASSERT(nrfx_is_word_aligned((void const *)addr));
NRFX_ASSERT(nrfx_is_word_aligned(src));
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 8b14b33..7bd1bce 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -73,9 +73,9 @@ static nrfx_pdm_cb_t m_cb;
void nrfx_pdm_irq_handler(void)
{
- if (nrf_pdm_event_check(NRF_PDM, NRF_PDM_EVENT_STARTED))
+ if (nrf_pdm_event_check(NRF_PDM0, NRF_PDM_EVENT_STARTED))
{
- nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STARTED);
+ nrf_pdm_event_clear(NRF_PDM0, 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, NRF_PDM_EVENT_STOPPED))
+ else if (nrf_pdm_event_check(NRF_PDM0, NRF_PDM_EVENT_STOPPED))
{
- nrf_pdm_event_clear(NRF_PDM, NRF_PDM_EVENT_STOPPED);
+ nrf_pdm_event_clear(NRF_PDM0, NRF_PDM_EVENT_STOPPED);
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_PDM_EVENT_STOPPED));
- nrf_pdm_disable(NRF_PDM);
+ nrf_pdm_disable(NRF_PDM0);
m_cb.op_state = NRFX_PDM_STATE_IDLE;
// Release the buffers.
@@ -200,21 +200,28 @@ 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(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);
+#if NRF_PDM_HAS_RATIO_CONFIG
+ nrf_pdm_ratio_set(NRF_PDM0, p_config->ratio);
+#endif
+
+#if NRF_PDM_HAS_MCLKCONFIG
+ nrf_pdm_mclksrc_configure(NRF_PDM0, p_config->mclksrc);
+#endif
+ nrf_pdm_clock_set(NRF_PDM0, p_config->clock_freq);
+ nrf_pdm_mode_set(NRF_PDM0, p_config->mode, p_config->edge);
+ nrf_pdm_gain_set(NRF_PDM0, 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(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));
+ nrf_pdm_psel_connect(NRF_PDM0, p_config->pin_clk, p_config->pin_din);
+
+ nrf_pdm_event_clear(NRF_PDM0, NRF_PDM_EVENT_STARTED);
+ nrf_pdm_event_clear(NRF_PDM0, NRF_PDM_EVENT_END);
+ nrf_pdm_event_clear(NRF_PDM0, NRF_PDM_EVENT_STOPPED);
+ nrf_pdm_int_enable(NRF_PDM0, NRF_PDM_INT_STARTED | NRF_PDM_INT_STOPPED);
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_PDM0), p_config->interrupt_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_PDM0));
m_cb.drv_state = NRFX_DRV_STATE_INITIALIZED;
err_code = NRFX_SUCCESS;
@@ -226,8 +233,8 @@ nrfx_err_t nrfx_pdm_init(nrfx_pdm_config_t const * p_config,
void nrfx_pdm_uninit(void)
{
- nrf_pdm_disable(NRF_PDM);
- nrf_pdm_psel_disconnect(NRF_PDM);
+ nrf_pdm_disable(NRF_PDM0);
+ nrf_pdm_psel_disconnect(NRF_PDM0);
m_cb.drv_state = NRFX_DRV_STATE_UNINITIALIZED;
NRFX_LOG_INFO("Uninitialized.");
}
@@ -235,15 +242,15 @@ void nrfx_pdm_uninit(void)
static void pdm_start()
{
m_cb.drv_state = NRFX_DRV_STATE_POWERED_ON;
- 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);
+ nrf_pdm_enable(NRF_PDM0);
+ nrf_pdm_event_clear(NRF_PDM0, NRF_PDM_EVENT_STARTED);
+ nrf_pdm_task_trigger(NRF_PDM0, NRF_PDM_TASK_START);
}
static void pdm_buf_request()
{
m_cb.irq_buff_request = 1;
- NRFX_IRQ_PENDING_SET(nrfx_get_irq_number(NRF_PDM));
+ NRFX_IRQ_PENDING_SET(nrfx_get_irq_number(NRF_PDM0));
}
nrfx_err_t nrfx_pdm_start(void)
@@ -296,7 +303,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(nrfx_get_irq_number(NRF_PDM));
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_PDM0));
uint8_t next_buffer = (~m_cb.active_buffer) & 0x01;
if (m_cb.op_state == NRFX_PDM_STATE_STARTING)
@@ -313,7 +320,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(NRF_PDM, (uint32_t *)buffer, buffer_length);
+ nrf_pdm_buffer_set(NRF_PDM0, (uint32_t *)buffer, buffer_length);
if (m_cb.drv_state != NRFX_DRV_STATE_POWERED_ON)
{
@@ -321,7 +328,7 @@ nrfx_err_t nrfx_pdm_buffer_set(int16_t * buffer, uint16_t buffer_length)
}
}
- NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_PDM));
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_PDM0));
return err_code;
}
@@ -335,7 +342,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);
+ nrf_pdm_disable(NRF_PDM0);
m_cb.op_state = NRFX_PDM_STATE_IDLE;
err_code = NRFX_SUCCESS;
NRFX_LOG_INFO("Function: %s, error code: %s.",
@@ -352,7 +359,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, NRF_PDM_TASK_STOP);
+ nrf_pdm_task_trigger(NRF_PDM0, 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 5bb5da8..3327c14 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,9 +34,6 @@
#if NRFX_CHECK(NRFX_POWER_ENABLED)
#include <nrfx_power.h>
-#if defined(REGULATORS_PRESENT)
-#include <hal/nrf_regulators.h>
-#endif
#if NRFX_CHECK(NRFX_CLOCK_ENABLED)
extern bool nrfx_clock_irq_enabled;
@@ -108,7 +105,10 @@ nrfx_err_t nrfx_power_init(nrfx_power_config_t const * p_config)
#if NRF_POWER_HAS_DCDCEN_VDDH
nrf_power_dcdcen_vddh_set(NRF_POWER, p_config->dcdcenhv);
+#elif NRF_REGULATORS_HAS_DCDCEN_VDDH
+ nrf_regulators_dcdcen_vddh_set(NRF_REGULATORS, p_config->dcdcenhv);
#endif
+
#if NRF_POWER_HAS_DCDCEN
nrf_power_dcdcen_set(NRF_POWER, p_config->dcdcen);
#elif defined(REGULATORS_PRESENT)
@@ -132,19 +132,19 @@ void nrfx_power_uninit(void)
{
NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_POWER));
}
-#if NRF_POWER_HAS_POFCON
+#if NRFX_POWER_SUPPORTS_POFCON
nrfx_power_pof_uninit();
#endif
#if NRF_POWER_HAS_SLEEPEVT
nrfx_power_sleepevt_uninit();
#endif
-#if NRF_POWER_HAS_USBREG
+#if NRF_POWER_HAS_USBREG || defined(USBREG_PRESENT)
nrfx_power_usbevt_uninit();
#endif
m_initialized = false;
}
-#if NRF_POWER_HAS_POFCON
+#if NRFX_POWER_SUPPORTS_POFCON
void nrfx_power_pof_init(nrfx_power_pofwarn_config_t const * p_config)
{
NRFX_ASSERT(p_config != NULL);
@@ -159,10 +159,18 @@ 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)
{
+#if NRF_POWER_HAS_POFCON
nrf_power_pofcon_set(NRF_POWER, true, p_config->thr);
-#if NRF_POWER_HAS_VDDH
+#elif NRF_REGULATORS_HAS_POFCON
+ nrf_regulators_pofcon_set(NRF_REGULATORS, true, p_config->thr);
+#endif
+
+#if NRF_POWER_HAS_POFCON_VDDH
nrf_power_pofcon_vddh_set(NRF_POWER, p_config->thrvddh);
+#elif NRF_REGULATORS_HAS_POFCON_VDDH
+ nrf_regulators_pofcon_vddh_set(NRF_REGULATORS, p_config->thrvddh);
#endif
+
if (m_pofwarn_handler != NULL)
{
nrf_power_int_enable(NRF_POWER, NRF_POWER_INT_POFWARN_MASK);
@@ -171,7 +179,11 @@ void nrfx_power_pof_enable(nrfx_power_pofwarn_config_t const * p_config)
void nrfx_power_pof_disable(void)
{
+#if NRF_POWER_HAS_POFCON
nrf_power_pofcon_set(NRF_POWER, false, NRF_POWER_POFTHR_V27);
+#elif NRF_REGULATORS_HAS_POFCON
+ nrf_regulators_pofcon_set(NRF_REGULATORS, false, NRF_REGULATORS_POFTHR_V27);
+#endif
nrf_power_int_disable(NRF_POWER, NRF_POWER_INT_POFWARN_MASK);
}
@@ -179,7 +191,7 @@ void nrfx_power_pof_uninit(void)
{
m_pofwarn_handler = NULL;
}
-#endif // NRF_POWER_HAS_POFCON
+#endif // NRFX_POWER_SUPPORTS_POFCON
#if NRF_POWER_HAS_SLEEPEVT
void nrfx_power_sleepevt_init(nrfx_power_sleepevt_config_t const * p_config)
@@ -249,8 +261,11 @@ void nrfx_power_usbevt_disable(void)
void nrfx_power_usbevt_uninit(void)
{
+ nrfx_power_usbevt_disable();
m_usbevt_handler = NULL;
}
+
+
#endif /* NRF_POWER_HAS_USBREG */
@@ -258,7 +273,7 @@ void nrfx_power_irq_handler(void)
{
uint32_t enabled = nrf_power_int_enable_get(NRF_POWER);
-#if NRF_POWER_HAS_POFCON
+#if NRFX_POWER_SUPPORTS_POFCON
if ((0 != (enabled & NRF_POWER_INT_POFWARN_MASK)) &&
nrf_power_event_get_and_clear(NRF_POWER, NRF_POWER_EVENT_POFWARN))
{
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 7981c1e..de7f65f 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 c3eb7e7..d89bc7c 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -92,16 +92,19 @@ static void configure_pins(nrfx_pwm_t const * p_instance,
bool inverted = output_pin & NRFX_PWM_PIN_INVERTED;
out_pins[i] = output_pin & ~NRFX_PWM_PIN_INVERTED;
- if (inverted)
+ if (!p_config->skip_gpio_cfg)
{
- nrf_gpio_pin_set(out_pins[i]);
+ if (inverted)
+ {
+ nrf_gpio_pin_set(out_pins[i]);
+ }
+ else
+ {
+ nrf_gpio_pin_clear(out_pins[i]);
+ }
+
+ nrf_gpio_cfg_output(out_pins[i]);
}
- else
- {
- nrf_gpio_pin_clear(out_pins[i]);
- }
-
- nrf_gpio_cfg_output(out_pins[i]);
}
else
{
@@ -365,14 +368,22 @@ bool nrfx_pwm_stop(nrfx_pwm_t const * p_instance,
bool ret_val = false;
+ // Deactivate shortcuts before triggering the STOP task, otherwise the PWM
+ // could be immediately started again if the LOOPSDONE event occurred in
+ // the same peripheral clock cycle as the STOP task was triggered.
+ nrf_pwm_shorts_set(p_instance->p_registers, 0);
+
+ // Trigger the STOP task even if the PWM appears to be already stopped.
+ // It won't harm, but it could help if for some strange reason the stopped
+ // status was not reported correctly.
+ nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_STOP);
+
if (nrfx_pwm_is_stopped(p_instance))
{
ret_val = true;
}
else
{
- nrf_pwm_task_trigger(p_instance->p_registers, NRF_PWM_TASK_STOP);
-
do {
if (nrfx_pwm_is_stopped(p_instance))
{
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 81937e0..a83e28c 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -141,8 +141,8 @@ nrfx_err_t nrfx_qdec_init(nrfx_qdec_config_t const * p_config,
}
nrf_qdec_int_enable(NRF_QDEC, int_mask);
- NRFX_IRQ_PRIORITY_SET(QDEC_IRQn, p_config->interrupt_priority);
- NRFX_IRQ_ENABLE(QDEC_IRQn);
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_QDEC), p_config->interrupt_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_QDEC));
m_state = NRFX_DRV_STATE_INITIALIZED;
@@ -155,7 +155,7 @@ void nrfx_qdec_uninit(void)
{
NRFX_ASSERT(m_state != NRFX_DRV_STATE_UNINITIALIZED);
nrfx_qdec_disable();
- NRFX_IRQ_DISABLE(QDEC_IRQn);
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_QDEC));
m_state = NRFX_DRV_STATE_UNINITIALIZED;
NRFX_LOG_INFO("Uninitialized.");
}
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 4583017..3983e8c 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -394,6 +394,50 @@ nrfx_err_t nrfx_qspi_chip_erase(void)
return nrfx_qspi_erase(NRF_QSPI_ERASE_LEN_ALL, 0);
}
+#if NRF_QSPI_HAS_XIP_ENC
+nrfx_err_t nrfx_qspi_xip_encrypt(nrf_qspi_encryption_t const * p_config)
+{
+ if (m_cb.is_busy)
+ {
+ return NRFX_ERROR_BUSY;
+ }
+
+ if (p_config)
+ {
+ nrf_qspi_xip_encryption_configure(NRF_QSPI, p_config);
+ nrf_qspi_xip_encryption_set(NRF_QSPI, true);
+ }
+ else
+ {
+ nrf_qspi_xip_encryption_set(NRF_QSPI, false);
+ }
+
+ return NRFX_SUCCESS;
+}
+#endif
+
+#if NRF_QSPI_HAS_DMA_ENC
+nrfx_err_t nrfx_qspi_dma_encrypt(nrf_qspi_encryption_t const * p_config)
+{
+ if (m_cb.is_busy)
+ {
+ return NRFX_ERROR_BUSY;
+ }
+
+ if (p_config)
+ {
+ nrf_qspi_dma_encryption_configure(NRF_QSPI, p_config);
+ nrf_qspi_dma_encryption_set(NRF_QSPI, true);
+ }
+ else
+ {
+ nrf_qspi_dma_encryption_set(NRF_QSPI, false);
+ }
+
+ return NRFX_SUCCESS;
+}
+#endif
+
void nrfx_qspi_irq_handler(void)
{
// Catch Event ready interrupts
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 8343866..bf5b4ef 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 53a0ed9..60fe2ae 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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 371cdc9..4e24409 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,24 +36,18 @@
#define NRFX_LOG_MODULE SAADC
#include <nrfx_log.h>
-#define EVT_TO_STR(event) \
- (event == NRF_SAADC_EVENT_STARTED ? "NRF_SAADC_EVENT_STARTED" : \
- (event == NRF_SAADC_EVENT_END ? "NRF_SAADC_EVENT_END" : \
- (event == NRF_SAADC_EVENT_DONE ? "NRF_SAADC_EVENT_DONE" : \
- (event == NRF_SAADC_EVENT_RESULTDONE ? "NRF_SAADC_EVENT_RESULTDONE" : \
- (event == NRF_SAADC_EVENT_CALIBRATEDONE ? "NRF_SAADC_EVENT_CALIBRATEDONE" : \
- (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)
+#if defined(NRF53_SERIES) || defined(NRF91_SERIES)
// Make sure that SAADC is stopped before channel configuration.
#define STOP_SAADC_ON_CHANNEL_CONFIG 1
+
+ // Make sure that SAADC calibration samples do not affect next conversions.
+ #define INTERCEPT_SAADC_CALIBRATION_SAMPLES 1
#endif
/** @brief SAADC driver states.*/
@@ -75,9 +69,12 @@ typedef struct
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.
+#if NRFX_CHECK(INTERCEPT_SAADC_CALIBRATION_SAMPLES)
+ nrf_saadc_value_t calib_samples[6]; ///< Scratch buffer for calibration samples.
+#endif
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.
+ uint16_t samples_converted; ///< Number of samples present in result buffer when 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.
@@ -87,6 +84,7 @@ typedef struct
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.
+ bool oversampling_without_burst; ///< Flag indicating whether oversampling without burst is configured.
} nrfx_saadc_cb_t;
static nrfx_saadc_cb_t m_cb;
@@ -122,17 +120,6 @@ static void saadc_anomaly_212_workaround_apply(void)
}
#endif // NRFX_CHECK(USE_WORKAROUND_FOR_ANOMALY_212)
-static void saadc_enabled_channels_sample(void)
-{
- for (uint32_t sample_idx = 0; sample_idx < m_cb.samples_per_trigger; sample_idx++)
- {
- 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);
- }
-}
-
static nrfx_err_t saadc_channel_count_get(uint32_t ch_to_activate_mask,
uint8_t * p_active_ch_count)
{
@@ -183,11 +170,9 @@ static void saadc_generic_mode_set(uint32_t ch_to_activate_mas
#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))
- {
- }
+ {}
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
#endif
@@ -198,25 +183,20 @@ static void saadc_generic_mode_set(uint32_t ch_to_activate_mas
m_cb.p_buffer_secondary = NULL;
m_cb.event_handler = event_handler;
m_cb.channels_activated = ch_to_activate_mask;
+ m_cb.samples_converted = 0;
nrf_saadc_resolution_set(NRF_SAADC, resolution);
nrf_saadc_oversample_set(NRF_SAADC, oversampling);
if (event_handler)
{
- 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);
+ nrf_saadc_int_set(NRF_SAADC,
+ NRF_SAADC_INT_STARTED |
+ NRF_SAADC_INT_STOPPED |
+ NRF_SAADC_INT_END);
}
else
{
- nrf_saadc_int_disable(NRF_SAADC,
- NRF_SAADC_INT_STARTED |
- NRF_SAADC_INT_STOPPED |
- NRF_SAADC_INT_END);
+ nrf_saadc_int_set(NRF_SAADC, 0);
}
for (uint32_t ch_pos = 0; ch_pos < SAADC_CH_NUM; ch_pos++)
@@ -243,22 +223,28 @@ static void saadc_generic_mode_set(uint32_t ch_to_activate_mas
nrfx_err_t nrfx_saadc_init(uint8_t interrupt_priority)
{
+ nrfx_err_t err_code;
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 NRFX_ERROR_INVALID_STATE;
+ return err_code;
}
m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
- nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_ALL);
+ 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_set(NRF_SAADC, 0);
NRFX_IRQ_ENABLE(SAADC_IRQn);
NRFX_IRQ_PRIORITY_SET(SAADC_IRQn, interrupt_priority);
+ err_code = NRFX_SUCCESS;
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return NRFX_SUCCESS;
+ return err_code;
}
void nrfx_saadc_uninit(void)
@@ -335,6 +321,7 @@ nrfx_err_t nrfx_saadc_simple_mode_set(uint32_t channel_mask,
}
else
{
+ // Burst is implicitly enabled if oversampling is enabled.
burst = NRF_SAADC_BURST_ENABLED;
}
@@ -344,17 +331,6 @@ nrfx_err_t nrfx_saadc_simple_mode_set(uint32_t channel_mask,
burst,
event_handler);
- if (event_handler)
- {
- 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);
- }
-
- 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;
@@ -386,24 +362,20 @@ nrfx_err_t nrfx_saadc_advanced_mode_set(uint32_t channel_
return NRFX_ERROR_NOT_SUPPORTED;
}
+ bool oversampling_without_burst = false;
if ((p_config->oversampling != NRF_SAADC_OVERSAMPLE_DISABLED) &&
(p_config->burst == NRF_SAADC_BURST_DISABLED))
{
- // Oversampling without burst
if (active_ch_count > 1)
{
+ // Oversampling without burst is possible only on single channel.
return NRFX_ERROR_NOT_SUPPORTED;
}
else
{
- m_cb.samples_per_trigger =
- nrf_saadc_oversample_sample_count_get(p_config->oversampling);
+ oversampling_without_burst = true;
}
}
- else
- {
- m_cb.samples_per_trigger = active_ch_count;
- }
saadc_generic_mode_set(channel_mask,
resolution,
@@ -422,6 +394,7 @@ nrfx_err_t nrfx_saadc_advanced_mode_set(uint32_t channel_
m_cb.channels_activated_count = active_ch_count;
m_cb.start_on_end = p_config->start_on_end;
+ m_cb.oversampling_without_burst = oversampling_without_burst;
m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE;
@@ -456,9 +429,8 @@ nrfx_err_t nrfx_saadc_buffer_set(nrf_saadc_value_t * p_buffer, uint16_t 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);
+ m_cb.p_buffer_primary = p_buffer;
break;
case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
@@ -471,14 +443,13 @@ nrfx_err_t nrfx_saadc_buffer_set(nrf_saadc_value_t * p_buffer, uint16_t size)
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;
+ m_cb.p_buffer_secondary = p_buffer;
}
else
{
- m_cb.p_buffer_primary = p_buffer;
m_cb.size_primary = size;
- nrf_saadc_buffer_init(NRF_SAADC, p_buffer, size);
+ m_cb.p_buffer_primary = p_buffer;
}
break;
@@ -500,9 +471,14 @@ nrfx_err_t nrfx_saadc_mode_trigger(void)
}
nrfx_err_t result = NRFX_SUCCESS;
- switch (m_cb.saadc_state) {
+ switch (m_cb.saadc_state)
+ {
case NRF_SAADC_STATE_SIMPLE_MODE:
nrf_saadc_enable(NRF_SAADC);
+ // When in simple blocking or non-blocking mode, buffer size is equal to activated channel count.
+ // Single SAMPLE task is enough to obtain one sample on each activated channel.
+ // This will result in buffer being filled with samples and therefore END event will appear.
+ nrf_saadc_buffer_init(NRF_SAADC, m_cb.p_buffer_primary, m_cb.size_primary);
if (m_cb.event_handler)
{
m_cb.saadc_state = NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE;
@@ -515,7 +491,7 @@ nrfx_err_t nrfx_saadc_mode_trigger(void)
{}
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
- saadc_enabled_channels_sample();
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END))
{}
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
@@ -527,49 +503,64 @@ nrfx_err_t nrfx_saadc_mode_trigger(void)
nrf_saadc_enable(NRF_SAADC);
if (m_cb.event_handler)
{
+ // When in advanced non-blocking mode, latch whole buffer in EasyDMA.
+ // END event will arrive when whole buffer is filled with samples.
m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE_SAMPLE;
+ nrf_saadc_buffer_init(NRF_SAADC, m_cb.p_buffer_primary, m_cb.size_primary);
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
break;
}
- m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED;
+ // When in advanced blocking mode, latch single chunk of buffer in EasyDMA.
+ // Each chunk consists of single sample from each activated channels.
+ // END event will arrive when single chunk is filled with samples.
+ nrf_saadc_buffer_init(NRF_SAADC,
+ &m_cb.p_buffer_primary[m_cb.samples_converted],
+ m_cb.channels_activated_count);
+
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)
+ if (m_cb.oversampling_without_burst)
{
- result = NRFX_ERROR_INVALID_STATE;
- break;
- }
+ // Oversampling without burst is possible only on single channel.
+ // In this configuration more than one SAMPLE task is needed to obtain single sample.
+ uint32_t samples_to_take =
+ nrf_saadc_oversample_sample_count_get(nrf_saadc_oversample_get(NRF_SAADC));
- 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
+ for (uint32_t sample_idx = 0; sample_idx < samples_to_take; sample_idx++)
{
- nrf_saadc_disable(NRF_SAADC);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_DONE);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_DONE))
+ {}
}
- result = NRFX_SUCCESS;
}
else
{
+ // Single SAMPLE task is enough to obtain one sample on each activated channel.
+ // This will result in chunk being filled with samples and therefore END event will appear.
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ }
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+
+ m_cb.samples_converted += m_cb.channels_activated_count;
+ if (m_cb.samples_converted < m_cb.size_primary)
+ {
result = NRFX_ERROR_BUSY;
}
+ else
+ {
+ m_cb.samples_converted = 0;
+ m_cb.p_buffer_primary = m_cb.p_buffer_secondary;
+ m_cb.size_primary = m_cb.size_secondary;
+ m_cb.p_buffer_secondary = NULL;
+ }
+ nrf_saadc_disable(NRF_SAADC);
break;
default:
@@ -584,43 +575,19 @@ void nrfx_saadc_abort(void)
{
NRFX_ASSERT(m_cb.saadc_state != NRF_SAADC_STATE_UNINITIALIZED);
- if (!saadc_busy_check())
- {
- return;
- }
-
- 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)
- {
- // STOPPED event does not appear when the calibration is ongoing
- m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
- }
- else if (!m_cb.event_handler)
+ 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)
+ m_cb.samples_converted = 0;
+ }
+ else
+ {
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
+ if (m_cb.saadc_state == NRF_SAADC_STATE_CALIBRATION)
{
- case NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE:
- m_cb.saadc_state = NRF_SAADC_STATE_SIMPLE_MODE;
- break;
-
- case NRF_SAADC_STATE_ADV_MODE_SAMPLE:
- /* fall-through */
-
- case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
- m_cb.saadc_state = NRF_SAADC_STATE_ADV_MODE;
- break;
-
- default:
- break;
+ // STOPPED event does not appear when the calibration is ongoing
+ m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
}
}
}
@@ -687,8 +654,31 @@ nrfx_err_t nrfx_saadc_offset_calibrate(nrfx_saadc_event_handler_t event_handler)
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);
+#if NRFX_CHECK(INTERCEPT_SAADC_CALIBRATION_SAMPLES)
+ nrf_saadc_buffer_init(NRF_SAADC, m_cb.calib_samples, NRFX_ARRAY_SIZE(m_cb.calib_samples));
+ if (event_handler)
+ {
+ nrf_saadc_int_set(NRF_SAADC, NRF_SAADC_INT_STARTED | NRF_SAADC_INT_CALIBRATEDONE);
+ 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);
+
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE))
+ {}
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+
+ nrf_saadc_disable(NRF_SAADC);
+ m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
+ }
+#else
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET);
if (event_handler)
{
@@ -702,6 +692,7 @@ nrfx_err_t nrfx_saadc_offset_calibrate(nrfx_saadc_event_handler_t event_handler)
nrf_saadc_disable(NRF_SAADC);
m_cb.saadc_state = NRF_SAADC_STATE_IDLE;
}
+#endif // NRFX_CHECK(INTERCEPT_SAADC_CALIBRATION_SAMPLES)
return NRFX_SUCCESS;
}
@@ -732,14 +723,25 @@ static void saadc_event_started_handle(void)
/* fall-through */
case NRF_SAADC_STATE_ADV_MODE_SAMPLE_STARTED:
- evt_data.type = NRFX_SAADC_EVT_BUF_REQ;
- m_cb.event_handler(&evt_data);
+ if (!m_cb.p_buffer_secondary)
+ {
+ // Send next buffer request only if it was not provided earlier,
+ // before conversion start or outside of user's callback context.
+ evt_data.type = NRFX_SAADC_EVT_BUF_REQ;
+ m_cb.event_handler(&evt_data);
+ }
break;
case NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE:
nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
break;
+#if NRFX_CHECK(INTERCEPT_SAADC_CALIBRATION_SAMPLES)
+ case NRF_SAADC_STATE_CALIBRATION:
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET);
+ break;
+#endif
+
default:
break;
}
@@ -814,16 +816,6 @@ void nrfx_saadc_irq_handler(void)
saadc_event_started_handle();
}
- if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_RESULTDONE))
- {
- nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_RESULTDONE);
-
- if (m_cb.saadc_state == NRF_SAADC_STATE_SIMPLE_MODE_SAMPLE)
- {
- nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
- }
- }
-
if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_STOPPED))
{
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
@@ -837,7 +829,15 @@ void nrfx_saadc_irq_handler(void)
if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END))
{
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
- saadc_event_end_handle();
+
+#if NRFX_CHECK(INTERCEPT_SAADC_CALIBRATION_SAMPLES)
+ // When samples are intercepted into scratch buffer during calibration,
+ // END event appears when the calibration finishes. This event should be ignored.
+ if (m_cb.saadc_state != NRF_SAADC_STATE_CALIBRATION)
+#endif
+ {
+ saadc_event_end_handle();
+ }
}
saadc_event_limits_handle(m_cb.limits_low_activated, NRF_SAADC_LIMIT_LOW);
@@ -846,6 +846,7 @@ void nrfx_saadc_irq_handler(void)
if (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;
@@ -853,8 +854,6 @@ void nrfx_saadc_irq_handler(void)
evt_data.type = NRFX_SAADC_EVT_CALIBRATEDONE;
m_cb.event_handler(&evt_data);
- nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_CALIBRATEDONE);
- nrf_saadc_disable(NRF_SAADC);
}
}
#endif // NRFX_CHECK(NRFX_SAADC_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c
index 1fa4b8a..1cbed19 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c
index bd8bc84..007d177 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spim.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,7 +34,8 @@
#if NRFX_CHECK(NRFX_SPIM_ENABLED)
#if !(NRFX_CHECK(NRFX_SPIM0_ENABLED) || NRFX_CHECK(NRFX_SPIM1_ENABLED) || \
- NRFX_CHECK(NRFX_SPIM2_ENABLED) || NRFX_CHECK(NRFX_SPIM3_ENABLED))
+ NRFX_CHECK(NRFX_SPIM2_ENABLED) || NRFX_CHECK(NRFX_SPIM3_ENABLED) || \
+ NRFX_CHECK(NRFX_SPIM4_ENABLED))
#error "No enabled SPIM instances. Check <nrfx_config.h>."
#endif
@@ -121,29 +122,45 @@
#define SPIM3_SUPPORTED_FREQ_VALIDATE(...) 0
#endif
+#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
+#define SPIM4_LENGTH_VALIDATE(...) SPIMX_LENGTH_VALIDATE(SPIM4, __VA_ARGS__)
+#define SPIM4_HW_CSN_PRESENT_VALIDATE(...) SPIMX_HW_CSN_PRESENT_VALIDATE(SPIM4, __VA_ARGS__)
+#define SPIM4_DCX_PRESENT_VALIDATE(...) SPIMX_DCX_PRESENT_VALIDATE(SPIM4, __VA_ARGS__)
+#define SPIM4_SUPPORTED_FREQ_VALIDATE(...) SPIMX_SUPPORTED_FREQ_VALIDATE(SPIM4, __VA_ARGS__)
+#else
+#define SPIM4_LENGTH_VALIDATE(...) 0
+#define SPIM4_HW_CSN_PRESENT_VALIDATE(...) 0
+#define SPIM4_DCX_PRESENT_VALIDATE(...) 0
+#define SPIM4_SUPPORTED_FREQ_VALIDATE(...) 0
+#endif
+
#define SPIM_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) \
(SPIM0_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
SPIM1_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
SPIM2_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
- SPIM3_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len))
+ SPIM3_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len) || \
+ SPIM4_LENGTH_VALIDATE(drv_inst_idx, rx_len, tx_len))
#define SPIM_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) \
(SPIM0_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
SPIM1_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
SPIM2_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
- SPIM3_HW_CSN_PRESENT_VALIDATE(drv_inst_idx))
+ SPIM3_HW_CSN_PRESENT_VALIDATE(drv_inst_idx) || \
+ SPIM4_HW_CSN_PRESENT_VALIDATE(drv_inst_idx))
#define SPIM_DCX_PRESENT_VALIDATE(drv_inst_idx) \
(SPIM0_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
SPIM1_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
SPIM2_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
- SPIM3_DCX_PRESENT_VALIDATE(drv_inst_idx))
+ SPIM3_DCX_PRESENT_VALIDATE(drv_inst_idx) || \
+ SPIM4_DCX_PRESENT_VALIDATE(drv_inst_idx))
#define SPIM_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) \
(SPIM0_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
SPIM1_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
SPIM2_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
- SPIM3_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq))
+ SPIM3_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq) || \
+ SPIM4_SUPPORTED_FREQ_VALIDATE(drv_inst_idx, freq))
#if defined(NRF52840_XXAA) && (NRFX_CHECK(NRFX_SPIM3_ENABLED))
// Enable workaround for nRF52840 anomaly 195 (SPIM3 continues to draw current after disable).
@@ -271,6 +288,9 @@ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * p_instance,
#if NRFX_CHECK(NRFX_SPIM3_ENABLED)
nrfx_spim_3_irq_handler,
#endif
+ #if NRFX_CHECK(NRFX_SPIM4_ENABLED)
+ nrfx_spim_4_irq_handler,
+ #endif
};
if (nrfx_prs_acquire(p_instance->p_reg,
irq_handlers[p_instance->drv_inst_idx]) != NRFX_SUCCESS)
@@ -754,4 +774,11 @@ void nrfx_spim_3_irq_handler(void)
}
#endif
+#if NRFX_CHECK(NRFX_SPIM4_ENABLED)
+void nrfx_spim_4_irq_handler(void)
+{
+ irq_handler(NRF_SPIM4, &m_cb[NRFX_SPIM4_INST_IDX]);
+}
+#endif
+
#endif // NRFX_CHECK(NRFX_SPIM_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c
index ebdf74f..be30e79 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_spis.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2013 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_systick.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_systick.c
index 878c068..708826a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_systick.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_systick.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_temp.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_temp.c
index a481df7..98ebb21 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_temp.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_temp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_timer.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_timer.c
index 06ac1dc..d8df49b 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_timer.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_timer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c
index 37f7dd9..4199400 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,8 @@
(event == NRFX_TWI_EVT_ADDRESS_NACK ? "EVT_ADDRESS_NACK" : \
(event == NRFX_TWI_EVT_DATA_NACK ? "EVT_DATA_NACK" : \
(event == NRFX_TWI_EVT_OVERRUN ? "EVT_OVERRUN" : \
- "UNKNOWN ERROR"))))
+ (event == NRFX_TWI_EVT_BUS_ERROR ? "EVT_BUS_ERROR" : \
+ "UNKNOWN ERROR")))))
#define EVT_TO_STR_TWI(event) \
(event == NRF_TWI_EVENT_STOPPED ? "NRF_TWI_EVENT_STOPPED" : \
@@ -132,7 +133,25 @@ static nrfx_err_t twi_process_error(uint32_t errorsrc)
return ret;
}
+static bool xfer_completeness_check(NRF_TWI_Type * p_twi, twi_control_block_t const * p_cb)
+{
+ // If the actual number of transferred bytes is not equal to what was requested,
+ // but there was no error signaled by the peripheral, this means that something
+ // unexpected, like a premature STOP condition, was received on the bus.
+ // In such case the peripheral has to be disabled and re-enabled, so that its
+ // internal state machine is reinitialized.
+ if (p_cb->bytes_transferred != p_cb->curr_length)
+ {
+ nrf_twi_disable(p_twi);
+ nrf_twi_enable(p_twi);
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
nrfx_err_t nrfx_twi_init(nrfx_twi_t const * p_instance,
nrfx_twi_config_t const * p_config,
@@ -264,7 +283,6 @@ static bool twi_send_byte(NRF_TWI_Type * p_twi,
if (p_cb->bytes_transferred < p_cb->curr_length)
{
nrf_twi_txd_set(p_twi, p_cb->p_curr_buf[p_cb->bytes_transferred]);
- ++(p_cb->bytes_transferred);
}
else
{
@@ -318,7 +336,19 @@ static bool twi_receive_byte(NRF_TWI_Type * p_twi,
static bool twi_transfer(NRF_TWI_Type * p_twi,
twi_control_block_t * p_cb)
{
- bool do_stop_check = ((p_cb->error) || ((p_cb->bytes_transferred) == p_cb->curr_length));
+ bool stopped = false;
+ if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_STOPPED))
+ {
+ nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED);
+ NRFX_LOG_DEBUG("TWI: Event: %s.", EVT_TO_STR_TWI(NRF_TWI_EVENT_STOPPED));
+
+ // Delay handling of STOPPED event till the end of events processing procedure.
+ // If penultimate byte is received and function gets interrupted for long enough
+ // after enabling BB_STOP shortcut, RXDREADY for last byte as well as STOPPED
+ // may be active at the same time. Therefore RXREADY has to be processed before STOPPED to
+ // acquire last byte before finishing transmission by returning 'false'.
+ stopped = true;
+ }
if (p_cb->error)
{
@@ -338,6 +368,7 @@ static bool twi_transfer(NRF_TWI_Type * p_twi,
if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_TXDSENT))
{
nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT);
+ ++(p_cb->bytes_transferred);
NRFX_LOG_DEBUG("TWI: Event: %s.", EVT_TO_STR_TWI(NRF_TWI_EVENT_TXDSENT));
if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR))
{
@@ -375,11 +406,13 @@ static bool twi_transfer(NRF_TWI_Type * p_twi,
}
}
- if (do_stop_check && nrf_twi_event_check(p_twi, NRF_TWI_EVENT_STOPPED))
+ if (stopped)
{
- nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED);
p_cb->prev_suspend = TWI_NO_SUSPEND;
- NRFX_LOG_DEBUG("TWI: Event: %s.", EVT_TO_STR_TWI(NRF_TWI_EVENT_STOPPED));
+ if (!p_cb->error)
+ {
+ p_cb->error = !xfer_completeness_check(p_twi, p_cb);
+ }
return false;
}
@@ -438,6 +471,10 @@ static nrfx_err_t twi_tx_start_transfer(NRF_TWI_Type * p_twi,
{
ret_code = twi_process_error(errorsrc);
}
+ else
+ {
+ ret_code = NRFX_ERROR_INTERNAL;
+ }
}
if (hw_timeout <= 0)
@@ -507,6 +544,10 @@ static nrfx_err_t twi_rx_start_transfer(NRF_TWI_Type * p_twi,
{
ret_code = twi_process_error(errorsrc);
}
+ else
+ {
+ ret_code = NRFX_ERROR_INTERNAL;
+ }
}
if (hw_timeout <= 0)
{
@@ -675,6 +716,11 @@ static void twi_irq_handler(NRF_TWI_Type * p_twi, twi_control_block_t * p_cb)
event.type = NRFX_TWI_EVT_OVERRUN;
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWI_EVT_OVERRUN));
}
+ else
+ {
+ event.type = NRFX_TWI_EVT_BUS_ERROR;
+ NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWI_EVT_BUS_ERROR));
+ }
}
else
{
@@ -684,7 +730,7 @@ static void twi_irq_handler(NRF_TWI_Type * p_twi, twi_control_block_t * p_cb)
p_cb->busy = false;
- if (!(TWI_FLAG_NO_HANDLER_IN_USE(p_cb->flags)))
+ if (!(TWI_FLAG_NO_HANDLER_IN_USE(p_cb->flags)) || p_cb->error)
{
p_cb->handler(&event, p_cb->p_context);
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi_twim.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi_twim.c
index f37c227..8452ccf 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi_twim.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twi_twim.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c
index 94ba4e7..8c0085c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twim.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,9 @@
(event == NRFX_TWIM_EVT_DONE ? "EVT_DONE" : \
(event == NRFX_TWIM_EVT_ADDRESS_NACK ? "EVT_ADDRESS_NACK" : \
(event == NRFX_TWIM_EVT_DATA_NACK ? "EVT_DATA_NACK" : \
- "UNKNOWN ERROR")))
+ (event == NRFX_TWIM_EVT_OVERRUN ? "EVT_OVERRUN" : \
+ (event == NRFX_TWIM_EVT_BUS_ERROR ? "EVT_BUS_ERROR" : \
+ "UNKNOWN ERROR")))))
#define EVT_TO_STR_TWIM(event) \
(event == NRF_TWIM_EVENT_STOPPED ? "NRF_TWIM_EVENT_STOPPED" : \
@@ -157,11 +159,11 @@ static nrfx_err_t twi_process_error(uint32_t errorsrc)
return ret;
}
-static bool xfer_completeness_check(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb)
+static bool xfer_completeness_check(NRF_TWIM_Type * p_twim, twim_control_block_t const * p_cb)
{
// If the actual number of transferred bytes is not equal to what was requested,
// but there was no error signaled by the peripheral, this means that something
- // unexpected, like a premature STOP condition, happened on the bus.
+ // unexpected, like a premature STOP condition, was received on the bus.
// In such case the peripheral has to be disabled and re-enabled, so that its
// internal state machine is reinitialized.
@@ -169,9 +171,12 @@ static bool xfer_completeness_check(NRF_TWIM_Type * p_twim, twim_control_block_t
switch (p_cb->xfer_desc.type)
{
case NRFX_TWIM_XFER_TXTX:
- if (((p_cb->int_mask == (NRF_TWIM_INT_SUSPENDED_MASK | NRF_TWIM_INT_ERROR_MASK)) &&
+ // int_mask variable is used to determine which length should be checked
+ // against number of bytes latched in EasyDMA.
+ // NRF_TWIM_INT_SUSPENDED_MASK is configured only in first TX of TXTX transfer.
+ if (((p_cb->int_mask & NRF_TWIM_INT_SUSPENDED_MASK) &&
(nrf_twim_txd_amount_get(p_twim) != p_cb->xfer_desc.primary_length)) ||
- ((p_cb->int_mask == (NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK)) &&
+ (!(p_cb->int_mask & NRF_TWIM_INT_SUSPENDED_MASK) &&
(nrf_twim_txd_amount_get(p_twim) != p_cb->xfer_desc.secondary_length)))
{
transfer_complete = false;
@@ -376,7 +381,6 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
{
nrfx_err_t err_code = NRFX_SUCCESS;
nrf_twim_task_t start_task = NRF_TWIM_TASK_STARTTX;
- nrf_twim_event_t evt_to_wait = NRF_TWIM_EVENT_STOPPED;
p_cb->error = false;
if (!nrfx_is_in_ram(p_xfer_desc->p_primary_buf))
@@ -406,10 +410,13 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
p_cb->xfer_desc = *p_xfer_desc;
p_cb->repeated = (flags & NRFX_TWIM_FLAG_REPEATED_XFER) ? true : false;
+ p_cb->flags = flags;
nrf_twim_address_set(p_twim, p_xfer_desc->address);
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_STOPPED);
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR);
+ nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTTX);
+ nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED);
twim_list_enable_handle(p_twim, flags);
switch (p_xfer_desc->type)
@@ -429,8 +436,6 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK);
nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length);
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED);
- nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTTX);
- nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED);
nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STARTTX);
while (!nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_TXSTARTED))
@@ -438,7 +443,7 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
NRFX_LOG_DEBUG("TWIM: Event: %s.", EVT_TO_STR_TWIM(NRF_TWIM_EVENT_TXSTARTED));
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED);
nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_secondary_buf, p_xfer_desc->secondary_length);
- p_cb->int_mask = NRF_TWIM_INT_SUSPENDED_MASK | NRF_TWIM_INT_ERROR_MASK;
+ p_cb->int_mask = NRF_TWIM_INT_SUSPENDED_MASK;
break;
case NRFX_TWIM_XFER_TXRX:
nrf_twim_tx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length);
@@ -453,7 +458,7 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
nrf_twim_rx_buffer_set(p_twim, p_xfer_desc->p_secondary_buf, p_xfer_desc->secondary_length);
nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_STARTRX_MASK |
NRF_TWIM_SHORT_LASTRX_STOP_MASK);
- p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK;
+ p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK;
nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
break;
case NRFX_TWIM_XFER_TX:
@@ -461,21 +466,19 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
if (NRFX_TWIM_FLAG_TX_NO_STOP & flags)
{
nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK);
- p_cb->int_mask = NRF_TWIM_INT_SUSPENDED_MASK | NRF_TWIM_INT_ERROR_MASK;
- nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED);
- evt_to_wait = NRF_TWIM_EVENT_SUSPENDED;
+ p_cb->int_mask = NRF_TWIM_INT_SUSPENDED_MASK;
}
else
{
nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTTX_STOP_MASK);
- p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK;
+ p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK;
}
nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
break;
case NRFX_TWIM_XFER_RX:
nrf_twim_rx_buffer_set(p_twim, p_xfer_desc->p_primary_buf, p_xfer_desc->primary_length);
nrf_twim_shorts_set(p_twim, NRF_TWIM_SHORT_LASTRX_STOP_MASK);
- p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK | NRF_TWIM_INT_ERROR_MASK;
+ p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK;
start_task = NRF_TWIM_TASK_STARTRX;
nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
break;
@@ -493,35 +496,90 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
{
if (flags & NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER)
{
- p_cb->int_mask = NRF_TWIM_INT_ERROR_MASK;
+ p_cb->int_mask = 0;
+ }
+
+ if (!(flags & NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK))
+ {
+ p_cb->int_mask |= NRF_TWIM_INT_STOPPED_MASK;
}
+
+ // Interrupts for ERROR are implicitly enabled, regardless of driver configuration.
+ p_cb->int_mask |= NRF_TWIM_INT_ERROR_MASK;
nrf_twim_int_enable(p_twim, p_cb->int_mask);
#if NRFX_CHECK(NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED)
- if ((flags & NRFX_TWIM_FLAG_HOLD_XFER) && ((p_xfer_desc->type == NRFX_TWIM_XFER_TX) ||
- (p_xfer_desc->type == NRFX_TWIM_XFER_TXRX)))
+ if ((flags & NRFX_TWIM_FLAG_HOLD_XFER) && (p_xfer_desc->type != NRFX_TWIM_XFER_RX))
{
- p_cb->flags = flags;
twim_list_enable_handle(p_twim, 0);
p_twim->FREQUENCY = 0;
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_TXSTARTED);
nrf_twim_int_enable(p_twim, NRF_TWIM_INT_TXSTARTED_MASK);
+ }
+ else
+ {
+ nrf_twim_frequency_set(p_twim, p_cb->bus_frequency);
}
#endif
}
else
{
- while (!nrf_twim_event_check(p_twim, evt_to_wait))
- {
+ bool transmission_finished = false;
+ do {
+ if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_SUSPENDED))
+ {
+ NRFX_LOG_DEBUG("TWIM: Event: %s.", EVT_TO_STR_TWIM(NRF_TWIM_EVENT_SUSPENDED));
+ transmission_finished = true;
+ }
+
+ if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_STOPPED))
+ {
+ nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_STOPPED);
+ NRFX_LOG_DEBUG("TWIM: Event: %s.", EVT_TO_STR_TWIM(NRF_TWIM_EVENT_STOPPED));
+ transmission_finished = true;
+ }
+
if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
{
- NRFX_LOG_DEBUG("TWIM: Event: %s.", EVT_TO_STR_TWIM(NRF_TWIM_EVENT_ERROR));
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR);
- nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
- nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP);
- evt_to_wait = NRF_TWIM_EVENT_STOPPED;
+ NRFX_LOG_DEBUG("TWIM: Event: %s.", EVT_TO_STR_TWIM(NRF_TWIM_EVENT_ERROR));
+
+ bool lasttx_triggered = nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_LASTTX);
+ uint32_t shorts_mask = nrf_twim_shorts_get(p_twim);
+
+ if (!(lasttx_triggered && (shorts_mask & NRF_TWIM_SHORT_LASTTX_STOP_MASK)))
+ {
+ // Unless LASTTX event arrived and LASTTX_STOP shortcut is active,
+ // triggering of STOP task in case of error has to be done manually.
+ nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
+ nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP);
+
+ // Mark transmission as not finished yet,
+ // as STOPPED event is expected to arrive.
+ // If LASTTX_SUSPENDED shortcut is active,
+ // NACK has been received on last byte sent
+ // and SUSPENDED event happened to be checked before ERROR,
+ // transmission will be marked as finished.
+ // In such case this flag has to be overwritten.
+ transmission_finished = false;
+ }
+
+ if (lasttx_triggered && (shorts_mask & NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK))
+ {
+ // When STOP task was triggered just before SUSPEND task has taken effect,
+ // SUSPENDED event may not arrive.
+ // However if SUSPENDED arrives it always arrives after ERROR.
+ // Therefore SUSPENDED has to be cleared
+ // so it does not cause premature termination of busy loop
+ // waiting for STOPPED event to arrive.
+ nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_SUSPENDED);
+
+ // Mark transmission as not finished yet,
+ // for same reasons as above.
+ transmission_finished = false;
+ }
}
- }
+ } while (!transmission_finished);
uint32_t errorsrc = nrf_twim_errorsrc_get_and_clear(p_twim);
@@ -533,7 +591,8 @@ static nrfx_err_t twim_xfer(twim_control_block_t * p_cb,
}
else
{
- if (!xfer_completeness_check(p_twim, p_cb))
+ if (!(flags & NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK) &&
+ !xfer_completeness_check(p_twim, p_cb))
{
err_code = NRFX_ERROR_INTERNAL;
}
@@ -626,8 +685,12 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
p_cb->int_mask = NRF_TWIM_INT_STOPPED_MASK;
nrf_twim_int_enable(p_twim, p_cb->int_mask);
- nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
- nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP);
+ if (!(nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_LASTTX) &&
+ (nrf_twim_shorts_get(p_twim) & NRF_TWIM_SHORT_LASTTX_STOP_MASK)))
+ {
+ nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
+ nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP);
+ }
p_cb->error = true;
return;
@@ -640,19 +703,43 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
{
NRFX_LOG_DEBUG("TWIM: Event: %s.", EVT_TO_STR_TWIM(NRF_TWIM_EVENT_STOPPED));
nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_STOPPED);
- event.xfer_desc = p_cb->xfer_desc;
- if (!p_cb->error)
+
+ if (!(p_cb->flags & NRFX_TWIM_FLAG_NO_SPURIOUS_STOP_CHECK) && !p_cb->error)
{
p_cb->error = !xfer_completeness_check(p_twim, p_cb);
}
- nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTTX);
- nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTRX);
- if (!p_cb->repeated || p_cb->error)
+
+ // Further processing of STOPPED event is valid only if NO_XFER_EVT_HANDLER
+ // setting is not used.
+ if (!(p_cb->flags & NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER))
{
- nrf_twim_shorts_set(p_twim, 0);
- p_cb->int_mask = 0;
- nrf_twim_int_disable(p_twim, NRF_TWIM_ALL_INTS_MASK);
+ event.xfer_desc = p_cb->xfer_desc;
+ nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTTX);
+ nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_LASTRX);
+ if (!p_cb->repeated || p_cb->error)
+ {
+ nrf_twim_shorts_set(p_twim, 0);
+ p_cb->int_mask = 0;
+ nrf_twim_int_disable(p_twim, NRF_TWIM_ALL_INTS_MASK);
+
+ // At this point interrupt handler should not be invoked again for current transfer.
+ // If STOPPED arrived during ERROR processing,
+ // its pending interrupt should be ignored.
+ // Otherwise spurious NRFX_TWIM_EVT_DONE or NRFX_TWIM_EVT_BUS_ERROR
+ // would be passed to user's handler.
+ NRFX_IRQ_PENDING_CLEAR(nrfx_get_irq_number(p_twim));
+ }
+ }
+
+#if NRFX_CHECK(NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED)
+ else if (p_cb->xfer_desc.type != NRFX_TWIM_XFER_RX)
+ {
+ /* Add Anomaly 109 workaround for each potential repeated transfer starting from TX. */
+ twim_list_enable_handle(p_twim, 0);
+ p_twim->FREQUENCY = 0;
+ nrf_twim_int_enable(p_twim, NRF_TWIM_INT_TXSTARTED_MASK);
}
+#endif
}
else
{
@@ -666,6 +753,13 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
nrf_twim_shorts_set(p_twim, 0);
p_cb->int_mask = 0;
nrf_twim_int_disable(p_twim, NRF_TWIM_ALL_INTS_MASK);
+
+ // At this point interrupt handler should not be invoked again for current transfer.
+ // If STOPPED arrived during SUSPENDED processing,
+ // its pending interrupt should be ignored.
+ // Otherwise spurious NRFX_TWIM_EVT_DONE or NRFX_TWIM_EVT_BUS_ERROR
+ // would be passed to user's handler.
+ NRFX_IRQ_PENDING_CLEAR(nrfx_get_irq_number(p_twim));
}
}
else
@@ -693,19 +787,17 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
}
else if (errorsrc & NRF_TWIM_ERROR_OVERRUN)
{
- event.type = NRFX_TWIM_EVT_DATA_NACK;
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWIM_EVT_DATA_NACK));
+ event.type = NRFX_TWIM_EVT_OVERRUN;
+ NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWIM_EVT_OVERRUN));
+ }
+ else if (p_cb->error)
+ {
+ event.type = NRFX_TWIM_EVT_BUS_ERROR;
+ NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWIM_EVT_BUS_ERROR));
}
else
{
- if (p_cb->error)
- {
- event.type = NRFX_TWIM_EVT_BUS_ERROR;
- }
- else
- {
- event.type = NRFX_TWIM_EVT_DONE;
- }
+ event.type = NRFX_TWIM_EVT_DONE;
NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWIM_EVT_DONE));
}
@@ -714,7 +806,10 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
p_cb->busy = false;
}
- p_cb->handler(&event, p_cb->p_context);
+ if (!(p_cb->flags & NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER) || p_cb->error)
+ {
+ p_cb->handler(&event, p_cb->p_context);
+ }
}
#if NRFX_CHECK(NRFX_TWIM0_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twis.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twis.c
index 10b827f..9298348 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twis.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_twis.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c
index 64edf86..e8c5a96 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uart.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c
index 64a43e8..88a06d3 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_uarte.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -191,6 +191,38 @@ static void pins_to_default(nrfx_uarte_t const * p_instance)
}
}
+static void apply_workaround_for_enable_anomaly(nrfx_uarte_t const * p_instance)
+{
+#if defined(NRF5340_XXAA_APPLICATION) || defined(NRF5340_XXAA_NETWORK) || defined(NRF9160_XXAA)
+ // Apply workaround for anomalies:
+ // - nRF9160 - anomaly 23
+ // - nRF5340 - anomaly 44
+ volatile uint32_t const * rxenable_reg =
+ (volatile uint32_t *)(((uint32_t)p_instance->p_reg) + 0x564);
+ volatile uint32_t const * txenable_reg =
+ (volatile uint32_t *)(((uint32_t)p_instance->p_reg) + 0x568);
+
+ if (*txenable_reg == 1)
+ {
+ nrf_uarte_task_trigger(p_instance->p_reg, NRF_UARTE_TASK_STOPTX);
+ }
+
+ if (*rxenable_reg == 1)
+ {
+ nrf_uarte_enable(p_instance->p_reg);
+ nrf_uarte_task_trigger(p_instance->p_reg, NRF_UARTE_TASK_STOPRX);
+
+ while (*rxenable_reg)
+ {}
+
+ (void)nrf_uarte_errorsrc_get_and_clear(p_instance->p_reg);
+ nrf_uarte_disable(p_instance->p_reg);
+ }
+#else
+ (void)(p_instance);
+#endif // defined(NRF5340_XXAA_APPLICATION) || defined(NRF5340_XXAA_NETWORK) || defined(NRF9160_XXAA)
+}
+
nrfx_err_t nrfx_uarte_init(nrfx_uarte_t const * p_instance,
nrfx_uarte_config_t const * p_config,
nrfx_uarte_event_handler_t event_handler)
@@ -236,6 +268,8 @@ nrfx_err_t nrfx_uarte_init(nrfx_uarte_t const * p_instance,
apply_config(p_instance, p_config);
+ apply_workaround_for_enable_anomaly(p_instance);
+
p_cb->handler = event_handler;
p_cb->p_context = p_config->p_context;
@@ -258,6 +292,7 @@ nrfx_err_t nrfx_uarte_init(nrfx_uarte_t const * p_instance,
void nrfx_uarte_uninit(nrfx_uarte_t const * p_instance)
{
uarte_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];
+ NRF_UARTE_Type * p_reg = p_instance->p_reg;
if (p_cb->handler)
{
@@ -265,18 +300,28 @@ void nrfx_uarte_uninit(nrfx_uarte_t const * p_instance)
}
// Make sure all transfers are finished before UARTE is disabled
// to achieve the lowest power consumption.
- nrf_uarte_shorts_disable(p_instance->p_reg, NRF_UARTE_SHORT_ENDRX_STARTRX);
- nrf_uarte_task_trigger(p_instance->p_reg, NRF_UARTE_TASK_STOPRX);
- nrf_uarte_event_clear(p_instance->p_reg, NRF_UARTE_EVENT_TXSTOPPED);
- nrf_uarte_task_trigger(p_instance->p_reg, NRF_UARTE_TASK_STOPTX);
- while (!nrf_uarte_event_check(p_instance->p_reg, NRF_UARTE_EVENT_TXSTOPPED))
+ nrf_uarte_shorts_disable(p_reg, NRF_UARTE_SHORT_ENDRX_STARTRX);
+
+ // Check if there is any ongoing reception.
+ if (p_cb->rx_buffer_length)
+ {
+ nrf_uarte_event_clear(p_reg, NRF_UARTE_EVENT_RXTO);
+ nrf_uarte_task_trigger(p_reg, NRF_UARTE_TASK_STOPRX);
+ }
+
+ nrf_uarte_event_clear(p_reg, NRF_UARTE_EVENT_TXSTOPPED);
+ nrf_uarte_task_trigger(p_reg, NRF_UARTE_TASK_STOPTX);
+
+ // Wait for TXSTOPPED event and for RXTO event, provided that there was ongoing reception.
+ while (!nrf_uarte_event_check(p_reg, NRF_UARTE_EVENT_TXSTOPPED) ||
+ (p_cb->rx_buffer_length && !nrf_uarte_event_check(p_reg, NRF_UARTE_EVENT_RXTO)))
{}
- nrf_uarte_disable(p_instance->p_reg);
+ nrf_uarte_disable(p_reg);
pins_to_default(p_instance);
#if NRFX_CHECK(NRFX_PRS_ENABLED)
- nrfx_prs_release(p_instance->p_reg);
+ nrfx_prs_release(p_reg);
#endif
p_cb->state = NRFX_DRV_STATE_UNINITIALIZED;
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c
index 17f3bfc..c0598e0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -809,19 +809,19 @@ static inline void usbd_ep_abort(nrfx_usbd_ep_t ep)
/* Workaround: Disarm the endpoint if there is any data buffered. */
if(ep != NRFX_USBD_EPIN0)
{
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7B6 + (2u * (NRF_USBD_EP_NR_GET(ep) - 1));
- uint8_t temp = *((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7B6 + (2u * (NRF_USBD_EP_NR_GET(ep) - 1));
+ uint8_t temp = *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
temp |= (1U << 1);
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) |= temp;
- (void)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) |= temp;
+ (void)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
}
else
{
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7B4;
- uint8_t temp = *((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7B4;
+ uint8_t temp = *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
temp |= (1U << 2);
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) |= temp;
- (void)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) |= temp;
+ (void)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
}
}
if ((m_ep_dma_waiting | (~m_ep_ready)) & (1U << ep2bit(ep)))
@@ -1466,7 +1466,7 @@ static void usbd_dmareq_process(void)
}
nrfx_systick_delay_us(30);
- while (0 == (0x20 & *((volatile uint32_t *)(NRF_USBD_BASE + 0x474))))
+ while (0 == (0x20 & *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x474))))
{
nrfx_systick_delay_us(2);
}
@@ -1573,54 +1573,54 @@ void nrfx_usbd_irq_handler(void)
{
uint8_t usbi, uoi, uii;
/* Testing */
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7A9;
- uii = (uint8_t)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7A9;
+ uii = (uint8_t)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
if (0 != uii)
{
- uii &= (uint8_t)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ uii &= (uint8_t)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
}
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AA;
- uoi = (uint8_t)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AA;
+ uoi = (uint8_t)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
if (0 != uoi)
{
- uoi &= (uint8_t)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ uoi &= (uint8_t)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
}
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AB;
- usbi = (uint8_t)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AB;
+ usbi = (uint8_t)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
if (0 != usbi)
{
- usbi &= (uint8_t)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ usbi &= (uint8_t)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
}
/* Processing */
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AC;
- uii &= (uint8_t)*((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AC;
+ uii &= (uint8_t)*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
if (0 != uii)
{
uint8_t rb;
m_simulated_dataepstatus |= ((uint32_t)uii) << NRFX_USBD_EPIN_BITPOS_0;
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7A9;
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = uii;
- rb = (uint8_t)*((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7A9;
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) = uii;
+ rb = (uint8_t)*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
NRFX_USBD_LOG_PROTO1_FIX_PRINTF(" uii: 0x%.2x (0x%.2x)", uii, rb);
(void)rb;
}
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AD;
- uoi &= (uint8_t)*((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AD;
+ uoi &= (uint8_t)*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
if (0 != uoi)
{
uint8_t rb;
m_simulated_dataepstatus |= ((uint32_t)uoi) << NRFX_USBD_EPOUT_BITPOS_0;
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AA;
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = uoi;
- rb = (uint8_t)*((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AA;
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) = uoi;
+ rb = (uint8_t)*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
NRFX_USBD_LOG_PROTO1_FIX_PRINTF(" uoi: 0x%.2u (0x%.2x)", uoi, rb);
(void)rb;
}
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AE;
- usbi &= (uint8_t)*((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AE;
+ usbi &= (uint8_t)*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
if (0 != usbi)
{
uint8_t rb;
@@ -1632,9 +1632,9 @@ void nrfx_usbd_irq_handler(void)
{
active |= USBD_INTEN_USBRESET_Msk;
}
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7AB;
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = usbi;
- rb = (uint8_t)*((volatile uint32_t *)(NRF_USBD_BASE + 0x804));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7AB;
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) = usbi;
+ rb = (uint8_t)*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804));
NRFX_USBD_LOG_PROTO1_FIX_PRINTF(" usbi: 0x%.2u (0x%.2x)", usbi, rb);
(void)rb;
}
@@ -1791,8 +1791,8 @@ void nrfx_usbd_enable(void)
if (nrfx_usbd_errata_166())
{
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7E3;
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = 0x40;
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7E3;
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) = 0x40;
__ISB();
__DSB();
}
@@ -2339,9 +2339,9 @@ void nrfx_usbd_transfer_out_drop(nrfx_usbd_ep_t ep)
{
NRFX_CRITICAL_SECTION_ENTER();
m_ep_ready &= ~(1U << ep2bit(ep));
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7C5 + (2u * NRF_USBD_EP_NR_GET(ep));
- *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = 0;
- (void)(*((volatile uint32_t *)(NRF_USBD_BASE + 0x804)));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7C5 + (2u * NRF_USBD_EP_NR_GET(ep));
+ *((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)) = 0;
+ (void)(*((volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x804)));
NRFX_CRITICAL_SECTION_EXIT();
}
else
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd_errata.h b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd_errata.h
index c50d9de..76f0c87 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd_errata.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbd_errata.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
#define NRFX_USBD_ERRATA_H__
#include <stdbool.h>
+#include <nrfx.h>
+#include <nrf_erratas.h>
#ifndef NRFX_USBD_ERRATA_ENABLE
/**
@@ -43,106 +45,46 @@
#define NRFX_USBD_ERRATA_ENABLE 1
#endif
-static inline bool nrfx_usbd_errata_type_52840(void)
-{
- return (*(uint32_t const *)0x10000130UL == 0x8UL);
-}
-
-static inline bool nrfx_usbd_errata_type_52840_eng_a_or_later(void)
-{
- return nrfx_usbd_errata_type_52840();
-}
-
-static inline bool nrfx_usbd_errata_type_52840_eng_b_or_later(void)
-{
- return (nrfx_usbd_errata_type_52840() && (*(uint32_t const *)0x10000134UL >= 0x1UL));
-}
-
-static inline bool nrfx_usbd_errata_type_52840_eng_c_or_later(void)
-{
- return (nrfx_usbd_errata_type_52840() && (*(uint32_t const *)0x10000134UL >= 0x2UL));
-}
-
-static inline bool nrfx_usbd_errata_type_52840_eng_d_or_later(void)
-{
- return (nrfx_usbd_errata_type_52840() && (*(uint32_t const *)0x10000134UL >= 0x3UL));
-}
-
-static inline bool nrfx_usbd_errata_type_52833(void)
-{
- return (*(uint32_t const *)0x10000130UL == 0x0DUL);
-}
-
-static inline bool nrfx_usbd_errata_type_52833_eng_a_or_later(void)
-{
- return nrfx_usbd_errata_type_52833();
-}
-
-/* Errata: USBD: EPDATA event is not always generated.
- *
- * Applies to nRF52840 Engineering A.
- **/
+/* Errata: USBD: EPDATA event is not always generated. **/
static inline bool nrfx_usbd_errata_104(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && (nrfx_usbd_errata_type_52840()
- && !nrfx_usbd_errata_type_52840_eng_b_or_later()));
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_104();
}
-/* Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task.
- *
- * Applies to nRF52840 Engineering A.
- **/
+/* Errata: During setup read/write transfer USBD acknowledges setup stage without SETUP task. **/
static inline bool nrfx_usbd_errata_154(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && (nrfx_usbd_errata_type_52840()
- && !nrfx_usbd_errata_type_52840_eng_b_or_later()));
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_154();
}
-/* Errata: ISO double buffering not functional.
- *
- * Applies to nRF52840.
- **/
+/* Errata: ISO double buffering not functional. **/
static inline bool nrfx_usbd_errata_166(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && nrfx_usbd_errata_type_52840());
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_166();
}
-/* Errata: USBD might not reach its active state.
- *
- * Applies to nRF52840.
- **/
+/* Errata: USBD might not reach its active state. **/
static inline bool nrfx_usbd_errata_171(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && nrfx_usbd_errata_type_52840());
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_171();
}
-/* Errata: USB cannot be enabled.
- *
- * Applies to nRF52840 Engineering B or later and nRF52833.
- **/
+/* Errata: USB cannot be enabled. **/
static inline bool nrfx_usbd_errata_187(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && (nrfx_usbd_errata_type_52840_eng_b_or_later()
- || nrfx_usbd_errata_type_52833()));
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_187();
}
-/* Errata: USBD cannot receive tasks during DMA.
- *
- * Applies to nRF52840.
- **/
+/* Errata: USBD cannot receive tasks during DMA. **/
static inline bool nrfx_usbd_errata_199(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && nrfx_usbd_errata_type_52840());
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_199();
}
-/* Errata: SIZE.EPOUT not writable.
- *
- * Applies to nRF52840 Engineering A.
- **/
+/* Errata: SIZE.EPOUT not writable. **/
static inline bool nrfx_usbd_errata_200(void)
{
- return (NRFX_USBD_ERRATA_ENABLE && (nrfx_usbd_errata_type_52840()
- && !nrfx_usbd_errata_type_52840_eng_b_or_later()));
+ return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_200();
}
#endif // NRFX_USBD_ERRATA_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbreg.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbreg.c
new file mode 100644
index 0000000..abac8b4
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_usbreg.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 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_USBREG_ENABLED)
+
+#include <nrfx_usbreg.h>
+
+static nrfx_usbreg_event_handler_t m_usbevt_handler;
+
+nrfx_usbreg_event_handler_t nrfx_usbreg_handler_get(void)
+{
+ return m_usbevt_handler;
+}
+
+void nrfx_usbreg_init(nrfx_usbreg_config_t const * p_config)
+{
+ NRFX_ASSERT(p_config != NULL);
+ NRFX_ASSERT(p_config->handler != NULL);
+
+ nrfx_usbreg_uninit();
+ m_usbevt_handler = p_config->handler;
+
+ NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(NRF_USBREGULATOR), p_config->irq_priority);
+ NRFX_IRQ_ENABLE(nrfx_get_irq_number(NRF_USBREGULATOR));
+}
+
+void nrfx_usbreg_enable(void)
+{
+ nrf_usbreg_int_enable(NRF_USBREGULATOR, NRF_USBREG_INT_USBDETECTED |
+ NRF_USBREG_INT_USBREMOVED |
+ NRF_USBREG_INT_USBPWRRDY);
+}
+
+void nrfx_usbreg_disable(void)
+{
+ nrf_usbreg_int_disable(NRF_USBREGULATOR, NRF_USBREG_INT_USBDETECTED |
+ NRF_USBREG_INT_USBREMOVED |
+ NRF_USBREG_INT_USBPWRRDY);
+}
+
+void nrfx_usbreg_uninit(void)
+{
+ nrfx_usbreg_disable();
+ NRFX_IRQ_DISABLE(nrfx_get_irq_number(NRF_USBREGULATOR));
+ m_usbevt_handler = NULL;
+}
+
+void nrfx_usbreg_irq_handler(void)
+{
+ if (nrf_usbreg_event_check(NRF_USBREGULATOR, NRF_USBREG_EVENT_USBDETECTED))
+ {
+ nrf_usbreg_event_clear(NRF_USBREGULATOR, NRF_USBREG_EVENT_USBDETECTED);
+ m_usbevt_handler(NRFX_USBREG_EVT_DETECTED);
+ }
+ if (nrf_usbreg_event_check(NRF_USBREGULATOR, NRF_USBREG_EVENT_USBREMOVED))
+ {
+ nrf_usbreg_event_clear(NRF_USBREGULATOR, NRF_USBREG_EVENT_USBREMOVED);
+ m_usbevt_handler(NRFX_USBREG_EVT_REMOVED);
+ }
+ if (nrf_usbreg_event_check(NRF_USBREGULATOR, NRF_USBREG_EVENT_USBPWRRDY))
+ {
+ nrf_usbreg_event_clear(NRF_USBREGULATOR, NRF_USBREG_EVENT_USBPWRRDY);
+ m_usbevt_handler(NRFX_USBREG_EVT_READY);
+ }
+}
+
+#endif // NRFX_CHECK(NRFX_USBREG_ENABLED)
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c
index 863b3ac..63dec1c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/nrfx_wdt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.c b/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.c
index 4eaf178..37de8b9 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.c
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h b/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h
index 693b273..2767b54 100644
--- a/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h
+++ b/hw/mcu/nordic/src/ext/nrfx/drivers/src/prs/nrfx_prs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -82,8 +82,12 @@ extern "C" {
#define NRFX_PRS_BOX_0_ADDR NRF_UARTE0
// SPIM1, SPIS1, TWIM1, TWIS1, UARTE1
#define NRFX_PRS_BOX_1_ADDR NRF_UARTE1
+ // SPIM2, SPIS2, TWIM2, TWIS2, UARTE2
+ #define NRFX_PRS_BOX_2_ADDR NRF_UARTE2
+ // SPIM3, SPIS3, TWIM3, TWIS3, UARTE3
+ #define NRFX_PRS_BOX_3_ADDR NRF_UARTE3
// COMP, LPCOMP
- #define NRFX_PRS_BOX_2_ADDR NRF_COMP
+ #define NRFX_PRS_BOX_4_ADDR NRF_COMP
#elif defined(NRF5340_XXAA_NETWORK)
// SPIM0, SPIS0, TWIM0, TWIS0, UARTE0
#define NRFX_PRS_BOX_0_ADDR NRF_UARTE0
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h
index 6d2828b..0b35fae 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_aar.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h
index d07b52d..b205a2e 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_acl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h
index 951a4a9..2313130 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_adc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h
index bbb97d1..18d8247 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_bprot.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,8 +67,7 @@ NRF_STATIC_INLINE void nrf_bprot_nvm_blocks_protection_enable(NRF_BPROT_Type * p
* NVM protection is disabled by default while debugging.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable True if NVM protection during debug is to be enabled.
- * False if otherwise.
+ * @param[in] enable True if NVM protection during debug is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_bprot_nvm_protection_in_debug_set(NRF_BPROT_Type * p_reg,
bool enable);
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h
index dd1ff43..28d5b79 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_cache.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -101,8 +101,7 @@ NRF_STATIC_INLINE void nrf_cache_erase_status_clear(NRF_CACHE_Type * p_reg);
* @brief Function for setting the cache profiling.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable True if cache profiling is to be enabled.
- * False if otherwise.
+ * @param[in] enable True if cache profiling is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_cache_profiling_set(NRF_CACHE_Type * p_reg, bool enable);
@@ -184,8 +183,7 @@ NRF_STATIC_INLINE uint32_t nrf_cache_data_miss_counter_get(NRF_CACHE_Type const
* @note -Disabling the RAM mode causes the cache to be invalidated.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable True if the cache RAM mode is to be enabled.
- * False if otherwise.
+ * @param[in] enable True if the cache RAM mode is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_cache_ram_mode_set(NRF_CACHE_Type * p_reg, bool enable);
@@ -210,8 +208,7 @@ NRF_STATIC_INLINE void nrf_cache_read_lock_enable(NRF_CACHE_Type * p_reg);
* @note Blocking is ignored in the RAM mode.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable True if cache content update lock is to be enabled.
- * False if otherwise.
+ * @param[in] enable True if cache content update lock is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_cache_update_lock_set(NRF_CACHE_Type * p_reg, bool enable);
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h
index 7813046..189eca2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ccm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -421,7 +421,12 @@ NRF_STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
NRF_STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg)
{
+#if defined(NRF5340_XXAA_NETWORK)
+ // Apply workaround for anomaly 10.
+ return (uint32_t *)(p_reg->CNFPTR | 0x01000000);
+#else
return (uint32_t *)(p_reg->CNFPTR);
+#endif
}
NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
@@ -432,7 +437,12 @@ NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
NRF_STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg)
{
+#if defined(NRF5340_XXAA_NETWORK)
+ // Apply workaround for anomaly 10.
+ return (uint32_t *)(p_reg->INPTR | 0x01000000);
+#else
return (uint32_t *)(p_reg->INPTR);
+#endif
}
NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
@@ -443,7 +453,12 @@ NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
NRF_STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg)
{
+#if defined(NRF5340_XXAA_NETWORK)
+ // Apply workaround for anomaly 10.
+ return (uint32_t *)(p_reg->OUTPTR | 0x01000000);
+#else
return (uint32_t *)(p_reg->OUTPTR);
+#endif
}
NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
@@ -454,7 +469,12 @@ NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
NRF_STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg)
{
+#if defined(NRF5340_XXAA_NETWORK)
+ // Apply workaround for anomaly 10.
+ return (uint32_t *)(p_reg->SCRATCHPTR | 0x01000000);
+#else
return (uint32_t *)(p_reg->SCRATCHPTR);
+#endif
}
#if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos)
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h
index 0169f82..553e19b 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_clock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,8 +44,9 @@ extern "C" {
* @ingroup nrf_clock
* @brief Hardware access layer for managing the CLOCK peripheral.
*
- * This code can be used to managing low-frequency clock (LFCLK) and the high-frequency clock
- * (HFCLK) settings.
+ * This code can be used to manage low-frequency clock (LFCLK), high-frequency clock (HFCLK),
+ * high-frequency 192 MHz clock (HFCLK192M) and high-frequency audio clock (HFCLKAUDIO)
+ * settings.
*/
#if defined(CLOCK_LFCLKSRC_BYPASS_Msk) && defined(CLOCK_LFCLKSRC_EXTERNAL_Msk)
@@ -53,16 +54,57 @@ extern "C" {
#define NRF_CLOCK_USE_EXTERNAL_LFCLK_SOURCES
#endif
-#if defined(CLOCK_CTIV_CTIV_Msk) || defined(__NRFX_DOXYGEN__)
-/**
- * @brief Presence of the Low Frequency Clock calibration.
- *
- * In some MCUs there is possibility to use LFCLK calibration.
- */
+#if defined(CLOCK_INTENSET_DONE_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of the Low Frequency Clock calibration. */
#define NRF_CLOCK_HAS_CALIBRATION 1
#else
#define NRF_CLOCK_HAS_CALIBRATION 0
-#endif // defined(CLOCK_CTIV_CTIV_Msk) || defined(__NRFX_DOXYGEN__)
+#endif
+
+#if defined(CLOCK_CTIV_CTIV_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of the Low Frequency Clock calibration timer. */
+#define NRF_CLOCK_HAS_CALIBRATION_TIMER 1
+#else
+#define NRF_CLOCK_HAS_CALIBRATION_TIMER 0
+#endif
+
+#if (defined(CLOCK_INTENSET_HFCLK192MSTARTED_Msk) && !defined(NRF5340_XXAA_NETWORK)) \
+ || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of the 192 MHz clock. */
+#define NRF_CLOCK_HAS_HFCLK192M 1
+#else
+#define NRF_CLOCK_HAS_HFCLK192M 0
+#endif
+
+#if (defined(CLOCK_INTENSET_HFCLKAUDIOSTARTED_Msk) && !defined(NRF5340_XXAA_NETWORK)) \
+ || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of the Audio clock. */
+#define NRF_CLOCK_HAS_HFCLKAUDIO 1
+#else
+#define NRF_CLOCK_HAS_HFCLKAUDIO 0
+#endif
+
+#if (defined(CLOCK_HFCLKCTRL_HCLK_Msk) && !defined(NRF5340_XXAA_NETWORK)) \
+ || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of HFCLK frequency configuration. */
+#define NRF_CLOCK_HAS_HFCLK_DIV 1
+#else
+#define NRF_CLOCK_HAS_HFCLK_DIV 0
+#endif
+
+#if defined(CLOCK_LFCLKALWAYSRUN_ALWAYSRUN_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of ALWAYSRUN registers. */
+#define NRF_CLOCK_HAS_ALWAYSRUN 1
+#else
+#define NRF_CLOCK_HAS_ALWAYSRUN 0
+#endif
+
+#if defined(CLOCK_HFCLKSRC_SRC_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Presence of HFCLKSRC register. */
+#define NRF_CLOCK_HAS_HFCLKSRC 1
+#else
+#define NRF_CLOCK_HAS_HFCLKSRC 0
+#endif
/**
* @brief Low-frequency clock sources.
@@ -70,6 +112,9 @@ extern "C" {
*/
typedef enum
{
+#if defined(CLOCK_LFCLKSRC_SRC_LFULP) || defined(__NRFX_DOXYGEN__)
+ NRF_CLOCK_LFCLK_LFULP = CLOCK_LFCLKSRC_SRC_LFULP, /**< Internal 32 kHz Ultra-low power oscillator. */
+#endif
#if defined(CLOCK_LFCLKSRC_SRC_RC) || defined(__NRFX_DOXYGEN__)
NRF_CLOCK_LFCLK_RC = CLOCK_LFCLKSRC_SRC_RC, /**< Internal 32 kHz RC oscillator. */
#else
@@ -102,11 +147,16 @@ typedef enum
#endif // defined(NRF_CLOCK_USE_EXTERNAL_LFCLK_SOURCES) || defined(__NRFX_DOXYGEN__)
} nrf_clock_lfclk_t;
-/** @brief High-frequency clock sources. */
+/**
+ * @brief High-frequency clock sources.
+ * @details Used by HFCLKSTAT and HFCLK192MSTAT registers.
+ */
typedef enum
{
#if defined(CLOCK_HFCLKSTAT_SRC_RC) || defined(__NRFX_DOXYGEN__)
NRF_CLOCK_HFCLK_LOW_ACCURACY = CLOCK_HFCLKSTAT_SRC_RC, /**< Internal 16 MHz RC oscillator. */
+#elif defined(CLOCK_HFCLKSTAT_SRC_HFINT)
+ NRF_CLOCK_HFCLK_LOW_ACCURACY = CLOCK_HFCLKSTAT_SRC_HFINT, /**< Internal 16 MHz RC oscillator. */
#endif
#if defined(CLOCK_HFCLKSTAT_SRC_Xtal) || defined(__NRFX_DOXYGEN__)
NRF_CLOCK_HFCLK_HIGH_ACCURACY = CLOCK_HFCLKSTAT_SRC_Xtal /**< External 16 MHz/32 MHz crystal oscillator. */
@@ -115,8 +165,39 @@ typedef enum
#endif
} nrf_clock_hfclk_t;
+/** @brief Clock domains. */
+typedef enum
+{
+ NRF_CLOCK_DOMAIN_LFCLK,
+ NRF_CLOCK_DOMAIN_HFCLK,
+#if NRF_CLOCK_HAS_HFCLK192M
+ NRF_CLOCK_DOMAIN_HFCLK192M,
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ NRF_CLOCK_DOMAIN_HFCLKAUDIO,
+#endif
+} nrf_clock_domain_t;
+
+#if NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK192M
+/**
+ * @brief High-frequency clock frequency configuration.
+ * @details Used by HFCLKCTRL and HFCLK192MCTRL registers.
+ */
+typedef enum
+{
+ NRF_CLOCK_HFCLK_DIV_1 = CLOCK_HFCLKCTRL_HCLK_Div1, /**< Divide HFCLK/HFCLK192M by 1 */
+ NRF_CLOCK_HFCLK_DIV_2 = CLOCK_HFCLKCTRL_HCLK_Div2, /**< Divide HFCLK/HFCLK192M by 2 */
+#if NRF_CLOCK_HAS_HFCLK192M
+ NRF_CLOCK_HFCLK_DIV_4 = CLOCK_HFCLK192MCTRL_HCLK192M_Div4, /**< Divide HFCLK192M by 4 */
+#endif
+} nrf_clock_hfclk_div_t;
+#endif // NRF_CLOCK_HAS_HFCLK_DIV || NRF_CLOCK_HAS_HFCLK192M
+
/**
* @brief Trigger status of task LFCLKSTART/HFCLKSTART.
+ *
+ * @note This enum is deprecated.
+ *
* @details Used by LFCLKRUN and HFCLKRUN registers.
*/
typedef enum
@@ -128,15 +209,24 @@ typedef enum
/** @brief Interrupts. */
typedef enum
{
- NRF_CLOCK_INT_HF_STARTED_MASK = CLOCK_INTENSET_HFCLKSTARTED_Msk, /**< Interrupt on HFCLKSTARTED event. */
- NRF_CLOCK_INT_LF_STARTED_MASK = CLOCK_INTENSET_LFCLKSTARTED_Msk, /**< Interrupt on LFCLKSTARTED event. */
-#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
- NRF_CLOCK_INT_DONE_MASK = CLOCK_INTENSET_DONE_Msk, /**< Interrupt on DONE event. */
- NRF_CLOCK_INT_CTTO_MASK = CLOCK_INTENSET_CTTO_Msk, /**< Interrupt on CTTO event. */
+ NRF_CLOCK_INT_HF_STARTED_MASK = CLOCK_INTENSET_HFCLKSTARTED_Msk, /**< Interrupt on HFCLKSTARTED event. */
+ NRF_CLOCK_INT_LF_STARTED_MASK = CLOCK_INTENSET_LFCLKSTARTED_Msk, /**< Interrupt on LFCLKSTARTED event. */
+#if NRF_CLOCK_HAS_CALIBRATION
+ NRF_CLOCK_INT_DONE_MASK = CLOCK_INTENSET_DONE_Msk, /**< Interrupt on DONE event. */
+#endif
+#if NRF_CLOCK_HAS_CALIBRATION_TIMER
+ NRF_CLOCK_INT_CTTO_MASK = CLOCK_INTENSET_CTTO_Msk, /**< Interrupt on CTTO event. */
#endif
#if defined(CLOCK_INTENSET_CTSTARTED_Msk) || defined(__NRFX_DOXYGEN__)
- NRF_CLOCK_INT_CTSTARTED_MASK = CLOCK_INTENSET_CTSTARTED_Msk, /**< Interrupt on CTSTARTED event. */
- NRF_CLOCK_INT_CTSTOPPED_MASK = CLOCK_INTENSET_CTSTOPPED_Msk /**< Interrupt on CTSTOPPED event. */
+ NRF_CLOCK_INT_CTSTARTED_MASK = CLOCK_INTENSET_CTSTARTED_Msk, /**< Interrupt on CTSTARTED event. */
+ NRF_CLOCK_INT_CTSTOPPED_MASK = CLOCK_INTENSET_CTSTOPPED_Msk /**< Interrupt on CTSTOPPED event. */
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ NRF_CLOCK_INT_HFAUDIO_STARTED_MASK = CLOCK_INTENSET_HFCLKAUDIOSTARTED_Msk, /**< Interrupt on HFCLKAUDIOSTARTED event. */
+#endif
+
+#if NRF_CLOCK_HAS_HFCLK192M
+ NRF_CLOCK_INT_HF192M_STARTED_MASK = CLOCK_INTENSET_HFCLK192MSTARTED_Msk, /**< Interrupt on HFCLK192MSTARTED event. */
#endif
} nrf_clock_int_mask_t;
@@ -148,29 +238,47 @@ typedef enum
*/
typedef enum
{
- NRF_CLOCK_TASK_HFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTART), /**< Start HFCLK clock source.*/
- NRF_CLOCK_TASK_HFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTOP), /**< Stop HFCLK clock source.*/
- NRF_CLOCK_TASK_LFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTART), /**< Start LFCLK clock source.*/
- NRF_CLOCK_TASK_LFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTOP), /**< Stop LFCLK clock source.*/
-#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
- NRF_CLOCK_TASK_CAL = offsetof(NRF_CLOCK_Type, TASKS_CAL), /**< Start calibration of LFCLK RC oscillator.*/
- NRF_CLOCK_TASK_CTSTART = offsetof(NRF_CLOCK_Type, TASKS_CTSTART), /**< Start calibration timer.*/
- NRF_CLOCK_TASK_CTSTOP = offsetof(NRF_CLOCK_Type, TASKS_CTSTOP) /**< Stop calibration timer.*/
+ NRF_CLOCK_TASK_HFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTART), /**< Start HFCLK clock source. */
+ NRF_CLOCK_TASK_HFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLKSTOP), /**< Stop HFCLK clock source. */
+ NRF_CLOCK_TASK_LFCLKSTART = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTART), /**< Start LFCLK clock source. */
+ NRF_CLOCK_TASK_LFCLKSTOP = offsetof(NRF_CLOCK_Type, TASKS_LFCLKSTOP), /**< Stop LFCLK clock source. */
+#if NRF_CLOCK_HAS_CALIBRATION
+ NRF_CLOCK_TASK_CAL = offsetof(NRF_CLOCK_Type, TASKS_CAL), /**< Start calibration of LFCLK RC oscillator. */
+#endif
+#if NRF_CLOCK_HAS_CALIBRATION_TIMER
+ NRF_CLOCK_TASK_CTSTART = offsetof(NRF_CLOCK_Type, TASKS_CTSTART), /**< Start calibration timer. */
+ NRF_CLOCK_TASK_CTSTOP = offsetof(NRF_CLOCK_Type, TASKS_CTSTOP) /**< Stop calibration timer. */
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ NRF_CLOCK_TASK_HFCLKAUDIOSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLKAUDIOSTART), /**< Start HFCLKAUDIO clock source. */
+ NRF_CLOCK_TASK_HFCLKAUDIOSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLKAUDIOSTOP), /**< Stop HFCLKAUDIO clock source. */
+#endif
+#if NRF_CLOCK_HAS_HFCLK192M
+ NRF_CLOCK_TASK_HFCLK192MSTART = offsetof(NRF_CLOCK_Type, TASKS_HFCLK192MSTART), /**< Start HFCLK192M clock source. */
+ NRF_CLOCK_TASK_HFCLK192MSTOP = offsetof(NRF_CLOCK_Type, TASKS_HFCLK192MSTOP), /**< Stop HFCLK192M clock source. */
#endif
} nrf_clock_task_t;
/** @brief Events. */
typedef enum
{
- NRF_CLOCK_EVENT_HFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLKSTARTED), /**< HFCLK oscillator started.*/
- NRF_CLOCK_EVENT_LFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_LFCLKSTARTED), /**< LFCLK oscillator started.*/
-#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
- NRF_CLOCK_EVENT_DONE = offsetof(NRF_CLOCK_Type, EVENTS_DONE), /**< Calibration of LFCLK RC oscillator completed.*/
- NRF_CLOCK_EVENT_CTTO = offsetof(NRF_CLOCK_Type, EVENTS_CTTO), /**< Calibration timer time-out.*/
+ NRF_CLOCK_EVENT_HFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLKSTARTED), /**< HFCLK oscillator started. */
+ NRF_CLOCK_EVENT_LFCLKSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_LFCLKSTARTED), /**< LFCLK oscillator started. */
+#if NRF_CLOCK_HAS_CALIBRATION
+ NRF_CLOCK_EVENT_DONE = offsetof(NRF_CLOCK_Type, EVENTS_DONE), /**< Calibration of LFCLK RC oscillator completed. */
+#endif
+#if NRF_CLOCK_HAS_CALIBRATION_TIMER
+ NRF_CLOCK_EVENT_CTTO = offsetof(NRF_CLOCK_Type, EVENTS_CTTO), /**< Calibration timer time-out. */
#endif
#if defined(CLOCK_INTENSET_CTSTARTED_Msk) || defined(__NRFX_DOXYGEN__)
- NRF_CLOCK_EVENT_CTSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_CTSTARTED), /**< Calibration timer started.*/
- NRF_CLOCK_EVENT_CTSTOPPED = offsetof(NRF_CLOCK_Type, EVENTS_CTSTOPPED) /**< Calibration timer stopped.*/
+ NRF_CLOCK_EVENT_CTSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_CTSTARTED), /**< Calibration timer started. */
+ NRF_CLOCK_EVENT_CTSTOPPED = offsetof(NRF_CLOCK_Type, EVENTS_CTSTOPPED) /**< Calibration timer stopped. */
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ NRF_CLOCK_EVENT_HFCLKAUDIOSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLKAUDIOSTARTED), /**< HFCLKAUDIO oscillator started. */
+#endif
+#if NRF_CLOCK_HAS_HFCLK192M
+ NRF_CLOCK_EVENT_HFCLK192MSTARTED = offsetof(NRF_CLOCK_Type, EVENTS_HFCLK192MSTARTED), /**< HFCLK192M oscillator started. */
#endif
} nrf_clock_event_t;
@@ -252,8 +360,37 @@ NRF_STATIC_INLINE void nrf_clock_event_clear(NRF_CLOCK_Type * p_reg, nrf_clock_e
NRF_STATIC_INLINE bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_clock_event_t event);
/**
+ * @brief Function for retrieving the trigger status of the task START for given domain.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] domain Clock domain.
+ *
+ * @retval false The task START for the given domain has not been triggered.
+ * @retval true The task START for the given domain has been triggered.
+ */
+NRF_STATIC_INLINE bool nrf_clock_start_task_check(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain);
+
+/**
+ * @brief Function for retrieving the state of the clock.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] domain Clock domain.
+ * @param[out] clk_src Clock source that is running. Set to NULL if not needed.
+ * Ignored for HFCLKAUDIO domain. Typecast it to @ref nrf_clock_lfclk_t for
+ * LFCLK and @ref nrf_clock_hfclk_t for HFCLK and HFCLK192M.
+ *
+ * @retval false The clock is not running.
+ * @retval true The clock is running.
+ */
+NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain,
+ void * clk_src);
+
+/**
* @brief Function for changing the low-frequency clock source.
- * @details This function cannot be called when the low-frequency clock is running.
+ * @details Check in Product Specification if this function can be called when
+ * the low-frequency clock is running.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
* @param[in] source New low-frequency clock source.
@@ -277,6 +414,8 @@ NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const *
/**
* @brief Function for retrieving the active source of the low-frequency clock.
*
+ * @note This function is deprecated. Use @ref nrf_clock_is_running instead.
+ *
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
*
* @retval NRF_CLOCK_LFCLK_RC The internal 32 kHz RC oscillator
@@ -306,6 +445,8 @@ NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(NRF_CLOCK_Type cons
/**
* @brief Function for retrieving the state of the LFCLK clock.
*
+ * @note This function is deprecated. Use @ref nrf_clock_is_running instead.
+ *
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
*
* @retval false The LFCLK clock is not running.
@@ -316,6 +457,8 @@ NRF_STATIC_INLINE bool nrf_clock_lf_is_running(NRF_CLOCK_Type const * p_reg);
/**
* @brief Function for retrieving the trigger status of the task LFCLKSTART.
*
+ * @note This function is deprecated. Use @ref nrf_clock_start_task_check instead.
+ *
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
*
* @retval NRF_CLOCK_START_TASK_NOT_TRIGGERED The task LFCLKSTART has not been triggered.
@@ -324,14 +467,27 @@ NRF_STATIC_INLINE bool nrf_clock_lf_is_running(NRF_CLOCK_Type const * p_reg);
NRF_STATIC_INLINE
nrf_clock_start_task_status_t nrf_clock_lf_start_task_status_get(NRF_CLOCK_Type const * p_reg);
+#if NRF_CLOCK_HAS_HFCLKSRC
+/**
+ * @brief Function for changing the high-frequency clock source.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] source New high-frequency clock source.
+ */
+NRF_STATIC_INLINE void nrf_clock_hf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_hfclk_t source);
+#endif
+
/**
- * @brief Function for retrieving the active source of the high-frequency clock.
+ * @brief Function for retrieving the selected source of the high-frequency clock.
+ *
+ * For SoCs not featuring the HFCLKSRC register, this is always also the active source
+ * of the high-frequency clock.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
*
- * @retval NRF_CLOCK_HFCLK_LOW_ACCURACY The internal RC oscillator is the active
+ * @retval NRF_CLOCK_HFCLK_LOW_ACCURACY The internal RC oscillator is the selected
* source of the high-frequency clock.
- * @retval NRF_CLOCK_HFCLK_HIGH_ACCURACY An external crystal oscillator is the active
+ * @retval NRF_CLOCK_HFCLK_HIGH_ACCURACY An external crystal oscillator is the selected
* source of the high-frequency clock.
*/
NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(NRF_CLOCK_Type const * p_reg);
@@ -339,6 +495,8 @@ NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(NRF_CLOCK_Type const *
/**
* @brief Function for retrieving the state of the HFCLK clock.
*
+ * @note This function is deprecated. Use @ref nrf_clock_is_running instead.
+ *
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
* @param[in] clk_src Clock source to be checked.
*
@@ -351,6 +509,8 @@ NRF_STATIC_INLINE bool nrf_clock_hf_is_running(NRF_CLOCK_Type const * p_reg,
/**
* @brief Function for retrieving the trigger status of the task HFCLKSTART.
*
+ * @note This function is deprecated. Use @ref nrf_clock_start_task_check instead.
+ *
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
*
* @retval NRF_CLOCK_START_TASK_NOT_TRIGGERED The task HFCLKSTART has not been triggered.
@@ -359,7 +519,38 @@ NRF_STATIC_INLINE bool nrf_clock_hf_is_running(NRF_CLOCK_Type const * p_reg,
NRF_STATIC_INLINE
nrf_clock_start_task_status_t nrf_clock_hf_start_task_status_get(NRF_CLOCK_Type const * p_reg);
-#if (NRF_CLOCK_HAS_CALIBRATION) || defined(__NRFX_DOXYGEN__)
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+/**
+ * @brief Function for changing the Audio clock FREQ_VALUE.
+ *
+ * The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps.
+ * To calculate @p freq_value corresponding to the chosen frequency, use the following equation:
+ * FREQ_VALUE = 2^16 * ((12 * f_out / 32M) - 4)
+ *
+ * @warning Chosen frequency must fit in 11.176 MHz - 11.402 MHz or 12.165 MHz - 12.411 MHz frequency bands.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] freq_value New FREQ_VALUE
+ */
+NRF_STATIC_INLINE
+void nrf_clock_hfclkaudio_config_set(NRF_CLOCK_Type * p_reg, uint16_t freq_value);
+
+/**
+ * @brief Function for retrieving the Audio clock FREQ_VALUE.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * The frequency of HFCLKAUDIO ranges from 10.666 MHz to 13.333 MHz in 40.7 Hz steps.
+ * To calculate frequency corresponding to the returned FREQ_VALUE, use the following equation:
+ * f_out = 32M * (4 + FREQ_VALUE * 2^(-16))/12
+
+ * @return FREQ_VALUE of the Audio clock.
+ */
+NRF_STATIC_INLINE
+uint16_t nrf_clock_hfclkaudio_config_get(NRF_CLOCK_Type const * p_reg);
+#endif
+
+#if NRF_CLOCK_HAS_CALIBRATION_TIMER
/**
* @brief Function for changing the calibration timer interval.
*
@@ -370,6 +561,102 @@ nrf_clock_start_task_status_t nrf_clock_hf_start_task_status_get(NRF_CLOCK_Type
NRF_STATIC_INLINE void nrf_clock_cal_timer_timeout_set(NRF_CLOCK_Type * p_reg, uint32_t interval);
#endif
+#if NRF_CLOCK_HAS_HFCLK_DIV
+/**
+ * @brief Function for changing the HFCLK frequency divider.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] divider New HFCLK divider.
+ */
+NRF_STATIC_INLINE void nrf_clock_hfclk_div_set(NRF_CLOCK_Type * p_reg,
+ nrf_clock_hfclk_div_t divider);
+
+/**
+ * @brief Function for retrieving the HFCLK frequency divider.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return HFCLK frequency divider.
+ */
+NRF_STATIC_INLINE nrf_clock_hfclk_div_t nrf_clock_hfclk_div_get(NRF_CLOCK_Type const * p_reg);
+#endif
+
+#if NRF_CLOCK_HAS_HFCLK192M
+/**
+ * @brief Function for changing the HFCLK192M frequency divider.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] divider New HFCLK192M divider.
+ */
+NRF_STATIC_INLINE void nrf_clock_hfclk192m_div_set(NRF_CLOCK_Type * p_reg,
+ nrf_clock_hfclk_div_t divider);
+
+/**
+ * @brief Function for retrieving the HFCLK192M frequency divider.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return HFCLK192M frequency divider.
+ */
+NRF_STATIC_INLINE nrf_clock_hfclk_div_t nrf_clock_hfclk192m_div_get(NRF_CLOCK_Type const * p_reg);
+
+/**
+ * @brief Function for changing the HFCLK192M source.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] source New HFCLK192M source.
+ */
+NRF_STATIC_INLINE void nrf_clock_hfclk192m_src_set(NRF_CLOCK_Type * p_reg,
+ nrf_clock_hfclk_t source);
+
+/**
+ * @brief Function for retrieving the selected source of the HFCLK192M.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @retval NRF_CLOCK_HFCLK_LOW_ACCURACY The internal RC oscillator is the selected
+ * source of the HFCLK192M.
+ * @retval NRF_CLOCK_HFCLK_HIGH_ACCURACY An external crystal oscillator is the selected
+ * source of the HFCLK192M.
+ */
+NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hfclk192m_src_get(NRF_CLOCK_Type const * p_reg);
+#endif // NRF_CLOCK_HAS_HFCLK192M
+
+#if NRF_CLOCK_HAS_ALWAYSRUN
+/**
+ * @brief Function for setting the clock domain to always run.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] domain Clock domain.
+ * @param[in] alwaysrun Ensure the clock is always running.
+ */
+NRF_STATIC_INLINE void nrf_clock_alwaysrun_set(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain,
+ bool alwaysrun);
+/**
+ * @brief Function for checking if the clock domain is configured to always run.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] domain Clock domain.
+ *
+ * @retval true The clock domain is configured to always run.
+ * @retval false The clock domain is not configured to always run.
+ */
+NRF_STATIC_INLINE bool nrf_clock_alwaysrun_get(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain);
+/**
+ * @brief Function for checking if the clock domain always run setting is active.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] domain Clock domain.
+ *
+ * @retval true The clock domain always run setting is active.
+ * @retval false The clock domain always run setting is not active.
+ */
+NRF_STATIC_INLINE bool nrf_clock_alwaysrun_active_get(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain);
+#endif
+
#if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
/**
* @brief Function for setting the subscribe configuration for a given
@@ -462,6 +749,89 @@ NRF_STATIC_INLINE bool nrf_clock_event_check(NRF_CLOCK_Type const * p_reg, nrf_c
return (bool)*((volatile uint32_t *)((uint8_t *)p_reg + event));
}
+NRF_STATIC_INLINE bool nrf_clock_start_task_check(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain)
+{
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ return ((p_reg->LFCLKRUN & CLOCK_LFCLKRUN_STATUS_Msk)
+ >> CLOCK_LFCLKRUN_STATUS_Pos);
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ return ((p_reg->HFCLKRUN & CLOCK_HFCLKRUN_STATUS_Msk)
+ >> CLOCK_HFCLKRUN_STATUS_Pos);
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ return ((p_reg->HFCLK192MRUN & CLOCK_HFCLK192MRUN_STATUS_Msk)
+ >> CLOCK_HFCLK192MRUN_STATUS_Pos);
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ return ((p_reg->HFCLKAUDIORUN & CLOCK_HFCLKAUDIORUN_STATUS_Msk)
+ >> CLOCK_HFCLKAUDIORUN_STATUS_Pos);
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return false;
+ }
+}
+
+NRF_STATIC_INLINE bool nrf_clock_is_running(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain,
+ void * clk_src)
+{
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ if (clk_src != NULL)
+ {
+ (*(uint32_t *)clk_src) = ((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk)
+ >> CLOCK_LFCLKSTAT_SRC_Pos);
+ }
+ if ((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_STATE_Msk)
+ >> CLOCK_LFCLKSTAT_STATE_Pos)
+ {
+ return true;
+ }
+ break;
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ if (clk_src != NULL)
+ {
+ (*(uint32_t *)clk_src) = ((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_SRC_Msk)
+ >> CLOCK_HFCLKSTAT_SRC_Pos);
+ }
+ if ((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk)
+ >> CLOCK_HFCLKSTAT_STATE_Pos)
+ {
+ return true;
+ }
+ break;
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ if (clk_src != NULL)
+ {
+ (*(uint32_t *)clk_src) = ((p_reg->HFCLK192MSTAT & CLOCK_HFCLK192MSTAT_SRC_Msk)
+ >> CLOCK_HFCLK192MSTAT_SRC_Pos);
+ }
+ if ((p_reg->HFCLK192MSTAT & CLOCK_HFCLK192MSTAT_STATE_Msk)
+ >> CLOCK_HFCLK192MSTAT_STATE_Pos)
+ {
+ return true;
+ }
+ break;
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ return (p_reg->HFCLKAUDIOSTAT & CLOCK_HFCLKAUDIOSTAT_STATE_Msk) ==
+ CLOCK_HFCLKAUDIOSTAT_STATE_Msk;
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return false;
+ }
+ return false;
+}
+
NRF_STATIC_INLINE void nrf_clock_lf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_lfclk_t source)
{
p_reg->LFCLKSRC = (uint32_t)(source);
@@ -474,8 +844,9 @@ NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_src_get(NRF_CLOCK_Type const *
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_actv_src_get(NRF_CLOCK_Type const * p_reg)
{
- return (nrf_clock_lfclk_t)((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk)
- >> CLOCK_LFCLKSTAT_SRC_Pos);
+ nrf_clock_lfclk_t clk_src;
+ (void)nrf_clock_is_running(p_reg, NRF_CLOCK_DOMAIN_LFCLK, &clk_src);
+ return clk_src;
}
NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(NRF_CLOCK_Type const * p_reg)
@@ -486,43 +857,203 @@ NRF_STATIC_INLINE nrf_clock_lfclk_t nrf_clock_lf_srccopy_get(NRF_CLOCK_Type cons
NRF_STATIC_INLINE bool nrf_clock_lf_is_running(NRF_CLOCK_Type const * p_reg)
{
- return ((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_STATE_Msk) >> CLOCK_LFCLKSTAT_STATE_Pos);
+ return nrf_clock_is_running(p_reg, NRF_CLOCK_DOMAIN_LFCLK, NULL);
}
NRF_STATIC_INLINE
nrf_clock_start_task_status_t nrf_clock_lf_start_task_status_get(NRF_CLOCK_Type const * p_reg)
{
- return (nrf_clock_start_task_status_t)((p_reg->LFCLKRUN & CLOCK_LFCLKRUN_STATUS_Msk)
- >> CLOCK_LFCLKRUN_STATUS_Pos);
+ return (nrf_clock_start_task_status_t)nrf_clock_start_task_check(p_reg,
+ NRF_CLOCK_DOMAIN_LFCLK);
+}
+
+#if NRF_CLOCK_HAS_HFCLKSRC
+NRF_STATIC_INLINE void nrf_clock_hf_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_hfclk_t source)
+{
+ p_reg->HFCLKSRC = (uint32_t)(source);
}
+#endif
NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hf_src_get(NRF_CLOCK_Type const * p_reg)
{
+#if NRF_CLOCK_HAS_HFCLKSRC
+ return (nrf_clock_hfclk_t)(p_reg->HFCLKSRC);
+#else
return (nrf_clock_hfclk_t)((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_SRC_Msk)
>> CLOCK_HFCLKSTAT_SRC_Pos);
+#endif
}
NRF_STATIC_INLINE bool nrf_clock_hf_is_running(NRF_CLOCK_Type const * p_reg,
nrf_clock_hfclk_t clk_src)
{
- return (p_reg->HFCLKSTAT & (CLOCK_HFCLKSTAT_STATE_Msk | CLOCK_HFCLKSTAT_SRC_Msk)) ==
- (CLOCK_HFCLKSTAT_STATE_Msk | (clk_src << CLOCK_HFCLKSTAT_SRC_Pos));
+ nrf_clock_hfclk_t active_clk_src;
+ bool ret = nrf_clock_is_running(p_reg, NRF_CLOCK_DOMAIN_HFCLK, &active_clk_src);
+ return (ret && (active_clk_src == clk_src));
}
NRF_STATIC_INLINE
nrf_clock_start_task_status_t nrf_clock_hf_start_task_status_get(NRF_CLOCK_Type const * p_reg)
{
- return (nrf_clock_start_task_status_t)((p_reg->HFCLKRUN & CLOCK_HFCLKRUN_STATUS_Msk)
- >> CLOCK_HFCLKRUN_STATUS_Pos);
+ return (nrf_clock_start_task_status_t)nrf_clock_start_task_check(p_reg,
+ NRF_CLOCK_DOMAIN_HFCLK);
+}
+
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+NRF_STATIC_INLINE
+void nrf_clock_hfclkaudio_config_set(NRF_CLOCK_Type * p_reg, uint16_t freq_value)
+{
+ p_reg->HFCLKAUDIO.FREQUENCY = freq_value;
+}
+
+NRF_STATIC_INLINE
+uint16_t nrf_clock_hfclkaudio_config_get(NRF_CLOCK_Type const * p_reg)
+{
+ return (uint16_t)(p_reg->HFCLKAUDIO.FREQUENCY);
+}
+#endif
+
+#if NRF_CLOCK_HAS_HFCLK_DIV
+NRF_STATIC_INLINE
+void nrf_clock_hfclk_div_set(NRF_CLOCK_Type * p_reg, nrf_clock_hfclk_div_t divider)
+{
+ p_reg->HFCLKCTRL = (((uint8_t)(divider) << CLOCK_HFCLKCTRL_HCLK_Pos) &
+ CLOCK_HFCLKCTRL_HCLK_Msk);
+}
+
+NRF_STATIC_INLINE nrf_clock_hfclk_div_t nrf_clock_hfclk_div_get(NRF_CLOCK_Type const * p_reg)
+{
+ return (nrf_clock_hfclk_div_t)((p_reg->HFCLKCTRL & CLOCK_HFCLKCTRL_HCLK_Msk)
+ >> CLOCK_HFCLKCTRL_HCLK_Pos);
+}
+#endif
+
+#if NRF_CLOCK_HAS_HFCLK192M
+NRF_STATIC_INLINE
+void nrf_clock_hfclk192m_div_set(NRF_CLOCK_Type * p_reg, nrf_clock_hfclk_div_t divider)
+{
+ p_reg->HFCLK192MCTRL = (((uint8_t)(divider) << CLOCK_HFCLK192MCTRL_HCLK192M_Pos) &
+ CLOCK_HFCLK192MCTRL_HCLK192M_Msk);
}
-#if (NRF_CLOCK_HAS_CALIBRATION)
+NRF_STATIC_INLINE nrf_clock_hfclk_div_t nrf_clock_hfclk192m_div_get(NRF_CLOCK_Type const * p_reg)
+{
+ return (nrf_clock_hfclk_div_t)((p_reg->HFCLK192MCTRL & CLOCK_HFCLK192MCTRL_HCLK192M_Msk)
+ >> CLOCK_HFCLK192MCTRL_HCLK192M_Pos);
+}
+
+NRF_STATIC_INLINE void nrf_clock_hfclk192m_src_set(NRF_CLOCK_Type * p_reg, nrf_clock_hfclk_t source)
+{
+ p_reg->HFCLK192MSRC = (uint32_t)(source);
+}
+
+NRF_STATIC_INLINE nrf_clock_hfclk_t nrf_clock_hfclk192m_src_get(NRF_CLOCK_Type const * p_reg)
+{
+ return (nrf_clock_hfclk_t)(p_reg->HFCLK192MSRC);
+}
+#endif
+
+#if NRF_CLOCK_HAS_CALIBRATION_TIMER
NRF_STATIC_INLINE void nrf_clock_cal_timer_timeout_set(NRF_CLOCK_Type * p_reg, uint32_t interval)
{
p_reg->CTIV = ((interval << CLOCK_CTIV_CTIV_Pos) & CLOCK_CTIV_CTIV_Msk);
}
#endif
+#if NRF_CLOCK_HAS_ALWAYSRUN
+NRF_STATIC_INLINE void nrf_clock_alwaysrun_set(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain,
+ bool alwaysrun)
+{
+ /* ALWAYSRUN registers should be R/W, but are marked as read-only.
+ * Redefine them as R/W as a workaround. */
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ *(volatile uint32_t *)(&p_reg->LFCLKALWAYSRUN) =
+ ((alwaysrun << CLOCK_LFCLKALWAYSRUN_ALWAYSRUN_Pos)
+ & CLOCK_LFCLKALWAYSRUN_ALWAYSRUN_Msk);
+ break;
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ *(volatile uint32_t *)(&p_reg->HFCLKALWAYSRUN) =
+ ((alwaysrun << CLOCK_HFCLKALWAYSRUN_ALWAYSRUN_Pos)
+ & CLOCK_HFCLKALWAYSRUN_ALWAYSRUN_Msk);
+ break;
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ *(volatile uint32_t *)(&p_reg->HFCLK192MALWAYSRUN) =
+ ((alwaysrun << CLOCK_HFCLK192MALWAYSRUN_ALWAYSRUN_Pos)
+ & CLOCK_HFCLK192MALWAYSRUN_ALWAYSRUN_Msk);
+ break;
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ *(volatile uint32_t *)(&p_reg->HFCLKAUDIOALWAYSRUN) =
+ ((alwaysrun << CLOCK_HFCLKAUDIOALWAYSRUN_ALWAYSRUN_Pos)
+ & CLOCK_HFCLKAUDIOALWAYSRUN_ALWAYSRUN_Msk);
+ break;
+#endif
+ default:
+ NRFX_ASSERT(0);
+ break;
+ }
+}
+
+NRF_STATIC_INLINE bool nrf_clock_alwaysrun_get(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain)
+{
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ return ((p_reg->LFCLKALWAYSRUN & CLOCK_LFCLKALWAYSRUN_ALWAYSRUN_Msk)
+ >> CLOCK_LFCLKALWAYSRUN_ALWAYSRUN_Pos);
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ return ((p_reg->HFCLKALWAYSRUN & CLOCK_HFCLKALWAYSRUN_ALWAYSRUN_Msk)
+ >> CLOCK_HFCLKALWAYSRUN_ALWAYSRUN_Pos);
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ return ((p_reg->HFCLK192MALWAYSRUN & CLOCK_HFCLK192MALWAYSRUN_ALWAYSRUN_Msk)
+ >> CLOCK_HFCLK192MALWAYSRUN_ALWAYSRUN_Pos);
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ return ((p_reg->HFCLKAUDIOALWAYSRUN & CLOCK_HFCLKAUDIOALWAYSRUN_ALWAYSRUN_Msk)
+ >> CLOCK_HFCLKAUDIOALWAYSRUN_ALWAYSRUN_Pos);
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return false;
+ }
+}
+
+NRF_STATIC_INLINE bool nrf_clock_alwaysrun_active_get(NRF_CLOCK_Type const * p_reg,
+ nrf_clock_domain_t domain)
+{
+ switch (domain)
+ {
+ case NRF_CLOCK_DOMAIN_LFCLK:
+ return ((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_ALWAYSRUNNING_Msk)
+ >> CLOCK_LFCLKSTAT_ALWAYSRUNNING_Pos);
+ case NRF_CLOCK_DOMAIN_HFCLK:
+ return ((p_reg->HFCLKSTAT & CLOCK_HFCLKSTAT_ALWAYSRUNNING_Msk)
+ >> CLOCK_HFCLKSTAT_ALWAYSRUNNING_Pos);
+#if NRF_CLOCK_HAS_HFCLK192M
+ case NRF_CLOCK_DOMAIN_HFCLK192M:
+ return ((p_reg->HFCLK192MSTAT & CLOCK_HFCLK192MSTAT_ALWAYSRUNNING_Msk)
+ >> CLOCK_HFCLK192MSTAT_ALWAYSRUNNING_Pos);
+#endif
+#if NRF_CLOCK_HAS_HFCLKAUDIO
+ case NRF_CLOCK_DOMAIN_HFCLKAUDIO:
+ return ((p_reg->HFCLKAUDIOSTAT & CLOCK_HFCLKAUDIOSTAT_ALWAYSRUNNING_Msk)
+ >> CLOCK_HFCLKAUDIOSTAT_ALWAYSRUNNING_Pos);
+#endif
+ default:
+ NRFX_ASSERT(0);
+ return false;
+ }
+}
+#endif // NRF_CLOCK_HAS_ALWAYSRUN
+
#if defined(DPPI_PRESENT)
NRF_STATIC_INLINE void nrf_clock_subscribe_set(NRF_CLOCK_Type * p_reg,
nrf_clock_task_t task,
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h
index 804abe3..3a00c48 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_comp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dcnf.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dcnf.h
new file mode 100644
index 0000000..79dc7c5
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dcnf.h
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 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 NRF_DCNF_H__
+#define NRF_DCNF_H__
+
+#include <nrfx.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup nrf_dcnf_hal DCNF HAL
+ * @{
+ * @ingroup nrf_dcnf
+ * @brief Hardware access layer for managing the Domain Configuration (DCNF) module.
+ */
+
+/**
+ * @brief Function for getting the value of the CPU ID.
+ *
+ * CPU ID can be used to identify the specific CPU in the multi-core environment.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return CPU ID.
+ */
+NRF_STATIC_INLINE uint32_t nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg);
+
+#if defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
+/**
+ * @brief Function for configuring the control access to local peripheral memory regions.
+ * Intended for external master connected to specified AMLI master port.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] port_idx Index of the master port to configure.
+ * @param[in] mask Mask of the AHB slaves to be protected from being accessed
+ * by external AHB masters.
+ */
+NRF_STATIC_INLINE void nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,
+ uint8_t port_idx,
+ uint32_t mask);
+
+/**
+ * @brief Function for getting the configuration of control access to local peripheral
+ * memory regions. Intended for external master connected to specified AMLI master port.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] port_idx Index of the master port to configure.
+ *
+ * @return Mask of the AHB slaves that are currently protected.
+ */
+NRF_STATIC_INLINE uint32_t nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,
+ uint8_t port_idx);
+#endif // defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
+
+#if defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
+/**
+ * @brief Function for configuring the control access to local RAM memory regions.
+ * Intended for external master connected to specified AMLI master port.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] port_idx Index of the master port to configure.
+ * @param[in] mask Mask of the AHB slaves to be protected from being accessed
+ * by external AHB masters.
+ */
+NRF_STATIC_INLINE void nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,
+ uint8_t port_idx,
+ uint32_t mask);
+
+/**
+ * @brief Function for getting the configuration of control access to local RAM
+ * memory regions. Intended for external master connected to specified AMLI master port.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] port_idx Index of the master port to configure.
+ *
+ * @return Mask of the AHB slaves that are currently protected.
+ */
+NRF_STATIC_INLINE uint32_t nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,
+ uint8_t port_idx);
+#endif // defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
+
+#if defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
+/**
+ * @brief Function for configuring the control access to local code memory regions.
+ * Intended for external master connected to specified AMLI master port.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] port_idx Index of the master port to configure.
+ * @param[in] mask Mask of the AHB slaves to be protected from being accessed
+ * by external AHB masters.
+ */
+NRF_STATIC_INLINE void nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,
+ uint8_t port_idx,
+ uint32_t mask);
+
+/**
+ * @brief Function for getting the configuration of control access to local code
+ * memory regions. Intended for external master connected to specified AMLI master port.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] port_idx Index of the master port to configure.
+ *
+ * @return Mask of the AHB slaves that are currently protected.
+ */
+NRF_STATIC_INLINE uint32_t nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,
+ uint8_t port_idx);
+#endif // defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
+
+#ifndef NRF_DECLARE_ONLY
+
+NRF_STATIC_INLINE uint32_t nrf_dcnf_cpuid_get(NRF_DCNF_Type const * p_reg)
+{
+ return p_reg->CPUID;
+}
+
+#if defined(DCNF_EXTPERI_PROTECT_SLAVE0_Msk)
+NRF_STATIC_INLINE void nrf_dcnf_peripheral_access_set(NRF_DCNF_Type * p_reg,
+ uint8_t port_idx,
+ uint32_t mask)
+{
+ p_reg->EXTPERI[port_idx].PROTECT = mask;
+}
+
+NRF_STATIC_INLINE uint32_t nrf_dcnf_peripheral_access_get(NRF_DCNF_Type const * p_reg,
+ uint8_t port_idx)
+{
+ return p_reg->EXTPERI[port_idx].PROTECT;
+}
+#endif
+
+#if defined(DCNF_EXTRAM_PROTECT_SLAVE0_Msk)
+NRF_STATIC_INLINE void nrf_dcnf_ram_access_set(NRF_DCNF_Type * p_reg,
+ uint8_t port_idx,
+ uint32_t mask)
+{
+ p_reg->EXTRAM[port_idx].PROTECT = mask;
+}
+
+NRF_STATIC_INLINE uint32_t nrf_dcnf_ram_access_get(NRF_DCNF_Type const * p_reg,
+ uint8_t port_idx)
+{
+ return p_reg->EXTRAM[port_idx].PROTECT;
+}
+#endif
+
+#if defined(DCNF_EXTCODE_PROTECT_SLAVE0_Msk)
+NRF_STATIC_INLINE void nrf_dcnf_code_access_set(NRF_DCNF_Type * p_reg,
+ uint8_t port_idx,
+ uint32_t mask)
+{
+ p_reg->EXTCODE[port_idx].PROTECT = mask;
+}
+
+NRF_STATIC_INLINE uint32_t nrf_dcnf_code_access_get(NRF_DCNF_Type const * p_reg,
+ uint8_t port_idx)
+{
+ return p_reg->EXTCODE[port_idx].PROTECT;
+}
+#endif
+
+#endif // NRF_DECLARE_ONLY
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NRF_DCNF_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h
index 486224b..9ff7e08 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_dppi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h
index 9cef4ad..e734e14 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ecb.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h
index 3a7bf4e..8c5cdc2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_egu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h
index 5967b06..193c83a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ficr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h
index 35ff12c..14bcab8 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_fpu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h
index d2b9366..6fcf5e6 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpio.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,11 @@ extern "C" {
* @brief Hardware access layer for managing the GPIO peripheral.
*/
+#if defined(GPIO_LATCH_PIN0_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether the functionality of latching GPIO state change is present. */
+#define NRF_GPIO_LATCH_PRESENT
+#endif
+
/** @brief Macro for mapping port and pin numbers to values understandable for nrf_gpio functions. */
#define NRF_GPIO_PIN_MAP(port, pin) (((port) << 5) | ((pin) & 0x1F))
@@ -91,14 +96,35 @@ typedef enum
/** @brief Enumerator used for selecting output drive mode. */
typedef enum
{
- NRF_GPIO_PIN_S0S1 = GPIO_PIN_CNF_DRIVE_S0S1, ///< !< Standard '0', standard '1'.
- NRF_GPIO_PIN_H0S1 = GPIO_PIN_CNF_DRIVE_H0S1, ///< !< High-drive '0', standard '1'.
- NRF_GPIO_PIN_S0H1 = GPIO_PIN_CNF_DRIVE_S0H1, ///< !< Standard '0', high-drive '1'.
- NRF_GPIO_PIN_H0H1 = GPIO_PIN_CNF_DRIVE_H0H1, ///< !< High drive '0', high-drive '1'.
- NRF_GPIO_PIN_D0S1 = GPIO_PIN_CNF_DRIVE_D0S1, ///< !< Disconnect '0' standard '1'.
- NRF_GPIO_PIN_D0H1 = GPIO_PIN_CNF_DRIVE_D0H1, ///< !< Disconnect '0', high-drive '1'.
- NRF_GPIO_PIN_S0D1 = GPIO_PIN_CNF_DRIVE_S0D1, ///< !< Standard '0', disconnect '1'.
- NRF_GPIO_PIN_H0D1 = GPIO_PIN_CNF_DRIVE_H0D1, ///< !< High-drive '0', disconnect '1'.
+ NRF_GPIO_PIN_S0S1 = GPIO_PIN_CNF_DRIVE_S0S1, ///< Standard '0', standard '1'.
+ NRF_GPIO_PIN_H0S1 = GPIO_PIN_CNF_DRIVE_H0S1, ///< High drive '0', standard '1'.
+ NRF_GPIO_PIN_S0H1 = GPIO_PIN_CNF_DRIVE_S0H1, ///< Standard '0', high drive '1'.
+ NRF_GPIO_PIN_H0H1 = GPIO_PIN_CNF_DRIVE_H0H1, ///< High drive '0', high drive '1'.
+ NRF_GPIO_PIN_D0S1 = GPIO_PIN_CNF_DRIVE_D0S1, ///< Disconnect '0' standard '1'.
+ NRF_GPIO_PIN_D0H1 = GPIO_PIN_CNF_DRIVE_D0H1, ///< Disconnect '0', high drive '1'.
+ NRF_GPIO_PIN_S0D1 = GPIO_PIN_CNF_DRIVE_S0D1, ///< Standard '0', disconnect '1'.
+ NRF_GPIO_PIN_H0D1 = GPIO_PIN_CNF_DRIVE_H0D1, ///< High drive '0', disconnect '1'.
+#if defined(GPIO_PIN_CNF_DRIVE_E0S1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_E0S1 = GPIO_PIN_CNF_DRIVE_E0S1, ///< Extra high drive '0', standard '1'.
+#endif
+#if defined(GPIO_PIN_CNF_DRIVE_S0E1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_S0E1 = GPIO_PIN_CNF_DRIVE_S0E1, ///< Standard '0', extra high drive '1'.
+#endif
+#if defined(GPIO_PIN_CNF_DRIVE_E0E1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_E0E1 = GPIO_PIN_CNF_DRIVE_E0E1, ///< Extra high drive '0', extra high drive '1'.
+#endif
+#if defined(GPIO_PIN_CNF_DRIVE_E0H1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_E0H1 = GPIO_PIN_CNF_DRIVE_E0H1, ///< Extra high drive '0', high drive '1'.
+#endif
+#if defined(GPIO_PIN_CNF_DRIVE_H0E1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_H0E1 = GPIO_PIN_CNF_DRIVE_H0E1, ///< High drive '0', extra high drive '1'.
+#endif
+#if defined(GPIO_PIN_CNF_DRIVE_D0E1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_D0E1 = GPIO_PIN_CNF_DRIVE_D0E1, ///< Disconnect '0', extra high drive '1'.
+#endif
+#if defined(GPIO_PIN_CNF_DRIVE_E0D1) || defined(__NRFX_DOXYGEN__)
+ NRF_GPIO_PIN_E0D1 = GPIO_PIN_CNF_DRIVE_E0D1, ///< Extra high drive '0', disconnect '1'.
+#endif
} nrf_gpio_pin_drive_t;
/** @brief Enumerator used for selecting the pin to sense high or low level on the pin input. */
@@ -421,7 +447,7 @@ NRF_STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port,
uint32_t length,
uint32_t * p_masks);
-#if defined(GPIO_DETECTMODE_DETECTMODE_LDETECT) || defined(__NRF_DOXYGEN__)
+#if defined(NRF_GPIO_LATCH_PRESENT)
/**
* @brief Function for reading latch state of multiple consecutive ports.
*
@@ -434,6 +460,17 @@ NRF_STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port,
uint32_t * p_masks);
/**
+ * @brief Function for reading and immediate clearing latch state of multiple consecutive ports.
+ *
+ * @param start_port Index of the first port to read and clear.
+ * @param length Number of ports to read and clear.
+ * @param p_masks Pointer to output array where latch states will be stored.
+ */
+NRF_STATIC_INLINE void nrf_gpio_latches_read_and_clear(uint32_t start_port,
+ uint32_t length,
+ uint32_t * p_masks);
+
+/**
* @brief Function for reading latch state of single pin.
*
* @param pin_number Pin number.
@@ -448,7 +485,7 @@ NRF_STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number);
* @param pin_number Pin number.
*/
NRF_STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number);
-#endif
+#endif // defined(NRF_GPIO_LATCH_PRESENT)
#if defined(GPIO_PIN_CNF_MCUSEL_Msk) || defined(__NRFX_DOXYGEN__)
/**
@@ -789,7 +826,7 @@ NRF_STATIC_INLINE void nrf_gpio_ports_read(uint32_t start_port,
}
-#ifdef GPIO_DETECTMODE_DETECTMODE_LDETECT
+#if defined(NRF_GPIO_LATCH_PRESENT)
NRF_STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port,
uint32_t length,
uint32_t * p_masks)
@@ -804,6 +841,23 @@ NRF_STATIC_INLINE void nrf_gpio_latches_read(uint32_t start_port,
}
}
+NRF_STATIC_INLINE void nrf_gpio_latches_read_and_clear(uint32_t start_port,
+ uint32_t length,
+ uint32_t * p_masks)
+{
+ NRF_GPIO_Type * gpio_regs[GPIO_COUNT] = GPIO_REG_LIST;
+ uint32_t i;
+
+ for (i = start_port; i < (start_port + length); i++)
+ {
+ *p_masks = gpio_regs[i]->LATCH;
+
+ // The LATCH register is cleared by writing a '1' to the bit that shall be cleared.
+ gpio_regs[i]->LATCH = *p_masks;
+
+ p_masks++;
+ }
+}
NRF_STATIC_INLINE uint32_t nrf_gpio_pin_latch_get(uint32_t pin_number)
{
@@ -819,7 +873,7 @@ NRF_STATIC_INLINE void nrf_gpio_pin_latch_clear(uint32_t pin_number)
reg->LATCH = (1 << pin_number);
}
-#endif
+#endif // defined(NRF_GPIO_LATCH_PRESENT)
#if defined(GPIO_PIN_CNF_MCUSEL_Msk)
NRF_STATIC_INLINE void nrf_gpio_pin_mcu_select(uint32_t pin_number, nrf_gpio_pin_mcusel_t mcu)
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h
index ab09e71..8f3321d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_gpiote.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h
index 33b8123..da71bc6 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_i2s.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,13 @@ extern "C" {
* @brief Hardware access layer for managing the Inter-IC Sound (I2S) peripheral.
*/
+#if defined(I2S_CONFIG_CLKCONFIG_CLKSRC_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether clock source configuration is available. */
+#define NRF_I2S_HAS_CLKCONFIG 1
+#else
+#define NRF_I2S_HAS_CLKCONFIG 0
+#endif
+
/**
* @brief This value can be provided as a parameter for the @ref nrf_i2s_pins_set
* function call to specify that the given I2S signal (SDOUT, SDIN, or MCK)
@@ -63,17 +70,23 @@ typedef enum
/** @brief I2S events. */
typedef enum
{
- NRF_I2S_EVENT_RXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_RXPTRUPD), ///< The RXD.PTR register has been copied to internal double buffers.
- NRF_I2S_EVENT_TXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_TXPTRUPD), ///< The TXD.PTR register has been copied to internal double buffers.
- NRF_I2S_EVENT_STOPPED = offsetof(NRF_I2S_Type, EVENTS_STOPPED) ///< I2S transfer stopped.
+ NRF_I2S_EVENT_RXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_RXPTRUPD), ///< The RXD.PTR register has been copied to internal double buffers.
+ NRF_I2S_EVENT_TXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_TXPTRUPD), ///< The TXD.PTR register has been copied to internal double buffers.
+ NRF_I2S_EVENT_STOPPED = offsetof(NRF_I2S_Type, EVENTS_STOPPED), ///< I2S transfer stopped.
+#if defined(I2S_INTENSET_FRAMESTART_Msk) || defined(__NRFX_DOXYGEN_)
+ NRF_I2S_EVENT_FRAMESTART = offsetof(NRF_I2S_Type, EVENTS_FRAMESTART) ///< Frame start event, generated on the active edge of LRCK.
+#endif
} nrf_i2s_event_t;
/** @brief I2S interrupts. */
typedef enum
{
- NRF_I2S_INT_RXPTRUPD_MASK = I2S_INTENSET_RXPTRUPD_Msk, ///< Interrupt on RXPTRUPD event.
- NRF_I2S_INT_TXPTRUPD_MASK = I2S_INTENSET_TXPTRUPD_Msk, ///< Interrupt on TXPTRUPD event.
- NRF_I2S_INT_STOPPED_MASK = I2S_INTENSET_STOPPED_Msk ///< Interrupt on STOPPED event.
+ NRF_I2S_INT_RXPTRUPD_MASK = I2S_INTENSET_RXPTRUPD_Msk, ///< Interrupt on RXPTRUPD event.
+ NRF_I2S_INT_TXPTRUPD_MASK = I2S_INTENSET_TXPTRUPD_Msk, ///< Interrupt on TXPTRUPD event.
+ NRF_I2S_INT_STOPPED_MASK = I2S_INTENSET_STOPPED_Msk, ///< Interrupt on STOPPED event.
+#if defined(I2S_INTENSET_FRAMESTART_Msk) || defined(__NRFX_DOXYGEN_)
+ NRF_I2S_INT_FRAMESTART_MASK = I2S_INTENCLR_FRAMESTART_Msk ///< Interrupt on FRAMESTART event.
+#endif
} nrf_i2s_int_mask_t;
/** @brief I2S modes of operation. */
@@ -136,9 +149,24 @@ typedef enum
/** @brief I2S sample widths. */
typedef enum
{
- NRF_I2S_SWIDTH_8BIT = I2S_CONFIG_SWIDTH_SWIDTH_8Bit, ///< 8 bit.
- NRF_I2S_SWIDTH_16BIT = I2S_CONFIG_SWIDTH_SWIDTH_16Bit, ///< 16 bit.
- NRF_I2S_SWIDTH_24BIT = I2S_CONFIG_SWIDTH_SWIDTH_24Bit ///< 24 bit.
+ NRF_I2S_SWIDTH_8BIT = I2S_CONFIG_SWIDTH_SWIDTH_8Bit, ///< 8 bit.
+ NRF_I2S_SWIDTH_16BIT = I2S_CONFIG_SWIDTH_SWIDTH_16Bit, ///< 16 bit.
+ NRF_I2S_SWIDTH_24BIT = I2S_CONFIG_SWIDTH_SWIDTH_24Bit, ///< 24 bit.
+#if defined(I2S_CONFIG_SWIDTH_SWIDTH_32Bit) || defined(__NRFX_DOXYGEN__)
+ NRF_I2S_SWIDTH_32BIT = I2S_CONFIG_SWIDTH_SWIDTH_32Bit, ///< 32 bit.
+#endif
+#if defined(I2S_CONFIG_SWIDTH_SWIDTH_8BitIn16) || defined(__NRFX_DOXYGEN__)
+ NRF_I2S_SWIDTH_8BIT_IN16BIT = I2S_CONFIG_SWIDTH_SWIDTH_8BitIn16, ///< 8 bit sample in a 16-bit half-frame.
+#endif
+#if defined(I2S_CONFIG_SWIDTH_SWIDTH_8BitIn32) || defined(__NRFX_DOXYGEN__)
+ NRF_I2S_SWIDTH_8BIT_IN32BIT = I2S_CONFIG_SWIDTH_SWIDTH_8BitIn32, ///< 8 bit sample in a 32-bit half-frame.
+#endif
+#if defined(I2S_CONFIG_SWIDTH_SWIDTH_16BitIn32) || defined(__NRFX_DOXYGEN__)
+ NRF_I2S_SWIDTH_16BIT_IN32BIT = I2S_CONFIG_SWIDTH_SWIDTH_16BitIn32, ///< 16 bit sample in a 32-bit half-frame.
+#endif
+#if defined(I2S_CONFIG_SWIDTH_SWIDTH_24BitIn32) || defined(__NRFX_DOXYGEN__)
+ NRF_I2S_SWIDTH_24BIT_IN32BIT = I2S_CONFIG_SWIDTH_SWIDTH_24BitIn32, ///< 24 bit sample in a 32-bit half-frame.
+#endif
} nrf_i2s_swidth_t;
/** @brief I2S alignments of sample within a frame. */
@@ -163,6 +191,14 @@ typedef enum
NRF_I2S_CHANNELS_RIGHT = I2S_CONFIG_CHANNELS_CHANNELS_Right ///< Right only.
} nrf_i2s_channels_t;
+#if NRF_I2S_HAS_CLKCONFIG
+/** @brief I2S Clock source selection. */
+typedef enum
+{
+ NRF_I2S_CLKSRC_PCLK32M = I2S_CONFIG_CLKCONFIG_CLKSRC_PCLK32M, ///< 32MHz peripheral clock.
+ NRF_I2S_CLKSRC_ACLK = I2S_CONFIG_CLKCONFIG_CLKSRC_ACLK ///< Audio PLL clock.
+} nrf_i2s_clksrc_t;
+#endif
/**
* @brief Function for activating the specified I2S task.
@@ -408,6 +444,19 @@ NRF_STATIC_INLINE void nrf_i2s_tx_buffer_set(NRF_I2S_Type * p_reg,
*/
NRF_STATIC_INLINE uint32_t * nrf_i2s_tx_buffer_get(NRF_I2S_Type const * p_reg);
+#if NRF_I2S_HAS_CLKCONFIG
+/**
+ * @brief Function for configuring I2S Clock.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] clksrc I2S Clock source selection.
+ * @param[in] enable_bypass Bypass clock generator. MCK will be equal to source input.
+ * If bypass is enabled the MCKFREQ setting has no effect.
+ */
+NRF_STATIC_INLINE void nrf_i2s_clk_configure(NRF_I2S_Type * p_reg,
+ nrf_i2s_clksrc_t clksrc,
+ bool enable_bypass);
+#endif
#ifndef NRF_DECLARE_ONLY
@@ -598,6 +647,16 @@ NRF_STATIC_INLINE uint32_t * nrf_i2s_tx_buffer_get(NRF_I2S_Type const * p_reg)
return (uint32_t *)(p_reg->TXD.PTR);
}
+#if NRF_I2S_HAS_CLKCONFIG
+NRF_STATIC_INLINE void nrf_i2s_clk_configure(NRF_I2S_Type * p_reg,
+ nrf_i2s_clksrc_t clksrc,
+ bool enable_bypass)
+{
+ p_reg->CONFIG.CLKCONFIG = ((uint32_t) clksrc << I2S_CONFIG_CLKCONFIG_CLKSRC_Pos) |
+ ((uint32_t) enable_bypass << I2S_CONFIG_CLKCONFIG_BYPASS_Pos);
+}
+#endif
+
#endif // NRF_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h
index 44f6b83..dee5b10 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ipc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h
index 6d51470..a026f4c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_kmu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h
index 30fe7a4..777f6ea 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_lpcomp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h
index 7eb8186..b4bbce2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mpu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -113,8 +113,7 @@ NRF_STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg
* NVM protection during debug is disabled by default.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable True if NVM protection during debug is to be enabled.
- * False if otherwise.
+ * @param[in] enable True if NVM protection during debug is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
bool enable);
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mutex.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mutex.h
index a2b9287..02e1a05 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mutex.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mutex.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h
index 64ebf8b..4fbf445 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_mwu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h
index 01dcfd9..f03d01d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nfct.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h
index 9a71ba3..3f0ddfd 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_nvmc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -349,7 +349,23 @@ NRF_STATIC_INLINE void nrf_nvmc_page_partial_erase_start(NRF_NVMC_Type * p_reg,
NRF_STATIC_INLINE void nrf_nvmc_icache_config_set(NRF_NVMC_Type * p_reg,
nrf_nvmc_icache_config_t config)
{
- p_reg->ICACHECNF = (uint32_t)config;
+#if defined(NRF5340_XXAA_NETWORK) || defined(NRF9160_XXAA)
+ // Apply workaround for the anomalies:
+ // - 6 for the nRF5340.
+ // - 21 for the nRF9160.
+ if (config == NRF_NVMC_ICACHE_DISABLE)
+ {
+ NRFX_CRITICAL_SECTION_ENTER();
+ __ISB();
+ p_reg->ICACHECNF = (uint32_t)NRF_NVMC_ICACHE_DISABLE;
+ __ISB();
+ NRFX_CRITICAL_SECTION_EXIT();
+ }
+ else
+#endif
+ {
+ p_reg->ICACHECNF = (uint32_t)config;
+ }
}
NRF_STATIC_INLINE bool nrf_nvmc_icache_enable_check(NRF_NVMC_Type const * p_reg)
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_oscillators.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_oscillators.h
new file mode 100644
index 0000000..d17ac60
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_oscillators.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 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 NRF_OSCILLATORS_H__
+#define NRF_OSCILLATORS_H__
+
+#include <nrfx.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup nrf_oscillators_hal OSCILLATORS HAL
+ * @{
+ * @ingroup nrf_clock
+ * @brief Hardware access layer for managing the OSCILLATORS peripheral.
+ */
+
+/** @brief Capacitors configuration for LFXO. */
+typedef enum
+{
+ NRF_OSCILLATORS_LFXO_CAP_EXTERNAL = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_External, ///< Use external capacitors.
+ NRF_OSCILLATORS_LFXO_CAP_6PF = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C6PF, ///< Use 6 pF internal capacitors.
+ NRF_OSCILLATORS_LFXO_CAP_7PF = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C7PF, ///< Use 7 pF internal capacitors.
+ NRF_OSCILLATORS_LFXO_CAP_11PF = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C11PF, ///< Use 11 pF internal capacitors.
+} nrf_oscillators_lfxo_cap_t;
+
+/**
+ * @brief Function for enabling or disabling the bypass of LFXO with external clock source.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if bypass is to be enabled (use with rail-to-rail external source).
+ * False if bypass is to be disabled (use with xtal or low-swing external source).
+ */
+NRF_STATIC_INLINE void nrf_oscillators_lfxo_bypass_set(NRF_OSCILLATORS_Type * p_reg, bool enable);
+
+/**
+ * @brief Function for configuring the internal capacitors of LFXO.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] cap Capacitors configuration.
+ */
+NRF_STATIC_INLINE void nrf_oscillators_lfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
+ nrf_oscillators_lfxo_cap_t cap);
+
+/**
+ * @brief Function for configuring the internal capacitors of HXFO.
+ *
+ * The capacitance of internal capacitors ranges from 7 pF to 20 pF in 0.5 pF steps.
+ * To calculate the correct @p cap_value, use the following equation:
+ * CAPVALUE = (1+FICR->XOSC32MTRIM.SLOPE/16) * (CAPACITANCE*2-14) + FICR->XOSC32MTRIM.OFFSET
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if internal capacitors are to be enabled, false otherwise.
+ * @param[in] cap_value Value representing capacitance, calculated using provided equation.
+ * Ignored when internal capacitors are disabled.
+ */
+NRF_STATIC_INLINE void nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
+ bool enable,
+ uint32_t cap_value);
+
+#ifndef NRF_DECLARE_ONLY
+NRF_STATIC_INLINE void nrf_oscillators_lfxo_bypass_set(NRF_OSCILLATORS_Type * p_reg, bool enable)
+{
+ p_reg->XOSC32KI.BYPASS = (enable ? OSCILLATORS_XOSC32KI_BYPASS_BYPASS_Enabled :
+ OSCILLATORS_XOSC32KI_BYPASS_BYPASS_Disabled);
+}
+
+NRF_STATIC_INLINE void nrf_oscillators_lfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
+ nrf_oscillators_lfxo_cap_t cap)
+{
+ p_reg->XOSC32KI.INTCAP = (uint32_t)cap;
+}
+
+NRF_STATIC_INLINE void nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
+ bool enable,
+ uint32_t cap_value)
+{
+ p_reg->XOSC32MCAPS =
+ (enable ? ((OSCILLATORS_XOSC32MCAPS_ENABLE_Enabled << OSCILLATORS_XOSC32MCAPS_ENABLE_Pos) |
+ (cap_value << OSCILLATORS_XOSC32MCAPS_CAPVALUE_Pos))
+ : (OSCILLATORS_XOSC32MCAPS_ENABLE_Disabled << OSCILLATORS_XOSC32MCAPS_ENABLE_Pos));
+}
+#endif // NRF_DECLARE_ONLY
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NRF_OSCILLATORS_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h
index 9dea754..b8545ff 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pdm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,10 @@
extern "C" {
#endif
+#ifndef NRF_PDM0
+#define NRF_PDM0 NRF_PDM
+#endif
+
/**
* @defgroup nrf_pdm_hal PDM HAL
* @{
@@ -44,6 +48,20 @@ extern "C" {
* @brief Hardware access layer for managing the Pulse Density Modulation (PDM) peripheral.
*/
+#if defined(PDM_MCLKCONFIG_SRC_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether master clock source configuration is available. */
+#define NRF_PDM_HAS_MCLKCONFIG 1
+#else
+#define NRF_PDM_HAS_MCLKCONFIG 0
+#endif
+
+#if defined(PDM_RATIO_RATIO_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether ratio configuration is available. */
+#define NRF_PDM_HAS_RATIO_CONFIG 1
+#else
+#define NRF_PDM_HAS_RATIO_CONFIG 0
+#endif
+
/** @brief Minimum value of PDM gain. */
#define NRF_PDM_GAIN_MINIMUM 0x00
/** @brief Default value of PDM gain. */
@@ -83,9 +101,28 @@ typedef enum
{
NRF_PDM_FREQ_1000K = PDM_PDMCLKCTRL_FREQ_1000K, ///< PDM_CLK = 1.000 MHz.
NRF_PDM_FREQ_1032K = PDM_PDMCLKCTRL_FREQ_Default, ///< PDM_CLK = 1.032 MHz.
- NRF_PDM_FREQ_1067K = PDM_PDMCLKCTRL_FREQ_1067K ///< PDM_CLK = 1.067 MHz.
+ NRF_PDM_FREQ_1067K = PDM_PDMCLKCTRL_FREQ_1067K, ///< PDM_CLK = 1.067 MHz.
+#if defined(PDM_PDMCLKCTRL_FREQ_1231K) || defined(__NRFX_DOXYGEN__)
+ NRF_PDM_FREQ_1231K = PDM_PDMCLKCTRL_FREQ_1231K, ///< PDM_CLK = 1.231 MHz.
+#endif
+#if defined(PDM_PDMCLKCTRL_FREQ_1280K) || defined(__NRFX_DOXYGEN__)
+ NRF_PDM_FREQ_1280K = PDM_PDMCLKCTRL_FREQ_1280K, ///< PDM_CLK = 1.280 MHz.
+#endif
+#if defined(PDM_PDMCLKCTRL_FREQ_1333K) || defined(__NRFX_DOXYGEN__)
+ NRF_PDM_FREQ_1333K = PDM_PDMCLKCTRL_FREQ_1333K ///< PDM_CLK = 1.333 MHz.
+#endif
} nrf_pdm_freq_t;
+
+#if NRF_PDM_HAS_RATIO_CONFIG
+/** @brief PDM ratio between PDM_CLK and output sample rate. */
+typedef enum
+{
+ NRF_PDM_RATIO_64X = PDM_RATIO_RATIO_Ratio64, ///< Ratio of 64.
+ NRF_PDM_RATIO_80X = PDM_RATIO_RATIO_Ratio80 ///< Ratio of 80.
+} nrf_pdm_ratio_t;
+#endif
+
/** @brief PDM operation mode. */
typedef enum
{
@@ -100,6 +137,14 @@ typedef enum
NRF_PDM_EDGE_LEFTRISING = PDM_MODE_EDGE_LeftRising ///< Left (or mono) is sampled on rising edge of PDM_CLK.
} nrf_pdm_edge_t;
+#if NRF_PDM_HAS_MCLKCONFIG
+/** @brief PDM master clock source selection. */
+typedef enum
+{
+ NRF_PDM_MCLKSRC_PCLK32M = PDM_MCLKCONFIG_SRC_PCLK32M, ///< 32MHz peripheral clock.
+ NRF_PDM_MCLKSRC_ACLK = PDM_MCLKCONFIG_SRC_ACLK ///< Audio PLL clock.
+} nrf_pdm_mclksrc_t;
+#endif
/**
* @brief Function for triggering a PDM task.
@@ -347,6 +392,26 @@ NRF_STATIC_INLINE void nrf_pdm_buffer_set(NRF_PDM_Type * p_reg, uint32_t * p_buf
*/
NRF_STATIC_INLINE uint32_t * nrf_pdm_buffer_get(NRF_PDM_Type const * p_reg);
+#if NRF_PDM_HAS_RATIO_CONFIG
+/**
+ * @brief Function for setting ratio between PDM_CLK and output sample rate.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] ratio Ratio between PDM_CLK and output sample rate.
+ */
+NRF_STATIC_INLINE void nrf_pdm_ratio_set(NRF_PDM_Type * p_reg, nrf_pdm_ratio_t ratio);
+#endif
+
+#if NRF_PDM_HAS_MCLKCONFIG
+/**
+ * @brief Function for configuring PDM master clock source.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] mclksrc Master Clock source selection.
+ */
+NRF_STATIC_INLINE void nrf_pdm_mclksrc_configure(NRF_PDM_Type * p_reg, nrf_pdm_mclksrc_t mclksrc);
+#endif
+
#ifndef NRF_DECLARE_ONLY
NRF_STATIC_INLINE void nrf_pdm_task_trigger(NRF_PDM_Type * p_reg, nrf_pdm_task_t task)
{
@@ -507,6 +572,20 @@ NRF_STATIC_INLINE uint32_t * nrf_pdm_buffer_get(NRF_PDM_Type const * p_reg)
return (uint32_t *)p_reg->SAMPLE.PTR;
}
+#if NRF_PDM_HAS_RATIO_CONFIG
+NRF_STATIC_INLINE void nrf_pdm_ratio_set(NRF_PDM_Type * p_reg, nrf_pdm_ratio_t ratio)
+{
+ p_reg->RATIO = ratio;
+}
+#endif
+
+#if NRF_PDM_HAS_MCLKCONFIG
+NRF_STATIC_INLINE void nrf_pdm_mclksrc_configure(NRF_PDM_Type * p_reg, nrf_pdm_mclksrc_t mclksrc)
+{
+ p_reg->MCLKCONFIG = mclksrc;
+}
+#endif
+
#endif // NRF_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h
index f489ff5..830d0b5 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_power.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,21 +50,14 @@ extern "C" {
#define NRF_POWER_HAS_SLEEPEVT 1
#else
#define NRF_POWER_HAS_SLEEPEVT 0
-#endif // defined(POWER_INTENSET_SLEEPENTER_Msk) || defined(__NRFX_DOXYGEN__)
+#endif
#if defined(POWER_USBREGSTATUS_VBUSDETECT_Msk) || defined(__NRFX_DOXYGEN__)
/** @brief Symbol indicating whether the POWER peripheral controls the USB regulator. */
#define NRF_POWER_HAS_USBREG 1
#else
#define NRF_POWER_HAS_USBREG 0
-#endif // defined(POWER_USBREGSTATUS_VBUSDETECT_Msk) || defined(__NRFX_DOXYGEN__)
-
-#if defined(POWER_POFCON_THRESHOLDVDDH_Msk) || defined(__NRFX_DOXYGEN__)
-/** @brief Symbol indicating whether VDDH is present. */
-#define NRF_POWER_HAS_VDDH 1
-#else
-#define NRF_POWER_HAS_VDDH 0
-#endif // defined(POWER_POFCON_THRESHOLDVDDH_Msk) || defined(__NRFX_DOXYGEN__)
+#endif
#if defined(POWER_DCDCEN0_DCDCEN_Msk) || defined(__NRFX_DOXYGEN__)
/** @brief Symbol indicating whether DCDCEN for REG0 is present. */
@@ -80,13 +73,27 @@ extern "C" {
#define NRF_POWER_HAS_DCDCEN 0
#endif
+#if defined(POWER_INTENSET_POFWARN_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether power failure event is present. */
+#define NRF_POWER_HAS_POFWARN 1
+#else
+#define NRF_POWER_HAS_POFWARN 0
+#endif
+
#if defined(POWER_POFCON_THRESHOLD_Msk) || defined(__NRFX_DOXYGEN__)
-/** @brief Symbol indicating whether POFCON is present. */
+/** @brief Symbol indicating whether power failure comparator is present. */
#define NRF_POWER_HAS_POFCON 1
#else
#define NRF_POWER_HAS_POFCON 0
#endif
+#if defined(POWER_POFCON_THRESHOLDVDDH_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether power failure comparator for VDDH is present. */
+#define NRF_POWER_HAS_POFCON_VDDH 1
+#else
+#define NRF_POWER_HAS_POFCON_VDDH 0
+#endif
+
#if defined(POWER_RESETREAS_RESETPIN_Msk) || defined(__NRFX_DOXYGEN__)
/** @brief Auxiliary definition to mark the fact that RESETREAS register is present in POWER */
#define NRF_POWER_HAS_RESETREAS 1
@@ -94,6 +101,13 @@ extern "C" {
#define NRF_POWER_HAS_RESETREAS 0
#endif
+#if defined(POWER_MAINREGSTATUS_MAINREGSTATUS_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether MAINREGSTATUS register is present. */
+#define NRF_POWER_HAS_MAINREGSTATUS 1
+#else
+#define NRF_POWER_HAS_MAINREGSTATUS 0
+#endif
+
/** @brief POWER tasks. */
typedef enum
{
@@ -104,7 +118,7 @@ typedef enum
/** @brief POWER events. */
typedef enum
{
-#if NRF_POWER_HAS_POFCON
+#if NRF_POWER_HAS_POFWARN
NRF_POWER_EVENT_POFWARN = offsetof(NRF_POWER_Type, EVENTS_POFWARN ), /**< Power failure warning. */
#endif
#if NRF_POWER_HAS_SLEEPEVT
@@ -121,7 +135,7 @@ typedef enum
/** @brief POWER interrupts. */
typedef enum
{
-#if NRF_POWER_HAS_POFCON
+#if NRF_POWER_HAS_POFWARN
NRF_POWER_INT_POFWARN_MASK = POWER_INTENSET_POFWARN_Msk , /**< Write '1' to Enable interrupt for POFWARN event. */
#endif
#if NRF_POWER_HAS_SLEEPEVT
@@ -258,7 +272,7 @@ typedef enum
} nrf_power_pof_thr_t;
#endif // NRF_POWER_HAS_POFCON
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_POFCON_VDDH
/** @brief Power failure comparator thresholds for VDDH. */
typedef enum
{
@@ -279,15 +293,16 @@ typedef enum
NRF_POWER_POFTHRVDDH_V41 = POWER_POFCON_THRESHOLDVDDH_V41, /**< Set threshold to 4.1 V. */
NRF_POWER_POFTHRVDDH_V42 = POWER_POFCON_THRESHOLDVDDH_V42, /**< Set threshold to 4.2 V. */
} nrf_power_pof_thrvddh_t;
+#endif // NRF_POWER_HAS_POFCON_VDDH
+#if NRF_POWER_HAS_MAINREGSTATUS
/** @brief Main regulator status. */
typedef enum
{
NRF_POWER_MAINREGSTATUS_NORMAL = POWER_MAINREGSTATUS_MAINREGSTATUS_Normal, /**< Normal voltage mode. Voltage supplied on VDD. */
NRF_POWER_MAINREGSTATUS_HIGH = POWER_MAINREGSTATUS_MAINREGSTATUS_High /**< High voltage mode. Voltage supplied on VDDH. */
} nrf_power_mainregstatus_t;
-
-#endif // NRF_POWER_HAS_VDDH
+#endif
#if defined(POWER_RAM_POWER_S0POWER_Msk) || defined(__NRFX_DOXYGEN__)
/**
@@ -588,18 +603,12 @@ NRF_STATIC_INLINE void nrf_power_system_off(NRF_POWER_Type * p_reg);
/**
* @brief Function for setting the power failure comparator configuration.
*
- * This function sets the power failure comparator threshold and enables or disables flag.
- *
- * @note If VDDH settings are present in the device, this function will
- * clear its settings (set to the lowest voltage).
- * Use @ref nrf_power_pofcon_vddh_set function to set new value.
- *
- * @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enabled Sets to true if power failure comparator is to be enabled.
- * @param[in] thr Sets the voltage threshold value.
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if the power failure comparator is to be enabled, false otherwise.
+ * @param[in] thr voltage threshold value.
*/
NRF_STATIC_INLINE void nrf_power_pofcon_set(NRF_POWER_Type * p_reg,
- bool enabled,
+ bool enable,
nrf_power_pof_thr_t thr);
/**
@@ -616,7 +625,7 @@ NRF_STATIC_INLINE nrf_power_pof_thr_t nrf_power_pofcon_get(NRF_POWER_Type const
bool * p_enabled);
#endif // NRF_POWER_HAS_POFCON
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_POFCON_VDDH
/**
* @brief Function for setting the VDDH power failure comparator threshold.
*
@@ -634,7 +643,7 @@ NRF_STATIC_INLINE void nrf_power_pofcon_vddh_set(NRF_POWER_Type * p_reg,
* @return VDDH threshold currently configured.
*/
NRF_STATIC_INLINE nrf_power_pof_thrvddh_t nrf_power_pofcon_vddh_get(NRF_POWER_Type const * p_reg);
-#endif // NRF_POWER_HAS_VDDH
+#endif // NRF_POWER_HAS_POFCON_VDDH
/**
* @brief Function for setting the general purpose retention register.
@@ -705,7 +714,7 @@ NRF_STATIC_INLINE void nrf_power_gpregret_ext_set(NRF_POWER_Type * p_reg,
* will relate to the converter on low voltage side (1.3 V output).
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable Set true to enable the DCDC converter or false to disable the DCDC converter.
+ * @param[in] enable True if DCDC converter is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_power_dcdcen_set(NRF_POWER_Type * p_reg, bool enable);
@@ -774,7 +783,7 @@ NRF_STATIC_INLINE uint32_t nrf_power_rampower_mask_get(NRF_POWER_Type const * p_
* @brief Function for enabling or disabling the DCDC converter on VDDH.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable Set true to enable the DCDC converter or false to disable the DCDC converter.
+ * @param[in] enable True if DCDC converter on VDDH is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_power_dcdcen_vddh_set(NRF_POWER_Type * p_reg, bool enable);
@@ -789,7 +798,7 @@ NRF_STATIC_INLINE void nrf_power_dcdcen_vddh_set(NRF_POWER_Type * p_reg, bool en
NRF_STATIC_INLINE bool nrf_power_dcdcen_vddh_get(NRF_POWER_Type const * p_reg);
#endif // NRF_POWER_HAS_DCDCEN_VDDH
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_MAINREGSTATUS
/**
* @brief Function for getting the main supply status.
*
@@ -799,7 +808,7 @@ NRF_STATIC_INLINE bool nrf_power_dcdcen_vddh_get(NRF_POWER_Type const * p_reg);
*/
NRF_STATIC_INLINE
nrf_power_mainregstatus_t nrf_power_mainregstatus_get(NRF_POWER_Type const * p_reg);
-#endif // NRF_POWER_HAS_VDDH
+#endif // NRF_POWER_HAS_MAINREGSTATUS
#if NRF_POWER_HAS_USBREG
/**
@@ -978,23 +987,23 @@ NRF_STATIC_INLINE void nrf_power_system_off(NRF_POWER_Type * p_reg)
#if NRF_POWER_HAS_POFCON
NRF_STATIC_INLINE void nrf_power_pofcon_set(NRF_POWER_Type * p_reg,
- bool enabled,
+ bool enable,
nrf_power_pof_thr_t thr)
{
NRFX_ASSERT(thr == (thr & (POWER_POFCON_THRESHOLD_Msk >> POWER_POFCON_THRESHOLD_Pos)));
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_POFCON_VDDH
uint32_t pofcon = p_reg->POFCON;
pofcon &= ~(POWER_POFCON_THRESHOLD_Msk | POWER_POFCON_POF_Msk);
pofcon |=
-#else // NRF_POWER_HAS_VDDH
+#else // NRF_POWER_HAS_POFCON_VDDH
p_reg->POFCON =
#endif
(((uint32_t)thr) << POWER_POFCON_THRESHOLD_Pos) |
- (enabled ?
+ (enable ?
(POWER_POFCON_POF_Enabled << POWER_POFCON_POF_Pos)
:
(POWER_POFCON_POF_Disabled << POWER_POFCON_POF_Pos));
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_POFCON_VDDH
p_reg->POFCON = pofcon;
#endif
}
@@ -1013,7 +1022,7 @@ NRF_STATIC_INLINE nrf_power_pof_thr_t nrf_power_pofcon_get(NRF_POWER_Type const
}
#endif // NRF_POWER_HAS_POFCON
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_POFCON_VDDH
NRF_STATIC_INLINE void nrf_power_pofcon_vddh_set(NRF_POWER_Type * p_reg,
nrf_power_pof_thrvddh_t thr)
{
@@ -1029,7 +1038,7 @@ NRF_STATIC_INLINE nrf_power_pof_thrvddh_t nrf_power_pofcon_vddh_get(NRF_POWER_Ty
return (nrf_power_pof_thrvddh_t)((p_reg->POFCON & POWER_POFCON_THRESHOLDVDDH_Msk) >>
POWER_POFCON_THRESHOLDVDDH_Pos);
}
-#endif // NRF_POWER_HAS_VDDH
+#endif // NRF_POWER_HAS_POFCON_VDDH
NRF_STATIC_INLINE void nrf_power_gpregret_set(NRF_POWER_Type * p_reg, uint8_t val)
{
@@ -1127,7 +1136,7 @@ NRF_STATIC_INLINE uint32_t nrf_power_rampower_mask_get(NRF_POWER_Type const * p_
{
return p_reg->RAM[block].POWER;
}
-#endif /* defined(POWER_RAM_POWER_S0POWER_Msk) */
+#endif // defined(POWER_RAM_POWER_S0POWER_Msk)
#if NRF_POWER_HAS_DCDCEN_VDDH
NRF_STATIC_INLINE void nrf_power_dcdcen_vddh_set(NRF_POWER_Type * p_reg, bool enable)
@@ -1144,7 +1153,7 @@ NRF_STATIC_INLINE bool nrf_power_dcdcen_vddh_get(NRF_POWER_Type const * p_reg)
}
#endif // NRF_POWER_HAS_DCDCEN_VDDH
-#if NRF_POWER_HAS_VDDH
+#if NRF_POWER_HAS_MAINREGSTATUS
NRF_STATIC_INLINE
nrf_power_mainregstatus_t nrf_power_mainregstatus_get(NRF_POWER_Type const * p_reg)
{
@@ -1152,7 +1161,7 @@ nrf_power_mainregstatus_t nrf_power_mainregstatus_get(NRF_POWER_Type const * p_r
POWER_MAINREGSTATUS_MAINREGSTATUS_Msk) >>
POWER_MAINREGSTATUS_MAINREGSTATUS_Pos);
}
-#endif // NRF_POWER_HAS_VDDH
+#endif // NRF_POWER_HAS_MAINREGSTATUS
#if NRF_POWER_HAS_USBREG
NRF_STATIC_INLINE uint32_t nrf_power_usbregstatus_get(NRF_POWER_Type const * p_reg)
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h
index 14b401d..85fa32d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_ppi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h
index c669c52..1f017d1 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_pwm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -219,7 +219,7 @@ typedef union {
* SEQ[n].REFRESH and SEQ[n].ENDDELAY registers in the peripheral,
* respectively) are ignored at the end of a complex sequence
* playback, indicated by the LOOPSDONE event.
- * See the @linkProductSpecification52 for more information.
+ * See the Product Specification for more information.
*/
typedef struct
{
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h
index 8da7ea9..8ae72f2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qdec.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h
index 838f2e1..69eca9a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_qspi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,34 @@ extern "C" {
* @brief Hardware access layer for managing the QSPI peripheral.
*/
+#if defined(QSPI_XIPEN_XIPEN_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether XIP can be explicitly enabled or disabled via XIPEN register. */
+#define NRF_QSPI_HAS_XIPEN 1
+#else
+#define NRF_QSPI_HAS_XIPEN 0
+#endif
+
+#if defined(QSPI_XIP_ENC_ENABLE_ENABLE_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether encryption for XIP is present. */
+#define NRF_QSPI_HAS_XIP_ENC 1
+#else
+#define NRF_QSPI_HAS_XIP_ENC 0
+#endif
+
+#if defined(QSPI_DMA_ENC_ENABLE_ENABLE_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether encryption for EasyDMA is present. */
+#define NRF_QSPI_HAS_DMA_ENC 1
+#else
+#define NRF_QSPI_HAS_DMA_ENC 0
+#endif
+
+#if defined(NRF53_SERIES) || defined(__NRFX_DOXYGEN__)
+/** @brief Value representing QSPI base clock frequency. */
+#define NRF_QSPI_BASE_CLOCK_FREQ 96000000uL
+#else
+#define NRF_QSPI_BASE_CLOCK_FREQ 32000000uL
+#endif
+
/**
* @brief This value can be used as a parameter for the @ref nrf_qspi_pins_set
* function to specify that a given QSPI signal (SCK, CSN, IO0, IO1, IO2, or IO3)
@@ -78,27 +106,47 @@ typedef enum
NRF_QSPI_INT_READY_MASK = QSPI_INTENSET_READY_Msk /**< Interrupt on READY event. */
} nrf_qspi_int_mask_t;
-/** @brief QSPI frequency divider values. */
+/** @brief QSPI base clock frequency divider values. */
typedef enum
{
- NRF_QSPI_FREQ_32MDIV1, /**< 32.0 MHz. */
- NRF_QSPI_FREQ_32MDIV2, /**< 16.0 MHz. */
- NRF_QSPI_FREQ_32MDIV3, /**< 10.6 MHz. */
- NRF_QSPI_FREQ_32MDIV4, /**< 8.00 MHz. */
- NRF_QSPI_FREQ_32MDIV5, /**< 6.40 MHz. */
- NRF_QSPI_FREQ_32MDIV6, /**< 5.33 MHz. */
- NRF_QSPI_FREQ_32MDIV7, /**< 4.57 MHz. */
- NRF_QSPI_FREQ_32MDIV8, /**< 4.00 MHz. */
- NRF_QSPI_FREQ_32MDIV9, /**< 3.55 MHz. */
- NRF_QSPI_FREQ_32MDIV10, /**< 3.20 MHz. */
- NRF_QSPI_FREQ_32MDIV11, /**< 2.90 MHz. */
- NRF_QSPI_FREQ_32MDIV12, /**< 2.66 MHz. */
- NRF_QSPI_FREQ_32MDIV13, /**< 2.46 MHz. */
- NRF_QSPI_FREQ_32MDIV14, /**< 2.29 MHz. */
- NRF_QSPI_FREQ_32MDIV15, /**< 2.13 MHz. */
- NRF_QSPI_FREQ_32MDIV16, /**< 2.00 MHz. */
+ NRF_QSPI_FREQ_DIV1, /**< Divide by 1. */
+ NRF_QSPI_FREQ_DIV2, /**< Divide by 2. */
+ NRF_QSPI_FREQ_DIV3, /**< Divide by 3. */
+ NRF_QSPI_FREQ_DIV4, /**< Divide by 4. */
+ NRF_QSPI_FREQ_DIV5, /**< Divide by 5. */
+ NRF_QSPI_FREQ_DIV6, /**< Divide by 6. */
+ NRF_QSPI_FREQ_DIV7, /**< Divide by 7. */
+ NRF_QSPI_FREQ_DIV8, /**< Divide by 8. */
+ NRF_QSPI_FREQ_DIV9, /**< Divide by 9. */
+ NRF_QSPI_FREQ_DIV10, /**< Divide by 10. */
+ NRF_QSPI_FREQ_DIV11, /**< Divide by 11. */
+ NRF_QSPI_FREQ_DIV12, /**< Divide by 12. */
+ NRF_QSPI_FREQ_DIV13, /**< Divide by 13. */
+ NRF_QSPI_FREQ_DIV14, /**< Divide by 14. */
+ NRF_QSPI_FREQ_DIV15, /**< Divide by 15. */
+ NRF_QSPI_FREQ_DIV16, /**< Divide by 16. */
} nrf_qspi_frequency_t;
+#if defined(NRF52_SERIES)
+/** Symbols translation for backward compatibility. */
+#define NRF_QSPI_FREQ_32MDIV1 NRF_QSPI_FREQ_DIV1
+#define NRF_QSPI_FREQ_32MDIV2 NRF_QSPI_FREQ_DIV2
+#define NRF_QSPI_FREQ_32MDIV3 NRF_QSPI_FREQ_DIV3
+#define NRF_QSPI_FREQ_32MDIV4 NRF_QSPI_FREQ_DIV4
+#define NRF_QSPI_FREQ_32MDIV5 NRF_QSPI_FREQ_DIV5
+#define NRF_QSPI_FREQ_32MDIV6 NRF_QSPI_FREQ_DIV6
+#define NRF_QSPI_FREQ_32MDIV7 NRF_QSPI_FREQ_DIV7
+#define NRF_QSPI_FREQ_32MDIV8 NRF_QSPI_FREQ_DIV8
+#define NRF_QSPI_FREQ_32MDIV9 NRF_QSPI_FREQ_DIV9
+#define NRF_QSPI_FREQ_32MDIV10 NRF_QSPI_FREQ_DIV10
+#define NRF_QSPI_FREQ_32MDIV11 NRF_QSPI_FREQ_DIV11
+#define NRF_QSPI_FREQ_32MDIV12 NRF_QSPI_FREQ_DIV12
+#define NRF_QSPI_FREQ_32MDIV13 NRF_QSPI_FREQ_DIV13
+#define NRF_QSPI_FREQ_32MDIV14 NRF_QSPI_FREQ_DIV14
+#define NRF_QSPI_FREQ_32MDIV15 NRF_QSPI_FREQ_DIV15
+#define NRF_QSPI_FREQ_32MDIV16 NRF_QSPI_FREQ_DIV16
+#endif
+
/** @brief Interface configuration for a read operation. */
typedef enum
{
@@ -171,10 +219,10 @@ typedef struct
uint8_t io0_pin; /**< IO0/MOSI pin number. */
uint8_t io1_pin; /**< IO1/MISO pin number. */
uint8_t io2_pin; /**< IO2 pin number (optional).
- * Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
+ * Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
*/
uint8_t io3_pin; /**< IO3 pin number (optional).
- * Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
+ * Set to @ref NRF_QSPI_PIN_NOT_CONNECTED if this signal is not needed.
*/
} nrf_qspi_pins_t;
@@ -215,10 +263,27 @@ typedef struct
uint8_t sck_delay; /**< tSHSL, tWHSL, and tSHWL in number of 16 MHz periods (62.5ns). */
bool dpmen; /**< Enable the DPM feature. */
nrf_qspi_spi_mode_t spi_mode; /**< SPI phase and polarization. */
- nrf_qspi_frequency_t sck_freq; /**< SCK frequency given as enum @ref nrf_qspi_frequency_t. */
+ nrf_qspi_frequency_t sck_freq; /**< SCK frequency given as QSPI base clock frequency divider.
+ * To calculate @p sck_freq value corresponding to chosen frequency,
+ * use the following equation:
+ *
+ * sck_freq = (NRF_QSPI_BASE_CLOCK_FREQ / frequency) - 1
+ *
+ * @note Achievable frequencies are determined by available
+ * divider values and QSPI base clock frequency.
+ */
} nrf_qspi_phy_conf_t;
+#if NRF_QSPI_HAS_XIP_ENC || NRF_QSPI_HAS_DMA_ENC
+/** @brief QSPI encryption settings for XIP and DMA transfers. */
+typedef struct
+{
+ uint32_t key[4]; /**< AES 128-bit key, stored on 4 32-bit words. */
+ uint32_t nonce[3]; /**< AES 96-bit nonce, stored on 3 32-bit words. */
+} nrf_qspi_encryption_t;
+#endif
+
/**
* @brief Function for activating the specified QSPI task.
*
@@ -499,6 +564,56 @@ NRF_STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type *
nrf_qspi_cinstr_len_t length,
bool finalize);
+#if NRF_QSPI_HAS_XIPEN
+/**
+ * @brief Function for enabling or disabling Execute in Place (XIP) operation.
+ *
+ * @note XIP can be enabled after reset. See Product Specification.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if XIP is to be enabled, false otherwise.
+ */
+NRF_STATIC_INLINE void nrf_qspi_xip_set(NRF_QSPI_Type * p_reg, bool enable);
+#endif
+
+#if NRF_QSPI_HAS_XIP_ENC
+/**
+ * @brief Function for configuring the XIP encryption.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] p_cfg Pointer to encryption configuration structure.
+ */
+NRF_STATIC_INLINE void nrf_qspi_xip_encryption_configure(NRF_QSPI_Type * p_reg,
+ nrf_qspi_encryption_t const * p_cfg);
+
+/**
+ * @brief Function for enabling or disabling the XIP encryption.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if XIP encryption is to be enabled, false otherwise.
+ */
+NRF_STATIC_INLINE void nrf_qspi_xip_encryption_set(NRF_QSPI_Type * p_reg, bool enable);
+#endif
+
+#if NRF_QSPI_HAS_DMA_ENC
+/**
+ * @brief Function for configuring the EasyDMA encryption.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] p_cfg Pointer to encryption configuration structure.
+ */
+NRF_STATIC_INLINE void nrf_qspi_dma_encryption_configure(NRF_QSPI_Type * p_reg,
+ nrf_qspi_encryption_t const * p_cfg);
+
+/**
+ * @brief Function for enabling or disabling the EasyDMA encryption.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if EasyDMA encryption is to be enabled, false otherwise.
+ */
+NRF_STATIC_INLINE void nrf_qspi_dma_encryption_set(NRF_QSPI_Type * p_reg, bool enable);
+#endif
+
#ifndef NRF_DECLARE_ONLY
NRF_STATIC_INLINE void nrf_qspi_task_trigger(NRF_QSPI_Type * p_reg, nrf_qspi_task_t task)
@@ -779,6 +894,55 @@ NRF_STATIC_INLINE void nrf_qspi_cinstr_long_transfer_continue(NRF_QSPI_Type *
p_reg->CINSTRCONF = mask;
}
+#if NRF_QSPI_HAS_XIPEN
+NRF_STATIC_INLINE void nrf_qspi_xip_set(NRF_QSPI_Type * p_reg, bool enable)
+{
+ p_reg->XIPEN = (enable ? QSPI_XIPEN_XIPEN_Enable << QSPI_XIPEN_XIPEN_Pos
+ : QSPI_XIPEN_XIPEN_Disable << QSPI_XIPEN_XIPEN_Pos);
+}
+#endif
+
+#if NRF_QSPI_HAS_XIP_ENC
+NRF_STATIC_INLINE void nrf_qspi_xip_encryption_configure(NRF_QSPI_Type * p_reg,
+ nrf_qspi_encryption_t const * p_cfg)
+{
+ p_reg->XIP_ENC.KEY0 = p_cfg->key[0];
+ p_reg->XIP_ENC.KEY1 = p_cfg->key[1];
+ p_reg->XIP_ENC.KEY2 = p_cfg->key[2];
+ p_reg->XIP_ENC.KEY3 = p_cfg->key[3];
+ p_reg->XIP_ENC.NONCE0 = p_cfg->nonce[0];
+ p_reg->XIP_ENC.NONCE1 = p_cfg->nonce[1];
+ p_reg->XIP_ENC.NONCE2 = p_cfg->nonce[2];
+}
+
+NRF_STATIC_INLINE void nrf_qspi_xip_encryption_set(NRF_QSPI_Type * p_reg, bool enable)
+{
+ p_reg->XIP_ENC.ENABLE =
+ (enable ? QSPI_XIP_ENC_ENABLE_ENABLE_Enabled << QSPI_XIP_ENC_ENABLE_ENABLE_Pos
+ : QSPI_XIP_ENC_ENABLE_ENABLE_Disabled << QSPI_XIP_ENC_ENABLE_ENABLE_Pos);
+}
+#endif
+
+#if NRF_QSPI_HAS_DMA_ENC
+NRF_STATIC_INLINE void nrf_qspi_dma_encryption_configure(NRF_QSPI_Type * p_reg,
+ nrf_qspi_encryption_t const * p_cfg)
+{
+ p_reg->DMA_ENC.KEY0 = p_cfg->key[0];
+ p_reg->DMA_ENC.KEY1 = p_cfg->key[1];
+ p_reg->DMA_ENC.KEY2 = p_cfg->key[2];
+ p_reg->DMA_ENC.KEY3 = p_cfg->key[3];
+ p_reg->DMA_ENC.NONCE0 = p_cfg->nonce[0];
+ p_reg->DMA_ENC.NONCE1 = p_cfg->nonce[1];
+ p_reg->DMA_ENC.NONCE2 = p_cfg->nonce[2];
+}
+
+NRF_STATIC_INLINE void nrf_qspi_dma_encryption_set(NRF_QSPI_Type * p_reg, bool enable)
+{
+ p_reg->DMA_ENC.ENABLE =
+ (enable ? QSPI_DMA_ENC_ENABLE_ENABLE_Enabled << QSPI_DMA_ENC_ENABLE_ENABLE_Pos
+ : QSPI_DMA_ENC_ENABLE_ENABLE_Disabled << QSPI_DMA_ENC_ENABLE_ENABLE_Pos);
+}
+#endif
#endif // NRF_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h
index c661bdf..d3e087d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_radio.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -124,6 +124,11 @@ typedef enum
and BleIeee802154_250Kbit modes when last
bit is sent on the air. */
#endif
+#if defined(RADIO_INTENSET_SYNC_Msk) || defined(__NRFX_DOXYGEN__)
+ NRF_RADIO_EVENT_SYNC = offsetof(NRF_RADIO_Type, EVENTS_SYNC), /**< Generated in Ble_LR125Kbit, Ble_LR500Kbit
+ and BleIeee802154_250Kbit modes when possible
+ preamble has been received. */
+#endif
} nrf_radio_event_t;
/** @brief RADIO interrupts. */
@@ -177,6 +182,9 @@ typedef enum
#if defined(RADIO_INTENSET_PHYEND_Msk) || defined(__NRFX_DOXYGEN__)
NRF_RADIO_INT_PHYEND_MASK = RADIO_INTENSET_PHYEND_Msk, /**< Interrupt on PHYEND event. */
#endif
+#if defined(RADIO_INTENSET_SYNC_Msk) || defined(__NRFX_DOXYGEN__)
+ NRF_RADIO_INT_SYNC_MASK = RADIO_INTENSET_SYNC_Msk, /**< Interrupt on SYNC event. */
+#endif
} nrf_radio_int_mask_t;
/** @brief RADIO shortcuts. */
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h
index 1c10406..3efb462 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,11 +45,95 @@ extern "C" {
* @brief Hardware access layer for managing the REGULATORS peripheral.
*/
+#if defined(REGULATORS_MAINREGSTATUS_VREGH_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether MAINREGSTATUS register is present. */
+#define NRF_REGULATORS_HAS_MAINREGSTATUS 1
+#else
+#define NRF_REGULATORS_HAS_MAINREGSTATUS 0
+#endif
+
+#if defined(REGULATORS_POFCON_POF_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether power failure comparator is present. */
+#define NRF_REGULATORS_HAS_POFCON 1
+#else
+#define NRF_REGULATORS_HAS_POFCON 0
+#endif
+
+#if defined(REGULATORS_POFCON_THRESHOLDVDDH_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether power failure comparator for VDDH is present. */
+#define NRF_REGULATORS_HAS_POFCON_VDDH 1
+#else
+#define NRF_REGULATORS_HAS_POFCON_VDDH 0
+#endif
+
+#if defined(REGULATORS_VREGH_DCDCEN_DCDCEN_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether high voltage regulator is present. */
+#define NRF_REGULATORS_HAS_DCDCEN_VDDH 1
+#else
+#define NRF_REGULATORS_HAS_DCDCEN_VDDH 0
+#endif
+
+#if defined(REGULATORS_VREGRADIO_DCDCEN_DCDCEN_Msk) || defined(__NRFX_DOXYGEN__)
+/** @brief Symbol indicating whether radio regulator is present. */
+#define NRF_REGULATORS_HAS_DCDCEN_RADIO 1
+#else
+#define NRF_REGULATORS_HAS_DCDCEN_RADIO 0
+#endif
+
+#if NRF_REGULATORS_HAS_MAINREGSTATUS
+/** @brief Main regulator status. */
+typedef enum
+{
+ NRF_REGULATORS_MAINREGSTATUS_NORMAL = REGULATORS_MAINREGSTATUS_VREGH_Inactive, /**< Normal voltage mode. Voltage supplied on VDD and VDDH. */
+ NRF_REGULATORS_MAINREGSTATUS_HIGH = REGULATORS_MAINREGSTATUS_VREGH_Active /**< High voltage mode. Voltage supplied on VDDH. */
+} nrf_regulators_mainregstatus_t;
+#endif
+
+#if NRF_REGULATORS_HAS_POFCON
+/** @brief Power failure comparator thresholds. */
+typedef enum
+{
+ NRF_REGULATORS_POFTHR_V19 = REGULATORS_POFCON_THRESHOLD_V19, /**< Set threshold to 1.9 V. */
+ NRF_REGULATORS_POFTHR_V20 = REGULATORS_POFCON_THRESHOLD_V20, /**< Set threshold to 2.0 V. */
+ NRF_REGULATORS_POFTHR_V21 = REGULATORS_POFCON_THRESHOLD_V21, /**< Set threshold to 2.1 V. */
+ NRF_REGULATORS_POFTHR_V22 = REGULATORS_POFCON_THRESHOLD_V22, /**< Set threshold to 2.2 V. */
+ NRF_REGULATORS_POFTHR_V23 = REGULATORS_POFCON_THRESHOLD_V23, /**< Set threshold to 2.3 V. */
+ NRF_REGULATORS_POFTHR_V24 = REGULATORS_POFCON_THRESHOLD_V24, /**< Set threshold to 2.4 V. */
+ NRF_REGULATORS_POFTHR_V25 = REGULATORS_POFCON_THRESHOLD_V25, /**< Set threshold to 2.5 V. */
+ NRF_REGULATORS_POFTHR_V26 = REGULATORS_POFCON_THRESHOLD_V26, /**< Set threshold to 2.6 V. */
+ NRF_REGULATORS_POFTHR_V27 = REGULATORS_POFCON_THRESHOLD_V27, /**< Set threshold to 2.7 V. */
+ NRF_REGULATORS_POFTHR_V28 = REGULATORS_POFCON_THRESHOLD_V28, /**< Set threshold to 2.8 V. */
+} nrf_regulators_pof_thr_t;
+#endif
+
+#if NRF_REGULATORS_HAS_POFCON_VDDH
+/** @brief Power failure comparator thresholds for VDDH. */
+typedef enum
+{
+ NRF_REGULATORS_POFTHRVDDH_V27 = REGULATORS_POFCON_THRESHOLDVDDH_V27, /**< Set threshold to 2.7 V. */
+ NRF_REGULATORS_POFTHRVDDH_V28 = REGULATORS_POFCON_THRESHOLDVDDH_V28, /**< Set threshold to 2.8 V. */
+ NRF_REGULATORS_POFTHRVDDH_V29 = REGULATORS_POFCON_THRESHOLDVDDH_V29, /**< Set threshold to 2.9 V. */
+ NRF_REGULATORS_POFTHRVDDH_V30 = REGULATORS_POFCON_THRESHOLDVDDH_V30, /**< Set threshold to 3.0 V. */
+ NRF_REGULATORS_POFTHRVDDH_V31 = REGULATORS_POFCON_THRESHOLDVDDH_V31, /**< Set threshold to 3.1 V. */
+ NRF_REGULATORS_POFTHRVDDH_V32 = REGULATORS_POFCON_THRESHOLDVDDH_V32, /**< Set threshold to 3.2 V. */
+ NRF_REGULATORS_POFTHRVDDH_V33 = REGULATORS_POFCON_THRESHOLDVDDH_V33, /**< Set threshold to 3.3 V. */
+ NRF_REGULATORS_POFTHRVDDH_V34 = REGULATORS_POFCON_THRESHOLDVDDH_V34, /**< Set threshold to 3.4 V. */
+ NRF_REGULATORS_POFTHRVDDH_V35 = REGULATORS_POFCON_THRESHOLDVDDH_V35, /**< Set threshold to 3.5 V. */
+ NRF_REGULATORS_POFTHRVDDH_V36 = REGULATORS_POFCON_THRESHOLDVDDH_V36, /**< Set threshold to 3.6 V. */
+ NRF_REGULATORS_POFTHRVDDH_V37 = REGULATORS_POFCON_THRESHOLDVDDH_V37, /**< Set threshold to 3.7 V. */
+ NRF_REGULATORS_POFTHRVDDH_V38 = REGULATORS_POFCON_THRESHOLDVDDH_V38, /**< Set threshold to 3.8 V. */
+ NRF_REGULATORS_POFTHRVDDH_V39 = REGULATORS_POFCON_THRESHOLDVDDH_V39, /**< Set threshold to 3.9 V. */
+ NRF_REGULATORS_POFTHRVDDH_V40 = REGULATORS_POFCON_THRESHOLDVDDH_V40, /**< Set threshold to 4.0 V. */
+ NRF_REGULATORS_POFTHRVDDH_V41 = REGULATORS_POFCON_THRESHOLDVDDH_V41, /**< Set threshold to 4.1 V. */
+ NRF_REGULATORS_POFTHRVDDH_V42 = REGULATORS_POFCON_THRESHOLDVDDH_V42, /**< Set threshold to 4.2 V. */
+} nrf_regulators_pof_thrvddh_t;
+#endif
+
/**
* @brief Function for enabling or disabling DCDC converter.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable Set true to enable or false to disable DCDC converter.
+ * @param[in] enable True if DCDC converter is to be enabled, false otherwise.
*/
NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable);
@@ -65,6 +149,86 @@ NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bo
*/
NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg);
+#if NRF_REGULATORS_HAS_MAINREGSTATUS
+/**
+ * @brief Function for getting the main supply status.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return The current main supply status.
+ */
+NRF_STATIC_INLINE
+nrf_regulators_mainregstatus_t nrf_regulators_mainregstatus_get(NRF_REGULATORS_Type const * p_reg);
+#endif
+
+#if NRF_REGULATORS_HAS_POFCON
+/**
+ * @brief Function for setting the power failure comparator configuration.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if power failure comparator is to be enabled, false otherwise.
+ * @param[in] thr Voltage threshold value.
+ */
+NRF_STATIC_INLINE void nrf_regulators_pofcon_set(NRF_REGULATORS_Type * p_reg,
+ bool enable,
+ nrf_regulators_pof_thr_t thr);
+
+/**
+ * @brief Function for getting the power failure comparator configuration.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[out] p_enabled Function sets this boolean variable to true
+ * if power failure comparator is enabled.
+ * The pointer can be NULL if we do not need this information.
+ *
+ * @return Threshold setting for power failure comparator.
+ */
+NRF_STATIC_INLINE
+nrf_regulators_pof_thr_t nrf_regulators_pofcon_get(NRF_REGULATORS_Type const * p_reg,
+ bool * p_enabled);
+#endif // NRF_REGULATORS_HAS_POFCON
+
+#if NRF_REGULATORS_HAS_POFCON_VDDH
+/**
+ * @brief Function for setting the VDDH power failure comparator threshold.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] thr Threshold to be set.
+ */
+NRF_STATIC_INLINE void nrf_regulators_pofcon_vddh_set(NRF_REGULATORS_Type * p_reg,
+ nrf_regulators_pof_thrvddh_t thr);
+
+/**
+ * @brief Function for getting the VDDH regulators failure comparator threshold.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return Threshold setting for regulators failure comparator.
+ */
+NRF_STATIC_INLINE
+nrf_regulators_pof_thrvddh_t nrf_regulators_pofcon_vddh_get(NRF_REGULATORS_Type const * p_reg);
+#endif // NRF_REGULATORS_HAS_POFCON_VDDH
+
+#if NRF_REGULATORS_HAS_DCDCEN_VDDH
+/**
+ * @brief Function for enabling or disabling the high voltage regulator.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if the high voltage regulator is to be enabled, false otherwise.
+ */
+NRF_STATIC_INLINE void nrf_regulators_dcdcen_vddh_set(NRF_REGULATORS_Type * p_reg, bool enable);
+#endif
+
+#if NRF_REGULATORS_HAS_DCDCEN_RADIO
+/**
+ * @brief Function for enabling or disabling the radio regulator.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] enable True if the radio regulator is to be enabled, false otherwise.
+ */
+NRF_STATIC_INLINE void nrf_regulators_dcdcen_radio_set(NRF_REGULATORS_Type * p_reg, bool enable);
+#endif
+
#ifndef NRF_DECLARE_ONLY
NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable)
@@ -88,6 +252,85 @@ NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
}
}
+#if NRF_REGULATORS_HAS_MAINREGSTATUS
+NRF_STATIC_INLINE
+nrf_regulators_mainregstatus_t nrf_regulators_mainregstatus_get(NRF_REGULATORS_Type const * p_reg)
+{
+ return (nrf_regulators_mainregstatus_t)p_reg->MAINREGSTATUS;
+}
+#endif
+
+#if NRF_REGULATORS_HAS_POFCON
+NRF_STATIC_INLINE void nrf_regulators_pofcon_set(NRF_REGULATORS_Type * p_reg,
+ bool enable,
+ nrf_regulators_pof_thr_t thr)
+{
+#if NRF_REGULATORS_HAS_POFCON_VDDH
+ uint32_t pofcon = p_reg->POFCON;
+ pofcon &= ~(REGULATORS_POFCON_THRESHOLD_Msk | REGULATORS_POFCON_POF_Msk);
+ pofcon |=
+#else // NRF_REGULATORS_HAS_POFCON_VDDH
+ p_reg->POFCON =
+#endif
+ (((uint32_t)thr) << REGULATORS_POFCON_THRESHOLD_Pos) |
+ (enable ?
+ (REGULATORS_POFCON_POF_Enabled << REGULATORS_POFCON_POF_Pos)
+ :
+ (REGULATORS_POFCON_POF_Disabled << REGULATORS_POFCON_POF_Pos));
+#if NRF_REGULATORS_HAS_POFCON_VDDH
+ p_reg->POFCON = pofcon;
+#endif
+}
+
+NRF_STATIC_INLINE
+nrf_regulators_pof_thr_t nrf_regulators_pofcon_get(NRF_REGULATORS_Type const * p_reg,
+ bool * p_enabled)
+{
+ uint32_t pofcon = p_reg->POFCON;
+ if (NULL != p_enabled)
+ {
+ (*p_enabled) = ((pofcon & REGULATORS_POFCON_POF_Msk) >> REGULATORS_POFCON_POF_Pos)
+ == REGULATORS_POFCON_POF_Enabled;
+ }
+ return (nrf_regulators_pof_thr_t)((pofcon & REGULATORS_POFCON_THRESHOLD_Msk) >>
+ REGULATORS_POFCON_THRESHOLD_Pos);
+}
+#endif // NRF_REGULATORS_HAS_POFCON
+
+#if NRF_REGULATORS_HAS_POFCON_VDDH
+NRF_STATIC_INLINE void nrf_regulators_pofcon_vddh_set(NRF_REGULATORS_Type * p_reg,
+ nrf_regulators_pof_thrvddh_t thr)
+{
+ uint32_t pofcon = p_reg->POFCON;
+ pofcon &= ~REGULATORS_POFCON_THRESHOLDVDDH_Msk;
+ pofcon |= (((uint32_t)thr) << REGULATORS_POFCON_THRESHOLDVDDH_Pos);
+ p_reg->POFCON = pofcon;
+}
+
+NRF_STATIC_INLINE
+nrf_regulators_pof_thrvddh_t nrf_regulators_pofcon_vddh_get(NRF_REGULATORS_Type const * p_reg)
+{
+ return (nrf_regulators_pof_thrvddh_t)((p_reg->POFCON & REGULATORS_POFCON_THRESHOLDVDDH_Msk) >>
+ REGULATORS_POFCON_THRESHOLDVDDH_Pos);
+}
+#endif // NRF_REGULATORS_HAS_POFCON_VDDH
+
+#if NRF_REGULATORS_HAS_DCDCEN_VDDH
+NRF_STATIC_INLINE void nrf_regulators_dcdcen_vddh_set(NRF_REGULATORS_Type * p_reg, bool enable)
+{
+ p_reg->VREGH.DCDCEN = (enable) ? REGULATORS_VREGH_DCDCEN_DCDCEN_Enabled :
+ REGULATORS_VREGH_DCDCEN_DCDCEN_Disabled;
+}
+#endif
+
+#if NRF_REGULATORS_HAS_DCDCEN_RADIO
+NRF_STATIC_INLINE void nrf_regulators_dcdcen_radio_set(NRF_REGULATORS_Type * p_reg, bool enable)
+{
+ p_reg->VREGRADIO.DCDCEN = (enable) ? REGULATORS_VREGRADIO_DCDCEN_DCDCEN_Enabled :
+ REGULATORS_VREGRADIO_DCDCEN_DCDCEN_Disabled;
+}
+#endif
+
#endif // NRF_DECLARE_ONLY
/** @} */
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h
index 438dedf..b9292c0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_reset.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h
index 27de21e..26698e0 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rng.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h
index ab1c4b7..710b943 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_rtc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h
index 3757413..fef39a3 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_saadc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,7 +66,10 @@ typedef enum
NRF_SAADC_INPUT_AIN5 = SAADC_CH_PSELP_PSELP_AnalogInput5, ///< Analog input 5 (AIN5).
NRF_SAADC_INPUT_AIN6 = SAADC_CH_PSELP_PSELP_AnalogInput6, ///< Analog input 6 (AIN6).
NRF_SAADC_INPUT_AIN7 = SAADC_CH_PSELP_PSELP_AnalogInput7, ///< Analog input 7 (AIN7).
- NRF_SAADC_INPUT_VDD = SAADC_CH_PSELP_PSELP_VDD ///< VDD as input.
+ NRF_SAADC_INPUT_VDD = SAADC_CH_PSELP_PSELP_VDD, ///< VDD as input.
+#if defined(SAADC_CH_PSELP_PSELP_VDDHDIV5) || defined(__NRFX_DOXYGEN__)
+ NRF_SAADC_INPUT_VDDHDIV5 = SAADC_CH_PSELP_PSELP_VDDHDIV5 ///< VDDH/5 as input.
+#endif
} nrf_saadc_input_t;
/** @brief Analog-to-digital converter oversampling mode. */
@@ -254,7 +257,7 @@ NRF_STATIC_INLINE uint32_t nrf_saadc_task_address_get(NRF_SAADC_Type const * p_r
nrf_saadc_task_t task);
/**
- * @brief Function for retrieving the state of the UARTE event.
+ * @brief Function for retrieving the state of the SAADC event.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
* @param[in] event Event to be checked.
@@ -380,6 +383,14 @@ NRF_STATIC_INLINE void nrf_saadc_channel_limits_set(NRF_SAADC_Type * p_reg,
int16_t high);
/**
+ * @brief Function for setting the configuration of SAADC interrupts.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] mask Interrupts configuration to be set.
+ */
+NRF_STATIC_INLINE void nrf_saadc_int_set(NRF_SAADC_Type * p_reg, uint32_t mask);
+
+/**
* @brief Function for enabling specified SAADC interrupts.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
@@ -718,6 +729,11 @@ NRF_STATIC_INLINE void nrf_saadc_channel_limits_set(NRF_SAADC_Type * p_reg,
| (((uint32_t) high << SAADC_CH_LIMIT_HIGH_Pos) & SAADC_CH_LIMIT_HIGH_Msk));
}
+NRF_STATIC_INLINE void nrf_saadc_int_set(NRF_SAADC_Type * p_reg, uint32_t mask)
+{
+ p_reg->INTEN = mask;
+}
+
NRF_STATIC_INLINE void nrf_saadc_int_enable(NRF_SAADC_Type * p_reg, uint32_t mask)
{
p_reg->INTENSET = mask;
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h
index bb5d034..95df3d2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h
index 0ce3a1f..a644f3e 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spim.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,21 +57,24 @@ extern "C" {
(NRFX_CHECK(SPIM0_FEATURE_HARDWARE_CSN_PRESENT) || \
NRFX_CHECK(SPIM1_FEATURE_HARDWARE_CSN_PRESENT) || \
NRFX_CHECK(SPIM2_FEATURE_HARDWARE_CSN_PRESENT) || \
- NRFX_CHECK(SPIM3_FEATURE_HARDWARE_CSN_PRESENT))
+ NRFX_CHECK(SPIM3_FEATURE_HARDWARE_CSN_PRESENT) || \
+ NRFX_CHECK(SPIM4_FEATURE_HARDWARE_CSN_PRESENT))
/** @brief Macro for checking if the DCX pin control is available. */
#define NRF_SPIM_DCX_PRESENT \
(NRFX_CHECK(SPIM0_FEATURE_DCX_PRESENT) || \
NRFX_CHECK(SPIM1_FEATURE_DCX_PRESENT) || \
NRFX_CHECK(SPIM2_FEATURE_DCX_PRESENT) || \
- NRFX_CHECK(SPIM3_FEATURE_DCX_PRESENT))
+ NRFX_CHECK(SPIM3_FEATURE_DCX_PRESENT) || \
+ NRFX_CHECK(SPIM4_FEATURE_DCX_PRESENT))
/** @brief Macro for checking if the RXDELAY function is available. */
#define NRF_SPIM_RXDELAY_PRESENT \
(NRFX_CHECK(SPIM0_FEATURE_RXDELAY_PRESENT) || \
NRFX_CHECK(SPIM1_FEATURE_RXDELAY_PRESENT) || \
NRFX_CHECK(SPIM2_FEATURE_RXDELAY_PRESENT) || \
- NRFX_CHECK(SPIM3_FEATURE_RXDELAY_PRESENT))
+ NRFX_CHECK(SPIM3_FEATURE_RXDELAY_PRESENT) || \
+ NRFX_CHECK(SPIM4_FEATURE_RXDELAY_PRESENT))
#if defined(NRF_SPIM_DCX_PRESENT) || defined(__NRFX_DOXYGEN__)
/**
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h
index cacb815..7819b6b 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spis.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h
index 62b6b4d..847068a 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_spu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h
index 483a749..8269854 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_systick.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h
index 67dbdba..56e1d43 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_temp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h
index 2ffe5cd..d3cc5d6 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_timer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h
index 1ffd531..5e37048 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h
index 50b4ed4..04d7555 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twim.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -104,9 +104,12 @@ typedef enum
/** @brief TWIM master clock frequency. */
typedef enum
{
- NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100, ///< 100 kbps.
- NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps.
- NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400 ///< 400 kbps.
+ NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100, ///< 100 kbps.
+ NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps.
+ NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400, ///< 400 kbps.
+#if defined(TWIM_FREQUENCY_FREQUENCY_K1000) || defined(__NRFX_DOXYGEN__)
+ NRF_TWIM_FREQ_1000K = TWIM_FREQUENCY_FREQUENCY_K1000 ///< 1000 kbps.
+#endif
} nrf_twim_frequency_t;
/** @brief TWIM error source. */
@@ -350,6 +353,15 @@ NRF_STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
uint32_t mask);
/**
+ * @brief Function for getting the shortcut setting.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return Current shortcut configuration.
+ */
+NRF_STATIC_INLINE uint32_t nrf_twim_shorts_get(NRF_TWIM_Type const * p_reg);
+
+/**
* @brief Function for getting the amount of transmitted bytes.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
@@ -553,6 +565,11 @@ NRF_STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_reg,
p_reg->SHORTS = mask;
}
+NRF_STATIC_INLINE uint32_t nrf_twim_shorts_get(NRF_TWIM_Type const * p_reg)
+{
+ return p_reg->SHORTS;
+}
+
NRF_STATIC_INLINE size_t nrf_twim_txd_amount_get(NRF_TWIM_Type const * p_reg)
{
return p_reg->TXD.AMOUNT;
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h
index 55d6684..2dffdaf 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_twis.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h
index 8512cbd..2acc9e9 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uart.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h
index 06c5960..ba79304 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_uarte.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h
index 9759c72..71c56c2 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1086,15 +1086,6 @@ NRF_STATIC_INLINE uint32_t nrf_usbd_ep_amount_get(NRF_USBD_Type const * p_reg, u
NRF_STATIC_INLINE void nrf_usbd_enable(NRF_USBD_Type * p_reg)
{
-#ifdef NRF_FPGA_IMPLEMENTATION
- *(volatile uint32_t *)0x400005F4 = 3;
- __ISB();
- __DSB();
- *(volatile uint32_t *)0x400005F0 = 3;
- __ISB();
- __DSB();
-#endif
-
p_reg->ENABLE = USBD_ENABLE_ENABLE_Enabled << USBD_ENABLE_ENABLE_Pos;
(void) p_reg->ENABLE;
}
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbreg.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbreg.h
new file mode 100644
index 0000000..be811e1
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_usbreg.h
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 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 NRF_USBREG_H__
+#define NRF_USBREG_H__
+
+#include <nrfx.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup nrf_usbreg_hal USBREG HAL
+ * @{
+ * @ingroup nrf_usbd
+ * @ingroup nrf_power
+ * @brief Hardware access layer for managing the USB regulator peripheral.
+ */
+
+/** @brief USBREG events. */
+typedef enum
+{
+ NRF_USBREG_EVENT_USBDETECTED = offsetof(NRF_USBREG_Type, EVENTS_USBDETECTED), /**< Voltage supply detected on VBUS. */
+ NRF_USBREG_EVENT_USBREMOVED = offsetof(NRF_USBREG_Type, EVENTS_USBREMOVED), /**< Voltage supply removed from VBUS. */
+ NRF_USBREG_EVENT_USBPWRRDY = offsetof(NRF_USBREG_Type, EVENTS_USBPWRRDY) /**< USB 3.3 V supply ready. */
+} nrf_usbreg_event_t;
+
+/** @brief USBREG interrupts. */
+typedef enum
+{
+ NRF_USBREG_INT_USBDETECTED = USBREG_INTEN_USBDETECTED_Msk, /**< Interrupt on USBDETECTED. */
+ NRF_USBREG_INT_USBREMOVED = USBREG_INTEN_USBREMOVED_Msk, /**< Interrupt on USBREMOVED. */
+ NRF_USBREG_INT_USBPWRRDY = USBREG_INTEN_USBPWRRDY_Msk /**< Interrupt on USBPWRRDY. */
+} nrf_usbreg_int_mask_t;
+
+/** @brief USBREGSTATUS register bit masks. */
+typedef enum
+{
+ NRF_USBREG_STATUS_VBUSDETECT_MASK = USBREG_USBREGSTATUS_VBUSDETECT_Msk, /**< USB detected or removed. */
+ NRF_USBREG_STATUS_OUTPUTRDY_MASK = USBREG_USBREGSTATUS_OUTPUTRDY_Msk /**< USB 3.3 V supply ready. */
+} nrf_usbreg_status_mask_t;
+
+/**
+ * @brief Function for clearing the specified USBREG event.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] event Event to be cleared.
+ */
+NRF_STATIC_INLINE void nrf_usbreg_event_clear(NRF_USBREG_Type * p_reg,
+ nrf_usbreg_event_t event);
+
+/**
+ * @brief Function for retrieving the state of the USBREG event.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] event Event to be checked.
+ *
+ * @retval true The event has been generated.
+ * @retval false The event has not been generated.
+ */
+NRF_STATIC_INLINE bool nrf_usbreg_event_check(NRF_USBREG_Type const * p_reg,
+ nrf_usbreg_event_t event);
+
+/**
+ * @brief Function for enabling specified interrupts.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] mask Mask of interrupts to be enabled.
+ */
+NRF_STATIC_INLINE void nrf_usbreg_int_enable(NRF_USBREG_Type * p_reg, uint32_t mask);
+
+/**
+ * @brief Function for disabling specified interrupts.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] mask Mask of interrupts to be disabled.
+ */
+NRF_STATIC_INLINE void nrf_usbreg_int_disable(NRF_USBREG_Type * p_reg, uint32_t mask);
+
+/**
+ * @brief Function for checking if the specified interrupts are enabled.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ * @param[in] mask Mask of interrupts to be checked.
+ *
+ * @return Mask of enabled interrupts.
+ */
+NRF_STATIC_INLINE uint32_t nrf_usbreg_int_enable_check(NRF_USBREG_Type const * p_reg,
+ uint32_t mask);
+
+/**
+ * @brief Function for getting the whole USBREGSTATUS register.
+ *
+ * @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @return The USBREGSTATUS register value.
+ * Use @ref nrf_usbreg_status_mask_t values for bit masking.
+ */
+NRF_STATIC_INLINE uint32_t nrf_usbreg_status_get(NRF_USBREG_Type const * p_reg);
+
+#ifndef NRF_DECLARE_ONLY
+
+NRF_STATIC_INLINE void nrf_usbreg_event_clear(NRF_USBREG_Type * p_reg,
+ nrf_usbreg_event_t event)
+{
+ *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
+}
+
+NRF_STATIC_INLINE bool nrf_usbreg_event_check(NRF_USBREG_Type const * p_reg,
+ nrf_usbreg_event_t event)
+{
+ return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
+}
+
+NRF_STATIC_INLINE void nrf_usbreg_int_enable(NRF_USBREG_Type * p_reg, uint32_t mask)
+{
+ p_reg->INTENSET = mask;
+}
+
+NRF_STATIC_INLINE void nrf_usbreg_int_disable(NRF_USBREG_Type * p_reg, uint32_t mask)
+{
+ p_reg->INTENCLR = mask;
+}
+
+NRF_STATIC_INLINE uint32_t nrf_usbreg_int_enable_check(NRF_USBREG_Type const * p_reg,
+ uint32_t mask)
+{
+ return p_reg->INTENSET & mask;
+}
+
+NRF_STATIC_INLINE uint32_t nrf_usbreg_status_get(NRF_USBREG_Type const * p_reg)
+{
+ return p_reg->USBREGSTATUS;
+}
+
+#endif // NRF_DECLARE_ONLY
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NRF_USBREG_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h
index a1d54e4..add75ef 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_vmc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_vreqctrl.h
similarity index 59%
copy from hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h
copy to hw/mcu/nordic/src/ext/nrfx/hal/nrf_vreqctrl.h
index 1c10406..be9d2e5 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_regulators.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_vreqctrl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef NRF_REGULATORS_H__
-#define NRF_REGULATORS_H__
+#ifndef NRF_VREQCTRL_H__
+#define NRF_VREQCTRL_H__
#include <nrfx.h>
@@ -39,53 +39,41 @@ extern "C" {
#endif
/**
- * @defgroup nrf_regulators_hal REGULATORS HAL
+ * @defgroup nrf_vreqctrl_hal VREQCTRL HAL
* @{
* @ingroup nrf_power
- * @brief Hardware access layer for managing the REGULATORS peripheral.
+ * @brief Hardware access layer for managing the VREQCTRL peripheral.
*/
/**
- * @brief Function for enabling or disabling DCDC converter.
+ * @brief Function for requesting high voltage on RADIO, to increase its output power by 3 dBm.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
- * @param[in] enable Set true to enable or false to disable DCDC converter.
+ * @param[in] enable True if high voltage on RADIO is to be enabled, false otherwise.
*/
-NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable);
+NRF_STATIC_INLINE void nrf_vreqctrl_radio_high_voltage_set(NRF_VREQCTRL_Type * p_reg, bool enable);
/**
- * @brief Function for putting CPU in system OFF mode.
- *
- * This function puts the CPU into system off mode.
- * The only way to wake up the CPU is by reset.
- *
- * @note This function never returns.
+ * @brief Function for checking if high voltage on RADIO is ready.
*
* @param[in] p_reg Pointer to the structure of registers of the peripheral.
+ *
+ * @retval true The high voltage is ready.
+ * @retval false The high voltage is not ready.
*/
-NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg);
+NRF_STATIC_INLINE bool nrf_vreqctrl_radio_high_voltage_check(NRF_VREQCTRL_Type const * p_reg);
#ifndef NRF_DECLARE_ONLY
-NRF_STATIC_INLINE void nrf_regulators_dcdcen_set(NRF_REGULATORS_Type * p_reg, bool enable)
+NRF_STATIC_INLINE void nrf_vreqctrl_radio_high_voltage_set(NRF_VREQCTRL_Type * p_reg, bool enable)
{
-#if defined(REGULATORS_DCDCEN_DCDCEN_Msk)
- p_reg->DCDCEN = (enable ? REGULATORS_DCDCEN_DCDCEN_Msk : 0);
-#else
- p_reg->VREGMAIN.DCDCEN = (enable ? REGULATORS_VREGMAIN_DCDCEN_DCDCEN_Msk : 0);
-#endif
+ p_reg->VREGRADIO.VREQH =
+ (enable ? VREQCTRL_VREGRADIO_VREQH_VREQH_Enabled : VREQCTRL_VREGRADIO_VREQH_VREQH_Disabled);
}
-NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
+NRF_STATIC_INLINE bool nrf_vreqctrl_radio_high_voltage_check(NRF_VREQCTRL_Type const * p_reg)
{
- p_reg->SYSTEMOFF = REGULATORS_SYSTEMOFF_SYSTEMOFF_Msk;
- __DSB();
-
- /* Solution for simulated System OFF in debug mode */
- while (true)
- {
- __WFE();
- }
+ return (bool)(p_reg->VREGRADIO.VREQHREADY & VREQCTRL_VREGRADIO_VREQHREADY_READY_Msk);
}
#endif // NRF_DECLARE_ONLY
@@ -96,4 +84,4 @@ NRF_STATIC_INLINE void nrf_regulators_system_off(NRF_REGULATORS_Type * p_reg)
}
#endif
-#endif // NRF_REGULATORS_H__
+#endif // NRF_VREQCTRL_H__
diff --git a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h
index e572fd9..79f866c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h
+++ b/hw/mcu/nordic/src/ext/nrfx/hal/nrf_wdt.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,10 @@
extern "C" {
#endif
+#ifndef NRF_WDT0
+#define NRF_WDT0 NRF_WDT
+#endif
+
/**
* @defgroup nrf_wdt_hal WDT HAL
* @{
diff --git a/hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h b/hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h
index 1c7e2fb..eb8b600 100644
--- a/hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h
+++ b/hw/mcu/nordic/src/ext/nrfx/helpers/nrfx_gppi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Nordic Semiconductor ASA
+ * Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/arm_startup_nrf5340_application.s b/hw/mcu/nordic/src/ext/nrfx/mdk/arm_startup_nrf5340_application.s
index 4152a8c..d9eb6eb 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/arm_startup_nrf5340_application.s
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/arm_startup_nrf5340_application.s
@@ -94,9 +94,9 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD 0 ; Reserved
DCD SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
DCD SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
- DCD SPIM2_IRQHandler
- DCD 0 ; Reserved
- DCD 0 ; Reserved
+ DCD SPIM4_IRQHandler
+ DCD SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+ DCD SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
DCD GPIOTE0_IRQHandler
DCD SAADC_IRQHandler
DCD TIMER0_IRQHandler
@@ -120,7 +120,7 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD PWM0_IRQHandler
DCD PWM1_IRQHandler
DCD PWM2_IRQHandler
- DCD 0 ; Reserved
+ DCD PWM3_IRQHandler
DCD 0 ; Reserved
DCD PDM0_IRQHandler
DCD 0 ; Reserved
@@ -135,8 +135,8 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
- DCD QDEC_IRQHandler
- DCD 0 ; Reserved
+ DCD QDEC0_IRQHandler
+ DCD QDEC1_IRQHandler
DCD 0 ; Reserved
DCD USBD_IRQHandler
DCD USBREGULATOR_IRQHandler
@@ -403,7 +403,9 @@ Default_Handler PROC
EXPORT CLOCK_POWER_IRQHandler [WEAK]
EXPORT SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler [WEAK]
EXPORT SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler [WEAK]
- EXPORT SPIM2_IRQHandler [WEAK]
+ EXPORT SPIM4_IRQHandler [WEAK]
+ EXPORT SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler [WEAK]
+ EXPORT SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler [WEAK]
EXPORT GPIOTE0_IRQHandler [WEAK]
EXPORT SAADC_IRQHandler [WEAK]
EXPORT TIMER0_IRQHandler [WEAK]
@@ -423,13 +425,15 @@ Default_Handler PROC
EXPORT PWM0_IRQHandler [WEAK]
EXPORT PWM1_IRQHandler [WEAK]
EXPORT PWM2_IRQHandler [WEAK]
+ EXPORT PWM3_IRQHandler [WEAK]
EXPORT PDM0_IRQHandler [WEAK]
EXPORT I2S0_IRQHandler [WEAK]
EXPORT IPC_IRQHandler [WEAK]
EXPORT QSPI_IRQHandler [WEAK]
EXPORT NFCT_IRQHandler [WEAK]
EXPORT GPIOTE1_IRQHandler [WEAK]
- EXPORT QDEC_IRQHandler [WEAK]
+ EXPORT QDEC0_IRQHandler [WEAK]
+ EXPORT QDEC1_IRQHandler [WEAK]
EXPORT USBD_IRQHandler [WEAK]
EXPORT USBREGULATOR_IRQHandler [WEAK]
EXPORT KMU_IRQHandler [WEAK]
@@ -440,7 +444,9 @@ SPU_IRQHandler
CLOCK_POWER_IRQHandler
SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
-SPIM2_IRQHandler
+SPIM4_IRQHandler
+SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
GPIOTE0_IRQHandler
SAADC_IRQHandler
TIMER0_IRQHandler
@@ -460,13 +466,15 @@ EGU5_IRQHandler
PWM0_IRQHandler
PWM1_IRQHandler
PWM2_IRQHandler
+PWM3_IRQHandler
PDM0_IRQHandler
I2S0_IRQHandler
IPC_IRQHandler
QSPI_IRQHandler
NFCT_IRQHandler
GPIOTE1_IRQHandler
-QDEC_IRQHandler
+QDEC0_IRQHandler
+QDEC1_IRQHandler
USBD_IRQHandler
USBREGULATOR_IRQHandler
KMU_IRQHandler
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf51.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf51.S
index 9ecb0ff..162db0c 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf51.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf51.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52.S
index dfc79ee..9e97163 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52805.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52805.S
index d725622..3e314c7 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52805.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52805.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S
index 4980201..5bca5cd 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52810.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52811.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52811.S
index 0a1a1e4..ac7fd29 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52811.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52811.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52833.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52833.S
index e781779..042b0c3 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52833.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52833.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52840.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52840.S
index 0de37bb..187a08d 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52840.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf52840.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_application.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_application.S
index e89588a..1b05d92 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_application.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_application.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
@@ -100,9 +100,9 @@ __isr_vector:
.long 0 /*Reserved */
.long SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
.long SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
- .long SPIM2_IRQHandler
- .long 0 /*Reserved */
- .long 0 /*Reserved */
+ .long SPIM4_IRQHandler
+ .long SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+ .long SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
.long GPIOTE0_IRQHandler
.long SAADC_IRQHandler
.long TIMER0_IRQHandler
@@ -126,7 +126,7 @@ __isr_vector:
.long PWM0_IRQHandler
.long PWM1_IRQHandler
.long PWM2_IRQHandler
- .long 0 /*Reserved */
+ .long PWM3_IRQHandler
.long 0 /*Reserved */
.long PDM0_IRQHandler
.long 0 /*Reserved */
@@ -141,8 +141,8 @@ __isr_vector:
.long 0 /*Reserved */
.long 0 /*Reserved */
.long 0 /*Reserved */
- .long QDEC_IRQHandler
- .long 0 /*Reserved */
+ .long QDEC0_IRQHandler
+ .long QDEC1_IRQHandler
.long 0 /*Reserved */
.long USBD_IRQHandler
.long USBREGULATOR_IRQHandler
@@ -504,7 +504,9 @@ Default_Handler:
IRQ CLOCK_POWER_IRQHandler
IRQ SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
IRQ SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
- IRQ SPIM2_IRQHandler
+ IRQ SPIM4_IRQHandler
+ IRQ SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+ IRQ SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
IRQ GPIOTE0_IRQHandler
IRQ SAADC_IRQHandler
IRQ TIMER0_IRQHandler
@@ -524,13 +526,15 @@ Default_Handler:
IRQ PWM0_IRQHandler
IRQ PWM1_IRQHandler
IRQ PWM2_IRQHandler
+ IRQ PWM3_IRQHandler
IRQ PDM0_IRQHandler
IRQ I2S0_IRQHandler
IRQ IPC_IRQHandler
IRQ QSPI_IRQHandler
IRQ NFCT_IRQHandler
IRQ GPIOTE1_IRQHandler
- IRQ QDEC_IRQHandler
+ IRQ QDEC0_IRQHandler
+ IRQ QDEC1_IRQHandler
IRQ USBD_IRQHandler
IRQ USBREGULATOR_IRQHandler
IRQ KMU_IRQHandler
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_network.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_network.S
index 836c37e..e8aa81e 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_network.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf5340_network.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf9160.S b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf9160.S
index bf44dd7..d8b9893 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf9160.S
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/gcc_startup_nrf9160.S
@@ -68,7 +68,7 @@ __HeapBase:
__HeapLimit:
.size __HeapLimit, . - __HeapLimit
- .section .isr_vector
+ .section .isr_vector, "ax"
.align 2
.globl __isr_vector
__isr_vector:
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/iar_startup_nrf5340_application.s b/hw/mcu/nordic/src/ext/nrfx/mdk/iar_startup_nrf5340_application.s
index 4fce0f3..32106ed 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/iar_startup_nrf5340_application.s
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/iar_startup_nrf5340_application.s
@@ -95,9 +95,9 @@ __vector_table
DCD 0 ; Reserved
DCD SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
DCD SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
- DCD SPIM2_IRQHandler
- DCD 0 ; Reserved
- DCD 0 ; Reserved
+ DCD SPIM4_IRQHandler
+ DCD SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+ DCD SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
DCD GPIOTE0_IRQHandler
DCD SAADC_IRQHandler
DCD TIMER0_IRQHandler
@@ -121,7 +121,7 @@ __vector_table
DCD PWM0_IRQHandler
DCD PWM1_IRQHandler
DCD PWM2_IRQHandler
- DCD 0 ; Reserved
+ DCD PWM3_IRQHandler
DCD 0 ; Reserved
DCD PDM0_IRQHandler
DCD 0 ; Reserved
@@ -136,8 +136,8 @@ __vector_table
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
- DCD QDEC_IRQHandler
- DCD 0 ; Reserved
+ DCD QDEC0_IRQHandler
+ DCD QDEC1_IRQHandler
DCD 0 ; Reserved
DCD USBD_IRQHandler
DCD USBREGULATOR_IRQHandler
@@ -429,9 +429,19 @@ SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
B .
- PUBWEAK SPIM2_IRQHandler
+ PUBWEAK SPIM4_IRQHandler
+ SECTION .text:CODE:REORDER:NOROOT(1)
+SPIM4_IRQHandler
+ B .
+
+ PUBWEAK SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+ SECTION .text:CODE:REORDER:NOROOT(1)
+SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
+ B .
+
+ PUBWEAK SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)
-SPIM2_IRQHandler
+SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
B .
PUBWEAK GPIOTE0_IRQHandler
@@ -529,6 +539,11 @@ PWM1_IRQHandler
PWM2_IRQHandler
B .
+ PUBWEAK PWM3_IRQHandler
+ SECTION .text:CODE:REORDER:NOROOT(1)
+PWM3_IRQHandler
+ B .
+
PUBWEAK PDM0_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)
PDM0_IRQHandler
@@ -559,9 +574,14 @@ NFCT_IRQHandler
GPIOTE1_IRQHandler
B .
- PUBWEAK QDEC_IRQHandler
+ PUBWEAK QDEC0_IRQHandler
+ SECTION .text:CODE:REORDER:NOROOT(1)
+QDEC0_IRQHandler
+ B .
+
+ PUBWEAK QDEC1_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)
-QDEC_IRQHandler
+QDEC1_IRQHandler
B .
PUBWEAK USBD_IRQHandler
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h b/hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h
index 289ab23..f36d5e7 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/nrf.h
@@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
/* MDK version */
#define MDK_MAJOR_VERSION 8
-#define MDK_MINOR_VERSION 29
-#define MDK_MICRO_VERSION 0
+#define MDK_MINOR_VERSION 30
+#define MDK_MICRO_VERSION 2
/* Define NRF51_SERIES for common use in nRF51 series devices. Only if not previously defined. */
#if defined (NRF51) ||\
@@ -85,6 +85,18 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#endif
+/* Define coprocessor domains */
+#if defined (NRF5340_XXAA_APPLICATION)
+ #ifndef NRF_APPLICATION
+ #define NRF_APPLICATION
+ #endif
+#endif
+#if defined (NRF5340_XXAA_NETWORK)
+ #ifndef NRF_NETWORK
+ #define NRF_NETWORK
+ #endif
+#endif
+
#if defined(_WIN32)
/* Do not include nrf specific files when building for PC host */
#elif defined(__unix)
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h b/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h
index 27baec4..5da3cea 100644
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h
+++ b/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51.h
@@ -30,10 +30,10 @@
* @file nrf51.h
* @brief CMSIS HeaderFile
* @version 522
- * @date 25. October 2019
- * @note Generated by SVDConv V3.3.25 on Friday, 25.10.2019 09:35:33
+ * @date 17. January 2020
+ * @note Generated by SVDConv V3.3.25 on Friday, 17.01.2020 17:08:30
* from File 'nrf51.svd',
- * last modified on Friday, 25.10.2019 07:35:24
+ * last modified on Friday, 17.01.2020 16:08:22
*/
diff --git a/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51422_erratas.h b/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51422_erratas.h
deleted file mode 100644
index 0f296a5..0000000
--- a/hw/mcu/nordic/src/ext/nrfx/mdk/nrf51422_erratas.h
+++ /dev/null
@@ -1,2579 +0,0 @@
-#ifndef NRF51422_ERRATAS_H
-#define NRF51422_ERRATAS_H
-
-/*
-
-Copyright (c) 2010 - 2018, Nordic Semiconductor ASA All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-3. Neither the name of Nordic Semiconductor ASA 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 NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-*/
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "compiler_abstraction.h"
-
-static bool errata_1(void) __UNUSED;
-static bool errata_2(void) __UNUSED;
-static bool errata_3(void) __UNUSED;
-static bool errata_4(void) __UNUSED;
-static bool errata_5(void) __UNUSED;
-static bool errata_6(void) __UNUSED;
-static bool errata_7(void) __UNUSED;
-static bool errata_8(void) __UNUSED;
-static bool errata_9(void) __UNUSED;
-static bool errata_10(void) __UNUSED;
-static bool errata_11(void) __UNUSED;
-static bool errata_12(void) __UNUSED;
-static bool errata_13(void) __UNUSED;
-static bool errata_14(void) __UNUSED;
-static bool errata_15(void) __UNUSED;
-static bool errata_16(void) __UNUSED;
-static bool errata_17(void) __UNUSED;
-static bool errata_18(void) __UNUSED;
-static bool errata_19(void) __UNUSED;
-static bool errata_20(void) __UNUSED;
-static bool errata_21(void) __UNUSED;
-static bool errata_22(void) __UNUSED;
-static bool errata_23(void) __UNUSED;
-static bool errata_24(void) __UNUSED;
-static bool errata_25(void) __UNUSED;
-static bool errata_26(void) __UNUSED;
-static bool errata_27(void) __UNUSED;
-static bool errata_28(void) __UNUSED;
-static bool errata_29(void) __UNUSED;
-static bool errata_30(void) __UNUSED;
-static bool errata_31(void) __UNUSED;
-static bool errata_32(void) __UNUSED;
-static bool errata_33(void) __UNUSED;
-static bool errata_34(void) __UNUSED;
-static bool errata_35(void) __UNUSED;
-static bool errata_36(void) __UNUSED;
-static bool errata_37(void) __UNUSED;
-static bool errata_38(void) __UNUSED;
-static bool errata_39(void) __UNUSED;
-static bool errata_40(void) __UNUSED;
-static bool errata_41(void) __UNUSED;
-static bool errata_42(void) __UNUSED;
-static bool errata_43(void) __UNUSED;
-static bool errata_44(void) __UNUSED;
-static bool errata_45(void) __UNUSED;
-static bool errata_46(void) __UNUSED;
-static bool errata_47(void) __UNUSED;
-static bool errata_48(void) __UNUSED;
-static bool errata_49(void) __UNUSED;
-static bool errata_50(void) __UNUSED;
-static bool errata_51(void) __UNUSED;
-static bool errata_52(void) __UNUSED;
-static bool errata_53(void) __UNUSED;
-static bool errata_54(void) __UNUSED;
-static bool errata_55(void) __UNUSED;
-static bool errata_56(void) __UNUSED;
-static bool errata_57(void) __UNUSED;
-static bool errata_58(void) __UNUSED;
-static bool errata_59(void) __UNUSED;
-static bool errata_60(void) __UNUSED;
-static bool errata_61(void) __UNUSED;
-static bool errata_62(void) __UNUSED;
-static bool errata_63(void) __UNUSED;
-static bool errata_64(void) __UNUSED;
-static bool errata_65(void) __UNUSED;
-static bool errata_66(void) __UNUSED;
-static bool errata_67(void) __UNUSED;
-static bool errata_68(void) __UNUSED;
-static bool errata_69(void) __UNUSED;
-static bool errata_70(void) __UNUSED;
-static bool errata_71(void) __UNUSED;
-static bool errata_72(void) __UNUSED;
-static bool errata_73(void) __UNUSED;
-static bool errata_74(void) __UNUSED;
-static bool errata_75(void) __UNUSED;
-static bool errata_76(void) __UNUSED;
-static bool errata_77(void) __UNUSED;
-static bool errata_78(void) __UNUSED;
-
-static bool errata_1(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_2(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_3(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_4(void)
-{
- return false;
-}
-
-static bool errata_5(void)
-{
- return false;
-}
-
-static bool errata_6(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_7(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_8(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_9(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_10(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_11(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_12(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_13(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_14(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_15(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_16(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_17(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_18(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_19(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_20(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_21(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_22(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_23(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_24(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_25(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_26(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_27(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_28(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_29(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_30(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_31(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_32(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
- }
- break;
-
- }
-
- return false;
-}
-
-static bool errata_33(void)
-{
- uint32_t var1 = ((*(uint32_t *)0xF0000FE0ul) & 0x000000FFul);
- uint32_t var2 = ((*(uint32_t *)0xF0000FE8ul) & 0x000000F0ul) >> 4;
-
- switch(var1)
- {
- case 0x01:
- switch(var2)
- {
- case 0x00ul:
- return true;
- case 0x01ul:
- return true;
- case 0x02ul:
- return false;
- case 0x04ul:
- return false;
- case 0x07ul:
- return false;
- case 0x08ul:
- return false;
- case 0x09ul:
- return false;
- default:
- return false;
- break;
... 47859 lines suppressed ...
[mynewt-core] 03/06: hw/drivers/adc: Update nrf52_adc driver for
nrfx 2.0.0
Posted by ja...@apache.org.
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 55dc8b7cc85658da7950d987fa80a6c2ea09d71b
Author: Miguel Azevedo <mi...@gmail.com>
AuthorDate: Thu Feb 13 03:35:56 2020 +0000
hw/drivers/adc: Update nrf52_adc driver for nrfx 2.0.0
---
.../adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h | 63 +-
hw/drivers/adc/adc_nrf52/src/adc_nrf52.c | 590 +++++++++++++------
hw/mcu/nordic/nrf52xxx/src/nrfx_saadc_mod.c | 651 ---------------------
3 files changed, 482 insertions(+), 822 deletions(-)
diff --git a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h b/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
index edd0938..52f8efe 100644
--- a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
+++ b/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
@@ -26,8 +26,67 @@
extern "C" {
#endif
+typedef enum {
+ ADC_RESOLUTION_8BIT = 0,
+ ADC_RESOLUTION_10BIT,
+ ADC_RESOLUTION_12BIT,
+ ADC_RESOLUTION_14BIT
+} adc_resolution_t;
+
+typedef enum {
+ ADC_OVERSAMPLE_DISABLED = 0,
+ ADC_OVERSAMPLE_2X,
+ ADC_OVERSAMPLE_4X,
+ ADC_OVERSAMPLE_8X,
+ ADC_OVERSAMPLE_16X,
+ ADC_OVERSAMPLE_32X,
+ ADC_OVERSAMPLE_64X,
+ ADC_OVERSAMPLE_128X,
+ ADC_OVERSAMPLE_256X
+} adc_oversample_t;
+
struct nrf52_adc_dev_cfg {
- uint16_t nadc_refmv; /* reference VDD in mV */
+ uint16_t nadc_refmv; /* Reference VDD in mV */
+};
+
+struct adc_dev_cfg {
+ adc_resolution_t resolution;
+ adc_oversample_t oversample; /* Only works on single channel mode */
+ bool calibrate; /* Calibrate before sampling */
+};
+
+typedef enum {
+ ADC_REFERENCE_INTERNAL = 0,
+ ADC_REFERENCE_VDD_DIV_4
+} adc_ref_t;
+
+typedef enum {
+ ADC_GAIN1_6 = 0,
+ ADC_GAIN1_5,
+ ADC_GAIN1_4,
+ ADC_GAIN1_3,
+ ADC_GAIN1_2,
+ ADC_GAIN1,
+ ADC_GAIN2,
+ ADC_GAIN4
+} adc_gain_t;
+
+typedef enum {
+ ADC_ACQTIME_3US = 0,
+ ADC_ACQTIME_5US,
+ ADC_ACQTIME_10US,
+ ADC_ACQTIME_15US,
+ ADC_ACQTIME_20US,
+ ADC_ACQTIME_40US
+} adc_acq_time_t;
+
+struct adc_chan_cfg {
+ adc_gain_t gain;
+ adc_ref_t reference;
+ adc_acq_time_t acq_time;
+ uint8_t pin;
+ bool differential;
+ uint8_t pin_negative;
};
int nrf52_adc_dev_init(struct os_dev *, void *);
@@ -36,4 +95,4 @@ int nrf52_adc_dev_init(struct os_dev *, void *);
}
#endif
-#endif /* __ADC_H__ */
+#endif /* __ADC_NRF52_H__ */
diff --git a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
index 85ddffc..44cb266 100644
--- a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
+++ b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
@@ -24,9 +24,7 @@
#include <mcu/cmsis_nvic.h>
/* Nordic headers */
-#include <nrfx.h>
#include <nrf_saadc.h>
-#include <nrfx_saadc.h>
#include "adc_nrf52/adc_nrf52.h"
@@ -36,50 +34,102 @@ struct nrf52_saadc_stats {
};
static struct nrf52_saadc_stats nrf52_saadc_stats;
+static struct nrf52_adc_dev_cfg *init_cfg;
static struct adc_dev *global_adc_dev;
-static nrfx_saadc_config_t *global_adc_config;
-static struct nrf52_adc_dev_cfg *init_adc_config;
+static struct adc_chan_config nrf52_adc_chans[SAADC_CH_NUM];
-static uint8_t nrf52_adc_chans[NRF_SAADC_CHANNEL_COUNT * sizeof(struct adc_chan_config)];
+struct nrf52_adc_chan {
+ nrf_saadc_input_t pin_p;
+ nrf_saadc_input_t pin_n;
+ nrf_saadc_channel_config_t nrf_chan;
+};
-static void
-nrf52_saadc_event_handler(const nrfx_saadc_evt_t *event)
-{
- nrfx_saadc_done_evt_t *done_ev;
- int rc;
+struct nrf52_saadc_dev_global {
+ nrf_saadc_value_t *primary_buf;
+ nrf_saadc_value_t *secondary_buf;
+ uint16_t primary_size;
+ uint16_t secondary_size;
+ nrf_saadc_resolution_t resolution;
+ nrf_saadc_oversample_t oversample;
+ struct nrf52_adc_chan channels[SAADC_CH_NUM];
+ bool calibrate;
+};
- if (global_adc_dev == NULL || !global_adc_dev->ad_event_handler_func) {
- ++nrf52_saadc_stats.saadc_events_failed;
- return;
- }
+static struct nrf52_saadc_dev_global g_drv_instance;
- ++nrf52_saadc_stats.saadc_events;
+/**
+ * Initialize a channel with default/unconfigured values.
+ */
+static void
+channel_unconf(int cnum)
+{
+ nrf_saadc_channel_config_t default_ch = {
+ .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,
+ .resistor_p = NRF_SAADC_RESISTOR_DISABLED,
+ .resistor_n = NRF_SAADC_RESISTOR_DISABLED,
+ };
+
+ memcpy(&g_drv_instance.channels[cnum].nrf_chan,
+ &default_ch,
+ sizeof(nrf_saadc_channel_config_t));
+ g_drv_instance.channels[cnum].pin_p = NRF_SAADC_INPUT_DISABLED;
+ g_drv_instance.channels[cnum].pin_n = NRF_SAADC_INPUT_DISABLED;
+ global_adc_dev->ad_chans[cnum].c_configured = 0;
+}
- switch (event->type) {
- case NRFX_SAADC_EVT_DONE:
- done_ev = (nrfx_saadc_done_evt_t * const) &event->data.done;
-
- rc = global_adc_dev->ad_event_handler_func(global_adc_dev,
- global_adc_dev->ad_event_handler_arg,
- ADC_EVENT_RESULT, done_ev->p_buffer,
- done_ev->size * sizeof(nrf_saadc_value_t));
- break;
- case NRFX_SAADC_EVT_CALIBRATEDONE:
- rc = global_adc_dev->ad_event_handler_func(global_adc_dev,
- global_adc_dev->ad_event_handler_arg,
- ADC_EVENT_CALIBRATED, NULL, 0);
- break;
- default:
- assert(0);
- break;
+/**
+ * Initialize a driver instance with default/unconfigured values.
+ */
+static void
+init_instance_unconf(void)
+{
+ int cnum;
+
+ g_drv_instance.primary_buf = NULL;
+ g_drv_instance.secondary_buf = NULL;
+ g_drv_instance.primary_size = 0;
+ g_drv_instance.secondary_size = 0;
+ g_drv_instance.resolution = NRF_SAADC_RESOLUTION_14BIT;
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_DISABLED;
+ g_drv_instance.calibrate = false;
+
+ for (cnum = 0; cnum < SAADC_CH_NUM; cnum++) {
+ channel_unconf(cnum);
}
+}
- if (rc != 0) {
- ++nrf52_saadc_stats.saadc_events_failed;
+/**
+ * Unconfigures the device registers
+ */
+static void
+clear_device_regs(void)
+{
+ int cnum;
+ nrf_saadc_channel_config_t default_ch = {
+ .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,
+ .resistor_p = NRF_SAADC_RESISTOR_DISABLED,
+ .resistor_n = NRF_SAADC_RESISTOR_DISABLED,
+ };
+
+ nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_ALL);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
+
+ for (cnum = 0; cnum < SAADC_CH_NUM; cnum++) {
+ nrf_saadc_channel_init(NRF_SAADC, cnum, &default_ch);
+ nrf_saadc_channel_input_set(NRF_SAADC, cnum, NRF_SAADC_INPUT_DISABLED,
+ NRF_SAADC_INPUT_DISABLED);
}
}
-
/**
* Open the NRF52 ADC device
*
@@ -90,7 +140,7 @@ nrf52_saadc_event_handler(const nrfx_saadc_evt_t *event)
* if resource unavailable. If OS_WAIT_FOREVER specified, blocks
* until resource is available.
* @param arg Argument provided by higher layer to open, in this case
- * it can be a nrfx_saadc_config_t, to override the default
+ * it can be a adc_dev_cfg, to override the default
* configuration.
*
* @return 0 on success, non-zero on failure.
@@ -98,11 +148,10 @@ nrf52_saadc_event_handler(const nrfx_saadc_evt_t *event)
static int
nrf52_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
{
- struct adc_dev *dev;
int rc = 0;
int unlock = 0;
-
- dev = (struct adc_dev *) odev;
+ struct adc_dev *dev = (struct adc_dev *) odev;
+ struct adc_dev_cfg *adc_config = (struct adc_dev_cfg *) arg;
if (os_started()) {
rc = os_mutex_pend(&dev->ad_lock, wait);
@@ -113,24 +162,71 @@ nrf52_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
}
if (++(dev->ad_ref_cnt) == 1) {
- /* Initialize the device */
- rc = nrfx_saadc_init((nrfx_saadc_config_t *) arg,
- nrf52_saadc_event_handler);
- if (rc != NRFX_SUCCESS) {
- goto err;
- }
- rc = 0;
-
+ init_instance_unconf();
+ NVIC_SetPriority(SAADC_IRQn, 0);
+ NVIC_EnableIRQ(SAADC_IRQn);
global_adc_dev = dev;
- global_adc_config = arg;
+
+ if (adc_config) {
+ switch (adc_config->resolution) {
+ case ADC_RESOLUTION_8BIT:
+ g_drv_instance.resolution = NRF_SAADC_RESOLUTION_8BIT;
+ break;
+ case ADC_RESOLUTION_10BIT:
+ g_drv_instance.resolution = NRF_SAADC_RESOLUTION_10BIT;
+ break;
+ case ADC_RESOLUTION_12BIT:
+ g_drv_instance.resolution = NRF_SAADC_RESOLUTION_12BIT;
+ break;
+ case ADC_RESOLUTION_14BIT:
+ g_drv_instance.resolution = NRF_SAADC_RESOLUTION_14BIT;
+ break;
+ default:
+ assert(0);
+ }
+
+ switch (adc_config->oversample) {
+ case ADC_OVERSAMPLE_DISABLED:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_DISABLED;
+ break;
+ case ADC_OVERSAMPLE_2X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_2X;
+ break;
+ case ADC_OVERSAMPLE_4X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_4X;
+ break;
+ case ADC_OVERSAMPLE_8X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_8X;
+ break;
+ case ADC_OVERSAMPLE_16X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_16X;
+ break;
+ case ADC_OVERSAMPLE_32X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_32X;
+ break;
+ case ADC_OVERSAMPLE_64X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_64X;
+ break;
+ case ADC_OVERSAMPLE_128X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_128X;
+ break;
+ case ADC_OVERSAMPLE_256X:
+ g_drv_instance.oversample = NRF_SAADC_OVERSAMPLE_256X;
+ break;
+ default:
+ assert(0);
+ }
+
+ g_drv_instance.calibrate = adc_config->calibrate;
+ }
}
err:
if (unlock) {
os_mutex_release(&dev->ad_lock);
}
- return (rc);
-}
+ return rc;
+}
/**
* Close the NRF52 ADC device.
@@ -156,10 +252,22 @@ nrf52_adc_close(struct os_dev *odev)
unlock = 1;
}
if (--(dev->ad_ref_cnt) == 0) {
- nrfx_saadc_uninit();
+ NVIC_DisableIRQ(SAADC_IRQn);
+ if (nrf_saadc_busy_check(NRF_SAADC)) {
+ 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));
+
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STOPPED);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+ }
+
+ nrf_saadc_disable(NRF_SAADC);
+ init_instance_unconf();
+ clear_device_regs();
global_adc_dev = NULL;
- global_adc_config = NULL;
}
err:
@@ -181,84 +289,98 @@ err:
* @return 0 on success, non-zero on failure.
*/
static int
-nrf52_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
- void *cfgdata)
+nrf52_adc_configure_channel(struct adc_dev *dev, uint8_t cnum, void *cfgdata)
{
- nrf_saadc_channel_config_t *cc;
+ struct adc_chan_cfg *cfg = (struct adc_chan_cfg *) cfgdata;
uint16_t refmv;
- uint8_t res;
- int rc;
+ nrf_saadc_resolution_t res;
- cc = (nrf_saadc_channel_config_t *) cfgdata;
+ if (cnum > SAADC_CH_NUM) {
+ return OS_EINVAL;
+ }
- rc = nrfx_saadc_channel_init(cnum, cc);
- if (rc != NRFX_SUCCESS) {
- goto err;
+ if (nrf_saadc_busy_check(NRF_SAADC)) {
+ return OS_EBUSY;
}
- if (global_adc_config) {
- /* Set the resolution and reference voltage for this channel to
- * enable conversion functions.
- */
- switch (global_adc_config->resolution) {
- case NRF_SAADC_RESOLUTION_8BIT:
- res = 8;
- break;
- case NRF_SAADC_RESOLUTION_10BIT:
- res = 10;
- break;
- case NRF_SAADC_RESOLUTION_12BIT:
- res = 12;
- break;
- case NRF_SAADC_RESOLUTION_14BIT:
- res = 14;
- break;
- default:
- assert(0);
- }
- } else {
- /* Default to 10-bit resolution. */
+ channel_unconf(cnum);
+ dev->ad_chans[cnum].c_configured = 0;
+ if (!cfgdata) {
+ nrf_saadc_channel_init(NRF_SAADC, cnum,
+ &g_drv_instance.channels[cnum].nrf_chan);
+ return 0;
+ }
+
+ switch (g_drv_instance.resolution) {
+ case NRF_SAADC_RESOLUTION_8BIT:
+ res = 8;
+ break;
+ case NRF_SAADC_RESOLUTION_10BIT:
res = 10;
+ break;
+ case NRF_SAADC_RESOLUTION_12BIT:
+ res = 12;
+ break;
+ case NRF_SAADC_RESOLUTION_14BIT:
+ res = 14;
+ break;
+ default:
+ assert(0);
}
- switch (cc->reference) {
- case NRF_SAADC_REFERENCE_INTERNAL:
- refmv = 600; /* 0.6V for NRF52 */
- break;
- case NRF_SAADC_REFERENCE_VDD4:
- refmv = init_adc_config->nadc_refmv / 4;
- break;
- default:
- assert(0);
+ switch (cfg->reference) {
+ case ADC_REFERENCE_INTERNAL:
+ g_drv_instance.channels[cnum].nrf_chan.reference =
+ NRF_SAADC_REFERENCE_INTERNAL;
+ refmv = 600; /* 0.6V for NRF52 */
+ break;
+ case ADC_REFERENCE_VDD_DIV_4:
+ g_drv_instance.channels[cnum].nrf_chan.reference =
+ NRF_SAADC_REFERENCE_VDD4;
+ refmv = init_cfg->nadc_refmv / 4;
+ break;
+ default:
+ assert(0);
}
/* Adjust reference voltage for gain. */
- switch (cc->gain) {
- case NRF_SAADC_GAIN1_6:
- refmv *= 6;
- break;
- case NRF_SAADC_GAIN1_5:
- refmv *= 5;
- break;
- case NRF_SAADC_GAIN1_4:
- refmv *= 4;
- break;
- case NRF_SAADC_GAIN1_3:
- refmv *= 3;
- break;
- case NRF_SAADC_GAIN1_2:
- refmv *= 2;
- break;
- case NRF_SAADC_GAIN2:
- refmv /= 2;
- break;
- case NRF_SAADC_GAIN4:
- refmv /= 4;
- break;
- default:
- break;
+ switch (cfg->gain) {
+ case ADC_GAIN1_6:
+ refmv *= 6;
+ break;
+ case ADC_GAIN1_5:
+ refmv *= 5;
+ break;
+ case ADC_GAIN1_4:
+ refmv *= 4;
+ break;
+ case ADC_GAIN1_3:
+ refmv *= 3;
+ break;
+ case ADC_GAIN1_2:
+ refmv *= 2;
+ break;
+ case ADC_GAIN2:
+ refmv /= 2;
+ break;
+ case ADC_GAIN4:
+ refmv /= 4;
+ break;
+ default:
+ break;
+ }
+
+ g_drv_instance.channels[cnum].pin_p = cfg->pin;
+ if (cfg->differential) {
+ g_drv_instance.channels[cnum].nrf_chan.mode =
+ NRF_SAADC_MODE_DIFFERENTIAL;
+ g_drv_instance.channels[cnum].pin_n = cfg->pin_negative;
}
+ /* Init Channel's registers */
+ nrf_saadc_channel_init(NRF_SAADC, cnum,
+ &g_drv_instance.channels[cnum].nrf_chan);
+
/* Store these values in channel definitions, for conversions to
* milivolts.
*/
@@ -266,58 +388,56 @@ nrf52_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
dev->ad_chans[cnum].c_refmv = refmv;
dev->ad_chans[cnum].c_configured = 1;
- return (0);
-err:
- return (rc);
+ return 0;
}
/**
- * Set buffer to read data into. Implementation of setbuffer handler.
+ * Set buffer to read data into. Implementation of setbuffer handler.
* Sets both the primary and secondary buffers for DMA.
*/
static int
-nrf52_adc_set_buffer(struct adc_dev *dev, void *buf1, void *buf2,
- int buf_len)
+nrf52_adc_set_buffer(struct adc_dev *dev, void *buf1, void *buf2, int buf_len)
{
- int rc;
-
- /* Convert overall buffer length, into a total number of samples which
- * Nordic APIs expect.
- */
- buf_len /= sizeof(nrf_saadc_value_t);
+ assert(dev);
+ assert(buf1);
- rc = nrfx_saadc_buffer_convert((nrf_saadc_value_t *) buf1, buf_len);
- if (rc != NRFX_SUCCESS) {
- goto err;
+ if (buf_len <= 0) {
+ return OS_EINVAL;
}
+ buf_len /= sizeof(nrf_saadc_value_t);
+ g_drv_instance.primary_buf = buf1;
+ g_drv_instance.primary_size = buf_len;
if (buf2) {
- rc = nrfx_saadc_buffer_convert((nrf_saadc_value_t *) buf2,
- buf_len);
- if (rc != NRFX_SUCCESS) {
- goto err;
- }
+ g_drv_instance.secondary_buf = buf2;
+ g_drv_instance.secondary_size = buf_len;
}
- return (0);
-err:
- return (rc);
+
+ return 0;
}
static int
nrf52_adc_release_buffer(struct adc_dev *dev, void *buf, int buf_len)
{
- int rc;
+ assert(dev);
+ assert(buf);
- buf_len /= sizeof(nrf_saadc_value_t);
+ if (buf_len <= 0) {
+ return OS_EINVAL;
+ }
- rc = nrfx_saadc_buffer_convert((nrf_saadc_value_t *) buf, buf_len);
- if (rc != NRFX_SUCCESS) {
- goto err;
+ buf_len /= sizeof(nrf_saadc_value_t);
+ if (!g_drv_instance.primary_buf) {
+ g_drv_instance.primary_buf = buf;
+ g_drv_instance.primary_size = buf_len;
+ } else if (!g_drv_instance.secondary_buf) {
+ g_drv_instance.secondary_buf = buf;
+ g_drv_instance.secondary_size = buf_len;
+ } else {
+ return OS_ENOENT;
}
- return (0);
-err:
- return (rc);
+ return 0;
}
/**
@@ -326,9 +446,58 @@ err:
static int
nrf52_adc_sample(struct adc_dev *dev)
{
- nrfx_saadc_sample();
+ int cnum;
+ int cnum_last = 0;
+ int used_chans = 0;
+
+ if (nrf_saadc_busy_check(NRF_SAADC)) {
+ return OS_EBUSY;
+ }
+
+ for (cnum = 0; cnum < SAADC_CH_NUM; cnum++) {
+ if (dev->ad_chans[cnum].c_configured) {
+ cnum_last = cnum;
+ used_chans++;
+ nrf_saadc_channel_input_set(NRF_SAADC, cnum,
+ g_drv_instance.channels[cnum].pin_p,
+ g_drv_instance.channels[cnum].pin_n);
+ }
+ }
+ assert(used_chans > 0);
+
+ if (g_drv_instance.primary_size < (used_chans * sizeof(nrf_saadc_value_t))) {
+ return OS_ENOMEM;
+ }
+
+ if ((used_chans == 1) &&
+ (g_drv_instance.oversample != NRF_SAADC_OVERSAMPLE_DISABLED)) {
+ nrf_saadc_burst_set(NRF_SAADC, cnum_last, NRF_SAADC_BURST_ENABLED);
+ nrf_saadc_oversample_set(NRF_SAADC, g_drv_instance.oversample);
+ } else {
+ nrf_saadc_oversample_set(NRF_SAADC, NRF_SAADC_OVERSAMPLE_DISABLED);
+ }
+
+ nrf_saadc_resolution_set(NRF_SAADC, g_drv_instance.resolution);
+ nrf_saadc_buffer_init(NRF_SAADC, g_drv_instance.primary_buf,
+ g_drv_instance.primary_size);
+
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
+ nrf_saadc_int_enable(NRF_SAADC,
+ NRF_SAADC_INT_END | NRF_SAADC_INT_CALIBRATEDONE);
+
+ /* Start Sampling */
+ nrf_saadc_enable(NRF_SAADC);
- return (0);
+ if (g_drv_instance.calibrate) {
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_CALIBRATEOFFSET);
+ } else {
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ }
+
+ return 0;
}
/**
@@ -337,9 +506,13 @@ nrf52_adc_sample(struct adc_dev *dev)
static int
nrf52_adc_read_channel(struct adc_dev *dev, uint8_t cnum, int *result)
{
- nrf_saadc_value_t adc_value;
int rc;
int unlock = 0;
+ nrf_saadc_value_t adc_value;
+
+ if (nrf_saadc_busy_check(NRF_SAADC)) {
+ return OS_EBUSY;
+ }
if (os_started()) {
rc = os_mutex_pend(&dev->ad_lock, OS_TIMEOUT_NEVER);
@@ -348,11 +521,42 @@ nrf52_adc_read_channel(struct adc_dev *dev, uint8_t cnum, int *result)
}
unlock = 1;
}
- rc = nrfx_saadc_sample_convert(cnum, &adc_value);
- if (rc != NRFX_SUCCESS) {
+
+ /* Channel must be configured */
+ if (!dev->ad_chans[cnum].c_configured) {
+ rc = OS_EINVAL;
goto err;
}
+ /* Enable the channel, set pins */
+ nrf_saadc_channel_input_set(NRF_SAADC, cnum,
+ g_drv_instance.channels[cnum].pin_p,
+ g_drv_instance.channels[cnum].pin_n);
+
+ if (g_drv_instance.oversample != NRF_SAADC_OVERSAMPLE_DISABLED) {
+ nrf_saadc_burst_set(NRF_SAADC, cnum, NRF_SAADC_BURST_ENABLED);
+ nrf_saadc_oversample_set(NRF_SAADC, g_drv_instance.oversample);
+ } else {
+ nrf_saadc_oversample_set(NRF_SAADC, NRF_SAADC_OVERSAMPLE_DISABLED);
+ }
+
+ nrf_saadc_resolution_set(NRF_SAADC, g_drv_instance.resolution);
+ nrf_saadc_buffer_init(NRF_SAADC, &adc_value, 1);
+ nrf_saadc_enable(NRF_SAADC);
+
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ while (!nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END));
+
+ nrf_saadc_disable(NRF_SAADC);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_STARTED);
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+
+ /* Disable the channel, unset pins */
+ nrf_saadc_channel_input_set(NRF_SAADC, cnum,
+ NRF_SAADC_INPUT_DISABLED,
+ NRF_SAADC_INPUT_DISABLED);
+
*result = (int) adc_value;
rc = 0;
@@ -360,12 +564,12 @@ err:
if (unlock) {
os_mutex_release(&dev->ad_lock);
}
- return (rc);
+ return rc;
}
static int
nrf52_adc_read_buffer(struct adc_dev *dev, void *buf, int buf_len, int off,
- int *result)
+ int *result)
{
nrf_saadc_value_t val;
int data_off;
@@ -376,21 +580,74 @@ nrf52_adc_read_buffer(struct adc_dev *dev, void *buf, int buf_len, int off,
val = *(nrf_saadc_value_t *) ((uint8_t *) buf + data_off);
*result = val;
- return (0);
+ return 0;
}
static int
nrf52_adc_size_buffer(struct adc_dev *dev, int chans, int samples)
{
- return (sizeof(nrf_saadc_value_t) * chans * samples);
+ return sizeof(nrf_saadc_value_t) * chans * samples;
+}
+
+void
+nrf52_saadc_irq_handler(void)
+{
+ adc_event_type_t ev = ADC_EVENT_CALIBRATED;
+ void *buf = NULL;
+ int bufsize = 0;
+
+ if (global_adc_dev == NULL || !global_adc_dev->ad_event_handler_func) {
+ ++nrf52_saadc_stats.saadc_events_failed;
+ return;
+ }
+ ++nrf52_saadc_stats.saadc_events;
+
+ if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END)) {
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
+
+ buf = g_drv_instance.primary_buf;
+ bufsize = g_drv_instance.primary_size * sizeof(nrf_saadc_value_t);
+ if (g_drv_instance.secondary_buf) {
+ g_drv_instance.primary_buf = g_drv_instance.secondary_buf;
+ g_drv_instance.primary_size = g_drv_instance.secondary_size;
+ g_drv_instance.secondary_buf = NULL;
+ g_drv_instance.secondary_size = 0;
+
+ nrf_saadc_buffer_init(NRF_SAADC,
+ g_drv_instance.primary_buf,
+ g_drv_instance.primary_size);
+ } else {
+ nrf_saadc_int_disable(NRF_SAADC, NRF_SAADC_INT_ALL);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
+ nrf_saadc_disable(NRF_SAADC);
+ }
+
+
+ ev = ADC_EVENT_RESULT;
+ global_adc_dev->ad_event_handler_func(global_adc_dev,
+ global_adc_dev->ad_event_handler_arg,
+ ev, buf, bufsize);
+ } else if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE)) {
+ nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
+
+ global_adc_dev->ad_event_handler_func(global_adc_dev,
+ global_adc_dev->ad_event_handler_arg,
+ ev, buf, bufsize);
+
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_STOP);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);
+ nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_SAMPLE);
+ } else {
+ ++nrf52_saadc_stats.saadc_events_failed;
+ }
}
#if MYNEWT_VAL(OS_SYSVIEW)
static void
-saadc_irq_handler(void)
+sysview_irq_handler(void)
{
os_trace_isr_enter();
- nrfx_saadc_irq_handler();
+ nrf52_saadc_irq_handler();
os_trace_isr_exit();
}
#endif
@@ -417,28 +674,23 @@ int
nrf52_adc_dev_init(struct os_dev *odev, void *arg)
{
struct adc_dev *dev;
-
dev = (struct adc_dev *) odev;
os_mutex_init(&dev->ad_lock);
dev->ad_chans = (void *) nrf52_adc_chans;
- dev->ad_chan_count = NRF_SAADC_CHANNEL_COUNT;
+ dev->ad_chan_count = SAADC_CH_NUM;
- OS_DEV_SETHANDLERS(odev, nrf52_adc_open, nrf52_adc_close);
-
- assert(init_adc_config == NULL || init_adc_config == arg);
- init_adc_config = arg;
+ init_cfg = (struct nrf52_adc_dev_cfg *) arg;
+ OS_DEV_SETHANDLERS(odev, nrf52_adc_open, nrf52_adc_close);
dev->ad_funcs = &nrf52_adc_funcs;
#if MYNEWT_VAL(OS_SYSVIEW)
- NVIC_SetVector(SAADC_IRQn, (uint32_t) saadc_irq_handler);
+ NVIC_SetVector(SAADC_IRQn, (uint32_t) sysview_irq_handler);
#else
- NVIC_SetVector(SAADC_IRQn, (uint32_t) nrfx_saadc_irq_handler);
+ NVIC_SetVector(SAADC_IRQn, (uint32_t) nrf52_saadc_irq_handler);
#endif
- return (0);
+ return 0;
}
-
-
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrfx_saadc_mod.c b/hw/mcu/nordic/nrf52xxx/src/nrfx_saadc_mod.c
deleted file mode 100644
index 8d63e94..0000000
--- a/hw/mcu/nordic/nrf52xxx/src/nrfx_saadc_mod.c
+++ /dev/null
@@ -1,651 +0,0 @@
-/**
- * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, 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 "syscfg/syscfg.h"
-
-#if MYNEWT_VAL(BSP_NRF52)
-
-#include <nrfx.h>
-
-#if NRFX_CHECK(NRFX_SAADC_ENABLED)
-#include <nrfx_saadc.h>
-
-#define NRFX_LOG_MODULE SAADC
-#include <nrfx_log.h>
-
-#define EVT_TO_STR(event) \
- (event == NRF_SAADC_EVENT_STARTED ? "NRF_SAADC_EVENT_STARTED" : \
- (event == NRF_SAADC_EVENT_END ? "NRF_SAADC_EVENT_END" : \
- (event == NRF_SAADC_EVENT_DONE ? "NRF_SAADC_EVENT_DONE" : \
- (event == NRF_SAADC_EVENT_RESULTDONE ? "NRF_SAADC_EVENT_RESULTDONE" : \
- (event == NRF_SAADC_EVENT_CALIBRATEDONE ? "NRF_SAADC_EVENT_CALIBRATEDONE" : \
- (event == NRF_SAADC_EVENT_STOPPED ? "NRF_SAADC_EVENT_STOPPED" : \
- "UNKNOWN EVENT"))))))
-
-
-typedef enum
-{
- NRF_SAADC_STATE_IDLE = 0,
- NRF_SAADC_STATE_BUSY = 1,
- NRF_SAADC_STATE_CALIBRATION = 2
-} 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_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
-
-void nrfx_saadc_irq_handler(void)
-{
- if (nrf_saadc_event_check(NRF_SAADC_EVENT_END))
- {
- nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
- NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_SAADC_EVENT_END));
-
- 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;
-
- if (m_cb.p_secondary_buffer == NULL)
- {
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
- }
- else
- {
- 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);
- }
- }
- m_cb.event_handler(&evt);
- m_cb.conversions_end = false;
- }
- }
- 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) &&
-
- (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);
- }
- if (nrf_saadc_event_check(NRF_SAADC_EVENT_CALIBRATEDONE))
- {
- 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;
-
- nrfx_saadc_evt_t evt;
- evt.type = NRFX_SAADC_EVT_CALIBRATEDONE;
- m_cb.event_handler(&evt);
- }
- if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED))
- {
- 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;
- }
- else
- {
- uint32_t limit_flags = m_cb.limits_enabled_flags;
- uint32_t flag_idx;
- nrf_saadc_event_t event;
-
- while (limit_flags)
- {
- 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);
- }
- }
- }
-}
-
-
-nrfx_err_t nrfx_saadc_init(nrfx_saadc_config_t const * p_config,
- nrfx_saadc_event_handler_t event_handler)
-{
- NRFX_ASSERT(p_config);
- NRFX_ASSERT(event_handler);
- nrfx_err_t err_code;
-
- if (m_cb.state != NRFX_DRV_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;
- }
-
- 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);
- NRFX_IRQ_PRIORITY_SET(SAADC_IRQn, p_config->interrupt_priority);
- NRFX_IRQ_ENABLE(SAADC_IRQn);
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
-
- 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;
-}
-
-
-void nrfx_saadc_uninit(void)
-{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
-
- nrf_saadc_int_disable(NRF_SAADC_INT_ALL);
- NRFX_IRQ_DISABLE(SAADC_IRQn);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
-
- // 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);
-
- nrf_saadc_disable();
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
-
- for (uint32_t channel = 0; channel < NRF_SAADC_CHANNEL_COUNT; ++channel)
- {
- if (m_cb.psel[channel].pselp != NRF_SAADC_INPUT_DISABLED)
- {
- nrfx_err_t err_code = nrfx_saadc_channel_uninit(channel);
- NRFX_ASSERT(err_code == NRFX_SUCCESS);
- }
- }
-
- m_cb.state = NRFX_DRV_STATE_UNINITIALIZED;
-}
-
-
-nrfx_err_t nrfx_saadc_channel_init(uint8_t channel,
- nrf_saadc_channel_config_t const * const p_config)
-{
- 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_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)
- {
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
-
-#ifdef NRF52_PAN_74
- if ((p_config->acq_time == NRF_SAADC_ACQTIME_3US) ||
- (p_config->acq_time == NRF_SAADC_ACQTIME_5US))
- {
- nrf_saadc_disable();
- }
-#endif //NRF52_PAN_74
-
- if (m_cb.psel[channel].pselp == NRF_SAADC_INPUT_DISABLED)
- {
- ++m_cb.active_channels;
- }
- 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);
- nrf_saadc_channel_input_set(channel, p_config->pin_p, p_config->pin_n);
-
-#ifdef NRF52_PAN_74
- if ((p_config->acq_time == NRF_SAADC_ACQTIME_3US) ||
- (p_config->acq_time == NRF_SAADC_ACQTIME_5US))
- {
- nrf_saadc_enable();
- }
-#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;
-}
-
-
-nrfx_err_t nrfx_saadc_channel_uninit(uint8_t channel)
-{
- NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
-
- nrfx_err_t err_code;
-
- // A channel can only be uninitialized if the driver is in the idle state.
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
- {
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
-
- if (m_cb.psel[channel].pselp != NRF_SAADC_INPUT_DISABLED)
- {
- --m_cb.active_channels;
- }
- 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;
-}
-
-
-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);
-}
-
-
-nrfx_err_t nrfx_saadc_sample_convert(uint8_t channel, nrf_saadc_value_t * p_value)
-{
- nrfx_err_t err_code;
-
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
- {
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
- 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)
- {
- 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);
- }
- }
- 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);
-
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
-
- NRFX_LOG_INFO("Conversion value: %d, channel %d.", *p_value, channel);
-
- if (m_cb.active_channels > 1)
- {
- 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);
- }
- }
-
- if (m_cb.low_power_mode)
- {
- nrf_saadc_int_enable(NRF_SAADC_INT_STARTED | NRF_SAADC_INT_END);
- }
- else
- {
- nrf_saadc_int_enable(NRF_SAADC_INT_END);
- }
-
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
-
- err_code = NRFX_SUCCESS;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
-
-
-nrfx_err_t nrfx_saadc_buffer_convert(nrf_saadc_value_t * p_buffer, uint16_t size)
-{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
- NRFX_ASSERT((size % m_cb.active_channels) == 0);
- nrfx_err_t err_code;
-
- nrf_saadc_int_disable(NRF_SAADC_INT_END | NRF_SAADC_INT_CALIBRATEDONE);
- if (m_cb.adc_state == NRF_SAADC_STATE_CALIBRATION)
- {
- 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;
- }
- if (m_cb.adc_state == NRF_SAADC_STATE_BUSY)
- {
- 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;
- }
- }
- 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;
-
- NRFX_LOG_INFO("Function: %s, buffer length: %d, active channels: %d.",
- __func__,
- size,
- m_cb.active_channels);
-
- if (m_cb.low_power_mode)
- {
- m_cb.buffer_size_left = size;
- nrf_saadc_buffer_init(p_buffer, m_cb.active_channels);
- }
- else
- {
- nrf_saadc_buffer_init(p_buffer, size);
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
- }
-
- err_code = NRFX_SUCCESS;
- NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
-
-
-nrfx_err_t nrfx_saadc_sample()
-{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
-
- nrfx_err_t err_code = NRFX_SUCCESS;
- if (m_cb.adc_state != NRF_SAADC_STATE_BUSY)
- {
- err_code = NRFX_ERROR_INVALID_STATE;
- }
- else if (m_cb.low_power_mode)
- {
- nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
- }
- else
- {
- nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
- }
-
- NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
-}
-
-
-nrfx_err_t nrfx_saadc_calibrate_offset()
-{
- NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
-
- nrfx_err_t err_code;
-
- if (m_cb.adc_state != NRF_SAADC_STATE_IDLE)
- {
- err_code = NRFX_ERROR_BUSY;
- NRFX_LOG_WARNING("Function: %s, error code: %s.",
- __func__,
- NRFX_LOG_ERROR_STRING_GET(err_code));
- return err_code;
- }
-
- m_cb.adc_state = NRF_SAADC_STATE_CALIBRATION;
-
- 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;
-}
-
-
-bool nrfx_saadc_is_busy(void)
-{
- return (m_cb.adc_state != NRF_SAADC_STATE_IDLE);
-}
-
-
-void nrfx_saadc_abort(void)
-{
- if (nrfx_saadc_is_busy())
- {
- nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
- nrf_saadc_int_enable(NRF_SAADC_INT_STOPPED);
- nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
-
- if (m_cb.adc_state == NRF_SAADC_STATE_CALIBRATION)
- {
- m_cb.adc_state = NRF_SAADC_STATE_IDLE;
- }
- else
- {
- // Wait for ADC being stopped.
- bool result;
- NRFX_WAIT_FOR((m_cb.adc_state != NRF_SAADC_STATE_IDLE), HW_TIMEOUT, 0, result);
- NRFX_ASSERT(result);
- }
-
- nrf_saadc_int_disable(NRF_SAADC_INT_STOPPED);
-
- m_cb.p_buffer = 0;
- m_cb.p_secondary_buffer = 0;
- NRFX_LOG_INFO("Conversion aborted.");
- }
-}
-
-
-void 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(m_cb.event_handler); // only non blocking mode supported
- NRFX_ASSERT(limit_low >= NRFX_SAADC_LIMITL_DISABLED);
- NRFX_ASSERT(limit_high <= NRFX_SAADC_LIMITH_DISABLED);
- NRFX_ASSERT(limit_low < limit_high);
- nrf_saadc_channel_limits_set(channel, limit_low, limit_high);
-
- uint32_t int_mask = nrf_saadc_limit_int_get(channel, NRF_SAADC_LIMIT_LOW);
- if (limit_low == NRFX_SAADC_LIMITL_DISABLED)
- {
- m_cb.limits_enabled_flags &= ~(0x80000000 >> LOW_LIMIT_TO_FLAG(channel));
- nrf_saadc_int_disable(int_mask);
- }
- else
- {
- m_cb.limits_enabled_flags |= (0x80000000 >> LOW_LIMIT_TO_FLAG(channel));
- nrf_saadc_int_enable(int_mask);
- }
-
- int_mask = nrf_saadc_limit_int_get(channel, NRF_SAADC_LIMIT_HIGH);
- if (limit_high == NRFX_SAADC_LIMITH_DISABLED)
- {
- m_cb.limits_enabled_flags &= ~(0x80000000 >> HIGH_LIMIT_TO_FLAG(channel));
- nrf_saadc_int_disable(int_mask);
- }
- else
- {
- m_cb.limits_enabled_flags |= (0x80000000 >> HIGH_LIMIT_TO_FLAG(channel));
- nrf_saadc_int_enable(int_mask);
- }
-}
-
-void nrfx_enable_adc_chan(int chan, nrf_saadc_input_t pselp,
- nrf_saadc_input_t pseln)
-{
- NRFX_ASSERT(m_cb.active_channels < NRF_SAADC_CHANNEL_COUNT);
- ++m_cb.active_channels;
- nrf_saadc_channel_input_set(chan, pselp, pseln);
-}
-
-void nrfx_disable_adc_chan(int chan)
-{
- NRFX_ASSERT(m_cb.active_channels != 0);
- --m_cb.active_channels;
- nrf_saadc_channel_input_set(chan, NRF_SAADC_INPUT_DISABLED,
- NRF_SAADC_INPUT_DISABLED);
-}
-#endif // NRFX_CHECK(NRFX_SAADC_ENABLED)
-#endif /* MYNEWT_VAL(BSP_NRF52) */