@@ -101,22 +101,29 @@ void i2c_stm32_event(const struct device *dev)
101
101
LL_I2C_ClearFlag_STOP (i2c );
102
102
LL_I2C_DisableReloadMode (i2c );
103
103
i2c_stm32_master_mode_end (dev );
104
+
105
+ if (i2c_rtio_complete (ctx , ret )) {
106
+ i2c_stm32_start (dev );
107
+ return ;
108
+ }
104
109
}
105
110
106
- /* TODO handle the reload separately from complete */
107
- /* Transfer Complete or Transfer Complete Reload */
108
111
if (LL_I2C_IsActiveFlag_TC (i2c ) ||
109
112
LL_I2C_IsActiveFlag_TCR (i2c )) {
113
+
110
114
/* Issue stop condition if necessary */
111
- /* TODO look at current sqe flags */
112
115
if ((data -> xfer_flags & I2C_MSG_STOP ) != 0 ) {
113
- LL_I2C_GenerateStopCondition (i2c );
116
+ if (data -> xfer_len == 0 ) {
117
+ LL_I2C_GenerateStopCondition (i2c );
118
+ } else {
119
+ LL_I2C_SetTransferSize (i2c , MIN (data -> xfer_len , UINT8_MAX ));
120
+ }
114
121
} else {
115
122
i2c_stm32_disable_transfer_interrupts (dev );
116
- }
117
123
118
- if ((data -> xfer_len == 0 ) && i2c_rtio_complete (ctx , ret )) {
119
- i2c_stm32_start (dev );
124
+ if ((data -> xfer_len == 0 ) && i2c_rtio_complete (ctx , ret )) {
125
+ i2c_stm32_start (dev );
126
+ }
120
127
}
121
128
}
122
129
}
@@ -162,12 +169,6 @@ int i2c_stm32_msg_start(const struct device *dev, uint8_t flags,
162
169
transfer = LL_I2C_REQUEST_WRITE ;
163
170
}
164
171
165
- /* TODO deal with larger than 255 byte transfers correctly */
166
- if (buf_len > UINT8_MAX ) {
167
- /* TODO LL_I2C_EnableReloadMode(i2c); */
168
- return - EINVAL ;
169
- }
170
-
171
172
if ((I2C_MSG_ADDR_10_BITS & flags ) != 0 ) {
172
173
LL_I2C_SetMasterAddressingMode (i2c ,
173
174
LL_I2C_ADDRESSING_MODE_10BIT );
@@ -178,9 +179,15 @@ int i2c_stm32_msg_start(const struct device *dev, uint8_t flags,
178
179
LL_I2C_SetSlaveAddr (i2c , (uint32_t ) i2c_addr << 1 );
179
180
}
180
181
182
+ if (buf_len > UINT8_MAX ) {
183
+ LL_I2C_EnableReloadMode (i2c );
184
+ } else {
185
+ LL_I2C_DisableReloadMode (i2c );
186
+ }
187
+
181
188
LL_I2C_DisableAutoEndMode (i2c );
182
189
LL_I2C_SetTransferRequest (i2c , transfer );
183
- LL_I2C_SetTransferSize (i2c , buf_len );
190
+ LL_I2C_SetTransferSize (i2c , MIN ( buf_len , UINT8_MAX ) );
184
191
185
192
LL_I2C_Enable (i2c );
186
193
0 commit comments