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:
László Monda
2017-09-25 03:03:14 +02:00
parent ef9d9ee9a7
commit b88c6e4291
11 changed files with 93 additions and 60 deletions

View File

@@ -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