Contiki 3.x
rs485-test.c
1 #include <stdio.h>
2 #include "contiki.h"
3 #include "dev/i2cmaster.h" // Include IC driver
4 
5 #define TMP102_READ_INTERVAL (CLOCK_SECOND/2) // Poll the sensor every 500 ms
6 
7 PROCESS (temp_process, "Test Temperature process");
8 AUTOSTART_PROCESSES (&temp_process);
9 /*---------------------------------------------------------------------------*/
10 static struct etimer et;
11 
12 PROCESS_THREAD (temp_process, ev, data)
13 {
14  PROCESS_BEGIN ();
15 
16  P4DIR|=0x00000001;
17  P4OUT|=0x00000001;
18  // turn on pin 4.0 (vsense control)
19  uart1_init(0);
20  {
21  while (1)
22  {
23  etimer_set(&et, TMP102_READ_INTERVAL); // Set the timer
24  PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); // wait for its expiration
25 
26  uart1_writearray((unsigned char*)"look sending",12);
27  printf ("sent");
28 
29  }
30  }
31  PROCESS_END ();
32 }
void uart1_init(unsigned long ubr)
Initalize the RS232 port.
Definition: uart1.c:143
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
Definition: etimer.c:177
#define PROCESS_END()
Define the end of a process.
Definition: process.h:131
#define PROCESS(name, strname)
Declare a process.
Definition: process.h:307
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
Definition: process.h:273
static struct etimer et
NIC receiver thread.
Definition: lanc111.c:1133
A timer.
Definition: etimer.h:76
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
Definition: process.h:157
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
Definition: etimer.c:213
#define PROCESS_BEGIN()
Define the beginning of a process.
Definition: process.h:120