MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / spi_setup

Function spi_setup

Software/C/GoPiGo3.h:51–64  ·  view source on GitHub ↗

Set up SPI. Open the file, and define the configuration.

Source from the content-addressed store, hash-verified

49
50// Set up SPI. Open the file, and define the configuration.
51int spi_setup(){
52 spi_file_handle = open(SPIDEV_FILE_NAME, O_RDWR);
53
54 if (spi_file_handle < 0){
55 return ERROR_SPI_FILE;
56 }
57
58 spi_xfer_struct.cs_change = 0; // Keep CS activated
59 spi_xfer_struct.delay_usecs = 0; // delay in us
60 spi_xfer_struct.speed_hz = SPI_TARGET_SPEED; // speed
61 spi_xfer_struct.bits_per_word = 8; // bites per word 8
62
63 return ERROR_NONE;
64}
65
66// Transfer length number of bytes. Write from outArray, read to inArray.
67int spi_transfer_array(uint8_t length, uint8_t *outArray, uint8_t *inArray){

Callers 1

GoPiGo3Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected