Share PM67 upload protocol through C core
This commit is contained in:
49
c/set-protocol/include/tms2812.h
Normal file
49
c/set-protocol/include/tms2812.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file tms2812.h
|
||||
* @brief Shared PM67/TMS320F2812 legacy upload protocol.
|
||||
*/
|
||||
#ifndef TMS2812_H
|
||||
#define TMS2812_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TMS2812_CMD_UPLOAD 52U
|
||||
#define TMS2812_UPLOAD_REQUEST_SIZE 12U
|
||||
#define TMS2812_UPLOAD_RESPONSE_OVERHEAD 8U
|
||||
|
||||
typedef enum {
|
||||
TMS2812_OK = 0,
|
||||
TMS2812_ERROR_ARGUMENT = -1,
|
||||
TMS2812_ERROR_RANGE = -2,
|
||||
TMS2812_ERROR_LENGTH = -3,
|
||||
TMS2812_ERROR_CRC = -4,
|
||||
TMS2812_ERROR_HEADER = -5,
|
||||
TMS2812_ERROR_CAPACITY = -6
|
||||
} tms2812_status_t;
|
||||
|
||||
uint16_t tms2812_crc16(const uint8_t *data, size_t size);
|
||||
|
||||
size_t tms2812_build_upload_request(
|
||||
uint8_t controller, uint32_t word_address, uint32_t byte_count,
|
||||
uint8_t *output, size_t output_size);
|
||||
|
||||
size_t tms2812_expected_upload_response_size(uint32_t byte_count);
|
||||
|
||||
int tms2812_validate_upload_response(
|
||||
const uint8_t *data, size_t size, uint8_t controller,
|
||||
uint32_t byte_count);
|
||||
|
||||
int tms2812_decode_upload_response(
|
||||
const uint8_t *data, size_t size, uint8_t controller,
|
||||
uint32_t byte_count, uint8_t *output, size_t output_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TMS2812_H */
|
||||
Reference in New Issue
Block a user