-
Notifications
You must be signed in to change notification settings - Fork 2
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
SPI device driver #3
Comments
Hello Zetlark28, Few points to consider:
Your application should follow the same SPI bus and device driver initialization and usage flow as in https://github.com/asuol/RTEMS_rpi_testing/blob/master/SPI_bus/Test_cases/SPI_23k256_TEST/init.c As for the new SPI framework, both API's (libi2c and the linux ported one) are available on RTEMS. The RPI SPI device driver (https://git.rtems.org/rtems/tree/bsps/arm/raspberrypi/spi/spi.c) is developed using the libi2c API, so currently that is the API required for using SPI with the RPI. The libi2c is deprecated in the sense that it should not be used to develop new BSP drivers, but it is still available as older drivers (such as the RPI SPI driver) were not ported yet to the new SPI framework. |
Hi asuol, sorry to bother you again. I check all points:
It seems that the CE0 pin doesn't switch to level high when the write operation it's finished. I connect the CE0 pin to a LED and it's turned off during the write operation, but it doesn't turn on when it's finished. It's possible that the function rtems_libi2c_send_stop(minor) doesn't work? Thank you. |
The SPI interface supported in the RTEMS SPI driver is the standard 4-wire (or 3-wire if the driver is configured for bidirectional mode) SPI protocol, meaning it should only support full-duplex communication, where to send a byte to the slave device the slave device must send a (possibly dummy) byte back. However since your device does not send data back, the raspberry may not actually send data to it, hence why I believe you see the CS line still low after the transfer call returned - the data was placed in the TX FIFO but the RPI is waiting for (dummy) data from the slave so it can send your data (full-duplex communication). I never tested the RTEMS RPI SPI driver with an unidirectional slave device, and I believe the way the RTEMS driver is implemented today does not support this type of slave device. I realize now that I actually stated in the driver itself that write-only devices were not supported (https://git.rtems.org/rtems/tree/bsps/arm/raspberrypi/spi/spi.c#n19) Sorry for not making this clearer sooner, it has been a while since I last had a look into this driver. |
Hi asuol, |
You can invert (active high instead of low) the CS line by setting the CSPOL or CSPOL0 field to 1 in the RPI SPI CS register (check the RPI datasheet at https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf page 155). In the RTEMS RPI driver this register is named "BCM2835_SPI_CS" However the datasheet for your device states that the CS line is to be held low during writes. Also, is the MOSI wave representative of the data you are sending? Are you sending 0xFFFF in the first image? You should also check the clock line to see if the data transfer on the MOSI line matches the clock pulses, or compare your waveforms with the ones in page 23 of https://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf As for your second diagram, assuming the yellow line is VoutA, it is expected from looking at the write command waveforms in the device datasheet referenced above for the Vout line to be idle during writes (i.e.: when the CS line is low) |
When writing values to hardware registers it is best to use the Regarding your ps at the end, are you talking about the new SPI driver framework? Are you developing a separate SPI driver or modifying the existing RPI spi driver (at https://git.rtems.org/rtems/tree/bsps/arm/raspberrypi/spi/spi.c)? As for the VoutA line increase, what are your commands trying to do? Are all commands 0x3FFF? |
Hi, I'm working with your SPI device driver but for the MCP4822 component, and it's not working.
There isn't any compiler or run-time errors, but it seems that the MCP4822 doesn't receive data.
This is the edited code of the driver:
rtems_status_code spi_mcp4822_read is empty because the MCP4822 can't be read.
I read the issue about the I2C device driver, and I understand that the libi2c is deprecated
I'm working with RTEMS v5.1 and I see that they add the SPI framework: https://git.rtems.org/rtems/commit/?h=5&id=a42be52bbf2b3a549d4b9635a5a93215dacd0657.
Do you have any advice?
Thank you in advice for your help
The text was updated successfully, but these errors were encountered: