contiki code style changes and copyright update + added source to ARCH instead of SOURCEFILES in platform Makefile
This commit is contained in:
parent
0a4a14aacb
commit
9810bfbcfd
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
* Copyright (c) 2013, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -54,7 +54,8 @@ AUTOSTART_PROCESSES(&tlc59116_process);
|
||||||
static struct etimer et;
|
static struct etimer et;
|
||||||
static uint8_t count = 0;
|
static uint8_t count = 0;
|
||||||
|
|
||||||
PROCESS_THREAD(tlc59116_process, ev, data) {
|
PROCESS_THREAD(tlc59116_process, ev, data)
|
||||||
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -69,7 +70,9 @@ PROCESS_THREAD(tlc59116_process, ev, data) {
|
||||||
tlc59116_led((count + 3) % 16, 0xFF);
|
tlc59116_led((count + 3) % 16, 0xFF);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
if(count>15) count=0;
|
if(count > 15) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
etimer_set(&et, BLINK_INTERVAL);
|
etimer_set(&et, BLINK_INTERVAL);
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
|
|
@ -17,7 +17,7 @@ ARCH=msp430.c leds.c watchdog.c xmem.c \
|
||||||
checkpoint-arch.c slip.c slip_uart0.c \
|
checkpoint-arch.c slip.c slip_uart0.c \
|
||||||
z1-phidgets.c sht11.c sht11-sensor.c light-sensor.c \
|
z1-phidgets.c sht11.c sht11-sensor.c light-sensor.c \
|
||||||
battery-sensor.c sky-sensors.c tmp102.c temperature-sensor.c light-ziglet.c \
|
battery-sensor.c sky-sensors.c tmp102.c temperature-sensor.c light-ziglet.c \
|
||||||
relay-phidget.c
|
relay-phidget.c tlc59116.c
|
||||||
|
|
||||||
CONTIKI_TARGET_DIRS = . dev apps net
|
CONTIKI_TARGET_DIRS = . dev apps net
|
||||||
ifndef CONTIKI_TARGET_MAIN
|
ifndef CONTIKI_TARGET_MAIN
|
||||||
|
@ -33,7 +33,7 @@ CFLAGS += -DMACID=$(nodemac)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
|
CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS)
|
||||||
CONTIKI_TARGET_SOURCEFILES += i2cmaster.c adxl345.c tlc59116.c
|
CONTIKI_TARGET_SOURCEFILES += i2cmaster.c adxl345.c
|
||||||
|
|
||||||
MCU=msp430f2617
|
MCU=msp430f2617
|
||||||
include $(CONTIKI)/cpu/msp430/Makefile.msp430
|
include $(CONTIKI)/cpu/msp430/Makefile.msp430
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
* Copyright (c) 2013, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* Device drivers for tlc5916 i2c led driver on Zolertia Z1.
|
* Device drivers for tlc59116 i2c led driver on Zolertia Z1.
|
||||||
* See http://www.ti.com/product/tlc59116 for datasheet.
|
* See http://www.ti.com/product/tlc59116 for datasheet.
|
||||||
* \author
|
* \author
|
||||||
* Jelmer Tiete, VUB <jelmer@tiete.be>
|
* Jelmer Tiete, VUB <jelmer@tiete.be>
|
||||||
|
@ -47,13 +47,14 @@
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Write to a register.
|
/* Write to a register.
|
||||||
args:
|
* args:
|
||||||
reg register to write to
|
* reg register to write to
|
||||||
val value to write
|
* val value to write
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tlc59116_write_reg(uint8_t reg, uint8_t val) {
|
tlc59116_write_reg(uint8_t reg, uint8_t val)
|
||||||
|
{
|
||||||
uint8_t tx_buf[] = { reg, val };
|
uint8_t tx_buf[] = { reg, val };
|
||||||
|
|
||||||
i2c_transmitinit(TLC59116_ADDR);
|
i2c_transmitinit(TLC59116_ADDR);
|
||||||
|
@ -66,15 +67,17 @@ tlc59116_write_reg(uint8_t reg, uint8_t val) {
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Write several registers from a stream.
|
/* Write several registers from a stream.
|
||||||
args:
|
* args:
|
||||||
len number of bytes to write
|
* len number of bytes to write
|
||||||
data pointer to where the data is written from
|
* data pointer to where the data is written from
|
||||||
|
*
|
||||||
First byte in stream must be the register address to begin writing to.
|
* First byte in stream must be the register address to begin writing to.
|
||||||
The data is then written from second byte and increasing. */
|
* The data is then written from second byte and increasing.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tlc59116_write_stream(uint8_t len, uint8_t *data) {
|
tlc59116_write_stream(uint8_t len, uint8_t * data)
|
||||||
|
{
|
||||||
i2c_transmitinit(TLC59116_ADDR);
|
i2c_transmitinit(TLC59116_ADDR);
|
||||||
while(i2c_busy());
|
while(i2c_busy());
|
||||||
PRINTFDEBUG("I2C Ready to TX(stream)\n");
|
PRINTFDEBUG("I2C Ready to TX(stream)\n");
|
||||||
|
@ -86,15 +89,17 @@ tlc59116_write_stream(uint8_t len, uint8_t *data) {
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Read one register.
|
/* Read one register.
|
||||||
args:
|
* args:
|
||||||
reg what register to read
|
* reg what register to read
|
||||||
returns the value of the read register
|
* returns the value of the read register
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
tlc59116_read_reg(uint8_t reg) {
|
tlc59116_read_reg(uint8_t reg)
|
||||||
|
{
|
||||||
uint8_t retVal = 0;
|
uint8_t retVal = 0;
|
||||||
uint8_t rtx = reg;
|
uint8_t rtx = reg;
|
||||||
|
|
||||||
PRINTFDEBUG("READ_REG 0x%02X\n", reg);
|
PRINTFDEBUG("READ_REG 0x%02X\n", reg);
|
||||||
|
|
||||||
/* transmit the register to read */
|
/* transmit the register to read */
|
||||||
|
@ -114,15 +119,17 @@ tlc59116_read_reg(uint8_t reg) {
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Read several registers in a stream.
|
/* Read several registers in a stream.
|
||||||
args:
|
* args:
|
||||||
reg what register to start reading from
|
* reg what register to start reading from
|
||||||
len number of bytes to read
|
* len number of bytes to read
|
||||||
whereto pointer to where the data is saved
|
* whereto pointer to where the data is saved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t *whereto) {
|
tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t * whereto)
|
||||||
|
{
|
||||||
uint8_t rtx = reg;
|
uint8_t rtx = reg;
|
||||||
|
|
||||||
PRINTFDEBUG("READ_STR %u B from 0x%02X\n", len, reg);
|
PRINTFDEBUG("READ_STR %u B from 0x%02X\n", len, reg);
|
||||||
|
|
||||||
/* transmit the register to start reading from */
|
/* transmit the register to start reading from */
|
||||||
|
@ -140,10 +147,14 @@ tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t *whereto) {
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Set pwm value for individual led. Make sure PWM mode is enabled.
|
/* Set pwm value for individual led. Make sure PWM mode is enabled.
|
||||||
|
* args:
|
||||||
|
* led led output -> 0 till 15
|
||||||
|
* pwm led pwm value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tlc59116_led(uint8_t led, uint8_t pwm) {
|
tlc59116_led(uint8_t led, uint8_t pwm)
|
||||||
|
{
|
||||||
if(led < 0 | led > 15) {
|
if(led < 0 | led > 15) {
|
||||||
PRINTFDEBUG("TLC59116: wrong led value.");
|
PRINTFDEBUG("TLC59116: wrong led value.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,11 +164,12 @@ tlc59116_led(uint8_t led, uint8_t pwm) {
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Init the led driver: ports, pins, registers, interrupts (none enabled), I2C,
|
/* Init the led driver: ports, pins, registers, interrupts (none enabled), I2C,
|
||||||
default threshold values etc.
|
* default threshold values etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tlc59116_init(void) {
|
tlc59116_init(void)
|
||||||
|
{
|
||||||
/* Set up ports and pins for I2C communication */
|
/* Set up ports and pins for I2C communication */
|
||||||
i2c_enable();
|
i2c_enable();
|
||||||
|
|
||||||
|
@ -166,8 +178,9 @@ tlc59116_init(void) {
|
||||||
tlc59116_write_reg(TLC59116_MODE2, TLC59116_MODE2_DEFAULT);
|
tlc59116_write_reg(TLC59116_MODE2, TLC59116_MODE2_DEFAULT);
|
||||||
|
|
||||||
/*Set all PWM values to 0x00 (off) */
|
/*Set all PWM values to 0x00 (off) */
|
||||||
//This would maybe be better with a SWRST
|
/*This would maybe be better with a SWRST */
|
||||||
uint8_t tx_buf[] = {TLC59116_PWM0_AUTOINCR,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
uint8_t tx_buf[] =
|
||||||
|
{ TLC59116_PWM0_AUTOINCR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
tlc59116_write_stream(17, &tx_buf);
|
tlc59116_write_stream(17, &tx_buf);
|
||||||
|
|
||||||
/* set all leds to PWM control */
|
/* set all leds to PWM control */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
* Copyright (c) 2013, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -56,41 +56,41 @@
|
||||||
void tlc59116_init(void);
|
void tlc59116_init(void);
|
||||||
|
|
||||||
/* Write to a register.
|
/* Write to a register.
|
||||||
args:
|
* args:
|
||||||
reg register to write to
|
* reg register to write to
|
||||||
val value to write
|
* val value to write
|
||||||
*/
|
*/
|
||||||
void tlc59116_write_reg(uint8_t reg, uint8_t val);
|
void tlc59116_write_reg(uint8_t reg, uint8_t val);
|
||||||
|
|
||||||
/* Write several registers from a stream.
|
/* Write several registers from a stream.
|
||||||
args:
|
* args:
|
||||||
len number of bytes to read
|
* len number of bytes to read
|
||||||
data pointer to where the data is read from
|
* data pointer to where the data is read from
|
||||||
First byte in stream must be the register address to begin writing to.
|
* First byte in stream must be the register address to begin writing to.
|
||||||
The data is then written from the second byte and increasing. The address byte
|
* The data is then written from the second byte and increasing. The address byte
|
||||||
is not included in length len.
|
* is not included in length len.
|
||||||
*/
|
*/
|
||||||
void tlc59116_write_stream(uint8_t len, uint8_t * data);
|
void tlc59116_write_stream(uint8_t len, uint8_t * data);
|
||||||
|
|
||||||
/* Read one register.
|
/* Read one register.
|
||||||
args:
|
* args:
|
||||||
reg what register to read
|
* reg what register to read
|
||||||
returns the value of the read register
|
* returns the value of the read register
|
||||||
*/
|
*/
|
||||||
uint8_t tlc59116_read_reg(uint8_t reg);
|
uint8_t tlc59116_read_reg(uint8_t reg);
|
||||||
|
|
||||||
/* Read several registers in a stream.
|
/* Read several registers in a stream.
|
||||||
args:
|
* args:
|
||||||
reg what register to start reading from
|
* reg what register to start reading from
|
||||||
len number of bytes to read
|
* len number of bytes to read
|
||||||
whereto pointer to where the data is saved
|
* whereto pointer to where the data is saved
|
||||||
*/
|
*/
|
||||||
void tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t * whereto);
|
void tlc59116_read_stream(uint8_t reg, uint8_t len, uint8_t * whereto);
|
||||||
|
|
||||||
/* Set pwm value for individual led
|
/* Set pwm value for individual led
|
||||||
args:
|
* args:
|
||||||
led led output -> 0 till 15
|
* led led output -> 0 till 15
|
||||||
pwm led pwm value
|
* pwm led pwm value
|
||||||
*/
|
*/
|
||||||
void tlc59116_led(uint8_t led, uint8_t pwm);
|
void tlc59116_led(uint8_t led, uint8_t pwm);
|
||||||
|
|
||||||
|
@ -99,10 +99,10 @@ void tlc59116_led(uint8_t led, uint8_t pwm);
|
||||||
/* Application definitions, change if required by application. */
|
/* Application definitions, change if required by application. */
|
||||||
|
|
||||||
/* Suggested defaults according to the data sheet etc */
|
/* Suggested defaults according to the data sheet etc */
|
||||||
#define TLC59116_MODE1_DEFAULT 0x80 //
|
#define TLC59116_MODE1_DEFAULT 0x00 // Default (no sub or all call) + OSC on
|
||||||
#define TLC59116_MODE2_DEFAULT 0x00 //
|
#define TLC59116_MODE2_DEFAULT 0x00 // Default (output change on stop)
|
||||||
|
|
||||||
#define TLC59116_LEDOUT_PWM 0xAA // LDRx = 01 -> PWM, 4 leds per reg: 01010101 -> 0xAA
|
#define TLC59116_LEDOUT_PWM 0xAA // LDRx = 01 -> PWM; 4 leds per reg: 01010101b -> 0xAA
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* Reference definitions, should not be changed */
|
/* Reference definitions, should not be changed */
|
||||||
|
@ -112,7 +112,7 @@ void tlc59116_led(uint8_t led, uint8_t pwm);
|
||||||
/* TLC59116 registers */
|
/* TLC59116 registers */
|
||||||
#define TLC59116_MODE1 0x00
|
#define TLC59116_MODE1 0x00
|
||||||
#define TLC59116_MODE2 0x01
|
#define TLC59116_MODE2 0x01
|
||||||
#define TLC59116_PWM0_AUTOINCR 0xA2 //
|
#define TLC59116_PWM0_AUTOINCR 0xA2 //auto increment address for first pwm register
|
||||||
#define TLC59116_PWM0 0x02
|
#define TLC59116_PWM0 0x02
|
||||||
#define TLC59116_PWM1 0x03
|
#define TLC59116_PWM1 0x03
|
||||||
#define TLC59116_PWM2 0x04
|
#define TLC59116_PWM2 0x04
|
||||||
|
@ -139,4 +139,4 @@ void tlc59116_led(uint8_t led, uint8_t pwm);
|
||||||
/* More registers follow, but not used in this implementation */
|
/* More registers follow, but not used in this implementation */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
#endif /* ifndef __ADXL345_H__ */
|
#endif /* ifndef __TLC59116_H__ */
|
||||||
|
|
Loading…
Reference in a new issue