RTEMS 6.1-rc1
stm32_i2c.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2013 Christian Mauderer. All rights reserved.
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifndef LIBBSP_ARM_STM32F4_STM32_I2C_H
16#define LIBBSP_ARM_STM32F4_STM32_I2C_H
17
18#include <bsp/utility.h>
19
27typedef struct {
28 uint32_t cr1;
29#define STM32F4_I2C_CR1_SWRST BSP_BIT32(15)
30#define STM32F4_I2C_CR1_ALERT BSP_BIT32(13)
31#define STM32F4_I2C_CR1_PEC BSP_BIT32(12)
32#define STM32F4_I2C_CR1_POS BSP_BIT32(11)
33#define STM32F4_I2C_CR1_ACK BSP_BIT32(10)
34#define STM32F4_I2C_CR1_STOP BSP_BIT32(9)
35#define STM32F4_I2C_CR1_START BSP_BIT32(8)
36#define STM32F4_I2C_CR1_NOSTRETCH BSP_BIT32(7)
37#define STM32F4_I2C_CR1_ENGC BSP_BIT32(6)
38#define STM32F4_I2C_CR1_ENPEC BSP_BIT32(5)
39#define STM32F4_I2C_CR1_ENARP BSP_BIT32(4)
40#define STM32F4_I2C_CR1_SMBTYPE BSP_BIT32(3)
41#define STM32F4_I2C_CR1_SMBUS BSP_BIT32(1)
42#define STM32F4_I2C_CR1_PE BSP_BIT32(0)
43 uint32_t cr2;
44#define STM32F4_I2C_CR2_LAST BSP_BIT32(12)
45#define STM32F4_I2C_CR2_DMAEN BSP_BIT32(11)
46#define STM32F4_I2C_CR2_ITBUFEN BSP_BIT32(10)
47#define STM32F4_I2C_CR2_ITEVTEN BSP_BIT32(9)
48#define STM32F4_I2C_CR2_ITERREN BSP_BIT32(8)
49#define STM32F4_I2C_CR2_FREQ(val) BSP_FLD32(val, 0, 5)
50#define STM32F4_I2C_CR2_FREQ_GET(reg) BSP_FLD32GET(reg, 0, 5)
51#define STM32F4_I2C_CR2_FREQ_SET(reg, val) BSP_FLD32SET(reg, val, 0, 5)
52 uint32_t oar1;
53#define STM32F4_I2C_OAR1_ADDMODE BSP_BIT32(15)
54#define STM32F4_I2C_OAR1_ADD(val) BSP_FLD32(val, 0, 9)
55#define STM32F4_I2C_OAR1_ADD_GET(reg) BSP_FLD32GET(reg, 0, 9)
56#define STM32F4_I2C_OAR1_ADD_SET(reg, val) BSP_FLD32SET(reg, val, 0, 9)
57 uint32_t oar2;
58#define STM32F4_I2C_OAR2_ADD2(val) BSP_FLD32(val, 1, 7)
59#define STM32F4_I2C_OAR2_ADD2_GET(reg) BSP_FLD32GET(reg, 1, 7)
60#define STM32F4_I2C_OAR2_ADD2_SET(reg, val) BSP_FLD32SET(reg, val, 1, 7)
61#define STM32F4_I2C_OAR2_ENDUAL BSP_BIT32(0)
62 uint32_t dr;
63#define STM32F4_I2C_DR(val) BSP_FLD32(val, 0, 7)
64#define STM32F4_I2C_DR_GET(reg) BSP_FLD32GET(reg, 0, 7)
65#define STM32F4_I2C_DR_SET(reg, val) BSP_FLD32SET(reg, val, 0, 7)
66 uint32_t sr1;
67#define STM32F4_I2C_SR1_SMBALERT BSP_BIT32(15)
68#define STM32F4_I2C_SR1_TIMEOUT BSP_BIT32(14)
69#define STM32F4_I2C_SR1_PECERR BSP_BIT32(12)
70#define STM32F4_I2C_SR1_OVR BSP_BIT32(11)
71#define STM32F4_I2C_SR1_AF BSP_BIT32(10)
72#define STM32F4_I2C_SR1_ARLO BSP_BIT32(9)
73#define STM32F4_I2C_SR1_BERR BSP_BIT32(8)
74#define STM32F4_I2C_SR1_TxE BSP_BIT32(7)
75#define STM32F4_I2C_SR1_RxNE BSP_BIT32(6)
76#define STM32F4_I2C_SR1_STOPF BSP_BIT32(4)
77#define STM32F4_I2C_SR1_ADD10 BSP_BIT32(3)
78#define STM32F4_I2C_SR1_BTF BSP_BIT32(2)
79#define STM32F4_I2C_SR1_ADDR BSP_BIT32(1)
80#define STM32F4_I2C_SR1_SB BSP_BIT32(0)
81 uint32_t sr2;
82#define STM32F4_I2C_SR2_PEC(val) BSP_FLD32(val, 8, 15)
83#define STM32F4_I2C_SR2_PEC_GET(reg) BSP_FLD32GET(reg, 8, 15)
84#define STM32F4_I2C_SR2_PEC_SET(reg, val) BSP_FLD32SET(reg, val, 8, 15)
85#define STM32F4_I2C_SR2_DUALF BSP_BIT32(7)
86#define STM32F4_I2C_SR2_SMBHOST BSP_BIT32(6)
87#define STM32F4_I2C_SR2_SMBDEFAULT BSP_BIT32(5)
88#define STM32F4_I2C_SR2_GENCALL BSP_BIT32(4)
89#define STM32F4_I2C_SR2_TRA BSP_BIT32(2)
90#define STM32F4_I2C_SR2_BUSY BSP_BIT32(1)
91#define STM32F4_I2C_SR2_MSL BSP_BIT32(0)
92 uint32_t ccr;
93#define STM32F4_I2C_CCR_FS BSP_BIT32(15)
94#define STM32F4_I2C_CCR_DUTY BSP_BIT32(14)
95#define STM32F4_I2C_CCR_CCR(val) BSP_FLD32(val, 0, 11)
96#define STM32F4_I2C_CCR_CCR_GET(reg) BSP_FLD32GET(reg, 0, 11)
97#define STM32F4_I2C_CCR_CCR_SET(reg, val) BSP_FLD32SET(reg, val, 0, 11)
98#define STM32F4_I2C_CCR_CCR_MAX STM32F4_I2C_CCR_CCR_GET(BSP_MSK32(0, 11))
99 uint32_t trise;
100#define STM32F4_I2C_TRISE(val) BSP_FLD32(val, 0, 5)
101#define STM32F4_I2C_TRISE_GET(reg) BSP_FLD32GET(reg, 0, 5)
102#define STM32F4_I2C_TRISE_SET(reg, val) BSP_FLD32SET(reg, val, 0, 5)
104
107#endif /* LIBBSP_ARM_STM32F4_STM32_I2C_H */
This header file provides utility macros for BSPs.
Definition: stm32_i2c.h:27