Fixed warnings in Z1 examples
This commit is contained in:
parent
ed4c1788a7
commit
830f5fb60d
|
@ -42,12 +42,6 @@
|
||||||
#include "dev/i2cmaster.h"
|
#include "dev/i2cmaster.h"
|
||||||
#include "dev/light-ziglet.h"
|
#include "dev/light-ziglet.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if DEBUG
|
|
||||||
#define PRINTF(...) printf(__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2)
|
#define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(test_process, "Test light ziglet process");
|
PROCESS(test_process, "Test light ziglet process");
|
||||||
|
@ -59,19 +53,14 @@ PROCESS_THREAD(test_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
uint16_t light;
|
|
||||||
|
|
||||||
/* Initialize driver and set a slower data rate */
|
/* Initialize driver and set a slower data rate */
|
||||||
|
|
||||||
light_ziglet_init();
|
light_ziglet_init();
|
||||||
i2c_setrate(I2C_PRESC_100KHZ_LSB, I2C_PRESC_100KHZ_MSB);
|
i2c_setrate(I2C_PRESC_100KHZ_LSB, I2C_PRESC_100KHZ_MSB);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
etimer_set(&et, SENSOR_READ_INTERVAL);
|
etimer_set(&et, SENSOR_READ_INTERVAL);
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
printf("Light = %u\n", light_ziglet_read());
|
||||||
light = light_ziglet_read();
|
|
||||||
PRINTF("Light = %u\n", light);
|
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* An example of how to use the button and light sensor on
|
* An example of how to use the button and read the ADC ports
|
||||||
* the Z1 platform.
|
|
||||||
* \author
|
* \author
|
||||||
* Joakim Eriksson <joakime@sics.se>
|
* Joakim Eriksson <joakime@sics.se>
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +43,7 @@
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
#include "dev/z1-phidgets.h"
|
#include "dev/z1-phidgets.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(test_button_process, "Test Button & Phidgets");
|
PROCESS(test_button_process, "Test Button & ADC");
|
||||||
AUTOSTART_PROCESSES(&test_button_process);
|
AUTOSTART_PROCESSES(&test_button_process);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS_THREAD(test_button_process, ev, data)
|
PROCESS_THREAD(test_button_process, ev, data)
|
||||||
|
|
|
@ -42,12 +42,6 @@
|
||||||
#include "dev/i2cmaster.h"
|
#include "dev/i2cmaster.h"
|
||||||
#include "dev/tmp102.h"
|
#include "dev/tmp102.h"
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if DEBUG
|
|
||||||
#define PRINTF(...) printf(__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define PRINTF(...)
|
|
||||||
#endif
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
#define TMP102_READ_INTERVAL (CLOCK_SECOND / 2)
|
#define TMP102_READ_INTERVAL (CLOCK_SECOND / 2)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(temp_process, "Test Temperature process");
|
PROCESS(temp_process, "Test Temperature process");
|
||||||
|
@ -59,32 +53,15 @@ PROCESS_THREAD(temp_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
int16_t tempint;
|
int16_t temp;
|
||||||
uint16_t tempfrac;
|
|
||||||
int16_t raw;
|
|
||||||
uint16_t absraw;
|
|
||||||
int16_t sign;
|
|
||||||
char minus = ' ';
|
|
||||||
|
|
||||||
tmp102_init();
|
tmp102_init();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
etimer_set(&et, TMP102_READ_INTERVAL);
|
etimer_set(&et, TMP102_READ_INTERVAL);
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
temp = tmp102_read_temp_x100();
|
||||||
sign = 1;
|
printf("Temp = %d\n", temp);
|
||||||
|
|
||||||
PRINTFDEBUG("Reading Temp...\n");
|
|
||||||
raw = tmp102_read_temp_raw();
|
|
||||||
absraw = raw;
|
|
||||||
if(raw < 0) { /* Perform 2C's if sensor returned negative data */
|
|
||||||
absraw = (raw ^ 0xFFFF) + 1;
|
|
||||||
sign = -1;
|
|
||||||
}
|
|
||||||
tempint = (absraw >> 8) * sign;
|
|
||||||
tempfrac = ((absraw >> 4) % 16) * 625; /* Info in 1/10000 of degree */
|
|
||||||
minus = ((tempint == 0) & (sign == -1)) ? '-' : ' ';
|
|
||||||
PRINTF("Temp = %c%d.%04d\n", minus, tempint, tempfrac);
|
|
||||||
}
|
}
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue