README.md
1## nRFx HAL
2
3The HAL source files provided with these models implement
4some modifications to [the real nRFx HAL](https://github.com/NordicSemiconductor/nrfx/)
5needed due to the HW models peculiarities.
6Its main purpose is to allow unmodified embedded code to run directly
7using this repository HW models.
8
9There is two main differences in this HAL compared to the real one:
10
11* The peripherals base addresses point to the HW models register IF
12 instead of to hardcoded HW addresses.<br>
13 For example `NRF_PPI_BASE` is defined as `(&NRF_PPI_regs)`, where
14 `NRF_PPI_regs` is the HW models structure containing the PPI model
15 registers
16
17* When a HW register with sideeffects is written, the appropriate
18 HW model function is called to trigger that sideeffect.<br>
19 A sideeffect should be understood as some activity beyond the modification
20 of the register itself. For example, in real HW, writting a `1` to
21 `NRF_RNG->TASKS_START` will start the random number generation.
22 When using the HW models, doing this write in itself would only change
23 that memory location content. To trigger the actual sideeffect the
24 function `nrf_rng_regw_sideeffects_TASK_START()` needs to be called.
25 This replacement HAL functions take care of that.
26
27The original implementation of the HAL APIs from the real nrfx is included in
28`nrf_hal_originals.c`.
29All these functions are labelled as weak, so they can be replaced as needed with content
30of `src/nrfx/hal/`. This removes the need for duplicating code.
31
32Note that this replacement HAL only provides the necessary replacements for the subset of the
33nRFx API corresponding to the peripherals included in these models.
34Note also that for these, not necessarily all nRFx functions which could need replacing are
35included. Though those used by Zephyr should be included.
36It is certainly possible to expand it to cover the whole API.
37