-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathi2c_handler.c
57 lines (45 loc) · 1.03 KB
/
i2c_handler.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
52
53
54
55
56
/**
* @file i2c_handler.c
*
* @brief Init I2C0 and transmit-receive.
* @note The accelerometer sensor is always turned on on the TTTW lab-kit. So
* no power ON or enable has to be done.
*
* @author Johannes Ehala, ProLab.
* @license MIT
*
* Copyright ProLab, TTÜ. 2021
*/
#include "em_cmu.h"
#include "i2c_handler.h"
#include "gpio_handler.h"
/**
* @brief Init I2C interface.
*
* Accelerometer sensor is connected to port A pin 2 (SCL) and pin 3 (SDA), I2C0
* must be routed to those pins.
*/
void i2c_init (void)
{
// TODO Enable I2C clock.
// TODO Initialize and configure SDA and SCL pins for I2C data transfer.
// TODO Route I2C SDA and SCL to GPIO pins (efr32mg12-datasheet page 188).
// TODO Initialize I2C.
}
void i2c_enable (void)
{
I2C_Enable(I2C0, true);
}
void i2c_disable (void)
{
I2C_Enable(I2C0, false);
}
void i2c_reset (void)
{
I2C_Reset(I2C0);
}
I2C_TransferSeq_TypeDef * i2c_transaction (I2C_TransferSeq_TypeDef * seq)
{
// TODO Do a polled transfer.
return seq;
}