From cc2567b9880e37cd683ad8cf5a2ca40285dd814c Mon Sep 17 00:00:00 2001 From: Jelmer Tiete Date: Thu, 23 May 2013 17:52:02 +0200 Subject: [PATCH] working tlc59116 implementation for z1 --- examples/z1/test-tlc59116.c | 13 ++++++++++--- platform/z1/dev/tlc59116.c | 17 +++++++++++++---- platform/z1/dev/tlc59116.h | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/examples/z1/test-tlc59116.c b/examples/z1/test-tlc59116.c index 6fbee8d03..f2d771cd5 100644 --- a/examples/z1/test-tlc59116.c +++ b/examples/z1/test-tlc59116.c @@ -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)); } diff --git a/platform/z1/dev/tlc59116.c b/platform/z1/dev/tlc59116.c index 9e5bd5df3..b1c01ca61 100644 --- a/platform/z1/dev/tlc59116.c +++ b/platform/z1/dev/tlc59116.c @@ -43,6 +43,15 @@ #include "tlc59116.h" #include "i2cmaster.h" + +#if 0 +#include +#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); +// } } /*---------------------------------------------------------------------------*/ diff --git a/platform/z1/dev/tlc59116.h b/platform/z1/dev/tlc59116.h index daa40bb3e..33e742c5a 100644 --- a/platform/z1/dev/tlc59116.h +++ b/platform/z1/dev/tlc59116.h @@ -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 */