-
Hi, im developing a project that requires me to configure the Teensy4.1 as an SPI Slave. i managed to get this setup fairly easily and quickly when using an RP2040. But not using the Teensy4.1. with the 'teensy4-bsp' and 'imxrt-hal' it seems as though Slave mode isnt supported since the only board::lpspi() function takes in a baudrate. and then just calls lpspi new in the imxrt-hal and temporarily disables the peripheral to change the clock. i thought maybe i could just bypass this and call lpspi new without changing the clock. but then saw that the imxrt-hal prepares the pins but im unsure of what mode the peripheral chip select is being set to since for a slave device it needs to be an input. There is also no method available to switch to slave mode when temporarily disabling the peripheral. i am fairly new to embedded programming so please forgive me for any lack of knowledge. i have checked the register values and all seems to be set to what i would want it to be set to. and weirdly when i send data over spi to the Teensy, nothing clocks in. but when i remove tor insert he clock pin it seems to clock in a few empty bytes randomly, but leaving the pin connected doesnt clock anything in at all. Is there actually support for slave mode? using either the hal or bsp since the IMXRT1060 supports slave mode with LPSPI but no high level support for it seemingly. If so, could someone please point me in the right direction. or let me know if im going to have to do this on a much lower level somehow For reference i am using LPSPI4 instance. and for the pins B0_00, B0_01, B0_02, B0_03. these all seem to be correct however as the pin sheet shows and the datasheet explains. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hey Simon. Today's imxrt-hal only supports using LPSPI peripheral as a controller. There's no support for using the LPSPI peripheral as a device. That being said, it might not be too difficult to add LPSPI device support. mciantyre/imxrt-hal@fbc9589 is my quick experiment. The only driver addition is a method to enable device support. The rest of the commit introduces hardware examples and board support for the examples. I'm testing on two of my non-Teensy boards. See the commit message for more information. Until there's a nicer API available, folks will need to use the LPSPI lower-level APIs to coordinate device I/O. |
Beta Was this translation helpful? Give feedback.
-
I think I'm having this issue as well. CS stays high even though it was set to low if I enter |
Beta Was this translation helpful? Give feedback.
Hey Simon. Today's imxrt-hal only supports using LPSPI peripheral as a controller. There's no support for using the LPSPI peripheral as a device.
That being said, it might not be too difficult to add LPSPI device support. mciantyre/imxrt-hal@fbc9589 is my quick experiment. The only driver addition is a method to enable device support. The rest of the commit introduces hardware examples and board support for the examples. I'm testing on two of my non-Teensy boards. See the commit message for more information.
Until there's a nicer API available, folks will need to use the LPSPI lower-level APIs to coordinate device I/O.
rtic_spi_device.rs
shows one way to do that. If you have contributions…