6 #define LED_INT_ONTIME CLOCK_SECOND/2
7 #define ACCM_READ_INTERVAL CLOCK_SECOND
9 static process_event_t ledOff_event;
11 PROCESS(accel_process,
"Test Accel process");
12 PROCESS(led_process,
"LED handling process");
13 AUTOSTART_PROCESSES(&accel_process, &led_process);
22 print_int(uint16_t reg){
23 #define ANNOYING_ALWAYS_THERE_ANYWAY_OUTPUT 0
24 #if ANNOYING_ALWAYS_THERE_ANYWAY_OUTPUT
25 if(reg & ADXL345_INT_OVERRUN) {
28 if(reg & ADXL345_INT_WATERMARK) {
31 if(reg & ADXL345_INT_DATAREADY) {
35 if(reg & ADXL345_INT_FREEFALL) {
38 if(reg & ADXL345_INT_INACTIVITY) {
39 printf(
"InActivity ");
41 if(reg & ADXL345_INT_ACTIVITY) {
44 if(reg & ADXL345_INT_DOUBLETAP) {
47 if(reg & ADXL345_INT_TAP) {
60 printf(
"~~[%u] Freefall detected! (0x%02X) -- ", ((u16_t)
clock_time())/128, reg);
67 accm_tap_cb(u8_t reg){
69 if(reg & ADXL345_INT_DOUBLETAP){
71 printf(
"~~[%u] DoubleTap detected! (0x%02X) -- ", ((u16_t)
clock_time())/128, reg);
74 printf(
"~~[%u] Tap detected! (0x%02X) -- ", ((u16_t)
clock_time())/128, reg);
85 static struct etimer ledETimer;
92 L_OFF(LEDS_R + LEDS_G + LEDS_B);
119 ACCM_REGISTER_INT1_CB((
void *)accm_ff_cb);
120 ACCM_REGISTER_INT2_CB((
void *)accm_tap_cb);
124 accm_set_irq(ADXL345_INT_FREEFALL, ADXL345_INT_TAP + ADXL345_INT_DOUBLETAP);
127 x = accm_read_axis(X_AXIS);
128 y = accm_read_axis(Y_AXIS);
129 z = accm_read_axis(Z_AXIS);
130 printf(
"x: %d y: %d z: %d\n", x, y, z);
CCIF clock_time_t clock_time(void)
Get the current clock time.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
#define PROCESS_END()
Define the end of a process.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
static struct etimer et
NIC receiver thread.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
int process_post(struct process *p, process_event_t ev, process_data_t data)
Post an asynchronous event.
process_event_t process_alloc_event(void)
Allocate a global event number.
A brief description of what this file is.
#define NULL
The null pointer.
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
#define PROCESS_BEGIN()
Define the beginning of a process.