]>
Commit | Line | Data |
---|---|---|
4b5f5fcb | 1 | #include "tlc59711.h" |
2 | static uint32_t command = 0; | |
3 | static int fd = 0; | |
4 | extern int tlc59711_init(const char *device) | |
5 | { | |
6 | command = CommandInit(); // need to set modes | |
7 | spiMode modes = { | |
8 | .mode = 0, | |
9 | .bits = 8, | |
10 | .speed = 500000, | |
11 | .delay = 0}; | |
12 | ||
13 | int fd = spi_init(&modes, device); | |
14 | return fd; | |
15 | } | |
16 | extern void tlc59711_send(const uint16_t data[12]){ | |
17 | uint8_t rx[24]; // throw away | |
18 | uint8_t tx[24]; | |
19 | ||
20 | tx[0] = command >> 24; | |
21 | tx[1] = command >> 16; | |
22 | tx[2] = command >> 8; | |
23 | tx[3] = command; | |
24 | transfer(tx,rx,4); | |
25 | ||
26 | ||
27 | // 12 channels per TLC59711 | |
28 | for (int8_t c = 11; c >= 0; c--) { | |
29 | ||
30 | // 16 bits per channel, send MSB first | |
31 | //spiSend(data[c] >> 8); | |
32 | //spiSend(data[c]); | |
33 | tx[c << 1] = 0xFF; | |
34 | } | |
35 | transfer(tx,rx,24); | |
36 | } | |
37 | ||
38 | ||
39 | static uint32_t CommandInit(){ | |
40 | uint32_t commands = 0; | |
41 | commands = 0x25; | |
42 | commands <<= 5; | |
43 | commands |= 0x16; | |
44 | commands <<= 7; | |
45 | commands |= 0x7F; | |
46 | commands <<= 7; | |
47 | commands |= 0x7F; | |
48 | commands <<= 7; | |
49 | commands |= 0x7F; | |
50 | return commands; | |
51 | } |