-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi2c_test.c
executable file
·50 lines (39 loc) · 1.12 KB
/
i2c_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <i2c.h>
#include "contiki.h"
#ifdef INGA_REVISION
#include <avr/eeprom.h>
#include "settings.h"
#include <util/delay.h>
#endif
#include <stdlib.h>
#include "node-id.h"
#include "leds.h"
// A R/W
// |--||-||
#define IC1_ADDR_W 0b01000000
#define IC2_ADDR_W 0b01001110
#define DEBUG 0
/*---------------------------------------------------------------------------*/
PROCESS(default_app_process, "Hello world process");
AUTOSTART_PROCESSES(&default_app_process);
/*---------------------------------------------------------------------------*/
static struct etimer timer;
PROCESS_THREAD(default_app_process, ev, data)
{
PROCESS_BEGIN();
uint8_t output = 0b11110000;
uint8_t ret;
i2c_init();
ret = i2c_start(IC1_ADDR_W);
printf("start: %d\n", ret);
ret = i2c_write(output);
printf("write: %d\n", ret);
i2c_stop();
ret = i2c_start(IC2_ADDR_W);
printf("start: %d\n", ret);
ret = i2c_write(output);
printf("write: %d\n", ret);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/