@@ -44,13 +44,19 @@ static int spi_bitbang_configure(const struct spi_bitbang_config *info,
44
44
45
45
const int bits = SPI_WORD_SIZE_GET (config -> operation );
46
46
47
- if (bits > 16 ) {
48
- LOG_ERR ("Word sizes > 16 bits not supported" );
47
+ if (bits > 32 ) {
48
+ LOG_ERR ("Word sizes > 32 bits not supported" );
49
49
return - ENOTSUP ;
50
50
}
51
51
52
52
data -> bits = bits ;
53
53
data -> dfs = ((data -> bits - 1 ) / 8 ) + 1 ;
54
+
55
+ /* As there is no uint24_t, it is assumed uint32_t will be used as the buffer base type. */
56
+ if (data -> dfs == 3 ) {
57
+ data -> dfs = 4 ;
58
+ }
59
+
54
60
if (config -> frequency > 0 ) {
55
61
/* convert freq to period, the extra /2 is due to waiting
56
62
* twice in each clock cycle. The '2000' is an upscale factor.
@@ -147,10 +153,14 @@ static int spi_bitbang_transceive(const struct device *dev,
147
153
const uint32_t wait_us = data -> wait_us ;
148
154
149
155
while (spi_context_tx_buf_on (ctx ) || spi_context_rx_buf_on (ctx )) {
150
- uint16_t w = 0 ;
156
+ uint32_t w = 0 ;
151
157
152
158
if (ctx -> tx_len ) {
153
159
switch (data -> dfs ) {
160
+ case 4 :
161
+ case 3 :
162
+ w = * (uint32_t * )(ctx -> tx_buf );
163
+ break ;
154
164
case 2 :
155
165
w = * (uint16_t * )(ctx -> tx_buf );
156
166
break ;
@@ -160,7 +170,7 @@ static int spi_bitbang_transceive(const struct device *dev,
160
170
}
161
171
}
162
172
163
- uint16_t r = 0 ;
173
+ uint32_t r = 0 ;
164
174
uint8_t i = 0 ;
165
175
int b = 0 ;
166
176
bool do_read = false;
@@ -209,6 +219,10 @@ static int spi_bitbang_transceive(const struct device *dev,
209
219
210
220
if (spi_context_rx_buf_on (ctx )) {
211
221
switch (data -> dfs ) {
222
+ case 4 :
223
+ case 3 :
224
+ * (uint32_t * )(ctx -> rx_buf ) = r ;
225
+ break ;
212
226
case 2 :
213
227
* (uint16_t * )(ctx -> rx_buf ) = r ;
214
228
break ;
0 commit comments