Skip to content

Conversation

nerwalt
Copy link
Contributor

@nerwalt nerwalt commented Aug 20, 2025

Adding SPI (Spim and Spis) support to the nrf54l

@nerwalt
Copy link
Contributor Author

nerwalt commented Aug 21, 2025

This PR is inspired by 4393 but takes a different approach to the SPI frequency. The nrf54l introduces a frequency prescaler that can take a relatively wide range of values compared to other NRF chips. Instead of introducing a new Frequency type, I left the prescaler as a u8 for simplicity. The prescaler value is checked in set_config(), and an error is returned if it doesn't meet its constraints.

r.dma().rx().ptr().write_value(rx_ptr);
r.dma().rx().maxcnt().write(|w| w.set_maxcnt(rx_len as _));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below you can see something I reeeeeally would like to avoid (and definitely don't want to support :-) ): #[cfg]'s in the drive code that address the register programming interface change introduced by the nrf54l.
It looks like there is no good way out of the problem. My approach was to hide the change and emulate classic interface, but the project owners want to move the whole codebase to the new interface at the pac level instead.

My opinion: I don't like this and I don't like that [(c) Muzzy from Gondoland], but do not want to block nrf54l development either :)

Copy link
Contributor Author

@nerwalt nerwalt Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that it is not an easy problem. I gave this approach a shot to see what it looks like. I am not a big fan of all the #[cfg()]s. I think I understand why you went the extend route after looking at the uarte module. The number #[cfg()]s required in that module is a lot.

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the comments, and on the earlier nrf54 PR, it would be great if changes were made to nrf-pac to expose a more generic interface that both nrf54 and nrf52 can support

@nerwalt
Copy link
Contributor Author

nerwalt commented Aug 26, 2025

As mentioned in the comments, and on the earlier nrf54 PR, it would be great if changes were made to nrf-pac to expose a more generic interface that both nrf54 and nrf52 can support

I will look more into the PAC changes. I wanted to try this approach to see how it looked. The same approach to the uarte module makes it unmaintainable, so I understand the pushback.

Signed-off-by: Dmitry Tarnyagin <[email protected]>
Signed-off-by: Vegard Eriksen <[email protected]>
Signed-off-by: Tyson Lawrence <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants