first
This commit is contained in:
30
include_lib/system/config/config_interface.h
Normal file
30
include_lib/system/config/config_interface.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*********************************************************************************************
|
||||
* Filename : config_interface.h
|
||||
|
||||
* Description :
|
||||
|
||||
* Author : Bingquan
|
||||
|
||||
* Email : bingquan_cai@zh-jieli.com
|
||||
|
||||
* Last modifiled : 2019-01-10 09:55
|
||||
|
||||
* Copyright:(c)JIELI 2011-2019 @ , All Rights Reserved.
|
||||
*********************************************************************************************/
|
||||
#ifndef _CONFIG_INTERFACE_H_
|
||||
#define _CONFIG_INTERFACE_H_
|
||||
|
||||
#include "config/config_transport.h"
|
||||
#include "config/config_target.h"
|
||||
|
||||
//配置工具 0:旧工具 1:新工具
|
||||
#define NEW_CONFIG_TOOL 1 //
|
||||
|
||||
void config_layer_init(const ci_transport_t *transport, void *config);
|
||||
|
||||
void *config_load(int id);
|
||||
|
||||
void ci_send_packet(u32 id, u8 *packet, int size);
|
||||
|
||||
|
||||
#endif
|
||||
43
include_lib/system/config/config_target.h
Normal file
43
include_lib/system/config/config_target.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*********************************************************************************************
|
||||
* Filename : config_target.h
|
||||
|
||||
* Description :
|
||||
|
||||
* Author : Bingquan
|
||||
|
||||
* Email : bingquan_cai@zh-jieli.com
|
||||
|
||||
* Last modifiled : 2019-01-09 19:28
|
||||
|
||||
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
|
||||
*********************************************************************************************/
|
||||
#ifndef _CONFIG_TARGET_H_
|
||||
#define _CONFIG_TARGET_H_
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
|
||||
#define EQ_CONFIG_ID 0x0005
|
||||
#define EFFECTS_CONFIG_ID 0x0006
|
||||
#define AEC_CONFIG_ID 0x0008
|
||||
|
||||
|
||||
typedef void (*ci_packet_handler_t)(uint8_t *packet, uint16_t size);
|
||||
|
||||
struct config_target {
|
||||
u16 id;
|
||||
ci_packet_handler_t callback;
|
||||
};
|
||||
|
||||
#define REGISTER_CONFIG_TARGET(target) \
|
||||
const struct config_target target sec(.config_target)
|
||||
|
||||
|
||||
extern const struct config_target config_target_begin[];
|
||||
extern const struct config_target config_target_end[];
|
||||
|
||||
#define list_for_each_config_target(p) \
|
||||
for (p = config_target_begin; p < config_target_end; p++)
|
||||
|
||||
|
||||
#endif
|
||||
93
include_lib/system/config/config_transport.h
Normal file
93
include_lib/system/config/config_transport.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*********************************************************************************************
|
||||
* Filename : config_transport.h
|
||||
|
||||
* Description : Config Interface
|
||||
|
||||
* Author : Bingquan
|
||||
|
||||
* Email : bingquan_cai@zh-jieli.com
|
||||
|
||||
* Last modifiled : 2019-01-07 14:33
|
||||
|
||||
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
|
||||
*********************************************************************************************/
|
||||
#ifndef _CI_TRANSPORT_H
|
||||
#define _CI_TRANSPORT_H
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
/* CI packet types */
|
||||
typedef struct {
|
||||
/**
|
||||
* transport name
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* init transport
|
||||
* @param transport_config
|
||||
*/
|
||||
void (*init)(const void *transport_config);
|
||||
|
||||
/**
|
||||
* open transport connection
|
||||
*/
|
||||
int (*open)(void);
|
||||
|
||||
/**
|
||||
* close transport connection
|
||||
*/
|
||||
int (*close)(void);
|
||||
|
||||
/**
|
||||
* register packet handler for CI packets
|
||||
*/
|
||||
void (*register_packet_handler)(void (*handler)(const u8 *packet, int size));
|
||||
|
||||
/**
|
||||
* support async transport layers, e.g. IRQ driven without buffers
|
||||
*/
|
||||
int (*can_send_packet_now)(uint8_t packet_type);
|
||||
|
||||
/**
|
||||
* send packet
|
||||
*/
|
||||
int (*send_packet)(const u8 *packet, int size);
|
||||
|
||||
/**
|
||||
* extension for UART transport implementations
|
||||
*/
|
||||
int (*set_baudrate)(uint32_t baudrate);
|
||||
} ci_transport_t;
|
||||
|
||||
typedef enum {
|
||||
CI_TRANSPORT_CONFIG_UART,
|
||||
CI_TRANSPORT_CONFIG_USB,
|
||||
CI_TRANSPORT_CONFIG_BLE,
|
||||
} ci_transport_config_type_t;
|
||||
|
||||
typedef struct {
|
||||
ci_transport_config_type_t type;
|
||||
} ci_transport_config_t;
|
||||
|
||||
typedef struct {
|
||||
ci_transport_config_type_t type; // == CI_TRANSPORT_CONFIG_UART
|
||||
uint32_t baudrate_init; // initial baud rate
|
||||
uint32_t baudrate_main; // = 0: same as initial baudrate
|
||||
int flowcontrol; //
|
||||
const char *device_name;
|
||||
} ci_transport_config_uart_t;
|
||||
|
||||
typedef struct {
|
||||
//head
|
||||
u16 id;
|
||||
u16 length;
|
||||
|
||||
u8 payload[0];
|
||||
} _GNU_PACKED_ ci_packet_t;
|
||||
|
||||
#define CI_FORMAT_HEAD sizeof(ci_packet_t)
|
||||
|
||||
const ci_transport_t *ci_transport_uart_instance(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user