> #### Updates

This release only targets USB Corecell (no change for SPI connexion type).
The USB-SPI bridge firmware, which runs on the STM32 MCU of the USB Corecell, has
been updated for API clean-up and robustness improvements.

> #### Changes

* MCU: USB-SPI bridge firmware binary v1.0.0.
	* Removed obsolete commands (ORDER_ID__REQ_SPI, ORDER_ID__ACK_SPI)
	* Command index shifted after obsolete commands removal (ORDER_ID__REQ_MULTIPLE_SPI, ORDER_ID__ACK_MULTIPLE_SPI)
	* Command parser sends ORDER_ID__UNKNOW_CMD in case of wrong command size.
	* Code clean-up (typo fixed, comments added...)
	* Implemented Error_Handler() function to reset the MCU in case of fatal error.
	* Fixed a potential roll-over issue in read_write_spi() function.
	* Increased delay tolerance for host feedback on USB transfers.
* HAL: Command interface updated for MCU firmware v1.0.0.
	* Removed obsolete commands from enum order_id_e
	* Shifted commands enum index according to USB-SPI bridge update.
	* Removed decode_ack_spi_access() unused function.
* HAL: Added timing debug information under DEBUG_MCU.
This commit is contained in:
Michael Coracin 2021-04-22 14:34:46 +02:00
parent 6dff8191d5
commit 4b42025d17
5 changed files with 49 additions and 35 deletions

View File

@ -1 +1 @@
2.0.2
2.1.0

View File

@ -28,7 +28,7 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
/* -------------------------------------------------------------------------- */
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
static const char mcu_version_string[] = "00.02.06";
static const char mcu_version_string[] = "01.00.00";
#define MAX_SIZE_COMMAND ( 4200 )
#define MAX_SPI_COMMAND ( MAX_SIZE_COMMAND - CMD_OFFSET__DATA - 1 )
@ -45,18 +45,16 @@ typedef enum order_id_e
ORDER_ID__REQ_BOOTLOADER_MODE = 0x02,
ORDER_ID__REQ_RESET = 0x03,
ORDER_ID__REQ_WRITE_GPIO = 0x04,
ORDER_ID__REQ_SPI = 0x05, /* deprecated */
ORDER_ID__REQ_MULTIPLE_SPI = 0x06,
ORDER_ID__REQ_MULTIPLE_SPI = 0x05,
ORDER_ID__ACK_PING = 0x40,
ORDER_ID__ACK_GET_STATUS = 0x41,
ORDER_ID__ACK_BOOTLOADER_MODE = 0x42,
ORDER_ID__ACK_RESET = 0x43,
ORDER_ID__ACK_WRITE_GPIO = 0x44,
ORDER_ID__ACK_SPI = 0x45, /* deprecated */
ORDER_ID__ACK_MULTIPLE_SPI = 0x46,
ORDER_ID__ACK_MULTIPLE_SPI = 0x45,
ORDER_ID__UNKNOW_CMD = 0xFF
ORDER_ID__CMD_ERROR = 0xFF
} order_id_t;
typedef enum

View File

@ -146,8 +146,6 @@ const char * cmd_get_str(const uint8_t cmd) {
return "REQ_RESET";
case ORDER_ID__REQ_WRITE_GPIO:
return "REQ_WRITE_GPIO";
case ORDER_ID__REQ_SPI:
return "REQ_SPI";
case ORDER_ID__REQ_MULTIPLE_SPI:
return "REQ_MULTIPLE_SPI";
default:
@ -197,6 +195,10 @@ int write_req(int fd, order_id_t cmd, const uint8_t * payload, uint16_t payload_
int n;
/* performances variables */
struct timeval tm;
/* debug variables */
#if DEBUG_MCU == 1
struct timeval write_tv;
#endif
/* Record function start time */
_meas_time_start(&tm);
@ -231,7 +233,10 @@ int write_req(int fd, order_id_t cmd, const uint8_t * payload, uint16_t payload_
}
}
DEBUG_PRINTF("\nINFO: write_req 0x%02X (%s) done, id:0x%02X\n", cmd, cmd_get_str(cmd), buf_w[0]);
#if DEBUG_MCU == 1
gettimeofday(&write_tv, NULL);
#endif
DEBUG_PRINTF("\nINFO: %ld.%ld: write_req 0x%02X (%s) done, id:0x%02X, size:%u\n", write_tv.tv_sec, write_tv.tv_usec, cmd, cmd_get_str(cmd), buf_w[0], payload_size);
#if DEBUG_VERBOSE
int i;
@ -261,6 +266,10 @@ int read_ack(int fd, uint8_t * hdr, uint8_t * buf, size_t buf_size) {
int nb_read = 0;
/* performances variables */
struct timeval tm;
/* debug variables */
#if DEBUG_MCU == 1
struct timeval read_tv;
#endif
/* Record function start time */
_meas_time_start(&tm);
@ -274,7 +283,10 @@ int read_ack(int fd, uint8_t * hdr, uint8_t * buf, size_t buf_size) {
perror("ERROR: Unable to read /dev/ttyACMx - ");
return -1;
} else {
DEBUG_PRINTF("INFO: read %d bytes for header from gateway\n", n);
#if DEBUG_MCU == 1
gettimeofday(&read_tv, NULL);
#endif
DEBUG_PRINTF("INFO: %ld.%ld: read %d bytes for header from gateway\n", read_tv.tv_sec, read_tv.tv_usec, n);
}
/* Compute time spent in this function */
@ -317,7 +329,10 @@ int read_ack(int fd, uint8_t * hdr, uint8_t * buf, size_t buf_size) {
perror("ERROR: Unable to read /dev/ttyACMx - ");
return -1;
} else {
DEBUG_PRINTF("INFO: read %d bytes from gateway\n", n);
#if DEBUG_MCU == 1
gettimeofday(&read_tv, NULL);
#endif
DEBUG_PRINTF("INFO: %ld.%ld: read %d bytes from gateway\n", read_tv.tv_sec, read_tv.tv_usec, n);
nb_read += n;
}
} while (nb_read < (int)size); /* we want to read only the expected payload, not more */
@ -457,29 +472,6 @@ int decode_ack_gpio_access(const uint8_t * hdr, const uint8_t * payload, uint8_t
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
int decode_ack_spi_access(const uint8_t * hdr, const uint8_t * payload) {
/* sanity checks */
if ((hdr == NULL) || (payload == NULL)) {
printf("ERROR: invalid parameter\n");
return -1;
}
if (cmd_get_type(hdr) != ORDER_ID__ACK_SPI) {
printf("ERROR: wrong ACK type for ACK_SPI (expected:0x%02X, got 0x%02X)\n", ORDER_ID__ACK_SPI, cmd_get_type(hdr));
return -1;
}
#if DEBUG_VERBOSE
DEBUG_MSG ("## ACK_SPI_ACCESS\n");
DEBUG_PRINTF(" id: 0x%02X\n", cmd_get_id(hdr));
DEBUG_PRINTF(" size: %u\n", cmd_get_size(hdr));
#endif
return 0;
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
int decode_ack_spi_bulk(const uint8_t * hdr, const uint8_t * payload) {
uint8_t req_id, req_type, req_status;
uint16_t frame_size;

View File

@ -191,6 +191,30 @@ found in the `libtools` directory.
## 7. Changelog
### v2.1.0 ###
> #### Updates
This release only targets USB Corecell (no change for SPI connexion type).
The USB-SPI bridge firmware, which runs on the STM32 MCU of the USB Corecell, has
been updated for API clean-up and robustness improvements.
> #### Changes
* MCU: USB-SPI bridge firmware binary v1.0.0.
* Removed obsolete commands (ORDER_ID__REQ_SPI, ORDER_ID__ACK_SPI)
* Command index shifted after obsolete commands removal (ORDER_ID__REQ_MULTIPLE_SPI, ORDER_ID__ACK_MULTIPLE_SPI)
* Command parser sends ORDER_ID__UNKNOW_CMD in case of wrong command size.
* Code clean-up (typo fixed, comments added...)
* Implemented Error_Handler() function to reset the MCU in case of fatal error.
* Fixed a potential roll-over issue in read_write_spi() function.
* Increased delay tolerance for host feedback on USB transfers.
* HAL: Command interface updated for MCU firmware v1.0.0.
* Removed obsolete commands from enum order_id_e
* Shifted commands enum index according to USB-SPI bridge update.
* Removed decode_ack_spi_access() unused function.
* HAL: Added timing debug information under DEBUG_MCU.
### v2.0.2 ###
> #### Updates