Add update config and apply config protocol commands.
This commit is contained in:
3
right/src/config_buffer.c
Normal file
3
right/src/config_buffer.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "config_buffer.h"
|
||||
|
||||
uint8_t ConfigBuffer[EEPROM_SIZE];
|
||||
16
right/src/config_buffer.h
Normal file
16
right/src/config_buffer.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef __CONFIG_BUFFER_H__
|
||||
#define __CONFIG_BUFFER_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
#define EEPROM_SIZE (32*1024)
|
||||
|
||||
// Variables:
|
||||
|
||||
extern uint8_t ConfigBuffer[EEPROM_SIZE];
|
||||
|
||||
#endif
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "i2c_addresses.h"
|
||||
#include "led_driver.h"
|
||||
#include "merge_sensor.h"
|
||||
#include "deserialize.h"
|
||||
#include "config_buffer.h"
|
||||
|
||||
void SetError(uint8_t error);
|
||||
void SetGenericError();
|
||||
@@ -16,6 +18,8 @@ void ReadLedDriver();
|
||||
void WriteEeprom();
|
||||
void ReadEeprom();
|
||||
void ReadMergeSensor();
|
||||
void uploadConfig();
|
||||
void applyConfig();
|
||||
|
||||
// Functions for setting error statuses
|
||||
|
||||
@@ -65,6 +69,12 @@ void UsbProtocolHandler()
|
||||
case USB_COMMAND_READ_MERGE_SENSOR:
|
||||
ReadMergeSensor();
|
||||
break;
|
||||
case USB_COMMAND_UPLOAD_CONFIG:
|
||||
uploadConfig();
|
||||
break;
|
||||
case USB_COMMAND_APPLY_CONFIG:
|
||||
applyConfig();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -171,3 +181,21 @@ void ReadMergeSensor()
|
||||
{
|
||||
SetResponseByte(MERGE_SENSOR_IS_MERGED);
|
||||
}
|
||||
|
||||
void uploadConfig()
|
||||
{
|
||||
uint8_t byteCount = GenericHidInBuffer[1];
|
||||
uint16_t memoryOffset = *((uint16_t*)(GenericHidInBuffer+2));
|
||||
|
||||
if (byteCount > USB_GENERIC_HID_OUT_BUFFER_LENGTH-4) {
|
||||
SetError(UPLOAD_CONFIG_INVALID_PAYLOAD_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(ConfigBuffer+memoryOffset, GenericHidInBuffer+4, byteCount);
|
||||
}
|
||||
|
||||
void applyConfig()
|
||||
{
|
||||
deserialize_Layer(ConfigBuffer, 0);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#define WRITE_EEPROM_RESPONSE_INVALID_PAYLOAD_SIZE 1
|
||||
#define USB_COMMAND_READ_EEPROM 6
|
||||
#define USB_COMMAND_READ_MERGE_SENSOR 7
|
||||
#define USB_COMMAND_UPLOAD_CONFIG 8
|
||||
#define UPLOAD_CONFIG_INVALID_PAYLOAD_SIZE 1
|
||||
#define USB_COMMAND_APPLY_CONFIG 9
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user