This commit is contained in:
Imbus 2025-08-24 12:47:13 +02:00
parent 6a58763ece
commit 38d078509e
4 changed files with 109 additions and 0 deletions

31
message/message.h Normal file
View file

@ -0,0 +1,31 @@
#ifndef MESSAGE_H
#define MESSAGE_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef enum {
UI_SPEED_MS,
UI_BATTERY,
UI_VOLTAGE,
} MessageType;
typedef union {
int battery;
int speed_ms;
float voltage;
} MessageData;
typedef struct {
MessageType type;
MessageData data;
int16_t crc;
} Message;
void message_create(Message *m, MessageType type, MessageData data);
bool message_validate(const Message *m);
int message_tests(void);
uint16_t compute_crc16(const uint8_t *data, uint16_t len);
#endif