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)
167167 (1 << S_CMD_S_PIN_STATE )|
168168 (1 << S_CMD_R_BYTE )|
169169 (1 << S_CMD_O_WRITEB )|
170- (1 << S_CMD_O_INIT )
170+ (1 << S_CMD_O_INIT )|
171+ (1 << S_CMD_O_EXEC )
171172 };
172173
173174 sendbyte_blocking (S_ACK );
@@ -347,6 +348,43 @@ static void command_loop(void)
347348 sendbyte_blocking (S_ACK );
348349 break ;
349350 }
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+ }
350388 default :
351389 sendbyte_blocking (S_NAK );
352390 break ;
You can’t perform that action at this time.
0 commit comments