NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
i2c_reg.h
Go to the documentation of this file.
1
22
23#ifndef CORTEX_M4_I2C_REG_H
24#define CORTEX_M4_I2C_REG_H
25
26#include "utils/types.h"
27#include <stdint.h>
28
35typedef struct {
36 __IO uint32_t CR1;
37 __IO uint32_t CR2;
38 __IO uint32_t OAR1;
39 __IO uint32_t OAR2;
40 __IO uint32_t DR;
41 __IO uint32_t SR1;
42 __IO uint32_t SR2;
43 __IO uint32_t CCR;
44 __IO uint32_t TRISE;
45 __IO uint32_t FLTR;
47
49#define I2C_BASE_ADDR 0x40005400
50
52#define I2C_GET_BASE(n) ((I2C_Reg_Typedef *)(I2C_BASE_ADDR + (0x400 * n)))
53
55#define I2C_APB1ENR_MASK(n) (1 << (21 + n))
56
58#define I2C_CR1_PE_Pos 0
59#define I2C_CR1_PE_MASK (1U << I2C_CR1_PE_Pos)
60#define I2C_CR1_START_Pos 8
61#define I2C_CR1_START_MASK (1U << I2C_CR1_START_Pos)
62#define I2C_CR1_STOP_Pos 9
63#define I2C_CR1_STOP_MASK (1U << I2C_CR1_STOP_Pos)
64#define I2C_CR1_ACK_Pos 10
65#define I2C_CR1_ACK_MASK (1U << I2C_CR1_ACK_Pos)
66#define I2C_CR1_POS_Pos 11
67#define I2C_CR1_POS_MASK (1U << I2C_CR1_POS_Pos)
68#define I2C_CR1_SWRST_Pos 15
69#define I2C_CR1_SWRST_MASK (1U << I2C_CR1_SWRST_Pos)
70
72#define I2C_CR2_FREQ_Pos 0
73#define I2C_CR2_FREQ_MASK (0x3FU << I2C_CR2_FREQ_Pos)
74#define I2C_CR2_ITERREN_Pos 8
75#define I2C_CR2_ITERREN (1U << I2C_CR2_ITERREN_Pos)
76#define I2C_CR2_ITEVTEN_Pos 9
77#define I2C_CR2_ITEVTEN (1U << I2C_CR2_ITEVTEN_Pos)
78#define I2C_CR2_ITBUFEN_Pos 10
79#define I2C_CR2_ITBUFEN (1U << I2C_CR2_ITBUFEN_Pos)
80
82#define I2C_SR1_SB_Pos 0
83#define I2C_SR1_SB_MASK (1U << I2C_SR1_SB_Pos)
84#define I2C_SR1_ADDR_Pos 1
85#define I2C_SR1_ADDR_MASK (1U << I2C_SR1_ADDR_Pos)
86#define I2C_SR1_BTF_Pos 2
87#define I2C_SR1_BTF_MASK (1U << I2C_SR1_BTF_Pos)
88#define I2C_SR1_STOPF_Pos 4
89#define I2C_SR1_STOPF (1U << I2C_SR1_STOPF_Pos)
90#define I2C_SR1_RXNE_Pos 6
91#define I2C_SR1_RXNE_MASK (1U << I2C_SR1_RXNE_Pos)
92#define I2C_SR1_TXE_Pos 7
93#define I2C_SR1_TXE_MASK (1U << I2C_SR1_TXE_Pos)
94#define I2C_SR1_BERR_Pos 8
95#define I2C_SR1_BERR (1U << I2C_SR1_BERR_Pos)
96#define I2C_SR1_ARLO_Pos 9
97#define I2C_SR1_ARLO (1U << I2C_SR1_ARLO_Pos)
98#define I2C_SR1_AF_Pos 10
99#define I2C_SR1_AF (1U << I2C_SR1_AF_Pos)
100#define I2C_SR1_OVR_Pos 11
101#define I2C_SR1_OVR (1U << I2C_SR1_OVR_Pos)
102#define I2C_SR1_TIMEOUT_Pos 14
103#define I2C_SR1_TIMEOUT (1U << I2C_SR1_TIMEOUT_Pos)
104
106#define I2C_SR2_MSL_Pos 0
107#define I2C_SR2_MSL (1U << I2C_SR2_MSL_Pos)
108#define I2C_SR2_BUSY_Pos 1
109#define I2C_SR2_BUSY (1U << I2C_SR2_BUSY_Pos)
110#define I2C_SR2_TRA_Pos 2
111#define I2C_SR2_TRA (1U << I2C_SR2_TRA_Pos)
112
114#define I2C_CCR_CCR_Pos 0
115#define I2C_CCR_CCR_MASK (0xFFFU << I2C_CCR_CCR_Pos)
116#define I2C_CCR_DUTY_Pos 14
117#define I2C_CCR_DUTY (1U << I2C_CCR_DUTY_Pos)
118#define I2C_CCR_FS_Pos 15
119#define I2C_CCR_FS_MASK (1U << I2C_CCR_FS_Pos)
120
122#define I2C_TRISE_TRISE_Pos 0
123#define I2C_TRISE_TRISE_Msk (0x3FU << I2C_TRISE_TRISE_Pos)
124
125#endif // CORTEX_M4_I2C_REG_H
#define __IO
Definition hal_types.h:20
I²C peripheral register map.
Definition i2c_reg.h:35
__IO uint32_t CCR
Definition i2c_reg.h:43
__IO uint32_t SR2
Definition i2c_reg.h:42
__IO uint32_t OAR2
Definition i2c_reg.h:39
__IO uint32_t TRISE
Definition i2c_reg.h:44
__IO uint32_t CR2
Definition i2c_reg.h:37
__IO uint32_t DR
Definition i2c_reg.h:40
__IO uint32_t SR1
Definition i2c_reg.h:41
__IO uint32_t CR1
Definition i2c_reg.h:36
__IO uint32_t OAR1
Definition i2c_reg.h:38
__IO uint32_t FLTR
Definition i2c_reg.h:45
Centralized type definitions include for NavHAL.