File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,8 @@ static void command_loop(void)
167
167
(1 << S_CMD_S_PIN_STATE )|
168
168
(1 << S_CMD_R_BYTE )|
169
169
(1 << S_CMD_O_WRITEB )|
170
- (1 << S_CMD_O_INIT )
170
+ (1 << S_CMD_O_INIT )|
171
+ (1 << S_CMD_O_EXEC )
171
172
};
172
173
173
174
sendbyte_blocking (S_ACK );
@@ -347,6 +348,43 @@ static void command_loop(void)
347
348
sendbyte_blocking (S_ACK );
348
349
break ;
349
350
}
351
+ case S_CMD_O_EXEC :
352
+ {
353
+ if (opbuf_pos == 0 ) {
354
+ sendbyte_blocking (S_NAK );
355
+ break ;
356
+ }
357
+
358
+ // Send ACK before handling the operation buffer
359
+ sendbyte_blocking (S_ACK );
360
+
361
+ // Handle the operation buffer
362
+ uint32_t i = 0 ;
363
+ while (i < opbuf_pos ) {
364
+ uint8_t cmd = opbuf [i ++ ];
365
+ uint32_t addr ;
366
+ uint8_t byte ;
367
+
368
+ switch (cmd ) {
369
+ case S_CMD_O_WRITEB :
370
+ memcpy (& addr , & opbuf [i ], 3 );
371
+ i += 3 ;
372
+ byte = opbuf [i ++ ];
373
+ cs_select (SPI_CS );
374
+ spi_write_blocking (SPI_IF , (uint8_t * )& addr , 3 ); // Send address
375
+ spi_write_blocking (SPI_IF , & byte , 1 ); // Send data
376
+ cs_deselect (SPI_CS );
377
+ break ;
378
+ default :
379
+ sendbyte_blocking (S_NAK );
380
+ break ;
381
+ }
382
+ }
383
+
384
+ // Send ACK after handling the operation buffer
385
+ sendbyte_blocking (S_ACK );
386
+ break ;
387
+ }
350
388
default :
351
389
sendbyte_blocking (S_NAK );
352
390
break ;
You can’t perform that action at this time.
0 commit comments