-
Notifications
You must be signed in to change notification settings - Fork 0
/
port_exp.c
executable file
·51 lines (41 loc) · 877 Bytes
/
port_exp.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
51
#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"
// fest A R/W
// |--||-| |
#define IC1_ADDR_W 0b01000000
#define IC2_ADDR_W 0b01001110
int set_button(uint16_t output)
{
uint8_t ret;
uint8_t ic1 = (uint8_t)output;
uint8_t ic2 = (uint8_t)(output >> 8);
printf("ic1: %d, ic2: %d\n", ic1, ic2);
i2c_init();
if(i2c_start(IC1_ADDR_W))
{
ret = i2c_write(output);
}
else
{
printf("i2c_start failed: IC1\n");
}
i2c_stop();
if(i2c_start(IC2_ADDR_W))
{
ret = i2c_write(output);
}
else
{
printf("i2c_start failed: IC2\n");
}
return ret;
}