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