Commit Graph

158 Commits

Author SHA1 Message Date
Alberto Escolar Piedras aa8d6f67f5 RADIO: Handle MAXLEN and other related improvements
Cap the Tx length by MAXLEN when doing a Tx.
(Note that just like in real HW, the transmitted length
field is not altered, so the actual Tx'ed packet is corrupted)

During Rx, handle properly MAXLEN:
Instead of erroring out when the received length is more than
MAXLEN, properly truncate the length during reception.

Check PCNF1 configuration for BLE modulation, to ensure
we only got a configuration we support.
(As other configurations are ignored).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-22 13:12:41 +02:00
Alberto Escolar Piedras acbbc929b8 PPI: Added 2 notes about status and shortcommings
Just that

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-10 14:22:39 +02:00
Alberto Escolar Piedras fa1daebb0f TIMER: Fix bogus events/interrupts if shorts where used
In some cases, if shorts were used,
the timer may unexpectedly set events registers
that would correspond to future events already when
the short was happening,
or may incorrectly miss raising an event for a
simultaneously triggering timer CC.

Fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-10 13:54:53 +02:00
Alberto Escolar Piedras 372954e4da PPI: Handle well an event triggering a task twice
It is possible for a single event to trigger a task
twice either by the same task being both in a channel
TEP and FORK TEP, or by an event triggering
several enabled channels which trigger the same TASK.

In real HW this only cause that task to be triggered
once, but in the models it was triggered multiple
times => fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-09 15:53:23 +02:00
Alberto Escolar Piedras 23bc852e3e TIMER: Add missing HAL function override
The event register write sideeffecting function also needs to be
replaced for simulation. Add it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-02 16:59:20 +02:00
Alberto Escolar Piedras 8cafb5d373 TIMER: Added notes about minor differences
No functional changes.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-02 12:11:33 +02:00
Alberto Escolar Piedras 0a7f846b0a RADIO: Bugfix if DISABLE or STOP during first us of TxStart
If a DISABLE or STOP was received during the first TxChainDelay (1us)
after a Tx START, the task would have been missed.
Fix it.

The issue was introduced in cee41373eb
where the actual Tx start was delayed by TxChainDelay.

Also set already the RADIO STATE register to TX
as soon as the TX START is triggered instead of postponing it
by that microsecond.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-02 11:05:04 +02:00
Alberto Escolar Piedras 0cc86704f3 File opening: Create folders if missing
When opening output files, create the folders if they are
missing, instead of assuming they already exist.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-02 10:12:25 +02:00
Alberto Escolar Piedras 20e134eea3 TIMER: Completed, including all count functionality
* Added missing count compare functionality
* Now each timers has the right amount of CC
  registers, events and tasks
* Interrupts are now level based

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-27 16:08:26 +02:00
Alberto Escolar Piedras cee41373eb RADIO: Improve T_IFS support, and fix for low latency mode
a) Fix for the HW automatically generated TIFS:
One condition which disables this HW feature was missing,
which lead to it being enabled when it shouldnt in some cases.
=> Fix it

b) Fix the DISABLED=>[TR]XEN shortcuts when automatic HW IFS is not used.
The shortcuts were missing in this case.

c) Postpone Tx request to the Phy until the last moment:
That is, do the request Tx_chain_delay later.
As otherwise, if another (pending) HW event was scheduled at the exact
same time as the Tx start it would cause the request to have an abort
reevaluation before the Tx start, which is a violation of the
protocol to the phy.
This issue was triggered, in low latency mode, where a TIMER event
was used to trigger the Tx start task, but could have been triggered
by other concurrent HW events.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-21 17:25:32 +02:00
Alberto Escolar Piedras 46a3f44403 docs: Miscelaneous improvements
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-21 11:22:08 +02:00
Alberto Escolar Piedras 7a5b67d9ee CLOCK: Implement more functionality and PPI connections
Including all PPI EVENTS and TASKS connections,
and missing HAL replacements.
All nRF52833 TASKS are now working.
Though note most operations are still instantaneous,
and don't really do anything more than set registers
and trigger events/interrupts correctly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-10 15:59:41 +02:00
Alberto Escolar Piedras 92c0f4b37e GPIOTE: Add missing include
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-07 14:08:47 +02:00
Alberto Escolar Piedras 33b999d500 GPIO: Fix bug during initialization
Fix a bug during the GPIO models initialization

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-06 10:31:05 +02:00
Alberto Escolar Piedras 2a5984e58c GPIO docs: Added paragraph about comments and empty lines on input files
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-04 12:47:24 +02:00
Alberto Escolar Piedras c1479fc405 GPIO: Add better documentation
Move documentation to its own file, and expand.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-03 16:28:39 +02:00
Alberto Escolar Piedras 0bd02dc498 GPIO & GPIOTE: Add HW models
Add models of the GPIO and GPIOTE peripherals
including PPI connections, and HAL replacements.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-03 11:35:32 +02:00
Alberto Escolar Piedras 5d7d944729 NRF_NVMC: Avoid segfault on double call of cleanup
Although it is not normal, a really bad exit from the program
(due to a programming error) can result
in a double call to the HW clean up functions.
Let's protect it so it does not segfault.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-20 09:44:38 +02:00
Alberto Escolar Piedras daba55c02f BLECrypt_if: Avoid segfault on double call of cleanup
Although it is not normal, a really bad exit from the program
(due to a programming error) can result
in a double call to the HW clean up functions.
Let's protect it so it does not segfault.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-06-20 09:44:32 +02:00
Jędrzej Ciupis 37c571ef7c PPI: add support for nrf_ppi_group_enable
This commit adds implementation of nrf_ppi_group_enable API.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2023-06-01 12:41:15 +02:00
Alberto Escolar Piedras ff79a928c9 BLECrypt: Widen search for crypto library
Some users are constrained about where they can
run the executable. Widen the search to include
the LD_LIBRARY_PATH.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-16 14:47:20 +02:00
Alberto Escolar Piedras 57f0f65644 Makefile: Switch to gnu11 from c11 due to HAL
The Nordic HAL now uses variadic macros, but in a not strictly
conformant way to the C standard, which results in thousands
of warnings when building with -Wpedantic.

Let's switch standard version to avoid this warnings.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-08 15:27:09 +02:00
Alberto Escolar Piedras 68ed36fad1 NVMC: Minor fixes in command line options descriptions
No functional changes.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-08 11:24:39 +02:00
Alberto Escolar Piedras c8d2ecd25d NVMC: Improvements around the partial erase functionality
Including a command line option to enable warnings

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-05-01 16:05:23 +02:00
Alberto Escolar Piedras ca763c33ca NVMC: Misc addons
Add missing link to UICR docs
(The same file (NVMC) contains both components)

Add replacements for the new nrf HAL
read byte and read halfword functions.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-28 12:50:00 +02:00
Alberto Escolar Piedras 10ef6a9f8f NVMC & UICR: Add functionality
Including the necessary hal replacements.

And add in the FICR the flash page info.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-27 16:07:28 +02:00
Alberto Escolar Piedras aaf0c6d9e4 TEMP,RNG: Fix typo in function prototype
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-26 16:34:13 +02:00
Alberto Escolar Piedras f215f297fe PPI: Fix undefined behaviour issue detected by UBSan
The detected issue is unlikely to cause any trouble,
but better to just fix it.

NRF_PPI.c:546:63: runtime error: left shift of
1 by 31 places cannot be represented in type 'int'

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-24 13:23:35 +02:00
Alberto Escolar Piedras 1eae2683f7 top_level: Call all init and cleanup functions even if empty
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-21 11:46:36 +02:00
Alberto Escolar Piedras bad9877e99 TEMP: Connect at the top level
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-14 14:58:54 +02:00
Alberto Escolar Piedras b4b369fbb1 TEMP: Add simple model of the temperature sensor
Including the necessary hal replacements,
and connect its event in the PPI

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-13 17:45:20 +02:00
Alberto Escolar Piedras e041ae6ccd RNG: Fix after TASK_STOP triggered by short
RNG would not start again with a TASK_START if it was
stopped with the short.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-13 17:42:55 +02:00
Alberto Escolar Piedras c5daf6abe8 ECB: Provide cheat interface to adjust the time it takes to complete
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-30 13:56:54 +02:00
Alberto Escolar Piedras 7078310d52 nrfx/drivers: Add missing EGU interrupts to nrfx_get_irq_number()
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-28 09:50:27 +02:00
Alberto Escolar Piedras 4bb169a654 PPI: Add all RTCs compare and overflow events
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-28 09:50:27 +02:00
Alberto Escolar Piedras 753f5db19d Add version file
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-23 15:04:14 +01:00
Alberto Escolar Piedras feb3e555f7 Refactor CMSIS dependencies
The idea is that the CMSIS replacement (if any is necessary)
is provided by the integrating program.
Nonetheless, there is a minimal set we need to provide
here due to the nrfx dependencies.

Note that this change is accompanied by an equivalent change
in Zephyr's nrf52_bsim.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-17 14:07:03 +01:00
Alberto Escolar Piedras a63e475b72 FICR: Add some trivial values
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-17 11:13:00 +01:00
Alberto Escolar Piedras a7960c4017 docs: Add notes on ARM peripherals
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-16 16:31:19 +01:00
Alberto Escolar Piedras bb7afb33cc TIMER: Add TASK_SHUTDOWN functionality
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-15 14:32:42 +01:00
Alberto Escolar Piedras e0292ac653 Rx continuation during header evaluation: Procedure change
Devices may need to update the abort substructure during
a header reevaluation.
Let's update the procedure so it is possible to do so.

NOTE!: This requires the equivalent update from the
2G4 Phy and 2G4 libPhyCom

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-15 09:19:02 +01:00
Alberto Escolar Piedras 565fbb928b RADIO: 15.4 Fix placement of LQI result in packet buffer
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-13 11:07:59 +01:00
Alberto Escolar Piedras 9fff44edad RADIO: Minor refactoring around Phy Rx resp handling
No functional change

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras 1e0c0cd1e6 RADIO: Added documentation
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras 131b147c63 RADIO: Added Energy detect procedure
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras 8bcabc0384 RADIO: Added FRAMESTART signal generation
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras f06c0b9f57 RADIO: Add CCA procedure
All modes

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras a3bcfe85b0 RADIO: Add timings for 15.4 modulation
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras 96388061f4 RADIO: Append LQI measurement to end of payload in RAM
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00
Alberto Escolar Piedras c337c7b2c8 RADIO: Add support for lenght field including the CRC lenght
PCNFO.CRCINC

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-03-10 09:55:28 +01:00