]> Git Repo - pov-display-rpi.git/blame - src/tlc59711.c
fixed errors and fromating
[pov-display-rpi.git] / src / tlc59711.c
CommitLineData
4b5f5fcb 1#include "tlc59711.h"
2static uint32_t command = 0;
3static int fd = 0;
a6a035a7 4
5static uint32_t CommandInit();
6
4b5f5fcb 7extern 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}
d41e803b 19extern int tlc59711_send(const uint16_t data[12])
a6a035a7 20{
4b5f5fcb 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;
d41e803b 28 int ret;
29 if((ret = transfer(tx,rx,4)) < 0){
30 return ret;
31 }
4b5f5fcb 32
33
34 // 12 channels per TLC59711
35 for (int8_t c = 11; c >= 0; c--) {
36
37 // 16 bits per channel, send MSB first
38 //spiSend(data[c] >> 8);
39 //spiSend(data[c]);
40 tx[c << 1] = 0xFF;
41 }
d41e803b 42 return transfer(tx,rx,24);
4b5f5fcb 43}
44
45
a6a035a7 46static uint32_t CommandInit()
47{
4b5f5fcb 48 uint32_t commands = 0;
49 commands = 0x25;
50 commands <<= 5;
51 commands |= 0x16;
52 commands <<= 7;
53 commands |= 0x7F;
54 commands <<= 7;
55 commands |= 0x7F;
56 commands <<= 7;
57 commands |= 0x7F;
58 return commands;
59}
This page took 0.027645 seconds and 4 git commands to generate.