SWRMeter/firmware/command_config.h

111 lines
3.3 KiB
C
Raw Normal View History

/*
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
* Date: 08/2016
* License: GPLv3
*/
#ifndef __COMMAND_CONFIG_H__
#define __COMMAND_CONFIG_H__
/*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <avr/wdt.h>
#include "config_helper.h"
#include "led_matrix.h"
#include "globals.h"
/*****************************************************************************/
extern uint8_t key_config[EEP_KEY_CNT][EEP_KEY_SEQ_LEN][EEP_KEY_TUPLE_LEN];
extern uint8_t os_type;
extern uint8_t keystroke_delay;
/*****************************************************************************/
void cc_getConfig(void);
void cc_setKeyConfig(void);
void cc_setLEDState(void);
void cc_setOSType(void);
void cc_startBootloader(void);
void cc_saveFullSampleCfg(void);
void cc_setKeyStrokeDelay(void);
/*****************************************************************************/
#define CC_CMD_GET_CONFIG 0x0A
#define CC_CMD_SET_KEY_CONFIG 0x14
#define CC_CMD_SET_LED_STATE 0x1E
#define CC_CMD_SET_OS_TYPE 0x28
#define CC_CMD_START_BTLDR 0x32
#define CC_CMD_SSKC 0x3C
#define CC_CMD_SET_KS_DELAY 0x46
//#define CC_CMD_SET_BAUDRATE 0x32
/*****************************************************************************/
#define CC_CMD_GET_CONFIG_FUNC &cc_getConfig
#define CC_CMD_SET_KEY_CONFIG_FUNC &cc_setKeyConfig
#define CC_CMD_SET_LED_STATE_FUNC &cc_setLEDState
#define CC_CMD_SET_OS_TYPE_FUNC &cc_setOSType
#define CC_CMD_START_BTLDR_FUNC &cc_startBootloader
#define CC_CMD_SSKC_FUNC &cc_saveFullSampleCfg
#define CC_CMD_SET_KS_DELAY_FUNC &cc_setKeyStrokeDelay
//#define CC_CMD_SET_BAUDRATE_FUNC &cc_setBaudrate
/*****************************************************************************/
#define CC_CMD_GET_CONFIG_DATA_TO_READ 0
#define CC_CMD_SET_KEY_CONFIG_DATA_TO_READ 41 // Key number, 40 byte sequence data
#define CC_CMD_SET_LED_STATE_DATA_TO_READ 2 // LED number, state
#define CC_CMD_SET_OS_TYPE_DATA_TO_READ 1 // the OS type
#define CC_CMD_START_BTLDR_DATA_TO_READ 0 // start bootloader
#define CC_CMD_SSKC_DATA_TO_READ 0 // save sample key config
#define CC_CMD_SET_KS_DELAY_DATA_TO_READ 1 // the keystroke delay value
/*****************************************************************************/
#define CC_READ_DATA_MAX 64
/*****************************************************************************/
uint8_t cc_commands[] = {
CC_CMD_GET_CONFIG,
CC_CMD_SET_KEY_CONFIG,
CC_CMD_SET_LED_STATE,
CC_CMD_SET_OS_TYPE,
CC_CMD_START_BTLDR,
CC_CMD_SSKC,
CC_CMD_SET_KS_DELAY,
};
void (*cc_cmd_functions[])() = {
CC_CMD_GET_CONFIG_FUNC,
CC_CMD_SET_KEY_CONFIG_FUNC,
CC_CMD_SET_LED_STATE_FUNC,
CC_CMD_SET_OS_TYPE_FUNC,
CC_CMD_START_BTLDR_FUNC,
CC_CMD_SSKC_FUNC,
CC_CMD_SET_KS_DELAY_FUNC,
};
uint8_t cc_cmd_data_to_read[] = {
CC_CMD_GET_CONFIG_DATA_TO_READ,
CC_CMD_SET_KEY_CONFIG_DATA_TO_READ,
CC_CMD_SET_LED_STATE_DATA_TO_READ,
CC_CMD_SET_OS_TYPE_DATA_TO_READ,
CC_CMD_START_BTLDR_DATA_TO_READ,
CC_CMD_SSKC_DATA_TO_READ,
CC_CMD_SET_KS_DELAY_DATA_TO_READ,
};
uint8_t cc_read_data[CC_READ_DATA_MAX];
/*****************************************************************************/
#endif