Skip to content

Samples: Introduce device_deinit() sample #89927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bjarki-andreasen
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen commented May 14, 2025

Introduce sample which switches ownership of a pin between a GPIO controller and a SPI controller driver, specifically the CS. This specific usecase has been requested before to be able to monitor the CS pin using GPIO to then wake up and switch to SPI when asserted. Its also a generally useful and portable sample of device_deinit(), device_init() and deferred init.

With this, the SPI API is updated with new headers for the _DEINIT variants of SPI_DEVICE_DT_DEFINE, and select SPI device drivers are updated to implement device deinit, drivers for the nRF SPI, nRF SPIM, and NXP LPSPI

@bjarki-andreasen bjarki-andreasen changed the title Samples: Introduce device_deinit() sample Samples: Introduce device_deinit() sample May 14, 2025
@bjarki-andreasen bjarki-andreasen marked this pull request as ready for review May 14, 2025 09:16
@github-actions github-actions bot added area: Samples Samples area: SPI SPI bus platform: nRF Nordic nRFx platform: NXP Drivers NXP Semiconductors, drivers area: MFD labels May 14, 2025
@bjarki-andreasen
Copy link
Collaborator Author

Note I'm all for chaning the name of the sample and its location :)

Add DEVICE_DEINIT variants of SPI_DEVICE_ macros. These include

- SPI_DEVICE_DT_DEINIT_DEFINE()
- SPI_DEVICE_DT_INST_DEINIT_DEFINE()

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Implement device deinit fn for nrf spim device driver.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Implement deinit op in spi_nrfx_spi.c

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Introduce clearirqhandler which clears the irq handler of a
peripheral. Useful for device_deinit().

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Implement deinit op for NXP LPSPI device driver.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Introduce device deinit sample which demonstrates how to share
hardware resources between application and device drivers using
device_deinit(), specifically between a GPIO port and SPI
peripheral.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Copy link

@carlescufi carlescufi added the DNM This PR should not be merged (Do Not Merge) label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: MFD area: Samples Samples area: SPI SPI bus DNM This PR should not be merged (Do Not Merge) platform: nRF Nordic nRFx platform: NXP Drivers NXP Semiconductors, drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants