forked from ChetanBiluve/asw_code_challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i2c.c
43 lines (37 loc) · 845 Bytes
/
i2c.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
#include "i2c.h"
#include <stdint.h>
#include <stdio.h>
status_t i2c_read(
uint8_t bus_address,
uint8_t register_address,
uint16_t length,
uint8_t *buffer)
{
printf(
"read [%d] bytes from bus [%d] for register [%d]\n",
length,
bus_address,
register_address);
/* Setting the output to some arbitrary value */
for (size_t i = 0; i < length; ++i) {
buffer[i] = 0xff;
}
return STATUS_OK;
}
status_t i2c_write(
uint8_t bus_address,
uint8_t register_address,
uint16_t length,
uint8_t *buffer)
{
printf(
"write [%d] bytes to bus [%d] for register [%d]\n\t",
length,
bus_address,
register_address);
for (size_t i = 0; i < length; ++i) {
printf("%p", buffer);
}
printf("\n");
return STATUS_OK;
}