osd-contiki/examples/zolertia/z1/test-tlc59116.c

82 lines
3.1 KiB
C
Raw Permalink Normal View History

/*
2013-06-24 16:13:35 +02:00
* Copyright (c) 2013, Jelmer Tiete.
* All rights reserved.
2015-11-24 13:00:23 +01:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
2013-06-24 16:13:35 +02:00
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
2015-11-24 13:00:23 +01:00
* written permission.
*
2013-06-24 16:13:35 +02:00
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2015-11-24 13:00:23 +01:00
*
* This file is part of the Contiki operating system.
2015-11-24 13:00:23 +01:00
*
*/
2015-11-24 13:00:23 +01:00
/*---------------------------------------------------------------------------*/
/**
* \file
* A simple program for testing the TLC59116 I2C led driver.
* All 16 outputs will sequencially light up.
* \author
* Jelmer Tiete, VUB <jelmer@tiete.be>
*/
2015-11-24 13:00:23 +01:00
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include "contiki.h"
#include "dev/tlc59116.h"
2015-11-24 13:00:23 +01:00
/*---------------------------------------------------------------------------*/
#define BLINK_INTERVAL (CLOCK_SECOND / 25)
/*---------------------------------------------------------------------------*/
PROCESS(tlc59116_process, "Test tlc59116 process");
AUTOSTART_PROCESSES(&tlc59116_process);
/*---------------------------------------------------------------------------*/
/* Main process, setups */
static struct etimer et;
2013-05-23 17:52:02 +02:00
static uint8_t count = 0;
2015-11-24 13:00:23 +01:00
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(tlc59116_process, ev, data)
{
PROCESS_BEGIN();
{
/* Start and setup the led driver with default values, eg outputs on and pwm enabled and 0. */
tlc59116_init();
while(1) {
tlc59116_led(count, 0x00);
tlc59116_led((count + 1) % 16, 0x20);
tlc59116_led((count + 2) % 16, 0x40);
tlc59116_led((count + 3) % 16, 0xFF);
2013-05-23 17:52:02 +02:00
count++;
if(count > 15) {
count = 0;
}
2013-05-23 17:52:02 +02:00
etimer_set(&et, BLINK_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/