Transfer a synchronization message to make I2C recovery more robust.

This commit is contained in:
László Monda
2017-10-04 02:24:34 +02:00
parent efb0f982d2
commit c707f0e408
4 changed files with 43 additions and 1 deletions

View File

@@ -1,12 +1,19 @@
#ifndef __SLAVE_PROTOCOL_H__
#define __SLAVE_PROTOCOL_H__
// Includes:
#include "fsl_common.h"
// Macros:
#define I2C_MESSAGE_HEADER_LENGTH 3
#define I2C_MESSAGE_MAX_PAYLOAD_LENGTH 255
#define I2C_MESSAGE_MAX_TOTAL_LENGTH (I2C_MESSAGE_HEADER_LENGTH + I2C_MESSAGE_MAX_PAYLOAD_LENGTH)
#define SLAVE_SYNC_STRING "SYNC"
#define SLAVE_SYNC_STRING_LENGTH (sizeof(SLAVE_SYNC_STRING) - 1)
// Typedefs:
typedef enum {
@@ -18,6 +25,7 @@
} slave_command_t;
typedef enum {
SlaveProperty_Sync,
SlaveProperty_Features,
} slave_property_t;
@@ -32,4 +40,8 @@
uint8_t data[I2C_MESSAGE_MAX_PAYLOAD_LENGTH];
} __attribute__ ((packed)) i2c_message_t;
// Variables:
extern char SlaveSyncString[];
#endif