7 changed files with 58 additions and 9 deletions
@ -0,0 +1,30 @@ |
|||
/*
|
|||
* command_interpreter.c |
|||
* |
|||
* Created on: Jul 10, 2021 |
|||
* Author: Andreas Berthoud |
|||
*/ |
|||
|
|||
#include "usbd_cdc_if.h" |
|||
#include "commands.h" |
|||
|
|||
void usb_receive(uint8_t *buf, uint32_t *len) { |
|||
|
|||
CDC_Transmit_FS(buf, *len); // echo
|
|||
|
|||
if (*len < 5) { |
|||
return; |
|||
} |
|||
uint8_t command_id = buf[0]; |
|||
uint16_t length = buf[1] << 8 | buf[2]; |
|||
uint8_t * payload_ptr = buf + 4; |
|||
uint8_t stop_byte = 0x1; |
|||
|
|||
if (*len >= 4 + length) { |
|||
stop_byte = buf[4+ length]; |
|||
} |
|||
|
|||
log_debug("received command, id: 0x%x", 1, command_id); |
|||
log_debug("length: %n", 1, length); |
|||
log_debug("stop_byte: 0x%x", 1, stop_byte); |
|||
} |
|||
Loading…
Reference in new issue