-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi2c.h
46 lines (39 loc) · 1.7 KB
/
i2c.h
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
/*
* i2c.h
*
* Created on: 9/4/21
* Author: LJBeato
*/
#ifndef I2C_H_
#define I2C_H_
#include "Common.h"
#define BR_RATE (40000) //6400000 for 48Mhz maybe 400000
#define OLED_ADDR (0x3C)
void i2c0_Init(int listenerAddress);
void i2c0_put(BYTE *data, unsigned int len);
void i2c0_putchar(BYTE ch);
#endif /* I2C_H_ */
// I2C Initialization Register Values
// configure EUSCI_B0->CTLW0 for:
// bit15 UCA10 - 0 = Own address is a 7-bit address, 1 = Own address is a 10-bit address.
// bit14 UCSLA10 - 0 = Address LISTENER with 7-bit address, 1 = Address LISTENER with 10-bit address
// bit13 UCMM - 0 = Single MASTER environment, 1 = multi-MASTER environ
// bit12 reserved
// bit11 UCMST - 0 = LISTENER mode, 1 = MASTER mode
// bits10-9 UCMODEx - 00 = 3-pin SPI
// 01 = 4-pin SPI (MASTER or LISTENER enabled if STE = 1)
// 10 = 4-pin SPI (MASTER or LISTENER enabled if STE = 0)
// 11 = I2C mode
// bit8 UCSYNC - For eUSCI_B always read and write as 1.
// bits7-6 UCSSELx - (ignore in LISTENER mode)
// 00 - UCLKI
// 01 - ACLK
// 10 - SMCLK
// 11 - SMCLK
// bit5 UCTXACK - 0 = do not acknowledge LISTENER, 1 = acknowledge LISTENER
// bit4 UCTR - 0 = LISTENER, 1 = MASTER
// bit3 UCTXNACK - 0 = acknowledge normally, 1 = generate NACK
// bit2 UCTXSTP - 0 = DO NOT generate STOP, 1 = generate STOP
// bit1 UCTXSTT - 0 = DO NOT generate START, 1 = generate START
// bit0 UCSWRST - 0 = not RESET, 1 = RESET
//