#ifndef TLC59711_H
#define TLC59711_H
#include "spi.h"
-extern void tlc59711_send(const uint16_t data[12]);
+extern int tlc59711_send(const uint16_t data[12]);
extern int tlc59711_init(const char *device);
#endif
\ No newline at end of file
uint16_t test[12] = {0};
tlc59711_init("/dev/spidev1.1");
while(1){
- tlc59711_send(test);
+ int ret;
+ if((ret = tlc59711_send(test)) < 0 ){
+ exit(ret);
+ }
}
return 0;
}
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
if (ret < 1)
- printf("can't send spi message");
+ printf("can't send spi message\n");
return ret;
}
extern int spi_init(spiMode* modes,const char *device )
int fd = spi_init(&modes, device);
return fd;
}
-extern void tlc59711_send(const uint16_t data[12])
+extern int tlc59711_send(const uint16_t data[12])
{
uint8_t rx[24]; // throw away
uint8_t tx[24];
tx[1] = command >> 16;
tx[2] = command >> 8;
tx[3] = command;
- transfer(tx,rx,4);
+ int ret;
+ if((ret = transfer(tx,rx,4)) < 0){
+ return ret;
+ }
// 12 channels per TLC59711
//spiSend(data[c]);
tx[c << 1] = 0xFF;
}
- transfer(tx,rx,24);
+ return transfer(tx,rx,24);
}