working tlc59116 implementation for z1

This commit is contained in:
Jelmer Tiete 2013-05-23 17:52:02 +02:00
parent 8b61492152
commit cc2567b988
3 changed files with 25 additions and 9 deletions

View file

@ -41,7 +41,7 @@
#include "contiki.h"
#include "dev/tlc59116.h"
#define BLINK_INTERVAL CLOCK_SECOND/2
#define BLINK_INTERVAL CLOCK_SECOND/25
/*---------------------------------------------------------------------------*/
PROCESS(tlc59116_process, "Test tlc59116 process");
@ -51,6 +51,7 @@ AUTOSTART_PROCESSES(&tlc59116_process);
/* Main process, setups */
static struct etimer et;
static uint8_t count = 0;
PROCESS_THREAD(tlc59116_process, ev, data) {
PROCESS_BEGIN();
@ -61,8 +62,14 @@ PROCESS_THREAD(tlc59116_process, ev, data) {
while (1) {
tlc59116_led(0x02,0xFF);
printf("Ping.\n");
tlc59116_led(count,0x00);
tlc59116_led((count+1)%16,0x20);
tlc59116_led((count+2)%16,0x40);
tlc59116_led((count+3)%16,0xFF);
count++;
if(count>15) count=0;
etimer_set(&et, BLINK_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}

View file

@ -43,6 +43,15 @@
#include "tlc59116.h"
#include "i2cmaster.h"
#if 0
#include <stdio.h>
#define PRINTFDEBUG(...) printf(__VA_ARGS__)
#else
#define PRINTFDEBUG(...)
#endif
/*---------------------------------------------------------------------------*/
/* Write to a register.
args:
@ -142,11 +151,11 @@ tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t *whereto) {
void
tlc59116_led(uint8_t led, uint8_t pwm) {
if (led<1 | led>16) {
if (led<0 | led>15) {
PRINTFDEBUG("TLC59116: wrong led value.");
}
tlc59116_write_reg(led, pwm);
}//else{
tlc59116_write_reg(led+TLC59116_PWM0, pwm);
// }
}
/*---------------------------------------------------------------------------*/

View file

@ -96,8 +96,8 @@ void tlc59116_led(uint8_t led, uint8_t pwm);
/* -------------------------------------------------------------------------- */
/* Reference definitions, should not be changed */
/* TLC59116 slave address */
#define TLC59116_ADDR 0xC0 //adress with all adress pins pulled to ground
#define TLC59116_ALLCALL 0xD0
#define TLC59116_ADDR 0x60 //7bit adress 0xC0 8bit adress; adress with all adress pins pulled to ground
//#define TLC59116_ALLCALL 0xD0
#define TLC59116_LEDOUT_PWM 0xAA // LDRx = 01 -> PWM, 4 leds per reg: 01010101 -> 0xAA
/* TLC59116 registers */