54 tlc59116_write_reg(uint8_t reg, uint8_t val)
56 uint8_t tx_buf[] = { reg, val };
58 i2c_transmitinit(TLC59116_ADDR);
60 PRINTFDEBUG(
"I2C Ready to TX\n");
62 i2c_transmit_n(2, tx_buf);
64 PRINTFDEBUG(
"WRITE_REG 0x%02X @ reg 0x%02X\n", val, reg);
77 tlc59116_write_stream(uint8_t len, uint8_t *data)
79 i2c_transmitinit(TLC59116_ADDR);
81 PRINTFDEBUG(
"I2C Ready to TX(stream)\n");
83 i2c_transmit_n(len, data);
85 PRINTFDEBUG(
"WRITE_STR %u B to 0x%02X\n", len, data[0]);
95 tlc59116_read_reg(uint8_t reg)
100 PRINTFDEBUG(
"READ_REG 0x%02X\n", reg);
103 i2c_transmitinit(TLC59116_ADDR);
105 i2c_transmit_n(1, &rtx);
109 i2c_receiveinit(TLC59116_ADDR);
111 i2c_receive_n(1, &retVal);
125 tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t *whereto)
129 PRINTFDEBUG(
"READ_STR %u B from 0x%02X\n", len, reg);
132 i2c_transmitinit(TLC59116_ADDR);
134 i2c_transmit_n(1, &rtx);
138 i2c_receiveinit(TLC59116_ADDR);
140 i2c_receive_n(len, whereto);
151 tlc59116_led(uint8_t led, uint8_t pwm)
153 if((led < 0) || (led > 15)) {
154 PRINTFDEBUG(
"TLC59116: wrong led value.");
156 tlc59116_write_reg(led + TLC59116_PWM0, pwm);
171 tlc59116_write_reg(TLC59116_MODE1, TLC59116_MODE1_DEFAULT);
172 tlc59116_write_reg(TLC59116_MODE2, TLC59116_MODE2_DEFAULT);
177 { TLC59116_PWM0_AUTOINCR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
178 tlc59116_write_stream(17, tx_buf);
181 tlc59116_write_reg(TLC59116_LEDOUT0, TLC59116_LEDOUT_PWM);
182 tlc59116_write_reg(TLC59116_LEDOUT1, TLC59116_LEDOUT_PWM);
183 tlc59116_write_reg(TLC59116_LEDOUT2, TLC59116_LEDOUT_PWM);
184 tlc59116_write_reg(TLC59116_LEDOUT3, TLC59116_LEDOUT_PWM);
void i2c_enable(void)
Configure serial controller in I2C mode and set I2C speed.
Device drivers header file for TLC59116 i2c led driver on Zolertia Z1.
I2C communication device driver header file for Zolertia Z1 sensor node.