| 1 | /*********************************************************************** |
| 2 | * Langford SPI header. |
| 3 | * |
| 4 | * This is an aid to help implement the SPI protocol to program on board |
| 5 | * chips. |
| 6 | * |
| 7 | * (c) 2013 Per Vices Corporation |
| 8 | * |
| 9 | * See LICENSE.txt for license and copyright information. |
| 10 | ************************************************************************/ |
| 11 | |
| 12 | #include <sys/ioctl.h> |
| 13 | |
| 14 | /** |
| 15 | * Do SPI writes to the Langord device |
| 16 | * @param DevFD - Device file descriptor (from open()) |
| 17 | * @param NumBytes - Number of bytes to transfer (maximum of 4 = bytes in int) |
| 18 | * @param Content - Data to transfer (NumBytes least significant bytes transfered) |
| 19 | * @param nCS - ioctl command to write SPI nCS pin |
| 20 | * @param SClk - ioctl command to write SPI SCLK pin |
| 21 | * @param SDO - ioctl command to write SPI SDO pin |
| 22 | |
| 23 | * For example, to write 3 bytes 0x123 to ADC A, you can use: |
| 24 | @code |
| 25 | int FD = open("/dev/langford", o_RDWR); |
| 26 | LangordSpiWrite(FD, 3, 0x123, IOCTL_SET_ADCAnCS, IOCTL_SET_ADCASClk, IOCTL_SET_ADCASDIO); |
| 27 | @endcode |
| 28 | */ |
| 29 | int LangordSpiWrite(int DevFD, int NumBytes, int Content, int nCS, int SClk, int SDO); |