Linux debugging
Check our new training course
Linux debugging, tracing, profiling & perf. analysis
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
/* * Copyright (c) 2016 BayLibre, SAS * * SPDX-License-Identifier: Apache-2.0 */ #ifndef _STM32LX_I2C_H_ #define _STM32LX_I2C_H_ /* 35.6.1 Control register 1 (I2C_CR1) */ union __cr1 { u32_t val; struct { u32_t pe :1 __packed; u32_t txie :1 __packed; u32_t rxie :1 __packed; u32_t addrie :1 __packed; u32_t nackie :1 __packed; u32_t stopie :1 __packed; u32_t tcie :1 __packed; u32_t errie :1 __packed; u32_t dnf :4 __packed; u32_t anfoff :1 __packed; u32_t rsvd__13 :1 __packed; u32_t txdmaen :1 __packed; u32_t rxdmaen :1 __packed; u32_t sbc :1 __packed; u32_t nostretch :1 __packed; u32_t wupen :1 __packed; u32_t gcen :1 __packed; u32_t smbhen :1 __packed; u32_t smbden :1 __packed; u32_t alerten :1 __packed; u32_t pecen :1 __packed; u32_t rsvd__24_31 :8 __packed; } bit; }; /* 35.6.2 Control register 2 (I2C_CR2) */ union __cr2 { u32_t val; struct { u32_t sadd :10 __packed; u32_t rd_wrn :1 __packed; u32_t add10 :1 __packed; u32_t head10r :1 __packed; u32_t start :1 __packed; u32_t stop :1 __packed; u32_t nack :1 __packed; u32_t nbytes :8 __packed; u32_t reload :1 __packed; u32_t autoend :1 __packed; u32_t pecbyte :1 __packed; u32_t rsvd__27_31 :5 __packed; } bit; }; union __oar1 { u32_t val; struct { u32_t oa1 :10 __packed; u32_t oa1mode :1 __packed; u32_t rsvd__11_14 :4 __packed; u32_t oa1en :1 __packed; u32_t rsvd__16_31 :16 __packed; } bit; }; union __oar2 { u32_t val; struct { u32_t rsvd__0 :1 __packed; u32_t oa2 :7 __packed; u32_t oa2msk :3 __packed; u32_t rsvd__11_14 :4 __packed; u32_t oa2en :1 __packed; u32_t rsvd__16_31 :16 __packed; } bit; }; union __timingr { u32_t val; struct { u32_t scll :8 __packed; u32_t sclh :8 __packed; u32_t sdadel :4 __packed; u32_t scldel :4 __packed; u32_t rsvd__24_27 :4 __packed; u32_t presc :4 __packed; } bit; }; union __timeoutr { u32_t val; struct { u32_t timeouta :12 __packed; u32_t tidle :1 __packed; u32_t rsvd__13_14 :1 __packed; u32_t timouten :1 __packed; u32_t timeoutb :12 __packed; u32_t rsvd__28_30 :1 __packed; u32_t texten :1 __packed; } bit; }; union __isr { u32_t val; struct { u32_t txe :1 __packed; u32_t txis :1 __packed; u32_t rxne :1 __packed; u32_t addr :1 __packed; u32_t nackf :1 __packed; u32_t stopf :1 __packed; u32_t tc :1 __packed; u32_t tcr :1 __packed; u32_t berr :1 __packed; u32_t arlo :1 __packed; u32_t ovr :1 __packed; u32_t pecerr :1 __packed; u32_t timeout :1 __packed; u32_t alert :1 __packed; u32_t rsvd__14 :1 __packed; u32_t busy :1 __packed; u32_t dir :1 __packed; u32_t addcode :7 __packed; u32_t rsvd__24_31 :8 __packed; } bit; }; union __icr { u32_t val; struct { u32_t rsvd__0_2 :3 __packed; u32_t addr :1 __packed; u32_t nack :1 __packed; u32_t stop :1 __packed; u32_t rsvd__6_7 :2 __packed; u32_t berr :1 __packed; u32_t arlo :1 __packed; u32_t ovr :1 __packed; u32_t pec :1 __packed; u32_t timeout :1 __packed; u32_t alert :1 __packed; u32_t rsvd__14_31 :17 __packed; } bit; }; union __pecr { u32_t val; struct { u32_t pec:8 __packed; u32_t rsvd__9_31 :24 __packed; } bit; }; union __dr { u32_t val; struct { u32_t data:8 __packed; u32_t rsvd__9_31 :24 __packed; } bit; }; /* 35.7.12 I2C register map */ struct i2c_stm32lx { union __cr1 cr1; union __cr2 cr2; union __oar1 oar1; union __oar2 oar2; union __timingr timingr; union __timeoutr timeoutr; union __isr isr; union __icr icr; union __pecr pecr; union __dr rxdr; u32_t txdr; }; typedef void (*irq_config_func_t)(struct device *port); /* device config */ struct i2c_stm32lx_config { void *base; irq_config_func_t irq_config_func; /* clock subsystem driving this peripheral */ struct stm32_pclken pclken; }; /* driver data */ struct i2c_stm32lx_data { /* clock device */ struct device *clock; /* Device config */ union dev_config dev_config; /* ISR Sync */ struct k_sem device_sync_sem; /* Current message data */ struct { struct i2c_msg *msg; unsigned int len; u8_t *buf; unsigned int is_err; unsigned int is_nack; unsigned int is_write; } current; }; #endif /* _STM32LX_UART_H_ */