code
stringlengths 1
1.05M
| repo_name
stringlengths 6
83
| path
stringlengths 3
242
| language
stringclasses 222
values | license
stringclasses 20
values | size
int64 1
1.05M
|
|---|---|---|---|---|---|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __APP_BLE_MODE_SWITCH_H__
#define __APP_BLE_MODE_SWITCH_H__
#ifdef __cplusplus
extern "C" {
#endif
/*****************************header include********************************/
#include "bluetooth.h"
/******************************macro defination*****************************/
#ifndef BLE_CONNECTION_MAX
#define BLE_CONNECTION_MAX (1)
#endif
// 3 bytes reserved for FLAG field
#define BLE_ADV_DATA_MAX_LEN (28)
#define BLE_SCAN_RSP_DATA_MAX_LEN (31)
// the default interval is 160ms, note that for Bisto user case, to
// let GVA iOS version pop-out notification smoothly, the maximum interval should be this value
#define BLE_ADVERTISING_INTERVAL (160)
#define BLE_FAST_ADVERTISING_INTERVAL (48)
#define BLE_ADV_SVC_FLAG 0x16
#define BLE_ADV_MANU_FLAG 0xFF
// Maximal length of the Device Name value
#define APP_DEVICE_NAME_MAX_LEN (24)
/******************************type defination******************************/
/**
* @brief The state type of the ble
*
*/
enum BLE_STATE_E {
STATE_IDLE = 0,
ADVERTISING = 1,
STARTING_ADV = 2,
STOPPING_ADV = 3,
SCANNING = 4,
STARTING_SCAN = 5,
STOPPING_SCAN = 6,
CONNECTING = 7,
STARTING_CONNECT = 8,
STOPPING_CONNECT = 9,
};
/**
* @brief The operation type of the ble
*
*/
enum BLE_OP_E {
OP_IDLE = 0,
START_ADV = 1,
START_SCAN = 2,
START_CONNECT = 3,
STOP_ADV = 4,
STOP_SCAN = 5,
STOP_CONNECT = 6,
};
enum BLE_ADV_USER_E {
USER_STUB = 0,
USER_GFPS = 1,
USER_GSOUND = 2,
USER_AI = 3,
USER_INTERCONNECTION = 4,
USER_TILE = 5,
USER_OTA = 6,
USER_BT_ADP = 7,
BLE_ADV_USER_NUM,
};
typedef void (*BLE_DATA_FILL_FUNC_T)(void *advParam);
enum BLE_CONNECT_STATE {
BLE_DISCONNECTED = 0,
BLE_DISCONNECTING = 1,
BLE_CONNECTED = 2,
};
typedef struct {
uint8_t advType;
uint16_t advInterval;
uint8_t advDataLen;
uint8_t advData[BLE_ADV_DATA_MAX_LEN];
uint8_t scanRspDataLen;
uint8_t scanRspData[BLE_SCAN_RSP_DATA_MAX_LEN];
} BLE_ADV_PARAM_T;
typedef struct {
uint8_t scanType;
uint16_t scanWindow;
uint16_t scanInterval;
} BLE_SCAN_PARAM_T;
typedef struct {
uint8_t state;
uint8_t addr[BTIF_BD_ADDR_SIZE];
} BLE_CONNECT_PARAM_T;
typedef struct
{
bool advSwitch;
uint8_t state;
uint8_t op;
uint8_t connectNum;
uint8_t bleAddrToConnect[BTIF_BD_ADDR_SIZE];
uint32_t adv_user_register; //one bit represent one user
uint32_t adv_user_enable; //one bit represent one user
/// Device Name length
uint8_t dev_name_len;
/// Device Name
uint8_t dev_name[APP_DEVICE_NAME_MAX_LEN];
BLE_DATA_FILL_FUNC_T bleDataFillFunc[BLE_ADV_USER_NUM];
// param used for BLE adv
BLE_ADV_PARAM_T advInfo;
// prarm used for BLE scan
BLE_SCAN_PARAM_T scanInfo;
// param used for BLE connect
BLE_CONNECT_PARAM_T connectInfo[BLE_CONNECTION_MAX];
} __attribute__((__packed__)) BLE_MODE_ENV_T;
/****************************function declearation**************************/
/*---------------------------------------------------------------------------
* app_ble_mode_tws_sync_init
*---------------------------------------------------------------------------
*
*Synopsis:
* tws related environment initialization for ble module
*
* Parameters:
* void
*
* Return:
* void
*/
void app_ble_mode_tws_sync_init(void);
/*---------------------------------------------------------------------------
* app_ble_mode_init
*---------------------------------------------------------------------------
*
*Synopsis:
* init the bleModeEnv
*
* Parameters:
* void
*
* Return:
* void
*/
void app_ble_mode_init(void);
/*---------------------------------------------------------------------------
* app_ble_sync_ble_info
*---------------------------------------------------------------------------
*
*Synopsis:
* for tws sync ble info
*
* Parameters:
* void
*
* Return:
* void
*/
void app_ble_sync_ble_info(void);
/*---------------------------------------------------------------------------
* app_ble_register_data_fill_handler
*---------------------------------------------------------------------------
*
*Synopsis:
* register a BLE advertisement and scan response data fill handler for a
* specific user(see @BLE_ADV_USER_E), so that the adv/scan response data
* could present in BLE adv/scan response data
*
* Parameters:
* user - see the defination in BLE_ADV_USER_E
* func - adv/scan response data fill handler for specific user
*
* Return:
* void
*/
void app_ble_register_data_fill_handle(enum BLE_ADV_USER_E user, BLE_DATA_FILL_FUNC_T func, bool enable);
void app_ble_unregister_data_fill_handle(enum BLE_ADV_USER_E user);
void app_ble_data_fill_enable(enum BLE_ADV_USER_E user, bool enable);
bool app_ble_get_data_fill_enable(enum BLE_ADV_USER_E user);
bool app_ble_start_adv(uint8_t advType, uint16_t advInterval);
/*---------------------------------------------------------------------------
* app_ble_start_connectable_adv
*---------------------------------------------------------------------------
*
*Synopsis:
* start connetable BLE advertise
*
* Parameters:
* advertisement interval in ms
*
* Return:
* None
*/
void app_ble_start_connectable_adv(uint16_t advInterval);
void app_ble_force_switch_adv(bool onOff);
void app_ble_start_scan(uint16_t scanWindow, uint16_t scanWnterval);
void app_ble_start_connect(uint8_t *bdAddrToConnect);
void app_ble_stop_activities(void);
bool app_ble_is_in_connected_state(void);
bool app_ble_is_in_advertising_state(void);
void app_ble_stub_user_init(void);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef __APP_BLE_MODE_SWITCH_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/ble_app/app_main/app_ble_mode_switch.h
|
C
|
apache-2.0
| 6,606
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BRIDGE_H__
#define __BRIDGE_H__
#if !defined(ENHANCED_STACK)
#include "hci.h"
#endif
#include "ke_msg.h"
#if defined(ENHANCED_STACK)
typedef struct {
uint8_t *buffer;
uint16_t buffer_len;
uint8_t *priv;
uint16_t conn_handle_flags;
} BridgeBuffer;
typedef struct {
U8 *param;
U8 param_len;
uint8_t event;
BridgeBuffer *rx_buff;
} BridgeEvent;
#else
typedef HciEvent BridgeEvent;
typedef HciBuffer BridgeBuffer;
#endif /* ENHANCED_STACK */
void bridge_hcif_send_acl(struct ke_msg *msg);
void bridge_hcif_recv_acl(BridgeBuffer * pBuffer);
void bridge_free_rx_buffer(BridgeBuffer *pBuffer);
void bridge_free_tx_buffer(BridgeBuffer *pBuffer);
void bridge_hci_ble_event(const BridgeEvent* event);
uint8_t bridge_is_cmd_opcode_supported(uint16_t opcode);
void bridge_free_token(void * token);
U8 bridge_check_ble_handle_valid(U16 handle);
void bridge_hcif_send_cmd(struct ke_msg *msg);
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/bridge/bridge.h
|
C
|
apache-2.0
| 1,589
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMMUNICATION_CMD_HANDLE_H
#define COMMUNICATION_CMD_HANDLE_H
#include "tool_msg.h"
#ifdef __cplusplus
extern "C" {
#endif
#define COMMUNICATION_CMD_BUFF_TO_U32(ptr,val) do{ \
val =( ((uint32_t) *((uint8_t*)ptr+3) << 24) | \
((uint32_t) *((uint8_t*)ptr+2) << 16) | \
((uint32_t) *((uint8_t*)ptr+1) << 8) | \
((uint32_t) *((uint8_t*)ptr)) ); \
}while(0)
#define COMMUNICATION_CMD_U32_TO_BUFF(ptr,val) do{ \
*(ptr+3) = (uint8_t) (val>>24); \
*(ptr+2) = (uint8_t) (val>>16); \
*(ptr+1) = (uint8_t) (val>>8); \
*(ptr+0) = (uint8_t) val; \
}while(0)
int communication_cmd_init(int (* cb)(const unsigned char *, unsigned int));
int communication_cmd_send_reply(const unsigned char *payload, unsigned int len);
enum ERR_CODE communication_cmd_check_msg_hdr(struct message_t *msg);
enum ERR_CODE communication_cmd_handle_cmd(enum COMMUNICATION_CMD_TYPE cmd, unsigned char *param, unsigned int len);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/communication/comminication_knowles/communication_cmd_handle.h
|
C
|
apache-2.0
| 1,906
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __COMMUNICATION_CMD_MSG_H__
#define __COMMUNICATION_CMD_MSG_H__
#ifdef __cplusplus
extern "C" {
#endif
enum COMMUNICATION_CMD_TYPE {
COMMUNICATION_CMD_EQ_OP = 0xA1,
COMMUNICATION_CMD_DRC_OP = 0xA2,
COMMUNICATION_CMD_HF_OP = 0xA3,
};
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/communication/comminication_knowles/communication_cmd_msg.h
|
C
|
apache-2.0
| 947
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __COMMUNICATION_SYSAPI_H__
#define __COMMUNICATION_SYSAPI_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#include "stdio.h"
#define TRACE(str, ...) do { printf("%s/" str "\n", __FUNCTION__, __VA_ARGS__); } while (0)
#define ASSERT(cond, str, ...) \
do { if (!(cond)) { printf("[ASSERT]%s/" str, __FUNCTION__, __VA_ARGS__); while (1); } } while (0)
#define TRACE_TIME(str, ...) TRACE(str, __VA_ARGS__)
int write_sig_data(const unsigned char *data, unsigned int len);
int write_code_data(const unsigned char *data, unsigned int len);
void programmer_main(void);
#else
#include "hal_trace.h"
#include "hal_timer.h"
#define TRACE_TIME(str, ...) TRACE("[%05u] " str, TICKS_TO_MS(hal_sys_timer_get()), ##__VA_ARGS__)
#endif
#define UART_OUT_SIGNAL_ID 0x19
enum DOWNLOAD_TRANSPORT {
TRANSPORT_USB,
TRANSPORT_UART,
};
enum XFER_TIMEOUT {
XFER_TIMEOUT_SHORT,
XFER_TIMEOUT_MEDIUM,
XFER_TIMEOUT_LONG,
XFER_TIMEOUT_IDLE,
XFER_TIMEOUT_QTY
};
enum UART_DMA_STATE {
UART_DMA_IDLE,
UART_DMA_START,
UART_DMA_DONE,
UART_DMA_ERROR,
};
void init_transport(void);
void deinit_transport(void);
void reinit_transport(void);
void set_send_timeout(uint32_t timeout);
int secure_settings_valid(void);
int secure_boot_enabled(void);
int usb_enabled(void);
int usb_connected(void);
unsigned short get_boot_security_value(void);
unsigned int get_boot_key_index(void);
int send_data(const unsigned char *buf, unsigned int len);
int recv_data(unsigned char *buf, unsigned int len);
int recv_data_dma(unsigned char *buf, unsigned int len, unsigned int expect);
void recv_data_state_get(enum UART_DMA_STATE *state);
void recv_data_reset(void);
int handle_error(void);
int cancel_input(void);
int verify_signature(const unsigned char *key, const unsigned char *sig, const unsigned char *data, unsigned int len);
int debug_read_enabled(void);
int debug_write_enabled(void);
int get_flash_boot_flag(void);
void set_flash_boot_flag(int flag);
void system_reboot(void);
void system_shutdown(void);
void system_flash_boot(void);
void system_set_bootmode(unsigned int bootmode);
void system_clear_bootmode(unsigned int bootmode);
unsigned int system_get_bootmode(void);
void wait_trace_finished(void);
unsigned int get_current_time(void);
uint32_t ama_uart_get_fifo_data(uint8_t *buf);
uint32_t avil_len_of_the_fifo();
void send_message();
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/communication/comminication_knowles/communication_sysapi.h
|
C
|
apache-2.0
| 3,117
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TOOL_MSG_H__
#define __TOOL_MSG_H__
#include "communication_cmd_msg.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BOOT_MAGIC_NUMBER 0xBE57EC1C
#define BOOT_HASH_TYPE_MD5 1
#define BOOT_HASH_TYPE_SHA256 2
#define BOOT_KEY_TYPE_RSA2048 1
#define BOOT_KEY_TYPE_ECDSA192 2
#define BOOT_KEY_TYPE_ECDSA256 3
#ifdef __PC_CMD_UART__
#define PREFIX_CHAR 0x7b//{
#else
#define PREFIX_CHAR 0xBE
#endif
#define KEY_LEN (4 + 256 + 256)
#define SIG_LEN 256
#define BOOT_STRUCT_OFFSET_TO_SIGN(b) \
((unsigned char *)&((struct boot_struct_t *)(b))->hdr.security)
#define BOOT_STRUCT_LEN_TO_SIGN \
((unsigned int)&((struct boot_struct_t *)0)->sig[0] - \
(unsigned int)&((struct boot_struct_t *)0)->hdr.security)
#define SIG_MSG_OVERHEAD 8
#define SIG_MSG_EXTRA_DATA_LEN (sizeof(struct boot_struct_t) + sizeof(struct code_sig_struct_t))
#define SIG_MSG_TOTAL_LEN (SIG_MSG_OVERHEAD + SIG_MSG_EXTRA_DATA_LEN)
#define CODE_MSG_OVERHEAD 8
#define BURN_DATA_MSG_OVERHEAD 16
#define SECTOR_SIZE_64K (1 << 16)
#define SECTOR_SIZE_32K (1 << 15)
#define SECTOR_SIZE_16K (1 << 14)
#define SECTOR_SIZE_4K (1 << 12)
#define MSG_TOTAL_LEN(msg) (sizeof((msg)->hdr) + (msg)->hdr.len + 1)
enum MSG_TYPE {
TYPE_SYS = 0x00,
TYPE_READ = 0x01,
TYPE_WRITE = 0x02,
TYPE_BULK_READ = 0x03,
TYPE_SYNC = 0x50,
TYPE_SIG_INFO = 0x51,
TYPE_SIG = 0x52,
TYPE_CODE_INFO = 0x53,
TYPE_CODE = 0x54,
TYPE_RUN = 0x55,
TYPE_SECTOR_SIZE = 0x60,
TYPE_ERASE_BURN_START = 0x61,
TYPE_ERASE_BURN_DATA = 0x62,
TYPE_BURN_START = 0x63,
TYPE_BURN_DATA = 0x64,
TYPE_BURN_CMD = 0x65,
TYPE_GET_SECTOR_INFO = 0x66,
#if defined(__EXT_CMD_SUPPORT__)
TYPE_EXTEND_CMD = 0x67,
#endif
TYPE_COMMUNICATION_CMD = 0x68,
};
enum SYS_CMD_TYPE {
SYS_CMD_REBOOT = 0xF1,
SYS_CMD_SHUTDOWN = 0xF2,
SYS_CMD_FLASH_BOOT = 0xF3,
SYS_CMD_SET_BOOTMODE = 0xE1,
SYS_CMD_CLR_BOOTMODE = 0xE2,
SYS_CMD_GET_BOOTMODE = 0xE3,
};
enum ERR_CODE {
ERR_NONE = 0x00,
ERR_LEN = 0x01,
ERR_CHECKSUM = 0x02,
ERR_NOT_SYNC = 0x03,
ERR_NOT_SEC = 0x04,
ERR_SYNC_WORD = 0x05,
ERR_SYS_CMD = 0x06,
ERR_DATA_ADDR = 0x07,
ERR_DATA_LEN = 0x08,
ERR_ACCESS_RIGHT = 0x09,
ERR_TYPE_INVALID = 0x0F,
//ERR_BOOT_OK = 0x10,
ERR_BOOT_MAGIC = 0x11,
ERR_BOOT_SEC = 0x12,
ERR_BOOT_HASH_TYPE = 0x13,
ERR_BOOT_KEY_TYPE = 0x14,
ERR_BOOT_KEY_LEN = 0x15,
ERR_BOOT_SIG_LEN = 0x16,
ERR_BOOT_SIG = 0x17,
ERR_BOOT_CRC = 0x18,
ERR_BOOT_LEN = 0x19,
ERR_SIG_CODE_SIZE = 0x1A,
ERR_SIG_SIG_LEN = 0x1B,
ERR_SIG_INFO_MISSING = 0x1C,
ERR_CODE_OK = 0x20,
ERR_BOOT_MISSING = 0x21,
ERR_CODE_SIZE_SIG = 0x22,
ERR_CODE_ADDR_SIZE = 0x23,
ERR_CODE_INFO_MISSING = 0x24,
ERR_CODE_CRC = 0x25,
ERR_CODE_SIG = 0x26,
ERR_CODE_MISSING = 0x31,
ERR_BURN_OK = 0x60,
ERR_SECTOR_SIZE = 0x61,
ERR_SECTOR_SEQ_OVERFLOW = 0x62,
ERR_BURN_INFO_MISSING = 0x63,
ERR_SECTOR_DATA_LEN = 0x64,
ERR_SECTOR_DATA_CRC = 0x65,
ERR_SECTOR_SEQ = 0x66,
ERR_ERASE_FLSH = 0x67,
ERR_BURN_FLSH = 0x68,
ERR_VERIFY_FLSH = 0x69,
ERR_BURN_CMD = 0x6A,
ERR_TYPE_MISMATCHED = 0xE1,
ERR_SEQ_MISMATCHED = 0xE2,
ERR_BUF_TOO_SMALL = 0xE3,
ERR_INTERNAL = 0xFF,
};
enum PARSE_STATE {
PARSE_HEADER,
PARSE_DATA,
PARSE_EXTRA,
};
struct message_t {
struct msg_hdr_t {
unsigned char prefix;
unsigned char type;
unsigned char seq;
unsigned char len;
} hdr;
unsigned char data[255];
};
struct boot_struct_t {
struct boot_hdr_t {
unsigned int magic;
unsigned short security;
unsigned char hash_type;
unsigned char key_type;
unsigned short key_len;
unsigned short sig_len;
unsigned int build_info_start;
} hdr;
unsigned char key[KEY_LEN];
unsigned char sig[SIG_LEN];
};
struct code_sig_struct_t {
unsigned int code_size;
unsigned short sig_len;
unsigned short reserved;
unsigned char sig[SIG_LEN];
};
struct exec_struct_t {
unsigned int entry;
unsigned int param;
unsigned int sp;
unsigned int reserved;
};
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/communication/comminication_knowles/tool_msg.h
|
C
|
apache-2.0
| 5,098
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __COMMUNICATION_SVR_H__
#define __COMMUNICATION_SVR_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*communication_receive_func_typedef)(uint8_t *buf, uint8_t len);
void communication_init(void);
int communication_receive_register_callback(communication_receive_func_typedef p);
int communication_send_buf(uint8_t * buf, uint8_t len);
#ifdef KNOWLES_UART_DATA
void uart_audio_init();
void uart_audio_deinit();
#endif
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/communication/communication_svr.h
|
C
|
apache-2.0
| 1,130
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CP_ACCEL_H__
#define __CP_ACCEL_H__
#include "plat_types.h"
#include "hal_location.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int (*CP_ACCEL_CP_MAIN)(void);
typedef unsigned int (*CP_ACCEL_EVT_HDLR)(uint32_t event);
int cp_accel_open(CP_ACCEL_CP_MAIN cp_main, CP_ACCEL_EVT_HDLR cp_hdlr, CP_ACCEL_EVT_HDLR mcu_hdlr, CP_ACCEL_EVT_HDLR mcu_sys_hdlr);
int cp_accel_close(void);
int cp_accel_init_done(void);
int cp_accel_send_event_mcu2cp(uint32_t event);
int cp_accel_send_event_cp2mcu(uint32_t event);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/cp_accel/cp_accel.h
|
C
|
apache-2.0
| 1,224
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CP_SERVER_H__
#define __CP_SERVER_H__
#if defined(CHIP_HAS_CP)
#ifdef __cplusplus
extern "C" {
#endif
#define CP_BUF_LEN 0x2000
typedef void (*CP_TASK_T)(void *param);
typedef enum {
CP_TASK_ID_INVALID,
CP_TASK_ID_MP3,
CP_TASK_ID_AAC_ADTS,
CP_TASK_ID_OPUS_DEC,
CP_TASK_ID_OPUS_ENC,
CP_TASK_ID_EQ_DRC,
#ifdef VOIP_ALG_IN_CP
CP_TASK_ID_VOIP_ALG,
#endif
CP_TASK_ID_RESAMP,
CP_TASK_ID_NUM,
}CP_TASK_ID_T;
#ifdef MP3_DECODE_IN_CP
typedef struct {
uint32_t decoder_hander_addr;
uint32_t mp3_bytes;
uint32_t out_pcm_addr;
uint32_t out_mp3_info_addr;
uint32_t in_buf_addr;
int32_t result;
uint8_t buf_location;
}CP_MSG_MP3_DEC_T;
#endif
#ifdef AAC_DECODE_IN_CP
typedef struct {
uint32_t decoder_hander_addr;
uint32_t in_buf_addr;
uint32_t in_buf_size_addr;
uint32_t in_buf_valid_addr;
uint32_t out_buf_addr;
int32_t out_buf_size;
int32_t flags;
int32_t result;
uint8_t buf_location;
}CP_MSG_AAC_DEC_T;
#endif
#ifdef OPUS_DECODE_IN_CP
typedef struct {
uint32_t decoder_hander_addr;
uint32_t in_buf_addr;
uint32_t in_buf_size;
uint32_t out_buf_addr;
uint32_t out_buf_size;
int32_t decode_fec;
int32_t result;
uint8_t buf_location;
}CP_MSG_OPUS_DEC_T;
#endif
#ifdef OPUS_ENCODE_IN_CP
typedef struct {
uint32_t handler_addr;
uint32_t in_buf_addr;
uint32_t in_buf_size;
uint32_t buf_size;
uint32_t out_buf_addr;
int32_t max_data_bytes;
int32_t result;
uint8_t buf_location;
}CP_MSG_OPUS_ENC_T;
#endif
#ifdef VOIP_ALG_IN_CP
typedef struct {
uint32_t decoder_hander_addr;
uint32_t near_buf_addr;
uint32_t far_buf_addr;
uint32_t out_buf_addr;
uint32_t buf_size;
int32_t result;
uint8_t buf_location;
}CP_MSG_VOIP_ALG_T;
#endif
#ifdef EQ_DRC_IN_CP
typedef struct {
uint32_t buf_addr;
uint32_t buf_len;
int32_t result;
}CP_MSG_EQ_DRC_T;
#endif
#ifdef ALSA_RESAMPLE_IN_CP
typedef struct {
uint32_t handler_addr;
uint32_t io_addr;
uint32_t in_size;
uint32_t out_size;
int32_t result;
uint8_t buf_location;
}CP_MSG_RESAMP_T;
#endif
typedef struct {
CP_TASK_ID_T id;
uint32_t buf[CP_BUF_LEN/4];
}CP_MSG_T;
int cp_server_init();
void cp_server_register_task(CP_TASK_ID_T id, CP_TASK_T task_handler);
int cp_server_send_msg_to_cp(CP_TASK_ID_T id, void *msg);
void *cp_heap_malloc(uint32_t size);
void *cp_heap_calloc(uint32_t count, uint32_t size);
void cp_heap_free(void *p);
void *cp_heap_realloc(void *p, uint32_t size);
void cp_heap_memory_info(uint32_t *total, uint32_t *used, uint32_t *max_used);
#ifdef __cplusplus
}
#endif
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/cp_server/cp_server.h
|
C
|
apache-2.0
| 3,336
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HW_FILTER_CODEC_IIR_H__
#define __HW_FILTER_CODEC_IIR_H__
#include <stdint.h>
#include "iir_process.h"
#include "hw_codec_iir_process.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int32_t bypass;
HW_CODEC_IIR_TYPE_T iir_device;
#if 1
HW_CODEC_IIR_CFG_F iir_cfg;
#else
IIR_CFG_T iir_cfg;
#endif
} hw_filter_codec_iir_cfg;
struct hw_filter_codec_iir_state_;
typedef struct hw_filter_codec_iir_state_ hw_filter_codec_iir_state;
// Creat a instance from hw_filter_codec_iir module/class
// Common value include: sample rate, frame size and so on.
hw_filter_codec_iir_state *hw_filter_codec_iir_create(int32_t sample_rate, int32_t channel_num, int32_t bits, hw_filter_codec_iir_cfg *cfg);
// Destory a hw_filter_codec_iir instance
int32_t hw_filter_codec_iir_destroy(hw_filter_codec_iir_state *st);
// Just use modify instance configure
int32_t hw_filter_codec_iir_set_config(hw_filter_codec_iir_state *st, hw_filter_codec_iir_cfg *cfg);
// Get/set some value or enable/disable some function
// int32_t hw_filter_codec_iir_ctl(hw_filter_codec_iir_state *st, int32_t ctl, void *ptr);
// Do not need process function, because hardware run separately
// Debug hw_filter_codec_iir instance
int32_t hw_filter_codec_iir_dump(hw_filter_codec_iir_state *st);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/hw_dsp/inc/hw_filter_codec_iir.h
|
C
|
apache-2.0
| 2,025
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __APP_INTERACTION_H__
#define __APP_INTERACTION_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "cmsis_os.h"
#include "stdint.h"
// connection related definitions
#define DEFAULT_INTERACTION_BLE_DATA_SEC_SIZE (20)
#define DEFAULT_INTERACTION_SPP_DATA_SEC_SIZE (600)
#define INTERACTION_SPP_DEFAULT_MTU_VALUE (600)
#define APP_INTERACTION_PATH_TYPE_SPP (1 << 0)
#define APP_INTERACTION_PATH_TYPE_BLE (1 << 1)
#define APP_INTERACTION_PATH_TYPE_HFP (1 << 2)
#define APP_INTERACTION_PATH_TYPE (APP_INTERCONN_PATH_TYPE_BLE | APP_INTERCONN_PATH_TYPE_SPP)
#define APP_INTERACTION_SPP_CONNECTED (1 << 0)
#define APP_INTERACTION_BLE_CONNECTED (1 << 1)
#define APP_INTERACTION_SPP_BLE_BOTH_CONNECTED (APP_INTERCONN_SPP_CONNECTED | APP_INTERCONN_BLE_CONNECTED)
#define APP_INTERACTION_SPP_DISCONNECTED (~(1 << 0))
#define APP_INTERACTION_BLE_DISCONNECTED (~(1 << 1))
#define APP_INTERACTION_SPP_BLE_BOTH_DISCONNECTED (0)
#define INTERACTION_DEVICE_CHECK(dev) \
do \
{ \
if (!dev) \
ASSERT(0, "false spp device, %s, %d\n", __func__, __LINE__); \
} while (0)
#define SPP_MAX_PACKET_SIZE 600
#define SPP_MAX_PACKET_NUM 5
typedef enum
{
INTERACTION_SUCESS = 0x00,
INTERACTION_FAILURE ,
INTERACTION_INVALIDATE_PARAMETER,
INTERACTION_VERIFICATION_FAILURE,
INTERACTION_VALIDATION_FAILURE,
INTERACTION_TIME_OUT_WITHOUT_ACK,
INTERACTION_TIME_OUT,
INTERACTION_WRITTING_FAILURE,
} INTERACTION_RSP_STATUS_E;
typedef struct {
uint8_t connType;
uint8_t conidx;
uint16_t DataSectorSize;
} __attribute__((__packed__)) INTERACTION_ENV_T;
typedef struct
{
void * pDev;
uint8_t process;
uint8_t *data;
uint32_t dataLen;
} INTERACTION_MAIL_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t *param;
}__attribute__ ((__packed__)) INTERACTION_PAYLOAD_T;
typedef struct
{
uint8_t cmdSOF;
uint8_t cmdLen;
uint16_t cmdCtrol;
//uint16_t cmdFSN;
INTERACTION_PAYLOAD_T cmdPayload;
// uint16_t cmdChecksum;
}__attribute__ ((__packed__)) INTERACTION_CMD_T;
typedef struct
{
uint8_t cmdSOF;
uint16_t cmdLen;
uint16_t cmdCtrol;
//uint16_t cmdFSN;
INTERACTION_PAYLOAD_T cmdPayload;
// uint16_t cmdChecksum;
}__attribute__ ((__packed__)) INTERACTION_LONG_CMD_T;
typedef enum {
INTERACTION_PROCESS_INVALID = 0,
INTERACTION_PROCESS_READ = 1,
INTERACTION_PROCESS_WRITE = 2,
INTERACTION_PROCESS_MAX,
} INTERACTION_PROCESS_E;
#define INTERACTION_SUCCESS_STATUS 0
#define INTERACTION_FAILURE_STATUS 1
#define NUMBER_OF_PAIRS 1
#define INTERACTION_CMD_PACKET_SOF 0xAA
/***************get remote capabilities***************/
#define INTERACTION_GET_REMOTE_CAPABILITIES_REQ 0x0100
#define INTERACTION_GET_REMOTE_CAPABILITIES_RSP 0x8100
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_REMOTE_CAPABILITIES_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t featureValue;
}__attribute__ ((__packed__)) INTERACTION_REMOTE_CAPABILITIES_CFM_T;
/*********************MTU***************************/
#define INTERACTION_MTU_CMD_REQ 0x0101
#define INTERACTION_MTU_CMD_CFM 0x8101
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t mtuValue;
}__attribute__ ((__packed__)) INTERACTION_MTU_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint16_t mtuValue;
}__attribute__ ((__packed__)) INTERACTION_MTU_CFM_T;
/*********************remote VID***************************/
#define INTERACTION_REMOTE_VID_CMD_REQ 0x0102
#define INTERACTION_REMOTE_VID_CMD_CFM 0x8102
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint16_t remoteVID;
}__attribute__ ((__packed__)) INTERACTION_VID_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint16_t remoteVID;
}__attribute__ ((__packed__)) INTERACTION_VID_CFM_T;
/*********************remote PID***************************/
#define INTERACTION_REMOTE_PID_CMD_REQ 0x0103
#define INTERACTION_REMOTE_PID_CMD_CFM 0x8103
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
//uint8_t remotePID;
}__attribute__ ((__packed__)) INTERACTION_PID_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t remotePID[3];
}__attribute__ ((__packed__)) INTERACTION_PID_CFM_T;
/*********************protocol version***************************/
#define INTERACTION_PROTOCOL_VERSION_CMD_REQ 0x0104
#define INTERACTION_PROTOCOL_VERSION_CMD_CFM 0x8104
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t *version;
}__attribute__ ((__packed__)) INTERACTION_PROTOCOL_VERSION_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t version[3];
}__attribute__ ((__packed__)) INTERACTION_PROTOCOL_VERSION_CFM_T;
/*********************remote version***************************/
#define INTERACTION_REMOTE_VERSION_CMD_REQ 0x0105
#define INTERACTION_REMOTE_VERSION_CMD_CFM 0x8105
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_REMOTE_VERSION_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t numbersOfKey;
uint8_t version[3];
}__attribute__ ((__packed__)) INTERACTION_REMOTE_VERSION_CFM_T;
/************battery infomation start***********/
#define INTERACTION_BATTERY_CMD_REQ 0x0106
#define INTERACTION_BATTERY_CMD_CFM 0x8106
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_BATTERY_REPORT_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t nums_of_pairs;
uint8_t earphone_info;
uint8_t battery_value;
}__attribute__ ((__packed__)) INTERACTION_BATTERY_REPORT_CFM_T;
/************upgrade capability info start***************/
#define INTERACTION_UPGRADE_CAPABITITY_CMD_REQ 0x0107
#define INTERACTION_UPGRADE_CAPABITITY_CMD_CFM 0x8107
#define INTERACTION_UPGRADE_SUPPORT 1
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_UPGRADE_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t nums_of_pairs;
uint16_t info;
}__attribute__ ((__packed__)) INTERACTION_UPGRADE_CFM_T;
/************key function***************/
#define INTERACTION_UPGRADE_KEY_FUNCTION_REQ 0x0108
#define INTERACTION_UPGRADE_KEY_FUNCTION_CFM 0x8108
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_KEY_FUNCTIONS_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t nums_of_array;
uint8_t earphone_info[8];
}__attribute__ ((__packed__)) INTERACTION_KEY_FUNCTIONS_CFM_T;
/************earbus status***************/
#define INTERACTION_UPGRADE_EARBUDS_STATUS_REQ 0x0109
#define INTERACTION_UPGRADE_EARBUDS_STATUS_CFM 0x8109
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_EARBUDS_STATUS_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t nums_of_array;
uint8_t earbuds_info[4];
}__attribute__ ((__packed__)) INTERACTION_EARBUDS_STATUS_CFM_T;
/************notification command start***************/
#define INTERACTION_GET_NOTIFICATION_CAPABILITY_CMD_REQ 0x0200
#define INTERACTION_GET_NOTIFICATION_CAPABILITY_CMD_CFM 0x8200
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_GET_NOTIFICATION_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t nums;
uint16_t eventType;
}__attribute__ ((__packed__)) INTERACTION_GET_NOTIFICATION_CFM_T;
#define INTERACTION_REGISTER_NOTIFICATION_CMD_REQ 0x0201
#define INTERACTION_REGISTER_NOTIFICATION_CMD_CFM 0x8201
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
uint8_t eventCode;
}__attribute__ ((__packed__)) INTERACTION_REGISTER_NOTIFICATION_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION_REGISTER_NOTIFICATION_CFM_T;
#define INTERACTION_GET_REGISTERED_NOTIFY_CMD_REQ 0x0202
#define INTERACTION_GET_REGISTERED_NOTIFY_CMD_CFM 0x8202
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION_GET_REGISTERED_NOTIFICATION_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t eventType;
uint8_t nums;
uint16_t info;
}__attribute__ ((__packed__)) INTERACTION_GET_REGISTERED_NOTIFICATION_CFM_T;
#define INTERACTION_CANCEL_REGISTERED_NOTIFY_CMD_REQ 0x0203
#define INTERACTION_CANCEL_REGISTERED_NOTIFY_CMD_CFM 0x8203
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION_CANCEL_REGISTERED_NOTIFICATION_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION_CANCEL_REGISTERED_NOTIFICATION_CFM_T;
#define INTERACTION_NOTIFY_EVENT_CMD_REQ 0x0204
#define INTERACTION_NOTIFY_EVENT_CMD_CFM 0x8204
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
uint8_t eventData;
}__attribute__ ((__packed__)) INTERACTION__NOTIFICATION_EVENT_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION_NOTIFICATION_EVENT_CFM_T;
#define INTERACTION_BATTERY_CHANGED_EVENT_CMD_REQ 0x0001
#define INTERACTION_BATTERY_CHANGED_EVENT_CMD_CFM 0x8001
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION__BATTERY_CHANGED_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION__BATTERY_CHANGED_CFM_T;
#define INTERACTION_EARBUDS_CHANGED_EVENT_CMD_REQ 0x0002
#define INTERACTION_EARBUDS_CHANGED_EVENT_CMD_CFM 0x8002
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION__EARBUDS_CHANGED_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION__EARBUDS_CHANGED_CFM_T;
/************notification command end***************/
/***********************set command start***************************/
#define INTERACTION_SET_FIND_MODE_CMD_REQ 0x0400
#define INTERACTION_SET_FIND_MODE_CMD_CFM 0x8400
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t eventType;
}__attribute__ ((__packed__)) INTERACTION_SET_MODE_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
}__attribute__ ((__packed__)) INTERACTION_SET_MODE_CFM_T;
#define INTERACTION_SET_KEY_FUNCTIONS_CMD_REQ 0x0401
#define INTERACTION_SET_KEY_FUNCTIONS_CMD_CFM 0x8401
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t *info;
}__attribute__ ((__packed__)) INTERACTION_SET_kEY_FUNCTIONS_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
}__attribute__ ((__packed__)) INTERACTION_SET_KEY_FUNCTIONS_CFM_T;
#define INTERACTION_LISTEN_MUSIC_CMD_REQ 0x0402
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
}__attribute__ ((__packed__)) INTERACTION_LISTEN_MUSIC_REQ_T;
/***********************set command end***************************/
/***********ota command start***************/
#define INTERACTION_OTA_UPGRADE_SYS_REQ 0x0300
#define INTERACTION_OTA_UPGRADE_SYS_CFM 0x8300
#define INTERACTION_OTA_UPGRADE_START_REQ 0x0301
#define INTERACTION_OTA_UPGRADE_START_CFM 0x8301
#define INTERACTION_OTA_UPGRADE_DATA_REQ 0x0302
#define INTERACTION_OTA_UPGRADE_DATA_CFM 0x8302
#define INTERACTION_OTA_UPGRADE_BLOCK_VERIFY_REQ 0x0303
#define INTERACTION_OTA_UPGRADE_BLOCK_VERIFY_CFM 0x8303
#define INTERACTION_OTA_UPGRADE_IS_VALIDATION_DONE_REQ 0x0304
#define INTERACTION_OTA_UPGRADE_IS_VALIDATION_DONE_CFM 0x8304
#define INTERACTION_OTA_UPGRADE_TRANSFER_COMPLETE_IND 0x0305
#define INTERACTION_OTA_UPGRADE_TRANSFER_COMPLETE_CFM 0x8305
#define INTERACTION_OTA_UPGRADE_COMMIT_REQ 0x0306
#define INTERACTION_OTA_UPGRADE_COMMIT_CFM 0x8306
#define INTERACTION_OTA_UPGRADE_ABORT_REQ 0x0307
#define INTERACTION_OTA_UPGRADE_ABORT_CFM 0x8307
#define INTERACTION_OTA_UPGRADE_ERROR_IND 0x0308
/***********ota command end***************/
//add new code begin
void app_interaction_spp_open(void);
int interaction_spp_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen);
void app_interaction_report_battery_level(void);
void app_interaction_get_upgrade_capability(void);
void app_interaction_register_notification_hanlder(void);
void app_interaction_send_cmd_handler(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_get_MTU_handler(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_get_remoteVID_handler(uint8_t* ptrData, uint32_t dataLength);
bool app_interaction_check_the_length(uint8_t* ptrData, uint32_t dataLength);
extern void app_interaciton_listen_music_handler(void);
uint8_t app_interaction_get_seq_number(void);
//add new code end
uint8_t app_interaction_get_ota_status();
extern void app_interaction_init();
void app_interaction_connected(uint8_t conidx, uint8_t connType);
void app_interaction_disconnected(uint8_t disconnType);
void app_interaction_send_done(void);
uint8_t app_interaction_get_conn_status();
uint16_t app_interaction_get_datasectorsize(void);
void app_interaction_spp_receive_data_handler(uint8_t* ptrData, uint32_t dataLength);
#ifdef __cplusplus
}
#endif
#endif // __APP_TENCENT_OTA_H__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/green/app_interaction.h
|
C
|
apache-2.0
| 18,275
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERACTION_FASTPAIR__
#ifdef __cplusplus
extern "C" {
#endif
void app_ibrt_ui_start_ble_adv_broadcasting(uint8_t pairing_status);
void app_ibrt_ui_stop_ble_adv_broadcasting(void);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/green/app_interaction_ble_fastpair.h
|
C
|
apache-2.0
| 880
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERACTION__
#ifdef __cplusplus
extern "C" {
#endif
#include "stdint.h"
#define APP_WAIT_TIMEOUT 60//second
#define DEVICE_RESTART_TIMEOUT 60
#define OTA_UNIT_SIZE_SPP 512
#define INTERVAL 10//ms
#define ACK_ENABLE
#define FLASH_SECTOR_SIZE_IN_BYTES 4096
#define OTA_DATA_BUFFER_SIZE_FOR_BURNING FLASH_SECTOR_SIZE_IN_BYTES
#define INTERACTION_OTA_NORFLASH_BUFFER_LEN (FLASH_SECTOR_SIZE_IN_BYTES*2)
#define OTA_START_MAGIC_CODE (0x54534542) // BEST
#define NORMAL_BOOT 0xBE57EC1C
#define COPY_NEW_IMAGE 0x5a5a5a5a
#ifndef NEW_IMAGE_FLASH_OFFSET
#define NEW_IMAGE_FLASH_OFFSET (0x200000)
#endif
#ifndef __APP_IMAGE_FLASH_OFFSET__
#define __APP_IMAGE_FLASH_OFFSET__ (0x18000)
#endif
#define OTA_FLASH_LOGIC_ADDR (FLASH_NC_BASE)
#define OTA_FLASH_OFFSET_OF_IMAGE __APP_IMAGE_FLASH_OFFSET__
#define OTA_FLASH_ENTRY_OFFSET (OTA_FLASH_LOGIC_ADDR + OTA_FLASH_OFFSET_OF_IMAGE)
#define OTA_FLASH_ENTRY2_OFFSET (OTA_FLASH_LOGIC_ADDR + NEW_IMAGE_FLASH_OFFSET)
#define BD_ADDR_LENGTH 6
#define NAME_LENGTH 32
#define OTA_BLE_DATA_PACKET_MAX_SIZE 257
#define OTA_BT_DATA_PACKET_MAX_SIZE 513
#define OTA_BOOT_INFO_FLASH_OFFSET 0x1000
/**
* @brief The format of the otaBootInfo
*
*/
typedef struct
{
uint8_t version_md5[4];
}__attribute__ ((__packed__)) INTERACTION_OTA_RESUME_VERIFY_T;
typedef struct
{
uint32_t magicNumber;
uint32_t imageSize;
uint32_t imageCrc;
}__attribute__ ((__packed__)) FLASH_OTA_BOOT_INFO_T;
typedef struct
{
uint8_t version_md5[4];
uint32_t upgradeDone;
uint32_t upgradeSize[(FLASH_SECTOR_SIZE_IN_BYTES - 8) / 4];
}__attribute__ ((__packed__)) FLASH_OTA_UPGRADE_LOG_FLASH_T;
typedef struct
{
uint8_t isToRenameBT;
uint8_t newBTName[32];
uint8_t isToRenameBLE;
uint8_t newBLEName[32];
uint8_t isToUpdateBTAddr;
uint8_t newBTAddr[6];
uint8_t isToUpdateBLEAddr;
uint8_t newBLEAddr[6];
uint32_t startLocationToWriteImage; // the offset of the flash to start writing the image
}__attribute__ ((__packed__))INTERACTION_OTA_CONFIGURATION_T;
typedef struct
{
uint8_t dataBufferForBurning[OTA_DATA_BUFFER_SIZE_FOR_BURNING];
uint32_t dstFlashOffsetForNewImage;
uint32_t offsetInDataBufferForBurning;
uint32_t offsetInFlashToProgram;
uint32_t totalImageSize;
uint32_t alreadyReceivedDataSizeOfImage;
uint32_t offsetInFlashOfCurrentSegment;
uint32_t offsetOfImageOfCurrentSegment;
uint32_t crc32OfImage;
uint32_t crc32OfSegment;
uint32_t flashOffsetOfUserDataPool;
uint32_t flasehOffsetOfFactoryDataPool;
uint8_t version_md5[4];
INTERACTION_OTA_CONFIGURATION_T configuration;
uint8_t isOTAInProgress;
uint8_t isReadyToApply;
// uint8_t resumeType;
bool resume_at_breakpoint;
uint32_t breakPoint;
uint32_t i_log;
} __attribute__((__packed__)) INTERACTION_OTA_ENV_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t idenfifier[4]; //is the MD5 of file;
uint8_t type;
} __attribute__((__packed__)) INTERACTION_OTA_SYNC_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t type;
uint8_t resumePointTpye;
uint8_t blockCheck;
uint32_t blockSize;
uint16_t transferSize;
uint8_t idenfifier[4];
} __attribute__((__packed__)) INTERACTION_OTA_SYNC_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t type;
uint8_t resumePoint;
uint32_t imageSize;
} __attribute__((__packed__)) INTERACTION_OTA_START_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint8_t type;
uint8_t resumePoint;
uint32_t startOffset;
} __attribute__((__packed__)) INTERACTION_OTA_START_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint32_t startOffset;
uint8_t *data;
} __attribute__((__packed__)) INTERACTION_OTA_DATA_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint16_t delayTime;
} __attribute__((__packed__)) INTERACTION_OTA_DATA_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint32_t startOffset ;
uint32_t crc;
} __attribute__((__packed__)) INTERACTION_OTA_BLOCK_VERIFY_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
} __attribute__((__packed__)) INTERACTION_OTA_BLOCK_VERIFY_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
} __attribute__((__packed__)) INTERACTION_OTA_VALIDATION_DONE_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
uint16_t delayTime;
} __attribute__((__packed__)) INTERACTION_OTA_VALIDATION_DONE_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
} __attribute__((__packed__)) INTERACTION_OTA_TRANSFER_COMPELETE_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
} __attribute__((__packed__)) INTERACTION_OTA_TRANSFER_COMPELETE_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
} __attribute__((__packed__)) INTERACTION_OTA_COMMIT_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
} __attribute__((__packed__)) INTERACTION_OTA_COMMIT_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
} __attribute__((__packed__)) INTERACTION_OTA_ABORT_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t status;
} __attribute__((__packed__)) INTERACTION_OTA_ABORT_CFM_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t errorCode;
} __attribute__((__packed__)) INTERACTION_OTA_ERROR_REQ_T;
typedef struct
{
uint16_t cmdID;
uint8_t transferID;
uint16_t paramLen;
uint8_t starus;
} __attribute__((__packed__)) INTERACTION_OTA_ERROR_CFM_T;
typedef enum
{
OTA_BLOCK_NO_CHECK = 0x00,
OTA_BLOCK_CHECK,
}INTERACTION_OTA_UPGRADE_BLOCK_CHECK_T;
typedef enum
{
OTA_UPGRADE_RESUME_POINT_START=0x00,
OTA_UPGRADE_RESUME_POINT_PRE_VALIDATE,
OTA_UPGRADE_RESUME_POINT_PRE_UPGRADE,
OTA_UPGRADE_RESUME_POINT_POST_UPGRADE,
} INTERACTION_OTA_UPGRADE_STATUS_T;
typedef enum
{
OTA_BIN_OF_EARPHONE=0x01,
OTA_BIN_OF_BOX,
}INTERACTION_OTA_UPGRADE_BIN_TYPE_T;
#define PACKETCRC_RESULT_TYPE 0x01
#define PACKETCRC_RESULT_LENGHT 0x01
#define IMAGE_RECV_FLASH_CHECK 1 // It's best to turn it on durning development and not a big deal off in the release.
#define MAX_IMAGE_SIZE ((uint32_t)(NEW_IMAGE_FLASH_OFFSET - __APP_IMAGE_FLASH_OFFSET__))
#define MIN_SEG_ALIGN 256
void ota_breakpoint_log(uint32_t breakpoint);
void app_interaction_ota_set_update_flag(bool flag);
bool app_interaction_ota_get_update_flag(void);
uint8_t app_interaction_ota_get_battery_threshold(void);
uint32_t app_interaction_ota_get_file_offset();
void app_interaction_ota_set_ota_in_progress(uint8_t value);
uint8_t app_interaction_ota_get_file_bitmap();
bool app_interaction_ota_is_image_info_received(void);
void app_interaction_ota_image_info_received_handler(uint8_t *ptrParam, uint32_t paramLen);
void app_interaction_ota_fw_data_received_handler(uint8_t* ptrData, uint32_t DataLength, bool pass);
void app_interaction_ota_handler_init(void);
void app_interaction_ota_finished_handler(void);
uint8_t app_interaction_get_ota_status();
void app_interaction_ota_firmware_verify_handler(void);
void ota_segmemt_verify_handler(uint8_t* ptrParam, uint32_t paramLen);
INTERACTION_OTA_ENV_T *app_interaction_ota_get_env_ptr();
void app_interaction_ota_upgrade_is_validation_done_rsp();
void app_interaction_ota_upgrade_sys_rsp();
void app_interaction_ota_upgrade_sys_hanlder(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_ota_upgrade_start_hanlder(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_ota_upgrade_data_hanlder(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_ota_upgrade_block_verify_hanlder(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_ota_upgrade_is_validation_done_hanlder(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_ota_finished_handler(void);
void app_interaction_ota_upgrade_is_complete_hanlder(void);
void app_interaction_ota_upgrade_commit_hanlder(uint8_t* ptrData, uint32_t dataLength);
void app_interaction_ota_upgrade_abort_handler(uint8_t* ptrData, uint32_t dataLength);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/green/app_interaction_ota.h
|
C
|
apache-2.0
| 9,836
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __APP_INTERACTION_SPP_H__
#define __APP_INTERACTION_SPP_H__
#include "spp_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*app_spp_tx_done_t)(void);
//add new function
void green_spp_server_open(void);
void app_interaction_send_cmd_via_spp(uint8_t* ptrData, uint32_t length);
void green_spp_register_tx_done(app_spp_tx_done_t callback);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/green/app_interaction_spp.h
|
C
|
apache-2.0
| 1,052
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONN_H__
#define __APP_INTERCONN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "cmsis_os.h"
#include "stdint.h"
#include "me_api.h"
#define INTERCONNECTION_MALLOC umm_malloc
#define INTERCONNECTION_FREE umm_free
#define INTERCONNECTION_DEVICE_CHECK(dev) \
do \
{ \
if (!dev) \
ASSERT(0, "false spp device, %s, %d\n", __func__, __LINE__); \
} while (0)
#define SPP_MAX_PACKET_SIZE 1024
#define SPP_MAX_PACKET_NUM 5
#define SPP_TX_BUF_SIZE 1024 //4096
#define INTERCONNECTION_READ_BUFF_SIZE (4096 + 100) //(FLASH_SECTOR_SIZE_IN_BYTES + 100)
// connection related definitions
#define DEFAULT_INTERCONN_BLE_DATA_SEC_SIZE (20)
#define DEFAULT_INTERCONN_SPP_DATA_SEC_SIZE (600)
#define APP_INTERCONN_PATH_TYPE_SPP (1 << 0)
#define APP_INTERCONN_PATH_TYPE_BLE (1 << 1)
#define APP_INTERCONN_PATH_TYPE_HFP (1 << 2)
#define APP_INTERCONN_PATH_TYPE (APP_INTERCONN_PATH_TYPE_BLE | APP_INTERCONN_PATH_TYPE_SPP)
#define APP_INTERCONN_SPP_CONNECTED (1 << 0)
#define APP_INTERCONN_BLE_CONNECTED (1 << 1)
#define APP_INTERCONN_SPP_BLE_BOTH_CONNECTED (APP_INTERCONN_SPP_CONNECTED | APP_INTERCONN_BLE_CONNECTED)
#define APP_INTERCONN_SPP_DISCONNECTED (~(1 << 0))
#define APP_INTERCONN_BLE_DISCONNECTED (~(1 << 1))
#define APP_INTERCONN_SPP_BLE_BOTH_DISCONNECTED (0)
// general used definitions
#define CRC16_LENGTH 2
// data structure related definitions
#define EA_MAX_LENGTH 4
#define EA_HEAD_MASK (0x80)
#define EA_DATA_MASK (~EA_HEAD_MASK)
// EA structrue used in CCMP connection negotiation process
#define EA_HEAD_WITH_EXTENSION (0 << 7)
#define EA_HEAD_WITHOUT_EXTENSION (1 << 7)
#define EA_WITH_EXTENSION(a) (a)
#define EA_WITHOUT_EXTENSION(a) (a + EA_HEAD_WITHOUT_EXTENSION)
// EA structure used after CCMP connection established
#define CCMP_EA_HEAD_WITH_EXTENSION (1 << 7)
#define CCMP_EA_HEAD_WITHOUT_EXTENSION (0 << 7)
#define CCMP_EA_WITH_EXTENSION(a) (a + CCMP_EA_HEAD_WITH_EXTENSION)
#define CCMP_EA_WITHOUT_EXTENSION(a) (a)
// sof value used for ccmp communication negotiation process
#define SOF_VALUE 0x7F
// type value used for ccmp communication negotiation process
#define CCMP_NEGO_TYPE_CHANNEL_MANAGER 0x00
#define CCMP_NEGO_TYPE_INSTANT_MESSAGE 0x02
// flag value used for ccmp communication negotiation process
#define CCMP_NEGO_FLAG_WITHOUT_ENCRYPTION 0x00
#define CCMP_NEGO_FLAG_LENGTH 0x00
// init request&response value used for ccmp communication negotiation process
#define CCMP_INIT_REQUEST_VERSION 0x01
#define CCMP_INIT_RESPONSE_VERSION 0x02
#define CCMP_INIT_VERSION_LENGTH 0x01
#define CCMP_INIT_VERSION_VALUE 0x01
#define CCMP_INIT_REQUEST_SUMMARY 0x03
#define CCMP_INIT_RESPONSE_SUMMARY 0x04
#define CCMP_INIT_REQUEST_SECURITY 0x05
#define CCMP_INIT_RESPONSE_SECURITY 0x06
#define CCMP_INIT_SECURITY_LENGTH 0x01
// bussiness request&response value used for ccmp communication negotiation process
#define CCMP_BUSINESS_REQUEST_COMMAND 0x09
#define CCMP_BUSINESS_RESPONSE_COMMAND 0x0A
#define CCMP_BUSINESS_REQUEST_ICONNECT 0x07
#define CCMP_BUSINESS_RESPONSE_ICONNECT_SUPPORT 0x00
#define CCMP_BUSINESS_RESPONSE_ICONNECT_NOT_SUPPORT 0x01
#define CCMP_BUSINESS_REQUEST_SECURITY 0x02
#define CCMP_BUSINESS_RESPONSE_SECURITY_SUPPORT 0x00
#define CCMP_BUSINESS_RESPONSE_SECURITY_NOT_SUPPORT 0x01
#define CCMP_BUSINESS_REQUEST_DATA_LENGTH 0x02
// BR socket creat request&response value used for ccmp communication negotiation process
#define CCMP_SOCKET_REQUEST_COMMAND 0x03
#define CCMP_SOCKET_RESPONSE_COMMAND 0x04
#define CCMP_SOCKET_CREAT_CHANNEL_BT 0x02
#define CCMP_SOCKET_CREAT_BUSINESS_ICONNECT CCMP_BUSINESS_REQUEST_ICONNECT
#define CCMP_SOCKET_CREAT_BUSINESS_TAG "iconnect"
#define CCMP_SOCKET_CREAT_PROTOCOL_BT 0x00
#define CCMP_SOCKET_CREAT_SERVICE_USE_DEFAULT_UUID 0x00
#define CCMP_SOCKET_RESPONSE_RESULT_ACCEPTED 0x00
#define CCMP_SOCKET_RESPONSE_RESULT_REFUSED 0x01
#define CCMP_SOCKET_RESPONSE_PORT_INVALID 0x00
typedef enum {
INTERCONNECTION_PROCESS_INVALID = 0,
INTERCONNECTION_PROCESS_READ = 1,
INTERCONNECTION_PROCESS_WRITE = 2,
INTERCONNECTION_PROCESS_MAX,
} INTERCONNECTION_PROCESS_E;
typedef struct
{
void * pDev;
uint8_t process;
uint8_t *data;
uint32_t dataLen;
} INTERCONNECTION_MAIL_T;
typedef struct
{
uint8_t type;
uint8_t length;
uint8_t value[1];
} __attribute__((__packed__)) TLV_T;
typedef struct
{
uint8_t flagType;
uint8_t flagLength;
} __attribute__((__packed__)) CCMP_FLAG_T;
typedef struct
{
uint8_t sof;
uint8_t type;
CCMP_FLAG_T flag;
uint8_t length;
uint8_t payload[1];
} __attribute__((__packed__)) CCMP_NEGO_HEAD_T;
#define CCMP_NEGO_PAYLOAD_OFFSET (OFFSETOF(CCMP_NEGO_HEAD_T, payload))
typedef enum
{
INTERCONNECTION_NULL = 0,
INTERCONNECTION_CCMP = 1,
INTERCONNECTION_SPP_CLIENT = 2,
INTERCONNECTION_SPP_SERVER = 3,
INTERCONNECTION_DATA_CHANNEL_NUM,
} INTERCONNECTION_DATA_CHANNEL_E;
#define INTERCONNECTION_DATA_PATH_SPP 0
#define INTERCONNECTION_DATA_PATH_CCMP 1
typedef struct
{
uint8_t isSppClientAlive : 1;
uint8_t isSppServerAlive : 1;
uint8_t isCcmpAlive : 1;
uint8_t isCcmpDeniedByMobile : 1;
uint8_t reserved : 4;
uint8_t ccmpChannel;
osThreadId rxThread;
uint8_t dataPath;
uint8_t currentDataChannel; // see @INTERCONNECTION_DATA_CHANNEL_E
uint8_t interconnectionDiscoverable;
} __attribute__((__packed__)) INTERCONNECTION_ENV_T;
#define INTERCONNECTION_STATUS_INVALID 0
#define INTERCONNECTION_STATUS_SUCCESS 1
#define INTERCONNECTION_STATUS_ERROR 2
bool app_interconnection_is_read_queue_empty(void);
int interconnect_spp_handle_data_event_func(void *pDev, uint8_t process, uint8_t *pData, uint16_t dataLen);
bool app_interconnection_get_spp_client_alive_flag(void);
bool app_interconnection_get_spp_server_alive_flag(void);
void app_interconnection_set_spp_client_alive_flag(bool flag);
void app_interconnection_set_spp_server_alive_flag(bool flag);
bool app_interconnection_get_ccmp_alive_flag(void);
void app_interconnection_set_ccmp_alive_flag(bool flag);
bool app_interconnection_get_ccmp_denied_by_mobile_flag(void);
void app_interconnection_set_ccmp_denied_by_mobile_flag(bool flag);
uint8_t app_interconnection_get_ccmp_channel(void);
void app_interconnection_set_ccmp_channel(uint8_t ccmpChannel);
uint8_t app_interconnection_get_data_path(void);
void app_interconnection_set_data_path(uint8_t dataPath);
uint8_t app_interconnection_get_current_data_channel(void);
void app_interconnection_set_current_data_channel(uint8_t channel);
void app_interconnection_init(void);
void app_interconnection_spp_open(btif_remote_device_t *remote_device);
void app_interconnection_ccmp_client_open(uint32_t param0, uint32_t param1);
void app_interconn_send_done(void);
void app_interconnection_disconnected_callback(void);
void app_set_interconnection_discoverable(uint8_t discoverable);
uint8_t app_get_interconnection_discoverable(void);
#ifdef __cplusplus
}
#endif
#endif // __APP_INTERCONNECTION_H__
#endif // #ifdef __INTERCONNECTION__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection.h
|
C
|
apache-2.0
| 8,051
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __APP_INTERCONNECTION_BLE_H__
#define __APP_INTERCONNECTION_BLE_H__
#ifdef __cplusplus
extern "C"{
#endif
/*****************************header include********************************/
/******************************macro defination*****************************/
#define INTERCONNECTION_BLE_FAST_ADVERTISING_INTERVAL (32) // 20ms (32*0.625ms)
#define INTERCONNECTION_BLE_ADVERTISING_INTERVAL (160) // 100ms (160*0.625ms)
#define APP_INTERCONNECTION_FAST_ADV_TIMEOUT_IN_MS 60000 // 1MIN
#define APP_INTERCONNECTION_SLOW_ADV_TIMEOUT_IN_MS 120000 // 2MIN
#define APP_INTERCONNECTION_DISAPPEAR_ADV_IN_MS 5000 // 5sec
#define INTERCONNECTION_DISCOVERABLE_YES (0)
#define INTERCONNECTION_DISCOVERABLE_NOT (1)
#define CUSTOMIZED_ADV_TYPE (0x16)
#define UUID_LEN (2)
#define UUID_VALUE "\xee\xfd"
#define MODEL_ID "\x00\x00\x01"
#define MODEL_ID_LEN (3)
// for debug
#define SUB_MODEL_ID (0x01)
// data length before extersible data is 15 byte according to spec from huawei
// data structure is defined as CUSTOMIZED_ADV_DATA_T
#define FIXED_CUSTOMIZED_ADV_DATA_LEN (15)
#define EXTENSIBLE_DATA_MAX_LEN (ADV_DATA_MAX_LEN-FIXED_CUSTOMIZED_ADV_DATA_LEN)
// 2 byte to describe paired device
#define PAIRED_DEVICE_ID_LEN (2)
// 2 byte to describe dual model device
#define DUAL_MODEL_DEVICE_ID_LEN (2)
// max length of per extensible service is 3 byte
#define EXTENSIBLE_SERVICE_MAX_LEN (3)
/******************************type defination******************************/
typedef enum
{
SERVICE_ID_NEARBY = 0x01,
SERVICE_ID_ICONNECT = 0x01,
SERVICE_ID_RSSI_REFERENCE_VALUE = 0x02,
SERVICE_ID_MODEL_ID = 0x03,
SERVICE_ID_SUB_MODEL_ID = 0x04,
SERVICE_ID_PAIRED_DEVICE_ID = 0x05,
SERVICE_ID_CONNECTED_DEVICE_NUM = 0x06,
SERVICE_ID_PAIRED_DEVICE_NUM = 0x07,
SERVICE_ID_MAX_CONNECT_DEVICE_NUM = 0x08,
SERVICE_ID_MAX_PAIR_DEVICE_NUM = 0x09,
SERVICE_ID_DUAL_MODE_DEVICE_IDENTIFICATION = 0x0a,
SERVICE_ID_TOTAL_BATTERY = 0x0b,
SERVICE_ID_LEFT_EAR_BATTERY = 0x0c,
SERVICE_ID_RIGHT_EAR_BATTERY = 0x0d,
SERVICE_ID_CHARGER_BOX_BATTERY = 0x0e,
} NEARBY_SERIVCE_ID_E;
typedef enum
{
RECONNECTABLE_NOT_DISCOVERABLE_NOT = 0x00,
RECONNECTABLE_NOT_DISCOVERABLE_YES = 0x01,
RECONNECTABLE_YES_DISCOVERABLE_NOT = 0x02,
RECONNECTABLE_YES_DISCOVERABLE_YES = 0X03,
}ICONNECT_STATUS_E;
typedef struct
{
uint8_t advLength; // 1 byte
uint8_t advType; // 1 byte
uint8_t uuidValue[UUID_LEN]; // 2 byte
NEARBY_SERIVCE_ID_E nearbyServiceID; // 1 byte
NEARBY_SERIVCE_ID_E iconnectServiceID; // 1 byte
ICONNECT_STATUS_E iconnectStatus; // 1 byte
NEARBY_SERIVCE_ID_E rssiReferenceValueServiceID; // 1 byte
int8_t rssiReferenceValue; // 1 byte
NEARBY_SERIVCE_ID_E modelIDServiceID; // 1 byte
uint8_t modelID[MODEL_ID_LEN]; // 3 byte
NEARBY_SERIVCE_ID_E subModelServiceID; // 1 byte
uint8_t subModelID; // 1 byte
// total length of data above is 15 byte
}__attribute__((__packed__)) CUSTOMIZED_ADV_DATA_HEAD_T;
typedef struct
{
uint8_t isCharging : 1;
uint8_t batteryLevel : 7;
}BATTERY_INFO_T;
/****************************function declearation**************************/
void clear_discoverable_adv_timeout_flag(void);
void app_interconnection_start_disappear_adv(uint32_t advInterval, uint32_t advDuration);
void app_interceonnection_start_discoverable_adv(uint32_t advInterval, uint32_t advDuration);
void app_interconnection_ble_data_fill_handler(void* param);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef __APP_INTERCONNECTION_BLE_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_ble.h
|
C
|
apache-2.0
| 5,102
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONNECTION_CCMP_DEFINE_H__
#define __APP_INTERCONNECTION_CCMP_DEFINE_H__
#ifdef __cplusplus
extern "C"{
#endif
#include "bluetooth.h"
#define CCMP_RECV_BUFFER_SIZE (4096+100)
struct spp_device *app_interconnection_get_ccmp_dev();
void app_interconnection_send_data_via_ccmp(uint8_t *ptrData, uint32_t length);
void app_ccmp_client_open(uint8_t *pServiceSearchRequest, uint8_t serviceSearchRequestLen, uint8_t port);
void app_interconnection_ccmp_disconnected_callback();
#ifdef __cplusplus
}
#endif
#endif // #ifndef __APP_INTERCONNECTION_CCMP_DEFINE_H__
#endif // #ifdef __INTERCONNECTION__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_ccmp.h
|
C
|
apache-2.0
| 1,320
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONNECTION_CUSTOMER_REALIZE_H__
#define __APP_INTERCONNECTION_CUSTOMER_REALIZE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "app_interconnection.h"
// #define H2_FOR_TEST 1
#define BT_VERSION "NA"
#define DEVICE_HARDWARE_VERSION "\x00\x00\x00\x00\x00\x00\x00\x00"
#define PHONE_NUMBER "NA"
#define DEVICE_BT_MAC "NA"
#define DEVICE_IMEI "NA"
#define SOFTWARE_VERSION "1.0.1.223"
#define DEVICE_OPEN_SOURCE_VERSION "NA"
#define DEVICE_SN "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
#ifdef H2_FOR_TEST
#define DEVICE_MODEL_ID "BTFCMH2S-000016"
#define DEVICE_NAME "CM-H2S"
#else
#define DEVICE_MODEL_ID "BTFCM70-00001B"
#define DEVICE_NAME "CM-70"
#endif
#define DEVICE_EMMC "NA"
#define CCMP_SUMMARY_VALUE "\xe5\xef\xcb\x85\xeb\x43\x77\xa5\x18\x09\x0e\x9d\xcd\x77\xb9\xbf\xb4\x3e\xa0\xeb\xf4\xb8\x6a\x81\x1f\xd9\x46\x2a\x34\x92\x68\x12"
#define BUSINESS_TAG "iconnect"
#define FIXED_IMAGE_INFO_HEADER 0x5A5A
#define OTA_COMPONENT_ID_HEAD_SET 1
#define FORCE_UPGRADE 1
#define OTA_FLASH_SIZE 0x180000 // 1.5M flash
typedef struct
{
uint8_t serviceID;
uint8_t support;
} __attribute__((__packed__)) SUPPORT_SERVICE_T;
#ifdef H2_FOR_TEST
// used for h2
typedef struct
{
uint16_t h_header;
uint16_t h_head_lens;
uint8_t h_upgrade_mode;
uint8_t h_image_version[19];
uint8_t h_headset_firmware_flag;
uint32_t h_headset_addr_offset;
uint32_t h_headset_data_lens;
uint8_t h_headset_version[19];
uint8_t h_headset_figure_signature[256];
uint32_t h_headset_crc;
uint8_t h_hinttone_firmware_flag;
uint32_t h_hinttone_addr_offset;
uint32_t h_hinttone_data_lens;
uint8_t h_hinttone_version[19];
uint8_t h_hinttone_figure_signature[256];
uint32_t h_hinttone_crc;
uint8_t h_charger_firmware_flag;
uint32_t h_charger_addr_offset;
uint32_t h_charger_data_lens;
uint8_t h_charger_version[19];
uint8_t h_charger_figure_signature[256];
uint32_t h_charger_crc;
uint32_t h_data_crc;
} __attribute__ ((__packed__)) REC_HEAD_PACKET_T;
#else
// used for amazon
typedef struct
{
uint16_t h_header;
uint16_t h_head_lens;
uint8_t h_upgrade_mode;
uint8_t h_image_version[19];
uint8_t h_headset_firmware_flag;
uint32_t h_headset_addr_offset;
uint32_t h_headset_data_lens;
uint8_t h_headset_version[19];
uint8_t h_headset_figure_signature[256];
uint32_t h_headset_crc;
uint32_t h_data_crc;
} __attribute__ ((__packed__)) REC_HEAD_PACKET_T;
#endif
#define IMAGE_INFO_SIZE sizeof(REC_HEAD_PACKET_T)
uint32_t crc32_image(uint32_t crc_val, uint8_t *input, uint32_t len);
uint8_t *get_link_param_protocol_version(void);
bool is_service_support(uint8_t serviceID);
char *get_bt_version_ptr(void);
uint8_t *get_device_type_ptr(void);
char *get_hardware_version_ptr(void);
char *get_phone_number_ptr(void);
char *get_device_bt_mac_ptr(void);
char *get_device_imei_ptr(void);
char *get_software_version_ptr(void);
char *get_open_source_version_ptr(void);
char *get_sn_ptr(void);
char *get_model_id_ptr(void);
char *get_device_emmc_ptr(void);
char *get_device_name_ptr(void);
char *get_summary_value_ptr(void);
char *get_business_tag_ptr(void);
uint32_t get_update_permission_error_code(void);
uint8_t customer_realize_image_info_receive_finished_hook();
#ifdef __cplusplus
}
#endif
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_customer_realize.h
|
C
|
apache-2.0
| 4,360
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONNECTION_LOGIC_PROTOCOL_H__
#define __APP_INTERCONNECTION_LOGIC_PROTOCOL_H__
#ifdef __cplusplus
extern "C" {
#endif
#define MTU_MAX_LENGTH (521)
#define SERVICE_ID_LENGTH (1)
#define COMMAND_ID_LENGTH (1)
#define CCMP_GENERAL_USED_ERROR_CODE_TYPE (127)
#define CCMP_GENERAL_USED_ERROR_CODE_NO_ERROR (0)
#define CCMP_GENERAL_USED_ERROR_CODE_LEN (4)
typedef union
{
uint32_t f;
char c[4];
}UINT32_CONV_U;
typedef union
{
uint16_t f;
char c[2];
}UINT16_CONV_U;
// sof value used for ccmp communication
#define CCMP_SOF_VALUE 0x5A
#define CCMP_CONTROL 0x00
#define CCMP_ERR_HEAD_BASE (100000)
#define CCMP_ERR_HEAD (1)
#define CCMP_ERR_MODULE_BASE (1000)
typedef enum
{
CCMP_MODULE_GENERAL = 0,
CCMP_MODULE_DEVICE_MANAGEMENT = 1,
CCMP_MODULE_NOTIFICATION = 2,
CCMP_MODULE_MUSIC = 6,
CCMP_MODULE_OTA = 9,
CCMP_MODULE_MUSIC_MANAGEMENT = 17,
CCMP_MODULE_BT_TEST = 19,
CCMP_MODULE_MCU_TEST = 20,
CCMP_MODULE_MIDWARE_SERVICE = 33,
} CCMP_MODULE_E;
/**
* @brief
*
* error code----start
*
*/
// general used error code
typedef enum
{
CCMP_GEN_ERR_CODE_SUCCESS = 0,
CCMP_GEN_ERR_CODE_UNKNOWN = 1,
CCMP_GEN_ERR_CODE_SERVICE_UNSUPPORTED = 2,
CCMP_GEN_ERR_CODE_COMMAND_UNSUPPORTED = 3,
CCMP_GEN_ERR_CODE_AUTHORITY_LIMITED = 4,
CCMP_GEN_ERR_CODE_SYS_BUSY = 5,
CCMP_GEN_ERR_CODE_REQUEST_FORMAT_ERROR = 6,
CCMP_GEN_ERR_CODE_PARAM_ERROR = 7,
CCMP_GEN_ERR_CODE_MALLOC_FAIL = 8,
CCMP_GEN_ERR_CODE_RESPONSE_TIMEOUT = 9,
CCMP_GEN_ERR_CODE_NOT_ENCRYPTED = 10,
CCMP_GEN_ERR_CODE_DECRYPTION_FORMAT_ERROR = 11,
CCMP_GEN_ERR_CODE_ILLEGAL_ECRYPTED_PACKET_INDEX = 12,
CCMP_GEN_ERR_CODE_ENCRYPTED_DATA_DAMAGED = 13,
CCMP_GEN_ERR_CODE_DATA_LOST = 14,
} CCMP_GEN_ERR_CODE_E;
// device management error code
typedef enum
{
CCMP_DEV_ERR_CODE_ILLEGAL_PARAM = 1,
CCMP_DEV_ERR_CODE_LOW_POWER = 2,
CCMP_DEV_ERR_CODE_DEVICE_UNAVAILABLE = 3,
} CCMP_DEV_ERR_CODE_E;
// notification error code
typedef enum
{
CCMP_NOTI_ERR_CODE_ILLEGAL_PAPAM = 1,
} CCMP_NOTI_ERR_CODE_E;
// OTA error code
typedef enum
{
CCMP_OTA_ERR_CODE_ILLEGAL_PARM = 1,
CCMP_OTA_ERR_CODE_LOW_BATTERY = 2,
CCMP_OTA_ERR_CODE_FIRMWARE_ABNORMAL = 3,
CCMP_OTA_ERR_CODE_FLASH_PROCESS_FAILURE = 4,
CCMP_OTA_ERR_CODE_UPDATE_DENIED = 5,
CCMP_OTA_ERR_CODE_FILE_TRANSFER_FAILURE = 6,
CCMP_OTA_ERR_CODE_BT_DOWNLOAD_FAILURE = 7,
CCMP_OTA_ERR_CODE_BT_UPDATE_FAILURE = 8,
CCMP_OTA_ERR_CODE_DATA_WRITE_FAILURE = 9,
CCMP_OTA_ERR_CODE_DATA_VERIFY_FAILURE = 10,
CCMP_OTA_ERR_CODE_UPDATE_PACKET_ABNORMAL = 11,
} CCMP_OTA_ERR_CODE_E;
// music error code
typedef enum
{
CCMP_MUSIC_ERR_CODE_ILLEGAL_PARAM = 1,
} CCMP_MUSIC_ERR_CODE_E;
// BT factory test error code
typedef enum
{
CCMP_BT_TEST_ERR_CODE_ILLEGAL_PARAM = 1,
} CCMP_BT_TEST_ERR_CODE_E;
// MCU factory test error code
typedef enum
{
CCMP_FACTORY_TEST_ERR_CODE_ILLEGAL_PARAM = 1,
} CCMP_FACTORY_TEST_ERR_CODE_E;
// midware service error code
typedef enum
{
CCMP_MIDWARE_ERR_CODE_NO_HUAWEI_MUSIC = 1,
CCMP_MIDWARE_ERR_CODE_USER_NOT_SIGNED = 2,
CCMP_MIDWARE_ERR_CODE_NO_NETWORK = 3,
CCMP_MIDWARE_ERR_CODE_ADD_FAILURE = 4,
CCMP_MIDWARE_ERR_CODE_NO_MUSIC = 5,
CCMP_MIDWARE_ERR_CODE_PLAYING_FAVORITE = 6,
CCMP_MIDWARE_ERR_CODE_PLAYING_FAILURE = 7,
} CCMP_MIDWARE_ERR_CODE_E;
/**
* @brief
*
* error code----end
*
*/
typedef enum
{
CCMP_GENERAL_COMMAND_ID_CONNECT_CCMP = 1,
} CCMP_GENERAL_COMMAND_ID_E;
// command id of service device management
typedef enum
{
CCMP_DEVICE_COMMAND_ID_LINK_PARAM = 1,
CCMP_DEVICE_COMMAND_ID_SERVICE_ABILITY = 2,
CCMP_DEVICE_COMMAND_ID_COMMAND_ABILITY = 3,
CCMP_DEVICE_COMMAND_ID_TIME_FORMAT = 4,
CCMP_DEVICE_COMMAND_ID_SET_DEVICE_TIME = 5,
CCMP_DEVICE_COMMAND_ID_GET_DEVICE_TIME = 6,
CCMP_DEVICE_COMMAND_ID_DEVICE_INFO = 7,
CCMP_DEVICE_COMMAND_ID_GET_MOBILE_BATT = 8,
} CCMP_DEVICE_COMMAND_ID_E;
// type id used for command CCMP_DEVICE_COMMAND_ID_LINK_PARAM
typedef enum
{
TYPE_PROTOCOL_VERSION = 1,
TYPE_MAX_FRAME_SIZE = 2,
TYPE_MAX_TRANSIMISSION_UNIT = 3,
TYPE_LINK_INTERVAL = 4,
TYPE_RANDOM_VALUE = 5,
} LINK_PARAM_TYPE_E;
// type id used for command CCMP_DEVICE_COMMAND_ID_SERVICE_ABILITY
typedef enum
{
TYPE_SUPPORT_SERVICE_REQUEST = 1,
TYPE_SUPPORT_SERVICE_RESPONSE = 2,
} SERVICE_ABILITY_SUPPORT_TYPE_E;
// type id used for command CCMP_DEVICE_COMMAND_ID_DEVICE_INFO
typedef enum
{
TYPE_BT_VERSION = 1,
TYPE_DEVICE_TYPE = 2,
TYPE_DEVICE_VERSION = 3,
TYPE_DEVICE_PHONE_NUMBER = 4,
TYPE_DEVICE_BT_MAC = 5,
TYPE_DEVICE_IMEI = 6,
TYPE_DEVICE_SOFTWARE_VERSION = 7,
TYPE_DEVICE_OPEN_SOURCE_VERSION = 8,
TYPE_DEVICE_SN = 9,
TYPE_DEVICE_MODEL_ID = 10,
TYPE_DEVICE_EMMC_ID = 11,
TYPE_DEVICE_NAME = 12,
TYPE_DEVICE_SUPPORT_HEALTH_APP = 13,
TYPE_DEVICE_ID_TO_SERVER_TYPE = 14,
} DEVICE_INFO_TYPE_E;
// command id of service midware
typedef enum
{
CCMP_MIDWARE_COMMAND_ID_HUAWEI_MUSIC = 3,
} CCMP_MIDWARE_COMMAND_ID_E;
// type id used for command CCMP_MIDWARE_COMMAND_ID_HUAWEI_MUSIC
typedef enum
{
TYPE_FAVORITE_INFO = 1,
}HUAWEI_MUSIC_TYPE_E;
// event id used for type TYPE_FAVORITE_INFO
typedef enum
{
HUAWEI_MUSIC_RESPONSE_ADD_FAVORITE = 1,
HUAWEI_MUSIC_RESPONSE_PLAY_FAVORITE = 2,
} HUAWEI_MUSIC_RESPONSE_E;
// command id of service ota
typedef enum
{
CCMP_OTA_COMMAND_ID_UPDATE_PERMISSION = 1,
CCMP_OTA_COMMAND_ID_PARAM_NEGOTIATION = 2,
CCMP_OTA_COMMAND_ID_DEVICE_REPORT = 3,
CCMP_OTA_COMMAND_ID_FIRMWARE_DATA = 4,
CCMP_OTA_COMMAND_ID_PACKAGE_SIZE = 5,
CCMP_OTA_COMMAND_ID_PACKAGE_VALIDITY = 6,
CCMP_OTA_COMMAND_ID_UPDATE_STATUS_REPORT = 7,
CCMP_OTA_COMMAND_ID_UPDATE_CANCEL = 8,
CCMP_OTA_COMMAND_ID_UPDATE_STATUS_NOTIFY = 9,
CCMP_OTA_COMMAND_ID_UPDATE_REQUEST = 10,
} CCMP_OTA_COMMAND_ID_E;
// type id for command CCMP_OTA_COMMAND_ID_UPDATE_PERMISSION
typedef enum
{
TYPE_PACKET_VERSION = 1,
TYPE_COMPONENT_SIZE = 2,
TYPE_OTA_WORK_MODE = 3,
TYPE_BATTERY_THRESHOLD = 4,
} UPDATE_PERMISSION_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_PARAM_NEGOTIATION
typedef enum
{
TYPE_APP_WAIT_TIMEOUT = 1,
TYPE_RESTART_TIMEOUT = 2,
TYPE_OTA_UNIT_SIZE = 3,
TYPE_INTERVAL = 4,
TYPE_ACK_ENABLE = 5,
} PARAM_NEGOTIATION_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_DEVICE_REPORT
typedef enum
{
TYPE_FILE_OFFSET = 1,
TYPE_FILE_LENGTH = 2,
TYPE_FILE_BITMAP = 3,
} DEVICE_REPORT_TYPE_E;
#define FILE_OFFSET_LENGTH 4
#define FILE_LENGTH 4
#define FILE_BITMAP_LENGTH 1
// type id for command CCMP_OTA_COMMAND_ID_PACKAGE_SIZE
typedef enum
{
TYPE_VALID_SIZE = 1,
TYPE_FILE_SIZE = 2,
} PACKAGE_SIZE_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_PACKAGE_VALIDITY
typedef enum
{
PACKAGE_VALIDITY = 1,
} PACKAGE_VALIDITY_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_UPDATE_STATUS_REPORT
typedef enum
{
UPDATE_STATUS_REPORT = 1,
} UPDATE_STATUS_REPORT_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_UPDATE_CANCEL
typedef enum
{
UPDATE_CANCEL = 1,
} UPDATE_CANCEL_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_UPDATE_STATUS_NOTIFY
typedef enum
{
UPDATE_STATUS_NOTIFY = 1,
} UPDATE_STATUS_NOTIFY_TYPE_E;
// type id for command CCMP_OTA_COMMAND_ID_UPDATE_REQUEST
typedef enum
{
UPDATE_REQUEST = 1,
} UPDATE_REQUEST_TYPE_E;
typedef enum
{
UPDATE_PARAM_RECEIVE_FAIL = 0,
UPDATE_PARAM_RECEIVE_SUCCESS = 1,
} UPDATE_PARAM_RECEIVE_STATUS_E;
typedef struct
{
uint8_t sof;
uint16_t length;
uint8_t ccmpControl;
uint8_t serviceID;
uint8_t commandID;
uint8_t item[1];
}__attribute__((__packed__))CCMP_COMMUNICATION_HEAD_T;
#define CCMP_PAYLOAD_OFFSET (OFFSETOF(CCMP_COMMUNICATION_HEAD_T, ccmpControl))
#define CCMP_ITEM_OFFSET (OFFSETOF(CCMP_COMMUNICATION_HEAD_T, item))
uint32_t uint32_convert_endian(uint32_t data);
uint16_t uint16_convert_endian(uint16_t data);
uint8_t app_interconnection_ccmp_creat_error_code(uint8_t module, uint8_t errType, uint32_t* dataPtr);
void app_interconnection_spp_client_send_ccmp_init_command();
void app_interconnection_package_size_report_handler(uint32_t packageSize, uint32_t receivedSize);
void app_interconnection_ota_package_validity_response(bool validity);
void ota_update_request(void);
void app_interconnection_ota_apply_update_data(uint32_t fileOffset, uint8_t fileBitmap, uint32_t fileLength);
uint8_t app_interconnection_spp_client_data_received_callback(uint8_t* ptrData, uint32_t dataLength);
void app_interconnection_handle_favorite_music_through_ccmp(uint8_t process);
uint8_t app_interconnection_mbb_data_received_callback(uint8_t* ptrData, uint16_t dataLength);
void app_interconnection_ccmp_negotiation_data_send(uint8_t *param, uint16_t paramLen);
void app_interconnection_ccmp_data_send(uint8_t *param, uint8_t paramLen);
void app_interconnection_spp_server_data_send(uint8_t *param, uint16_t paramLen);
void app_interconnection_response_error_code(uint8_t module, uint8_t err, uint8_t serviceId, uint8_t commandId);
#ifdef __cplusplus
}
#endif
#endif // #ifndef __APP_INTERCONNECTION_LOGIC_PROTOCOL_H__
#endif // #ifdef __INTERCONNECTION__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_logic_protocol.h
|
C
|
apache-2.0
| 10,460
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONN_OTA_H__
#define __APP_INTERCONN_OTA_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "stdint.h"
#define APP_WAIT_TIMEOUT 60//second
#define DEVICE_RESTART_TIMEOUT 60
#define OTA_UNIT_SIZE_SPP 512
#define OTA_UNIT_SIZE_BLE 256
#define INTERVAL 10//ms
#define ACK_ENABLE
#define FLASH_SECTOR_SIZE_IN_BYTES 4096
#define OTA_DATA_BUFFER_SIZE_FOR_BURNING FLASH_SECTOR_SIZE_IN_BYTES
#define OTA_START_MAGIC_CODE (0x54534542) // BEST
#define NORMAL_BOOT 0xBE57EC1C
#define COPY_NEW_IMAGE 0x5a5a5a5a
#ifndef DATA_ACK_FOR_SPP_DATAPATH_ENABLED
#define DATA_ACK_FOR_SPP_DATAPATH_ENABLED 0
#endif
#ifndef NEW_IMAGE_FLASH_OFFSET
#define NEW_IMAGE_FLASH_OFFSET (0x200000)
#endif
#ifndef __APP_IMAGE_FLASH_OFFSET__
#define __APP_IMAGE_FLASH_OFFSET__ (0x18000)
#endif
#define OTA_FLASH_LOGIC_ADDR (FLASH_NC_BASE)
#define OTA_FLASH_OFFSET_OF_IMAGE __APP_IMAGE_FLASH_OFFSET__
#define OTA_FLASH_ENTRY_OFFSET (OTA_FLASH_LOGIC_ADDR + OTA_FLASH_OFFSET_OF_IMAGE)
#define BD_ADDR_LENGTH 6
#define NAME_LENGTH 32
#define OTA_BLE_DATA_PACKET_MAX_SIZE 257
#define OTA_BT_DATA_PACKET_MAX_SIZE 513
#define OTA_BOOT_INFO_FLASH_OFFSET 0x1000
// #define otaUpgradeLogInFlash (*(FLASH_OTA_UPGRADE_LOG_FLASH_T *)(OTA_FLASH_LOGIC_ADDR+0x3000))
// #define otaUpgradeLog otaUpgradeLogInFlash
/**
* @brief The format of the otaBootInfo
*
*/
typedef struct
{
uint32_t magicNumber;
uint32_t imageSize;
uint32_t imageCrc;
}__attribute__ ((__packed__)) FLASH_OTA_BOOT_INFO_T;
// typedef struct
// {
// uint8_t version_md5[32];
// uint32_t upgradeSize[(FLASH_SECTOR_SIZE_IN_BYTES - 32) / 4];
// }__attribute__ ((__packed__)) FLASH_OTA_UPGRADE_LOG_FLASH_T;
// typedef struct
// {
// uint8_t version_md5[32];
// }__attribute__ ((__packed__)) OTA_RESUME_VERIFY_T;
// typedef struct
// {
// bool breakpoint_flag;
// uint32_t offset;
// }__attribute__ ((__packed__)) OTA_RESUME_VERIFY_RESPONSE_T;
typedef struct
{
uint8_t* dataBufferForBurning; // temp buffer pointer for image data wite into flash
uint8_t* imageInfoPtr; // pointer for image information
uint32_t dstFlashOffsetForNewImage;
uint32_t offsetInDataBufferForBurning;
uint32_t offsetInFlashToProgram;
uint32_t totalImageSize; // image size to apply
uint32_t imageRequestTime;
uint32_t imageLastRequestSize;
uint8_t imageLastRequestBitmapMask;
uint32_t alreadyReceivedDataSizeOfImage;
uint32_t addressOfStartApplyImage; // start applied data offset of the whole image
uint32_t offsetInFlashOfCurrentSegment;
uint32_t offsetOfImageOfCurrentSegment;
uint32_t crcOfImage;
uint32_t crcOfSegment;
uint32_t flasehOffsetOfUserDataPool;
uint32_t flasehOffsetOfFactoryDataPool;
uint32_t startLocationToWriteImage;
uint32_t endLocationToWriteImage;
uint8_t isOTAInProgress;
uint8_t isPendingForReboot;
uint16_t dataPacketSize;
bool isUpdateNecessary;
bool resume_at_breakpoint;
uint32_t breakPoint;
uint32_t i_log;
uint8_t otaWorkMode;
uint8_t componentSize;
uint8_t batteryThreshold;
uint16_t appWaitTimeout;
uint16_t deviceRestartTimeout;
uint16_t otaUnitSize;
uint16_t packetInterval;
uint8_t ackEnable;
uint8_t bitmap;
bool isImageInfoReceived;
uint32_t receivedImageInfoLength;
bool isLastPacketReceived;
uint8_t packetNum;
bool isAskAgain;
uint8_t askAgainPacketNum;
uint8_t askAgainPacketTotal;
uint8_t updateDataChannel;
uint8_t shaOfImg[32];
} __attribute__((__packed__)) INTERCONN_OTA_ENV_T;
#define PACKETCRC_RESULT_TYPE 0x01
#define PACKETCRC_RESULT_LENGHT 0x01
typedef struct
{
uint16_t funcCode;
uint8_t result_type;
uint8_t result_length;
uint8_t result_value;
}__attribute__ ((__packed__)) ota_packetCRC_report_t;
#define IMAGE_RECV_FLASH_CHECK 1 // It's best to turn it on durning development and not a big deal off in the release.
#define MAX_IMAGE_SIZE ((uint32_t)(NEW_IMAGE_FLASH_OFFSET - __APP_IMAGE_FLASH_OFFSET__))
#define MIN_SEG_ALIGN 256
void app_interconnection_ota_set_update_flag(bool flag);
bool app_interconnection_ota_get_update_flag(void);
uint8_t app_interconnection_ota_get_battery_threshold(void);
uint32_t app_interconnection_ota_get_file_offset();
void app_interconnection_ota_set_ota_in_progress(uint8_t value);
uint8_t app_interconnection_ota_get_file_bitmap();
bool app_interconnection_ota_is_image_info_received(void);
void app_interconnection_ota_image_info_received_handler(uint8_t *ptrParam, uint32_t paramLen);
void app_interconnection_ota_fw_data_received_handler(uint8_t* ptrData, uint32_t DataLength, bool pass);
void app_interconn_ota_handler_init(void);
void app_interconnection_ota_finished_handler(void);
uint8_t app_interconn_get_ota_status();
void app_interconnection_ota_firmware_verify_handler(void);
void ota_segmemt_verify_handler(uint8_t* ptrParam, uint32_t paramLen);
INTERCONN_OTA_ENV_T *app_interconnection_ota_get_env_ptr();
uint8_t app_interconnection_ota_get_update_data_channel(void);
void app_interconnection_ota_set_update_data_channel(uint8_t channel);
#ifdef __cplusplus
}
#endif
#endif // __APP_TENCENT_OTA_H__
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_ota.h
|
C
|
apache-2.0
| 6,450
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONNECTION_SPP_H__
#define __APP_INTERCONNECTION_SPP_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "bluetooth.h"
#define SPP_RECV_BUFFER_SIZE 3072
uint8_t* app_interconnection_ea_parse_data(uint8_t* sourceDataPtr, uint32_t* eaDataPtr);
uint16_t app_interconnection_spp_data_calculate_crc16(uint8_t *buf, uint32_t len);
struct spp_device *app_interconnection_get_spp_client();
struct spp_device *app_interconnection_get_spp_server();
typedef void(*app_spp_tx_done_t)(void);
void red_spp_register_tx_done(app_spp_tx_done_t callback);
void app_spp_client_open(uint8_t* pServiceSearchRequest, uint8_t serviceSearchRequestLen);
void app_spp_client_close(void);
void app_spp_client_close(void);
void app_spp_client_init_variable(void);
bt_status_t app_interconnection_spp_client_read_data(char * buffer, uint16_t* ptrLen);
bt_status_t app_interconnection_spp_server_read_data(char * buffer, uint16_t* ptrLen);
void app_interconnection_send_data_via_spp(uint8_t* ptrData, uint16_t length, uint8_t port);
void app_interconnection_spp_client_disconnected_callback(void);
void app_interconnection_spp_server_disconnected_callback(void);
void app_spp_client_init_variable(void);
void app_spp_server_init(void);
void app_spp_server_close(void);
void app_spp_server_init_variable(void);
void app_ibrt_spp_client_open();
#ifdef __cplusplus
}
#endif
#endif // #ifndef __APP_INTERCONNECTION_SPP_H__
#endif // #ifdef __INTERCONNECTION__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_spp.h
|
C
|
apache-2.0
| 2,170
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __INTERCONNECTION__
#ifndef __APP_INTERCONNECTION_TLV_H__
#define __APP_INTERCONNECTION_TLV_H__
#ifdef __cplusplus
extern "C" {
#endif
#define CCMP_CHILD_MASK 0x80
#define CCMP_BIGLEN_MASK 0x80
typedef struct _TlvItem
{
uint8_t type; // bit7= 1,with subtype ; bit7=0, no subtype type value: bit6~bit0 ; general error = 127
uint16_t length;
uint8_t *value;
struct _TlvItem *brotherNode;
struct _TlvItem *childNode;
struct _TlvItem *parentNode;
}TLV_ITEM_T;
void app_interconnection_tlv_get_big_endian_u16_from_item(TLV_ITEM_T* item, uint16_t* dataPtr);
void app_interconnection_tlv_get_big_endian_u32_from_item(TLV_ITEM_T* item, uint32_t* dataPtr);
uint32_t app_interconnection_tlv_item_get_length_size(uint32_t len);
void app_interconnection_tlv_item_print(uint32_t spaceNumber, TLV_ITEM_T *item);
TLV_ITEM_T *app_interconnection_tlv_item_tree_malloc(uint8_t *buf, uint32_t len);
TLV_ITEM_T *app_interconnection_tlv_item_tree_malloc_long_msg(uint8_t *buf, uint32_t len);
void app_interconnection_tlv_item_tree_free(TLV_ITEM_T *tree);
TLV_ITEM_T *app_interconnection_creat_new_tlv_item(uint8_t type,uint32_t len,uint8_t *value);
void free_tlv_item(TLV_ITEM_T *item);
void tlv_item_add_child(TLV_ITEM_T *parent, TLV_ITEM_T *child);
void tlv_item_add_brother(TLV_ITEM_T *brother, TLV_ITEM_T *me);
TLV_ITEM_T *app_interconnection_tlv_get_item_with_type(TLV_ITEM_T *root, uint8_t type);
TLV_ITEM_T* app_interconnection_tlv_get_brother_node(TLV_ITEM_T *root);
TLV_ITEM_T* app_interconnection_tlv_get_child_node(TLV_ITEM_T *root);
uint8_t app_interconnection_tlv_get_item_type(TLV_ITEM_T *item);
uint8_t* app_interconnection_tlv_get_item_value(TLV_ITEM_T *item,uint32_t *length);
uint32_t app_interconnection_tlv_get_item_tree_length(TLV_ITEM_T* root);
uint8_t* app_interconnection_tlv_malloc_for_item(TLV_ITEM_T *item,uint32_t *length);
uint8_t* app_interconnection_tlv_malloc_for_item_tree_with_margin(TLV_ITEM_T *item, uint8_t head, uint8_t tail, uint32_t *length);
#ifdef __cplusplus
}
#endif
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/interconnection/red/app_interconnection_tlv.h
|
C
|
apache-2.0
| 2,823
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __AQE_KWS_H__
#define __AQE_KWS_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int32_t bypass;
} AqeKwsConfig;
struct AqeKwsState_;
typedef struct AqeKwsState_ AqeKwsState;
AqeKwsState *aqe_kws_create(uint32_t sample_rate, uint32_t frame_size, AqeKwsConfig *cfg);
int32_t aqe_kws_destroy(AqeKwsState *st);
int32_t aqe_kws_process(AqeKwsState *st, int16_t *pcm_in, uint32_t pcm_len, int16_t *thres_buf);
float aqe_kws_get_required_mips(AqeKwsState *st);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/multimedia/speech/inc/aqe_kws.h
|
C
|
apache-2.0
| 1,181
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SPEECH_MEMORY_H__
#define __SPEECH_MEMORY_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef VQE_SIMULATE
#include "med_memory.h"
#define speech_heap_init(a, b) med_heap_init(a, b)
#define speech_heap_add_block(a, b) med_heap_add_block(a, b)
#define speech_malloc(a) med_malloc(a)
#define speech_realloc(a, b) med_realloc(a, b)
#define speech_calloc(a, b) med_calloc(a, b)
#define speech_free(a) med_free(a)
#define speech_memory_info(a, b, c) med_memory_info(a, b, c)
#define speech_heap_set_cp(a) med_heap_set_cp(a)
#else
#include <stddef.h>
#include <stdlib.h>
void speech_heap_init(void *begin_addr, size_t size);
void *speech_malloc(size_t size);
void speech_free(void *p);
void *speech_calloc(size_t nmemb, size_t size);
void *speech_realloc(void *ptr, size_t size);
void speech_memory_info(size_t *total,
size_t *used,
size_t *max_used);
#define speech_heap_set_cp(a)
#endif
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/multimedia/speech/inc/speech_memory.h
|
C
|
apache-2.0
| 1,693
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _NORFLASH_ASYNC_API_H_
#define _NORFLASH_ASYNC_API_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "hal_norflash.h"
#define FLASH_SECTOR_SIZE 4096
enum NORFLASH_API_MODULE_ID_T
{
NORFLASH_API_MODULE_ID_TRACE_DUMP,
NORFLASH_API_MODULE_ID_USERDATA,
NORFLASH_API_MODULE_ID_OTA,
NORFLASH_API_MODULE_ID_OTA_UPGRADE_LOG,
NORFLASH_API_MODULE_ID_FREE,
NORFLASH_API_MODULE_ID_CRASH_DUMP,
NORFLASH_API_MODULE_ID_COREDUMP,
NORFLASH_API_MODULE_ID_FACTORY,
NORFLASH_API_MODULE_ID_GSOUND_OTA,
NORFLASH_API_MODULE_ID_USERDATA_EXT,
NORFLASH_API_MODULE_ID_INTERACTION_OTA,
NORFLASH_API_MODULE_ID_GMA_OTA,
NORFLASH_API_MODULE_ID_COUNT,
};
enum NORFLASH_API_RET_T
{
NORFLASH_API_OK,
NORFLASH_API_BUFFER_FULL,
NORFLASH_API_BAD_DEV_ID,
NORFLASH_API_BAD_MOD_ID,
NORFLASH_API_BAD_BUFF_LEN,
NORFLASH_API_BAD_ADDR,
NORFLASH_API_BAD_LEN,
NORFLASH_API_ERR_UNINIT,
NORFLASH_API_ERR_HASINIT,
NORFLASH_API_ERR,
};
enum NORFLASH_API_OPRATION_TYPE
{
NORFLASH_API_WRITTING = 0x01,
NORFLASH_API_ERASING = 0x02,
NORFLASH_API_ALL = 0x03
};
typedef struct
{
enum NORFLASH_API_OPRATION_TYPE type;
uint32_t addr;
uint32_t len;
uint32_t remain_num;
enum NORFLASH_API_RET_T result;
}NORFLASH_API_OPERA_RESULT;
enum NORFLASH_API_STATE
{
NORFLASH_API_STATE_IDLE,
NORFLASH_API_STATE_WRITTING,
NORFLASH_API_STATE_WRITTING_SUSPEND,
NORFLASH_API_STATE_WRITTING_RESUME,
NORFLASH_API_STATE_ERASE,
NORFLASH_API_STATE_ERASE_SUSPEND,
NORFLASH_API_STATE_ERASE_RESUME,
};
typedef void (* NORFLASH_API_OPERA_CB)(void* opera_result);
typedef struct _opera_info
{
enum NORFLASH_API_OPRATION_TYPE type;
uint32_t addr;
uint32_t len;
uint32_t w_offs;
uint32_t w_len;
uint8_t *buff;
bool lock;
struct _opera_info *next;
}OPRA_INFO;
typedef struct
{
bool is_inited;
enum HAL_NORFLASH_ID_T dev_id;
enum NORFLASH_API_MODULE_ID_T mod_id;
uint32_t mod_base_addr;
uint32_t mod_len;
uint32_t mod_block_len;
uint32_t mod_sector_len;
uint32_t mod_page_len;
uint32_t buff_len;
NORFLASH_API_OPERA_CB cb_func;
OPRA_INFO *opera_info;
OPRA_INFO *cur_opera_info;
enum NORFLASH_API_STATE state;
}MODULE_INFO;
typedef struct
{
bool is_inited;
MODULE_INFO mod_info[NORFLASH_API_MODULE_ID_COUNT];
enum NORFLASH_API_MODULE_ID_T cur_mod_id;
MODULE_INFO* cur_mod;
}NORFLASH_API_INFO;
#if defined(FLASH_API_SIMPLE)
#define NORFLASH_API_WRITE_BUFF_LEN (0)
#endif
#if defined(FLASH_API_HIGHPERFORMANCE)
#define NORFLASH_API_WRITE_BUFF_LEN (4)
#endif
#if defined(FLASH_API_NORMAL)
#define NORFLASH_API_WRITE_BUFF_LEN (1)
#endif
#define NORFLASH_API_OPRA_LIST_LEN (NORFLASH_API_WRITE_BUFF_LEN + 1)*3
#define NORFLASH_API_SECTOR_SIZE 4096
typedef struct
{
bool is_used;
OPRA_INFO opera_info;
}OPERA_INFO_LIST;
typedef struct
{
bool is_used;
uint8_t buffer[NORFLASH_API_SECTOR_SIZE];
}DATA_LIST;
enum NORFLASH_API_RET_T norflash_api_init(void);
enum NORFLASH_API_RET_T norflash_api_register(
enum NORFLASH_API_MODULE_ID_T mod_id,
enum HAL_NORFLASH_ID_T dev_id,
uint32_t mod_base_addr,
uint32_t mod_len,
uint32_t mod_block_len,
uint32_t mod_sector_len,
uint32_t mod_page_len,
uint32_t buffer_len,
NORFLASH_API_OPERA_CB cb_func
);
// read flash buffer or flash,priority read flash buffer.
enum NORFLASH_API_RET_T norflash_api_read(
enum NORFLASH_API_MODULE_ID_T mod_id,
uint32_t start_addr,
uint8_t *buffer,
uint32_t len
);
// read flash.
enum NORFLASH_API_RET_T norflash_sync_read(
enum NORFLASH_API_MODULE_ID_T mod_id,
uint32_t start_addr,
uint8_t *buffer,
uint32_t len
);
enum NORFLASH_API_RET_T norflash_api_erase(
enum NORFLASH_API_MODULE_ID_T mod_id,
uint32_t start_addr,
uint32_t len,
bool async
);
enum NORFLASH_API_RET_T norflash_api_write(
enum NORFLASH_API_MODULE_ID_T mod_id,
uint32_t start_addr,
const uint8_t *buffer,
uint32_t len,
bool async
);
int norflash_api_flush(void);
bool norflash_api_is_changed(
enum NORFLASH_API_MODULE_ID_T mod_id,
uint32_t start_addr,
const uint8_t *buffer,
uint32_t len);
bool norflash_api_buffer_is_free(
enum NORFLASH_API_MODULE_ID_T mod_id);
uint32_t norflash_api_get_used_buffer_count(
enum NORFLASH_API_MODULE_ID_T mod_id,
enum NORFLASH_API_OPRATION_TYPE type
);
uint32_t norflash_api_get_free_buffer_count(
enum NORFLASH_API_OPRATION_TYPE type
);
void norflash_flush_all_pending_op(void);
void app_flash_page_erase(enum NORFLASH_API_MODULE_ID_T module, uint32_t flashOffset);
void app_flash_page_program(enum NORFLASH_API_MODULE_ID_T module,
uint32_t flashOffset,
uint8_t *ptr,
uint32_t len,
bool synWrite);
#ifdef __cplusplus
}
#endif
#endif //_NORFLASH_ASYNC_API_H_
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/norflash_api/norflash_api.h
|
C
|
apache-2.0
| 6,190
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __aud_section_h__
#define __aud_section_h__
#include "section_def.h"
#ifdef __cplusplus
extern "C" {
#endif
#define aud_section_debug
#ifdef aud_section_debug
#define aud_trace TRACE
#else
#define aud_trace(...)
#endif
#include "hal_aud.h"
#define audsec_tag "audsec_tag"
#define aud_section_magic 0xdad1
#define aud_section_struct_version 1
#define AUD_COEF_LEN (500)
#if (AUD_SECTION_STRUCT_VERSION == 1)
#define AUD_IIR_NUM (6)
#elif (AUD_SECTION_STRUCT_VERSION == 2)
#define AUD_IIR_NUM (8)
#elif (AUD_SECTION_STRUCT_VERSION == 3)
#define AUD_IIR_NUM (8)
#else
#error "Can not support this version!!!"
#endif
typedef struct _anc_rir_coefs {
int32_t coef_b[3];
int32_t coef_a[3];
} anc_iir_coefs;
typedef struct _aud_item {
int32_t total_gain;
uint16_t iir_bypass_flag;
uint16_t iir_counter;
anc_iir_coefs iir_coef[AUD_IIR_NUM];
#if (AUD_SECTION_STRUCT_VERSION == 1)
uint16_t fir_bypass_flag;
uint16_t fir_len;
int16_t fir_coef[AUD_COEF_LEN];
int8_t pos_tab[16];
#elif (AUD_SECTION_STRUCT_VERSION == 2)
int32_t reserved_for_drc[32];
#elif (AUD_SECTION_STRUCT_VERSION == 3)
#endif
int16_t reserved1;
int8_t dac_gain_offset; // in qdb (quater of dB)
int8_t adc_gain_offset; // in qdb (quater of dB)
} aud_item;
typedef struct {
#if (AUD_SECTION_STRUCT_VERSION == 1)
aud_item anc_cfg_ff_l;
aud_item anc_cfg_ff_r;
aud_item anc_cfg_fb_l;
aud_item anc_cfg_fb_r;
#elif (AUD_SECTION_STRUCT_VERSION == 2)
aud_item anc_cfg_ff_l;
aud_item anc_cfg_ff_r;
aud_item anc_cfg_fb_l;
aud_item anc_cfg_fb_r;
aud_item anc_cfg_tt_l;
aud_item anc_cfg_tt_r;
aud_item anc_cfg_mc_l;
aud_item anc_cfg_mc_r;
#elif (AUD_SECTION_STRUCT_VERSION == 3)
aud_item anc_cfg_ff_l;
aud_item anc_cfg_fb_l;
aud_item anc_cfg_tt_l;
aud_item anc_cfg_mc_l;
#endif
} struct_anc_cfg;
enum ANC_INDEX {
ANC_INDEX_0 = 0,
ANC_INDEX_1,
ANC_INDEX_2,
ANC_INDEX_3,
ANC_INDEX_TOTAL,
};
typedef struct {
unsigned char anc_ver[16];
unsigned char batch_info[16];
unsigned char serial[16];
} anc_ident;
enum auditem_sample_enum_t {
#if (AUD_SECTION_STRUCT_VERSION == 3)
PCTOOL_SAMPLERATE_48X8K,
#else
PCTOOL_SAMPLERATE_44_1X8K,
PCTOOL_SAMPLERATE_48X8K,
PCTOOL_SAMPLERATE_50_7X8K = PCTOOL_SAMPLERATE_48X8K,
#endif
PCTOOL_AUDITEM_SAMPLERATE_COUNT
};
typedef struct {
struct_anc_cfg anc_cfg[PCTOOL_AUDITEM_SAMPLERATE_COUNT];
} pctool_struct_anc_cfg;
#if (AUD_SECTION_STRUCT_VERSION == 3)
#define PCTOOL_ANC_APPMODE_COUNT 15
#define ANC_SECTIONE_SIZE (16*1024)
#else
#define PCTOOL_ANC_APPMODE_COUNT 4
#define ANC_SECTIONE_SIZE (64*1024)
#endif
typedef struct {
pctool_struct_anc_cfg anc_config_arr[PCTOOL_ANC_APPMODE_COUNT];
} pctool_anc_config_t;
#define PCTOOL_AUDSEC_RESERVED_LEN (ANC_SECTIONE_SIZE -sizeof(section_head_t) - sizeof(anc_ident) - sizeof(pctool_anc_config_t))
typedef struct {
anc_ident ancIdent;
pctool_anc_config_t anc_config;
unsigned char reserved[PCTOOL_AUDSEC_RESERVED_LEN];
} audsec_body;
typedef struct {
section_head_t sec_head;
audsec_body sec_body;
} pctool_aud_section;
typedef struct {
uint8_t io_pin;
uint8_t set_flag;
} pctool_iocfg;
/*
typedef struct{
uint8_t digmic_ck_iomux_pin;
uint8_t digmic_d0_iomux_pin;
uint8_t digmic_d1_iomux_pin;
uint8_t digmic_d2_iomux_pin;
uint8_t digmic_phase;
}digital_mic_cfg;
*/
// Add audio and speech support
#define AUDIO_SECTION_DEBUG
// Device
#define AUDIO_SECTION_DEVICE_ANC (0)
#define AUDIO_SECTION_DEVICE_AUDIO (1)
#define AUDIO_SECTION_DEVICE_SPEECH (2)
#define AUDIO_SECTION_DEVICE_NUM (3)
// If add device, need add length to section_device_length
#define AUDIO_SECTION_LENGTH_ANC (1024*8)
#define AUDIO_SECTION_LENGTH_AUDIO (1024*8)
#define AUDIO_SECTION_LENGTH_SPEECH (1024*8)
#define AUDIO_SECTION_CFG_RESERVED_LEN (sizeof(audio_section_t))
typedef struct {
section_head_t head;
uint32_t device;
uint32_t cfg_len;
} audio_section_t;
// README: Important!!!!!!
// App cfg struecture must define reserved like follow:
// typedef struct {
// uint8_t reserved[AUDIO_SECTION_CFG_RESERVED_LEN];
// custom_cfg_t custom_cfg;
// } audio_section_custom_cfg_t;
int audio_section_store_cfg(uint32_t device, uint8_t *cfg, uint32_t len);
int audio_section_load_cfg(uint32_t device, uint8_t *cfg, uint32_t len);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/aud_section/aud_section.h
|
C
|
apache-2.0
| 5,344
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __aud_section_inc_h__
#define __aud_section_inc_h__
#ifdef __cplusplus
extern "C" {
#endif
#include "aud_section.h"
int anccfg_loadfrom_audsec(const struct_anc_cfg *list[], const struct_anc_cfg *list_44p1k[], uint32_t count);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/aud_section/aud_section_inc.h
|
C
|
apache-2.0
| 924
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUSTOMPARAM_SECTION_H__
#define __CUSTOMPARAM_SECTION_H__
#ifdef __cplusplus
extern "C" {
#endif
// Could be customized
#define CUSTOMPARAM_MAGIC_CODE 0x54534542
#define CUSTOMPARAM_VERSION 1
#define CUSTOMPARAM_SECTION_SIZE 4096 // one flash page
typedef struct
{
uint32_t magic_code; // fixed value as CUSTOMPARAM_MAGIC_CODE
uint16_t version;
uint16_t length; // length in bytes of the following data in the section
uint16_t entryCount;
// following are parameter entries
} __attribute__((packed)) CUSTOM_PARAM_SECTION_HEADER_T;
typedef struct
{
uint16_t paramIndex;
uint16_t paramLen;
// following are the parameter content with length paramLen
} __attribute__((packed)) CUSTOM_PARAM_ENTRY_HEADER_T;
#define CUSTOM_PARAM_Mode_ID_INDEX 0
#define CUSTOM_PARAM_Model_ID_LEN 3
#define CUSTOM_PARAM_SERIAL_NUM_INDEX 0
#define CUSTOM_PARAM_SERIAL_NUM_LEN 16
#ifdef BES_BLE_MESH_ENABLE
typedef void (*ble_addr_set)(unsigned char* addr);
#define CUSTOM_PARAM_SECRET_NUM_INDEX 0
#define CUSTOM_PARAM_PID_NUM_INDEX 1
#define CUSTOM_PARAM_MAC_NUM_INDEX 2
#define GENIE_SIZE_PID 4
#define GENIE_SIZE_KEY 16
#define GENIE_SIZE_MAC 6
void nv_custom_register(ble_addr_set callback);
uint8_t *genie_tri_tuple_get_uuid(void);
uint8_t *genie_tri_tuple_get_auth(void);
#endif
typedef struct
{
uint8_t sn[CUSTOM_PARAM_SERIAL_NUM_LEN];
} CUSTOM_PARAM_SERIAL_NUM_T;
// TODO:
// Add your own custom parameters here
void nv_custom_parameter_section_init(void);
bool nv_custom_parameter_section_get_entry(
uint16_t paramIndex, uint8_t* pParamVal, uint32_t* pParamLen);
uint32_t Get_ModelId(void);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/customparam_section/customparam_section.h
|
C
|
apache-2.0
| 2,323
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __FACTORY_SECTIONS_H__
#define __FACTORY_SECTIONS_H__
#define ALIGN4 __attribute__((aligned(4)))
#define nvrec_mini_version 1
#define nvrec_dev_magic 0xba80
#define nvrec_current_version 2
#define FACTORY_SECTOR_SIZE 4096
typedef struct{
unsigned short magic;
unsigned short version;
unsigned int crc ;
unsigned int reserved0;
unsigned int reserved1;
}section_head_t;
typedef struct{
unsigned char device_name[248+1] ALIGN4;
unsigned char bt_address[8] ALIGN4;
unsigned char ble_address[8] ALIGN4;
unsigned char tester_address[8] ALIGN4;
unsigned int xtal_fcap ALIGN4;
unsigned int rev1_data_len;
unsigned int rev2_data_len;
unsigned int rev2_crc;
unsigned int rev2_reserved0;
unsigned int rev2_reserved1;
unsigned int rev2_bt_name[63];
unsigned int rev2_bt_addr[2];
unsigned int rev2_ble_addr[2];
unsigned int rev2_dongle_addr[2];
unsigned int rev2_xtal_fcap;
unsigned int rev2_ble_name[8];
}factory_section_data_t;
typedef struct{
section_head_t head;
factory_section_data_t data;
}factory_section_t;
typedef struct
{
unsigned short magic;
unsigned short version;
unsigned int crc;
} section_wifi_head_t;
typedef struct
{
unsigned char mac_addr[6];
unsigned short freq_cal;
unsigned int iQ_cal;
unsigned int iQ_offset;
/*
freq_cal_flags 0 - save bgn 1,7,13 power
freq_cal_flags 1 - save bgn 1-13 power
freq_cal_flags 0xff - not calibration
*/
unsigned char tx_power_type;
/*
freq_cal_flags 0 - chip not calibrated
freq_cal_flags 1 - chip has been calibrated
*/
unsigned char freq_cal_flags;
/*
when freq_cal_flags value is 0
index 0-8
0-2:11b ch1, 11b ch7, 11b ch13
3-5:11g ch1, 11g ch7, 11g ch13
6-8:11n ch1, 11n ch7, 11n ch13
when freq_cal_flags value is 1
index 0-41
0-13:11b ch1, 11b ch2 ......11b ch14
14-27:11g ch1, 11g ch2 ......11g ch14
28-41:11n ch1, 11n ch2 ......11n ch14
*/
unsigned short tx_power_ch[42];
unsigned short temperature;;
unsigned char band; //0:2.4 1:5 2:dual band
unsigned char country[3];
unsigned int bt_tx_power[4];
/*
5G power calibration 0-12 save the 5G calib power,13-15 reserve
5G power calibration 0-12 save the 5G calib power,13-15 reserve
11g
0 36~40;1 44~48;2 52~56;3 60~64;
4 100~104;5 108~112;6 116~120;
7 124~128;8 132~136;9 140~144
11 149~153; 12 157~161;13 165~169
11n
0 36~40;1 44~48;2 52~56;3 60~64;
4 100~104;5 108~112;6 116~120;
7 124~128;8 132~136;9 140~144
11 149~153; 12 157~161;13 165~169
*/
unsigned short tx_power_ch_5G[32];
/*
0- it means that power not calib
1- it means that power have clibrated
*/
unsigned short tx_power_flags_5G;
/*
The temperature after 5G clibrating.
*/
unsigned short temperature_5G;
} factory_section_wifi_data_t;
/* offset 2k */
#define FACTORY_SECTION_WIFI_OFFSET 0x800
typedef struct{
section_wifi_head_t head;
factory_section_wifi_data_t data;
}factory_section_wifi_t;
#ifdef __cplusplus
extern "C" {
#endif
void factory_section_init(void);
int factory_section_open(void);
void factory_section_original_btaddr_get(uint8_t *btAddr);
int factory_section_xtal_fcap_get(unsigned int *xtal_fcap);
int factory_section_xtal_fcap_set(unsigned int xtal_fcap);
uint8_t* factory_section_get_bt_address(void);
uint8_t* factory_section_get_bt_name(void);
uint8_t* factory_section_get_ble_name(void);
uint32_t factory_section_get_version(void);
uint8_t *factory_section_get_wifi_address(void);
int factory_section_set_wifi_address(uint8_t *wifi_addr);
uint8_t *factory_section_get_wifi_tx_power(void);
uint8_t *factory_section_get_wifi_tx_power_5G(void);
int factory_section_set_wifi_tx_power_ch(int power,int index);
factory_section_wifi_t* factory_section_get_wifi_data();
int factory_section_set_wifi_data(factory_section_wifi_data_t *wifi_data);
int factory_section_set_wifi_temp(int temp);
int factory_section_set_wifi_xtal(unsigned short xtal);
int factory_section_set_bt_tx_power(uint8_t index, uint32_t div_value, uint32_t txPower);
int factory_section_set_wifi_tx_power_all_ch(int power,int index);
int factory_section_set_wifi_power_type(unsigned short powerType);
int factory_section_wifi_band_status(int bandType);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/factory_section/factory_section.h
|
C
|
apache-2.0
| 5,211
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_BLE_H
#define NVRECORD_BLE_H
#include "nvrecord_extension.h"
#ifdef __cplusplus
extern "C" {
#endif
int nv_record_blerec_add(const BleDeviceinfo *param_rec);
bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t* pBdAddr, uint8_t *ltk);
bool nv_record_ble_record_Once_a_device_has_been_bonded(void);
void nv_record_ble_delete_entry(uint8_t* pBdAddr);
uint8_t nv_record_ble_fill_irk(uint8_t* ltkToFill);
void nv_record_blerec_init(void);
NV_RECORD_PAIRED_BLE_DEV_INFO_T* nv_record_blerec_get_ptr(void);
void nv_record_blerec_get_local_irk(uint8_t* pIrk);
bool nv_record_blerec_get_bd_addr_from_irk(uint8_t* pBdAddr, uint8_t* pIrk);
void nvrecord_rebuild_paired_ble_dev_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T* pPairedBtInfo);
#ifdef TWS_SYSTEM_ENABLED
void nv_record_extension_update_tws_ble_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T *info);
void nv_record_tws_exchange_ble_info(void);
uint8_t *nv_record_tws_get_self_ble_info(void);
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/fpga_section/nvrecord_ble.h
|
C
|
apache-2.0
| 1,735
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_BT_H
#define NVRECORD_BT_H
#include "nvrecord_extension.h"
#ifdef __cplusplus
extern "C" {
#endif
#define NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT (AUDIO_OUTPUT_VOLUME_DEFAULT)
#define NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT (AUDIO_OUTPUT_VOLUME_DEFAULT)
void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord* pRecord, int8_t vol);
void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord* pRecord, int8_t vol);
void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume* device_vol, int8_t vol);
void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume* device_vol, int8_t vol);
void nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_profile* device_plf, bool isActive);
int nv_record_enum_latest_two_paired_dev(btif_device_record_t* record1,btif_device_record_t* record2);
void nv_record_all_ddbrec_print(void);
void nv_record_update_runtime_userdata(void);
void nvrecord_rebuild_paired_bt_dev_info(NV_RECORD_PAIRED_BT_DEV_INFO_T* pPairedBtInfo);
int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record);
void nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_profile* device_plf, uint8_t a2dpCodec);
bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr);
bt_status_t nv_record_enum_dev_records(unsigned short index,btif_device_record_t* record);
bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, btif_device_record_t*record);
bt_status_t nv_record_add(SECTIONS_ADP_ENUM type,void *record);
int nv_record_get_paired_dev_count(void);
void ram_record_ddbrec_init(void);
bt_status_t ram_record_ddbrec_find(const bt_bdaddr_t* bd_ddr, nvrec_btdevicerecord **record);
bt_status_t ram_record_ddbrec_add(const nvrec_btdevicerecord* param_rec);
bt_status_t ram_record_ddbrec_delete(const bt_bdaddr_t *bdaddr);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/fpga_section/nvrecord_bt.h
|
C
|
apache-2.0
| 2,795
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_ENV_H
#define NVRECORD_ENV_H
#ifdef __cplusplus
extern "C" {
#endif
#include "me_api.h"
#include "nvrecord_extension.h"
#define NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT (0)
#define NVRAM_ENV_TWS_MODE_DEFAULT (0xff)
#define NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT (0xaabbccdd)
int nv_record_env_init(void);
int nv_record_env_get(struct nvrecord_env_t **nvrecord_env);
int nv_record_env_set(struct nvrecord_env_t *nvrecord_env);
void nv_record_update_ibrt_info(uint32_t newMode,bt_bdaddr_t *ibrtPeerAddr);
void nvrecord_rebuild_system_env(struct nvrecord_env_t* pSystemEnv);
void nv_record_update_factory_tester_status(uint32_t status);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/fpga_section/nvrecord_env.h
|
C
|
apache-2.0
| 1,417
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef NEW_NV_RECORD_ENALBED
#ifndef __NVRECORD_EXTENSION_H__
#define __NVRECORD_EXTENSION_H__
#include "bluetooth.h"
#include "me_api.h"
// increase by 1 if the nvrecord's whole data structure is changed and the content needs to be rebuilt
#define NV_EXTENSION_MAJOR_VERSION 2
// increase by 1 if the new items are appended to the tail of the former nvrecord's data structure
#define NV_EXTENSION_MINOR_VERSION 1
#define NV_EXTENSION_SIZE 4096 // one flash page
#define NV_EXTENSION_HEADER_SIZE sizeof(NVRECORD_HEADER_T) // magic number and valid length
#define NV_EXTENSION_MAGIC_NUMBER 0x4E455854
#define NV_EXTENSION_VALID_LEN (sizeof(NV_EXTENSION_RECORD_T) - sizeof(NVRECORD_HEADER_T))
/* unused, just for backwards compatible */
#define section_name_ddbrec "ddbrec"
/* BT paired device info */
#define MAX_BT_PAIRED_DEVICE_COUNT 8
/* BLE paired device information */
#define BLE_RECORD_NUM 5
#define BLE_ADDR_SIZE 6
#define BLE_ENC_RANDOM_SIZE 8
#define BLE_LTK_SIZE 16
#define BLE_IRK_SIZE 16
#define BLE_STATIC_ADDR 0
#define BLE_RANDOM_ADDR 1
#ifdef GFPS_ENABLED
/* fast pair account key */
#define FP_ACCOUNT_KEY_RECORD_NUM 5
#define FP_ACCOUNT_KEY_SIZE 16
#define FP_MAX_NAME_LEN 64
#endif
// TODO: should be increased if NV_EXTENSION_MIRROR_RAM_SIZE exceeds this value
#define TILE_INFO_SIZE 400
#define BT_FREQENCY_RANGE_NUM 3
#define BT_IQ_INVALID_MAGIC_NUM 0xFFFFFFFF
#define BT_IQ_VALID_MAGIC_NUM 0x5a5a5a5a
typedef struct
{
uint32_t validityMagicNum;
uint16_t gain_cal_val[BT_FREQENCY_RANGE_NUM];
uint16_t phase_cal_val[BT_FREQENCY_RANGE_NUM];
} BT_IQ_CALIBRATION_CONFIG_T;
/* nv record header data structure */
typedef struct
{
uint32_t magicNumber;
uint16_t majorVersion; // should be NV_EXTENSION_MAJOR_VERSION
uint16_t minorVersion; // should be NV_EXTENSION_MINOR_VERSION
uint32_t validLen; // should be the valid content in this nv record version
uint32_t crc32; // crc32 of following valid values in the nv extention section
} NVRECORD_HEADER_T;
/* system information */
typedef struct {
int8_t language;
} media_language_t;
#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE)
typedef struct {
int8_t src_snk_mode;
} src_snk_t;
#endif
typedef struct {
uint32_t mode;
btif_device_record_t record;
bool tws_connect_success;
} ibrt_mode_t;
typedef struct {
uint32_t status;
} factory_tester_status_t;
#ifdef IS_MULTI_AI_ENABLED
typedef struct {
uint8_t setedCurrentAi;
uint8_t currentAiSpec;
uint8_t aiStatusDisableFlag;
uint8_t amaAssistantEnableStatus;
} AI_MANAGER_INFO_T;
#endif
struct nvrecord_env_t {
media_language_t media_language;
#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE)
src_snk_t src_snk_flag;
#endif
ibrt_mode_t ibrt_mode;
factory_tester_status_t factory_tester_status;
#if defined(__TENCENT_VOICE__)
uint8_t flag_value[8];
#endif
#ifdef IS_MULTI_AI_ENABLED
bool voice_key_enable;
AI_MANAGER_INFO_T aiManagerInfo;
#endif
};
typedef struct btdevice_volume {
int8_t a2dp_vol;
int8_t hfp_vol;
} btdevice_volume;
typedef struct btdevice_profile {
bool hfp_act;
bool hsp_act;
bool a2dp_act;
uint8_t a2dp_codectype;
} btdevice_profile;
typedef struct {
btif_device_record_t record;
btdevice_volume device_vol;
btdevice_profile device_plf;
} nvrec_btdevicerecord;
typedef struct {
uint32_t pairedDevNum;
nvrec_btdevicerecord pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT];
} NV_RECORD_PAIRED_BT_DEV_INFO_T;
typedef enum {
section_usrdata_ddbrecord,
section_none
} SECTIONS_ADP_ENUM;
#if defined(GSOUND_OTA_ENABLED)&&defined(VOICE_DATAPATH)
typedef enum {
GSOUND_OTA_STATUS_NONE = 0,
GSOUND_OTA_STATUS_IN_PROGRESS = 1,
GSOUND_OTA_STATUS_COMPLETE = 2,
GSOUND_OTA_STATUS_NUM,
} GSOUND_OTA_STATUS_E;
#endif
typedef struct {
uint8_t ble_addr[BTIF_BD_ADDR_SIZE];
uint8_t ble_irk[BLE_IRK_SIZE];
} BLE_BASIC_INFO_T;
typedef struct {
uint8_t peer_bleAddr[BLE_ADDR_SIZE];
uint16_t EDIV;
uint8_t RANDOM[BLE_ENC_RANDOM_SIZE];
uint8_t LTK[BLE_LTK_SIZE];
uint8_t IRK[BLE_IRK_SIZE];
uint8_t bonded;
} BleDeviceinfo;
typedef struct {
uint32_t saved_list_num;
BLE_BASIC_INFO_T self_info;
BleDeviceinfo ble_nv[BLE_RECORD_NUM];
} NV_RECORD_PAIRED_BLE_DEV_INFO_T;
#ifdef TWS_SYSTEM_ENABLED
typedef struct {
BLE_BASIC_INFO_T ble_info;
} TWS_INFO_T;
#endif // #ifdef TWS_SYSTEM_ENABLED
#ifdef GFPS_ENABLED
typedef struct {
uint8_t key[FP_ACCOUNT_KEY_SIZE];
} NV_FP_ACCOUNT_KEY_ENTRY_T;
typedef struct {
uint32_t key_count;
NV_FP_ACCOUNT_KEY_ENTRY_T accountKey[FP_ACCOUNT_KEY_RECORD_NUM];
uint16_t nameLen;
uint8_t name[FP_MAX_NAME_LEN];
} NV_FP_ACCOUNT_KEY_RECORD_T;
#endif // #ifdef GFPS_ENABLED
#ifdef NVREC_BAIDU_DATA_SECTION
/* DMA owned configuration information */
typedef struct {
int32_t fmfreq;
char rand[BAIDU_DATA_RAND_LEN + 1];
} NV_DMA_CONFIGURATION_T;
#endif // #ifdef NVREC_BAIDU_DATA_SECTION
#ifdef TILE_DATAPATH
typedef struct {
uint8_t tileInfo[TILE_INFO_SIZE];
} NV_TILE_INFO_CONFIG_T;
#endif
#if defined(GSOUND_OTA_ENABLED) && defined(VOICE_DATAPATH)
typedef struct {
uint8_t isGsoundEnabled;
uint8_t gsoundOtaStatus;
uint32_t gsoundOtaOffset;
uint32_t gsoundOtaImageSize;
uint8_t gsoundOtaSessionString[16];
} NV_GSOUND_INFO_T;
#endif
typedef struct {
NVRECORD_HEADER_T header;
struct nvrecord_env_t system_info;
NV_RECORD_PAIRED_BT_DEV_INFO_T bt_pair_info;
NV_RECORD_PAIRED_BLE_DEV_INFO_T ble_pair_info;
#ifdef TWS_SYSTEM_ENABLED
TWS_INFO_T tws_info;
#endif
#ifdef GFPS_ENABLED
NV_FP_ACCOUNT_KEY_RECORD_T fp_account_key_rec;
#endif
#ifdef NVREC_BAIDU_DATA_SECTION
NV_DMA_CONFIGURATION_T dma_config;
#endif
#ifdef TILE_DATAPATH
NV_TILE_INFO_CONFIG_T tileConfig;
#endif
#if defined(GSOUND_OTA_ENABLED) && defined(VOICE_DATAPATH)
NV_GSOUND_INFO_T gsound_info;
#endif
#ifdef TX_IQ_CAL
BT_IQ_CALIBRATION_CONFIG_T btIqCalConfig;
#endif
// TODO: If wanna OTA to update the nv record, two choices:
// 1. Change above data structures and increase NV_EXTENSION_MAJOR_VERSION.
// Then the nv record will be rebuilt and the whole history information will be cleared
// 2. Don't touch above data structures but just add new items here and increase NV_EXTENSION_MINOR_VERSION.
// Then the nv record will keep all the whole hisotry.
} NV_EXTENSION_RECORD_T;
#ifdef __cplusplus
extern "C" {
#endif
extern NV_EXTENSION_RECORD_T *nvrecord_extension_p;
int nv_record_env_init(void);
NV_EXTENSION_RECORD_T *nv_record_get_extension_entry_ptr(void);
void nv_record_extension_update(void);
void nv_extension_callback(void *param);
int nv_record_touch_cause_flush(void);
void nv_record_sector_clear(void);
void nv_record_flash_flush(void);
int nv_record_flash_flush_in_sleep(void);
void nv_record_update_runtime_userdata(void);
void nv_record_rebuild(void);
uint32_t nv_record_pre_write_operation(void);
void nv_record_post_write_operation(uint32_t lock);
bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id);
void nv_record_init(void);
#ifdef __cplusplus
}
#endif
#endif
#endif //#if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/fpga_section/nvrecord_externsion.h
|
C
|
apache-2.0
| 7,975
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __section_def_h__
#define __section_def_h__
#include "stdint.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uint16_t magic;
uint16_t version;
uint32_t crc;
uint32_t reserved0;
uint32_t reserved1;
} section_head_t;
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/include/section_def.h
|
C
|
apache-2.0
| 945
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _COREDUMP_SECTION_H
#define _COREDUMP_SECTION_H
#define COREDUMP_SECTOR_SIZE 0x1000
#define COREDUMP_SECTOR_SIZE_MASK 0xFFF
#define COREDUMP_BUFFER_LEN (COREDUMP_SECTOR_SIZE*2)
#define COREDUMP_NORFALSH_BUFFER_LEN (COREDUMP_BUFFER_LEN)
#if defined(__cplusplus)
extern "C" {
#endif
void coredump_to_flash_init();
void core_dump_erase_section();
int32_t core_dump_write_large(const uint8_t* ptr,uint32_t len);
int32_t core_dump_write(const uint8_t* ptr,uint32_t len);
#if defined(__cplusplus)
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/log_section/coredump_section.h
|
C
|
apache-2.0
| 1,206
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CRASH_DUMP_SECTION_H__
#define __CRASH_DUMP_SECTION_H__
#ifdef __cplusplus
extern "C" {
#endif
#if 0
#include "plat_types.h"
#define CRASH_DUMP_MAGIC_CODE 0x504D5544
#define CRASH_DUMP_ASSERT_CODE 0xEB6D0924
#define CRASH_DUMP_EXCEPTION_CODE 0xC78BA332
/*
* Total number of core registers stored
*/
#define CRASH_DUMP_REGISTERS_NUM 17
#define CRASH_DUMP_REGISTERS_NUM_BYTES ((CRASH_DUMP_REGISTERS_NUM)*4)
/*
* Number bytes to store from stack
* - this is total, not per PSP/MSP
*/
#define CRASH_DUMP_STACK_NUM_BYTES 384
#define CRASH_DUMP_FRAME_SIZE (1024*16)
typedef struct {
uint32_t magicCode; // must be CRASH_DUMP_MAGIC_CODE
int32_t seqnum; // increased by 1 per crash
uint32_t partnum; // maximum crash log count saved in the flash
uint32_t reserved;
uint32_t bufpos; // valid content in the following buf array
uint32_t liteDumpOffset;
uint32_t crashCode;
} CRASH_OUTPUT_BUF_HEADER_T;
/**
* This structure MUST be a total size
* of 0x4000
*/
struct CRASH_OUTPUT_BUF_T {
CRASH_OUTPUT_BUF_HEADER_T hdr;
uint8_t buf[CRASH_DUMP_FRAME_SIZE - sizeof(CRASH_OUTPUT_BUF_HEADER_T)];
};
/** Tell whether the system reboots because of a fresh assert or hardfault. */
bool crashdump_is_crash_happened(void);
void crashdump_set_existing_flag(uint8_t isExisting);
/**
* Tell the flash offset of the latest crash dump
* -1 means there is no crash dump in the flash.
* Other values are the valid flash offset of the latest happend crash dump log.
*/
int32_t crashdump_get_latest_flash_offset(void);
/** Tell whether there is any crash dump logs in the flash. */
bool crashdump_is_crash_dump_existing(void);
void crashdump_set_crash_happened_flag(uint8_t isHappened);
void crashdump_dumptoflash(void);
void crashdump_init_section_info(void);
#else
#include "hal_trace.h"
#define CRASH_DUMP_PREFIX "__CRASH_DUMP:"
#define CRASH_DUMP_TRACE(fmt, ...) TRACE(fmt, ##__VA_ARGS__)
#define CRASH_LOG_ALIGN(x,a) (uint32_t)(((x + a - 1)/a) * a)
#define CRASH_DUMP_SECTOR_SIZE 0x1000
#define CRASH_DUMP_BUFFER_LEN (CRASH_DUMP_SECTOR_SIZE*2)
#define CRASH_DUMP_NORFALSH_BUFFER_LEN (CRASH_DUMP_BUFFER_LEN)
#define DATA_BUFFER_STATE_FREE 0
#define DATA_BUFFER_STATE_WRITTING 0x1
#define DATA_BUFFER_STATE_WRITTEN 0x2
#define CRASH_DUMP_MAGIC_CODE 0x504D5544
#define CRASH_DUMP_VERSION 0x00010001
#define CRASH_DUMP_ASSERT_CODE 0xEB6D0924
#define CRASH_DUMP_EXCEPTION_CODE 0xC78BA332
typedef struct
{
uint32_t magic;
uint32_t version;
uint32_t seqnum;
uint8_t reseved[4];
}CRASH_DUMP_HEADER_T;
#define CRASH_DUMP_FRAME_SIZE (CRASH_DUMP_BUFFER_LEN)
typedef struct{
uint32_t offset;
uint8_t *buffer;
}CRASH_DATA_BUFFER;
void crash_dump_init(void);
void crash_dump_init_buffer(void);
int32_t crash_dump_read(uint32_t addr,uint8_t* ptr,uint32_t len);
int32_t crash_dump_write(uint32_t addr,uint8_t* ptr,uint32_t len);
void crash_dump_notify_handler(enum HAL_TRACE_STATE_T state);
void crash_dump_output_handler(const unsigned char *buf, unsigned int buf_len);
void crash_dump_fault_handler(const unsigned char *buf, unsigned int buf_len);
void crash_dump_set_flag(uint8_t is_happend);
void crash_dump_register(HAL_TRACE_APP_NOTIFY_T notify_cb,HAL_TRACE_APP_OUTPUT_T crash_output_cb,HAL_TRACE_APP_OUTPUT_T crash_fault_cb);
CRASH_DATA_BUFFER* crash_dump_get_buffer(void);
uint32_t crash_dump_get_type(void);
// --gsound crash dump -------------
typedef struct {
uint32_t magicCode; // must be CRASH_DUMP_MAGIC_CODE
uint32_t seqnum; // increased by 1 per crash
uint32_t partnum; // maximum crash log count saved in the flash
uint32_t reserved;
uint32_t bufpos; // valid content in the following buf array
uint32_t liteDumpOffset;
uint32_t crashCode;
} CRASH_OUTPUT_BUF_HEADER_T;
/**
* This structure MUST be a total size
* of 0x1000
*/
struct CRASH_OUTPUT_BUF_T {
CRASH_OUTPUT_BUF_HEADER_T hdr;
uint8_t buf[CRASH_DUMP_FRAME_SIZE - sizeof(CRASH_OUTPUT_BUF_HEADER_T)];
};
// --gsound crash dump end -------------
#endif
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/log_section/crash_dump_section.h
|
C
|
apache-2.0
| 4,816
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __LOG_SECTION_H__
#define __LOG_SECTION_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#if 0
void init_dump_log(void);
void dump_whole_logs(void);
//void log_update_time_stamp(void);
//void set_dump_log_flush(bool isEnable);
//bool is_dump_log_flush_pending(void);
//void flush_dump_log_handler(void);
void clear_dump_log(void);
uint32_t test_dump_log_from_flash(uint32_t addr,uint32_t size);
#else
#define LOG_DUMP_SECTOR_SIZE 0x1000
#define LOG_DUMP_SECTOR_BUFFER_COUNT 4
#define LOG_DUMP_BUFFER_LEN (LOG_DUMP_SECTOR_SIZE*LOG_DUMP_SECTOR_BUFFER_COUNT)
#define LOG_DUMP_NORFALSH_BUFFER_LEN (LOG_DUMP_BUFFER_LEN*2)
#define DATA_BUFFER_STATE_FREE 0
#define DATA_BUFFER_STATE_WRITTING 0x1
#define DATA_BUFFER_STATE_WRITTEN 0x2
#define DUMP_LOG_MAGIC 0xd5151001
#define DUMP_LOG_VERSION 0x00010001
// #define DUMP_LOG_NEWLINE '\n'
enum LOG_DUMP_FLUSH_STATE
{
LOG_DUMP_FLASH_STATE_IDLE,
LOG_DUMP_FLASH_STATE_ERASED,
LOG_DUMP_FLASH_STATE_WRITTING,
LOG_DUMP_FLASH_STATE_WRITTEN,
};
typedef struct
{
uint32_t magic;
uint32_t version;
uint32_t seqnum;
uint8_t is_bootup;
uint8_t reseved[3];
}LOG_DUMP_HEADER;
typedef struct{
uint32_t state;
uint32_t offset;
uint8_t buffer[LOG_DUMP_BUFFER_LEN];
}DATA_BUFFER;
void log_dump_init(void);
int log_dump_flush(void);
void log_dump_notify_handler(enum HAL_TRACE_STATE_T state);
void log_dump_output_handler(const unsigned char *buf, unsigned int buf_len);
void log_dump_callback(void* param);
void log_dump_clear(void);
//uint32_t test_log_dump_from_flash(uint32_t addr,uint32_t size);
#endif
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/log_section/log_section.h
|
C
|
apache-2.0
| 2,390
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_BLE_H
#define NVRECORD_BLE_H
#include "nvrecord_extension.h"
#ifdef __cplusplus
extern "C" {
#endif
int nv_record_blerec_add(const BleDeviceinfo *param_rec);
bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t* pBdAddr, uint8_t *ltk);
bool nv_record_ble_record_Once_a_device_has_been_bonded(void);
void nv_record_ble_delete_entry(uint8_t* pBdAddr);
uint8_t nv_record_ble_fill_irk(uint8_t* ltkToFill);
void nv_record_blerec_init(void);
NV_RECORD_PAIRED_BLE_DEV_INFO_T* nv_record_blerec_get_ptr(void);
void nv_record_blerec_get_local_irk(uint8_t* pIrk);
bool nv_record_blerec_get_bd_addr_from_irk(uint8_t* pBdAddr, uint8_t* pIrk);
void nvrecord_rebuild_paired_ble_dev_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T* pPairedBtInfo);
#ifdef TWS_SYSTEM_ENABLED
void nv_record_extension_update_tws_ble_info(NV_RECORD_PAIRED_BLE_DEV_INFO_T *info);
void nv_record_tws_exchange_ble_info(void);
uint8_t *nv_record_tws_get_self_ble_info(void);
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_ble.h
|
C
|
apache-2.0
| 1,735
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_BT_H
#define NVRECORD_BT_H
#include "nvrecord_extension.h"
#ifdef __cplusplus
extern "C" {
#endif
#define NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT (AUDIO_OUTPUT_VOLUME_DEFAULT)
#define NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT (AUDIO_OUTPUT_VOLUME_DEFAULT)
void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord* pRecord, int8_t vol);
void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord* pRecord, int8_t vol);
void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume* device_vol, int8_t vol);
void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume* device_vol, int8_t vol);
void nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_profile* device_plf, bool isActive);
int nv_record_enum_latest_two_paired_dev(btif_device_record_t* record1,btif_device_record_t* record2);
void nv_record_all_ddbrec_print(void);
void nv_record_update_runtime_userdata(void);
void nvrecord_rebuild_paired_bt_dev_info(NV_RECORD_PAIRED_BT_DEV_INFO_T* pPairedBtInfo);
int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record);
void nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_profile* device_plf, uint8_t a2dpCodec);
bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr);
bt_status_t nv_record_enum_dev_records(unsigned short index,btif_device_record_t* record);
bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, btif_device_record_t*record);
bt_status_t nv_record_add(SECTIONS_ADP_ENUM type,void *record);
int nv_record_get_paired_dev_count(void);
void ram_record_ddbrec_init(void);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_bt.h
|
C
|
apache-2.0
| 2,561
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef NEW_NV_RECORD_ENALBED
#ifdef NVREC_BAIDU_DATA_SECTION
#ifndef __NVRECORD_DMA_CONFIG_H__
#define __NVRECORD_DMA_CONFIG_H__
#include "nvrecord_extension.h"
#define BAIDU_DATA_DEF_RAND "abcdefghi"
#ifdef __cplusplus
extern "C" {
#endif
int nvrec_baidu_data_init(void);
int nvrec_get_fm_freq(void);
int nvrec_set_fm_freq(int fmfreq);
int nvrec_get_rand(char *rand);
int nvrec_set_rand(char *rand);
void nvrecord_rebuild_dma_configuration(NV_DMA_CONFIGURATION_T* pDmaConfig);
int nvrec_dev_get_sn(char *sn);
#ifdef __cplusplus
}
#endif
#endif
#endif // #ifdef NVREC_BAIDU_DATA_SECTION
#endif // #ifdef NEW_NV_RECORD_ENALBED
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_dma_config.h
|
C
|
apache-2.0
| 1,286
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_ENV_H
#define NVRECORD_ENV_H
#ifdef __cplusplus
extern "C" {
#endif
#include "me_api.h"
#include "nvrecord_extension.h"
#define NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT (0)
#define NVRAM_ENV_TWS_MODE_DEFAULT (0xff)
#define NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT (0xaabbccdd)
int nv_record_env_init(void);
int nv_record_env_get(struct nvrecord_env_t **nvrecord_env);
int nv_record_env_set(struct nvrecord_env_t *nvrecord_env);
void nv_record_update_ibrt_info(uint32_t newMode,bt_bdaddr_t *ibrtPeerAddr);
void nvrecord_rebuild_system_env(struct nvrecord_env_t* pSystemEnv);
void nv_record_update_factory_tester_status(uint32_t status);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_env.h
|
C
|
apache-2.0
| 1,416
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef NEW_NV_RECORD_ENALBED
#ifndef __NVRECORD_EXTENSION_H__
#define __NVRECORD_EXTENSION_H__
#include "bluetooth.h"
#include "me_api.h"
#include "nvrecord_wifi.h"
// increase by 1 if the nvrecord's whole data structure is changed and the content needs to be rebuilt
#define NV_EXTENSION_MAJOR_VERSION 2
// increase by 1 if the new items are appended to the tail of the former nvrecord's data structure
#define NV_EXTENSION_MINOR_VERSION 1
#define NV_EXTENSION_SIZE 4096 // one flash page
#define NV_EXTENSION_HEADER_SIZE sizeof(NVRECORD_HEADER_T) // magic number and valid length
#define NV_EXTENSION_MAGIC_NUMBER 0x4E455854
#define NV_EXTENSION_VALID_LEN (sizeof(NV_EXTENSION_RECORD_T) - sizeof(NVRECORD_HEADER_T))
/* unused, just for backwards compatible */
#define section_name_ddbrec "ddbrec"
/* BT paired device info */
#define MAX_BT_PAIRED_DEVICE_COUNT 8
/* BLE paired device information */
#define BLE_RECORD_NUM 5
#define BLE_ADDR_SIZE 6
#define BLE_ENC_RANDOM_SIZE 8
#define BLE_LTK_SIZE 16
#define BLE_IRK_SIZE 16
#define BLE_STATIC_ADDR 0
#define BLE_RANDOM_ADDR 1
#ifdef GFPS_ENABLED
/* fast pair account key */
#define FP_ACCOUNT_KEY_RECORD_NUM 5
#define FP_ACCOUNT_KEY_SIZE 16
#define FP_MAX_NAME_LEN 64
#endif
// TODO: should be increased if NV_EXTENSION_MIRROR_RAM_SIZE exceeds this value
#define TILE_INFO_SIZE 400
#define BT_FREQENCY_RANGE_NUM 3
#define BT_IQ_INVALID_MAGIC_NUM 0xFFFFFFFF
#define BT_IQ_VALID_MAGIC_NUM 0x5a5a5a5a
typedef struct
{
uint32_t validityMagicNum;
uint16_t gain_cal_val[BT_FREQENCY_RANGE_NUM];
uint16_t phase_cal_val[BT_FREQENCY_RANGE_NUM];
} BT_IQ_CALIBRATION_CONFIG_T;
/* nv record header data structure */
typedef struct
{
uint32_t magicNumber;
uint16_t majorVersion; // should be NV_EXTENSION_MAJOR_VERSION
uint16_t minorVersion; // should be NV_EXTENSION_MINOR_VERSION
uint32_t validLen; // should be the valid content in this nv record version
uint32_t crc32; // crc32 of following valid values in the nv extention section
} NVRECORD_HEADER_T;
/* system information */
typedef struct {
int8_t language;
} media_language_t;
#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE)
typedef struct {
int8_t src_snk_mode;
} src_snk_t;
#endif
typedef struct {
uint32_t mode;
btif_device_record_t record;
bool tws_connect_success;
} ibrt_mode_t;
typedef struct {
uint32_t status;
} factory_tester_status_t;
#ifdef IS_MULTI_AI_ENABLED
typedef struct {
bool voice_key_enable;
uint8_t setedCurrentAi; //if false, set ai default mode
uint8_t currentAiSpec; //
uint8_t aiStatusDisableFlag; //all ai disable flag
uint8_t amaAssistantEnableStatus; //ama enable flag
} AI_MANAGER_INFO_T;
#endif
struct nvrecord_env_t {
media_language_t media_language;
#if defined(APP_LINEIN_A2DP_SOURCE) || defined(APP_I2S_A2DP_SOURCE)
src_snk_t src_snk_flag;
#endif
ibrt_mode_t ibrt_mode;
factory_tester_status_t factory_tester_status;
#if defined(__TENCENT_VOICE__)
uint8_t flag_value[8];
#endif
#ifdef IS_MULTI_AI_ENABLED
AI_MANAGER_INFO_T aiManagerInfo;
#endif
};
typedef struct btdevice_volume {
int8_t a2dp_vol;
int8_t hfp_vol;
} btdevice_volume;
typedef struct btdevice_profile {
bool hfp_act;
bool hsp_act;
bool a2dp_act;
uint8_t a2dp_codectype;
} btdevice_profile;
typedef struct {
btif_device_record_t record;
btdevice_volume device_vol;
btdevice_profile device_plf;
} nvrec_btdevicerecord;
typedef struct {
uint32_t pairedDevNum;
nvrec_btdevicerecord pairedBtDevInfo[MAX_BT_PAIRED_DEVICE_COUNT];
} NV_RECORD_PAIRED_BT_DEV_INFO_T;
typedef enum {
section_usrdata_ddbrecord,
section_none
} SECTIONS_ADP_ENUM;
#if defined(GSOUND_OTA_ENABLED)&&defined(VOICE_DATAPATH)
typedef enum {
GSOUND_OTA_STATUS_NONE = 0,
GSOUND_OTA_STATUS_IN_PROGRESS = 1,
GSOUND_OTA_STATUS_COMPLETE = 2,
GSOUND_OTA_STATUS_NUM,
} GSOUND_OTA_STATUS_E;
#endif
typedef struct {
uint8_t ble_addr[BTIF_BD_ADDR_SIZE];
uint8_t ble_irk[BLE_IRK_SIZE];
} BLE_BASIC_INFO_T;
typedef struct {
uint8_t peer_bleAddr[BLE_ADDR_SIZE];
uint16_t EDIV;
uint8_t RANDOM[BLE_ENC_RANDOM_SIZE];
uint8_t LTK[BLE_LTK_SIZE];
uint8_t IRK[BLE_IRK_SIZE];
uint8_t bonded;
} BleDeviceinfo;
typedef struct {
uint32_t saved_list_num;
BLE_BASIC_INFO_T self_info;
BleDeviceinfo ble_nv[BLE_RECORD_NUM];
} NV_RECORD_PAIRED_BLE_DEV_INFO_T;
#ifdef TWS_SYSTEM_ENABLED
typedef struct {
BLE_BASIC_INFO_T ble_info;
} TWS_INFO_T;
#endif // #ifdef TWS_SYSTEM_ENABLED
#ifdef GFPS_ENABLED
typedef struct {
uint8_t key[FP_ACCOUNT_KEY_SIZE];
} NV_FP_ACCOUNT_KEY_ENTRY_T;
typedef struct {
uint32_t key_count;
NV_FP_ACCOUNT_KEY_ENTRY_T accountKey[FP_ACCOUNT_KEY_RECORD_NUM];
uint16_t nameLen;
uint8_t name[FP_MAX_NAME_LEN];
} NV_FP_ACCOUNT_KEY_RECORD_T;
#endif // #ifdef GFPS_ENABLED
#ifdef NVREC_BAIDU_DATA_SECTION
/* DMA owned configuration information */
typedef struct {
int32_t fmfreq;
char rand[BAIDU_DATA_RAND_LEN + 1];
} NV_DMA_CONFIGURATION_T;
#endif // #ifdef NVREC_BAIDU_DATA_SECTION
#ifdef TGENIE_MESH_DATA_SECTION
#define NETKEY_MAX_NUM 2
#define APPKEY_MAX_NUM 10
#define GROUP_MAX_CNT 10
#define GENIE_TIME_CNT 40
#define GENIE_TIME_SIZE 4
/* MESH data information */
typedef struct{
uint8_t def_trans;
#ifdef CONFIG_MESH_MODEL_GEN_ONOFF_SRV
uint8_t default_onoff;
uint8_t last_onoff;
#endif
uint8_t range_status;
#ifdef CONFIG_MESH_MODEL_GEN_LEVEL_SRV
int16_t default_level;
int16_t last_level;
#endif
uint16_t default_actual;
uint16_t last_actual;
uint16_t min_actual;
uint16_t max_actual;
//temp
uint16_t default_temp;
uint16_t last_temp;
uint16_t min_temp;
uint16_t max_temp;
//uint16_t default_UV;
//uint16_t last_UV;
#if 0
//hue
uint16_t default_hue;
uint16_t last_hue;
uint16_t min_hue;
uint16_t max_hue;
//sat
uint16_t default_sat;
uint16_t last_sat;
uint16_t min_sat;
uint16_t max_sat;
#endif
} MESH_POWERUP;
typedef struct
{
uint8_t appkey[APPKEY_MAX_NUM][16];
uint8_t netkey[NETKEY_MAX_NUM][16];
uint16_t group[GROUP_MAX_CNT];
}CONFIG_STATUS;
typedef struct
{
uint32_t duration;
uint32_t times;
}MESH_IND;
typedef struct
{
uint16_t period_time;
uint8_t retry_delay;
uint8_t retry_times;
}TIME_ADJUST;
typedef struct
{
uint32_t time;
uint16_t attr_type;
uint8_t attr_param;
uint8_t rsv;
}TIMER_SETTING;
typedef struct
{
uint16_t h24_time;
uint8_t schedule;
uint8_t rsv1;
uint16_t attr_type;
uint8_t attr_param;
uint8_t rsv2;
}PERIOD_TIMER_SETTING;
typedef struct
{
union
{
TIMER_SETTING timer;
PERIOD_TIMER_SETTING period_timer;
}t;
//bit1,bit0, timer type
//00'b- not set;
//01'b, timer set,
//10'b, period timer set.
//bit7, bit6,// use status
//01'b, in use, not time out
//10'b, in use, time out.
uint8_t flag;
uint32_t timer_cur_time;//system seconds.
uint32_t timer_cur_unix_time;//unix seconds.
}VENDOR_TIMER;
typedef struct
{
uint32_t unix_time;
uint32_t cur_time;//system seconds.
//bit 0, for unix time;
//bit 1, for time adjust set.
//bit 2, for time zone.
//bit 3, for time update
uint16_t set_flag;
int8_t time_zone;
uint8_t used_timer_num;
TIME_ADJUST time_adjust;
VENDOR_TIMER timer[GENIE_TIME_CNT];
}MESH_TIME_SCENE;
typedef struct
{
uint16_t addr;//unicast address
uint8_t times;//valid onoff times, for mode (5 times for factory mode)
uint8_t network_id;
uint32_t seq_number;//this should not be removed after node reset.
MESH_POWERUP light_st;
MESH_TIME_SCENE time_scene;
uint8_t mesh_data[600];//more than sizeof(struct bt_mesh_net);
} NV_MESH_DATA_T;
#endif
#if TILE_DATAPATH
typedef struct {
uint8_t tileInfo[TILE_INFO_SIZE];
} NV_TILE_INFO_CONFIG_T;
#endif
#if defined(GSOUND_OTA_ENABLED)&&defined(VOICE_DATAPATH)
typedef struct {
uint8_t isGsoundEnabled;
uint8_t gsoundOtaStatus;
uint32_t gsoundOtaOffset;
uint32_t gsoundOtaImageSize;
uint8_t gsoundOtaSessionString[16];
} NV_GSOUND_INFO_T;
#endif
typedef struct {
NVRECORD_HEADER_T header;
struct nvrecord_env_t system_info;
NV_RECORD_PAIRED_BT_DEV_INFO_T bt_pair_info;
NV_RECORD_PAIRED_BLE_DEV_INFO_T ble_pair_info;
#ifdef TWS_SYSTEM_ENABLED
TWS_INFO_T tws_info;
#endif
#ifdef GFPS_ENABLED
NV_FP_ACCOUNT_KEY_RECORD_T fp_account_key_rec;
#endif
#ifdef NVREC_BAIDU_DATA_SECTION
NV_DMA_CONFIGURATION_T dma_config;
#endif
#ifdef TILE_DATAPATH
NV_TILE_INFO_CONFIG_T tileConfig;
#endif
#if defined(GSOUND_OTA_ENABLED)&&defined(VOICE_DATAPATH)
NV_GSOUND_INFO_T gsound_info;
#endif
#ifdef TX_IQ_CAL
BT_IQ_CALIBRATION_CONFIG_T btIqCalConfig;
#endif
#ifdef TGENIE_MESH_DATA_SECTION
NV_MESH_DATA_T mesh_config;
#endif
nvrec_wifidevicerecord wifi_info;
// TODO: If wanna OTA to update the nv record, two choices:
// 1. Change above data structures and increase NV_EXTENSION_MAJOR_VERSION.
// Then the nv record will be rebuilt and the whole history information will be cleared
// 2. Don't touch above data structures but just add new items here and increase NV_EXTENSION_MINOR_VERSION.
// Then the nv record will keep all the whole hisotry.
} NV_EXTENSION_RECORD_T;
#ifdef __cplusplus
extern "C" {
#endif
extern NV_EXTENSION_RECORD_T *nvrecord_extension_p;
int nv_record_env_init(void);
NV_EXTENSION_RECORD_T *nv_record_get_extension_entry_ptr(void);
void nv_record_extension_update(void);
void nv_extension_callback(void *param);
int nv_record_touch_cause_flush(void);
void nv_record_sector_clear(void);
void nv_record_flash_flush(void);
int nv_record_flash_flush_in_sleep(void);
void nv_record_update_runtime_userdata(void);
void nv_record_rebuild(void);
uint32_t nv_record_pre_write_operation(void);
void nv_record_post_write_operation(uint32_t lock);
bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id);
void nv_record_init(void);
#ifdef __cplusplus
}
#endif
#endif
#endif //#if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_extension.h
|
C
|
apache-2.0
| 10,971
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#ifdef GFPS_ENABLED
#ifndef __NVRECORD_FP_ACCOUNT_KEY_H__
#define __NVRECORD_FP_ACCOUNT_KEY_H__
#include "nvrecord_extension.h"
#ifdef __cplusplus
extern "C" {
#endif
void nv_record_fp_account_key_add(NV_FP_ACCOUNT_KEY_ENTRY_T* param_rec);
void nv_record_fp_account_key_delete();
void nv_record_fp_account_key_init(void);
bool nv_record_fp_account_key_get_by_index(uint8_t index, uint8_t* outputKey);
uint8_t nv_record_fp_account_key_count(void);
void nvrecord_rebuild_fp_account_key(NV_FP_ACCOUNT_KEY_RECORD_T* pFpAccountKey);
void nv_record_fp_update_name(uint8_t* ptrName, uint32_t nameLen);
uint8_t* nv_record_fp_get_name_ptr(uint32_t* ptrNameLen);
NV_FP_ACCOUNT_KEY_RECORD_T* nv_record_get_fp_data_structure_info(void);
void nv_record_update_fp_data_structure(NV_FP_ACCOUNT_KEY_RECORD_T* pFpData);
void nv_record_fp_update_all(uint8_t *info);
#ifdef __cplusplus
}
#endif
#endif
#endif
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_fp_account_key.h
|
C
|
apache-2.0
| 1,630
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(NEW_NV_RECORD_ENALBED)
#if defined(TGENIE_MESH_DATA_SECTION)
#ifndef __NVRECORD_MESH_DATA_H__
#define __NVRECORD_MESH_DATA_H__
#include "nvrecord_extension.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
GENIE_FLASH_SUCCESS,
GENIE_FLASH_FAIL,
}GENIE_STATUS;
GENIE_STATUS nvrecord_mesh_data_init(void);
GENIE_STATUS nvrecord_reset_mesh_configuration(void);
GENIE_STATUS nvrecord_get_onoff_times(uint8_t* times);
GENIE_STATUS nvrecord_set_onoff_times(uint8_t times);
GENIE_STATUS nvrecord_rebuild_mesh_configuration(NV_MESH_DATA_T* pMeshData);
GENIE_STATUS nvrecord_get_onoff_status(uint8_t* onoff);
GENIE_STATUS nvrecord_set_onoff_status(uint8_t onoff);
GENIE_STATUS nvrecord_get_lightness(uint16_t* lightness);
GENIE_STATUS nvrecord_set_lightness(uint16_t lightness);
GENIE_STATUS nvrecord_get_addr(uint16_t* addr);
GENIE_STATUS nvrecord_set_addr(uint16_t addr);
GENIE_STATUS nvrecord_get_seq(uint32_t* seq);
GENIE_STATUS nvrecord_set_seq(uint32_t seq);
GENIE_STATUS nvrecord_get_light_powerup(MESH_POWERUP* powerup);
GENIE_STATUS nvrecord_set_light_powerup(MESH_POWERUP* powerup);
GENIE_STATUS nvrecord_get_mesh_param(uint8_t* mesh_data,uint32_t len);
GENIE_STATUS nvrecord_set_mesh_param(uint8_t* mesh_data,uint32_t len);
GENIE_STATUS nvrecord_get_time_scene(MESH_TIME_SCENE* time_scene,uint32_t len);
GENIE_STATUS nvrecord_set_time_scene(MESH_TIME_SCENE* time_scene,uint32_t len);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if defined(TGENIE_MESH_DATA_SECTION)
#endif // #if defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_mesh_data.h
|
C
|
apache-2.0
| 2,205
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __NVRECORD_OTA_H__
#define __NVRECORD_OTA_H__
#ifdef __cplusplus
extern "C"{
#endif
/*****************************header include********************************/
#include "nvrecord_extension.h"
/******************************macro defination*****************************/
/******************************type defination******************************/
/****************************function declearation**************************/
#if defined(GSOUND_OTA_ENABLED)&&defined(VOICE_DATAPATH)
void nv_record_otarec_init(void);
void nv_record_otarec_get_ptr(void **ptr);
void nv_record_extension_update_gsound_ota_session(uint8_t gsoundOtaStatus,
uint32_t totalImageSize,
const char *session);
void nv_record_extension_update_gsound_ota_progress(uint32_t otaOffset);
void nv_record_extension_update_gsound_info(NV_GSOUND_INFO_T* gsoundInfo);
#endif
#ifdef __cplusplus
}
#endif
#endif /* #ifndef __NVRECORD_OTA_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_ota.h
|
C
|
apache-2.0
| 1,679
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _NVRECORD_WIFI_H
#define _NVRECORD_WIFI_H
#ifdef __cplusplus
extern "C" {
#endif
#include "plat_types.h"
#include "../../net/bwifi_sta.h"
#include "../../net/net_defs.h"
#include "../../net/net_debug.h"
#define WIFI_RECORD_TYPE_SIZE (3+1)
enum config_type {
BWIFI_RECORD_TYPE_VOL = BIT(1),
BWIFI_RECORD_QUICK_CON = BIT(2),
BWIFI_RECORD_TYPE_BW = BIT(4),
BWIFI_RECORD_TYPE_CTRY = BIT(5),
WIFI_RECORD_CONF_NUM0 = BIT(6),
WIFI_RECORD_CONF_NUM1 = BIT(7),
WIFI_RECORD_CONF_NUM2 = BIT(8),
WIFI_RECORD_CONF_NUM3 = BIT(9),
WIFI_RECORD_CONF_MAX = WIFI_RECORD_CONF_NUM3*2,
};
enum wifi_status {
WIFI_STS_SUCCESS = 0,
WIFI_STS_FAILED = 1,
};
typedef struct wifi_volume{
int8_t a2dp_vol;
int8_t hfp_vol;
}wifi_volume;
#ifndef PMK_LEN
#define PMK_LEN 32
#endif
struct nvrec_wifi_station_data {
struct bwifi_station_config config;
u8 pmk[PMK_LEN];
int pmk_set;
};
struct wifi_record_info {
uint32_t conf_bit_map;
struct nvrec_wifi_station_data sta_data;
struct nvrec_wifi_station_data sta_data1;
struct nvrec_wifi_station_data sta_data2;
struct nvrec_wifi_station_data sta_data3;
struct bwifi_quick_connect_config quick_config;
wifi_volume volume;
char band; //0:2.4 1:5 2:dual band
char country[3];
};
typedef struct _nvrec_wifidevicerecord
{
char type[WIFI_RECORD_TYPE_SIZE];
struct wifi_record_info wifi_record;
} nvrec_wifidevicerecord;
#define BWIFI_RECORD_TYPE_VOLUME "vol"
#define BWIFI_RECORD_TYPE_CFG(n) ("cf"#n)
#define BWIFI_RECORD_QUICK_CONNECT "qcn"
#define BWIFI_RECORD_TYPE_BAND "bnd"
#define BWIFI_RECORD_TYPE_COUNTRY "cny"
#define WIFI_CONF_RECORD_NUM 4
static inline const char *_conf_id_2_type(u32 conf_id)
{
switch (conf_id) {
case 0:
return BWIFI_RECORD_TYPE_CFG(0);
case 1:
return BWIFI_RECORD_TYPE_CFG(1);
case 2:
return BWIFI_RECORD_TYPE_CFG(2);
case 3:
return BWIFI_RECORD_TYPE_CFG(3);
case 4:
return BWIFI_RECORD_TYPE_CFG(4);
case 5:
return BWIFI_RECORD_TYPE_CFG(5);
case 6:
return BWIFI_RECORD_TYPE_CFG(6);
case 7:
return BWIFI_RECORD_TYPE_CFG(7);
default:
return "err";
}
}
static inline int bwifi_unknown_record_type(const char *type)
{
int i;
if (strcmp(type, BWIFI_RECORD_TYPE_VOLUME) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_QUICK_CONNECT) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_TYPE_BAND) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_TYPE_COUNTRY) == 0)
return 0;
for (i=0; i<WIFI_CONF_RECORD_NUM; ++i)
if (strcmp(type, _conf_id_2_type(i)) == 0)
return 0;
return 1;
}
static inline int bwifi_find_record_type(const char *type)
{
int i;
if (strcmp(type, BWIFI_RECORD_TYPE_VOLUME) == 0)
return BWIFI_RECORD_TYPE_VOL;
if (strcmp(type, BWIFI_RECORD_QUICK_CONNECT) == 0)
return BWIFI_RECORD_QUICK_CON;
if (strcmp(type, BWIFI_RECORD_TYPE_BAND) == 0)
return BWIFI_RECORD_TYPE_BW;
if (strcmp(type, BWIFI_RECORD_TYPE_COUNTRY) == 0)
return BWIFI_RECORD_TYPE_CTRY;
for (i = 0; i < WIFI_CONF_RECORD_NUM; i ++) {
if (strcmp(type, _conf_id_2_type(i)) == 0) {
switch (i) {
case 0:
return WIFI_RECORD_CONF_NUM0;
case 1:
return WIFI_RECORD_CONF_NUM1;
case 2:
return WIFI_RECORD_CONF_NUM2;
case 3:
return WIFI_RECORD_CONF_NUM3;
}
}
}
return 0;
}
void nv_record_wifirec_debug(void);
void nv_record_rebuild_wifi_env(nvrec_wifidevicerecord* pWifiEnv);
int nv_record_wifirec_find(const char *type, nvrec_wifidevicerecord *record);
int nv_record_wifirec_delete(const char *type);
int nv_record_wifirec_add(const nvrec_wifidevicerecord *record);
int config_entries_wifidev_delete_head_cfg(void);
void nv_record_flash_flush(void);
#ifdef __cplusplus
}
#endif
#endif /*_NVRECORD_WIFI_H*/
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nv_section/userdata_section/nvrecord_wifi.h
|
C
|
apache-2.0
| 4,516
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifndef __LIST_H__
#define __LIST_H__
#include <stdbool.h>
#include <stdlib.h>
#include "heap_api.h"
#ifdef __cplusplus
extern "C" {
#endif
extern heap_handle_t g_nv_mempool;
#define pool_malloc(size) heap_malloc(g_nv_mempool,size)
#define pool_free(ptr) heap_free(g_nv_mempool,ptr)
#define pool_free_space() heap_free_size(g_nv_mempool)
typedef void (*list_free_cb)(void *data);
typedef bool (*list_iter_cb)(void *data);
typedef struct list_node_t {
struct list_node_t *next;
void *data;
} list_node_t;
typedef struct list_t {
list_node_t *head;
list_node_t *tail;
size_t length;
list_free_cb free_cb;
} list_t;
//struct list_t;
typedef struct list_t list_t;
void *zmalloc_ext (size_t size);
// Lifecycle.
list_t *list_new_ext(list_free_cb callback);
void list_free_ext(list_t *list);
// Accessors.
bool list_is_empty_ext(const list_t *list);
size_t list_length_ext(const list_t *list);
void *list_front_ext(const list_t *list);
void *list_back_ext(const list_t *list);
// Mutators.
bool list_insert_after_ext(list_t *list, list_node_t *prev_node, void *data);
bool list_prepend_ext(list_t *list, void *data);
bool list_append_ext(list_t *list, void *data);
bool list_remove_ext(list_t *list, void *data);
void list_clear_ext(list_t *list);
// Iteration.
void list_foreach_ext(const list_t *list, list_iter_cb callback);
list_node_t *list_begin_ext(const list_t *list);
list_node_t *list_end_ext(const list_t *list);
list_node_t *list_next_ext(const list_node_t *node);
void *list_node_ext(const list_node_t *node);
#ifdef __cplusplus
}
#endif
#endif//__FMDEC_H__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/list_ext.h
|
C
|
apache-2.0
| 2,270
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OSI_CONFIG_H__
#define __OSI_CONFIG_H__
// This module implements a configuration parser. Clients can query the
// contents of a configuration file through the interface provided here.
// The current implementation is read-only; mutations are only kept in
// memory. This parser supports the INI file format.
// Implementation notes:
// - Key/value pairs that are not within a section are assumed to be under
// the |CONFIG_DEFAULT_SECTION| section.
// - Multiple sections with the same name will be merged as if they were in
// a single section.
// - Empty sections with no key/value pairs will be treated as if they do
// not exist. In other words, |nvrec_config_has_section| will return false for
// empty sections.
// - Duplicate keys in a section will overwrite previous values.
#include <stdbool.h>
#include "list_ext.h"
// The default section name to use if a key/value pair is not defined within
// a section.
#define CONFIG_DEFAULT_SECTION "Global"
typedef struct {
char *key;
char *value;
} nvrec_entry_t;
typedef struct {
char *name;
list_t *entries;
} nvrec_section_t;
typedef struct nvrec_config {
list_t *sections;
}nvrec_config_t;
// Loads the specified file and returns a handle to the config file. If there
// was a problem loading the file or allocating memory, this function returns
// NULL. Clients must call |nvrec_config_free| on the returned handle when it is no
// longer required. |filename| must not be NULL and must point to a readable
// file on the filesystem.
nvrec_config_t *nvrec_config_new(const char *filename);
// Frees resources associated with the config file. No further operations may
// be performed on the |config| object after calling this function. |config|
// may be NULL.
void nvrec_config_free(nvrec_config_t *config);
// Returns true if the config file contains a section named |section|. If
// the section has no key/value pairs in it, this function will return false.
// |config| and |section| must not be NULL.
bool nvrec_config_has_section(const nvrec_config_t *config, const char *section);
// Returns true if the config file has a key named |key| under |section|.
// Returns false otherwise. |config|, |section|, and |key| must not be NULL.
bool nvrec_config_has_key(const nvrec_config_t *config, const char *section, const char *key);
// Returns the integral value for a given |key| in |section|. If |section|
// or |key| do not exist, or the value cannot be fully converted to an integer,
// this function returns |def_value|. |config|, |section|, and |key| must not
// be NULL.
int nvrec_config_get_int(const nvrec_config_t *config, const char *section, const char *key, int def_value);
// Returns the boolean value for a given |key| in |section|. If |section|
// or |key| do not exist, or the value cannot be converted to a boolean, this
// function returns |def_value|. |config|, |section|, and |key| must not be NULL.
bool nvrec_config_get_bool(const nvrec_config_t *config, const char *section, const char *key, bool def_value);
// Returns the string value for a given |key| in |section|. If |section| or
// |key| do not exist, this function returns |def_value|. The returned string
// is owned by the config module and must not be freed. |config|, |section|,
// and |key| must not be NULL. |def_value| may be NULL.
const char *nvrec_config_get_string(const nvrec_config_t *config, const char *section, const char *key, const char *def_value);
// Sets an integral value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, and |key|
// must not be NULL.
void nvrec_config_set_int(nvrec_config_t *config, const char *section, const char *key, int value);
// Sets a boolean value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, and |key|
// must not be NULL.
void nvrec_config_set_bool(nvrec_config_t *config, const char *section, const char *key, bool value);
// Sets a string value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, |key|, and
// |value| must not be NULL.
void nvrec_config_set_string(nvrec_config_t *config, const char *section, const char *key, const char *value);
nvrec_section_t *nvrec_section_find(const nvrec_config_t *config, const char *section);
void nvrec_entry_free(void *ptr);
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrec_config.h
|
C
|
apache-2.0
| 5,088
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __NVRECORD_H__
#define __NVRECORD_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <string.h>
#include "cmsis.h"
#include "nvrec_config.h"
#include "bluetooth.h"
#include "me_api.h"
#include "hal_trace.h"
#if defined(NEW_NV_RECORD_ENALBED)
#include "nvrecord_extension.h"
#include "nvrecord_bt.h"
#include "nvrecord_env.h"
#include "nvrecord_ble.h"
#include "nvrecord_dma_config.h"
#include "nvrecord_fp_account_key.h"
#define nvdev_tag "nvdev_tag"
#else
#define DDB_RECORD_NUM 9
#define section_name_ddbrec "ddbrec"
#define nvrecord_mem_pool_size 4096
#define nvrecord_tag "nvrecord"
#define nvdev_tag "nvdev_tag"
#define section_name_other "other"
/*
version|magic 16bit|16bit 0001 cb91
crc 32bit
reserve[0] 32bit
reserve[1] 32bit
config_addr 32bit
heap_contents 32bit
mempool ...
*/
#define nvrecord_struct_version 8
#define nvrecord_magic 0xcb91
typedef enum
{
pos_version_and_magic,// 0
pos_crc, // 1
pos_start_ram_addr, // 2
pos_reserv2, // 3
pos_config_addr, // 4
pos_heap_contents, // 5
}nvrec_mempool_pre_enum;
#define mempool_pre_offset (1+pos_config_addr+((sizeof(heap_handle_t)/sizeof(uint32_t))+1))
typedef enum
{
NV_STATE_IDLE,
NV_STATE_MAIN_ERASING,
NV_STATE_MAIN_ERASED,
NV_STATE_MAIN_WRITTING,
NV_STATE_MAIN_WRITTEN,
NV_STATE_MAIN_DONE,
NV_STATE_BAK_ERASING,
NV_STATE_BAK_ERASED,
NV_STATE_BAK_WRITTING,
NV_STATE_BAK_WRITTEN,
NV_STATE_BAK_DONE,
}NV_STATE;
typedef struct
{
bool is_update;
NV_STATE state;
uint32_t written_size;
nvrec_config_t *config;
}nv_record_struct;
typedef enum
{
section_usrdata_ddbrecord,
section_none
}SECTIONS_ADP_ENUM;
typedef struct btdevice_volume{
int8_t a2dp_vol;
int8_t hfp_vol;
}btdevice_volume;
typedef struct btdevice_profile{
bool hfp_act;
bool hsp_act;
bool a2dp_act;
uint8_t a2dp_codectype;
}btdevice_profile;
typedef struct _nvrec_btdevicerecord
{
btif_device_record_t record;
btdevice_volume device_vol;
btdevice_profile device_plf;
} nvrec_btdevicerecord;
extern uint8_t nv_record_dev_rev;
void nv_record_init(void);
bt_status_t nv_record_open(SECTIONS_ADP_ENUM section_id);
bt_status_t nv_record_enum_dev_records(unsigned short index,btif_device_record_t* record);
bt_status_t nv_record_add(SECTIONS_ADP_ENUM type,void *record);
bt_status_t nv_record_ddbrec_find(const bt_bdaddr_t *bd_ddr, btif_device_record_t*record);
bt_status_t nv_record_ddbrec_delete(const bt_bdaddr_t *bdaddr);
int nv_record_btdevicerecord_find(const bt_bdaddr_t *bd_ddr, nvrec_btdevicerecord **record);
int nv_record_touch_cause_flush(void);
int nv_record_get_paired_dev_count(void);
void nv_record_sector_clear(void);
void nv_record_flash_flush(void);
int nv_record_flash_flush_in_sleep(void);
int nv_record_enum_latest_two_paired_dev(btif_device_record_t* record1,btif_device_record_t* record2);
void nv_record_all_ddbrec_print(void);
void nv_record_update_runtime_userdata(void);
bt_status_t nv_record_config_rebuild(void);
void nv_record_btdevicerecord_set_a2dp_vol(nvrec_btdevicerecord* pRecord, int8_t vol);
void nv_record_btdevicerecord_set_hfp_vol(nvrec_btdevicerecord* pRecord, int8_t vol);
void nv_record_btdevicevolume_set_a2dp_vol(btdevice_volume* device_vol, int8_t vol);
void nv_record_btdevicevolume_set_hfp_vol(btdevice_volume* device_vol, int8_t vol);
void nv_record_btdevicerecord_set_a2dp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_hfp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_hsp_profile_active_state(btdevice_profile* device_plf, bool isActive);
void nv_record_btdevicerecord_set_a2dp_profile_codec(btdevice_profile* device_plf, uint8_t a2dpCodec);
#ifdef NVREC_BAIDU_DATA_SECTION
#define BAIDU_DATA_SECTIN ("baidu_data")
#define BAIDU_DATA_FM_KEY ("fmfreq")
#define BAIDU_DATA_RAND_KEY ("rand")
#define BAIDU_DATA_DEF_RAND "abcdefghi"
int nvrec_baidu_data_init(void);
int nvrec_get_fm_freq(void);
int nvrec_set_fm_freq(int fmfreq);
int nvrec_get_rand(char *rand);
int nvrec_set_rand(char *rand);
int nvrec_clear_rand(void);
int nvrec_dev_get_sn(char *sn);
#endif
uint32_t nv_record_pre_write_operation(void);
void nv_record_post_write_operation(uint32_t lock);
#include "nvrecord_wifi.h"
#endif // #if !defined(NEW_NV_RECORD_ENALBED)
//#define nv_record_debug
#ifdef nv_record_debug
#define nvrec_trace TRACE
#else
#define nvrec_trace(...)
#endif
#define NVREC_DEV_NEWEST_REV 2
#define NVREC_DEV_VERSION_1 1
#define BLE_NAME_LEN_IN_NV 32
/*
this is the nvrec dev zone struct :
version|magic 16bit|16bit
crc 32bit
reserve[0] 32bit
reserv[1] 32bit
dev local name max 249*8bit
dev bt addr 64bit
dev ble addr 64bit
calib data 32bit
*/
#define nvrec_dev_version 1
#define nvrec_dev_magic 0xba80
typedef enum
{
dev_version_and_magic, //0
dev_crc, //1
dev_reserv1, //2
dev_reserv2, //3
dev_name, //[4~66]
dev_bt_addr = 67, //[67~68]
dev_ble_addr = 69, //[69~70]
dev_dongle_addr = 71,
dev_xtal_fcap = 73, //73
dev_data_len,
}nvrec_dev_enum;
// following the former nv rec dev info
typedef enum
{
rev2_dev_data_len = 75, //75, length of the valid content, excluding crc
rev2_dev_crc, //76, crc value of the following data
rev2_dev_section_start_reserved, //77
rev2_dev_reserv2, //78
rev2_dev_name, //[79~141]
rev2_dev_bt_addr = 142, //[142~143]
rev2_dev_ble_addr = 144, //[144~145]
rev2_dev_dongle_addr = 146, //[146~147]
rev2_dev_xtal_fcap = 148, //148
rev2_dev_ble_name = 149, //[149~156]
#ifdef NVREC_BAIDU_DATA_SECTION
rev2_dev_prod_sn = 157, //[157~160]
#endif
// TODO: add the new section in the future if needed
rev2_dev_section_end = 157,
}nvrec_dev_rev_2_enum;
int nvrec_dev_get_dongleaddr(bt_bdaddr_t *dongleaddr);
int nvrec_dev_get_btaddr(char *btaddr);
char* nvrec_dev_get_bt_name(void);
const char* nvrec_dev_get_ble_name(void);
size_t nv_record_get_bt_records_num(void);
#ifdef __cplusplus
}
#endif
#endif /* __NVRECORD_H__*/
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrecord.h
|
C
|
apache-2.0
| 7,385
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_BLE_H
#define NVRECORD_BLE_H
#define BLE_RECORD_NUM 5
#define section_name_ble_nvds "blenvds"
#define NV_RECORD_BLE_KEY "ble_key"
#define NVRAM_BLE_INVALID (0xfae66666)
#define BLE_ADDR_SIZE 6
#define BLE_ENC_RANDOM_SIZE 8
#define BLE_LTK_SIZE 16
#define BLE_IRK_SIZE 16
#define BLE_STATIC_ADDR 0
#define BLE_RANDOM_ADDR 1
typedef struct _BleDeviceRecord {
uint8_t peer_bleAddr[BLE_ADDR_SIZE];
uint16_t EDIV;
uint8_t RANDOM[BLE_ENC_RANDOM_SIZE];
uint8_t LTK[BLE_LTK_SIZE];
uint8_t IRK[BLE_IRK_SIZE];
uint8_t bonded;
} BleDeviceinfo;
struct Ble_nvrecord {
uint8_t loc_irk[BLE_IRK_SIZE];
uint8_t saved_list_num;
BleDeviceinfo ble_nv[BLE_RECORD_NUM];
};
#ifdef __cplusplus
extern "C" {
#endif
int nv_record_blerec_add(const BleDeviceinfo *param_rec);
bool nv_record_ble_record_find_ltk_through_static_bd_addr(uint8_t *pBdAddr, uint8_t *ltk);
bool nv_record_ble_record_Once_a_device_has_been_bonded(void);
void nv_record_ble_delete_entry(uint8_t *pBdAddr);
uint8_t nv_record_ble_fill_irk(uint8_t *ltkToFill);
void nv_record_blerec_init(void);
void nv_record_blerec_get_local_irk(uint8_t *pIrk);
bool nv_record_blerec_get_bd_addr_from_irk(uint8_t *pBdAddr, uint8_t *pIrk);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if !defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrecord_ble.h
|
C
|
apache-2.0
| 2,001
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NVRECORD_DEV_H
#define NVRECORD_DEV_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
unsigned char *btd_addr;
unsigned char *ble_addr;
const char *localname;
const char *ble_name;
}dev_addr_name;
bool nvrec_dev_data_open(void);
bool nvrec_dev_localname_addr_init(dev_addr_name *dev);
int nvrec_dev_force_get_btaddress(unsigned char *btd_addr);
void nvrec_dev_flash_flush(unsigned char *mempool);
void nvrec_dev_rand_btaddr_gen(uint8_t* bdaddr);
void nvrec_dev_set_xtal_fcap(unsigned int xtal_fcap);
int nvrec_dev_get_xtal_fcap(unsigned int *xtal_fcap);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrecord_dev.h
|
C
|
apache-2.0
| 1,272
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(NEW_NV_RECORD_ENALBED)
#ifndef NVRECORD_ENV_H
#define NVRECORD_ENV_H
#ifdef __cplusplus
extern "C" {
#endif
#include "me_api.h"
#define NVRAM_ENV_INVALID (0xdead0000)
#define NVRAM_ENV_MEDIA_LANGUAGE_DEFAULT (0)
#define NVRAM_ENV_STREAM_VOLUME_A2DP_VOL_DEFAULT (AUDIO_OUTPUT_VOLUME_DEFAULT)
#define NVRAM_ENV_STREAM_VOLUME_HFP_VOL_DEFAULT (AUDIO_OUTPUT_VOLUME_DEFAULT)
#define NVRAM_ENV_TWS_MODE_DEFAULT (0xff)
#define NVRAM_ENV_FACTORY_TESTER_STATUS_DEFAULT (0xaabbccdd)
struct media_language_t
{
int8_t language;
};
#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE)
struct src_snk_t
{
int8_t src_snk_mode;
};
#endif
struct ibrt_mode_t
{
uint32_t mode;
btif_device_record_t record;
bool tws_connect_success;
};
struct factory_tester_status_t
{
uint32_t status;
};
#ifdef IS_MULTI_AI_ENABLED
typedef struct
{
bool voice_key_enable;
uint8_t setedCurrentAi;
uint8_t currentAiSpec;
uint8_t aiStatusDisableFlag;
uint8_t amaAssistantEnableStatus; //one bit for one AI assistant
} AI_MANAGER_INFO_T;
#endif
struct nvrecord_env_t
{
struct media_language_t media_language;
#if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE)
struct src_snk_t src_snk_flag;
#endif
struct ibrt_mode_t ibrt_mode;
struct factory_tester_status_t factory_tester_status;
#if defined(__TENCENT_VOICE__)
uint8_t flag_value[8];
#endif
#ifdef IS_MULTI_AI_ENABLED
AI_MANAGER_INFO_T aiManagerInfo;
#endif
};
int nv_record_env_init(void);
int nv_record_env_get(struct nvrecord_env_t **nvrecord_env);
int nv_record_env_set(struct nvrecord_env_t *nvrecord_env);
void nv_record_update_ibrt_info(uint32_t newMode,bt_bdaddr_t *ibrtPeerAddr);
void nv_record_update_factory_tester_status(uint32_t status);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if !defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrecord_env.h
|
C
|
apache-2.0
| 2,532
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(NEW_NV_RECORD_ENALBED)
#ifndef __NVRECORD_FP_ACCOUNT_KEY_H__
#define __NVRECORD_FP_ACCOUNT_KEY_H__
#define FP_ACCOUNT_KEY_RECORD_NUM 5
#define section_name_fp_account_key "fpaccountkey"
#define NV_RECORD_ACCOUNT_KEY "account_key"
#define NVRAM_ACCOUNT_KEY_INVALID (0xFFFFFFFF)
#define FP_ACCOUNT_KEY_SIZE 16
#define FP_MAX_NAME_LEN 64
typedef struct
{
uint8_t key[FP_ACCOUNT_KEY_SIZE];
} NV_FP_ACCOUNT_KEY_ENTRY_T;
typedef struct
{
uint8_t key_count;
NV_FP_ACCOUNT_KEY_ENTRY_T accountKey[FP_ACCOUNT_KEY_RECORD_NUM];
uint16_t nameLen;
uint8_t name[FP_MAX_NAME_LEN];
} NV_FP_ACCOUNT_KEY_RECORD_T;
#ifdef __cplusplus
extern "C" {
#endif
void nv_record_fp_account_key_add(NV_FP_ACCOUNT_KEY_ENTRY_T* param_rec);
void nv_record_fp_account_key_delete();
void nv_record_fp_account_key_init(void);
bool nv_record_fp_account_key_get_by_index(uint8_t index, uint8_t* outputKey);
uint8_t nv_record_fp_account_key_count(void);
void nv_record_fp_update_name(uint8_t* ptrName, uint32_t nameLen);
uint8_t* nv_record_fp_get_name_ptr(uint32_t* ptrNameLen);
NV_FP_ACCOUNT_KEY_RECORD_T* nv_record_get_fp_data_structure_info(void);
void nv_record_update_fp_data_structure(NV_FP_ACCOUNT_KEY_RECORD_T* pFpData);
#ifdef __cplusplus
}
#endif
#endif
#endif // #if !defined(NEW_NV_RECORD_ENALBED)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrecord_fp_account_key.h
|
C
|
apache-2.0
| 2,111
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _NVRECORD_WIFI_H
#define _NVRECORD_WIFI_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../../net/bwifi_sta.h"
#define WIFI_RECORD_TYPE_SIZE (3+1)
typedef struct wifi_volume{
int8_t a2dp_vol;
int8_t hfp_vol;
}wifi_volume;
typedef struct _wifi_cal{
uint16 freq_cal;
uint16 freq_cal_5G;
uint32 iQ_cal;
uint32 iQ_offset;
uint32 iQ_cal_5G;
uint32 iQ_offset_5G;
uint16 tx_power[14];
uint16 tx_power_5G[5];
}wifi_cal;
#ifndef PMK_LEN
#define PMK_LEN 32
#endif
struct nvrec_wifi_station_data {
struct bwifi_station_config config;
u8 pmk[PMK_LEN];
int pmk_set;
};
typedef struct _nvrec_wifidevicerecord
{
char type[WIFI_RECORD_TYPE_SIZE];//"cf0","bnd","cny"
union {
//u32 conf_bit_map;
struct nvrec_wifi_station_data sta_data;
struct bwifi_quick_connect_config quick_config;
wifi_volume volume;
wifi_cal cal;
char band; //0:2.4 1:5 2:dual band
char country[3];
}wifi_record;
} nvrec_wifidevicerecord;
#define BWIFI_RECORD_TYPE_VOLUME "vol"
#define BWIFI_RECORD_TYPE_CFG(n) ("cf"#n)
#define BWIFI_RECORD_QUICK_CONNECT "qcn"
#define BWIFI_RECORD_TYPE_CAL "cal"
#define BWIFI_RECORD_TYPE_BAND "bnd"
#define BWIFI_RECORD_TYPE_COUNTRY "cny"
#define WIFI_CONF_RECORD_NUM 4
static inline const char *_conf_id_2_type(u32 conf_id)
{
switch (conf_id) {
case 0:
return BWIFI_RECORD_TYPE_CFG(0);
case 1:
return BWIFI_RECORD_TYPE_CFG(1);
case 2:
return BWIFI_RECORD_TYPE_CFG(2);
case 3:
return BWIFI_RECORD_TYPE_CFG(3);
case 4:
return BWIFI_RECORD_TYPE_CFG(4);
case 5:
return BWIFI_RECORD_TYPE_CFG(5);
case 6:
return BWIFI_RECORD_TYPE_CFG(6);
case 7:
return BWIFI_RECORD_TYPE_CFG(7);
default:
return "err";
}
}
static inline int bwifi_unknown_record_type(const char *type)
{
int i;
if (strcmp(type, BWIFI_RECORD_TYPE_VOLUME) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_QUICK_CONNECT) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_TYPE_CAL) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_TYPE_BAND) == 0)
return 0;
if (strcmp(type, BWIFI_RECORD_TYPE_COUNTRY) == 0)
return 0;
for (i=0; i<WIFI_CONF_RECORD_NUM; ++i)
if (strcmp(type, _conf_id_2_type(i)) == 0)
return 0;
return 1;
}
int nv_record_wifirec_find(const char *type, nvrec_wifidevicerecord *record);
int nv_record_wifirec_delete(const char *type);
int nv_record_wifirec_add(const nvrec_wifidevicerecord *record);
int config_entries_wifidev_delete_head_cfg(void);
void nv_record_flash_flush(void);
#ifdef __cplusplus
}
#endif
#endif /*_NVRECORD_WIFI_H*/
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/nvrecord/nvrecord_wifi.h
|
C
|
apache-2.0
| 3,223
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DDBIF_H__
#define __DDBIF_H__
#include "bluetooth.h"
#include "me_api.h"
void ddbif_list_saved_flash(void);
bt_status_t ddbif_close(void);
bt_status_t ddbif_add_record(btif_device_record_t *record);
bt_status_t ddbif_open(const bt_bdaddr_t *bdAddr);
bt_status_t ddbif_find_record(const bt_bdaddr_t *bdAddr, btif_device_record_t *record);
bt_status_t ddbif_delete_record(const bt_bdaddr_t *bdAddr);
bt_status_t ddbif_enum_device_records(I16 index, btif_device_record_t *record);
size_t ddbif_device_records_num(void);
#endif /*__DDBIF_H__*/
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/osif/ddbif.h
|
C
|
apache-2.0
| 1,211
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __OSIF_H__
#define __OSIF_H__
#include <stdint.h>
typedef uint32_t osif_timer_t;
typedef void (*osif_timer_callback)(void);
#if defined(__cplusplus)
extern "C" {
#endif
bool osif_init(void);
uint32_t osif_get_sys_time(void);
uint16_t osif_rand(void);
void osif_stop_hardware(void);
void osif_resume_hardware(void);
void osif_memcopy(uint8_t *dest, const uint8_t *source, uint32_t numBytes);
bool osif_memcmp(const uint8_t *buffer1, uint16_t len1, const uint8_t *buffer2, uint16_t len2);
void osif_memset(uint8_t *dest, uint8_t byte, uint32_t len);
uint8_t osif_strcmp(const char *Str1, const char *Str2);
uint16_t osif_strlen(const char *Str);
void osif_assert(const char *expression, const char *file, uint16_t line);
void osif_lock_stack(void);
void osif_unlock_stack(void);
void osif_notify_evm(void);
void osif_start_timer(osif_timer_t t, osif_timer_callback func);
void osif_cancel_timer(void);
uint8_t osif_lock_is_exist(void);
#if defined(__cplusplus)
}
#endif
#endif /*__OSIF_H__*/
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/osif/osif.h
|
C
|
apache-2.0
| 1,672
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __APP_OVERLAY_H__
#define __APP_OVERLAY_H__
#include "plat_types.h"
#include "hal_overlay.h"
#define app_overlay_load(id) hal_overlay_load((enum HAL_OVERLAY_ID_T)id)
#define app_overlay_unload(id) hal_overlay_unload((enum HAL_OVERLAY_ID_T)id)
#define app_overlay_get_text_size(id) hal_overlay_get_text_size((enum HAL_OVERLAY_ID_T)id)
#define app_overlay_get_text_all_size hal_overlay_get_text_all_size
#define app_overlay_get_text_address hal_overlay_get_text_address
#define app_overlay_get_text_free_size(id) hal_overlay_get_text_free_size((enum HAL_OVERLAY_ID_T)id)
#define app_overlay_get_text_free_addr(id) hal_overlay_get_text_free_addr((enum HAL_OVERLAY_ID_T)id)
//#define app_overlay_is_used hal_overlay_is_used
enum APP_OVERLAY_ID_T {
APP_OVERLAY_HFP = HAL_OVERLAY_ID_0,
APP_OVERLAY_A2DP = HAL_OVERLAY_ID_1,
APP_OVERLAY_FM = HAL_OVERLAY_ID_2,
APP_OVERLAY_AAC = HAL_OVERLAY_ID_3,
APP_OVERLAY_A2DP_AAC = HAL_OVERLAY_ID_4,
APP_OVERLAY_MPA = HAL_OVERLAY_ID_5,
#if defined(A2DP_SCALABLE_ON)
APP_OVERLAY_A2DP_SCALABLE= HAL_OVERLAY_ID_6,
#elif defined(A2DP_LHDC_ON)
APP_OVERLAY_A2DP_LHDC = HAL_OVERLAY_ID_6,
#elif defined(A2DP_LDAC_ON)
APP_OVERLAY_A2DP_LDAC = HAL_OVERLAY_ID_6,
#else
APP_OVERLAY_WAV = HAL_OVERLAY_ID_6,
#endif
#ifdef OPUS_IN_OVERLAY
APP_OVERLAY_OPUS = HAL_OVERLAY_ID_7,
#endif
APP_OVERLAY_ID_QTY = HAL_OVERLAY_ID_QTY,
APP_OVERLAY_ID_IN_CFG = HAL_OVERLAY_ID_IN_CFG,
};
#ifdef __cplusplus
extern "C" {
#endif
void app_overlay_select(enum APP_OVERLAY_ID_T id);
void app_overlay_unloadall(void);
void app_overlay_open(void);
void app_overlay_close(void);
enum APP_OVERLAY_ID_T app_get_current_overlay(void);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/overlay/app_overlay.h
|
C
|
apache-2.0
| 2,443
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __RESOURCES_H__
#define __RESOURCES_H__
#include "plat_types.h"
typedef enum {
AUD_ID_INVALID = -1,
AUD_ID_POWER_ON = 0x0,
AUD_ID_POWER_OFF,
AUD_ID_LANGUAGE_SWITCH,
AUD_ID_NUM_0,
AUD_ID_NUM_1,
AUD_ID_NUM_2,
AUD_ID_NUM_3,
AUD_ID_NUM_4,
AUD_ID_NUM_5,
AUD_ID_NUM_6,
AUD_ID_NUM_7,
AUD_ID_NUM_8,
AUD_ID_NUM_9,
AUD_ID_BT_PAIR_ENABLE,
AUD_ID_BT_PAIRING,
AUD_ID_BT_PAIRING_SUC,
AUD_ID_BT_PAIRING_FAIL,
AUD_ID_BT_CALL_REFUSE,
AUD_ID_BT_CALL_OVER,
AUD_ID_BT_CALL_ANSWER,
AUD_ID_BT_CALL_HUNG_UP,
AUD_ID_BT_CALL_INCOMING_CALL,
AUD_ID_BT_CALL_INCOMING_NUMBER,
AUD_ID_BT_CHARGE_PLEASE,
AUD_ID_BT_CHARGE_FINISH,
AUD_ID_BT_CLEAR_SUCCESS,
AUD_ID_BT_CLEAR_FAIL,
AUD_ID_BT_CONNECTED,
AUD_ID_BT_DIS_CONNECT,
AUD_ID_BT_WARNING,
AUDIO_ID_BT_ALEXA_START,
AUDIO_ID_BT_ALEXA_STOP,
AUDIO_ID_BT_GSOUND_MIC_OPEN,
AUDIO_ID_BT_GSOUND_MIC_CLOSE,
AUDIO_ID_BT_GSOUND_NC,
AUDIO_ID_BT_MUTE,
AUD_ID_RING_WARNING,
#ifdef __INTERACTION__
AUD_ID_BT_FINDME,
#endif
MAX_RECORD_NUM,
AUD_ID_ENUM_BOTTOM = 0x1001,
} AUD_ID_ENUM;
enum ENUM_RESOURCE_ID
{
RES_ENGLISH_ID = 0xFF00,
RES_CHINESE_ID = 0xFF01,
MAX_RES_LANGUAGE_ID
};
//typedef uint8_t UINT8;
//typedef uint16_t UINT16;
//typedef uint32_t UINT32;
void init_audio_resource(void* gResource);
UINT8* aud_get_reouce(AUD_ID_ENUM id, UINT32* leng, UINT16* type);
const char *aud_id2str(UINT16 aud_id);
extern UINT8 BIN_FILE[];
#endif//__RESOURCES_H__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/resources/resources.h
|
C
|
apache-2.0
| 2,207
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SYS_TIME_H__
#define __SYS_TIME_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "plat_types.h"
#include "hal_cmu.h"
#ifndef osCMSIS_FreeRTOS
#include <sys/time.h>
#else
#include "time.h"
#endif
#ifdef __ARM_ARCH_ISA_ARM
int gettimeofday(struct timeval *__restrict __p, void *__restrict __tz);
#endif
int gettimeready(void);
void hal_sys_time_init(s32_t ntp_sec, u32_t frac);
s32_t hal_sys_time_get(void);
char *hal_sys_get_cur_time(void);
time_t hal_sys_get_cur_rawtime(void);
char *hal_sys_format_time(s32_t sec);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/sys_time/sys_time.h
|
C
|
apache-2.0
| 1,228
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TRANSQ_MSG_H__
#define __TRANSQ_MSG_H__
#if defined(CHIP_HAAS1000)
#include "hal_transq.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*TRANSQ_MSG_HANDLE_CB_T)(void *param);
typedef enum {
TRANSQ_MSG_TYPE_TRACE,
TRANSQ_MSG_TYPE_AF_OPEN,
TRANSQ_MSG_TYPE_AF_CLOSE,
TRANSQ_MSG_TYPE_AF_CAPTURE_START,
TRANSQ_MSG_TYPE_AF_CAPTURE_STOP,
TRANSQ_MSG_TYPE_AF_PLAYBACK_START,
TRANSQ_MSG_TYPE_AF_PLAYBACK_STOP,
TRANSQ_MSG_TYPE_AF_CAPTURE_IRQ,
TRANSQ_MSG_TYPE_AF_PLAYBACK_IRQ,
TRANSQ_MSG_TYPE_RECORD_DATA,
TRANSQ_MSG_TYPE_USERDATA,
TRANSQ_MSG_TYPE_VOIP,
TRANSQ_MSG_TYPE_KEY,
TRANSQ_MSG_TYPE_CMD,
TRANSQ_MSG_TYPE_AUDIO_DUMP,
TRANSQ_MSG_TYPE_HEARTBEAT,
TRANSQ_MSG_TYPE_AUDIO_DUMP_ONE_CHANNEL,
TRANSQ_MSG_TYPE_NUM,
}TRANSQ_MSG_TYPE_T;
struct TRANSQ_MSG_TRACE {
unsigned int addr;
unsigned int len;
};
struct TRANSQ_MSG_AF_CONFIG_T {
unsigned int bits;
unsigned int sample_rate;
unsigned int channel_num;
unsigned int channel_map;
unsigned int device;
unsigned int io_path;
bool chan_sep_buf;
bool i2s_master_clk_wait;
unsigned char i2s_sample_cycles;
unsigned char *data_ptr;
unsigned int data_size;
//should define type
unsigned char vol;
};
struct TRANSQ_MSG_AF_BUF {
unsigned char *buf;
unsigned int len;
};
struct TRANSQ_MSG{
struct TRANSQ_MSG_TRACE trace;
struct TRANSQ_MSG_AF_CONFIG_T stream_cfg;
struct TRANSQ_MSG_AF_BUF stream_buf;
};
typedef struct {
TRANSQ_MSG_TYPE_T type;
enum HAL_TRANSQ_PRI_T pri;
unsigned int id;
struct TRANSQ_MSG msg;
void *user_data;
unsigned int user_data_len;
unsigned char sync;
} TRANSQ_MSG_T;
#ifndef RTOS
#define transq_msg_tx_wait_done(p) \
do{ \
transq_tx_done = 0; \
if(transq_msg_tx(p)) { \
while (!transq_tx_done) { \
hal_sys_timer_delay(MS_TO_TICKS(1)); \
} \
hal_sys_timer_delay(MS_TO_TICKS(1)); \
} \
}while(0)
#else
#define transq_msg_tx_wait_done(p) \
do{ \
if(transq_msg_tx(p)) { \
if (transq_tx_sem != NULL) { \
osSemaphoreWait(transq_tx_sem, osWaitForever); \
} \
} \
}while(0)
#endif
int transq_msg_init();
int transq_msg_reinit();
int transq_msg_flush();
void transq_msg_onoff(int onoff);
int transq_msg_tx(TRANSQ_MSG_T *msg);
void transq_msg_register(TRANSQ_MSG_TYPE_T type, TRANSQ_MSG_HANDLE_CB_T func, bool tx);
#ifdef __cplusplus
}
#endif
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/transq_msg/transq_msg.h
|
C
|
apache-2.0
| 3,145
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_H__
#define __ALSA_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* for 48K sample rate, 1 channels, 16bit
* 96Bytes means 1ms data size.
* bitrate 48000*16*1/1000 = 768Kbps
* in 1ms data size is 768*1000/1000/8 = 96 Bytes
* dma buffer size == trigger size , start delay all dma buffer size.
* for 48K sample rate, 1 channels, 24bit
* 192Bytes means 1ms data size.
*/
#define ALSA_SLOT_MS (128)
#define ALSA_ONE_MS_PCM_SIZE (192)
#define ALSA_PCM_DMA_BUFFER_SIZE (ALSA_ONE_MS_PCM_SIZE*ALSA_SLOT_MS*2)
#ifdef ALSA_FILL_DATA_ON_START
#define ALSA_PCM_THR_TRIGGER_PLAY (ALSA_PCM_DMA_BUFFER_SIZE)
#else
#define ALSA_PCM_THR_TRIGGER_PLAY (ALSA_PCM_DMA_BUFFER_SIZE/2)
#endif
#if (ALSA_SLOT_MS < 64)
#define ALSA_PCM_QUEUE_BUFFER_SIZE (ALSA_PCM_DMA_BUFFER_SIZE*4/ALSA_SLOT_MS*64) /* for sw gain fade out */
#else
#define ALSA_PCM_QUEUE_BUFFER_SIZE (ALSA_PCM_DMA_BUFFER_SIZE*4)
#endif
#define ALSA_INSTANCE_COUNT (3)
#ifdef ALIOS_THINGS_RELEASE
#define ALSA_DEFAULT_VOL_DAC (80)
#define ALSA_DEFAULT_VOL_PERCENT (90)
#define ALSA_MUTE_VOL (2)
#else
#define ALSA_DEFAULT_VOL_DAC (10)
#define ALSA_DEFAULT_VOL_PERCENT (50)
#define ALSA_MUTE_VOL (0)
#endif
typedef enum {
ALSA_MODE_UNKNOWN = -1,
ALSA_MODE_OUT = 0,
ALSA_MODE_IN = 1,
ALSA_MODE_ULTRASONIC = (1 << 1),
ALSA_MODE_MAX,
} alsa_mode_t;
typedef enum {
/** Signed, 8-bit */
ALSA_PCM_FORMAT_S8 = 1,
/** Signed 16-bit, little endian */
ALSA_PCM_FORMAT_S16_LE = 0,
/** Signed, 16-bit, big endian */
ALSA_PCM_FORMAT_S16_BE = 2,
/** Signed, 24-bit (32-bit in memory), little endian */
ALSA_PCM_FORMAT_S24_LE,
/** Signed, 24-bit (32-bit in memory), big endian */
ALSA_PCM_FORMAT_S24_BE,
/** Signed, 24-bit, little endian */
ALSA_PCM_FORMAT_S24_3LE,
/** Signed, 24-bit, big endian */
ALSA_PCM_FORMAT_S24_3BE,
/** Signed, 32-bit, little endian */
ALSA_PCM_FORMAT_S32_LE,
/** Signed, 32-bit, big endian */
ALSA_PCM_FORMAT_S32_BE,
/** Max of the enumeration list, not an actual format. */
ALSA_PCM_FORMAT_MAX
} alsa_pcm_format_t;
typedef enum {
ALSA_PCM_STATE_UNDERRUN,
ALSA_PCM_STATE_UNDERRUN_EXIT,
ALSA_PCM_STATE_OVERRUN,
ALSA_PCM_STATE_OVERRUN_EXIT,
} alsa_pcm_state_t;
typedef void (*alsa_pcm_state_callback_t)(alsa_pcm_state_t state, void *user, void *info);
typedef struct alsa_handle alsa_handle_t;
void alsa_init(void);
alsa_handle_t * alsa_open(alsa_mode_t mode, int sample_rate, int channels, alsa_pcm_format_t format);
int alsa_write(alsa_handle_t * h, uint8_t *buf, uint32_t size);
int alsa_start(alsa_handle_t * h);
int alsa_stop(alsa_handle_t * h);
int alsa_close(alsa_handle_t * h);
void alsa_register_pcm_state_callback(alsa_handle_t * h, alsa_pcm_state_callback_t cb, void * arg);
void alsa_mute_set(void);
void alsa_mute_cancel(void);
void alsa_volume_set(uint8_t vol_percent, uint8_t vol_dac);
uint8_t alsa_volume_get(void);
uint8_t alsa_volume_percent_get(void);
uint8_t alsa_volume_adc_get(uint8_t mic_id);
void alsa_volume_adc_set(uint8_t mic_id, uint8_t vol);
uint8_t alsa_is_playing_state(void);
uint8_t alsa_is_close_state(void);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa.h
|
C
|
apache-2.0
| 3,966
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_AUDIO_PROCESS_H__
#define __ALSA_AUDIO_PROCESS_H__
#ifdef __cplusplus
extern "C" {
#endif
int alsa_audio_process_oepn(int sample_rate, int channel_num, int bits, uint32_t dma_data_size);
int alsa_audio_process_close(void);
int alsa_audio_process(uint8_t *buf, uint32_t len);
void alsa_audio_process_enter_online_debug(void);
void alsa_audio_process_level_online_debug(void);
uint8_t alsa_audio_process_is_online_debug(void);
#ifdef AUDIO_PROCESS_CFG_DIFF_FOR_ODM
void alsa_audio_process_set_odm_cfg(char * odm_name, uint32_t odm_name_len, uint8_t odm_type);
uint8_t alsa_audio_process_get_cfg_index(void);
#endif
void alsa_audio_process_bypass_eq_set(uint8_t enable);
uint8_t alsa_audio_process_bypass_eq_get(void);
#ifdef ALSA_INSTANCE_SKIP_AUDIO_PROCESS
void alsa_skip_audio_process_set(uint8_t val);
#endif
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa_audio_process.h
|
C
|
apache-2.0
| 1,518
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_DEAMON_H__
#define __ALSA_DEAMON_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef ALSA_SRC_PROCESS_EN
#define ALSA_SAMPLERATE AUD_SAMPRATE_48000
#else
#define ALSA_SAMPLERATE AUD_SAMPRATE_16000
#endif
#ifdef ALSA_STEREO_TO_MONO_EN
#define ALSA_CHANNELS AUD_CHANNEL_NUM_1
#else
#define ALSA_CHANNELS AUD_CHANNEL_NUM_2
#endif
#ifdef ALSA_24BIT_PROCESS_EN
#define ALSA_BITS AUD_BITS_24
#else
#define ALSA_BITS AUD_BITS_16
#endif
typedef enum
{
ALSA_STATE_CLOSE = 0,
ALSA_STATE_OPEN,
ALSA_STATE_START,
ALSA_STATE_STOP,
} alsa_state_t;
typedef uint32_t (*ALSA_GET_USER_DATA_CB)(uint8_t *, uint32_t);
typedef int (*ALSA_USER_DATA_LEN_CHANGED_CB)(uint32_t);
void alsa_deamon_init(ALSA_GET_USER_DATA_CB alsa_get_user_data_cb, ALSA_USER_DATA_LEN_CHANGED_CB alsa_user_data_len_changed_cb);
int alsa_open_for_user(uint8_t user_id);
int alsa_start_for_user(uint8_t user_id);
int alsa_stop_for_user(uint8_t user_id);
int alsa_close_for_user(uint8_t user_id);
int alsa_check_only_ultra_playing(void);
int alsa_modify_adc_gain_for_ultra(uint8_t only_ultra_playing);
#ifdef __cplusplus
}
#endif
#endif /* __ALSA_DEAMON_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa_deamon.h
|
C
|
apache-2.0
| 1,824
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_DUMP_H__
#define __ALSA_DUMP_H__
#ifdef ALSA_DUMP_EN
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uint8_t id;
uint32_t sample_rate;
uint8_t channels;
uint8_t bits;
} alsa_dump_info_t;
void *alsa_dump_if_open(const char *ip_str, alsa_dump_info_t * info);
int alsa_dump_if_close(void *h);
int alsa_dump_if_dump(void *h, uint8_t *buf, uint32_t len);
int alsa_dump_local_printf(uint8_t * buf, uint32_t len);
#ifdef ALSA_DUMP_EN
void alsa_dump_point_init(alsa_handle_t *h);
void alsa_dump_point_denint(alsa_handle_t *h);
void alsa_dump_point_write(alsa_handle_t *h, uint8_t *buf, uint32_t len);
void alsa_dump_point_after_sw_gain(uint8_t *buf, uint32_t len);
void alsa_dump_point_after_audio_process(uint8_t *buf, uint32_t len);
void alsa_dump_point_mixer(uint8_t *buf, uint32_t len);
#endif
#ifdef __cplusplus
}
#endif
#endif /* ALSA_DUMP_EN */
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa_dump.h
|
C
|
apache-2.0
| 1,549
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_RESAMPLE_HOOK_H__
#define __ALSA_RESAMPLE_HOOK_H__
#ifdef ALSA_RESAMPLE_USER_HOOK_EN
/**
* state:
* 0: start data stream
* 1: stop data stream
*/
typedef void (*alsa_resample_user_cb_t)(uint8_t state, void * user_arg);
void alsa_resample_register_user_callback(alsa_resample_user_cb_t cb, void * arg);
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa_resample_hook.h
|
C
|
apache-2.0
| 984
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_RESAMPLE_PROCESS_H__
#define __ALSA_RESAMPLE_PROCESS_H__
#include <stdint.h>
#include "hal_aud.h"
#include "audio_resample_ex.h"
#define ALSA_SRC_BUF_SIZE (12 * 1024)
int new_alsa_resample(enum AUD_CHANNEL_NUM_T channels, enum AUD_BITS_T bits,
uint32_t sample_rate_src, uint32_t sample_rate_dst);
void del_alsa_resample(int id);
int alsa_resample_process(int id, const int16_t *data_in, int16_t **data_out, uint32_t *in_out_len);
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa_resample_process.h
|
C
|
apache-2.0
| 1,128
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __ALSA_WAV_PLAYER_H__
#define __ALSA_WAV_PLAYER_H__
typedef int (*alsa_wav_player_file_open)(const char *pathname, int flags);
typedef int (*alsa_wav_player_file_close)(int fd);
typedef int (*alsa_wav_player_file_read)(int fd, void *buf, uint32_t count);
typedef struct {
alsa_wav_player_file_open open;
alsa_wav_player_file_close close;
alsa_wav_player_file_read read;
} alsa_wav_player_file_opt_t;
void alsa_wav_player_file_opt_register(alsa_wav_player_file_opt_t * opt);
int alsa_wav_play_file(const char * path, uint8_t ultra_sound_flag);
int alsa_wav_play_mem(uint8_t *data, uint32_t len);
void alsa_ultra_sound_test(uint8_t en, const char * path_of_20k, const char * path_of_music);
#endif /* __ALSA_WAV_PLAYER_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/alsa_wav_player.h
|
C
|
apache-2.0
| 1,399
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BTPCM_CONFIG_H__
#define __BTPCM_CONFIG_H__
typedef uint32_t (*bt_sco_btpcm_data_callback_t)(uint8_t *buf, uint32_t len);
typedef enum SCO_SAMPRATE {
SCO_SAMPRATE_8000 = 8000,
SCO_SAMPRATE_16000 = 16000,
}SCO_SAMPRATE_T;
typedef enum {
BTPCM_HF_SCO_CODEC_NONE = 0,
BTPCM_HF_SCO_CODEC_CVSD = 1,
BTPCM_HF_SCO_CODEC_MSBC = 2,
} btpcm_sco_codec_t;
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
function : bt_sco_btpcm_data_callback_register
Description : register btpcm callback function
Input : capture_callback receive len datas by sco
: playback_callback send len datas by sco
Output : None
Date : 2021/1/15
*****************************************************************************/
void bt_sco_btpcm_data_callback_register(bt_sco_btpcm_data_callback_t capture_callback,
bt_sco_btpcm_data_callback_t playback_callback);
void btpcm_capture_start(SCO_SAMPRATE_T sample_rate,uint8_t*sco_buff,uint32_t data_size);
void btpcm_playback_start(SCO_SAMPRATE_T sample_rate,uint8_t*sco_buff,uint32_t data_size);
void btpcm_capture_stop(void);
void btpcm_playback_stop(void);
int app_btpcm_set_sco_codec_type(btpcm_sco_codec_t codec_id);
int app_btpcm_get_sco_codec_type(void);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/alsa_adapter/btpcm_config.h
|
C
|
apache-2.0
| 2,073
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_DEC_
#define _AUDIO_DEC_
#ifdef __cplusplus
extern "C"
{
#endif
#include "plat_types.h"
typedef enum
{
AUDIO_DEC_FORMAT_INVALID = -1,
AUDIO_DEC_FORMAT_MP3 = 0,
AUDIO_DEC_FORMAT_AAC_ADTS,
AUDIO_DEC_FORMAT_AAC_M4A,
AUDIO_DEC_FORMAT_OPUS,
} audio_dec_format_t;
typedef struct
{
uint32_t sample_rate;
uint32_t channels_num;
uint32_t bitrate;
uint32_t sample_bit;
} audio_dec_pcm_arg_t;
typedef int (*audio_dec_pcm_handler_cb)(uint8_t *pcm, uint32_t pcm_size, audio_dec_pcm_arg_t *pcm_arg, void *user_arg);
typedef int (*audio_dec_finish_cb)(void);
int audio_dec_get_decoder_available_input_data_size(void * audio_dec_handle, audio_dec_format_t format);
void* audio_dec_open(audio_dec_format_t format);
int audio_dec_write(void * audio_dec_handle, audio_dec_format_t format, uint8_t *data, uint32_t input_size, audio_dec_pcm_handler_cb cb, void * cb_arg);
int audio_dec_close(void * audio_dec_handle, audio_dec_format_t format, audio_dec_finish_cb cb);
int audio_dec_check_pcm_arg_changed(audio_dec_pcm_arg_t *old_pcm_arg, audio_dec_pcm_arg_t *new_pcm_arg);
#ifdef __cplusplus
}
#endif
#endif /* _AUDIO_DEC_ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_dec.h
|
C
|
apache-2.0
| 1,903
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_DEC_AAC_ADTS_H_
#define _AUDIO_DEC_AAC_ADTS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define AUDIO_DEC_AAC_ADTS_FIFO_SIZE (1024)
void *audio_aac_adts_dec_open(void);
int audio_aac_adts_dec_write(void *aac_dec_handle, uint8_t *data_in, int input_size, audio_dec_pcm_handler_cb cb, void *cb_arg);
int audio_aac_adts_dec_close(void *aac_dec_handle);
uint32_t audio_aac_adts_dec_get_decoder_available_input_data_size(void *aac_dec_handle);
#ifdef __cplusplus
}
#endif
#endif /* _AUDIO_DEC_AAC_ADTS_H_ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_dec_aac_adts.h
|
C
|
apache-2.0
| 1,187
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_DEC_AAC_M4A_H_
#define _AUDIO_DEC_AAC_M4A_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define AUDIO_DEC_AAC_M4A_FIFO_SIZE (1024)
int audio_aac_m4a_dec_open(void);
int audio_aac_m4a_dec_write(uint8_t *data, uint32_t input_size, audio_dec_pcm_handler_cb cb, void * cb_arg);
int audio_aac_m4a_dec_close(void);
uint32_t audio_aac_m4a_dec_get_decoder_available_input_data_size(void);
int audio_aac_m4a_dec_prepare_file(uint8_t *data, uint32_t data_len);
#ifdef __cplusplus
}
#endif
#endif /* _AUDIO_DEC_AAC_M4A_H_ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_dec_aac_m4a.h
|
C
|
apache-2.0
| 1,201
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_DEC_MP3_H_
#define _AUDIO_DEC_MP3_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "audio_dec.h"
#define AUDIO_DEC_MP3_FIFO_SIZE (1024*2)
void *audio_mp3_dec_open(void);
int audio_mp3_dec_write(void *mp3_dec_handle, uint8_t *data, uint32_t input_size, audio_dec_pcm_handler_cb cb, void *cb_arg);
int audio_mp3_dec_close(void * mp3_dec_handle);
uint32_t audio_mp3_dec_get_decoder_available_input_data_size(void *mp3_dec_handle);
#ifdef __cplusplus
}
#endif
#endif /* _AUDIO_DEC_MP3_H_ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_dec_mp3.h
|
C
|
apache-2.0
| 1,177
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_DEC_OPUS_H_
#define _AUDIO_DEC_OPUS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "audio_dec.h"
/* call this function befor audio_opus_dec_open to config decoder arg */
int audio_opus_dec_set_arg(uint32_t sample_rate, uint32_t frame_size_time_ms, uint8_t channles_num);
void *audio_opus_dec_open(void);
int audio_opus_dec_write(void *opus_dec_handle, uint8_t *data, uint32_t input_size, audio_dec_pcm_handler_cb cb, void *cb_arg);
int audio_opus_dec_close(void *opus_dec_handle);
uint32_t audio_opus_dec_get_decoder_available_input_data_size(void *opus_dec_handle);
#ifdef __cplusplus
}
#endif
#endif /* _AUDIO_DEC_OPUS_H_ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_dec_opus.h
|
C
|
apache-2.0
| 1,325
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _AUDIO_ENC_OPUS_H_
#define _AUDIO_ENC_OPUS_H_
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum
{
OPUS_ENC_APP_AUDIO,
OPUS_ENC_APP_VOIP,
OPUS_ENC_APP_RESTRICTED_LOWDELAY,
} OPUS_ENC_APP_T;
int audio_opus_enc_init(uint32_t sample_rate, uint8_t channels_num, uint32_t frame_size_time_ms, OPUS_ENC_APP_T app_type);
int audio_opus_enc_write(uint8_t *data_in, uint8_t *data_out, int max_output_size);
int audio_opus_enc_close(void);
int audio_opus_enc_test(uint8_t *pcm_data, uint32_t pcm_len);
#ifdef __cplusplus
}
#endif
#endif /* _AUDIO_ENC_OPUS_H_ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_enc_opus.h
|
C
|
apache-2.0
| 1,266
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __AUDIO_PLAYER_H__
#define __AUDIO_PLAYER_H__
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum
{
AUDIO_PLAYER_FORMAT_INVALID = -1,
AUDIO_PLAYER_FORMAT_MP3 = 0,
AUDIO_PLAYER_FORMAT_AAC_ADTS,
AUDIO_PLAYER_FORMAT_AAC_M4A,
AUDIO_PLAYER_FORMAT_OPUS,
AUDIO_PLAYER_FORMAT_PCM,
AUDIO_PLAYER_FORMAT_WAV,
} audio_player_format_t;
int audio_player_init(void);
typedef void (*audio_player_playback_cb)(void);
/* if player pcm audio, should config pcm arg. */
int audio_player_fomat_pcm_config(uint32_t sample_rate, uint8_t channels_num);
/* audio_player play audio from file, auto start player. */
int audio_player_play_file(const char *path_name, audio_player_playback_cb cb);
/* audio_player play audio from memory data, audo start player. */
int audio_player_play_mem_init(audio_player_format_t format, uint32_t total_size, audio_player_playback_cb cb);
int audio_player_play_mem(const uint8_t *data, uint32_t data_len);
int audio_player_play_mem_denint(void);
/* audio_player control function */
int audio_player_stop(void);
#if 0
/* Not Support */
int audio_player_pause(void);
int audio_player_resume(void);
#endif
/* for filesystem */
typedef int (*audio_player_file_open)(const char *pathname, int flags);
typedef int (*audio_player_file_close)(int fd);
typedef int (*audio_player_file_read)(int fd, void *buf, uint32_t count);
typedef struct {
audio_player_file_open open;
audio_player_file_close close;
audio_player_file_read read;
} audio_player_file_opt_t;
int audio_player_file_ops_register(audio_player_file_opt_t * file_opt);
int audio_fs_open(const char *pathname, int flags);
int audio_fs_close(int fd);
uint32_t audio_fs_read(int fd, void *buf, uint32_t count);
/* some test case */
int audio_player_test_from_sd_card_file(const char *path);
int audio_player_test_from_sd_card_file_and_stop(const char *path, uint32_t play_time_ms);
int audio_player_test_from_mem(audio_player_format_t foramt, uint8_t *raw_data, uint32_t raw_data_size);
#ifdef __cplusplus
}
#endif
#endif /* __AUDIO_PLAYER_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/audio_player.h
|
C
|
apache-2.0
| 2,887
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __FS_ADAPT_H__
#define __FS_ADAPT_H__
#ifdef __cplusplus
extern "C"
{
#endif
void fs_adapt_init(void);
int flush(int fd);
int filesize(int fd);
int relax(int fd, int size);
int open(const char *pathname, int flags, ...);
uint32_t read(int fd, void *buf, size_t count);
uint32_t write(int fd, const void *buf, size_t nbyte);
int lseek(int fildes, int offset, int whence);
//int _is_virtual_path(const char *path);
int close(int fd);
#ifdef __cplusplus
}
#endif
#endif /* __FS_ADAPT_H__ */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/audio_dec/fs_adapt.h
|
C
|
apache-2.0
| 1,189
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BESWIFI_H
#define BESWIFI_H
#ifdef __cplusplus
extern "C" {
#endif
int bes_wifi_init(void);
int bes_wifi_connect(const char *ssid, const char *passwd, unsigned char *bssid);
#ifdef __cplusplus
}
#endif
#endif /* BESWIFI_H */
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/beswifi.h
|
C
|
apache-2.0
| 890
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BES_SNIFFER_H_
#define _BES_SNIFFER_H_
#define SNIFFER_STATE_ENABLE_MASK 0x001
#define SNIFFER_STATE_DISABLE 0x000
#define SNIFFER_STATE_ENABLE 0x001
#define SNIFFER_STATE_MGMT 0x002
#define SNIFFER_STATE_FROMDS 0x004
#define SNIFFER_STATE_TODS 0x008
#define SNIFFER_STATE_40M 0x010
#define SNIFFER_STATE_ACK 0x020
#define SNIFFER_STATE_RTSCTX 0x040
#define SNIFFER_STATE_NULL 0x080
enum TYPESUBTYPE_T
{
ASSOC_REQ = 0x00,
ASSOC_RSP = 0x10,
REASSOC_REQ = 0x20,
REASSOC_RSP = 0x30,
PROBE_REQ = 0x40,
PROBE_RSP = 0x50,
BEACON = 0x80,
ATIM = 0x90,
DISASOC = 0xA0,
AUTH = 0xB0,
DEAUTH = 0xC0,
ACTION = 0xD0,
PS_POLL = 0xA4,
RTS = 0xB4,
CTS = 0xC4,
ACK = 0xD4,
CFEND = 0xE4,
CFEND_ACK = 0xF4,
DATA = 0x08,
DATA_ACK = 0x18,
DATA_POLL = 0x28,
DATA_POLL_ACK = 0x38,
NULL_FRAME = 0x48,
CFACK = 0x58,
CFPOLL = 0x68,
CFPOLL_ACK = 0x78,
QOS_DATA = 0x88,
QOS_DATA_ACK = 0x98,
QOS_DATA_POLL = 0xA8,
QOS_DATA_POLL_ACK = 0xB8,
QOS_NULL_FRAME = 0xC8,
QOS_CFPOLL = 0xE8,
QOS_CFPOLL_ACK = 0xF8,
BLOCKACK_REQ = 0x84,
BLOCKACK = 0x94
};
typedef int (*sniffer_handler_t)(unsigned short data_len, void *data);
int bes_sniffer_start(sniffer_handler_t handler);
int bes_sniffer_stop(void);
int bes_sniffer_set_channel(u8 channel);
int bes_sniffer_set_filter(u8 f_mgmt, u8 f_fromds, u8 f_tods, u8 f_error, u8 f_ack, u8 f_rts, u8 f_null);
int bes_sniffer_send_mgmt_frame(u8 channel, const u8 *data, size_t len);
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/services/wifi_app/sniffer/bes_sniffer.h
|
C
|
apache-2.0
| 2,703
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "tool_msg.h"
#include "reboot_param.h"
#include "norflash_cfg.h"
#include "hal_cmu.h"
extern const char sys_build_info[];
#ifdef USER_SECURE_BOOT
extern const unsigned int system_info;
#endif
// -----------------------------------------------------------
// Boot struct and code sig struct
// -----------------------------------------------------------
#if defined(PROGRAMMER_INFLASH)
#undef PROGRAMMER
#endif
#define BOOT_STRUCT_LOC __attribute((section(".boot_struct")))
#ifdef USER_SECURE_BOOT
#define DEFAULT_BUILD_INFO ((uint32_t)&system_info)
#else
#define DEFAULT_BUILD_INFO ((uint32_t)sys_build_info)
#endif
#define DEFAULT_CODE_SIG \
{ \
.code_size = 0, \
.sig_len = SIG_LEN, \
}
#ifdef SIMU
#define DEFAULT_NORFLASH_SAMDLY 0x1
#define DEFAULT_NORFLASH_MOD_CLK HAL_CMU_FREQ_26M
#define DEFAULT_NORFLASH_RDCMD 0x03
#else
#define DEFAULT_NORFLASH_SAMDLY 0x2
// Select 26M for 40M crystal case
#define DEFAULT_NORFLASH_MOD_CLK HAL_CMU_FREQ_104M
// Below 50M: 0x03, Above 50M: 0x0B
#define DEFAULT_NORFLASH_RDCMD 0x0B
#endif
#define DEFAULT_NORFLASH_CFG \
{ \
.neg_phase = 0, \
.pos_neg = 0, \
.cmdquad = 0, \
.div = 0x2, \
.samdly = DEFAULT_NORFLASH_SAMDLY, \
.dualmode = 1, \
.holdpin = 0, \
.wprpin = 0, \
.quadmode = 0, \
.mod_clk = DEFAULT_NORFLASH_MOD_CLK, \
.spiruen = 0, \
.spirden = 0, \
.dualiocmd = 0xBB, \
.rdcmd = DEFAULT_NORFLASH_RDCMD, \
.frdcmd = 0x0B, \
.qrdcmd = 0xEB, \
}
#ifdef SECURE_BOOT_V1
#ifdef PROGRAMMER
struct programmer_boot_struct_t {
struct boot_struct_v1_t boot_struct;
struct code_sig_struct_t code_sig_struct;
};
const struct programmer_boot_struct_t BOOT_STRUCT_LOC programmer_boot_struct = {
.boot_struct = {
.hdr = {
.magic = BOOT_MAGIC_NUMBER,
.security = 1,
.hash_type = BOOT_HASH_TYPE_SHA256,
.key_type = BOOT_KEY_TYPE_RSA2048,
.key_len = KEY_LEN,
.sig_len = SIG_LEN,
.build_info_start = ((uint32_t)sys_build_info),
},
},
.code_sig_struct = DEFAULT_CODE_SIG,
};
#elif defined(SECURE_BOOT)
struct secure_boot_struct_t {
struct boot_struct_v1_t boot_struct;
struct code_sig_struct_t code_sig_struct;
struct norflash_cfg_struct_t norflash_cfg;
};
const struct secure_boot_struct_t BOOT_STRUCT_LOC secure_boot_struct = {
.boot_struct = {
.hdr = {
.magic = ~0UL,
.security = 1,
.hash_type = BOOT_HASH_TYPE_SHA256,
.key_type = BOOT_KEY_TYPE_RSA2048,
.key_len = KEY_LEN,
.sig_len = SIG_LEN,
.build_info_start = DEFAULT_BUILD_INFO,
},
},
.code_sig_struct = DEFAULT_CODE_SIG,
.norflash_cfg = DEFAULT_NORFLASH_CFG,
};
#else
const struct boot_hdr_v1_t BOOT_STRUCT_LOC boot_struct = {
.magic = ~0UL,
.security = 0,
.build_info_start = DEFAULT_BUILD_INFO,
};
#endif
#else // !SECURE_BOOT_V1
#ifdef PROGRAMMER
union programmer_boot_struct_t {
// To keep compatible with the old download tools when downloadig non-secure images
struct {
struct boot_struct_v1_t dummy;
struct code_sig_struct_t code_sig_struct;
} s_v1;
struct {
struct boot_struct_t boot_struct;
struct code_sig_struct_t code_sig_struct;
} s;
};
const union programmer_boot_struct_t BOOT_STRUCT_LOC programmer_boot_struct = {
.s = {
.boot_struct = {
.hdr = {
.magic = BOOT_MAGIC_NUMBER,
.security = 1,
.version = BOOT_STRUCT_VERSION,
.build_info_start = ((uint32_t)sys_build_info),
},
},
.code_sig_struct = DEFAULT_CODE_SIG,
},
};
#elif defined(SECURE_BOOT)
struct secure_boot_struct_t {
struct boot_struct_t boot_struct;
struct code_sig_struct_t code_sig_struct;
struct norflash_cfg_struct_t norflash_cfg;
};
const struct secure_boot_struct_t BOOT_STRUCT_LOC secure_boot_struct = {
.boot_struct = {
.hdr = {
.magic = ~0UL,
.security = 1,
.version = BOOT_STRUCT_VERSION,
.build_info_start = DEFAULT_BUILD_INFO,
},
#if HAAS_OTA_ENABLED
.ver = HAAS_OTA_BIN_VER,
#endif
},
.code_sig_struct = DEFAULT_CODE_SIG,
.norflash_cfg = DEFAULT_NORFLASH_CFG,
};
#else
const struct boot_hdr_t BOOT_STRUCT_LOC boot_struct = {
.magic = ~0UL,
.security = 0,
.version = BOOT_STRUCT_VERSION,
.build_info_start = DEFAULT_BUILD_INFO,
};
#endif
#endif // !SECURE_BOOT_V1
// -----------------------------------------------------------
// Reboot param
// -----------------------------------------------------------
#ifdef __ARMCC_VERSION
#define REBOOT_PARAM_LOC __attribute((section(".bss.reboot_param")))
#else
#define REBOOT_PARAM_LOC __attribute((section(".reboot_param")))
#endif
struct REBOOT_PARAM_T REBOOT_PARAM_LOC reboot_param;
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/boot_struct/boot_struct.c
|
C
|
apache-2.0
| 6,154
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __NORFLASH_CFG_H__
#define __NORFLASH_CFG_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "plat_types.h"
#define STATUS_S10_LB_BIT_SHIFT 2
#define STATUS_S10_LB_BIT_MASK (1 << STATUS_S10_LB_BIT_SHIFT)
#define STATUS_S11_LB1_BIT_SHIFT 3
#define STATUS_S11_LB1_BIT_MASK (1 << STATUS_S11_LB1_BIT_SHIFT)
enum SEC_REG_BASE_T {
SEC_REG_BASE_0X1000,
SEC_REG_BASE_0X0000,
};
enum SEC_REG_SIZE_T {
SEC_REG_SIZE_1024,
SEC_REG_SIZE_512,
SEC_REG_SIZE_256,
};
enum SEC_REG_OFFSET_T {
SEC_REG_OFFSET_0X1000,
SEC_REG_OFFSET_0X0100,
};
enum SEC_REG_CNT_T {
SEC_REG_CNT_3,
SEC_REG_CNT_4,
};
enum SEC_REG_PP_T {
SEC_REG_PP_256,
SEC_REG_PP_1024,
};
enum SEC_REG_LB_T {
SEC_REG_LB_S11_S13,
SEC_REG_LB_S10,
};
struct norflash_cfg_struct_t {
uint8_t neg_phase:1;
uint8_t pos_neg:1;
uint8_t cmdquad:1;
uint8_t samdly:3;
uint8_t div; /* least 2 */
uint8_t dualmode:1;
uint8_t holdpin:1;
uint8_t wprpin:1;
uint8_t quadmode:1;
uint8_t mod_clk:4;
uint8_t spiruen:3;
uint8_t spirden:3;
uint8_t dualiocmd;
uint8_t rdcmd;
uint8_t frdcmd;
uint8_t qrdcmd; /* quad io cmd */
};
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/boot_struct/norflash_cfg.h
|
C
|
apache-2.0
| 1,925
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __REBOOT_PARAM_H__
#define __REBOOT_PARAM_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "stdint.h"
struct REBOOT_PARAM_T {
uint32_t reserved[4];
};
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/boot_struct/reboot_param.h
|
C
|
apache-2.0
| 858
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TOOL_MSG_H__
#define __TOOL_MSG_H__
#ifdef __cplusplus
extern "C" {
#endif
#define BOOT_MAGIC_NUMBER 0xBE57EC1C
#define BOOT_HASH_TYPE_MD5 1
#define BOOT_HASH_TYPE_SHA256 2
#define BOOT_KEY_TYPE_RSA2048 1
#define BOOT_KEY_TYPE_ECDSA192 2
#define BOOT_KEY_TYPE_ECDSA256 3
#define SEC_KEY_VERSION 0
#define BOOT_STRUCT_VERSION 0
#define PREFIX_CHAR 0xBE
#define KEY_LEN (4 + 256 + 256)
#define SIG_LEN 256
#define HASH_LEN 32
#ifndef MAX_TOOL_MSG_DATA_LEN
// Max msg: flash cmd msg with 4-byte address and 16-byte data (1 + 4 + 16)
#define MAX_TOOL_MSG_DATA_LEN 21
#endif
#define MAX_READ_DATA_LEN 16
#define MAX_WRITE_DATA_LEN 16
#define MAX_FLASH_CMD_DATA_LEN 16
#define MIN_SIGNED_CODE_SIZE 32
#ifdef SECURE_BOOT_V1
#define BOOT_STRUCT_V1_OFFSET_TO_SIGN(b) \
((unsigned char *)&((struct boot_struct_v1_t *)(b))->hdr.security)
#define BOOT_STRUCT_V1_LEN_TO_SIGN \
((unsigned long)&((struct boot_struct_v1_t *)0)->sig[0] - \
(unsigned long)&((struct boot_struct_v1_t *)0)->hdr.security)
#endif
#define SEC_KEY_OFFSET_TO_HASH(b) \
((unsigned char *)&((struct sec_key_struct_t *)(b))->version)
#define SEC_KEY_LEN_TO_HASH \
((unsigned long)&((struct sec_key_struct_t *)0)->hash[0] - \
(unsigned long)&((struct sec_key_struct_t *)0)->version)
#define SIG_MSG_OVERHEAD 8
#define SIG_MSG_V1_EXTRA_DATA_LEN (sizeof(struct boot_struct_v1_t) + sizeof(struct code_sig_struct_t))
#define SIG_MSG_V1_TOTAL_LEN (SIG_MSG_OVERHEAD + SIG_MSG_V1_EXTRA_DATA_LEN)
#define SIG_MSG_EXTRA_DATA_LEN (sizeof(struct boot_struct_t) + sizeof(struct code_sig_struct_t))
#define SIG_MSG_TOTAL_LEN (SIG_MSG_OVERHEAD + SIG_MSG_EXTRA_DATA_LEN)
#define CODE_MSG_OVERHEAD 8
#define BURN_DATA_MSG_OVERHEAD 16
#define SECTOR_SIZE_64K (1 << 16)
#define SECTOR_SIZE_32K (1 << 15)
#define SECTOR_SIZE_16K (1 << 14)
#define SECTOR_SIZE_4K (1 << 12)
#define MSG_TOTAL_LEN(msg) (sizeof(struct msg_hdr_t) + ((struct msg_hdr_t *)(msg))->len + 1)
enum MSG_TYPE {
TYPE_SYS = 0x00,
TYPE_READ = 0x01,
TYPE_WRITE = 0x02,
TYPE_BULK_READ = 0x03,
#if defined(TEST_OVER_THE_AIR_ENANBLED)
TYPE_EXT_WRITE = 0x04,
TYPE_BULK_WRITE_START = 0x05,
TYPE_BULK_WRITE_DATA = 0x06,
#endif
TYPE_NOTIF = 0x10,
TYPE_SYNC = 0x50,
TYPE_SIG_INFO = 0x51,
TYPE_SIG = 0x52,
TYPE_CODE_INFO = 0x53,
TYPE_CODE = 0x54,
TYPE_RUN = 0x55,
TYPE_SECTOR_SIZE = 0x60,
TYPE_ERASE_BURN_START = 0x61,
TYPE_ERASE_BURN_DATA = 0x62,
TYPE_OBSOLETED_63 = 0x63,
TYPE_OBSOLETED_64 = 0x64,
TYPE_FLASH_CMD = 0x65,
TYPE_GET_SECTOR_INFO = 0x66,
TYPE_SEC_REG_ERASE_BURN_START = 0x67,
TYPE_SEC_REG_ERASE_BURN_DATA = 0x68,
// Extended types
TYPE_PROD_TEST = 0x81,
TYPE_RUNTIME_CMD = 0x82,
TYPE_BT_CALIB_CMD = 0x83,
TYPE_PROTO_EL = 0xA0,
TYPE_INVALID = 0xFF,
};
enum SYS_CMD_TYPE {
SYS_CMD_REBOOT = 0xF1,
SYS_CMD_SHUTDOWN = 0xF2,
SYS_CMD_FLASH_BOOT = 0xF3,
SYS_CMD_SET_BOOTMODE = 0xE1,
SYS_CMD_CLR_BOOTMODE = 0xE2,
SYS_CMD_GET_BOOTMODE = 0xE3,
};
enum ERR_CODE {
ERR_NONE = 0x00,
ERR_LEN = 0x01,
ERR_CHECKSUM = 0x02,
ERR_NOT_SYNC = 0x03,
ERR_NOT_SEC = 0x04,
ERR_SYNC_WORD = 0x05,
ERR_SYS_CMD = 0x06,
ERR_DATA_ADDR = 0x07,
ERR_DATA_LEN = 0x08,
ERR_ACCESS_RIGHT = 0x09,
ERR_TYPE_INVALID = 0x0F,
//ERR_BOOT_OK = 0x10,
ERR_BOOT_MAGIC = 0x11,
ERR_BOOT_SEC = 0x12,
ERR_BOOT_HASH_TYPE = 0x13,
ERR_BOOT_KEY_TYPE = 0x14,
ERR_BOOT_KEY_LEN = 0x15,
ERR_BOOT_SIG_LEN = 0x16,
ERR_BOOT_SIG = 0x17,
ERR_BOOT_CRC = 0x18,
ERR_BOOT_LEN = 0x19,
ERR_SIG_CODE_SIZE = 0x1A,
ERR_SIG_SIG_LEN = 0x1B,
ERR_SIG_INFO_MISSING = 0x1C,
ERR_BOOT_KEY_ID = 0x1D,
ERR_BOOT_HASH = 0x1E,
ERR_CODE_OK = 0x20,
ERR_BOOT_MISSING = 0x21,
ERR_CODE_SIZE_SIG = 0x22,
ERR_CODE_ADDR_SIZE = 0x23,
ERR_CODE_INFO_MISSING = 0x24,
ERR_CODE_CRC = 0x25,
ERR_CODE_SIG = 0x26,
ERR_CODE_MISSING = 0x31,
ERR_VERSION = 0x32,
ERR_BURN_OK = 0x60,
ERR_SECTOR_SIZE = 0x61,
ERR_SECTOR_SEQ_OVERFLOW = 0x62,
ERR_BURN_INFO_MISSING = 0x63,
ERR_SECTOR_DATA_LEN = 0x64,
ERR_SECTOR_DATA_CRC = 0x65,
ERR_SECTOR_SEQ = 0x66,
ERR_ERASE_FLSH = 0x67,
ERR_BURN_FLSH = 0x68,
ERR_VERIFY_FLSH = 0x69,
ERR_FLASH_CMD = 0x6A,
ERR_TYPE_MISMATCHED = 0xE1,
ERR_SEQ_MISMATCHED = 0xE2,
ERR_BUF_TOO_SMALL = 0xE3,
ERR_INTERNAL = 0xFF,
};
enum PARSE_STATE {
PARSE_HEADER,
PARSE_DATA,
PARSE_EXTRA,
};
struct msg_hdr_t {
unsigned char prefix;
unsigned char type;
unsigned char seq;
unsigned char len;
};
struct message_t {
struct msg_hdr_t hdr;
// data and 1-byte check_sum
unsigned char data[MAX_TOOL_MSG_DATA_LEN + 1];
};
struct sec_key_struct_t {
unsigned int magic;
unsigned short version;
unsigned char hash_type;
unsigned char key_type;
unsigned short key_len;
unsigned short sig_len;
unsigned int reserved[5];
unsigned char key[KEY_LEN];
unsigned char hash[HASH_LEN];
};
struct boot_hdr_v1_t {
unsigned int magic;
unsigned short security;
unsigned char hash_type;
unsigned char key_type;
unsigned short key_len;
unsigned short sig_len;
unsigned int build_info_start;
};
struct boot_struct_v1_t {
struct boot_hdr_v1_t hdr;
unsigned char key[KEY_LEN];
unsigned char sig[SIG_LEN];
};
struct boot_hdr_t {
unsigned int magic;
unsigned short security;
unsigned short version;
unsigned int reserved;
unsigned int build_info_start;
};
struct boot_struct_t {
struct boot_hdr_t hdr;
#if HAAS_OTA_ENABLED //OTA user add it for debug.
unsigned char ver[16];
#else
unsigned int reserved[4];
#endif
};
struct code_sig_struct_t {
unsigned int code_size;
unsigned short sig_len;
unsigned short reserved;
unsigned char sig[SIG_LEN];
};
struct exec_struct_t {
unsigned int entry;
unsigned int param;
unsigned int sp;
unsigned int exec_addr;
};
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/boot_struct/tool_msg.h
|
C
|
apache-2.0
| 7,265
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "plat_addr_map.h"
#define BUILD_INFO_LOCATION __attribute__((section(".build_info")))
#define TO_STR_A(s) # s
#define TO_STR(s) TO_STR_A(s)
#ifdef TRACE_CRLF
#define NEW_LINE_STR "\r\n"
#else
#define NEW_LINE_STR "\n"
#endif
const char BUILD_INFO_LOCATION sys_build_info[] =
#if defined(ROM_BUILD) || defined(PROGRAMMER)
__DATE__ " " __TIME__ " " TO_STR(REVISION_INFO);
#else
NEW_LINE_STR "CHIP=" TO_STR(CHIP)
#ifdef CHIP_SUBTYPE
NEW_LINE_STR "CHIP_SUBTYPE=" TO_STR(CHIP_SUBTYPE)
#endif
NEW_LINE_STR "KERNEL=" TO_STR(KERNEL)
#ifdef OTA_CODE_OFFSET
NEW_LINE_STR "OTA_CODE_OFFSET=" TO_STR(OTA_CODE_OFFSET)
#endif
#ifdef SOFTWARE_VERSION
NEW_LINE_STR "SW_VER=" TO_STR(SOFTWARE_VERSION)
#endif
#ifdef OTA_BOOT_SIZE
NEW_LINE_STR "SW_TYPE=OTA"
NEW_LINE_STR "OTA_BOOT_SIZE=" TO_STR(OTA_BOOT_SIZE)
#else
NEW_LINE_STR "CRASH_DUMP_SIZE=" TO_STR(CRASH_DUMP_SECTION_SIZE)
NEW_LINE_STR "AUD_SEC_SIZE=" TO_STR(AUD_SECTION_SIZE)
NEW_LINE_STR "USER_SEC_SIZE=" TO_STR(USERDATA_SECTION_SIZE)
NEW_LINE_STR "FACT_SEC_SIZE=" TO_STR(FACTORY_SECTION_SIZE)
NEW_LINE_STR "NV_REC_DEV_VER=" TO_STR(NV_REC_DEV_VER)
#endif
NEW_LINE_STR "FLASH_BASE=" TO_STR(FLASH_NC_BASE)
NEW_LINE_STR "FLASH_SIZE=" TO_STR(FLASH_SIZE)
#ifdef OTA_REMAP_OFFSET
NEW_LINE_STR "OTA_REMAP_OFFSET=" TO_STR(OTA_REMAP_OFFSET)
#endif
NEW_LINE_STR "CRC32_OF_IMAGE=0x00000000"
//--------------------
// Add new items above
//--------------------
NEW_LINE_STR "BUILD_DATE=" __DATE__ " " __TIME__
NEW_LINE_STR "REV_INFO=" TO_STR(REVISION_INFO)
NEW_LINE_STR;
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/build_info/build_info.c
|
C
|
apache-2.0
| 2,362
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HEAP_API__
#define __HEAP_API__
#include "stdint.h"
#include "string.h"
#include "multi_heap.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SYSPOOL_PURE __attribute__((__const__))
void syspool_init(void);
void syspool_init_specific_size(uint32_t size);
int syspool_free_size(void);
int syspool_get_buff(uint8_t **buff, uint32_t size);
int syspool_get_available(uint8_t **buff);
uint8_t* syspool_start_addr(void) SYSPOOL_PURE;
uint32_t syspool_total_size(void);
uint32_t syspool_original_size(void) SYSPOOL_PURE;
#if defined(A2DP_LDAC_ON)
int syspool_force_used_size(uint32_t size);
#endif
#define heap_malloc multi_heap_malloc
#define heap_free multi_heap_free
#define heap_realloc multi_heap_realloc
#define heap_get_allocated_size multi_heap_get_allocated_size
#define heap_register multi_heap_register
#define heap_free_size multi_heap_free_size
#define heap_minimum_free_size multi_heap_minimum_free_size
#define heap_get_info multi_heap_get_info
#define heap_dump multi_heap_dump
#define heap_check multi_heap_check
typedef struct multi_heap_info *heap_handle_t;
heap_handle_t heap_register(void *start, size_t size);
void *heap_malloc(heap_handle_t heap, size_t size);
void heap_free(heap_handle_t heap, void *p);
void *heap_realloc(heap_handle_t heap, void *p, size_t size);
size_t heap_get_allocated_size(heap_handle_t heap, void *p);
void heap_set_lock(heap_handle_t heap, void* lock);
void heap_dump(heap_handle_t heap);
bool heap_check(heap_handle_t heap, bool print_errors);
size_t heap_free_size(heap_handle_t heap);
size_t heap_minimum_free_size(heap_handle_t heap);
void heap_get_info(heap_handle_t heap, multi_heap_info_t *info);
void heap_memory_info(heap_handle_t heap,
size_t *total,
size_t *used,
size_t *max_used);
#if 0
void *malloc(size_t size);
void free(void *p);
void *calloc(size_t nmemb, size_t size);
void *realloc(void *ptr, size_t size);
#endif
void med_heap_init(void *begin_addr, size_t size);
void med_heap_set_cp(int switch_cp);
void med_heap_add_block(void *begin_addr, size_t size);
void *med_malloc(size_t size);
void med_free(void *p);
void *med_calloc(size_t nmemb, size_t size);
void *med_realloc(void *ptr, size_t size);
void med_memory_info(size_t *total,
size_t *used,
size_t *max_used);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/heap/heap_api.h
|
C
|
apache-2.0
| 3,034
|
#include "heap_api.h"
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/heap/med_memory.h
|
C
|
apache-2.0
| 22
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
/* multi_heap is a heap implementation for handling multiple
heterogenous heaps in a single program.
Any contiguous block of memory can be registered as a heap.
*/
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Opaque handle to a registered heap */
typedef struct multi_heap_info *multi_heap_handle_t;
/** @brief malloc() a buffer in a given heap
*
* Semantics are the same as standard malloc(), only the returned buffer will be allocated in the specified heap.
*
* @param heap Handle to a registered heap.
* @param size Size of desired buffer.
*
* @return Pointer to new memory, or NULL if allocation fails.
*/
void *multi_heap_malloc(multi_heap_handle_t heap, size_t size);
/** @brief free() a buffer in a given heap.
*
* Semantics are the same as standard free(), only the argument 'p' must be NULL or have been allocated in the specified heap.
*
* @param heap Handle to a registered heap.
* @param p NULL, or a pointer previously returned from multi_heap_malloc() or multi_heap_realloc() for the same heap.
*/
void multi_heap_free(multi_heap_handle_t heap, void *p);
/** @brief realloc() a buffer in a given heap.
*
* Semantics are the same as standard realloc(), only the argument 'p' must be NULL or have been allocated in the specified heap.
*
* @param heap Handle to a registered heap.
* @param p NULL, or a pointer previously returned from multi_heap_malloc() or multi_heap_realloc() for the same heap.
* @param size Desired new size for buffer.
*
* @return New buffer of 'size' containing contents of 'p', or NULL if reallocation failed.
*/
void *multi_heap_realloc(multi_heap_handle_t heap, void *p, size_t size);
/** @brief Return the size that a particular pointer was allocated with.
*
* @param heap Handle to a registered heap.
* @param p Pointer, must have been previously returned from multi_heap_malloc() or multi_heap_realloc() for the same heap.
*
* @return Size of the memory allocated at this block. May be more than the original size argument, due
* to padding and minimum block sizes.
*/
size_t multi_heap_get_allocated_size(multi_heap_handle_t heap, void *p);
/** @brief Register a new heap for use
*
* This function initialises a heap at the specified address, and returns a handle for future heap operations.
*
* There is no equivalent function for deregistering a heap - if all blocks in the heap are free, you can immediately start using the memory for other purposes.
*
* @param start Start address of the memory to use for a new heap.
* @param size Size (in bytes) of the new heap.
*
* @return Handle of a new heap ready for use, or NULL if the heap region was too small to be initialised.
*/
multi_heap_handle_t multi_heap_register(void *start, size_t size);
/** @brief Associate a private lock pointer with a heap
*
* The lock argument is supplied to the MULTI_HEAP_LOCK() and MULTI_HEAP_UNLOCK() macros, defined in multi_heap_platform.h.
*
* The lock in question must be recursive.
*
* When the heap is first registered, the associated lock is NULL.
*
* @param heap Handle to a registered heap.
* @param lock Optional pointer to a locking structure to associate with this heap.
*/
void multi_heap_set_lock(multi_heap_handle_t heap, void* lock);
/** @brief Dump heap information to stdout
*
* For debugging purposes, this function dumps information about every block in the heap to stdout.
*
* @param heap Handle to a registered heap.
*/
void multi_heap_dump(multi_heap_handle_t heap);
/** @brief Check heap integrity
*
* Walks the heap and checks all heap data structures are valid. If any errors are detected, an error-specific message
* can be optionally printed to stderr. Print behaviour can be overriden at compile time by defining
* MULTI_CHECK_FAIL_PRINTF in multi_heap_platform.h.
*
* @param heap Handle to a registered heap.
* @param print_errors If true, errors will be printed to stderr.
* @return true if heap is valid, false otherwise.
*/
bool multi_heap_check(multi_heap_handle_t heap, bool print_errors);
/** @brief Return free heap size
*
* Returns the number of bytes available in the heap.
*
* Equivalent to the total_free_bytes member returned by multi_heap_get_heap_info().
*
* Note that the heap may be fragmented, so the actual maximum size for a single malloc() may be lower. To know this
* size, see the largest_free_block member returned by multi_heap_get_heap_info().
*
* @param heap Handle to a registered heap.
* @return Number of free bytes.
*/
size_t multi_heap_free_size(multi_heap_handle_t heap);
/** @brief Return the lifetime minimum free heap size
*
* Equivalent to the minimum_free_bytes member returned by multi_heap_get_info().
*
* Returns the lifetime "low water mark" of possible values returned from multi_free_heap_size(), for the specified
* heap.
*
* @param heap Handle to a registered heap.
* @return Number of free bytes.
*/
size_t multi_heap_minimum_free_size(multi_heap_handle_t heap);
/** @brief Structure to access heap metadata via multi_heap_get_info */
typedef struct {
size_t total_free_bytes; ///< Total free bytes in the heap. Equivalent to multi_free_heap_size().
size_t total_allocated_bytes; ///< Total bytes allocated to data in the heap.
size_t largest_free_block; ///< Size of largest free block in the heap. This is the largest malloc-able size.
size_t minimum_free_bytes; ///< Lifetime minimum free heap size. Equivalent to multi_minimum_free_heap_size().
size_t allocated_blocks; ///< Number of (variable size) blocks allocated in the heap.
size_t free_blocks; ///< Number of (variable size) free blocks in the heap.
size_t total_blocks; ///< Total number of (variable size) blocks in the heap.
size_t total_bytes;
} multi_heap_info_t;
/** @brief Return metadata about a given heap
*
* Fills a multi_heap_info_t structure with information about the specified heap.
*
* @param heap Handle to a registered heap.
* @param info Pointer to a structure to fill with heap metadata.
*/
void multi_heap_get_info(multi_heap_handle_t heap, multi_heap_info_t *info);
#ifdef __cplusplus
}
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/heap/multi_heap.h
|
C
|
apache-2.0
| 6,867
|
/*
* Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HWTIMER_LIST_H__
#define __HWTIMER_LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef void *HWTIMER_ID;
typedef void (*HWTIMER_CALLBACK_T)(void *param);
enum E_HWTIMER_T {
E_HWTIMER_OK = 0,
E_HWTIMER_FAILED,
E_HWTIMER_INVAL_ID,
E_HWTIMER_INVAL_ST,
E_HWTIMER_IN_CALLBACK,
E_HWTIMER_NOT_FOUND,
};
void hwtimer_init(void);
HWTIMER_ID hwtimer_alloc(HWTIMER_CALLBACK_T callback, void *param);
enum E_HWTIMER_T hwtimer_free(HWTIMER_ID id);
enum E_HWTIMER_T hwtimer_start(HWTIMER_ID id, unsigned int ticks);
enum E_HWTIMER_T hwtimer_update_then_start(HWTIMER_ID id, HWTIMER_CALLBACK_T callback, void *param, unsigned int ticks);
enum E_HWTIMER_T hwtimer_update(HWTIMER_ID id, HWTIMER_CALLBACK_T callback, void *param);
enum E_HWTIMER_T hwtimer_stop(HWTIMER_ID id);
#ifdef __cplusplus
}
#endif
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/drivers/utils/hwtimer_list/hwtimer_list.h
|
C
|
apache-2.0
| 1,497
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "boot_ringbuffer.h"
int32_t boot_ringbuff_reset(boot_ringbuff_t *rb)
{
if (!rb) {
return -1;
}
rb->rd_ptr = rb->buffer;
rb->wr_ptr = rb->buffer;
rb->dirty_size = 0;
rb->free_size = rb->buffer_end - rb->buffer;
return 0;
}
int32_t boot_ringbuff_init(boot_ringbuff_t *rb, uint8_t *buffer, int32_t size)
{
if (!rb) {
return -1;
}
if (!buffer) {
return -1;
}
if (size <= 4) {
return -1;
}
rb->buffer = buffer;
rb->buffer_end = rb->buffer + size;
boot_ringbuff_reset(rb);
return 0;
}
int32_t boot_ringbuff_freesize(boot_ringbuff_t *rb)
{
if (!rb) {
return -1;
}
return rb->free_size;
}
int32_t boot_ringbuff_dirtysize(boot_ringbuff_t *rb)
{
if (!rb) {
return -1;
}
return rb->dirty_size;
}
int32_t boot_ringbuff_fill(boot_ringbuff_t *rb, uint8_t *buffer, int32_t size)
{
if (!rb) {
return -1;
}
if (size > rb->free_size || size <= 0) {
return -1;
}
if ((rb->buffer_end - rb->wr_ptr >= size &&
rb->wr_ptr >= rb->rd_ptr) ||
rb->wr_ptr < rb->rd_ptr) {
memcpy(rb->wr_ptr, buffer, size);
rb->wr_ptr += size;
rb->dirty_size += size;
rb->free_size -= size;
if (rb->wr_ptr >= rb->buffer_end)
rb->wr_ptr = rb->buffer;
} else if (rb->buffer_end - rb->wr_ptr < size &&
rb->wr_ptr >= rb->rd_ptr) {
int temp = rb->buffer_end - rb->wr_ptr;
memcpy(rb->wr_ptr, buffer, temp);
rb->wr_ptr = rb->buffer;
memcpy(rb->wr_ptr, buffer + temp, size - temp);
rb->dirty_size += size;
rb->free_size -= size;
rb->wr_ptr += size - temp;
} else {
return -1;
}
return size;
}
int32_t boot_ringbuff_read(boot_ringbuff_t *rb, uint8_t *buffer, int32_t size)
{
if (!rb) {
return -1;
}
if (size > rb->dirty_size || size <= 0) {
return -1;
}
if (rb->rd_ptr < rb->wr_ptr &&
rb->wr_ptr - rb->rd_ptr >= size) {
memcpy(buffer, rb->rd_ptr, size);
rb->dirty_size -= size;
rb->free_size += size;
rb->rd_ptr += size;
} else if (rb->rd_ptr >= rb->wr_ptr) {
if (rb->buffer_end - rb->rd_ptr >= size) {
memcpy(buffer, rb->rd_ptr, size);
rb->dirty_size -= size;
rb->free_size += size;
rb->rd_ptr += size;
if (rb->rd_ptr >= rb->buffer_end)
rb->rd_ptr = rb->buffer;
} else {
int temp = rb->buffer_end - rb->rd_ptr;
memcpy(buffer, rb->rd_ptr, temp);
rb->rd_ptr = rb->buffer;
memcpy(buffer + temp, rb->rd_ptr, size - temp);
rb->dirty_size -= size;
rb->free_size += size;
rb->rd_ptr += size - temp;
}
} else {
return -1;
}
return size;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/boot_ringbuffer.c
|
C
|
apache-2.0
| 2,606
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef __BOOT_RINGBUFFER_H__
#define __BOOT_RINGBUFFER_H__
#include <stdint.h>
typedef struct {
uint8_t *buffer;
uint8_t *buffer_end;
uint8_t *rd_ptr;
uint8_t *wr_ptr;
int32_t free_size;
int32_t dirty_size;
} boot_ringbuff_t;
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/boot_ringbuffer.h
|
C
|
apache-2.0
| 308
|
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include "2ndboot.h"
#include "flash.h"
#include "cmsis.h"
#include "hal_trace.h"
#include "hal_norflash.h"
extern const hal_logic_partition_t hal_partitions[];
hal_logic_partition_t *flash_get_info(hal_partition_t pno)
{
if(pno >= HAL_PARTITION_MAX)
{
return NULL;
}
return &hal_partitions[pno];
}
int flash_erase(unsigned int offset, unsigned int len)
{
int ret = 0;
unsigned int addr;
unsigned int start_addr;
unsigned int end_addr;
uint32_t lock = 0;
start_addr = ROUND_DOWN(offset, SECTOR_SIZE);
end_addr = ROUND_DOWN((offset + len - 1), SECTOR_SIZE);
for (addr = start_addr; addr <= end_addr; addr += SECTOR_SIZE) {
lock = int_lock();
pmu_flash_write_config();
hal_norflash_disable_remap(HAL_NORFLASH_ID_0);
ret = hal_norflash_erase(HAL_NORFLASH_ID_0, addr, SECTOR_SIZE);
hal_norflash_re_enable_remap(HAL_NORFLASH_ID_0);
if (ret != HAL_NORFLASH_OK) {
printf("error %s %d, ret:%d", __func__, __LINE__, ret);
}
pmu_flash_read_config();
int_unlock(lock);
}
return 0;
}
int flash_read_data(unsigned int offset, unsigned char *buf, unsigned int len)
{
int ret = 0;
unsigned int lock = 0;
volatile char *flashPointer = NULL;
if (buf == NULL) {
return -1;
}
if (len == 0) {
return -1;
}
lock = int_lock();
hal_norflash_disable_remap(HAL_NORFLASH_ID_0);
flashPointer = (volatile char *)(FLASH_NC_BASE + offset);
memcpy(buf, (void *)flashPointer, len);
hal_norflash_re_enable_remap(HAL_NORFLASH_ID_0);
int_unlock(lock);
if (ret != HAL_NORFLASH_OK) {
printf("error %s %d, hal_norflash_write ret:%d", __func__, __LINE__, ret);
}
return 0;
}
int flash_write_data(unsigned int offset, unsigned char *buf, unsigned int len)
{
int ret = 0;
unsigned int lock = 0;
if (buf == NULL) {
return -1;
}
if (len == 0) {
return -1;
}
lock = int_lock();
pmu_flash_write_config();
hal_norflash_disable_remap(HAL_NORFLASH_ID_0);
ret = hal_norflash_write(HAL_NORFLASH_ID_0, offset, buf, len);
hal_norflash_re_enable_remap(HAL_NORFLASH_ID_0);
pmu_flash_read_config();
int_unlock(lock);
if (ret != HAL_NORFLASH_OK) {
printf("error %s %d, hal_norflash_write ret:%d", __func__, __LINE__, ret);
}
return 0;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/flash.c
|
C
|
apache-2.0
| 2,566
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef __2NDBOOT_FLASH_H__
#define __2NDBOOT_FLASH_H__
#define REG_READ(addr) *((volatile UINT32 *)(addr))
#define REG_WRITE(addr, _data) (*((volatile UINT32 *)(addr)) = (_data))
#define MODE_STD 0
#define MODE_DUAL 1
#define MODE_QUAD 2
#define FLASH_WRITE_UNIT 32
#define FLASH_BASE (0x00803000)
#define REG_FLASH_OPERATE_SW (FLASH_BASE + 0 * 4)
#define ADDR_SW_REG_POSI (0)
#define ADDR_SW_REG_MASK (0xFFFFFF)
#define OP_TYPE_SW_POSI (24)
#define OP_TYPE_SW_MASK (0x1F)
#define OP_SW (0x01UL << 29)
#define WP_VALUE (0x01UL << 30)
#define BUSY_SW (0x01UL << 31)
#define REG_FLASH_DATA_SW_FLASH (FLASH_BASE + 1 * 4)
#define REG_FLASH_DATA_FLASH_SW (FLASH_BASE + 2 * 4)
#define REG_FLASH_RDID_DATA_FLASH (FLASH_BASE + 4 * 4)
#define REG_FLASH_SR_DATA_CRC_CNT (FLASH_BASE + 5 * 4)
#define SR_DATA_FLASH_POSI (0)
#define SR_DATA_FLASH_MASK (0xFF)
#define CRC_ERROR_COUNT_POSI (8)
#define CRC_ERROR_COUNT_MASK (0xFF)
#define DATA_FLASH_SW_SEL_POSI (16)
#define DATA_FLASH_SW_SEL_MASK (0x07)
#define DATA_SW_FLASH_SEL_POSI (19)
#define DATA_SW_FLASH_SEL_MASK (0x07)
#define REG_FLASH_CONF (FLASH_BASE + 7 * 4)
#define FLASH_CLK_CONF_POSI (0)
#define FLASH_CLK_CONF_MASK (0x0F)
#define MODEL_SEL_POSI (4)
#define MODEL_SEL_MASK (0x1F)
#define FWREN_FLASH_CPU (0x01UL << 9)
#define WRSR_DATA_POSI (10)
#define WRSR_DATA_MASK (0xFFFF)
#define CRC_EN (0x01UL << 26)
typedef enum
{
FLASH_OPCODE_WREN = 1,
FLASH_OPCODE_WRDI = 2,
FLASH_OPCODE_RDSR = 3,
FLASH_OPCODE_WRSR = 4,
FLASH_OPCODE_READ = 5,
FLASH_OPCODE_RDSR2 = 6,
FLASH_OPCODE_WRSR2 = 7,
FLASH_OPCODE_PP = 12,
FLASH_OPCODE_SE = 13,
FLASH_OPCODE_BE1 = 14,
FLASH_OPCODE_BE2 = 15,
FLASH_OPCODE_CE = 16,
FLASH_OPCODE_DP = 17,
FLASH_OPCODE_RFDP = 18,
FLASH_OPCODE_RDID = 20,
FLASH_OPCODE_HPM = 21,
FLASH_OPCODE_CRMR = 22,
FLASH_OPCODE_CRMR2 = 23,
} FLASH_OPCODE;
#endif // __2NDBOOT_FLASH_H__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/flash.h
|
C
|
apache-2.0
| 2,764
|
#include "2ndboot.h"
void ota_2ndboot_os_entry(void)
{
return;
}
void ota_2ndboot_image_entry(void)
{
printf("2ndboot image start \n");
/* normal start */
printf("os image start\r\n");
ota_2ndboot_os_entry();
}
#ifdef AOS_2ND_BOOT_AB
extern int ota_get_ab_boot(void);
extern void ota_switch_ab_boot(void);
int ota_2ndboot_ab_get(void)
{
return ota_get_ab_boot();
}
void ota_2ndboot_ab_switch(void)
{
ota_switch_ab_boot();
}
#endif
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/startup.c
|
C
|
apache-2.0
| 467
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "sys.h"
static uint8_t ota_2ndboot_heap[256*1024];
void sys_delayms(volatile int ms)
{
osDelay(ms);
}
void sys_reboot(void)
{
hal_cmu_sys_reboot();
}
void *sys_set_heap(unsigned int *size)
{
memset(ota_2ndboot_heap, 0, sizeof(ota_2ndboot_heap));
*size = sizeof(ota_2ndboot_heap);
return ota_2ndboot_heap;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/sys.c
|
C
|
apache-2.0
| 403
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#ifndef __2NDBOOT_SYS_H__
#define __2NDBOOT_SYS_H__
#include "2ndboot.h"
#endif // __2NDBOOT_SYS_H__
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/sys.h
|
C
|
apache-2.0
| 167
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "2ndboot.h"
#include "hal_trace.h"
#include "hal_uart.h"
#include "libc.h"
#include "boot_ringbuffer.h"
static enum HAL_UART_ID_T trace_uart = HAL_UART_ID_0;
#define TRACE_RX_BUFFER_SIZE 1032
__SRAMBSS unsigned char hal_trace_rx_buf[TRACE_RX_BUFFER_SIZE];
__SRAMBSS unsigned char uart_rx_ringbuf[TRACE_RX_BUFFER_SIZE*2];
struct HAL_DMA_DESC_T dma_desc_rx;
static boot_ringbuff_t uart_ringbuff = {NULL, NULL, NULL, NULL, 0, 0};
static void console_hal_trace_rx_start(void)
{
unsigned int desc_cnt = 1;
union HAL_UART_IRQ_T mask;
mask.reg = 0;
mask.BE = 0;
mask.FE = 0;
mask.OE = 0;
mask.PE = 0;
mask.RT = 1;
hal_uart_dma_recv_mask(trace_uart, hal_trace_rx_buf, TRACE_RX_BUFFER_SIZE, &dma_desc_rx, &desc_cnt, &mask);
}
static void console_uart_dma_rx_handler(uint32_t xfer_size, int dma_error, union HAL_UART_IRQ_T status)
{
boot_ringbuff_fill(&uart_ringbuff, hal_trace_rx_buf, xfer_size);
console_hal_trace_rx_start();
}
int hal_trace_rx_start(void)
{
struct HAL_UART_CFG_T uart_cfg = {
.dma_rx = true,
.dma_tx = false,
.dma_rx_stop_on_err = false,
};
hal_uart_reopen(trace_uart, &uart_cfg);
hal_uart_irq_set_dma_handler(trace_uart, console_uart_dma_rx_handler, NULL, NULL);
console_hal_trace_rx_start();
return 0;
}
static int uart_ringbuffer_init(void)
{
int ret;
uint8_t *buffer = NULL;
memset(&uart_ringbuff, 0, sizeof(uart_ringbuff));
buffer = uart_rx_ringbuf;
if(buffer == NULL) {
return -1;
}
ret = boot_ringbuff_init(&uart_ringbuff, buffer, TRACE_RX_BUFFER_SIZE*2);
return ret;
}
void uart_init(void)
{
uart_ringbuffer_init();
hal_trace_rx_start();
return;
}
void uart_send(unsigned char *buf, int len)
{
for (uint32_t i = 0; i < len; i++) {
hal_uart_blocked_putc(trace_uart, buf[i]);
}
}
void uart_send_string(char *buf)
{
int len = strlen(buf);
uart_send(buf, len);
}
void uart_send_byte(unsigned char buf)
{
hal_uart_blocked_putc(trace_uart, buf);
}
unsigned char uart_recv_byte(unsigned char *c)
{
int ret = 0;
ret = boot_ringbuff_read(&uart_ringbuff, c, 1);
if(ret < 0) {
return 0;
}
return 1;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/uart.c
|
C
|
apache-2.0
| 2,277
|
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include "2ndboot.h"
#include "sys.h"
#include "cmsis.h"
#include "hal_wdt.h"
#include "hal_bootmode.h"
static int set_silent_reboot_flag(void)
{
hal_sw_bootmode_set(HAL_SW_BOOTMODE_RESERVED_BIT24);
return 0;
}
static void app_wdt_irq_handle(enum HAL_WDT_ID_T id, uint32_t status)
{
analog_aud_codec_mute();
set_silent_reboot_flag();
}
void wdg_init(unsigned int ms)
{
uint32_t lock = int_lock();
hal_wdt_set_irq_callback(HAL_WDT_ID_0, app_wdt_irq_handle);
hal_wdt_set_timeout(HAL_WDT_ID_0, ms /1000);
hal_wdt_start(HAL_WDT_ID_0);
int_unlock(lock);
}
void wdg_feed(void)
{
hal_wdt_ping(HAL_WDT_ID_0);
}
void wdg_finish()
{
uint32_t lock = 0;
lock = int_lock();
hal_wdt_stop(HAL_WDT_ID_0);
int_unlock(lock);
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/2ndboot/wdg.c
|
C
|
apache-2.0
| 833
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include <errno.h>
#include "aos/hal/adc.h"
#include "hal_trace.h"
#include "hal_gpadc.h"
static void __hal_adc_irqhandler(uint16_t irq_val, HAL_GPADC_MV_T volt)
{
//printf("%s irq_val=%d, volt=%d\n", __FUNCTION__, irq_val, volt);
}
static enum HAL_GPADC_CHAN_T __hal_adc_port2chan(uint8_t port)
{
return (port<3) ? port+HAL_GPADC_CHAN_2 : HAL_GPADC_CHAN_QTY;
}
/**
* Initialises an ADC interface, Prepares an ADC hardware interface for sampling
*
* @param[in] adc the interface which should be initialised
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_adc_init(adc_dev_t *adc)
{
//printf("%s port=%d, sampling_cycle=%d, priv=%p\n", __FUNCTION__, adc->port, adc->config.sampling_cycle, adc->priv);
if (adc->config.sampling_cycle) {
hal_gpadc_open(__hal_adc_port2chan(adc->port), HAL_GPADC_ATP_NULL, NULL);
} else {
hal_gpadc_open(__hal_adc_port2chan(adc->port), HAL_GPADC_ATP_ONESHOT, __hal_adc_irqhandler);
}
return 0;
}
/**
* Takes a single sample from an ADC interface
*
* @param[in] adc the interface which should be sampled
* @param[out] output pointer to a variable which will receive the sample
* @param[in] timeout ms timeout
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_adc_value_get(adc_dev_t *adc, uint32_t *output, uint32_t timeout)
{
int count = 5;
enum HAL_GPADC_CHAN_T channel;
HAL_GPADC_MV_T volt = HAL_GPADC_BAD_VALUE;
if (output == NULL)
return -EINVAL;
channel = __hal_adc_port2chan(adc->port);
if (channel >= HAL_GPADC_CHAN_QTY)
return -EINVAL;
hal_gpadc_open(channel, HAL_GPADC_ATP_ONESHOT, NULL);
osDelay(1);
while (count--) {
if (hal_gpadc_get_volt(channel, &volt)) {
*output = volt;
return 0;
}
osDelay(1);
}
return -EIO;
}
/**
* De-initialises an ADC interface, Turns off an ADC hardware interface
*
* @param[in] adc the interface which should be de-initialised
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_adc_finalize(adc_dev_t *adc)
{
//printf("%s port=%d, sampling_cycle=%d, priv=%p\n", __FUNCTION__, adc->port, adc->config.sampling_cycle, adc->priv);
hal_gpadc_close(__hal_adc_port2chan(adc->port));
return 0;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/adc.c
|
C
|
apache-2.0
| 2,314
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include <ulog/ulog.h>
#include <string.h>
#include <aos/list.h>
#include "audio_rtos.h"
#include "control.h"
#include "alsa.h"
#include "mcu_audio.h"
#define LOG_TAG "[haas1000_audio]"
static const int32_t volume_step[] = {
2, // 0 mute codec_dac_vol[2] = -99 db
53, // 1 0 codec_dac_vol[53] = -48 db
53, // 2 codec_dac_vol[53] = -48 db
54, // 3 codec_dac_vol[54] = -47 db
54, // 4 codec_dac_vol[54] = -47 db
55, // 5 codec_dac_vol[55] = -46 db
55, // 6 codec_dac_vol[55] = -46 db
56, // 7 1 codec_dac_vol[56] = -45 db
56, // 8 codec_dac_vol[56] = -45 db
57, // 9 codec_dac_vol[57] = -44 db
57, // 10 codec_dac_vol[57] = -44 db
58, // 11 codec_dac_vol[58] = -43 db
58, // 12 codec_dac_vol[58] = -43 db
59, // 13 2 codec_dac_vol[59] = -42 db
59, // 14 codec_dac_vol[59] = -42 db
60, // 15 codec_dac_vol[60] = -41 db
60, // 16 codec_dac_vol[60] = -41 db
61, // 17 codec_dac_vol[61] = -40 db
61, // 18 codec_dac_vol[61] = -40 db
62, // 19 3 codec_dac_vol[62] = -39 db
62, // 20 codec_dac_vol[62] = -39 db
63, // 21 codec_dac_vol[63] = -38 db
63, // 22 codec_dac_vol[63] = -38 db
64, // 23 codec_dac_vol[64] = -37 db
64, // 24 codec_dac_vol[64] = -37 db
65, // 25 4 codec_dac_vol[65] = -36 db
65, // 26 codec_dac_vol[65] = -36 db
66, // 27 codec_dac_vol[66] = -35 db
66, // 28 codec_dac_vol[66] = -35 db
67, // 29 codec_dac_vol[67] = -34 db
67, // 30 codec_dac_vol[67] = -34 db
68, // 31 5 codec_dac_vol[68] = -33 db
68, // 32 codec_dac_vol[68] = -33 db
69, // 33 codec_dac_vol[69] = -32 db
69, // 34 codec_dac_vol[69] = -32 db
70, // 35 codec_dac_vol[70] = -31 db
70, // 36 codec_dac_vol[70] = -31 db
71, // 37 6 codec_dac_vol[71] = -30 db
71, // 38 codec_dac_vol[71] = -30 db
72, // 39 codec_dac_vol[72] = -29 db
72, // 40 codec_dac_vol[72] = -29 db
73, // 41 codec_dac_vol[73] = -28 db
73, // 42 codec_dac_vol[73] = -28 db
74, // 43 codec_dac_vol[74] = -27 db
74, // 44 7 codec_dac_vol[74] = -27 db
75, // 45 codec_dac_vol[75] = -26 db
75, // 46 codec_dac_vol[75] = -26 db
76, // 47 codec_dac_vol[76] = -25 db
76, // 48 codec_dac_vol[76] = -25 db
77, // 49 codec_dac_vol[77] = -24 db
77, // 50 codec_dac_vol[77] = -24 db
78, // 51 8 codec_dac_vol[78] = -23 db
78, // 52 codec_dac_vol[78] = -23 db
79, // 53 codec_dac_vol[79] = -22 db
79, // 54 codec_dac_vol[79] = -22 db
80, // 55 codec_dac_vol[80] = -21 db
80, // 56 codec_dac_vol[80] = -21 db
81, // 57 codec_dac_vol[81] = -20 db
81, // 58 9 codec_dac_vol[81] = -20 db
82, // 59 codec_dac_vol[82] = -19 db
82, // 60 codec_dac_vol[82] = -19 db
83, // 61 codec_dac_vol[83] = -18 db
83, // 62 codec_dac_vol[83] = -18 db
84, // 63 codec_dac_vol[84] = -17 db
84, // 64 codec_dac_vol[84] = -17 db
85, // 65 10 codec_dac_vol[85] = -16 db
85, // 66 codec_dac_vol[85] = -16 db
86, // 67 codec_dac_vol[86] = -15 db
86, // 68 codec_dac_vol[86] = -15 db
87, // 69 codec_dac_vol[87] = -14 db
87, // 70 codec_dac_vol[87] = -14 db
88, // 71 11 codec_dac_vol[88] = -13 db
88, // 72 codec_dac_vol[88] = -13 db
89, // 73 codec_dac_vol[89] = -12 db
89, // 74 codec_dac_vol[89] = -12 db
90, // 75 codec_dac_vol[90] = -11 db
90, // 76 codec_dac_vol[90] = -11 db
91, // 77 12 codec_dac_vol[91] = -10 db
91, // 78 codec_dac_vol[91] = -10 db
92, // 79 codec_dac_vol[92] = -9 db
92, // 80 codec_dac_vol[92] = -9 db
93, // 81 codec_dac_vol[93] = -8 db
93, // 82 codec_dac_vol[93] = -8 db
94, // 83 13 codec_dac_vol[94] = -7 db
94, // 84 codec_dac_vol[94] = -7 db
95, // 85 codec_dac_vol[95] = -6 db
95, // 86 codec_dac_vol[95] = -6 db
96, // 87 codec_dac_vol[96] = -5 db
96, // 88 codec_dac_vol[96] = -5 db
97, // 89 14 codec_dac_vol[97] = -4 db
97, // 90 codec_dac_vol[97] = -4 db
98, // 91 codec_dac_vol[98] = -3 db
98, // 92 codec_dac_vol[98] = -3 db
99, // 93 codec_dac_vol[99] = -2 db
99, // 94 codec_dac_vol[99] = -2 db
99, // 95 codec_dac_vol[99] = -2 db
100, // 96 codec_dac_vol[100] = -1 db
100, // 97 codec_dac_vol[100] = -1 db
100, // 98 codec_dac_vol[100] = -1 db
100, // 99 codec_dac_vol[100] = -1 db
101, // 100 15 codec_dac_vol[101] = 0 db
};
pcm_stream_handler_t playback_stream_hdl = NULL;
pcm_stream_handler_t capture_stream_hdl = NULL;
static int codec_hw_vol_get(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol);
static int codec_hw_vol_put(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol);
static int codec_hw_mute_state_get(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol);
static int codec_hw_mute_state_put(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol);
static const struct audio_kcontrol_new master_codec_controls[] = {
SOC_SINGLE_EXT("Master Volume TX", /* master volume attribute name: defined in sound_mixer.h */
0,
0, /* codec volume minimum value */
63, /* codec volume maxmum value */
0,
codec_hw_vol_get, /* get codec volume api */
codec_hw_vol_put), /* set codec volume api */
SOC_SINGLE_EXT("Master Mute State", /* master mute attribute name: defined in sound_mixer.h */
0,
0, /* codec mute state minimum value */
1, /* codec mute state maxmum value */
0,
codec_hw_mute_state_get, /* get codec mute state */
codec_hw_mute_state_put), /* put codec mute state */
};
static int codec_hw_mute_state_get(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol)
{
int mute = 0;
if(!kcontrol || !ucontrol) {
LOGE(LOG_TAG, "%s:%d: invalid params. \r\n", __func__, __LINE__);
return -1;
}
// TBD: get codec mute state, e.g. mute = ac97_get_mute();
LOGD(LOG_TAG, "%s:%d: get mute state %d \r\n", __func__, __LINE__, mute);
ucontrol->value.integer.value[0] = mute;
return 0;
}
static int codec_hw_mute_state_put(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol)
{
int mute = 0;
if(!kcontrol || !ucontrol) {
LOGE(LOG_TAG, "%s:%d: invalid params. \r\n", __func__, __LINE__);
return -1;
}
mute = ucontrol->value.integer.value[0];
LOGD(LOG_TAG, "%s:%d: set mute state %d \r\n", __func__, __LINE__, mute);
// TBD: set codec mute state, e.g. ac97_set_mute(mute);
return 0;
}
static int codec_hw_vol_get(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol)
{
int volume = 0;
if(!kcontrol || !ucontrol) {
LOGE(LOG_TAG, "%s:%d: invalid params. \r\n", __func__, __LINE__);
return -1;
}
// TBD: get codec volume, e.g. volume = ac97_get_vol();
volume = alsa_volume_percent_get();
LOGD(LOG_TAG, "%s:%d: get volume %d \r\n", __func__, __LINE__, volume);
ucontrol->value.integer.value[0] = volume;
return 0;
}
static int codec_hw_vol_put(struct audio_kcontrol *kcontrol, struct audio_ctl_elem_value *ucontrol)
{
int volume = 0, dac_vol = 0;
if(!kcontrol || !ucontrol) {
LOGE(LOG_TAG, "%s:%d: invalid params. \r\n", __func__, __LINE__);
return -1;
}
volume = ucontrol->value.integer.value[0];
if (volume < 0)
{
volume = 0;
}
if (volume > 100)
{
volume = 100;
}
LOGD(LOG_TAG, "%s:%d: set volume %d \r\n", __func__, __LINE__, volume);
dac_vol = volume_step[volume];
alsa_volume_set(volume, dac_vol);
return 0;
}
static pcm_stream_handler_t codec_pcm_stream_open(int mode, int sampleRate, int channels, pcm_stream_format_t format, aos_hdl_t *event_hdl)
{
if(mode == PCM_STREAM_IN) {
// TBD: initializa capture codec
int large_buf = (sampleRate & 0xFF000000) >> 24;
int _kfifo_len = KFIFO_CAPTURE_SIZE;
if (large_buf)
{
_kfifo_len *= large_buf;
}
capture_stream_hdl = data_dump_open(aud_record_subscribe, _kfifo_len / 1024, sampleRate, 0);
LOGD(LOG_TAG, "%s:%d: capture_stream_hdl 0x%x, mode %d, sampleRate %d, channels %d, format %d \r\n", __func__, __LINE__,
(unsigned int)capture_stream_hdl, PCM_STREAM_OUT, sampleRate, channels, format);
return capture_stream_hdl;
} else if (mode == PCM_STREAM_OUT) {
playback_stream_hdl = (pcm_stream_handler_t)alsa_open(ALSA_MODE_OUT, sampleRate, channels, format);
LOGD(LOG_TAG, "%s:%d: playback_stream_hdl 0x%x, mode %d, sampleRate %d, channels %d, format %d \r\n", __func__, __LINE__,
(unsigned int)playback_stream_hdl, PCM_STREAM_OUT, sampleRate, channels, format);
return playback_stream_hdl;
}
return NULL;
}
static int codec_pcm_stream_start(pcm_stream_handler_t hdl)
{
int ret = 0;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == capture_stream_hdl) {
// TBD: start capture stream
data_dump_start(hdl);
} else if (hdl == &playback_stream_hdl) {
// TBD: start playback stream
}
LOGD(LOG_TAG, "%s:%d, ret = %d.", __func__, __LINE__, ret);
return ret;
}
static int codec_pcm_stream_write(pcm_stream_handler_t hdl, void *buf, unsigned int len)
{
int ret = -1;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == capture_stream_hdl) {
LOGE(LOG_TAG, "%s:%d, write operation not allowed on capture stream.", __func__, __LINE__);
} else if (hdl == playback_stream_hdl) {
ret = alsa_write(playback_stream_hdl, (uint8_t *)buf, len);
}
return ret;
}
static int codec_pcm_stream_read(pcm_stream_handler_t hdl, void *buf, unsigned int len)
{
int ret = -1, i = 0, j = 0;
int channel_num = 3, sample_bytes = 2, frame_size;
char *tempBuf = NULL;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == playback_stream_hdl) {
LOGE(LOG_TAG, "%s:%d, read operation not allowed on playback stream.", __func__, __LINE__);
} else if (hdl == capture_stream_hdl) {
// TBD: read capture stream
frame_size = channel_num * sample_bytes;
tempBuf = (char *)malloc(len * channel_num);
if(tempBuf) {
ret = data_dump_read(hdl, tempBuf, len * channel_num);
for(i = 0; i < ret/frame_size; i++) {
for(j = 0; j < sample_bytes; j++) {
#if (BOARD_HAASEDUK1 == 1) // for audio expansion board
((char *)buf)[i * sample_bytes + j] = tempBuf[i * frame_size + j]; // MIC1
// ((char *)buf)[i * sample_bytes + j] = tempBuf[i * frame_size + sample_bytes + j]; // MIC2
// ((char *)buf)[i * sample_bytes + j] = tempBuf[(i+1)*frame_size - sample_bytes + j]; // MIC3*/
#else
// ((char *)buf)[i * sample_bytes + j] = tempBuf[i * frame_size + j]; // MIC1
// ((char *)buf)[i * sample_bytes + j] = tempBuf[i * frame_size + sample_bytes + j]; // MIC2
((char *)buf)[i * sample_bytes + j] = tempBuf[(i+1)*frame_size - sample_bytes + j]; // MIC3*/
#endif
}
}
ret = ret / channel_num;
}
//LOGD(LOG_TAG, "%s:%d, data_dump_read %d bytes", __func__, __LINE__, ret);
}
return ret;
}
static int codec_pcm_stream_pause(pcm_stream_handler_t hdl, int enable)
{
int ret = -1;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == playback_stream_hdl) {
// TBD: pause playback stream
} else if (hdl == capture_stream_hdl) {
// TBD: pause capture stream
}
LOGD(LOG_TAG, "%s:%d, ret = %d.", __func__, __LINE__, ret);
return ret;
}
static int codec_pcm_stream_suspend(pcm_stream_handler_t hdl)
{
int ret = 0;
if(hdl == &playback_stream_hdl) {
// TBD: put playback stream into lowpower/suspend mode
} else if (hdl == &capture_stream_hdl) {
// TBD: put capture stream into lowpower/suspend mode
}
return ret;
}
static int codec_pcm_stream_resume(pcm_stream_handler_t hdl)
{
int ret = 0;
if(hdl == &playback_stream_hdl) {
// TBD: put playback stream into active mode
} else if (hdl == &capture_stream_hdl) {
// TBD: put playback stream into active mode
}
return ret;
}
static int codec_pcm_stream_stop(pcm_stream_handler_t hdl)
{
int ret = 0;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == capture_stream_hdl) {
// TBD: stop capture stream
data_dump_stop(hdl);
} else if (hdl == playback_stream_hdl) {
ret = alsa_stop(playback_stream_hdl);
}
LOGD(LOG_TAG, "%s:%d, ret = %d.", __func__, __LINE__, ret);
return ret;
}
static int codec_pcm_stream_close(pcm_stream_handler_t hdl)
{
int ret = 0;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == capture_stream_hdl) {
// TBD: close capture stream
data_dump_close(hdl, aud_record_unsubscribe);
capture_stream_hdl = NULL;
} else if (hdl == playback_stream_hdl) {
ret = alsa_close(playback_stream_hdl);
capture_stream_hdl = NULL;
}
LOGD(LOG_TAG, "%s:%d, ret = %d.", __func__, __LINE__, ret);
return ret;
}
static int codec_pcm_stream_recover(pcm_stream_handler_t hdl)
{
int ret = -1;
if(NULL == hdl) {
LOGE(LOG_TAG, "%s:%d, invalid hdl.", __func__, __LINE__);
return ret;
}
if(hdl == capture_stream_hdl) {
// TBD: recover capture stream
} else if (hdl == playback_stream_hdl) {
// TBD: recover playback stream
}
LOGD(LOG_TAG, "%s:%d, ret = %d.", __func__, __LINE__, ret);
return ret;
}
pcm_stream_ops_t codec_pcm_ops = {
.open = codec_pcm_stream_open,
.start = codec_pcm_stream_start,
.read = codec_pcm_stream_read,
.write = codec_pcm_stream_write,
.pause = codec_pcm_stream_pause,
.stop = codec_pcm_stream_stop,
.close = codec_pcm_stream_close,
.recover = codec_pcm_stream_recover,
.suspend = codec_pcm_stream_suspend,
.resume = codec_pcm_stream_resume,
};
/* Application shall call this API to install codec driver instance. */
int audio_install_codec_driver()
{
int pb_stream_num = 1;
int cap_stream_num = 1;
LOGD(LOG_TAG, "%s:%d, install RTOS codec driver %d Capture %d Playback", __func__, __LINE__, cap_stream_num, pb_stream_num);
return audio_native_card_register(cap_stream_num, pb_stream_num, &codec_pcm_ops, master_codec_controls, sizeof(master_codec_controls)/sizeof(master_codec_controls[0]));
}
//FINSH_FUNCTION_EXPORT_CMD(audio_install_codec_driver, insmod_audio_drv, RTOS Codec Driver Test)
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/audio.c
|
C
|
apache-2.0
| 16,322
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "aos/hal/can.h"
/**
* Initialises a CAN interface
*
* @param[in] can the interface which should be initialised
*
* @return 0 : on success, EINVAL : if an error occurred with any step
*/
int32_t hal_can_init(can_dev_t *can)
{
return 0;
}
/**
* config a CAN fliter
*
* @param[in] can the interface which should be initialised
* @param[in] filter_grp_cnt 0 will make all id pass. This value must be <=10
* @param[in] filter_config point to a filter config
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_can_filter_init(can_dev_t *can, const uint8_t filter_grp_cnt, can_filter_item_t *filter_config)
{
return 0;
}
/**
* Transmit data by CAN
*
* @param[in] can the can interface
* @param[in] tx_header frame head
* @param[in] data pointer to the start of data
* @param[in] timeout timeout in milisecond, set this value to HAL_WAIT_FOREVER
* if you want to wait forever
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_can_send(can_dev_t *can, can_frameheader_t *tx_header, const void *data, const uint32_t timeout)
{
return 0;
}
/**
* Receive data by CAN
*
* @param[in] can the can interface
* @param[out] rx_header frame head
* @param[out] data pointer to the start of data
* @param[in] timeout timeout in milisecond, set this value to HAL_WAIT_FOREVER
* if you want to wait forever
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_can_recv(can_dev_t *can, can_frameheader_t *rx_header, void *data, const uint32_t timeout)
{
return 0;
}
/**
* Deinitialises a CAN interface
*
* @param[in] can the interface which should be deinitialised
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_can_finalize(can_dev_t *can)
{
return 0;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/can.c
|
C
|
apache-2.0
| 2,011
|
/*
* Copyright (C) 2015-2020 Alibaba Group Holding Limited
*/
#include "aos/hal/dac.h"
/**
* Initialises an dac interface
*
* @param[in] dac the interface which should be initialised
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_dac_init(dac_dev_t *dac)
{
return 0;
}
/**
* Start output dac
*
* @param[in] dac the interface which should be started
* @param[out] channel the channel to output dac
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_dac_start(dac_dev_t *dac, uint32_t channel)
{
return 0;
}
/**
* Stop output dac
*
* @param[in] dac the interface which should be stopped
* @param[out] channel the channel to output dac
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_dac_stop(dac_dev_t *dac, uint32_t channel)
{
return 0;
}
/**
* Output a value to an dac interface
*
* @param[in] dac the interface to set value
* @param[out] channel the channel to output dac
* @param[in] data the value to output
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_dac_set_value(dac_dev_t *dac, uint32_t channel, uint32_t data)
{
return 0;
}
/**
* Returns the last data output value of the selected dac channel
*
* @param[in] dac the interface to get value
* @param[out] channel channel the channel to output dac
*
* @return dac output value
*/
int32_t hal_dac_get_value(dac_dev_t *dac, uint32_t channel)
{
return 0;
}
/**
* De-initialises an dac interface, Turns off an dac hardware interface
*
* @param[in] dac the interface which should be de-initialised
*
* @return 0 : on success, EIO : if an error occurred with any step
*/
int32_t hal_dac_finalize(dac_dev_t *dac)
{
return 0;
}
|
YifuLiu/AliOS-Things
|
hardware/chip/haas1000/hal/dac.c
|
C
|
apache-2.0
| 1,831
|