Share PM67 upload protocol through C core

This commit is contained in:
2026-09-05 11:37:03 +03:00
parent 78d3f6690b
commit 235d5d81a2
17 changed files with 466 additions and 15 deletions

View File

@@ -2,6 +2,8 @@
#include <string.h>
#include "set_crc.h"
typedef struct {
const char *project;
const char *commands[PERIPH28335_COMMAND_COUNT];
@@ -32,19 +34,7 @@ static uint16_t get_be16(const uint8_t *input)
uint16_t periph28335_crc16_modbus(const uint8_t *data, size_t size)
{
uint16_t crc = 0xFFFFU;
size_t index;
uint8_t bit;
if ((data == NULL) && (size != 0U)) return 0U;
for (index = 0U; index < size; ++index) {
crc ^= data[index];
for (bit = 0U; bit < 8U; ++bit) {
crc = (crc & 1U) != 0U
? (uint16_t)((crc >> 1) ^ 0xA001U)
: (uint16_t)(crc >> 1);
}
}
return crc;
return set_crc16_modbus(data, size);
}
size_t periph28335_append_crc(const uint8_t *payload, size_t payload_size,