Add i2c_message_t and use it all across the codebase. This will allow handling variable-length I2C messages and validation with minimal effort. The test LED and brightness PWM update features got temporarily broken and will fix them soon.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
#ifndef __SLAVE_PROTOCOL_H__
|
||||
#define __SLAVE_PROTOCOL_H__
|
||||
|
||||
// Macros:
|
||||
|
||||
#define I2C_MESSAGE_MAX_LENGTH 255
|
||||
#define I2C_BUFFER_MAX_LENGTH (I2C_MESSAGE_MAX_LENGTH + 3)
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef enum {
|
||||
@@ -10,4 +15,10 @@
|
||||
SlaveCommand_JumpToBootloader,
|
||||
} slave_command_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t length;
|
||||
uint16_t crc;
|
||||
uint8_t data[I2C_MESSAGE_MAX_LENGTH];
|
||||
} __attribute__ ((packed)) i2c_message_t;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user