1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18:
19:
20: #ifndef __DEV_I2C_STM32L4_H__
21: #define __DEV_I2C_STM32L4_H__
22:
23: #define DEV_I2C_UNITNM (3)
24: #define DEV_I2C_1 (0)
25: #define DEV_I2C_2 (1)
26: #define DEV_I2C_3 (2)
27:
28:
29: #define I2C_STS_START 0x0000
30: #define I2C_STS_RESTART 0x0001
31: #define I2C_STS_STOP 0x0003
32: #define I2C_STS_SEND 0x0004
33: #define I2C_STS_RECV 0x0005
34: #define I2C_STS_TOP 0x8000
35:
36: 37: 38:
39: #define RCC_CCIPR_I2CSEL 0x00003000
40:
41: 42: 43:
44:
45:
46: #define I2C1_BASE 0x40005400
47: #define I2C2_BASE 0x40005800
48: #define I2C3_BASE 0x40005C00
49:
50:
51: #define I2Cx_CR1 (0x00)
52: #define I2Cx_CR2 (0x04)
53: #define I2Cx_OAR1 (0x08)
54: #define I2Cx_OAR2 (0x0C)
55: #define I2Cx_TIMINGR (0x10)
56: #define I2Cx_TIMEOUTR (0x14)
57: #define I2Cx_ISR (0x18)
58: #define I2Cx_ICR (0x1C)
59: #define I2Cx_PECR (0x20)
60: #define I2Cx_RXDR (0x24)
61: #define I2Cx_TXDR (0x28)
62:
63: #define I2C_CR1_PE (1<<0)
64: #define I2C_CR1_TXIE (1<<1)
65: #define I2C_CR1_RXIE (1<<2)
66: #define I2C_CR1_NACKIE (1<<4)
67: #define I2C_CR1_STOPIE (1<<5)
68: #define I2C_CR1_TCIE (1<<6)
69: #define I2C_CR1_ERRIE (1<<7)
70:
71: #define I2C_CR2_RD_WRN (1<<10)
72: #define I2C_CR2_START (1<<13)
73: #define I2C_CR2_AUTOEND (1<<25)
74:
75: #define I2C_ISR_TXE (1<<0)
76: #define I2C_ISR_TXIS (1<<1)
77: #define I2C_ISR_RXNE (1<<2)
78: #define I2C_ISR_NACKF (1<<4)
79: #define I2C_ISR_STOPF (1<<5)
80: #define I2C_ISR_TC (1<<6)
81: #define I2C_ISR_TCR (1<<7)
82: #define I2C_ISR_BUSY (1<<15)
83:
84: #define I2C_ICR_ALL (0x00003F38)
85:
86: 87: 88:
89: #define INTNO_I2C1_EV 31
90: #define ININO_I2C1_ER 32
91:
92: #define INTNO_I2C2_EV 33
93: #define ININO_I2C2_ER 34
94:
95: #define INTNO_I2C3_EV 72
96: #define ININO_I2C3_ER 73
97:
98: #endif