Stair56E UART project
This commit is contained in:
@@ -0,0 +1,336 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_task.h
|
||||
*
|
||||
* @brief Header file - APPTASK.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_TASK_H_
|
||||
#define APP_TASK_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APPTASK Task
|
||||
* @ingroup APP
|
||||
* @brief Routes ALL messages to/from APP block.
|
||||
*
|
||||
* The APPTASK is the block responsible for bridging the final application with
|
||||
*the RWBLE software host stack. It communicates with the different modules of
|
||||
*the BLE host, i.e. @ref SMP, @ref GAP and @ref GATT.
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "app_sec.h"
|
||||
#include "co_bt_defines.h"
|
||||
#include "dbg.h"
|
||||
#include "gapm_int.h"
|
||||
#include "gatt_msg_int.h" // GATTC Definitions
|
||||
#include "ke_task.h" // Kernel Task
|
||||
#include "rwip_task.h" // Task definitions
|
||||
#include "usr_client.h"
|
||||
#include "xc_gap_api.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include <stdio.h>
|
||||
|
||||
#define BOND_TEST 0
|
||||
#define MULTI_ROLE_TEST 1
|
||||
#define WHITE_LIST_TEST 0
|
||||
|
||||
#define CONNECT_DEV_NUM 5
|
||||
extern struct app_env_tag app_env;
|
||||
#if (NVDS_SUPPORT)
|
||||
#include "nvds.h"
|
||||
#endif // (NVDS_SUPPORT)
|
||||
|
||||
#define APP_HANDLERS(subtask) \
|
||||
{ \
|
||||
&subtask##_msg_handler_list[0], ARRAY_LEN(subtask##_msg_handler_list) \
|
||||
}
|
||||
|
||||
#define APP_DEVICE_NAME_MAX_LEN (18)
|
||||
/// Default Device Name
|
||||
#define APP_DFLT_DEVICE_NAME ("XC_BLE_MULTI_ROLE")
|
||||
#define APP_DFLT_DEVICE_NAME_LEN (sizeof(APP_DFLT_DEVICE_NAME))//must not be greater than APP_DEVICE_NAME_MAX_LEN
|
||||
/// Maximal length of the Device Name value
|
||||
#define APP_DEVICE_NAME_MAX_LEN (18)
|
||||
#define APP_MAX_TX_POWER (0)
|
||||
// Advertising channel map - 37, 38, 39
|
||||
#define APP_ADV_CHMAP (0x07)
|
||||
// Advertising minimum interval - 40ms (64*0.625ms)
|
||||
#define APP_ADV_INT_MIN (64)
|
||||
// Advertising maximum interval - 40ms (64*0.625ms)
|
||||
#define APP_ADV_INT_MAX (64)
|
||||
|
||||
#define ADV_DATA_MAX_LENGTH 28
|
||||
|
||||
#define MANUFACTURER_DATA "\x09\xFF\x00\x60\x52\x57\x2D\x42\x4C\x45"
|
||||
#define MANUFACTURER_DATA_LEN 10
|
||||
/// Advertising duration (in unit of 10ms). 0 means that advertising continues
|
||||
/// until the host disable it
|
||||
#define ADV_DURATION 0
|
||||
|
||||
#define APP_SCAN_INTERVAL (0xa0)
|
||||
#define APP_SCAN_WINDOW (0x50)
|
||||
|
||||
#define APP_CONN_EST_TIME_OUT (0)
|
||||
#define APP_CONN_SCNA_INTV (32)
|
||||
#define APP_CONN_SCAN_WD (20)
|
||||
#define APP_CONN_INTV_MIN (80)
|
||||
#define APP_CONN_INV_MAX (80)
|
||||
#define APP_CONN_LATENCY (0)
|
||||
#define APP_CONN_TIME_OUT (500)
|
||||
|
||||
/// Number of APP Task Instances
|
||||
#define APP_IDX_MAX 1
|
||||
#define DEV_APPEARANCE 0
|
||||
|
||||
#define BLE_UAPDATA_MIN_INTVALUE 8
|
||||
#define BLE_UAPDATA_MAX_INTVALUE 10
|
||||
#define BLE_UAPDATA_LATENCY 0
|
||||
#define BLE_UAPDATA_TIMEOUT 200
|
||||
|
||||
#define INVALID_DATA 0xFF
|
||||
// #define TAGET_DEVICE_ADDR ("\x02\x6e\x00\x05\x21\x41")
|
||||
#define TAGET_DEVICE_ADDR ("\x41\x21\x05\x00\x6e\x02")
|
||||
|
||||
/// Application environment structure
|
||||
struct app_env_tag
|
||||
{
|
||||
/// Connection handle
|
||||
uint16_t conhdl;
|
||||
/// Connection Index
|
||||
uint8_t conidx;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t adv_state;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t scan_state;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t init_state;
|
||||
/// Next expected operation completed event
|
||||
uint8_t adv_op;
|
||||
|
||||
/// Last initialized profile
|
||||
uint8_t next_svc;
|
||||
|
||||
/// Bonding status
|
||||
bool bonded;
|
||||
|
||||
/// Device Name length
|
||||
uint8_t dev_name_len;
|
||||
/// Device Name
|
||||
uint8_t dev_name[APP_DEVICE_NAME_MAX_LEN];
|
||||
|
||||
/// Local device IRK
|
||||
uint8_t loc_irk[KEY_LEN];
|
||||
|
||||
/// Secure Connections on current link
|
||||
bool sec_con_enabled;
|
||||
|
||||
/// Counter used to generate IRK
|
||||
uint8_t rand_cnt;
|
||||
|
||||
/// Demonstration type length
|
||||
uint8_t demo_type_len;
|
||||
/// Demonstration type
|
||||
uint8_t demo_type;
|
||||
/// GATT user local identifier
|
||||
uint8_t user_lid;
|
||||
uint8_t adv_actv_idx;
|
||||
uint8_t scan_actv_idx;
|
||||
uint8_t init_actv_idx;
|
||||
uint8_t slave_conidx;
|
||||
uint8_t master_conidx;
|
||||
bool slave_connected;
|
||||
bool master_connected;
|
||||
};
|
||||
|
||||
struct conn_dev_info
|
||||
{
|
||||
uint8_t conidx;
|
||||
uint8_t addr[6];
|
||||
bool connnectd;
|
||||
};
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
/// List of Application NVDS TAG identifiers
|
||||
enum app_nvds_tag
|
||||
{
|
||||
/// Device Name
|
||||
NVDS_TAG_DEVICE_NAME = 0x02,
|
||||
NVDS_LEN_DEVICE_NAME = 62,
|
||||
|
||||
/// BD Address
|
||||
NVDS_TAG_BD_ADDRESS = 0x01,
|
||||
NVDS_LEN_BD_ADDRESS = 6,
|
||||
|
||||
/// Local device Identity resolving key
|
||||
NVDS_TAG_LOC_IRK = 0xA0,
|
||||
NVDS_LEN_LOC_IRK = KEY_LEN,
|
||||
|
||||
#if (BLE_APP_PRF)
|
||||
/// BLE Application Advertising data
|
||||
NVDS_TAG_APP_BLE_ADV_DATA = 0x0B,
|
||||
NVDS_LEN_APP_BLE_ADV_DATA = 32,
|
||||
|
||||
/// BLE Application Scan response data
|
||||
NVDS_TAG_APP_BLE_SCAN_RESP_DATA = 0x0C,
|
||||
NVDS_LEN_APP_BLE_SCAN_RESP_DATA = 32,
|
||||
|
||||
/// Mouse Sample Rate
|
||||
NVDS_TAG_MOUSE_SAMPLE_RATE = 0x38,
|
||||
NVDS_LEN_MOUSE_SAMPLE_RATE = 1,
|
||||
|
||||
/// Peripheral Bonded
|
||||
NVDS_TAG_PERIPH_BONDED = 0x39,
|
||||
NVDS_LEN_PERIPH_BONDED = 1,
|
||||
|
||||
/// Mouse NTF Cfg
|
||||
NVDS_TAG_MOUSE_NTF_CFG = 0x3A,
|
||||
NVDS_LEN_MOUSE_NTF_CFG = 2,
|
||||
|
||||
/// Mouse Timeout value
|
||||
NVDS_TAG_MOUSE_TIMEOUT = 0x3B,
|
||||
NVDS_LEN_MOUSE_TIMEOUT = 2,
|
||||
|
||||
/// Peer Device BD Address
|
||||
NVDS_TAG_PEER_BD_ADDRESS = 0x3C,
|
||||
NVDS_LEN_PEER_BD_ADDRESS = 7,
|
||||
|
||||
/// Mouse Energy Safe
|
||||
NVDS_TAG_MOUSE_ENERGY_SAFE = 0x3D,
|
||||
NVDS_LEN_MOUSE_SAFE_ENERGY = 2,
|
||||
|
||||
/// EDIV (2bytes), RAND NB (8bytes), LTK (16 bytes), Key Size (1 byte)
|
||||
NVDS_TAG_LTK = 0x3E,
|
||||
NVDS_LEN_LTK = 28,
|
||||
|
||||
/// PAIRING
|
||||
NVDS_TAG_PAIRING = 0x3F,
|
||||
NVDS_LEN_PAIRING = 54,
|
||||
|
||||
/// Audio mode 0 task
|
||||
NVDS_TAG_AM0_FIRST = 0x90,
|
||||
NVDS_TAG_AM0_LAST = 0x9F,
|
||||
|
||||
/// Peer device Resolving identity key (+identity address)
|
||||
NVDS_TAG_PEER_IRK = 0xA1,
|
||||
NVDS_LEN_PEER_IRK = sizeof(struct gapc_irk),
|
||||
|
||||
#endif //(BLE_APP_PRF)
|
||||
};
|
||||
#endif // (NVDS_SUPPORT)
|
||||
|
||||
/// Advertising state machine
|
||||
enum app_adv_state
|
||||
{
|
||||
/// Advertising activity does not exists
|
||||
APP_ADV_STATE_IDLE = 0,
|
||||
#if BLE_APP_PRF
|
||||
/// Creating advertising activity
|
||||
APP_ADV_STATE_CREATING,
|
||||
/// Setting advertising data
|
||||
APP_ADV_STATE_SETTING_ADV_DATA,
|
||||
/// Setting scan response data
|
||||
APP_ADV_STATE_SETTING_SCAN_RSP_DATA,
|
||||
|
||||
/// Advertising activity created
|
||||
APP_ADV_STATE_CREATED,
|
||||
/// Starting advertising activity
|
||||
APP_ADV_STATE_STARTING,
|
||||
/// Advertising activity started
|
||||
APP_ADV_STATE_STARTED,
|
||||
/// Stopping advertising activity
|
||||
APP_ADV_STATE_STOPPING,
|
||||
APP_ADV_STATE_STOPPED,
|
||||
#endif //(BLE_APP_PRF)
|
||||
};
|
||||
|
||||
/// Scanning state machine
|
||||
enum app_scan_state
|
||||
{
|
||||
APP_SCAN_STATE_IDLE = 0,
|
||||
APP_SCAN_STATE_CREATING,
|
||||
APP_SCAN_STATE_CREATED,
|
||||
APP_SCAN_STATE_STARTING,
|
||||
APP_SCAN_STATE_STARTED,
|
||||
APP_SCAN_STATE_STOPPING,
|
||||
APP_SCAN_STATE_STOPPED,
|
||||
};
|
||||
|
||||
/// initting state machine
|
||||
enum app_init_state
|
||||
{
|
||||
APP_INIT_STATE_IDLE = 0,
|
||||
APP_INIT_STATE_CREATING,
|
||||
APP_INIT_STATE_CREATED,
|
||||
APP_INIT_STATE_STARTING,
|
||||
APP_INIT_STATE_STARTED,
|
||||
APP_INIT_STATE_STOPPING,
|
||||
APP_INIT_STATE_STOPPED,
|
||||
};
|
||||
|
||||
/// States of APP task
|
||||
enum app_state
|
||||
{
|
||||
/// Initialization state
|
||||
APP_INIT,
|
||||
/// Database create state
|
||||
APP_CREATE_DB,
|
||||
/// Ready State
|
||||
APP_READY,
|
||||
/// Connected state
|
||||
APP_CONNECTED,
|
||||
|
||||
/// Number of defined states.
|
||||
APP_STATE_MAX
|
||||
};
|
||||
|
||||
/// APP Task messages
|
||||
/*@TRACE*/
|
||||
enum app_msg_id
|
||||
{
|
||||
APP_DUMMY_MSG = TASK_FIRST_MSG(TASK_ID_APP),
|
||||
|
||||
#if (BLE_APP_PRF)
|
||||
#if (BLE_APP_HT)
|
||||
/// Timer used to refresh the temperature measurement value
|
||||
APP_HT_MEAS_INTV_TIMER,
|
||||
#endif //(BLE_APP_HT)
|
||||
|
||||
#if (BLE_APP_HID)
|
||||
/// Timer used to disconnect the moue if no activity is detecter
|
||||
APP_HID_MOUSE_TIMEOUT_TIMER,
|
||||
#endif //(BLE_APP_HID)
|
||||
#endif //(BLE_APP_PRF)
|
||||
#if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
ONE_SEC_TIMER_MSG
|
||||
#endif // (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
};
|
||||
|
||||
struct app_subtask_handlers
|
||||
{
|
||||
/// Pointer to the message handler table
|
||||
const struct ke_msg_handler *p_msg_handler_tab;
|
||||
/// Number of messages handled
|
||||
uint16_t msg_cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize the BLE demo application.
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_init(void);
|
||||
struct app_env_tag *get_app_env(void);
|
||||
/// @} APPTASK
|
||||
|
||||
#endif // APP_TASK_H_
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file rwapp_config.h
|
||||
*
|
||||
* @brief Application configuration definition
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2016
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _RWAPP_CONFIG_H_
|
||||
#define _RWAPP_CONFIG_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup app
|
||||
* @brief Application configuration definition
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#define CFG_APP_BATT
|
||||
/******************************************************************************************/
|
||||
/* ------------------------- BLE APPLICATION SETTINGS
|
||||
* -----------------------------*/
|
||||
/******************************************************************************************/
|
||||
|
||||
/// Application Profile
|
||||
#if defined(CFG_APP_PRF)
|
||||
#define BLE_APP_PRF 1
|
||||
#else // defined(CFG_APP_PRF)
|
||||
#define BLE_APP_PRF 0
|
||||
#endif // defined(CFG_APP_PRF)
|
||||
|
||||
/// Health Thermometer Application
|
||||
#if defined(CFG_APP_HT)
|
||||
#define BLE_APP_HT 1
|
||||
#else // defined(CFG_APP_HT)
|
||||
#define BLE_APP_HT 0
|
||||
#endif // defined(CFG_APP_HT)
|
||||
|
||||
/// HID Application
|
||||
#if defined(CFG_APP_HID)
|
||||
#define BLE_APP_HID 1
|
||||
#else // defined(CFG_APP_HID)
|
||||
#define BLE_APP_HID 0
|
||||
#endif // defined(CFG_APP_HID)
|
||||
|
||||
/// DIS Application
|
||||
#if defined(CFG_APP_DIS)
|
||||
#define BLE_APP_DIS 1
|
||||
#else // defined(CFG_APP_DIS)
|
||||
#define BLE_APP_DIS 0
|
||||
#endif // defined(CFG_APP_DIS)
|
||||
|
||||
/// Battery Service Application
|
||||
#if defined(CFG_APP_BATT)
|
||||
#define BLE_APP_BATT 1
|
||||
#else
|
||||
#define BLE_APP_BATT 0
|
||||
#endif //(BLE_APP_BATT)
|
||||
|
||||
// There are 3 modes of flash operation, turn on one of them according to your needs.
|
||||
// This method can be operated at any time without affecting the Bluetooth send and receive packets.
|
||||
#define FLASH_TEST_IN_INTERRUPT (0)
|
||||
// This method can be operated at any time, and will affect the Bluetooth send and receive packets.
|
||||
#define FLASH_TEST_IN_TASK (0)
|
||||
// This way operates in the gap of Bluetooth and will not affect the Bluetooth sending and receiving packets,
|
||||
// but the flash operation may not be successful immediately.
|
||||
#define FLASH_TEST_IN_BLUETOOTH_GAP (0)
|
||||
|
||||
/// @} rwapp_config
|
||||
|
||||
#endif /* _RWAPP_CONFIG_H_ */
|
||||
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_batt.c
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // SW configuration
|
||||
|
||||
#if (BLE_APP_BATT)
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "app_batt.h" // Battery Application Module Definitions
|
||||
#include "app_task.h" // application task definitions
|
||||
#include "bass_msg.h" // health thermometer functions
|
||||
#include "co_bt.h"
|
||||
#include "co_utils.h"
|
||||
#include "prf_types.h" // Profile common types definition
|
||||
#include "arch.h" // Platform Definitions
|
||||
#include "prf.h"
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application Module Environment Structure
|
||||
struct app_batt_env_tag app_batt_env;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTION DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
void app_batt_init(void)
|
||||
{
|
||||
// Reset the environment
|
||||
memset(&app_batt_env, 0, sizeof(struct app_batt_env_tag));
|
||||
|
||||
// Initial battery level: 100
|
||||
app_batt_env.batt_lvl = 100;
|
||||
}
|
||||
|
||||
void app_batt_add_bas(void)
|
||||
{
|
||||
struct bass_db_cfg* db_cfg;
|
||||
// Allocate the BASS_CREATE_DB_REQ
|
||||
struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD,
|
||||
TASK_GAPM, TASK_APP,
|
||||
gapm_profile_task_add_cmd, sizeof(struct bass_db_cfg));
|
||||
// Fill message
|
||||
req->operation = GAPM_PROFILE_TASK_ADD;
|
||||
req->sec_lvl = 0;//PERM(SVC_AUTH, AUTH);
|
||||
req->prf_api_id = TASK_ID_BASS;
|
||||
req->app_task = TASK_APP;
|
||||
req->start_hdl = 0;
|
||||
|
||||
// Set parameters
|
||||
db_cfg = (struct bass_db_cfg* ) req->param;
|
||||
|
||||
// Add a BAS instance
|
||||
db_cfg->bas_nb = 1;
|
||||
// Sending of notifications is supported
|
||||
db_cfg->features[0] = BAS_BATT_LVL_NTF_SUP;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
void app_batt_enable_prf(uint8_t conidx)
|
||||
{
|
||||
app_batt_env.conidx = conidx;
|
||||
|
||||
// Allocate the message
|
||||
struct bass_enable_req * req = KE_MSG_ALLOC(BASS_ENABLE_REQ,
|
||||
prf_dst_task_get(TASK_ID_BASS),
|
||||
TASK_APP,
|
||||
bass_enable_req);
|
||||
|
||||
// Fill in the parameter structure
|
||||
req->conidx = conidx;
|
||||
|
||||
// NTF initial status - Disabled
|
||||
req->ntf_cfg = PRF_CLI_STOP_NTFIND;
|
||||
req->old_batt_lvl[0] = 50;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
void app_batt_send_lvl(uint8_t batt_lvl)
|
||||
{
|
||||
ASSERT_ERR(batt_lvl <= BAS_BATTERY_LVL_MAX);
|
||||
|
||||
// Allocate the message
|
||||
struct bass_batt_level_upd_req * req = KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_REQ,
|
||||
prf_dst_task_get(TASK_ID_BASS),
|
||||
TASK_APP,
|
||||
bass_batt_level_upd_req);
|
||||
|
||||
// Fill in the parameter structure
|
||||
req->bas_instance = 0;
|
||||
req->batt_level = batt_lvl;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
static int bass_batt_level_ntf_cfg_ind_handler(ke_msg_id_t const msgid,
|
||||
struct bass_batt_level_ntf_cfg_ind const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static int batt_level_upd_handler(ke_msg_id_t const msgid,
|
||||
struct bass_batt_level_upd_rsp const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in] msgid Id of the message received.
|
||||
* @param[in] param Pointer to the parameters of the message.
|
||||
* @param[in] dest_id ID of the receiving task instance (TASK_GAP).
|
||||
* @param[in] src_id ID of the sending task instance.
|
||||
*
|
||||
* @return If the message was consumed or not.
|
||||
****************************************************************************************
|
||||
*/
|
||||
static int app_batt_msg_dflt_handler(ke_msg_id_t const msgid,
|
||||
void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
// Drop the message
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/*
|
||||
* LOCAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Default State handlers definition
|
||||
const struct ke_msg_handler app_batt_msg_handler_list[] =
|
||||
{
|
||||
// Note: first message is latest message checked by kernel so default is put on top.
|
||||
{KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_batt_msg_dflt_handler},
|
||||
|
||||
{BASS_BATT_LEVEL_NTF_CFG_IND, (ke_msg_func_t)bass_batt_level_ntf_cfg_ind_handler},
|
||||
{BASS_BATT_LEVEL_UPD_RSP, (ke_msg_func_t)batt_level_upd_handler},
|
||||
};
|
||||
|
||||
const struct app_subtask_handlers app_batt_handlers = APP_HANDLERS(app_batt);
|
||||
|
||||
#endif //BLE_APP_BATT
|
||||
|
||||
/// @} APP
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_batt.h
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_BATT_H_
|
||||
#define APP_BATT_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @ingroup RICOW
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // SW configuration
|
||||
|
||||
#if (BLE_APP_BATT)
|
||||
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include "ke_task.h" // Kernel Task Definition
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application Module Environment Structure
|
||||
struct app_batt_env_tag
|
||||
{
|
||||
/// Connection handle
|
||||
uint8_t conidx;
|
||||
/// Current Battery Level
|
||||
uint8_t batt_lvl;
|
||||
};
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLES DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application environment
|
||||
extern struct app_batt_env_tag app_batt_env;
|
||||
|
||||
/// Table of message handlers
|
||||
extern const struct app_subtask_handlers app_batt_handlers;
|
||||
|
||||
/*
|
||||
* FUNCTIONS DECLARATION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* Health Thermometer Application Functions
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize Battery Application Module
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_init(void);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Add a Battery Service instance in the DB
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_add_bas(void);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Enable the Battery Service
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_enable_prf(uint8_t conidx);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Send a Battery level value
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_send_lvl(uint8_t batt_lvl);
|
||||
|
||||
#endif //(BLE_APP_BATT)
|
||||
|
||||
/// @} APP
|
||||
|
||||
#endif // APP_BATT_H_
|
||||
@@ -0,0 +1,56 @@
|
||||
#if 0
|
||||
/*@TRACE*/
|
||||
enum basc_msg_id
|
||||
{
|
||||
/// Start the Battery Service Client Role - at connection
|
||||
// BASC_ENABLE_REQ = MSG_ID(BASC, 0x00),
|
||||
///Confirm that cfg connection has finished with discovery results, or that normal cnx started
|
||||
BASC_ENABLE_RSP = MSG_ID(BASC, 0x01),
|
||||
|
||||
/// Read Characteristic Value Request
|
||||
// BASC_READ_INFO_REQ = MSG_ID(BASC, 0x02),
|
||||
/// Read Characteristic Value Request
|
||||
BASC_READ_INFO_RSP = MSG_ID(BASC, 0x03),
|
||||
|
||||
/// Write Battery Level Notification Configuration Value request
|
||||
// BASC_BATT_LEVEL_NTF_CFG_REQ = MSG_ID(BASC, 0x04),
|
||||
/// Write Battery Level Notification Configuration Value response
|
||||
BASC_BATT_LEVEL_NTF_CFG_RSP = MSG_ID(BASC, 0x05),
|
||||
|
||||
/// Indicate to APP that the Battery Level value has been received
|
||||
BASC_BATT_LEVEL_IND = MSG_ID(BASC, 0x06),
|
||||
};
|
||||
#endif
|
||||
|
||||
void xc_basc_enbale_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_ENABLE_REQ
|
||||
}
|
||||
|
||||
void xc_basc_read_info_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_READ_INFO_REQ
|
||||
}
|
||||
|
||||
void xc_basc_batt_leval_ntf_cfg_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_BATT_LEVEL_NTF_CFG_REQ
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Default State handlers definition
|
||||
KE_MSG_HANDLER_TAB(basc)
|
||||
{
|
||||
// Note: all messages must be sorted in ID ascending order
|
||||
|
||||
{BASC_ENABLE_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_READ_INFO_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_BATT_LEVEL_NTF_CFG_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_BATT_LEVEL_IND, (ke_msg_func_t) xxx_handler },
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,546 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_sec.c
|
||||
*
|
||||
* @brief Application Security Entry Point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
#include "rwip_config.h"
|
||||
#if (BLE_APP_PRESENT)
|
||||
#if (BLE_HOST_SUPPORT_SMP)
|
||||
#include "rwip_config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "co_utils.h"
|
||||
#include "co_math.h"
|
||||
//#include "gapc_task.h" // GAP Controller Task API Definition
|
||||
#include "gap.h" // GAP Definition
|
||||
#include "gapc.h" // GAPC Definition
|
||||
#include "gapc_int.h"
|
||||
#include "prf_types.h"
|
||||
|
||||
#include "app_sec.h" // Application Security API Definition
|
||||
#include "app_task.h" // Application Manager API Definition
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
#include "nvds.h" // NVDS API Definitions
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
#include "app_task.h"
|
||||
uint8_t bond_flag = 0;
|
||||
struct gapc_ltk g_ltk = {0};
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Application Security Environment Structure
|
||||
struct app_sec_env_tag app_sec_env;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTION DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
void app_sec_init()
|
||||
{
|
||||
/*------------------------------------------------------
|
||||
* RETRIEVE BOND STATUS
|
||||
*------------------------------------------------------*/
|
||||
#if (NVDS_SUPPORT)
|
||||
uint8_t length = NVDS_LEN_PERIPH_BONDED;
|
||||
|
||||
// Get bond status from NVDS
|
||||
if (nvds_get(NVDS_TAG_PERIPH_BONDED, &length, (uint8_t *)&app_sec_env.bonded) != NVDS_OK)
|
||||
{
|
||||
// If read value is invalid, set status to not bonded
|
||||
app_sec_env.bonded = false;
|
||||
}
|
||||
|
||||
if ((app_sec_env.bonded != true) && (app_sec_env.bonded != false))
|
||||
{
|
||||
app_sec_env.bonded = false;
|
||||
}
|
||||
LOGI("===bond_state:%d\r\n",app_sec_env.bonded);
|
||||
#endif //(NVDS_SUPPORT)
|
||||
}
|
||||
|
||||
bool app_sec_get_bond_status(void)
|
||||
{
|
||||
return app_sec_env.bonded;
|
||||
}
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
void app_sec_remove_bond(void)
|
||||
{
|
||||
#if (BLE_APP_HID)
|
||||
uint16_t ntf_cfg = PRF_CLI_STOP_NTFIND;
|
||||
#endif //(BLE_APP_HID)
|
||||
|
||||
// Check if we are well bonded
|
||||
if (app_sec_env.bonded == true)
|
||||
{
|
||||
// Update the environment variable
|
||||
app_sec_env.bonded = false;
|
||||
|
||||
if (nvds_put(NVDS_TAG_PERIPH_BONDED, NVDS_LEN_PERIPH_BONDED,
|
||||
(uint8_t *)&app_sec_env.bonded) != NVDS_OK)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
|
||||
if (nvds_del(NVDS_TAG_LTK) != NVDS_OK)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
|
||||
if (nvds_del(NVDS_TAG_PEER_BD_ADDRESS) != NVDS_OK)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
|
||||
#if (BLE_APP_HID)
|
||||
if (nvds_put(NVDS_TAG_MOUSE_NTF_CFG, NVDS_LEN_MOUSE_NTF_CFG,
|
||||
(uint8_t *)&ntf_cfg) != NVDS_OK)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#endif //(BLE_APP_HID)
|
||||
}
|
||||
}
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
|
||||
/*
|
||||
* MESSAGE HANDLERS
|
||||
****************************************************************************************
|
||||
*/
|
||||
static int app_sec_msg_dflt_handler(ke_msg_id_t const msgid,
|
||||
void *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
// Drop the message
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int gapc_bond_req_ind_handler(ke_msg_id_t const msgid,
|
||||
void const * p_param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
struct gapc_bond_req_ind *param = (struct gapc_bond_req_ind *)p_param;
|
||||
LOGI(" [debug] gapc_bond_req_ind_handler,request:0x%x \r\n",param->request);
|
||||
// Prepare the GAPC_BOND_CFM message
|
||||
struct gapc_bond_cfm *cfm = KE_MSG_ALLOC(GAPC_BOND_CFM,
|
||||
src_id, TASK_APP,
|
||||
gapc_bond_cfm);
|
||||
switch (param->request)
|
||||
{
|
||||
case (GAPC_PAIRING_REQ):
|
||||
{
|
||||
cfm->request = GAPC_PAIRING_RSP;
|
||||
{
|
||||
cfm->accept = true;
|
||||
#if (BLE_SEC_CON)
|
||||
cfm->data.pairing_feat.auth = GAP_AUTH_REQ_SEC_CON_BOND;
|
||||
#else // (BLE_SEC_CON)
|
||||
cfm->data.pairing_feat.auth = GAP_AUTH_REQ_NO_MITM_BOND;
|
||||
#endif // (BLE_SEC_CON)
|
||||
|
||||
app_env.sec_con_enabled = true;
|
||||
cfm->data.pairing_feat.iocap = GAP_IO_CAP_NO_INPUT_NO_OUTPUT;//GAP_IO_CAP_KB_ONLY;//GAP_IO_CAP_DISPLAY_ONLY;//GAP_IO_CAP_NO_INPUT_NO_OUTPUT;
|
||||
cfm->data.pairing_feat.key_size = 16;
|
||||
cfm->data.pairing_feat.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT;
|
||||
cfm->data.pairing_feat.sec_req = GAP_SEC1_NOAUTH_PAIR_ENC;//GAP_SEC1_AUTH_PAIR_ENC;//GAP_NO_SEC;
|
||||
cfm->data.pairing_feat.rkey_dist = GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY;
|
||||
cfm->data.pairing_feat.ikey_dist = GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY;
|
||||
}
|
||||
} break;
|
||||
|
||||
case (GAPC_LTK_EXCH):
|
||||
{
|
||||
// Counter
|
||||
uint8_t counter;
|
||||
cfm->accept = true;
|
||||
cfm->request = GAPC_LTK_EXCH;
|
||||
// Generate all the values
|
||||
cfm->data.ltk.ediv = (uint16_t)co_rand_word();
|
||||
|
||||
for (counter = 0; counter < RAND_NB_LEN; counter++)
|
||||
{
|
||||
cfm->data.ltk.ltk.key[counter] = (uint8_t)co_rand_word();
|
||||
cfm->data.ltk.randnb.nb[counter] = (uint8_t)co_rand_word();
|
||||
}
|
||||
|
||||
for (counter = RAND_NB_LEN; counter < KEY_LEN; counter++)
|
||||
{
|
||||
cfm->data.ltk.ltk.key[counter] = (uint8_t)co_rand_word();
|
||||
}
|
||||
#if (1)
|
||||
LOGI( "nvds_put cfm->ediv=0x%x\r\nparam_randnb:",cfm->data.ltk.ediv);
|
||||
for(uint8_t i=0;i<GAP_RAND_NB_LEN;i++)
|
||||
LOGI( "%x",cfm->data.ltk.randnb.nb[i]);
|
||||
LOGI("\r\nltk:");
|
||||
for(uint8_t i=0;i<GAP_KEY_LEN;i++)
|
||||
LOGI( "%x",cfm->data.ltk.ltk.key[i]);
|
||||
LOGI("\r\n");
|
||||
#endif
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
uint8_t err = nvds_del(NVDS_TAG_LTK);
|
||||
LOGI("err2 =%d \n", err);
|
||||
// Store the generated value in NVDS
|
||||
if (nvds_put(NVDS_TAG_LTK, NVDS_LEN_LTK, (uint8_t *)&cfm->data.ltk) != NVDS_OK)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
|
||||
// uint8_t buff5[10] = {1,2,3,4,5,6,9,8,9,11};
|
||||
// // LOGI("nvds del:%d \r\n",nvds_del(16));
|
||||
// if (nvds_put(18, 10, buff5) != NVDS_OK)
|
||||
// {
|
||||
// LOGI("77111\r\n");
|
||||
// ASSERT_ERR(0);
|
||||
// }
|
||||
// LOGI("77222\r\n");
|
||||
|
||||
#endif // #if (NVDS_SUPPORT)
|
||||
} break;
|
||||
|
||||
|
||||
case (GAPC_IRK_EXCH):
|
||||
{
|
||||
#if (NVDS_SUPPORT)
|
||||
uint8_t addr_len = BD_ADDR_LEN;
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
cfm->accept = true;
|
||||
cfm->request = GAPC_IRK_EXCH;
|
||||
|
||||
// Load IRK
|
||||
memcpy(cfm->data.irk.irk.key, app_env.loc_irk, KEY_LEN);
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
if (nvds_get(NVDS_TAG_BD_ADDRESS, &addr_len, cfm->data.irk.addr.addr) != NVDS_OK)
|
||||
#endif //(NVDS_SUPPORT)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
// load device address
|
||||
cfm->data.irk.addr.addr_type = (cfm->data.irk.addr.addr[5] & 0xC0) ? ADDR_RAND : ADDR_PUBLIC;
|
||||
} break;
|
||||
|
||||
|
||||
//#if (BLE_APP_HT)
|
||||
case (GAPC_TK_EXCH):
|
||||
{
|
||||
// Generate a PIN Code- (Between 100000 and 999999)
|
||||
uint32_t pin_code = (100000 + (co_rand_word()%900000));
|
||||
|
||||
LOGI("app_sec GAPC_TK_EXCH: tk_type=%d\r\n",param->data.tk_type);
|
||||
cfm->accept = true;
|
||||
cfm->request = GAPC_TK_EXCH;
|
||||
|
||||
// Set the TK value
|
||||
memset(cfm->data.tk.key, 0, KEY_LEN);
|
||||
|
||||
cfm->data.tk.key[0] = (uint8_t)((pin_code & 0x000000FF) >> 0);
|
||||
cfm->data.tk.key[1] = (uint8_t)((pin_code & 0x0000FF00) >> 8);
|
||||
cfm->data.tk.key[2] = (uint8_t)((pin_code & 0x00FF0000) >> 16);
|
||||
cfm->data.tk.key[3] = (uint8_t)((pin_code & 0xFF000000) >> 24);
|
||||
|
||||
LOGI("###GAPC_TK_EXCH pincode=%d\r\n", pin_code);
|
||||
|
||||
} break;
|
||||
//#endif //(BLE_APP_HT)
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
} break;
|
||||
}
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(cfm);
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static int gapc_bond_ind_handler(ke_msg_id_t const msgid,
|
||||
void const *p_param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
struct gapc_bond_ind const *param = (struct gapc_bond_ind const *)p_param;
|
||||
|
||||
LOGI(" [debug] gapc_bond_ind_handler : info=%d\r\n", param->info);
|
||||
switch (param->info)
|
||||
{
|
||||
case (GAPC_PAIRING_SUCCEED):
|
||||
{
|
||||
// Update the bonding status in the environment
|
||||
app_sec_env.bonded = true;
|
||||
bond_flag = 1;
|
||||
LOGI("GAPC_PAIRING_SUCCEED auth=%d,ltk_present=%d\r\n",
|
||||
param->data.pairing.level,param->data.pairing.ltk_present);
|
||||
|
||||
// Update the bonding status in the environment
|
||||
#if (PLF_NVDS)
|
||||
uint8_t err = nvds_del(NVDS_TAG_PERIPH_BONDED);
|
||||
LOGI("err1 =%d \n", err);
|
||||
if (nvds_put(NVDS_TAG_PERIPH_BONDED, NVDS_LEN_PERIPH_BONDED,
|
||||
(uint8_t *)&app_sec_env.bonded) != NVDS_OK)
|
||||
{
|
||||
// An error has occurred during access to the NVDS
|
||||
ASSERT_ERR(0);
|
||||
LOGI("3\n");
|
||||
}
|
||||
LOGI("4\n");
|
||||
// Set the BD Address of the peer device in NVDS
|
||||
uint8_t err2 = nvds_del(NVDS_TAG_PEER_BD_ADDRESS);
|
||||
LOGI("err2 =%d \n", err);
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
if (nvds_put(NVDS_TAG_PEER_BD_ADDRESS, NVDS_LEN_PEER_BD_ADDRESS,
|
||||
(uint8_t *)gapc_get_bdaddr(app_env->slave_conidx, GAPC_SMP_INFO_PEER)) != NVDS_OK)
|
||||
{
|
||||
// An error has occurred during access to the NVDS
|
||||
ASSERT_ERR(0);
|
||||
LOGI("5\n");
|
||||
}
|
||||
LOGI("6\n");
|
||||
#endif //(PLF_NVDS)
|
||||
|
||||
|
||||
|
||||
} break;
|
||||
|
||||
case (GAPC_REPEATED_ATTEMPT):
|
||||
{
|
||||
// app_disconnect();
|
||||
} break;
|
||||
|
||||
case (GAPC_IRK_EXCH):
|
||||
{
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
// Store peer identity in NVDS
|
||||
LOGI("GAPC_IRK_EXCH\r\n");
|
||||
uint8_t err = nvds_del(NVDS_TAG_PEER_IRK);
|
||||
LOGI("err2 =%d \n", err);
|
||||
if (nvds_put(NVDS_TAG_PEER_IRK, NVDS_LEN_PEER_IRK, (uint8_t *)¶m->data.irk.irk.key[0]) != NVDS_OK)
|
||||
|
||||
{
|
||||
LOGI("1\r\n");
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
LOGI("2\r\n");
|
||||
|
||||
#endif // (NVDS_SUPPORT)
|
||||
} break;
|
||||
|
||||
case (GAPC_PAIRING_FAILED):
|
||||
{
|
||||
// app_sec_send_security_req(0);
|
||||
} break;
|
||||
|
||||
// In Secure Connections we get BOND_IND with SMPC calculated LTK
|
||||
case (GAPC_LTK_EXCH) :
|
||||
{
|
||||
LOGI( "GAPC_LTK_EXCH sec_con_enabled=%d\r\n",app_env.sec_con_enabled);
|
||||
|
||||
LOGI( " param->ediv=0x%x\r\nparam_randnb:",param->data.ltk.ediv);
|
||||
for(uint8_t i=0;i<GAP_RAND_NB_LEN;i++)
|
||||
LOGI( "%x",param->data.ltk.randnb.nb[i]);
|
||||
LOGI("\r\nltk:");
|
||||
for(uint8_t i=0;i<GAP_KEY_LEN;i++)
|
||||
LOGI( "%x",param->data.ltk.ltk.key[i]);
|
||||
LOGI("\r\n");
|
||||
|
||||
#if (0)
|
||||
if (app_env.sec_con_enabled == true)
|
||||
{
|
||||
#if (NVDS_SUPPORT)
|
||||
// Store LTK in NVDS
|
||||
if (nvds_put(NVDS_TAG_LTK, NVDS_LEN_LTK,(uint8_t *)¶m->data.ltk.ltk.key[0]) != NVDS_OK)
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#endif // (NVDS_SUPPORT)
|
||||
}
|
||||
#endif // (BLE_APP_SEC_CON)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
} break;
|
||||
}
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static int gapc_encrypt_req_ind_handler(ke_msg_id_t const msgid,
|
||||
void const *p_param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
#if (NVDS_SUPPORT)
|
||||
struct gapc_encrypt_req_ind const *param = (struct gapc_encrypt_req_ind const *)p_param;
|
||||
#endif // (NVDS_SUPPORT)
|
||||
LOGI(" [debug] gapc_encrypt_req_ind_handler \r\n");
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
// LTK value
|
||||
struct gapc_ltk ltk;
|
||||
// Length
|
||||
uint8_t length = NVDS_LEN_LTK;
|
||||
#endif // #if (NVDS_SUPPORT)
|
||||
|
||||
// Prepare the GAPC_ENCRYPT_CFM message
|
||||
struct gapc_encrypt_cfm *cfm = KE_MSG_ALLOC(GAPC_ENCRYPT_CFM,
|
||||
src_id, TASK_APP,
|
||||
gapc_encrypt_cfm);
|
||||
|
||||
cfm->found = false;
|
||||
|
||||
|
||||
LOGI("app_sec gapc_encrypt_req_ind_handler: bonded=%d\r\n", app_sec_env.bonded);
|
||||
|
||||
|
||||
// if (app_sec_env.bonded)
|
||||
{
|
||||
#if (NVDS_SUPPORT)
|
||||
// Retrieve the required informations from NVDS
|
||||
if (nvds_get(NVDS_TAG_LTK, &length, (uint8_t *)<k) == NVDS_OK)
|
||||
{
|
||||
|
||||
|
||||
LOGI( "nvds_get param->ediv=0x%x,ltk.ediv=0x%x\r\nparam_randnb:",param->ediv,ltk.ediv);
|
||||
for(uint8_t i=0;i<GAP_RAND_NB_LEN;i++)
|
||||
LOGI( "%x",param->rand_nb.nb[i]);
|
||||
LOGI("\r\nltk.randnb.nb:");
|
||||
for(uint8_t i=0;i<GAP_RAND_NB_LEN;i++)
|
||||
LOGI( "%x",ltk.randnb.nb[i]);
|
||||
LOGI("\r\n");
|
||||
|
||||
|
||||
// Check if the provided EDIV and Rand Nb values match with the stored values
|
||||
if ((param->ediv == ltk.ediv) &&
|
||||
!memcmp(¶m->rand_nb.nb[0], <k.randnb.nb[0], sizeof(struct rand_nb)))
|
||||
{
|
||||
LOGI("EDIV and randnb are same!!!\r\n");
|
||||
cfm->found = true;
|
||||
cfm->key_size = 16;
|
||||
memcpy(&cfm->ltk, <k.ltk, sizeof(struct gap_sec_key));
|
||||
bond_flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("EDIV and randnb not same!!!\r\n");
|
||||
}
|
||||
/*
|
||||
* else we are bonded with another device, disconnect the link
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#endif // (NVDS_SUPPORT)
|
||||
}
|
||||
/*
|
||||
* else the peer device is not known, an error should trigger a new pairing procedure.
|
||||
*/
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(cfm);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
|
||||
static int gapc_encrypt_ind_handler(ke_msg_id_t const msgid,
|
||||
void const *p_param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
struct gapc_encrypt_ind const *param = (struct gapc_encrypt_ind const *)p_param;
|
||||
LOGI(" [debug] gapc_encrypt_ind_handler \r\n");
|
||||
|
||||
// encryption/ re-encryption succeeded
|
||||
|
||||
LOGI("app_sec gapc_encrypt_ind_handler: auth=%d\r\n", param->pairing_lvl);
|
||||
|
||||
|
||||
// struct gapc_set_le_pkt_size_cmd *req = KE_MSG_ALLOC(GAPC_SET_LE_PKT_SIZE_CMD,
|
||||
// KE_BUILD_ID(TASK_GAPC, KE_IDX_GET(src_id)), TASK_APP,
|
||||
// gapc_set_le_pkt_size_cmd);
|
||||
|
||||
// req->operation = GAPC_SET_LE_PKT_SIZE;
|
||||
// req->tx_octets = 0xFB;
|
||||
// req->tx_time = 2120;
|
||||
|
||||
// // Send the message
|
||||
// ke_msg_send(req);
|
||||
|
||||
|
||||
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* LOCAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Default State handlers definition
|
||||
const struct ke_msg_handler app_sec_msg_handler_list[] =
|
||||
{
|
||||
// Note: first message is latest message checked by kernel so default is put on top.
|
||||
{KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_sec_msg_dflt_handler},
|
||||
|
||||
{GAPC_BOND_REQ_IND, (ke_msg_func_t)gapc_bond_req_ind_handler},
|
||||
{GAPC_BOND_IND, (ke_msg_func_t)gapc_bond_ind_handler},
|
||||
|
||||
{GAPC_ENCRYPT_REQ_IND, (ke_msg_func_t)gapc_encrypt_req_ind_handler},
|
||||
{GAPC_ENCRYPT_IND, (ke_msg_func_t)gapc_encrypt_ind_handler},
|
||||
};
|
||||
|
||||
const struct app_subtask_handlers app_sec_handlers = {&app_sec_msg_handler_list[0], ARRAY_LEN(app_sec_msg_handler_list)};
|
||||
#endif
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
|
||||
/// @} APP
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_sec.h
|
||||
*
|
||||
* @brief Application Security Entry Point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP_SEC
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_SEC_H_
|
||||
#define APP_SEC_H_
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
struct app_sec_env_tag
|
||||
{
|
||||
// Bond status
|
||||
bool bonded;
|
||||
};
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Application Security Environment
|
||||
extern struct app_sec_env_tag app_sec_env;
|
||||
|
||||
/// Table of message handlers
|
||||
extern const struct app_subtask_handlers app_sec_handlers;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTIONS DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize the Application Security Module
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_init(void);
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Remove all bond data stored in NVDS
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_remove_bond(void);
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Send a security request to the peer device. This function is used to
|
||||
*require the central to start the encryption with a LTK that would have shared
|
||||
*during a previous bond procedure.
|
||||
*
|
||||
* @param[in] - conidx: Connection Index
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_send_security_req(uint8_t conidx);
|
||||
|
||||
#endif // APP_SEC_H_
|
||||
|
||||
/// @} APP_SEC
|
||||
@@ -0,0 +1,983 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_task.c
|
||||
*
|
||||
* @brief RW APP Task implementation
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "app_task.h" // Application Manager Task API
|
||||
#include "timer.h"
|
||||
#include "xc_drv_timer.h"
|
||||
#include "lld_int.h"
|
||||
|
||||
extern struct lld_env_tag lld_env;
|
||||
__RAM_EM struct conn_dev_info conn_dev[CONNECT_DEV_NUM] = {0};
|
||||
|
||||
/// Application Task Descriptor
|
||||
const struct ke_task_desc TASK_DESC_APP;
|
||||
/// Application Environment Structure
|
||||
__RAM_EM struct app_env_tag app_env = {
|
||||
.adv_actv_idx = INVALID_DATA,
|
||||
.scan_actv_idx = INVALID_DATA,
|
||||
.init_actv_idx = INVALID_DATA,
|
||||
.slave_conidx = INVALID_DATA,
|
||||
.master_conidx = INVALID_DATA,
|
||||
.slave_connected = false,
|
||||
.master_connected = false,
|
||||
};
|
||||
|
||||
static uint8_t gapc_callback(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id);
|
||||
|
||||
static uint8_t gapm_callback(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id);
|
||||
|
||||
struct app_env_tag *get_app_env(void) { return &app_env; }
|
||||
|
||||
uint8_t find_conn_dev(uint8_t *addr)
|
||||
{
|
||||
uint8_t find_idx = 0xFF;
|
||||
for (uint8_t i = 0; i < CONNECT_DEV_NUM; i++) {
|
||||
if (memcmp(&(conn_dev[i].addr[0]), &addr[0], GAP_BD_ADDR_LEN) == 0) {
|
||||
find_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return find_idx;
|
||||
}
|
||||
|
||||
|
||||
uint8_t calc_conn_num(void)
|
||||
{
|
||||
uint8_t num = 0;
|
||||
for(uint8_t i = 0; i <CONNECT_DEV_NUM ;i++)
|
||||
{
|
||||
if(conn_dev[i].connnectd)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
void printf_conn_dev(void)
|
||||
{
|
||||
for(uint8_t i = 0; i <CONNECT_DEV_NUM ;i++)
|
||||
{
|
||||
LOGI(" idx :%d condix :%d addr:%x %x %x %x %x %x connectd:%d \r\n",i,conn_dev[i].conidx,conn_dev[i].addr[0],conn_dev[i].addr[1],conn_dev[i].addr[2],conn_dev[i].addr[3],conn_dev[i].addr[4],conn_dev[i].addr[5],conn_dev[i].connnectd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint8_t find_conn_dev_idx(uint8_t conidx)
|
||||
{
|
||||
uint8_t find_idx = 0xFF;
|
||||
for (uint8_t i = 0; i < CONNECT_DEV_NUM; i++) {
|
||||
if (conn_dev[i].conidx == conidx) {
|
||||
find_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return find_idx;
|
||||
}
|
||||
|
||||
uint8_t add_conn_dev(uint8_t *addr)
|
||||
{
|
||||
uint8_t add_idx = 0xFF;
|
||||
uint8_t invild_addr[6] = {0, 0, 0, 0, 0, 0};
|
||||
for (uint8_t i = 0; i < CONNECT_DEV_NUM; i++) {
|
||||
if (memcmp(&(conn_dev[i].addr[0]), &invild_addr[0], GAP_BD_ADDR_LEN) ==
|
||||
0) {
|
||||
memcpy(&(conn_dev[i].addr[0]), &addr[0], GAP_BD_ADDR_LEN);
|
||||
add_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return add_idx;
|
||||
}
|
||||
|
||||
void app_init()
|
||||
{
|
||||
// Reset the application manager environment
|
||||
// memset(&app_env, 0, sizeof(app_env));
|
||||
// Create APP task
|
||||
ke_task_create(TASK_APP, &TASK_DESC_APP);
|
||||
// Initialize Task state
|
||||
ke_state_set(TASK_APP, APP_INIT);
|
||||
#if (NVDS_SUPPORT)
|
||||
// Get the Device Name to add in the Advertising Data (Default one or NVDS
|
||||
// one)
|
||||
// app_env.dev_name_len = APP_DEVICE_NAME_MAX_LEN;
|
||||
// if (nvds_get(NVDS_TAG_DEVICE_NAME, &(app_env.dev_name_len),
|
||||
// app_env.dev_name) != NVDS_OK)
|
||||
#endif //(NVDS_SUPPORT)
|
||||
{
|
||||
// Get default Device Name (No name if not enough space)
|
||||
memcpy(app_env.dev_name, APP_DFLT_DEVICE_NAME,
|
||||
APP_DFLT_DEVICE_NAME_LEN);
|
||||
app_env.dev_name_len = APP_DFLT_DEVICE_NAME_LEN;
|
||||
}
|
||||
// Reset the stack
|
||||
xc_ble_gapm_reset();
|
||||
for(uint8_t i = 0;i<CONNECT_DEV_NUM;i++)
|
||||
{
|
||||
conn_dev[i].conidx =0xff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint8_t app_get_dev_name(uint8_t *name)
|
||||
{
|
||||
if ((app_env.dev_name_len > 0) &&
|
||||
(app_env.dev_name_len <= APP_DEVICE_NAME_MAX_LEN) && (name != NULL)) {
|
||||
// copy name to provided pointer
|
||||
memcpy(name, app_env.dev_name, APP_DFLT_DEVICE_NAME_LEN);
|
||||
// return name length
|
||||
return app_env.dev_name_len;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void app_set_dev_name(uint8_t *name, uint8_t name_len)
|
||||
{
|
||||
if ((name_len > 0) && (name_len <= APP_DEVICE_NAME_MAX_LEN) &&
|
||||
(name != NULL)) {
|
||||
memcpy(app_env.dev_name, name, name_len);
|
||||
app_env.dev_name_len = name_len;
|
||||
}
|
||||
}
|
||||
|
||||
#if MULTI_ROLE_TEST
|
||||
// adv
|
||||
void app_create_advertising(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_IDLE) {
|
||||
struct gapm_activity_create_adv_cmd param = {0};
|
||||
param.own_addr_type = GAPM_STATIC_ADDR;
|
||||
param.adv_param.type = GAPM_ADV_TYPE_LEGACY;
|
||||
param.adv_param.disc_mode = GAPM_ADV_MODE_GEN_DISC;
|
||||
param.adv_param.prop = GAPM_ADV_PROP_UNDIR_CONN_MASK;
|
||||
param.adv_param.max_tx_pwr = APP_MAX_TX_POWER;
|
||||
param.adv_param.filter_pol = ADV_ALLOW_SCAN_ANY_CON_ANY;
|
||||
param.adv_param.prim_cfg.adv_intv_min = APP_ADV_INT_MIN;
|
||||
param.adv_param.prim_cfg.adv_intv_max = APP_ADV_INT_MAX;
|
||||
param.adv_param.prim_cfg.chnl_map = APP_ADV_CHMAP;
|
||||
param.adv_param.prim_cfg.phy = GAP_PHY_1MBPS;
|
||||
|
||||
xc_ble_advertise_create(¶m);
|
||||
app_env.adv_state = APP_ADV_STATE_STARTING;
|
||||
}
|
||||
}
|
||||
|
||||
void app_set_adv_data(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_STARTING) {
|
||||
uint8_t adv_data[ADV_DATA_MAX_LENGTH] = {0};
|
||||
adv_data[0] = APP_DFLT_DEVICE_NAME_LEN + 1;
|
||||
adv_data[1] = GAP_AD_TYPE_COMPLETE_NAME;
|
||||
memcpy(&adv_data[2], APP_DFLT_DEVICE_NAME, APP_DFLT_DEVICE_NAME_LEN);
|
||||
xc_ble_set_adv_data(app_env.adv_actv_idx, APP_DFLT_DEVICE_NAME_LEN + 2,
|
||||
adv_data);
|
||||
app_env.adv_state = APP_ADV_STATE_SETTING_ADV_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
void app_set_scan_rsp_data(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_SETTING_ADV_DATA) {
|
||||
uint8_t scan_rsp_data[ADV_DATA_MAX_LENGTH] = {0};
|
||||
scan_rsp_data[0] = MANUFACTURER_DATA_LEN + 1;
|
||||
scan_rsp_data[1] = GAP_AD_TYPE_MANU_SPECIFIC_DATA;
|
||||
memcpy(&scan_rsp_data[2], MANUFACTURER_DATA, MANUFACTURER_DATA_LEN);
|
||||
xc_ble_set_scan_rsp_data(app_env.adv_actv_idx,
|
||||
MANUFACTURER_DATA_LEN + 2, scan_rsp_data);
|
||||
app_env.adv_state = APP_ADV_STATE_SETTING_SCAN_RSP_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
void app_start_advertising(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_SETTING_ADV_DATA ||
|
||||
app_env.adv_state == APP_ADV_STATE_SETTING_SCAN_RSP_DATA ||
|
||||
app_env.adv_state == APP_ADV_STATE_STOPPED) {
|
||||
struct gapm_activity_start_cmd param = {0};
|
||||
param.actv_idx = app_env.adv_actv_idx;
|
||||
param.u_param.adv_add_param.duration = ADV_DURATION;
|
||||
|
||||
xc_ble_advertise_start(¶m);
|
||||
app_env.adv_state = APP_ADV_STATE_STARTING;
|
||||
}
|
||||
}
|
||||
|
||||
void app_stop_advertising(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_STARTING) {
|
||||
xc_ble_activity_stop(app_env.adv_actv_idx);
|
||||
app_env.adv_state = APP_ADV_STATE_STOPPING;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// scan
|
||||
void app_create_scan(void)
|
||||
{
|
||||
if (app_env.scan_state == APP_SCAN_STATE_IDLE) {
|
||||
struct gapm_activity_create_cmd param = {
|
||||
.own_addr_type = GAPM_STATIC_ADDR,
|
||||
};
|
||||
xc_ble_scan_create(¶m);
|
||||
app_env.scan_state = APP_SCAN_STATE_CREATING;
|
||||
}
|
||||
}
|
||||
|
||||
void app_start_scan(void)
|
||||
{
|
||||
if (app_env.scan_state == APP_SCAN_STATE_CREATING ||
|
||||
app_env.scan_state == APP_SCAN_STATE_STOPPED) {
|
||||
struct gapm_activity_start_cmd scan_param = {0};
|
||||
struct gapm_scan_param *param = &scan_param.u_param.scan_param;
|
||||
scan_param.actv_idx = app_env.scan_actv_idx;
|
||||
param->type = GAPM_SCAN_TYPE_OBSERVER;
|
||||
param->prop = GAPM_SCAN_PROP_PHY_1M_BIT | GAPM_SCAN_PROP_ACTIVE_1M_BIT;
|
||||
param->dup_filt_pol = GAPM_DUP_FILT_DIS;
|
||||
param->scan_param_1m.scan_intv = 0xa0; // 20*0.625 ms
|
||||
param->scan_param_1m.scan_wd = 0x50; // 15*0.625 ms
|
||||
param->duration = 0;
|
||||
|
||||
xc_ble_scan_start(&scan_param);
|
||||
app_env.scan_state = APP_SCAN_STATE_STARTING;
|
||||
}
|
||||
}
|
||||
|
||||
void app_stop_scanning(void)
|
||||
{
|
||||
if (app_env.scan_state == APP_SCAN_STATE_STARTING) {
|
||||
xc_ble_activity_stop(app_env.scan_actv_idx);
|
||||
app_env.scan_state = APP_SCAN_STATE_STOPPING;
|
||||
}
|
||||
}
|
||||
|
||||
// init
|
||||
|
||||
void app_create_init(void)
|
||||
{
|
||||
if (app_env.init_state == APP_INIT_STATE_IDLE) {
|
||||
struct gapm_activity_create_cmd param = {
|
||||
.own_addr_type = GAPM_STATIC_ADDR,
|
||||
};
|
||||
|
||||
xc_ble_init_create(¶m);
|
||||
app_env.init_state = APP_INIT_STATE_CREATING;
|
||||
}
|
||||
}
|
||||
|
||||
void app_start_init(uint8_t addr_type, uint8_t *addr)
|
||||
{
|
||||
LOGI(" start init state :%d \r\n", app_env.init_state);
|
||||
#if !WHITE_LIST_TEST
|
||||
if (app_env.init_state == APP_INIT_STATE_CREATING ||
|
||||
app_env.init_state == APP_INIT_STATE_STOPPED)
|
||||
#else
|
||||
#endif
|
||||
{
|
||||
struct gapm_activity_start_cmd init_param = {0};
|
||||
struct gapm_init_param *param = &init_param.u_param.init_param;
|
||||
init_param.actv_idx = app_env.init_actv_idx;
|
||||
#if WHITE_LIST_TEST
|
||||
param->type = GAPM_INIT_TYPE_AUTO_CONN_EST;
|
||||
#else
|
||||
param->type = GAPM_INIT_TYPE_DIRECT_CONN_EST;
|
||||
#endif
|
||||
param->prop = GAPM_INIT_PROP_1M_BIT;
|
||||
param->conn_to = APP_CONN_EST_TIME_OUT;
|
||||
param->scan_param_1m.scan_intv = APP_CONN_SCNA_INTV;
|
||||
param->scan_param_1m.scan_wd = APP_CONN_SCAN_WD;
|
||||
param->conn_param_1m.conn_intv_min = APP_CONN_INTV_MIN;
|
||||
param->conn_param_1m.conn_intv_max = APP_CONN_INTV_MIN;
|
||||
param->conn_param_1m.conn_latency = APP_CONN_LATENCY;
|
||||
param->conn_param_1m.supervision_to = APP_CONN_TIME_OUT;
|
||||
param->peer_addr.addr_type = addr_type;
|
||||
memcpy(param->peer_addr.addr, addr, GAP_BD_ADDR_LEN);
|
||||
|
||||
xc_ble_init_start(&init_param);
|
||||
app_env.init_state = APP_INIT_STATE_STARTING;
|
||||
}
|
||||
}
|
||||
|
||||
void app_stop_init(void)
|
||||
{
|
||||
if (app_env.init_state == APP_INIT_STATE_STARTING) {
|
||||
xc_ble_activity_stop(app_env.init_actv_idx);
|
||||
app_env.init_state = APP_INIT_STATE_STOPPING;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
app_get_handler(const struct app_subtask_handlers *handler_list_desc,
|
||||
ke_msg_id_t msgid, void *p_param, ke_task_id_t src_id)
|
||||
{
|
||||
// Counter
|
||||
uint8_t counter;
|
||||
// Get the message handler function by parsing the message table
|
||||
for (counter = handler_list_desc->msg_cnt; 0 < counter; counter--) {
|
||||
struct ke_msg_handler handler = (struct ke_msg_handler)(
|
||||
*(handler_list_desc->p_msg_handler_tab + counter - 1));
|
||||
if ((handler.id == msgid) || (handler.id == KE_MSG_DEFAULT_HANDLER)) {
|
||||
// If handler is NULL, message should not have been received in this
|
||||
// state
|
||||
ASSERT_ERR(handler.func);
|
||||
return (uint8_t)(handler.func(msgid, p_param, TASK_APP, src_id));
|
||||
}
|
||||
}
|
||||
|
||||
// If we are here no handler has been found, drop the message
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Handles reception of all messages sent from the lower layers to the
|
||||
*application
|
||||
* @param[in] msgid Id of the message received.
|
||||
* @param[in] p_param Pointer to the parameters of the message.
|
||||
* @param[in] dest_id ID of the receiving task instance
|
||||
* @param[in] src_id ID of the sending task instance.
|
||||
*
|
||||
* @return If the message was consumed or not.
|
||||
****************************************************************************************
|
||||
*/
|
||||
static int app_msg_handler(ke_msg_id_t const msgid, void *p_param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
// Retrieve identifier of the task from received message
|
||||
ke_task_id_t src_task_id = MSG_T(msgid);
|
||||
// Message policy
|
||||
uint8_t msg_pol = KE_MSG_CONSUMED;
|
||||
switch (src_task_id) {
|
||||
case TASK_ID_GAPM: {
|
||||
msg_pol = gapm_callback(msgid, p_param, dest_id, src_id);
|
||||
} break;
|
||||
case TASK_ID_GAPC: {
|
||||
if ((msgid >= GAPC_BOND_CMD) && (msgid <= GAPC_BOND_DATA_UPDATE_IND)) {
|
||||
// Call the Security Module
|
||||
msg_pol =
|
||||
app_get_handler(&app_sec_handlers, msgid, p_param, src_id);
|
||||
} else {
|
||||
msg_pol = gapc_callback(msgid, p_param, dest_id, src_id);
|
||||
}
|
||||
} break;
|
||||
case TASK_ID_GATT: {
|
||||
|
||||
} break;
|
||||
#if (BLE_APP_HT)
|
||||
case (TASK_ID_HTPT): {
|
||||
// Call the Health Thermometer Module
|
||||
msg_pol = app_get_handler(&app_ht_handlers, msgid, p_param, src_id);
|
||||
} break;
|
||||
#endif //(BLE_APP_HT)
|
||||
|
||||
#if (BLE_APP_DIS)
|
||||
case (TASK_ID_DISS): {
|
||||
// Call the Device Information Module
|
||||
msg_pol = app_get_handler(&app_dis_handlers, msgid, p_param, src_id);
|
||||
} break;
|
||||
#endif //(BLE_APP_DIS)
|
||||
|
||||
#if (BLE_APP_HID)
|
||||
case (TASK_ID_HOGPD): {
|
||||
// Call the HID Module
|
||||
msg_pol = app_get_handler(&app_hid_handlers, msgid, p_param, src_id);
|
||||
} break;
|
||||
#endif //(BLE_APP_HID)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (msg_pol);
|
||||
}
|
||||
|
||||
|
||||
#define IP_DIAGCNTL_ADDR 0x53000050
|
||||
|
||||
__INLINE void ip_diagcntl_pack(uint8_t diag3en, uint8_t diag3, uint8_t diag2en, uint8_t diag2, uint8_t diag1en, uint8_t diag1, uint8_t diag0en, uint8_t diag0)
|
||||
{
|
||||
ASSERT_ERR((((uint32_t)diag3en << 31) & ~((uint32_t)0x80000000)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag3 << 24) & ~((uint32_t)0x3F000000)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag2en << 23) & ~((uint32_t)0x00800000)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag2 << 16) & ~((uint32_t)0x003F0000)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag1en << 15) & ~((uint32_t)0x00008000)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag1 << 8) & ~((uint32_t)0x00003F00)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag0en << 7) & ~((uint32_t)0x00000080)) == 0);
|
||||
ASSERT_ERR((((uint32_t)diag0 << 0) & ~((uint32_t)0x0000003F)) == 0);
|
||||
REG_IP_WR(IP_DIAGCNTL_ADDR, ((uint32_t)diag3en << 31) | ((uint32_t)diag3 << 24) | ((uint32_t)diag2en << 23) | ((uint32_t)diag2 << 16) | ((uint32_t)diag1en << 15) | ((uint32_t)diag1 << 8) | ((uint32_t)diag0en << 7) | ((uint32_t)diag0 << 0));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Handles GAP manager command complete events.
|
||||
*
|
||||
* @param[in] msgid Id of the message received.
|
||||
* @param[in] p_param Pointer to the parameters of the message.
|
||||
* @param[in] dest_id ID of the receiving task instance (TASK_GAP).
|
||||
* @param[in] src_id ID of the sending task instance.
|
||||
****************************************************************************************
|
||||
*/
|
||||
static void gapm_cmp_evt(ke_msg_id_t const msgid,
|
||||
struct gapm_cmp_evt const *p_param,
|
||||
ke_task_id_t const dest_id, ke_task_id_t const src_id)
|
||||
{
|
||||
LOGI(
|
||||
" app gapm_cmp_evt operation:0x%02x, act_id:0x%02x status :0x%02x\r\n",
|
||||
p_param->operation, p_param->actv_idx, p_param->status);
|
||||
if (p_param->status == GAP_ERR_NO_ERROR) {
|
||||
switch (p_param->operation) {
|
||||
// Reset completed
|
||||
case GAPM_RESET: {
|
||||
struct gapm_set_dev_config_cmd cfg_param = {
|
||||
.role = GAP_ROLE_ALL,
|
||||
.pairing_mode = GAPM_PAIRING_SEC_CON | GAPM_PAIRING_LEGACY,
|
||||
.sugg_max_tx_octets = BLE_MIN_OCTETS,
|
||||
.sugg_max_tx_time = BLE_MIN_TIME,
|
||||
};
|
||||
// SETF(cfg_param.att_cfg, GAPM_ATT_SLV_PREF_CON_PAR_EN, 1);
|
||||
xc_ble_set_dev_config(&cfg_param);
|
||||
#if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
ke_timer_set(ONE_SEC_TIMER_MSG, TASK_APP, 1000);
|
||||
#endif // #if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
|
||||
if (CFG_CON > 1) {
|
||||
extern uint8_t rwip_prog_delay;
|
||||
rwip_prog_delay = 6;
|
||||
}
|
||||
lld_env.dft_slave_md = 0;
|
||||
// ip_diagcntl_pack(0,0,0,0,1,0x7c,1,0x3);
|
||||
} break;
|
||||
case GAPM_SET_DEV_CONFIG: {
|
||||
#if WHITE_LIST_TEST
|
||||
gap_bdaddr_t wl_info[10] = {0};
|
||||
uint8_t addr1[6] = {0x89, 0x23, 0x33, 0x46, 0x55, 0x88};
|
||||
uint8_t addr2[6] = {0x21 ,0x9c, 0xe4 ,0xd2 ,0xe6 ,0x02};
|
||||
uint8_t addr3[6] = {0x21 ,0x9c, 0xb8 ,0xd3 ,0x0e ,0x13 };
|
||||
uint8_t addr4[6] = {0x21 ,0x9c, 0xe4 ,0xd2 ,0x7d ,0x02 };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// wl_info[0].addr_type = 1;
|
||||
// wl_info[1].addr_type = 1;
|
||||
// wl_info[2].addr_type = 1;
|
||||
memcpy(&wl_info[0].addr[0],&addr1[0],6);
|
||||
memcpy(&wl_info[1].addr[0],&addr2[0],6);
|
||||
memcpy(&wl_info[2].addr[0],&addr3[0],6);
|
||||
memcpy(&wl_info[3].addr[0],&addr4[0],6);
|
||||
|
||||
xc_ble_set_white_list(4, &wl_info[0]);
|
||||
#endif
|
||||
// xc_ble_gen_random_nb();
|
||||
// xc_ble_gen_random_nb();
|
||||
// } break;
|
||||
// case GAPM_GEN_RAND_NB: {
|
||||
// if (app_env.rand_cnt == 2) {
|
||||
gap_sec_key_t irk = {0};
|
||||
memcpy(&irk.key[0], &app_env.loc_irk[0], GAP_KEY_LEN);
|
||||
xc_ble_set_irk(&irk);
|
||||
// app_env.rand_cnt = 0;
|
||||
if (!app_cli_register()) {
|
||||
app_create_scan();
|
||||
app_create_init();
|
||||
}
|
||||
#if MULTI_ROLE_TEST
|
||||
if (!custom_svc_add()) {
|
||||
app_create_advertising();
|
||||
}
|
||||
#endif
|
||||
// }
|
||||
|
||||
} break;
|
||||
|
||||
case GAPM_SET_ADV_DATA: {
|
||||
#if MULTI_ROLE_TEST
|
||||
app_start_advertising();
|
||||
#endif
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void gapc_get_device_info_req_ind(
|
||||
ke_msg_id_t const msgid, struct gapc_get_dev_info_req_ind const *param,
|
||||
ke_task_id_t const dest_id, ke_task_id_t const src_id)
|
||||
{
|
||||
uint8_t conidx = KE_IDX_GET(src_id);
|
||||
struct gapc_get_dev_info_cfm *pcfm = NULL;
|
||||
switch (param->req) {
|
||||
case GAPC_DEV_NAME: {
|
||||
pcfm = KE_MSG_ALLOC_DYN(
|
||||
GAPC_GET_DEV_INFO_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
|
||||
gapc_get_dev_info_cfm, DEVICE_NAME_MAX_LEN);
|
||||
pcfm->req = param->req;
|
||||
pcfm->token = param->token;
|
||||
pcfm->status = GAP_ERR_NO_ERROR;
|
||||
pcfm->info.name.value_length = app_get_dev_name(pcfm->info.name.value);
|
||||
} break;
|
||||
|
||||
case GAPC_DEV_APPEARANCE: {
|
||||
pcfm = KE_MSG_ALLOC_DYN(
|
||||
GAPC_GET_DEV_INFO_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
|
||||
gapc_get_dev_info_cfm, 0);
|
||||
pcfm->req = param->req;
|
||||
pcfm->info.appearance = DEV_APPEARANCE;
|
||||
pcfm->token = param->token;
|
||||
pcfm->status = GAP_ERR_NO_ERROR;
|
||||
} break;
|
||||
|
||||
case GAPC_DEV_SLV_PREF_PARAMS: {
|
||||
pcfm = KE_MSG_ALLOC_DYN(
|
||||
GAPC_GET_DEV_INFO_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
|
||||
gapc_get_dev_info_cfm, 0);
|
||||
pcfm->req = param->req;
|
||||
pcfm->info.slv_pref_params.con_intv_min = BLE_UAPDATA_MIN_INTVALUE;
|
||||
// Slave preferred Connection interval Max
|
||||
pcfm->info.slv_pref_params.con_intv_max = BLE_UAPDATA_MAX_INTVALUE;
|
||||
// Slave preferred Connection latency
|
||||
pcfm->info.slv_pref_params.slave_latency = BLE_UAPDATA_LATENCY;
|
||||
// Slave preferred Link supervision timeout
|
||||
pcfm->info.slv_pref_params.conn_timeout = BLE_UAPDATA_TIMEOUT;
|
||||
pcfm->token = param->token;
|
||||
pcfm->status = GAP_ERR_NO_ERROR;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (pcfm) {
|
||||
xc_ble_get_dev_info_cfm(conidx, pcfm);
|
||||
}
|
||||
}
|
||||
|
||||
static void gapm_profile_add_ind(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
struct gapm_profile_added_ind *p_param =
|
||||
(struct gapm_profile_added_ind *)param;
|
||||
// Current State
|
||||
ke_state_t state = ke_state_get(dest_id);
|
||||
LOGI("gapm_profile_add_ind profile_task_id:0x%x,state=0x%x\r\n",
|
||||
p_param->prf_task_id, state);
|
||||
switch (p_param->prf_task_id) {
|
||||
case TASK_ID_BASS: {
|
||||
|
||||
} break;
|
||||
case TASK_ID_BASC: {
|
||||
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gapm_activity_created_ind(ke_msg_id_t const msgid,
|
||||
void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
struct gapm_activity_created_ind *p_param =
|
||||
(struct gapm_activity_created_ind *)param;
|
||||
LOGI(" gapm_activity_created_ind actv_idx = %d,actv_type = %d ",
|
||||
p_param->actv_idx, p_param->actv_type);
|
||||
switch (p_param->actv_type) {
|
||||
case GAPM_ACTV_TYPE_SCAN: {
|
||||
app_env.scan_actv_idx = p_param->actv_idx;
|
||||
app_start_scan();
|
||||
} break;
|
||||
case GAPM_ACTV_TYPE_INIT: {
|
||||
app_env.init_actv_idx = p_param->actv_idx;
|
||||
|
||||
} break;
|
||||
case GAPM_ACTV_TYPE_ADV: {
|
||||
#if MULTI_ROLE_TEST
|
||||
app_env.adv_actv_idx = p_param->actv_idx;
|
||||
app_set_adv_data();
|
||||
#endif
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gapm_activity_stop_ind(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
struct gapm_activity_stopped_ind *p_param =
|
||||
(struct gapm_activity_stopped_ind *)param;
|
||||
LOGI(" activity stop actv_id=%d actv_type=%d, reason=0x%x\r\n",
|
||||
p_param->actv_idx, p_param->actv_type, p_param->reason);
|
||||
if (p_param->actv_idx == app_env.scan_actv_idx) {
|
||||
app_env.scan_state = APP_SCAN_STATE_STOPPED;
|
||||
|
||||
} else if (p_param->actv_idx == app_env.init_actv_idx) {
|
||||
app_env.init_state = APP_INIT_STATE_STOPPED;
|
||||
#if WHITE_LIST_TEST
|
||||
app_start_init(0,NULL);
|
||||
#endif
|
||||
} else if (p_param->actv_idx == app_env.adv_actv_idx) {
|
||||
app_env.adv_state = APP_ADV_STATE_STOPPED;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t gapm_callback(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
switch (msgid) {
|
||||
case GAPM_CMP_EVT:
|
||||
gapm_cmp_evt(msgid, param, dest_id, src_id);
|
||||
break;
|
||||
case GAPM_DEV_BDADDR_IND: {
|
||||
struct gapm_dev_bdaddr_ind *p_param =
|
||||
(struct gapm_dev_bdaddr_ind *)param;
|
||||
LOGI("GAPM_DEV_BDADDR_IND\r\n");
|
||||
LOGI("app_gapm_dev_bdaddr_ind_handler addr type:0x%x, addr:0x%x "
|
||||
"0x%x 0x%x 0x%x 0x%x 0x%x \r\n",
|
||||
p_param->addr.addr_type, p_param->addr.addr[0],
|
||||
p_param->addr.addr[1], p_param->addr.addr[2],
|
||||
p_param->addr.addr[3], p_param->addr.addr[4],
|
||||
p_param->addr.addr[5]);
|
||||
|
||||
} break;
|
||||
case GAPM_GEN_RAND_NB_IND: {
|
||||
struct gapm_gen_rand_nb_ind *p_param =
|
||||
(struct gapm_gen_rand_nb_ind *)param;
|
||||
// First part of IRK
|
||||
if (app_env.rand_cnt == 0) {
|
||||
memcpy(&app_env.loc_irk[0], &p_param->randnb.nb[0], 8);
|
||||
}
|
||||
// Second part of IRK
|
||||
else if (app_env.rand_cnt == 1) {
|
||||
memcpy(&app_env.loc_irk[8], &p_param->randnb.nb[0], 8);
|
||||
}
|
||||
app_env.rand_cnt++;
|
||||
} break;
|
||||
case GAPM_ACTIVITY_CREATED_IND: {
|
||||
gapm_activity_created_ind(msgid, param, dest_id, src_id);
|
||||
} break;
|
||||
case GAPM_ACTIVITY_STOPPED_IND: {
|
||||
gapm_activity_stop_ind(msgid, param, dest_id, src_id);
|
||||
} break;
|
||||
case GAPM_SCAN_REQUEST_IND:
|
||||
LOGI("GAPM_SCAN_REQUEST_IND\r\n");
|
||||
break;
|
||||
case GAPM_PROFILE_ADDED_IND: {
|
||||
gapm_profile_add_ind(msgid, param, dest_id, src_id);
|
||||
} break;
|
||||
|
||||
case GAPM_ADDR_SOLVED_IND: {
|
||||
LOGI("======== GAPM_ADDR_SOLVED_IND ========\r\n");
|
||||
struct gapm_addr_solved_ind *p_param =
|
||||
(struct gapm_addr_solved_ind *)param;
|
||||
LOGI("addr: %x %x %x %x %x %x \r\n", p_param->addr.addr[0],
|
||||
p_param->addr.addr[1], p_param->addr.addr[2],
|
||||
p_param->addr.addr[3], p_param->addr.addr[4],
|
||||
p_param->addr.addr[5]);
|
||||
for (uint8_t i = 0; i < 16; i++) {
|
||||
LOGI(" %x ", p_param->irk.key[i]);
|
||||
}
|
||||
} break;
|
||||
case GAPM_EXT_ADV_REPORT_IND: {
|
||||
struct gapm_ext_adv_report_ind *p_param =
|
||||
(struct gapm_ext_adv_report_ind *)param;
|
||||
|
||||
// LOGI("addr: %x %x %x %x %x %x\r\n", p_param->trans_addr.addr[0],
|
||||
// p_param->trans_addr.addr[1], p_param->trans_addr.addr[2],
|
||||
// p_param->trans_addr.addr[3], p_param->trans_addr.addr[4],
|
||||
// p_param->trans_addr.addr[5]);
|
||||
#if (SCAN_RSSI_DEBUG)
|
||||
LOGI("rssi=%d\n",p_param->rssi);
|
||||
#endif
|
||||
|
||||
#if WHITE_LIST_TEST
|
||||
app_start_init(0,NULL);
|
||||
#else
|
||||
|
||||
uint8_t addr2[6] = {0xA9, 0xE4, 0x7B, 0x68, 0x32, 0x96};
|
||||
uint8_t addr3[6] = {0xAB, 0xD5, 0x7B, 0x68, 0x32, 0x96};
|
||||
uint8_t addr4[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x52};
|
||||
uint8_t addr5[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x53};
|
||||
|
||||
if ((memcmp(p_param->trans_addr.addr, addr2,
|
||||
GAP_BD_ADDR_LEN) == 0) ||(memcmp(p_param->trans_addr.addr, addr3,
|
||||
GAP_BD_ADDR_LEN) == 0) ||(memcmp(p_param->trans_addr.addr, addr4,
|
||||
GAP_BD_ADDR_LEN) == 0) ||(memcmp(p_param->trans_addr.addr, addr5,
|
||||
GAP_BD_ADDR_LEN) == 0))
|
||||
{
|
||||
LOGI("find target device \r\n");
|
||||
LOGI("addr_type :%d ,addr :%x %x %x %x %x %x \r\n",p_param->trans_addr.addr_type,p_param->trans_addr.addr[0],p_param->trans_addr.addr[1],p_param->trans_addr.addr[2],p_param->trans_addr.addr[3],p_param->trans_addr.addr[4],p_param->trans_addr.addr[5]);
|
||||
|
||||
uint8_t find_idx = find_conn_dev(&(p_param->trans_addr.addr[0]));
|
||||
if(find_idx != 0xff)
|
||||
{
|
||||
if(conn_dev[find_idx].connnectd == false)
|
||||
{
|
||||
LOGI(" dddd1 find_idx :%d ,connect dev addr :%x %x %x %x %x %x \r\n",find_idx,p_param->trans_addr.addr[0],p_param->trans_addr.addr[1],p_param->trans_addr.addr[2],p_param->trans_addr.addr[3],p_param->trans_addr.addr[4],p_param->trans_addr.addr[5]);
|
||||
printf_conn_dev();
|
||||
app_start_init(p_param->trans_addr.addr_type,
|
||||
p_param->trans_addr.addr);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("dddd2 find_idx :%d,conn dev addr :%x %x %x %x %x %x \r\n",find_idx,p_param->trans_addr.addr[0],p_param->trans_addr.addr[1],p_param->trans_addr.addr[2],p_param->trans_addr.addr[3],p_param->trans_addr.addr[4],p_param->trans_addr.addr[5]);
|
||||
printf_conn_dev();
|
||||
app_start_init(p_param->trans_addr.addr_type,
|
||||
p_param->trans_addr.addr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static uint8_t gapc_callback(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
uint8_t conidx = KE_IDX_GET(src_id);
|
||||
switch (msgid) {
|
||||
case GAPC_CMP_EVT: {
|
||||
struct gapc_cmp_evt const *p_param = (struct gapc_cmp_evt const *)param;
|
||||
LOGI("GAPC_CMP_EVT operation = 0x%x, status = 0x%x conidx = "
|
||||
"0x%x\r\n",
|
||||
p_param->operation, p_param->status, conidx);
|
||||
} break;
|
||||
case GAPC_CONNECTION_REQ_IND: {
|
||||
struct gapc_connection_req_ind *p_param =
|
||||
(struct gapc_connection_req_ind *)param;
|
||||
LOGI(" ======= GAPC_CONNECTION_REQ_IND conhdl = x%x, conidx = 0x%x ",
|
||||
p_param->conhdl, conidx);
|
||||
LOGI("conn_intv:%d, role=%d addr: ", p_param->con_interval,
|
||||
p_param->role);
|
||||
// DUMP_DATA_PRINTF(&(p_param->peer_addr.addr[0]), GAP_BD_ADDR_LEN);
|
||||
for (uint8_t i = 0; i < GAP_BD_ADDR_LEN; i++) {
|
||||
LOGI(" %02x ", p_param->peer_addr.addr[i]);
|
||||
}
|
||||
LOGI("\r\n");
|
||||
|
||||
|
||||
// Check if the received connection index is valid
|
||||
if (conidx != GAP_INVALID_CONIDX) {
|
||||
struct gapc_connection_cfm cfm = {0};
|
||||
cfm.pairing_lvl = GAP_PAIRING_UNAUTH;
|
||||
xc_ble_conn_cfm(conidx, &cfm);
|
||||
}
|
||||
|
||||
uint8_t find_idx = find_conn_dev(&(p_param->peer_addr.addr[0]));
|
||||
if (find_idx != 0xff) {
|
||||
conn_dev[find_idx].connnectd = true;
|
||||
LOGI(" debug conn_dev[find_idx].conidx :%d conidx :%d \r\n ",
|
||||
conn_dev[find_idx].conidx, conidx);
|
||||
conn_dev[find_idx].conidx = conidx;
|
||||
} else {
|
||||
uint8_t add_idx = add_conn_dev(&(p_param->peer_addr.addr[0]));
|
||||
if (add_idx == 0xff) {
|
||||
LOGI("==== add dev error===\r\n");
|
||||
} else {
|
||||
conn_dev[add_idx].conidx = conidx;
|
||||
conn_dev[add_idx].connnectd = true;
|
||||
}
|
||||
}
|
||||
printf_conn_dev();
|
||||
LOGI("--------- connect num :%d --------\r\n",calc_conn_num());
|
||||
|
||||
if (p_param->role == GAPM_ROLE_SLAVE) {
|
||||
app_env.slave_conidx = conidx;
|
||||
app_env.slave_connected = true;
|
||||
}
|
||||
// device as master
|
||||
if (p_param->role == GAPM_ROLE_MASTER) {
|
||||
//app_stop_scanning();
|
||||
app_env.master_conidx = conidx;
|
||||
app_env.master_connected = true;
|
||||
#if (BOND_TEST)
|
||||
struct gapc_bond_cmd bond_param = {0};
|
||||
bond_param.pairing.auth =
|
||||
GAP_AUTH_REQ_NO_MITM_BOND; // GAP_AUTH_REQ_MITM_BOND;//GAP_AUTH_REQ_MITM_BOND;
|
||||
bond_param.pairing.iocap =
|
||||
GAP_IO_CAP_NO_INPUT_NO_OUTPUT; // GAP_IO_CAP_KB_ONLY;//GAP_IO_CAP_DISPLAY_ONLY;//GAP_IO_CAP_NO_INPUT_NO_OUTPUT;
|
||||
bond_param.pairing.key_size = 16;
|
||||
bond_param.pairing.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT;
|
||||
bond_param.pairing.sec_req =
|
||||
GAP_SEC1_NOAUTH_PAIR_ENC; // GAP_SEC1_AUTH_PAIR_ENC;//GAP_NO_SEC;
|
||||
bond_param.pairing.rkey_dist = GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY;
|
||||
bond_param.pairing.ikey_dist = GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY;
|
||||
xc_ble_bond(conidx, &bond_param);
|
||||
#endif // (BOND_TEST)
|
||||
usr_cli_feat_enable(conidx);
|
||||
}
|
||||
} break;
|
||||
case GAPC_DISCONNECT_IND: {
|
||||
struct gapc_disconnect_ind *p_param =
|
||||
(struct gapc_disconnect_ind *)param;
|
||||
LOGI("******* GAPC_DISCONNECT_IND conidx = 0x%x, reason = 0x%x "
|
||||
"conhdl = 0x%x,\r\n",
|
||||
conidx, p_param->reason, p_param->conhdl);
|
||||
|
||||
uint8_t find_idx = find_conn_dev_idx(conidx);
|
||||
if (find_idx == 0xff) {
|
||||
LOGI("debug find condix error\r\n");
|
||||
} else {
|
||||
conn_dev[find_idx].connnectd = false;
|
||||
conn_dev[find_idx].conidx = 0xff;
|
||||
}
|
||||
printf_conn_dev();
|
||||
LOGI("--------- connect num :%d --------\r\n",calc_conn_num());
|
||||
#if !WHITE_LIST_TEST
|
||||
if (conidx == app_env.master_conidx) {
|
||||
app_env.master_conidx = INVALID_DATA;
|
||||
app_env.master_connected = false;
|
||||
// app_start_scan();
|
||||
}
|
||||
#else
|
||||
app_start_init(0,NULL);
|
||||
#endif
|
||||
#if MULTI_ROLE_TEST
|
||||
if (conidx == app_env.slave_conidx) {
|
||||
app_env.slave_conidx = INVALID_DATA;
|
||||
app_env.slave_connected = false;
|
||||
app_start_advertising();
|
||||
}
|
||||
#endif
|
||||
|
||||
} break;
|
||||
case GAPC_GET_DEV_INFO_REQ_IND: {
|
||||
gapc_get_device_info_req_ind(msgid, param, dest_id, src_id);
|
||||
} break;
|
||||
case GAPC_SET_DEV_INFO_REQ_IND: {
|
||||
struct gapc_set_dev_info_req_ind *p_param =
|
||||
(struct gapc_set_dev_info_req_ind *)param;
|
||||
struct gapc_set_dev_info_cfm cfm = {0};
|
||||
LOGI("GAPC_SET_DEV_INFO_REQ_IND param->req=0x%x,conidx=0x%x\r\n",
|
||||
p_param->req, conidx);
|
||||
xc_ble_set_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
case GAPC_PARAM_UPDATE_REQ_IND: {
|
||||
struct gapc_param_update_req_ind *p_param =
|
||||
(struct gapc_param_update_req_ind *)param;
|
||||
struct gapc_param_update_cfm cfm = {0};
|
||||
LOGI("GAPC_PARAM_UPDATE_REQ_IND "
|
||||
"conidx=0x%x,intv_max=0x%x,intv_min=0x%x",
|
||||
conidx, p_param->intv_max, p_param->intv_min);
|
||||
LOGI("latency=0x%x,time_out=0x%x\r\n", p_param->latency,
|
||||
p_param->time_out);
|
||||
// Check if the received Connection Handle was valid
|
||||
if (app_env.conidx != GAP_INVALID_CONIDX) {
|
||||
cfm.accept = true;
|
||||
cfm.ce_len_min = CE_LEN_MIN;
|
||||
cfm.ce_len_max = CE_LEN_MAX;
|
||||
xc_ble_param_update_cfm(conidx, &cfm);
|
||||
}
|
||||
} break;
|
||||
case GAPC_PARAM_UPDATED_IND: {
|
||||
struct gapc_param_updated_ind *p_param =
|
||||
(struct gapc_param_updated_ind *)param;
|
||||
LOGI("GAPC_PARAM_UPDATED_IND "
|
||||
"conidx=0x%x,con_interval=0x%x,con_latency=0x%x ",
|
||||
conidx, p_param->con_interval, p_param->con_latency);
|
||||
LOGI("sup_to=0x%x\r\n", p_param->sup_to);
|
||||
} break;
|
||||
case GAPC_LE_PKT_SIZE_IND: {
|
||||
struct gapc_le_pkt_size_ind *p_param =
|
||||
(struct gapc_le_pkt_size_ind *)param;
|
||||
LOGI("GAPC_LE_PKT_SIZE_IND "
|
||||
"conidx=0x%x, max_rx_octets:%d",
|
||||
conidx, p_param->max_rx_octets);
|
||||
LOGI("max_rx_time:%d,max_tx_octets:%d, "
|
||||
"max_tx_time :%d\r\n",
|
||||
p_param->max_rx_time, p_param->max_tx_octets,
|
||||
p_param->max_tx_time);
|
||||
} break;
|
||||
case GAPC_CON_RSSI_IND: {
|
||||
struct gapc_con_rssi_ind *p_param = (struct gapc_con_rssi_ind *)param;
|
||||
LOGI("GAPC_CON_RSSI_IND conidx=0x%x,rssi = %d\r\n", conidx,
|
||||
p_param->rssi);
|
||||
} break;
|
||||
case GAPC_LE_PHY_IND: {
|
||||
struct gapc_le_phy_ind *p_param = (struct gapc_le_phy_ind *)param;
|
||||
LOGI("GAPC_LE_PHY_IND conidx=0x%x tx phy:%d rx phy:%d \r\n", conidx,
|
||||
p_param->tx_phy, p_param->rx_phy);
|
||||
} break;
|
||||
case GAPC_BOND_REQ_IND:
|
||||
// gapc_bond_req_ind_handler(msgid, p_param, dest_id,src_id)
|
||||
break;
|
||||
case GAPC_BOND_IND:
|
||||
// gapc_bond_ind_handler(msgid, p_param, dest_id,src_id)
|
||||
break;
|
||||
case GAPC_SECURITY_IND:
|
||||
// gapc_security_ind_handler(msgid, p_param, dest_id,src_id)
|
||||
break;
|
||||
case GAPC_ENCRYPT_REQ_IND:
|
||||
// gapc_encrypt_req_ind_handler(msgid, p_param, dest_id,src_id)
|
||||
break;
|
||||
case GAPC_ENCRYPT_IND:
|
||||
// gapc_encrypt_ind_handler(msgid, p_param, dest_id,src_id)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
#if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
static int one_sec_timer_handler(ke_msg_id_t const msgid, void *p_param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
ke_timer_set(ONE_SEC_TIMER_MSG, TASK_APP, 1000);
|
||||
#if (FLASH_TEST_IN_TASK)
|
||||
flash_test_in_task();
|
||||
#endif // (FLASH_TEST_IN_TASK)
|
||||
#if (FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
flash_test_in_bluetooth_gap();
|
||||
#endif // (FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
#endif // #if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
|
||||
/* Default State handlers definition. */
|
||||
KE_MSG_HANDLER_TAB(app){
|
||||
#if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
{ONE_SEC_TIMER_MSG, (ke_msg_func_t)one_sec_timer_handler},
|
||||
#endif // #if (FLASH_TEST_IN_TASK || FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
{KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_msg_handler},
|
||||
};
|
||||
|
||||
/* Defines the place holder for the states of all the task instances. */
|
||||
ke_state_t app_state[APP_IDX_MAX];
|
||||
|
||||
// Application task descriptor
|
||||
const struct ke_task_desc TASK_DESC_APP = {app_msg_handler_tab, app_state,
|
||||
APP_IDX_MAX,
|
||||
ARRAY_LEN(app_msg_handler_tab)};
|
||||
|
||||
/// @} APPTASK
|
||||
@@ -0,0 +1,433 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // RW SW configuration
|
||||
#include "xc_drv_pwr.h"
|
||||
#if (USE_ROM_FLASH)
|
||||
#include "xc6xxx_fmc_spi.h"
|
||||
#endif // (USE_ROM_FLASH)
|
||||
#include "app_task.h"
|
||||
#include "rom_port.h"
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
#include "uart.h" // UART initialization
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
|
||||
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
||||
#include "rf.h" // RF initialization
|
||||
#endif // BLE_EMB_PRESENT || BT_EMB_PRESENT
|
||||
|
||||
#if (PLF_NVDS)
|
||||
#include "nvds.h" // NVDS definitions
|
||||
#endif // PLF_NVDS
|
||||
|
||||
#include "xc6xxx.h"
|
||||
#include "xc_drv_fmc_spi.h"
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup DRIVERS
|
||||
* @{
|
||||
*
|
||||
*
|
||||
* ****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
/// NVDS location in FLASH : 0x000E0000 (896KB (1Mo - 128KB))
|
||||
#define NVDS_FLASH_ADDRESS (0x0003E000)
|
||||
|
||||
/// NVDS size in RAM : 0x00010000 (128KB)
|
||||
#define NVDS_FLASH_SIZE (0x00000800)
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* MAIN FUNCTION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief RW main function.
|
||||
*
|
||||
* This function is called right after the booting process has completed.
|
||||
*
|
||||
* @return status exit status
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
void flash_init()
|
||||
{
|
||||
// uint32_t mid = 0;
|
||||
// uint32_t flash_size;
|
||||
// uint16_t flash_type;
|
||||
// xc_fmc_spi_init_oprt();
|
||||
// xc_fmc_spi_flash_wake_up();
|
||||
|
||||
// xc_fmc_spi_flash_rdid((uint8_t *)&mid);
|
||||
// LOGI("Flash RDID: 0x%08x\n", mid);
|
||||
|
||||
|
||||
#if (PLF_NVDS)
|
||||
if (false == flash_size_and_type_get(&flash_size, &flash_type)) {
|
||||
LOGI("Flash Memory size Get ERROR ! ");
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
nvds_space_init(flash_size);
|
||||
#endif
|
||||
// if chip unique get failed,then use flash RUID
|
||||
if (false == xc_unique_identification_read(co_default_bdaddr.addr)) {
|
||||
uint8_t ruid[16];
|
||||
xc_fmc_spi_flash_ruid(ruid);
|
||||
LOGI("Flash RUID11: ");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
LOGI("%02x ", ruid[i]);
|
||||
}
|
||||
LOGI("\n");
|
||||
LOGI("The chip does not have unique , then use flash RUID\n");
|
||||
memset(co_default_bdaddr.addr, 0, 6);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
co_default_bdaddr.addr[i % 6] += ruid[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define clrbit(x, y) ((x) &= ~(1 << (y)))
|
||||
#define AHB_CTL clrbit(*(uint32_t volatile *)(0x40000000 + 0x130), 0)
|
||||
#define _TOSTRING(s) #s
|
||||
#define TOSTRING(s) _TOSTRING(s)
|
||||
|
||||
extern void clock_init(void);
|
||||
void app_uart_init(void)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.FunSel = UART0_TX;
|
||||
|
||||
gpio_cfg.Pin = GPIO_18;
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.FunSel = UART0_RX;
|
||||
gpio_cfg.Pin = GPIO_19;
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_STOP_1_BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_115200;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(UART0_IDX, &uart_cfg);
|
||||
}
|
||||
void wdt_init(void)
|
||||
{
|
||||
WDT_InitCfg_t wdt_cfg ;
|
||||
|
||||
wdt_cfg.WorkMode = WDT_WORK_MODE0;
|
||||
wdt_cfg.ReloadValue = WDT_CLK_32K_RESET_MODE0_2048MS;
|
||||
wdt_cfg.PclkSel = WDT_WORK_32K;
|
||||
xc_wdt_init(&wdt_cfg);
|
||||
xc_wdt_start();
|
||||
}
|
||||
|
||||
void system_lightsleep_cfg()
|
||||
{
|
||||
#if (USE_XIP != 1)
|
||||
cprao_aon_puctrl1_set(0x4); /* puctrl1= 0x4 , SSI0RX must pulldown*/
|
||||
#endif
|
||||
cprao_aon_sys_time_set((RST_READY_TIME << 12) | (OSC32_STABLE_TIME));
|
||||
|
||||
xc_pwr_pd_lightsleep_set();
|
||||
xc_pwr_sleepsrc_mask_set(0x1e001e);
|
||||
xc_pwr_osc_off();
|
||||
}
|
||||
|
||||
/* Zero the host global variable. */
|
||||
void rom_env_host_init()
|
||||
{
|
||||
|
||||
uint32_t *ptr = (uint32_t *)(0x10000800);
|
||||
memset(ptr, 0, 0x10001300 - 0x10000800);
|
||||
|
||||
rom_env.stack_printf = printf;
|
||||
}
|
||||
|
||||
void board_init()
|
||||
{
|
||||
clock_init();
|
||||
|
||||
app_uart_init();
|
||||
|
||||
LOGI("sdk version: %s build time: %s %s\n", TOSTRING(SDK_VERSION), __DATE__,
|
||||
__TIME__);
|
||||
// xc_fmc_spi_init_oprt();
|
||||
#if (SLEEP_ENABLE)
|
||||
// xc_rc32k_calib_by_hw();
|
||||
// xc_rc32k_calib_by_soft();
|
||||
#endif // (SLEEP_ENABLE)
|
||||
rom_env_host_init();
|
||||
rom_env_init();
|
||||
AHB_CTL;
|
||||
|
||||
// Initialize random process
|
||||
// srand(1);
|
||||
}
|
||||
|
||||
void bluetooth_init()
|
||||
{
|
||||
|
||||
uint32_t error = RESET_NO_ERROR;
|
||||
flash_init();
|
||||
#if (PLF_NVDS)
|
||||
|
||||
// Initialize NVDS module
|
||||
nvds_init(NVDS_FLASH_SIZE);
|
||||
#endif // PLF_NVDS
|
||||
/*
|
||||
************************************************************************************
|
||||
* RW SW stack initialization
|
||||
************************************************************************************
|
||||
*/
|
||||
NVIC_SetPriority((IRQn_Type)BLE_IRQn, 0);
|
||||
NVIC_EnableIRQ((IRQn_Type)BLE_IRQn);
|
||||
#if (!HCI_TEST_NO_IP)
|
||||
// Initialize modem
|
||||
modem_init();
|
||||
#endif
|
||||
// Initialize RF
|
||||
#if (BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
||||
rf_init(&rwip_rf);
|
||||
#endif // BT_EMB_PRESENT || BLE_EMB_PRESENT
|
||||
// Initialize RW SW stack
|
||||
rwip_init(error);
|
||||
|
||||
uint32_t seed;
|
||||
rwip_time_t current_time = rwip_time_get();
|
||||
seed = current_time.hs;
|
||||
seed += current_time.hus;
|
||||
//Init the random seed
|
||||
co_random_init(seed);
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
enter_test_mode();
|
||||
#else // (BLE_TEST_MODE_SUPPORT)
|
||||
// Initialize APP
|
||||
app_init();
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
// finally start interrupt handling
|
||||
GLOBAL_INT_START();
|
||||
}
|
||||
|
||||
#if ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1))
|
||||
extern uint8_t adv_evt_start ; // adv event
|
||||
extern uint8_t evt_start ; // conn event
|
||||
extern volatile uint8_t sv_lock;
|
||||
extern volatile uint8_t sv_txlen;
|
||||
__RAM_CODE void PendSV_Handler(void)
|
||||
{
|
||||
if(adv_evt_start){ // adv event
|
||||
#if (ADV_EVENT_NOT_RUN_XIP ==1)
|
||||
while (!sv_lock)
|
||||
;
|
||||
#endif // (ADV_EVENT_NOT_RUN_XIP ==1)
|
||||
}else if(evt_start){ // conn event
|
||||
#if (CONN_EVENT_NOT_RUN_XIP == 0)
|
||||
uint32_t nus = sv_txlen * 8 + 148;
|
||||
uint32_t unit = 32;
|
||||
uint32_t temp;
|
||||
|
||||
SysTick->CTRL = 0x00;
|
||||
SysTick->LOAD = unit * nus - unit + 1;
|
||||
|
||||
SysTick->VAL = 0;
|
||||
SysTick->CTRL = 0x05;
|
||||
|
||||
do {
|
||||
temp = SysTick->CTRL;
|
||||
if (sv_lock) {
|
||||
break;
|
||||
}
|
||||
} while ((temp & 0x01) && (!(temp & (1 << 16))));
|
||||
#endif // (CONN_EVENT_NOT_RUN_XIP == 0)
|
||||
|
||||
#if (CONN_EVENT_NOT_RUN_XIP == 1)
|
||||
while (!sv_lock)
|
||||
;
|
||||
#endif // (CONN_EVENT_NOT_RUN_XIP == 1)
|
||||
}
|
||||
|
||||
}
|
||||
#endif // ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1))
|
||||
|
||||
#if (FLASH_TEST_IN_INTERRUPT)
|
||||
void flash_test_in_interrupt(void)
|
||||
{
|
||||
uint8_t wr_data[10] = {0x63,0x89,0x63,0x89,0x63,0x89};
|
||||
uint8_t rd_data[10] ={0};
|
||||
// Timer 1 can be used for flash, interrupt priority is lower than bluetooth, then higher than other interrupts.
|
||||
// Operate flash in timer 1 interrupt context, no need to lock interrupt, won't affect bluetooth send/receive packets.
|
||||
// xc_fmc_spi_flash_write(0x32000 , wr_data, sizeof(wr_data));
|
||||
xc_fmc_spi_flash_write_page(0x32000, wr_data,
|
||||
sizeof(wr_data));
|
||||
xc_fmc_spi_flash_read(0x32000 , rd_data, sizeof(rd_data));
|
||||
for(uint8_t i = 0;i<sizeof(rd_data);i++)
|
||||
{
|
||||
printf(" %02x ",rd_data[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
|
||||
void timer_init(uint8_t timer_idx,uint32_t us)
|
||||
{
|
||||
Timer_InitCfg_t timer_cfg;
|
||||
|
||||
timer_cfg.timer_src_clk = TIMER_CLK_SRC_32K;
|
||||
timer_cfg.timer_div_clk = TIMER_DIV_CLK_16MHzOr16K;
|
||||
timer_cfg.timer_mode = TIMER_MODE_CYCLE;
|
||||
|
||||
xc_timer_init(timer_idx, &timer_cfg);
|
||||
xc_timer_set_value(timer_idx, us);
|
||||
xc_timer_start(timer_idx);
|
||||
NVIC_SetPriority((IRQn_Type)TIMER0_IRQn + timer_idx, 1);
|
||||
}
|
||||
|
||||
void timer1_callback(void *context) {
|
||||
flash_test_in_interrupt();
|
||||
}
|
||||
#endif // (FLASH_TEST_IN_INTERRUPT)
|
||||
|
||||
|
||||
#if (FLASH_TEST_IN_TASK)
|
||||
void flash_test_in_task(void)
|
||||
{
|
||||
uint8_t wr_data[10] = {0x63,0x89,0x63,0x89,0x63,0x89};
|
||||
static uint8_t wr_cnt= 0;
|
||||
uint8_t rd_data[10] ={0};
|
||||
wr_cnt++;
|
||||
if(wr_cnt >= 252)
|
||||
{
|
||||
wr_cnt = 0;
|
||||
}
|
||||
wr_data[9] = wr_cnt;
|
||||
GLOBAL_INT_DISABLE();
|
||||
xc_fmc_spi_flash_write_page(0x32000, wr_data,
|
||||
sizeof(wr_data));
|
||||
xc_fmc_spi_flash_read(0x32000 , rd_data, sizeof(rd_data));
|
||||
|
||||
GLOBAL_INT_RESTORE();
|
||||
for(uint8_t i = 0;i<sizeof(rd_data);i++)
|
||||
{
|
||||
printf(" %02x ",rd_data[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
#endif // (FLASH_TEST_IN_TASK)
|
||||
|
||||
#if (FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
#include "rwip_int.h"
|
||||
extern struct rwip_env_tag rwip_env;
|
||||
void flash_test_in_bluetooth_gap(void)
|
||||
{
|
||||
uint8_t wr_data[10] = {0x63,0x89,0x63,0x89,0x63,0x89};
|
||||
static uint8_t wr_cnt= 0;
|
||||
uint8_t rd_data[10] ={0};
|
||||
wr_cnt++;
|
||||
if(wr_cnt >= 252)
|
||||
{
|
||||
wr_cnt = 0;
|
||||
}
|
||||
wr_data[9] = wr_cnt;
|
||||
|
||||
if (rwip_env.prevent_sleep != 0)
|
||||
return;
|
||||
|
||||
rwip_time_t current_time;
|
||||
current_time = rwip_time_get();
|
||||
// Get the most recent Bluetooth event interval.
|
||||
int32_t duration = CLK_DIFF(current_time.hs, rwip_env.timer_arb_target); //312.5us
|
||||
if(duration < 64){ // 20ms = 64*312.5
|
||||
return;
|
||||
}
|
||||
|
||||
GLOBAL_INT_DISABLE();
|
||||
xc_fmc_spi_flash_write_page(0x32000, wr_data,
|
||||
sizeof(wr_data));
|
||||
xc_fmc_spi_flash_read(0x32000 , rd_data, sizeof(rd_data));
|
||||
|
||||
GLOBAL_INT_RESTORE();
|
||||
for(uint8_t i = 0;i<sizeof(rd_data);i++)
|
||||
{
|
||||
printf(" %02x ",rd_data[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
#endif // (FLASH_TEST_IN_BLUETOOTH_GAP)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
wdt_init();
|
||||
board_init();
|
||||
bluetooth_init();
|
||||
|
||||
#if (SLEEP_ENABLE)
|
||||
//lvr bor_intr
|
||||
cprao_aon_bor_ctr_reg0__bor_ctrl__setf(0x0);
|
||||
cprao_aon_bor_ctr_reg0__bor_rstn_mask__setf(1);
|
||||
cprao_aon_bor_ctr_reg0__bor_intr_mask__setf(0);
|
||||
NVIC_EnableIRQ(MPU_IRQn);
|
||||
#endif // (SLEEP_ENABLE)
|
||||
|
||||
#if ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1))
|
||||
NVIC_SetPriority(PendSV_IRQn, 0xff);
|
||||
NVIC_EnableIRQ(PendSV_IRQn);
|
||||
#endif // ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1))
|
||||
#if (FLASH_TEST_IN_INTERRUPT)
|
||||
timer_init(TIMER1_IDX,1000*1000);
|
||||
#endif //(FLASH_TEST_IN_INTERRUPT)
|
||||
|
||||
// rf_test_pin_init();
|
||||
#if (BLE_APP_PRESENT)
|
||||
while (1) {
|
||||
// schedule all pending events
|
||||
rwip_schedule();
|
||||
#if (SLEEP_ENABLE)
|
||||
sleep_schedule();
|
||||
#endif // (SLEEP_ENABLE)
|
||||
xc_wdt_reload(); //TOOD
|
||||
}
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
}
|
||||
|
||||
/// @} DRIVERS
|
||||
@@ -0,0 +1,284 @@
|
||||
#<SYMDEFS># ARM Linker, 5060750: Last Updated: Tue Sep 05 15:30:26 2023
|
||||
0x10000808 D co_default_bdaddr
|
||||
0x00004169 T ke_msg_alloc
|
||||
0x000041ed T ke_msg_send
|
||||
0x00004225 T ke_msg_send_basic
|
||||
0x000042e9 T ke_state_set
|
||||
0x00004359 T ke_task_create
|
||||
0x000042b9 T ke_state_get
|
||||
0x000041af T ke_msg_discard
|
||||
0x000041b3 T ke_msg_forward
|
||||
0x000041dd T ke_msg_in_queue
|
||||
0x00004233 T ke_msg_src_id_get
|
||||
0x00003e05 T ke_free
|
||||
0x000041d5 T ke_msg_free
|
||||
0x00003c21 T ke_check_malloc
|
||||
0x0000dbf5 T rwip_init
|
||||
0x0000de79 T rwip_schedule
|
||||
0x10000938 D rwip_rf
|
||||
0x00000df9 T BLE_Handler
|
||||
0x0000238d T co_buf_alloc
|
||||
0x000024fd T co_buf_copy_data_from_mem
|
||||
0x00002721 T co_buf_release
|
||||
0x000028c9 T co_djob_prepare
|
||||
0x000028d5 T co_djob_reg
|
||||
0x0000291d T co_djob_unreg
|
||||
0x00002969 T co_list_extract
|
||||
0x000029ad T co_list_extract_after
|
||||
0x00002ac5 T co_list_pop_front
|
||||
0x00002ae9 T co_list_push_back
|
||||
0x00002b39 T co_list_push_front
|
||||
0x00002b55 T co_time_get
|
||||
0x00002ce5 T co_time_timer_init
|
||||
0x00002dcd T co_time_timer_set
|
||||
0x00002df9 T co_time_timer_stop
|
||||
0x00000e95 T aes_c1
|
||||
0x00001465 T aes_encrypt
|
||||
0x000014cd T aes_f4
|
||||
0x00001521 T aes_f5
|
||||
0x00001641 T aes_f6
|
||||
0x000016bd T aes_g2
|
||||
0x00001c35 T aes_rand
|
||||
0x000012a1 T aes_cmac
|
||||
0x000025b1 T co_buf_head_release
|
||||
0x000025dd T co_buf_head_reserve
|
||||
0x00002ec5 T co_util_pack
|
||||
0x000030d5 T co_util_unpack
|
||||
0x0000ddd9 T rwip_reset
|
||||
0x00001da5 T aes_rpa_resolve
|
||||
0x00002799 T co_buf_reuse
|
||||
0x000027dd T co_buf_size
|
||||
0x00002489 T co_buf_copy
|
||||
0x00002569 T co_buf_duplicate
|
||||
0x000027ed T co_buf_tail_release
|
||||
0x00002a0d T co_list_init
|
||||
0x00002285 T ble_util_buf_rx_free
|
||||
0x00001f69 T ble_util_buf_acl_tx_alloc
|
||||
0x00002439 T co_buf_cb_free_set
|
||||
0x00003fad T ke_malloc
|
||||
0x00002a25 T co_list_insert_after
|
||||
0x0000459d T ke_timer_active
|
||||
0x000045ad T ke_timer_clear
|
||||
0x00004641 T ke_timer_set
|
||||
0x00002369 T co_buf_acquire
|
||||
0x00002819 T co_buf_tail_reserve
|
||||
0x00002531 T co_buf_copy_data_to_mem
|
||||
0x00002a55 T co_list_insert_before
|
||||
0x10000e90 D rom_env
|
||||
0x1000096c D rwip_param
|
||||
0x0000fe8d D one_bits
|
||||
0x000039bd T hci_rd_rem_ver_info_cmd_handler
|
||||
0x00003445 T hci_le_con_upd_cmd_handler
|
||||
0x00003705 T hci_le_rd_chnl_map_cmd_handler
|
||||
0x00003761 T hci_le_rd_rem_feats_cmd_handler
|
||||
0x0000354d T hci_le_en_enc_cmd_handler
|
||||
0x0000369d T hci_le_ltk_req_reply_cmd_handler
|
||||
0x0000360d T hci_le_ltk_req_neg_reply_cmd_handler
|
||||
0x00003851 T hci_le_rem_con_param_req_reply_cmd_handler
|
||||
0x000037f9 T hci_le_rem_con_param_req_neg_reply_cmd_handler
|
||||
0x000038d9 T hci_le_set_data_len_cmd_handler
|
||||
0x00003be5 T hci_vs_set_pref_slave_latency_cmd_handler
|
||||
0x00003b9d T hci_vs_set_pref_slave_evt_dur_cmd_handler
|
||||
0x00003ab9 T hci_vs_set_max_rx_size_and_time_cmd_handler
|
||||
0x00003a39 T hci_rd_rssi_cmd_handler
|
||||
0x0000d749 T llm_ch_map_update_ind_handler
|
||||
0x0000650d T llc_loc_llcp_rsp_to_handler
|
||||
0x00007161 T llc_rem_llcp_rsp_to_handler
|
||||
0x00005255 T llc_encrypt_ind_handler
|
||||
0x00006739 T llc_op_ver_exch_ind_handler
|
||||
0x000066d5 T llc_op_feats_exch_ind_handler
|
||||
0x00006675 T llc_op_encrypt_ind_handler
|
||||
0x00006609 T llc_op_dl_upd_ind_handler
|
||||
0x0000657d T llc_op_con_upd_ind_handler
|
||||
0x00006525 T llc_op_ch_map_upd_ind_handler
|
||||
0x0000bda9 T lld_llcp_rx_ind_handler
|
||||
0x0000bf1d T lld_llcp_tx_cfm_handler
|
||||
0x00007551 T lld_acl_rx_ind_handler
|
||||
0x000075dd T lld_acl_tx_cfm_handler
|
||||
0x00009509 T lld_con_param_upd_cfm_handler
|
||||
0x00008921 T lld_ch_map_upd_cfm_handler
|
||||
0x000094cd T lld_con_offset_upd_ind_handler
|
||||
0x00003435 T hci_command_llc_handler
|
||||
0x00003385 T hci_acl_data_handler
|
||||
0x00003cc1 T ke_event_callback_set
|
||||
0x00003cd9 T ke_event_clear
|
||||
0x00003db1 T ke_event_set
|
||||
0x000022e5 T ble_util_nb_good_channels
|
||||
0x0000230d T ble_util_pkt_dur_in_us
|
||||
0x0000234d T co_bdaddr_compare
|
||||
0x000088bd T lld_ch_assess_data_get
|
||||
0x000088c5 T lld_ch_map_set
|
||||
0x0000c16d T lld_read_clock
|
||||
0x0000c30d T lld_res_list_peer_update
|
||||
0x0000d60d T lld_white_list_add
|
||||
0x0000dd99 T rwip_prevent_sleep_clear
|
||||
0x0000ddb9 T rwip_prevent_sleep_set
|
||||
0x0000f071 T sch_plan_rem
|
||||
0x00001ce5 T aes_rpa_gen
|
||||
0x00002029 T ble_util_buf_adv_tx_alloc
|
||||
0x00002061 T ble_util_buf_adv_tx_free
|
||||
0x0000feae D co_null_bdaddr
|
||||
0x0000feb4 D co_null_key
|
||||
0x000050c9 T llc_con_move_cbk
|
||||
0x000071d9 T llc_start
|
||||
0x00007669 T lld_adv_adv_data_update
|
||||
0x00007ff5 T lld_adv_rand_addr_update
|
||||
0x00008071 T lld_adv_restart
|
||||
0x0000817d T lld_adv_scan_rsp_data_update
|
||||
0x000081c5 T lld_adv_start
|
||||
0x00008831 T lld_adv_stop
|
||||
0x0000d6c1 T lld_white_list_rem
|
||||
0x0000b401 T lld_init_rand_addr_update
|
||||
0x0000c179 T lld_res_list_add
|
||||
0x0000c251 T lld_res_list_clear
|
||||
0x0000c27d T lld_res_list_local_rpa_get
|
||||
0x0000c2c5 T lld_res_list_peer_rpa_get
|
||||
0x0000c341 T lld_res_list_priv_mode_update
|
||||
0x0000c37d T lld_res_list_rem
|
||||
0x0000cedd T lld_scan_rand_addr_update
|
||||
0x0000b699 T lld_init_start
|
||||
0x0000bc9d T lld_init_stop
|
||||
0x0000f081 T sch_plan_req
|
||||
0x0000f0d5 T sch_plan_set
|
||||
0x0000fec4 D co_rate_to_phy
|
||||
0x0000cb81 T lld_scan_params_update
|
||||
0x0000d115 T lld_scan_start
|
||||
0x0000d5c5 T lld_scan_stop
|
||||
0x0000c3ad T lld_rpa_renew
|
||||
0x0000408d T ke_mem_init
|
||||
0x00002609 T co_buf_init
|
||||
0x0000de9d T rwip_sleep
|
||||
0x10000810 D em_ble_base_address_table_0
|
||||
0x10000812 D em_ble_base_address_table_1
|
||||
0x10000814 D em_ble_base_address_table_2
|
||||
0x10000816 D em_ble_base_address_table_3
|
||||
0x10000818 D em_ble_base_address_table_4
|
||||
0x1000081a D em_ble_base_address_table_5
|
||||
0x10000822 D em_ble_base_address_table_6
|
||||
0x1000081c D em_ble_base_address_table_7
|
||||
0x10000824 D em_ble_base_address_table_8
|
||||
0x1000081e D em_ble_base_address_table_9
|
||||
0x10000820 D em_ble_base_address_table_10
|
||||
0x000021d9 T ble_util_buf_init_env
|
||||
0x10000978 D PATCH_FUN
|
||||
0x1000108c D lld_adv_env
|
||||
0x0000ebe5 T sch_arb_remove
|
||||
0x0000f739 T sch_slice_fg_remove
|
||||
0x10000f44 D llc_env
|
||||
0x0000693d T llc_proc_err_ind
|
||||
0x000073c1 T llc_stop
|
||||
0x00004695 T ll_channel_map_ind_handler
|
||||
0x0000471d T ll_connection_param_req_handler
|
||||
0x00004809 T ll_connection_param_rsp_handler
|
||||
0x0000489d T ll_connection_update_ind_handler
|
||||
0x000049c1 T ll_enc_req_handler
|
||||
0x00004a85 T ll_enc_rsp_handler
|
||||
0x00004af9 T ll_feature_req_handler
|
||||
0x00004b4d T ll_feature_rsp_handler
|
||||
0x00004ba1 T ll_length_req_handler
|
||||
0x00004bf9 T ll_length_rsp_handler
|
||||
0x00004c75 T ll_min_used_channels_ind_handler
|
||||
0x00004cf1 T ll_pause_enc_req_handler
|
||||
0x00004d5d T ll_pause_enc_rsp_handler
|
||||
0x00004db5 T ll_reject_ext_ind_handler
|
||||
0x00004dd5 T ll_reject_ind_handler
|
||||
0x00004df5 T ll_slave_feature_req_handler
|
||||
0x00004e49 T ll_start_enc_req_handler
|
||||
0x00004e99 T ll_start_enc_rsp_handler
|
||||
0x00004ee9 T ll_unknown_rsp_handler
|
||||
0x00004ef9 T ll_version_ind_handler
|
||||
0x00001fd9 T ble_util_buf_acl_tx_free
|
||||
0x0000c5c1 T lld_rxdesc_check
|
||||
0x0000c609 T lld_rxdesc_free
|
||||
0x0000fee4 D rwip_priority
|
||||
0x0000e8b1 T sch_arb_insert
|
||||
0x0000f355 T sch_prog_push
|
||||
0x0000fde5 T FMC_SPI_Flash_RDID
|
||||
0x0000fd8d T FMC_SPI_Flash_RUID
|
||||
0x0000fa71 T FMC_SPI_Flash_WakeUp
|
||||
0x0000f9f1 T FMC_SPI_Init_Oprt
|
||||
0x0000fa49 T FMC_SPI_Flash_PowerDown
|
||||
0x0000fceb T FMC_SPI_FlashRead
|
||||
0x0000fc1f T FMC_SPI_FlashWrite
|
||||
0x0000fb09 T FMC_SPI_Flash_Erase_Sector
|
||||
0x00004fc9 T llc_cleanup
|
||||
0x00005091 T llc_cmd_stat_send
|
||||
0x00005a39 T llc_llcp_send
|
||||
0x00005ac9 T llc_llcp_state_set
|
||||
0x00006981 T llc_proc_get
|
||||
0x00006999 T llc_proc_id_get
|
||||
0x000069b5 T llc_proc_init
|
||||
0x000069c1 T llc_proc_reg
|
||||
0x00006a05 T llc_proc_state_get
|
||||
0x00006a09 T llc_proc_state_set
|
||||
0x00006a0d T llc_proc_timer_pause_set
|
||||
0x00006a7d T llc_proc_timer_set
|
||||
0x00006ae5 T llc_proc_unreg
|
||||
0x0000a1c1 T lld_con_stop
|
||||
0x00007869 T lld_adv_evt_start_cbk
|
||||
0x10000e68 D rwip_env
|
||||
0x1000080e D rwip_prog_delay
|
||||
0x0000e041 T rwip_time_get
|
||||
0x0000e2cd T rwip_wakeup_end
|
||||
0x1000112c D sch_arb_env
|
||||
0x00007905 T lld_adv_frm_cbk
|
||||
0x0000e0b1 T rwip_timer_alarm_handler
|
||||
0x0000e11d T rwip_timer_arb_handler
|
||||
0x0000e189 T rwip_timer_co_handler
|
||||
0x10000f94 D lld_env
|
||||
0x10000828 D aa_gen
|
||||
0x00007c25 T lld_adv_init
|
||||
0x00009301 T lld_con_init
|
||||
0x0000a7f1 T lld_core_init
|
||||
0x1000082c D lld_rpa_renew_env
|
||||
0x00008959 T lld_channel_assess
|
||||
0x100010dc D lld_con_env
|
||||
0x0000a4ad T lld_con_tx_len_update
|
||||
0x10000830 D lld_exp_sync_pos_tab
|
||||
0x0000bce5 T lld_instant_proc_end
|
||||
0x11012145 T prf_dst_task_get
|
||||
0x1101227d T rom_env_init
|
||||
0x110048f5 T gapc_get_bdaddr
|
||||
0x1100bcd9 T gatt_db_svc16_add
|
||||
0x1100be5d T gatt_db_svc_add
|
||||
0x1100d49d T gatt_srv_event_send
|
||||
0x1100d8a5 T gatt_user_srv_register
|
||||
0x1101302c D llc_msg_handler_tab
|
||||
0x10001c80 D rom_llc_state
|
||||
0x00008e4d T lld_con_evt_start_cbk
|
||||
0x00008ddd T lld_con_evt_canceled_cbk
|
||||
0x0000fe9e D co_sca2ppm
|
||||
0x00009051 T lld_con_evt_time_update
|
||||
0x00009415 T lld_con_max_lat_calc
|
||||
0x00009a69 T lld_con_sched
|
||||
0x0000f7e1 T sch_slice_per_add
|
||||
0x0000d801 T rwble_isr
|
||||
0x0000dc75 T rwip_isr
|
||||
0x00009189 T lld_con_frm_isr
|
||||
0x000044f9 T ke_task_schedule
|
||||
0x00007949 T lld_adv_frm_isr
|
||||
0x10001c9b D sv_lock
|
||||
0x10001ca2 D sv_txlen
|
||||
0x10001735 T rom_lld_con_rx
|
||||
0x100019c5 T rom_lld_con_evt_start_cbk
|
||||
0x10001a1d T rom_lld_con_frm_isr
|
||||
0x1100abbd T gatt_cli_mtu_exch
|
||||
0x11012425 T rom_lld_disable_latency
|
||||
0x11012451 T rom_lld_enable_latency
|
||||
0x10001c9a D evt_start
|
||||
0x11009ced T gatt_cli_discover_svc
|
||||
0x1100d945 T gatt_uuid16_comp
|
||||
0x11009415 T gatt_cli_att_event_cfm
|
||||
0x11009729 T gatt_cli_discover_cancel
|
||||
0x1100977d T gatt_cli_discover_char
|
||||
0x110097e3 T gatt_cli_discover_desc
|
||||
0x1100a1b9 T gatt_cli_event_register
|
||||
0x1100ac9d T gatt_cli_read
|
||||
0x1100acd1 T gatt_cli_read_by_uuid
|
||||
0x1100b369 T gatt_cli_write
|
||||
0x1100d7ad T gatt_user_cli_register
|
||||
0x11003cdd T co_rand_word
|
||||
0x11003ce5 T co_random_init
|
||||
0x10001c98 D adv_evt_start
|
||||
0x10001c40 D gatt_srv_read_api_tbl
|
||||
0x10001c54 D gatt_srv_write_api_tbl
|
||||
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // RW SW configuration
|
||||
|
||||
#include "arch.h" // architectural platform definitions
|
||||
#include "boot.h" // boot definition
|
||||
#include "rwip.h" // RW SW initialization
|
||||
#include "xc_drv_pwr.h"
|
||||
#include <stdbool.h> // boolean definition
|
||||
#include <stddef.h> // standard definitions
|
||||
#include <stdint.h> // standard integer definition
|
||||
#include <stdlib.h> // standard lib functions
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
#include "uart.h" // UART initialization
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
|
||||
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
||||
#include "rf.h" // RF initialization
|
||||
#endif // BLE_EMB_PRESENT || BT_EMB_PRESENT
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
// #include "app.h" // application functions
|
||||
#endif // BLE_APP_PRESENT
|
||||
|
||||
#if PLF_DMA
|
||||
#include "dma.h" // DMA initialization
|
||||
#endif // PLF_DMA
|
||||
|
||||
#if (PLF_NVDS)
|
||||
#include "nvds.h" // NVDS definitions
|
||||
#endif // PLF_NVDS
|
||||
|
||||
#include "reg_assert_mgr.h"
|
||||
#if (PLF_PROFILING || PLF_MEM_PROTECTION)
|
||||
#include "reg_sw_profiling.h"
|
||||
#endif // (PLF_PROFILING || PLF_MEM_PROTECTION)
|
||||
#include "platform.h"
|
||||
|
||||
#include "xc6xxx.h"
|
||||
|
||||
// CPU early wake-up time (unit:us)
|
||||
#define SLEEP_TIME_EARLY (3000)
|
||||
|
||||
#define HS_TO_US(frame) (((frame) * SLOT_SIZE) >> 1)
|
||||
|
||||
/**
|
||||
* @brief clock_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void clock_init(void)
|
||||
{
|
||||
CLOCK_InitCfg_t clock_cfg;
|
||||
|
||||
clock_cfg.hfclk_src = CLOCK_HFCLK_SRC_XTAL;
|
||||
clock_cfg.hfclk_in = CLOCK_HFCLK_IN_32M;
|
||||
#if (RC_32K)
|
||||
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_RC;
|
||||
#endif //(RC_32K)
|
||||
|
||||
#if (XTAL_32K)
|
||||
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_XTAL;
|
||||
#endif // (XTAL_32K)
|
||||
|
||||
#if (XTAL_32768K)
|
||||
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_XTAL;
|
||||
#endif // (XTAL_32768K)
|
||||
|
||||
if (clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_XTAL) {
|
||||
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32768;
|
||||
} else if (clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_RC) {
|
||||
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32K;
|
||||
}
|
||||
|
||||
xc_clock_init_cfg(&clock_cfg);
|
||||
|
||||
SysTick_Config(xc_clock_hfclk_in_get() / 100);
|
||||
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
||||
}
|
||||
|
||||
#if (SLEEP_ENABLE)
|
||||
void wakeup_timer_init(void)
|
||||
{
|
||||
TIMER_BaseInitTypeDef Timer_Init;
|
||||
Timer_Init.src_clk = TIMER_CLK_SRC_32K;
|
||||
Timer_Init.mode = TIMER_MODE_SINGLE_COUNT;
|
||||
Timer_Init.div_clk = TIMER_DIV_CLK_32000Hz;
|
||||
// Timer0 Config & Start
|
||||
TIMER_Base_Init(XC_TIMER0, &Timer_Init);
|
||||
|
||||
PWR_InitTypeDef PWR_InitStruct = {0};
|
||||
PWR_InitStruct.PWR_WakeITSrc = GPIO_IRQn_WAKE | TIMER0_IRQn_WAKE;
|
||||
PWR_InitStruct.PWR_SleepMode = LIGHT_SLEEP_MODE;
|
||||
PWR_SleepInit(&PWR_InitStruct);
|
||||
|
||||
PWR_GPIO_SleepConfig(PWR_InitStruct.PWR_SleepMode);
|
||||
|
||||
PWR_GPIO_LightSleepWakeConfig(GPIO_2, RIS_EDGE_INT);
|
||||
PWR_GPIO_LightSleepWakeConfig(GPIO_3, RIS_EDGE_INT);
|
||||
}
|
||||
|
||||
void sleep_wkup()
|
||||
{
|
||||
PWR_InitTypeDef PWR_InitStruct = {0};
|
||||
|
||||
#if (USE_XIP != 1)
|
||||
SPI_InitCfg_t spi_cfg = {0};
|
||||
spi_cfg.Mode = SPI_MODE_MASTER;
|
||||
spi_cfg.DataSize = SSI_CTRL0_DFS_LEN_8BIT;
|
||||
spi_cfg.Direction = SSI_CTRL0_TMOD_WR;
|
||||
spi_cfg.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
spi_cfg.CLKPolarity = SSI_CTRL0_SCPOL_LOW;
|
||||
spi_cfg.CLKPhase = SPI_CPHA_LEAD;
|
||||
spi_cfg.FirstBit = SPI_FirstBit_MSB;
|
||||
|
||||
xc_spi_init(XC_SPI0, &spi_cfg);
|
||||
SPI_Flash_PowerDown(XC_SPI0);
|
||||
#endif //(USE_XIP!=1)
|
||||
|
||||
// PWR_InitStruct.PWR_WakeITSrc = GPIO_IRQn_WAKE | TIMER0_IRQn_WAKE ;
|
||||
// PWR_InitStruct.PWR_SleepMode = LIGHT_SLEEP_MODE;
|
||||
// PWR_SleepInit(&PWR_InitStruct);
|
||||
// PWR_GPIO_SleepConfig(PWR_InitStruct.PWR_SleepMode);
|
||||
sleep_init();
|
||||
PWR_BLE_SleepEnter();
|
||||
}
|
||||
|
||||
void Turn_Off_PeripheralClk()
|
||||
{
|
||||
XC_CPR->SSI0_MCLK_CTL = (((0UL << CPR_SSI_MCLK_CTL_SSI_MCLK_DIV_Pos) |
|
||||
CPR_SSI_MCLK_CTL_SSI_MCLK_DIV_WE) |
|
||||
((CPR_SSI_MCLK_CTL_SSI_MCLK_EN_DISABLE) |
|
||||
CPR_SSI_MCLK_CTL_SSI_MCLK_EN_WE));
|
||||
|
||||
XC_CPR->CTLAPBCLKEN_GRCTL = ((CPR_CTLAPBCLKEN_GRCTL_SSI0_PCLK_EN_DISABLE) |
|
||||
(CPR_CTLAPBCLKEN_GRCTL_SSI0_PCLK_EN_Msk
|
||||
<< CPR_CTLAPBCLKEN_GRCTL_MASK_OFFSET))
|
||||
<< 0;
|
||||
|
||||
XC_CPR->CTLAPBCLKEN_GRCTL = ((CPR_CTLAPBCLKEN_GRCTL_UART0_PCLK_EN_DISABLE) |
|
||||
(CPR_CTLAPBCLKEN_GRCTL_UART0_PCLK_EN_Msk
|
||||
<< CPR_CTLAPBCLKEN_GRCTL_MASK_OFFSET));
|
||||
|
||||
XC_CPR->UART0_CLK_GRCTL = (((8UL << CPR_UART_CLK_GRCTL_UART0_CLK_GR_Pos) |
|
||||
CPR_UART_CLK_GRCTL_UART0_CLK_GR_WE) |
|
||||
((CPR_UART_CLK_GRCTL_UART0_CLK_GR_UPD_DISABLE) |
|
||||
(CPR_UART_CLK_GRCTL_UART1_CLK_GR_UPD_WE)));
|
||||
|
||||
XC_CPR->CTLAPBCLKEN_GRCTL = ((CPR_CTLAPBCLKEN_GRCTL_UART0_PCLK_EN_DISABLE) |
|
||||
(CPR_CTLAPBCLKEN_GRCTL_UART0_PCLK_EN_Msk
|
||||
<< CPR_CTLAPBCLKEN_GRCTL_MASK_OFFSET))
|
||||
<< 1;
|
||||
//
|
||||
// XC_CPR->UART1_CLK_GRCTL = (((8UL <<
|
||||
// CPR_UART_CLK_GRCTL_UART1_CLK_GR_Pos) |
|
||||
// CPR_UART_CLK_GRCTL_UART1_CLK_GR_WE) |
|
||||
// ((CPR_UART_CLK_GRCTL_UART1_CLK_GR_UPD_DISABLE)
|
||||
// |
|
||||
// (CPR_UART_CLK_GRCTL_UART1_CLK_GR_UPD_WE)));
|
||||
|
||||
// XC_CPR->AHBCLKEN_GRCTL =0x1e001e;
|
||||
}
|
||||
|
||||
void sleep_schedule()
|
||||
{
|
||||
// Checks for sleep have to be done with interrupt disabled
|
||||
GLOBAL_INT_DISABLE();
|
||||
|
||||
// Check if the processor clock can be gated
|
||||
uint32_t duration = 0;
|
||||
uint32_t duration_timer = 0;
|
||||
// switch(rwip_sleep(&duration, 2, \
|
||||
// 0x7D00, RWIP_MINIMUM_SLEEP_TIME)){
|
||||
switch (rwip_sleep(&duration, 1, 0x7D00, 20)) {
|
||||
case RWIP_DEEP_SLEEP: {
|
||||
duration_timer = (HS_TO_US(duration) - SLEEP_TIME_EARLY);
|
||||
TIMER_SetUs(XC_TIMER0, duration_timer);
|
||||
TIMER_Start_IT(XC_TIMER0);
|
||||
sleep_wkup();
|
||||
__TIMER_Disable(XC_TIMER0);
|
||||
}
|
||||
// no break
|
||||
case RWIP_CPU_SLEEP: {
|
||||
// Wait for interrupt
|
||||
// Turn_Off_PeripheralClk();
|
||||
|
||||
// __PWR_SleepSrcMask_Set(0x1e000e);
|
||||
// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
|
||||
// __WFI();
|
||||
// __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
|
||||
// __PWR_SleepSrcMask_Set(0x1e001e);
|
||||
} break;
|
||||
case RWIP_ACTIVE:
|
||||
default: {
|
||||
// nothing to do.
|
||||
} break;
|
||||
}
|
||||
// Checks for sleep have to be done with interrupt disabled
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
#endif // (SLEEP_ENABLE)
|
||||
@@ -0,0 +1,245 @@
|
||||
|
||||
;/*****************************************************************************
|
||||
; * @file: startup_xinc.s
|
||||
; * @purpose: CMSIS Cortex-M0 Core Device Startup File for the
|
||||
; * Device xinc.
|
||||
; *****************************************************************************/
|
||||
|
||||
Stack_Size EQU 0x000006f0
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
Heap_Size EQU 0x00000000
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
; ToDo: Add here the vectors for the device specific external interrupts handler
|
||||
DCD BLE_Handler ; 0
|
||||
DCD DMA_Handler ; 1
|
||||
DCD CPR_Handler ; 2
|
||||
DCD GPIO_Handler ; 3
|
||||
DCD RTC_Handler ; 4
|
||||
DCD TIMER0_Handler ; 5
|
||||
DCD TIMER1_Handler ; 6
|
||||
DCD TIMER2_Handler ; 7
|
||||
DCD TIMER3_Handler ; 8
|
||||
DCD WDT_Handler ; 9
|
||||
DCD I2C_Handler ; 10
|
||||
DCD UART0_Handler ; 11
|
||||
DCD UART1_Handler ; 12
|
||||
DCD SPI0_Handler ; 13
|
||||
DCD SPI1_Handler ; 14
|
||||
DCD 0 ; 15
|
||||
DCD 0 ; 16
|
||||
DCD GADC_Handler ; 17
|
||||
DCD PWM_Handler ; 18
|
||||
DCD AES_Handler ; 19
|
||||
DCD USB_Handler ; 20
|
||||
DCD AUDIO_Handler ; 21
|
||||
DCD RF24G_Handler ; 22
|
||||
DCD SPI2_Handler ; 23
|
||||
DCD MPU_Handler ; 24
|
||||
DCD UART2_Handler ; 25
|
||||
DCD I2S_Handler ; 26
|
||||
DCD AOTIMER0_Handler ; 27
|
||||
DCD AOTIMER1_Handler ; 28
|
||||
DCD CMP_Handler ; 29
|
||||
DCD FMC_Handler ; 30
|
||||
DCD CAN_Handler ; 31
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
; Reset Handler
|
||||
|
||||
Reset_Handler PROC
|
||||
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
LDR r0, =0x4000013C ; remap
|
||||
LDR r1, =0x10000001
|
||||
STR r1, [r0]
|
||||
|
||||
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
EXPORT BLE_Handler [WEAK]
|
||||
EXPORT DMA_Handler [WEAK]
|
||||
EXPORT CPR_Handler [WEAK]
|
||||
EXPORT GPIO_Handler [WEAK]
|
||||
EXPORT RTC_Handler [WEAK]
|
||||
EXPORT TIMER0_Handler [WEAK]
|
||||
EXPORT TIMER1_Handler [WEAK]
|
||||
EXPORT TIMER2_Handler [WEAK]
|
||||
EXPORT TIMER3_Handler [WEAK]
|
||||
EXPORT WDT_Handler [WEAK]
|
||||
EXPORT I2C_Handler [WEAK]
|
||||
EXPORT UART0_Handler [WEAK]
|
||||
EXPORT UART1_Handler [WEAK]
|
||||
EXPORT SPI0_Handler [WEAK]
|
||||
EXPORT SPI1_Handler [WEAK]
|
||||
;EXPORT KBS_Handler [WEAK]
|
||||
;EXPORT QDEC_Handler [WEAK]
|
||||
EXPORT GADC_Handler [WEAK]
|
||||
EXPORT PWM_Handler [WEAK]
|
||||
EXPORT AES_Handler [WEAK]
|
||||
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
|
||||
EXPORT USB_Handler [WEAK];20
|
||||
EXPORT AUDIO_Handler [WEAK];21
|
||||
EXPORT RF24G_Handler [WEAK];22
|
||||
EXPORT SPI2_Handler [WEAK];23
|
||||
EXPORT MPU_Handler [WEAK];24
|
||||
EXPORT UART2_Handler [WEAK];25
|
||||
EXPORT I2S_Handler [WEAK];26
|
||||
EXPORT AOTIMER0_Handler [WEAK];27
|
||||
EXPORT AOTIMER1_Handler [WEAK];28
|
||||
EXPORT CMP_Handler [WEAK];29
|
||||
EXPORT FMC_Handler [WEAK];30
|
||||
EXPORT CAN_Handler [WEAK];31
|
||||
|
||||
PendSV_Handler
|
||||
SysTick_Handler
|
||||
BLE_Handler
|
||||
RF24G_Handler
|
||||
DMA_Handler
|
||||
CPR_Handler
|
||||
GPIO_Handler
|
||||
RTC_Handler
|
||||
TIMER0_Handler
|
||||
TIMER1_Handler
|
||||
TIMER2_Handler
|
||||
TIMER3_Handler
|
||||
WDT_Handler
|
||||
I2C_Handler
|
||||
I2S_Handler
|
||||
UART0_Handler
|
||||
UART1_Handler
|
||||
UART2_Handler
|
||||
SPI0_Handler
|
||||
SPI1_Handler
|
||||
SPI2_Handler
|
||||
MPU_Handler
|
||||
;KBS_Handler
|
||||
;QDEC_Handler
|
||||
GADC_Handler
|
||||
PWM_Handler
|
||||
AUDIO_Handler
|
||||
;SIM_Handler
|
||||
AES_Handler
|
||||
AOTIMER0_Handler
|
||||
AOTIMER1_Handler
|
||||
CMP_Handler
|
||||
FMC_Handler
|
||||
CAN_Handler
|
||||
USB_Handler
|
||||
|
||||
B .
|
||||
ENDP
|
||||
|
||||
|
||||
ALIGN
|
||||
|
||||
; User Initial Stack & Heap
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, = (Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
END
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rwip.h"
|
||||
#include "xc6xxx.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define __DEBUG_OUT_PORT 0
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define VECTOR_NUM 48
|
||||
|
||||
void set_vector(void)
|
||||
{
|
||||
#if (USE_XIP == 1)
|
||||
__disable_irq();
|
||||
for (uint32_t i = 0, *Pvector = (uint32_t *)(0x11014000 + 0),
|
||||
*_vector_table = (uint32_t *)(0x10000000);
|
||||
i < VECTOR_NUM; i++) // copy vertor table
|
||||
{
|
||||
_vector_table[i] = *Pvector++;
|
||||
}
|
||||
|
||||
*((volatile unsigned int *)(0x4000013C)) =
|
||||
0x10000001; // inter vertor table remap
|
||||
__enable_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void WDT_ResetInit(void)
|
||||
{
|
||||
cpr_ctlapbclken_grctl__wdt_pclk_en__setf(ENABLE);
|
||||
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_DISABLE);
|
||||
|
||||
cpr_rstctl_wdtrst_mask_set(
|
||||
(WDT_SYS_RSTN_MASK_DISABLE | WDT_M0_RSTN_MASK_ENABLE));
|
||||
|
||||
cpr_lp_ctl__wdt_tclk_en__setf(DISABLE);
|
||||
wdt_cr__wdt_en__setf(DISABLE);
|
||||
}
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
|
||||
WDT_ResetInit();
|
||||
|
||||
#if (USE_XIP == 1)
|
||||
|
||||
set_vector();
|
||||
#endif
|
||||
|
||||
// enable BT CLK
|
||||
writel(0x40000040, readl(0x40000040) | (0x01 << 4) | 0xFFFF0000);
|
||||
}
|
||||
|
||||
__RAM_CODE int sendchar(int c)
|
||||
{
|
||||
unsigned int status;
|
||||
#if (__DEBUG_OUT_PORT == 1)
|
||||
for (;;) {
|
||||
status = (*((volatile unsigned *)(0x40011000 + 0x14)));
|
||||
status &= 0x20;
|
||||
if (status == 0x20)
|
||||
break;
|
||||
}
|
||||
(*((volatile unsigned *)(0x40011000 + 0x00))) = c;
|
||||
return (1);
|
||||
#else
|
||||
for (;;) {
|
||||
status = (*((volatile unsigned *)(0x40010000 + 0x14)));
|
||||
status &= 0x20;
|
||||
if (status == 0x20)
|
||||
break;
|
||||
}
|
||||
(*((volatile unsigned *)(0x40010000 + 0x00))) = c;
|
||||
return (1);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct __FILE
|
||||
{
|
||||
int handle; /* Add whatever you need here */
|
||||
};
|
||||
|
||||
FILE __stdout;
|
||||
__RAM_CODE int fputc(int ch, FILE *f) { return (sendchar(ch)); }
|
||||
|
||||
int ferror(FILE *f)
|
||||
{
|
||||
/* Your implementation of ferror */
|
||||
return EOF;
|
||||
}
|
||||
|
||||
void _ttywrch(int ch) { sendchar(ch); }
|
||||
|
||||
void _sys_exit(int return_code)
|
||||
{
|
||||
label:
|
||||
goto label; /* endless loop */
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
#include "usr_client.h"
|
||||
|
||||
uint8_t cli_user_lid = GATT_INVALID_USER_LID;
|
||||
/* Handle for sending data from the centre to the slave. */
|
||||
uint16_t cli_tx_hdl = GATT_INVALID_HDL;
|
||||
uint16_t cli_chg_ccc_hdl = GATT_INVALID_HDL;
|
||||
|
||||
#define CUSTOM_SVC_UUID_CLI 0xFFF0
|
||||
#define CUSTOM_SVC_RX_CHAR_UUID_CLI 0xFFF3
|
||||
#define CUSTOM_SVC_TX_CHAR_UUID_CLI 0xFFF4
|
||||
|
||||
uint8_t get_cli_user_ild(void) { return cli_user_lid; }
|
||||
|
||||
void cli_discover_cmp_cb(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
|
||||
uint16_t status)
|
||||
{
|
||||
LOGI(
|
||||
"[%s] conidx = 0x%x, user_lid = 0x%x, dummy = 0x%x, status = 0x%x \r\n",
|
||||
__func__, conidx, user_lid, dummy, status);
|
||||
|
||||
uint16_t cli_cfg = GATT_CCC_START_NTF;
|
||||
status = xc_ble_gatt_cli_write(conidx, get_cli_user_ild(), 0, GATT_WRITE,
|
||||
cli_chg_ccc_hdl, 2, (uint8_t *)&cli_cfg);
|
||||
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("xc_ble_gatt_cli_write error 0x%x", status);
|
||||
}
|
||||
|
||||
// send_data(conidx);
|
||||
}
|
||||
|
||||
void cli_read_cmp_cb(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
|
||||
uint16_t status)
|
||||
{
|
||||
LOGI(
|
||||
"[%s] conidx = 0x%x, user_lid = 0x%x, dummy = 0x%x, status = 0x%x \r\n",
|
||||
__func__, conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
void cli_write_cmp_cb(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
|
||||
uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx = 0x%x, user_lid = 0x%x, dummy = 0x%x, status = 0x%x\r\n",
|
||||
__func__, conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
void cli_svc_cb(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t hdl,
|
||||
uint8_t disc_info, uint8_t nb_att, const gatt_svc_att_t *p_atts)
|
||||
{
|
||||
LOGI("[%s] conidx = 0x%x, user_lid = 0x%x, dummy = 0x%x, hdl = 0x%x \r\n",
|
||||
__func__, conidx, user_lid, dummy, hdl);
|
||||
|
||||
uint8_t cursor;
|
||||
uint16_t att_handle = GATT_INVALID_HDL;
|
||||
|
||||
// check all attributes
|
||||
for (cursor = 0; cursor < nb_att; cursor++) {
|
||||
const gatt_svc_att_t *p_att = &(p_atts[cursor]);
|
||||
|
||||
switch (p_att->att_type) {
|
||||
case GATT_ATT_PRIMARY_SVC: {
|
||||
} break;
|
||||
case GATT_ATT_CHAR: {
|
||||
att_handle = p_att->info.charac.val_hdl;
|
||||
} break;
|
||||
case GATT_ATT_VAL: {
|
||||
if (gatt_uuid16_comp(p_att->uuid, p_att->uuid_type,
|
||||
CUSTOM_SVC_RX_CHAR_UUID_CLI)) {
|
||||
cli_tx_hdl = att_handle;
|
||||
LOGI("cli_tx_hdl=0x%x\n", cli_tx_hdl);
|
||||
}
|
||||
} break;
|
||||
case GATT_ATT_DESC: {
|
||||
// Client Char Configuration of service changed value
|
||||
if (gatt_uuid16_comp(p_att->uuid, p_att->uuid_type,
|
||||
GATT_DESC_CLIENT_CHAR_CFG)) {
|
||||
cli_chg_ccc_hdl = hdl + cursor;
|
||||
LOGI("cli_chg_ccc_hdl=0x%x\n", cli_chg_ccc_hdl);
|
||||
}
|
||||
} break;
|
||||
default: { /* Nothing to do */
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cli_svc_info_cb(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
|
||||
uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type,
|
||||
const uint8_t *p_uuid)
|
||||
{
|
||||
LOGI("[%s] conidx = 0x%x, user_lid = 0x%x, start_hdl = 0x%x, end_hdl = "
|
||||
"0x%x, uuid[0] = 0x%x, uuid[1] = 0x%x \r\n",
|
||||
__func__, conidx, user_lid, start_hdl, end_hdl, p_uuid[0], p_uuid[1]);
|
||||
}
|
||||
|
||||
void cli_read_val_cb(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
|
||||
uint16_t hdl, uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
LOGI("[%s] conidx = 0x%x, user_lid = 0x%x, handler = 0x%x, length = "
|
||||
"0x%x data: \r\n",
|
||||
__func__, conidx, user_lid, hdl, length);
|
||||
// DUMP_DATA_PRINTF(&(co_buf_data(p_data)[0]), length);
|
||||
}
|
||||
|
||||
void cli_val_evt_cb(uint8_t conidx, uint8_t user_lid, uint16_t token,
|
||||
uint8_t evt_type, bool complete, uint16_t hdl,
|
||||
co_buf_t *p_data)
|
||||
{
|
||||
uint16_t status;
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
|
||||
LOGI("[%s] conidx = 0x%x, user_lid = 0x%x, token = 0x%x evt_type = \
|
||||
0x%x complete = 0x%x handler = 0x%x, length = %d data: \r\n",
|
||||
__func__, conidx, user_lid, token, evt_type, complete, hdl, length);
|
||||
status = xc_ble_gatt_cli_indicate_cfm(conidx, user_lid, token);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_cli_indicate_cfm error 0x%x", status);
|
||||
}
|
||||
|
||||
|
||||
for(uint8_t i = 0;i<length;i++)
|
||||
{
|
||||
LOGI(" %02x ",co_buf_data(p_data)[i]);
|
||||
}
|
||||
LOGI("\r\n");
|
||||
//(&(co_buf_data(p_data)[0]), length);
|
||||
}
|
||||
|
||||
void cli_svc_changed_cb(uint8_t conidx, uint8_t user_lid, bool out_of_sync,
|
||||
uint16_t start_hdl, uint16_t end_hdl)
|
||||
{
|
||||
LOGI("[%s] conidx = 0x%x, user_lid = 0x%x, out_of_sync = 0x%x ,start_hdl = "
|
||||
"0x%x, end_hdl = "
|
||||
"0x%x \r\n",
|
||||
__func__, conidx, user_lid, out_of_sync, start_hdl, end_hdl);
|
||||
}
|
||||
|
||||
static const gatt_cli_cb_t cli_cb = {
|
||||
.cb_discover_cmp = cli_discover_cmp_cb,
|
||||
.cb_read_cmp = cli_read_cmp_cb,
|
||||
.cb_write_cmp = cli_write_cmp_cb,
|
||||
.cb_svc = cli_svc_cb,
|
||||
.cb_svc_info = cli_svc_info_cb,
|
||||
.cb_att_val = cli_read_val_cb,
|
||||
.cb_att_val_evt = cli_val_evt_cb,
|
||||
.cb_svc_changed = cli_svc_changed_cb,
|
||||
};
|
||||
|
||||
uint8_t app_cli_register(void)
|
||||
{
|
||||
uint16_t status = 0;
|
||||
status = xc_ble_gatt_user_cli_register(GAP_LE_MTU_MAX, 0, &cli_cb,
|
||||
&cli_user_lid);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_user_cli_register error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
__RAM_EM uint8_t data_test[THROUGHTPUT_SEND_DATA_LEN] = {0x00, 0x01, 0x02,
|
||||
0x03};
|
||||
void send_data(uint8_t conidx)
|
||||
{
|
||||
uint16_t status;
|
||||
|
||||
status = xc_ble_gatt_cli_write(conidx, get_cli_user_ild(), 0, GATT_WRITE,
|
||||
cli_tx_hdl, sizeof(data_test), data_test);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("write error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
void usr_cli_feat_enable(uint8_t conidx)
|
||||
{
|
||||
uint16_t svc_uuid = CUSTOM_SVC_UUID_CLI;
|
||||
uint8_t status = gatt_cli_discover_svc(
|
||||
conidx, get_cli_user_ild(), 0, GATT_DISCOVER_SVC_PRIMARY_BY_UUID, true,
|
||||
GATT_MIN_HDL, GATT_MAX_HDL, GATT_UUID_16, (uint8_t *)&svc_uuid);
|
||||
|
||||
if (status == GATT_NO_ERROR) {
|
||||
status = xc_ble_gatt_cli_event_register(conidx, get_cli_user_ild(),
|
||||
GATT_MIN_HDL, GATT_MAX_HDL);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("xc_ble_gatt_cli_event_register error 0x%x", status);
|
||||
}
|
||||
} else {
|
||||
LOGI_ERR("gatt_cli_discover_svc error 0x%x", status);
|
||||
}
|
||||
|
||||
// uint16_t xc_ble_gatt_cli_mtu_exch( conidx, get_cli_user_ild());
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_client.h
|
||||
*
|
||||
* @brief Custom client
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _USR_CLIENT_H_
|
||||
#define _USE_CLIENT_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "usr_server.h"
|
||||
#include "xc_gatt_client_api.h"
|
||||
|
||||
#define THROUGHTPUT_SEND_DATA_LEN 20
|
||||
|
||||
uint8_t get_cli_user_ild(void);
|
||||
uint8_t app_cli_register(void);
|
||||
void usr_cli_feat_enable(uint8_t conidx);
|
||||
#endif // _USE_CLIENT_H_
|
||||
@@ -0,0 +1,170 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.c
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#include "usr_server.h"
|
||||
#include "xc6xxx.h"
|
||||
uint8_t srv_user_lid = GATT_INVALID_USER_LID;
|
||||
uint16_t custom_svc_start_hdl = GATT_INVALID_HDL;
|
||||
uint8_t custom_svc_tx_char_notify = DISABLE;
|
||||
|
||||
static const gatt_att_desc_t custom_server_atts[] = {
|
||||
[CUSTOM_SVC_DECL] =
|
||||
{
|
||||
.uuid = 0x00,
|
||||
0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_RX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid = 0x03,
|
||||
0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_RX_CHAR_VAL] =
|
||||
{
|
||||
.uuid = CUSTOM_SVC_RX_CHAR_UUID,
|
||||
.info = GATT_ATT_WC_BIT | GATT_ATT_RD_BIT | ATT_UUID(128),
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid = 0x03,
|
||||
0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_VAL] =
|
||||
{
|
||||
.uuid = CUSTOM_SVC_TX_CHAR_UUID,
|
||||
.info = GATT_ATT_N_BIT | ATT_UUID(128),
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_CFG] =
|
||||
{
|
||||
.uuid = 0x02,
|
||||
0x29,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WR_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
|
||||
uint16_t srv_get_hdl_from_att_idx(uint8_t idx)
|
||||
{
|
||||
return custom_svc_start_hdl + idx;
|
||||
}
|
||||
|
||||
// This function is called when GATT server user has initiated event send to
|
||||
// peer device or if an error occurs.
|
||||
__STATIC void custom_svc_cb_event_sent(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t dummy, uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, dummy:%d, status:%d \r\n", __func__,
|
||||
conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
// This function is called when peer want to read local attribute database
|
||||
// value.
|
||||
__STATIC void custom_svc_cb_att_read_get(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, uint16_t max_length)
|
||||
{
|
||||
uint16_t status;
|
||||
uint8_t data[] = {0x12, 0x15, 0x46, 0x62};
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d, "
|
||||
"max_length:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset, max_length);
|
||||
// Send result to peer device
|
||||
status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
sizeof(data), sizeof(data), data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_read_cfm error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC void custom_svc_cb_att_val_set(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
uint16_t status;
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset);
|
||||
status =
|
||||
xc_ble_gatt_srv_write_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_write_cfm error 0x%x", status);
|
||||
}
|
||||
LOGI("length:%d data:\r\n", length);
|
||||
// DUMP_DATA_PRINTF(co_buf_data(p_data), length);
|
||||
// xc_fota_server_write_ind(co_buf_data(p_data), length);
|
||||
// LOGI("hdl=%x %x\r\n", hdl,
|
||||
// srv_get_hdl_from_att_idx(CUSTOM_SVC_TX_CHAR_CFG));
|
||||
if (hdl == srv_get_hdl_from_att_idx(CUSTOM_SVC_TX_CHAR_CFG)) {
|
||||
if ((co_buf_data(p_data)[1] == 0) && (co_buf_data(p_data)[0] == 0)) {
|
||||
custom_svc_tx_char_notify = DISABLE;
|
||||
} else {
|
||||
custom_svc_tx_char_notify = ENABLE;
|
||||
LOGI("custom_svc_tx_char_notify ENABLE\r\n");
|
||||
uint8_t data[254] = {0x12, 0x13, 0x14};
|
||||
slave_send_data(data, sizeof(data), CUSTOM_SVC_TX_CHAR_VAL);
|
||||
LOGI("notify test\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const gatt_srv_cb_t custom_src_cb = {
|
||||
.cb_event_sent = custom_svc_cb_event_sent,
|
||||
.cb_att_read_get = custom_svc_cb_att_read_get,
|
||||
.cb_att_val_set = custom_svc_cb_att_val_set,
|
||||
};
|
||||
|
||||
uint8_t custom_svc_add(void)
|
||||
{
|
||||
int nb_att = sizeof(custom_server_atts) / sizeof(custom_server_atts[0]);
|
||||
uint16_t status;
|
||||
uint8_t custom_svc_uuid[GATT_UUID_128_LEN] = CUSTOM_SVC_UUID;
|
||||
status = xc_ble_gatt_user_srv_register(GAP_LE_MTU_MAX, 0, &custom_src_cb,
|
||||
&srv_user_lid);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_user_srv_register error 0x%x", status);
|
||||
}
|
||||
status = xc_ble_gatt_service_add(
|
||||
srv_user_lid, GATT_UUID_128 << GATT_SVC_UUID_TYPE_LSB, custom_svc_uuid,
|
||||
nb_att, NULL, &(custom_server_atts[0]), nb_att, &custom_svc_start_hdl);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("xc_ble_gatt_service_add error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx)
|
||||
{
|
||||
uint16_t status = INVALID_DATA;
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
if (app_env->slave_connected && custom_svc_tx_char_notify) {
|
||||
status = xc_ble_gatt_srv_notify(app_env->slave_conidx, srv_user_lid, 0,
|
||||
srv_get_hdl_from_att_idx(att_idx), len,
|
||||
data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_notify error 0x%x", status);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _USR_SERVER_H_
|
||||
#define _USR_SERVER_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
|
||||
// #define CUSTOM_SVC_UUID
|
||||
// {0x00,0x00,0xFF,0x10,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFA}
|
||||
// #define CUSTOM_SVC_RX_CHAR_UUID
|
||||
// 0x00,0x00,0xFF,0x11,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB
|
||||
// #define CUSTOM_SVC_TX_CHAR_UUID
|
||||
// 0x00,0x00,0xFF,0x12,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB
|
||||
|
||||
#define CUSTOM_SVC_UUID \
|
||||
{ \
|
||||
0xFA, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, \
|
||||
0x00, 0x10, 0xFF, 0x00, 0x00 \
|
||||
}
|
||||
#define CUSTOM_SVC_TX_CHAR_UUID \
|
||||
0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \
|
||||
0x11, 0xFF, 0x00, 0x00
|
||||
#define CUSTOM_SVC_RX_CHAR_UUID \
|
||||
0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \
|
||||
0x12, 0xFF, 0x00, 0x00
|
||||
|
||||
#define CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH (512)
|
||||
#define CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH (512)
|
||||
|
||||
#ifndef DISABLE
|
||||
#define DISABLE 0
|
||||
#endif // DISABLE
|
||||
|
||||
#ifndef ENABLE
|
||||
#define ENABLE 1
|
||||
#endif // ENABLE
|
||||
|
||||
enum cust_svc
|
||||
{
|
||||
CUSTOM_SVC_DECL = 0,
|
||||
CUSTOM_SVC_RX_CHAR_DECL_CHAR,
|
||||
CUSTOM_SVC_RX_CHAR_VAL,
|
||||
CUSTOM_SVC_TX_CHAR_DECL_CHAR,
|
||||
CUSTOM_SVC_TX_CHAR_VAL,
|
||||
CUSTOM_SVC_TX_CHAR_CFG,
|
||||
};
|
||||
uint8_t custom_svc_add(void);
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
#endif // _USR_SERVER_H_
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
FUNC void Initialization(void)
|
||||
{
|
||||
SP = _RDWORD(0x10000000);
|
||||
PC = _RDWORD(0x10000004);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOAD %L INCREMENTAL
|
||||
Initialization();
|
||||
@@ -0,0 +1,39 @@
|
||||
[BREAKPOINTS]
|
||||
ForceImpTypeAny = 0
|
||||
ShowInfoWin = 1
|
||||
EnableFlashBP = 2
|
||||
BPDuringExecution = 0
|
||||
[CFI]
|
||||
CFISize = 0x00
|
||||
CFIAddr = 0x00
|
||||
[CPU]
|
||||
MonModeVTableAddr = 0xFFFFFFFF
|
||||
MonModeDebug = 0
|
||||
MaxNumAPs = 0
|
||||
LowPowerHandlingMode = 0
|
||||
OverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
[FLASH]
|
||||
CacheExcludeSize = 0x00
|
||||
CacheExcludeAddr = 0x00
|
||||
MinNumBytesFlashDL = 0
|
||||
SkipProgOnCRCMatch = 1
|
||||
VerifyDownload = 1
|
||||
AllowCaching = 1
|
||||
EnableFlashDL = 2
|
||||
Override = 0
|
||||
Device="ARM7"
|
||||
[GENERAL]
|
||||
WorkRAMSize = 0x00
|
||||
WorkRAMAddr = 0x00
|
||||
RAMUsageLimit = 0x00
|
||||
[SWO]
|
||||
SWOLogFile=""
|
||||
[MEM]
|
||||
RdOverrideOrMask = 0x00
|
||||
RdOverrideAndMask = 0xFFFFFFFF
|
||||
RdOverrideAddr = 0xFFFFFFFF
|
||||
WrOverrideOrMask = 0x00
|
||||
WrOverrideAndMask = 0xFFFFFFFF
|
||||
WrOverrideAddr = 0xFFFFFFFF
|
||||
@@ -0,0 +1,16 @@
|
||||
LOAD 0x10000000
|
||||
{
|
||||
EXE 0x10000000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
|
||||
RW +0000
|
||||
{
|
||||
* (+RW,+ZI)
|
||||
}
|
||||
|
||||
ScatterAssert(ImageLength(RW) < 1024 * 28)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
LOAD 0x11014000
|
||||
{
|
||||
EXE 0x11014000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
;This area is vector
|
||||
RW1 0x10000100
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
}
|
||||
ScatterAssert(ImageLength(RW1) < (0x800 - 0x100))
|
||||
RW 0x10002d00
|
||||
{
|
||||
; startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
aeabi_sdiv.o(.text)
|
||||
uread4.o(.text)
|
||||
rt_memclr.o(.text)
|
||||
}
|
||||
ScatterAssert((0x2d00+ImageLength(RW)) < 1024 * 32 )
|
||||
|
||||
|
||||
; RW2 (0x53004000+12*1024)
|
||||
; {
|
||||
; *(ram_em)
|
||||
; }
|
||||
; ScatterAssert((0x53004000+12*1024)+ImageLength(RW2) < (0x53004000+16*1024))
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,553 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
||||
|
||||
<SchemaVersion>1.0</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Extensions>
|
||||
<cExt>*.c</cExt>
|
||||
<aExt>*.s*; *.src; *.a*</aExt>
|
||||
<oExt>*.obj; *.o</oExt>
|
||||
<lExt>*.lib</lExt>
|
||||
<tExt>*.txt; *.h; *.inc; *.md</tExt>
|
||||
<pExt>*.plm</pExt>
|
||||
<CppX>*.cpp</CppX>
|
||||
<nMigrate>0</nMigrate>
|
||||
</Extensions>
|
||||
|
||||
<DaveTm>
|
||||
<dwLowDateTime>0</dwLowDateTime>
|
||||
<dwHighDateTime>0</dwHighDateTime>
|
||||
</DaveTm>
|
||||
|
||||
<Target>
|
||||
<TargetName>ble-sdk-xip</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<TargetOption>
|
||||
<CLKADS>12000000</CLKADS>
|
||||
<OPTTT>
|
||||
<gFlags>1</gFlags>
|
||||
<BeepAtEnd>1</BeepAtEnd>
|
||||
<RunSim>0</RunSim>
|
||||
<RunTarget>1</RunTarget>
|
||||
<RunAbUc>0</RunAbUc>
|
||||
</OPTTT>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<FlashByte>65535</FlashByte>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
</OPTHX>
|
||||
<OPTLEX>
|
||||
<PageWidth>79</PageWidth>
|
||||
<PageLength>66</PageLength>
|
||||
<TabStop>8</TabStop>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
</OPTLEX>
|
||||
<ListingPage>
|
||||
<CreateCListing>1</CreateCListing>
|
||||
<CreateAListing>1</CreateAListing>
|
||||
<CreateLListing>1</CreateLListing>
|
||||
<CreateIListing>0</CreateIListing>
|
||||
<AsmCond>1</AsmCond>
|
||||
<AsmSymb>1</AsmSymb>
|
||||
<AsmXref>0</AsmXref>
|
||||
<CCond>1</CCond>
|
||||
<CCode>0</CCode>
|
||||
<CListInc>0</CListInc>
|
||||
<CSymb>0</CSymb>
|
||||
<LinkerCodeListing>0</LinkerCodeListing>
|
||||
</ListingPage>
|
||||
<OPTXL>
|
||||
<LMap>1</LMap>
|
||||
<LComments>1</LComments>
|
||||
<LGenerateSymbols>1</LGenerateSymbols>
|
||||
<LLibSym>1</LLibSym>
|
||||
<LLines>1</LLines>
|
||||
<LLocSym>1</LLocSym>
|
||||
<LPubSym>1</LPubSym>
|
||||
<LXref>0</LXref>
|
||||
<LExpSel>0</LExpSel>
|
||||
</OPTXL>
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>7</CpuCode>
|
||||
<DebugOpt>
|
||||
<uSim>0</uSim>
|
||||
<uTrg>1</uTrg>
|
||||
<sLdApp>1</sLdApp>
|
||||
<sGomain>1</sGomain>
|
||||
<sRbreak>1</sRbreak>
|
||||
<sRwatch>1</sRwatch>
|
||||
<sRmem>1</sRmem>
|
||||
<sRfunc>1</sRfunc>
|
||||
<sRbox>1</sRbox>
|
||||
<tLdApp>1</tLdApp>
|
||||
<tGomain>1</tGomain>
|
||||
<tRbreak>1</tRbreak>
|
||||
<tRwatch>1</tRwatch>
|
||||
<tRmem>1</tRmem>
|
||||
<tRfunc>0</tRfunc>
|
||||
<tRbox>1</tRbox>
|
||||
<tRtrace>1</tRtrace>
|
||||
<sRSysVw>1</sRSysVw>
|
||||
<tRSysVw>1</tRSysVw>
|
||||
<sRunDeb>0</sRunDeb>
|
||||
<sLrtime>0</sLrtime>
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>4</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile></sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile>..\..\..\driver\adc\mdk\Linker\XIPInitialization.ini</tIfile>
|
||||
<pMon>Segger\JL2CM3.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U4294967295 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BB11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD10000000 -FC1000 -FN1 -FF0XIP_SPI_FLASH_M0 -FS011001000 -FL020000</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>UL2CM3</Key>
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>0</periodic>
|
||||
<aLwin>0</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
<aPa>0</aPa>
|
||||
<viewmode>0</viewmode>
|
||||
<vrSel>0</vrSel>
|
||||
<aSym>0</aSym>
|
||||
<aTbox>0</aTbox>
|
||||
<AscS1>0</AscS1>
|
||||
<AscS2>0</AscS2>
|
||||
<AscS3>0</AscS3>
|
||||
<aSer3>0</aSer3>
|
||||
<eProf>0</eProf>
|
||||
<aLa>0</aLa>
|
||||
<aPa1>0</aPa1>
|
||||
<AscS4>0</AscS4>
|
||||
<aSer4>0</aSer4>
|
||||
<StkLoc>0</StkLoc>
|
||||
<TrcWin>0</TrcWin>
|
||||
<newCpu>0</newCpu>
|
||||
<uProt>0</uProt>
|
||||
</DebugFlag>
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<LntExFlags>0</LntExFlags>
|
||||
<pMisraName></pMisraName>
|
||||
<pszMrule></pszMrule>
|
||||
<pSingCmds></pSingCmds>
|
||||
<pMultCmds></pMultCmds>
|
||||
<pMisraNamep></pMisraNamep>
|
||||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
</TargetOption>
|
||||
</Target>
|
||||
|
||||
<Group>
|
||||
<GroupName>startup</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>1</FileNumber>
|
||||
<FileType>5</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cm0.h</PathWithFileName>
|
||||
<FilenameWithoutPath>core_cm0.h</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\startup_xinc.s</PathWithFileName>
|
||||
<FilenameWithoutPath>startup_xinc.s</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\system_xinc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>system_xinc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>application</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\app_task.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_task.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\usr_client.c</PathWithFileName>
|
||||
<FilenameWithoutPath>usr_client.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\sleep.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sleep.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\arch_main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>arch_main.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>3</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\rom_symdefs.o</PathWithFileName>
|
||||
<FilenameWithoutPath>rom_symdefs.o</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\app_sec.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_sec.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\usr_server.c</PathWithFileName>
|
||||
<FilenameWithoutPath>usr_server.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>modules_rf</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\ble\modules\rf\src\rf_extrc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>rf_extrc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>hal</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\ringbuffer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ringbuffer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_clock.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_clock.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_pwr.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_pwr.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_systick.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_systick.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_timer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_timer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_wdt.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_wdt.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_drv_fmc_spi.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>ble_api</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\ble\ip\ble\api\xc_gap_api.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_gap_api.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_client_api.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_gatt_client_api.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_server_api.c</PathWithFileName>
|
||||
<FilenameWithoutPath>xc_gatt_server_api.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>modules_nvds</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\ble\modules\nvds\src\nvds.c</PathWithFileName>
|
||||
<FilenameWithoutPath>nvds.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>lib</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>4</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\src\Xinc_ble_sdk_central.lib</PathWithFileName>
|
||||
<FilenameWithoutPath>Xinc_ble_sdk_central.lib</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>dut</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\component\ble\plf\refip\src\driver\uart\uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
||||
@@ -0,0 +1,661 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>ble-sdk-xip</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>ARMCM0</Device>
|
||||
<Vendor>ARM</Vendor>
|
||||
<PackID>ARM.CMSIS.5.7.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M0") CLOCK(12000000) ESEL ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:ARMCM0$Device\ARM\ARMCM0\Include\ARMCM0.h</RegisterFile>
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:ARMCM0$Device\ARM\SVD\ARMCM0.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
<ButtonStop>0</ButtonStop>
|
||||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>.\Objects\</OutputDirectory>
|
||||
<OutputName>Xinc_ble_sdk</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>0</CreateHexFile>
|
||||
<DebugInformation>1</DebugInformation>
|
||||
<BrowseInformation>1</BrowseInformation>
|
||||
<ListingPath>.\Listings\</ListingPath>
|
||||
<HexFormatSelection>1</HexFormatSelection>
|
||||
<Merge32K>0</Merge32K>
|
||||
<CreateBatchFile>0</CreateBatchFile>
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
<nStopU2X>0</nStopU2X>
|
||||
</BeforeCompile>
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
<nStopB2X>0</nStopB2X>
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>1</RunUserProg1>
|
||||
<RunUserProg2>1</RunUserProg2>
|
||||
<UserProg1Name>fromelf --bin --output=app.bin !L</UserProg1Name>
|
||||
<UserProg2Name>.\output_tool\xinchip_bootloader2.bat</UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
<SimDllName>SARMCM3.DLL</SimDllName>
|
||||
<SimDllArguments> </SimDllArguments>
|
||||
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
|
||||
<SimDlgDllArguments>-pCM0</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments> </TargetDllArguments>
|
||||
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM0</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
<HexSelection>1</HexSelection>
|
||||
<HexRangeLowAddress>0</HexRangeLowAddress>
|
||||
<HexRangeHighAddress>0</HexRangeHighAddress>
|
||||
<HexOffset>0</HexOffset>
|
||||
<Oh166RecLen>16</Oh166RecLen>
|
||||
</OPTHX>
|
||||
</DebugOption>
|
||||
<Utilities>
|
||||
<Flash1>
|
||||
<UseTargetDll>1</UseTargetDll>
|
||||
<UseExternalTool>0</UseExternalTool>
|
||||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
<ArmAdsMisc>
|
||||
<GenerateListings>0</GenerateListings>
|
||||
<asHll>1</asHll>
|
||||
<asAsm>1</asAsm>
|
||||
<asMacX>1</asMacX>
|
||||
<asSyms>1</asSyms>
|
||||
<asFals>1</asFals>
|
||||
<asDbgD>1</asDbgD>
|
||||
<asForm>1</asForm>
|
||||
<ldLst>0</ldLst>
|
||||
<ldmm>1</ldmm>
|
||||
<ldXref>1</ldXref>
|
||||
<BigEnd>0</BigEnd>
|
||||
<AdsALst>1</AdsALst>
|
||||
<AdsACrf>1</AdsACrf>
|
||||
<AdsANop>0</AdsANop>
|
||||
<AdsANot>0</AdsANot>
|
||||
<AdsLLst>1</AdsLLst>
|
||||
<AdsLmap>1</AdsLmap>
|
||||
<AdsLcgr>1</AdsLcgr>
|
||||
<AdsLsym>1</AdsLsym>
|
||||
<AdsLszi>1</AdsLszi>
|
||||
<AdsLtoi>1</AdsLtoi>
|
||||
<AdsLsun>1</AdsLsun>
|
||||
<AdsLven>1</AdsLven>
|
||||
<AdsLsxf>1</AdsLsxf>
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M0"</AdsCpuType>
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
<hadIROM>1</hadIROM>
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>0</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>0</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
<useUlib>0</useUlib>
|
||||
<EndSel>1</EndSel>
|
||||
<uLtcg>0</uLtcg>
|
||||
<nSecure>0</nSecure>
|
||||
<RoSelD>3</RoSelD>
|
||||
<RwSelD>3</RwSelD>
|
||||
<CodeSel>0</CodeSel>
|
||||
<OptFeed>0</OptFeed>
|
||||
<NoZi1>0</NoZi1>
|
||||
<NoZi2>0</NoZi2>
|
||||
<NoZi3>0</NoZi3>
|
||||
<NoZi4>0</NoZi4>
|
||||
<NoZi5>0</NoZi5>
|
||||
<Ro1Chk>0</Ro1Chk>
|
||||
<Ro2Chk>0</Ro2Chk>
|
||||
<Ro3Chk>0</Ro3Chk>
|
||||
<Ir1Chk>0</Ir1Chk>
|
||||
<Ir2Chk>0</Ir2Chk>
|
||||
<Ra1Chk>0</Ra1Chk>
|
||||
<Ra2Chk>0</Ra2Chk>
|
||||
<Ra3Chk>0</Ra3Chk>
|
||||
<Im1Chk>0</Im1Chk>
|
||||
<Im2Chk>0</Im2Chk>
|
||||
<OnChipMemories>
|
||||
<Ocm1>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm1>
|
||||
<Ocm2>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm2>
|
||||
<Ocm3>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm3>
|
||||
<Ocm4>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm4>
|
||||
<Ocm5>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm5>
|
||||
<Ocm6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</Ocm6>
|
||||
<IRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x20000</Size>
|
||||
</IRAM>
|
||||
<IROM>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
</IROM>
|
||||
<XRAM>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</XRAM>
|
||||
<OCR_RVCT1>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT1>
|
||||
<OCR_RVCT2>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT2>
|
||||
<OCR_RVCT3>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT3>
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x40000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT5>
|
||||
<OCR_RVCT6>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT6>
|
||||
<OCR_RVCT7>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT7>
|
||||
<OCR_RVCT8>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT8>
|
||||
<OCR_RVCT9>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x20000000</StartAddress>
|
||||
<Size>0x20000</Size>
|
||||
</OCR_RVCT9>
|
||||
<OCR_RVCT10>
|
||||
<Type>0</Type>
|
||||
<StartAddress>0x0</StartAddress>
|
||||
<Size>0x0</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>4</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
<Strict>0</Strict>
|
||||
<EnumInt>0</EnumInt>
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>1</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>3</v6Lang>
|
||||
<v6LangP>3</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls>--gnu --diag_suppress=66 --feedback fb.txt</MiscControls>
|
||||
<Define>SDK_VERSION="4b62ec53" RC_32K=1 XC65XX CFG_BLE CFG_EMB CFG_STATIC USE_XIP=0 HCI_TEST_NO_IP=0 CFG_ACT=8 CFG_CON=6 CFG_RAL=1 CFG_HOST CFG_APP CFG_APP_PRF CFG_RF_EXTRC CFG_AES_RPA CFG_ALLROLES CFG_GATT_CLI USE_XIP=1 DEBUG_ENABLE ROM_ENV_ENABLE=0 CODE_USE_XIP CFG_PRF_BASS USE_ROM_FLASH=1 CFG_SCAN_PERFORMANCE CFG_MIN_STACK CONFIG_BT_WAKEUP_VIA_GPIO=1 CONFIG_HFCLK_IS_OSC32M_PLL_32M=1 SCATTER_LOAD_RAM_EM=1</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\..\..\..\component\ble\Include;..\app\api;..\..\..\..\..\component\ble\modules\aes\api;..\..\..\..\..\component\ble\modules\aes\src;..\..\..\..\..\component\ble\modules\common\api;..\..\..\..\..\component\ble\modules\common\src;..\..\..\..\..\component\ble\modules\ecc_p256\api;..\..\..\..\..\component\ble\modules\ecc_p256\src;..\..\..\..\..\component\ble\modules\h4tl\api;..\..\..\..\..\component\ble\modules\h4tl\src;..\..\..\..\..\component\ble\modules\ke\api;..\..\..\..\..\component\ble\modules\ke\src;..\..\..\..\..\component\ble\modules\nvds\api;..\..\..\..\..\component\ble\modules\nvds\src;..\..\..\..\..\component\ble\modules\rf\api;..\..\..\..\..\component\ble\modules\rf\src;..\..\..\..\..\component\ble\modules\rwip\api;..\..\..\..\..\component\ble\modules\rwip\src;..\..\..\..\..\component\ble\ip\ahi\api;..\..\..\..\..\component\ble\ip\ahi\src;..\..\..\..\..\component\ble\ip\ble\gaf\api;..\..\..\..\..\component\ble\ip\ble\gaf\inc;..\..\..\..\..\component\ble\ip\ble\gaf\src;..\..\..\..\..\component\ble\ip\ble\gaf\src\acc;..\..\..\..\..\component\ble\ip\ble\gaf\src\al;..\..\..\..\..\component\ble\ip\ble\gaf\src\arc;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\bc;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\capa;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\codec;..\..\..\..\..\component\ble\ip\ble\gaf\src\bap\uc;..\..\..\..\..\component\ble\ip\ble\gaf\src\iap;..\..\..\..\..\component\ble\ip\ble\hl\api;..\..\..\..\..\component\ble\ip\ble\hl\inc;..\..\..\..\..\component\ble\ip\ble\hl\src;..\..\..\..\..\component\ble\ip\ble\hl\src\gap;..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapc;..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapm;..\..\..\..\..\component\ble\ip\ble\hl\src\gatt;..\..\..\..\..\component\ble\ip\ble\hl\src\inc;..\..\..\..\..\component\ble\ip\ble\hl\src\l2cap;..\..\..\..\..\component\ble\ip\ble\ll\api;..\..\..\..\..\component\ble\ip\ble\ll\src;..\..\..\..\..\component\ble\ip\ble\ll\src\co;..\..\..\..\..\component\ble\ip\ble\ll\src\llc;..\..\..\..\..\component\ble\ip\ble\ll\src\lld;..\..\..\..\..\component\ble\ip\ble\ll\src\lli;..\..\..\..\..\component\ble\ip\ble\ll\src\llm;..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\api;..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\src;..\..\..\..\..\component\ble\ip\em\api;..\..\..\..\..\component\ble\ip\em\src;..\..\..\..\..\component\ble\ip\hci\api;..\..\..\..\..\component\ble\ip\hci\src;..\..\..\..\..\component\ble\ip\sch\api;..\..\..\..\..\component\ble\ip\sch\src;..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw;..\app\api;..\app\src;..\..\..\..\..\component\ble\plf\refip\src\arch;..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm;..\..\..\..\..\component\ble\plf\refip\src\arch\ll\gnuarm;..\..\..\..\..\component\ble\plf\refip\src\driver\reg;..\..\..\..\..\component\ble\plf\refip\src\arch\boot\rvds;..\..\..\..\..\component\ble\plf\refip\src\driver\syscntl;..\..\..\..\..\component\ble\plf\refip\src\driver\emi;..\..\..\..\..\component\ble\plf\refip\src\driver\intc;..\..\..\..\..\component\ble\plf\refip\src\driver\uart;..\..\..\..\..\component\ble\plf\refip\src\driver\flash;..\..\..\..\..\component\ble\plf\refip\src\driver\led;..\..\..\..\..\component\ble\modules\dbg\api;..\..\..\..\..\component\ble\plf\refip\src\driver\uart;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device;..\..\..\..\..\component\xc6xx_drivers\Drivers\Startup;..\..\..\..\..\component\xc6xx_drivers\Drivers\Startup\xc65xx;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver\Bitfields;..\..\..\..\..\component\xc6xx_drivers\Drivers\Periph_HAL_Driver\Ringbuffer;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\PWR;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\TIMER;..\..\..\..\..\component\ble\ip\ble\api;..\..\..\..\..\component\xc6xx_drivers\Drivers\test_case\TIMER;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS;..\..\..\..\..\component\xc6xx_drivers\Drivers;..\..\..\..\..\component\ble\ip\ble\ll_rom_port;..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver;..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register;..\..\..\..\..\component\ble\modules\flash</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>1</interw>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<thumb>0</thumb>
|
||||
<SplitLS>0</SplitLS>
|
||||
<SwStkChk>0</SwStkChk>
|
||||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<ClangAsOpt>1</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>0</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x00000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>.\Linker\cpu_xip.scat</ScatterFile>
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc>--feedback fb.txt --info=stack --callgraph</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
<Groups>
|
||||
<Group>
|
||||
<GroupName>startup</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>core_cm0.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cm0.h</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>startup_xinc.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\app\src\startup_xinc.s</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_xinc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\system_xinc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>application</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>app_task.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\app_task.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usr_client.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\usr_client.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sleep.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\sleep.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>arch_main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\arch_main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>rom_symdefs.o</FileName>
|
||||
<FileType>3</FileType>
|
||||
<FilePath>..\app\src\rom_symdefs.o</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>app_sec.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\app_sec.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usr_server.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\app\src\usr_server.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>modules_rf</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>rf_extrc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\ble\modules\rf\src\rf_extrc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>hal</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ringbuffer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\ringbuffer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_clock.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_clock.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_systick.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_systick.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_timer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_wdt.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_drv_fmc_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>ble_api</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>xc_gap_api.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\ble\ip\ble\api\xc_gap_api.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_gatt_client_api.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_client_api.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>xc_gatt_server_api.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_server_api.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>modules_nvds</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>nvds.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\ble\modules\nvds\src\nvds.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>lib</GroupName>
|
||||
<GroupOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>0</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<GroupArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>2</interw>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<thumb>2</thumb>
|
||||
<SplitLS>2</SplitLS>
|
||||
<SwStkChk>2</SwStkChk>
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<ClangAsOpt>0</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
</GroupArmAds>
|
||||
</GroupOption>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>Xinc_ble_sdk_central.lib</FileName>
|
||||
<FileType>4</FileType>
|
||||
<FilePath>..\app\src\Xinc_ble_sdk_central.lib</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>dut</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\component\ble\plf\refip\src\driver\uart\uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis/>
|
||||
<components/>
|
||||
<files>
|
||||
<file attr="config" category="linkerScript" condition="ARMCC5" name="Device\ARM\ARMCM0\Source\ARM\ARMCM0_ac5.sct" version="1.0.0">
|
||||
<instance index="0" removed="1">RTE\Device\ARMCM0\ARMCM0_ac5.sct</instance>
|
||||
<component Cclass="Device" Cgroup="Startup" Cvariant="C Startup" Cvendor="ARM" Cversion="2.0.3" condition="ARMCM0 CMSIS" isDefaultVariant="1"/>
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
|
||||
<targetInfos/>
|
||||
</file>
|
||||
<file attr="config" category="sourceC" name="Device\ARM\ARMCM0\Source\startup_ARMCM0.c" version="2.0.3">
|
||||
<instance index="0" removed="1">RTE\Device\ARMCM0\startup_ARMCM0.c</instance>
|
||||
<component Cclass="Device" Cgroup="Startup" Cvariant="C Startup" Cvendor="ARM" Cversion="2.0.3" condition="ARMCM0 CMSIS" isDefaultVariant="1"/>
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
|
||||
<targetInfos/>
|
||||
</file>
|
||||
<file attr="config" category="sourceC" name="Device\ARM\ARMCM0\Source\system_ARMCM0.c" version="1.0.0">
|
||||
<instance index="0" removed="1">RTE\Device\ARMCM0\system_ARMCM0.c</instance>
|
||||
<component Cclass="Device" Cgroup="Startup" Cvariant="C Startup" Cvendor="ARM" Cversion="2.0.3" condition="ARMCM0 CMSIS" isDefaultVariant="1"/>
|
||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
|
||||
<targetInfos/>
|
||||
</file>
|
||||
</files>
|
||||
</RTE>
|
||||
|
||||
<LayerInfo>
|
||||
<Layers>
|
||||
<Layer>
|
||||
<LayName><Project Info></LayName>
|
||||
<LayTarg>0</LayTarg>
|
||||
<LayPrjMark>1</LayPrjMark>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</LayerInfo>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,175 @@
|
||||
;#<FEEDBACK># ARM Linker, 5060960: Last Updated: Thu Dec 18 14:11:00 2025
|
||||
;VERSION 0.2
|
||||
;FILE app_sec.o
|
||||
__asm___9_app_sec_c_9f4819f3____REV16 <= USED 0
|
||||
__asm___9_app_sec_c_9f4819f3____REVSH <= USED 0
|
||||
app_sec_get_bond_status <= USED 0
|
||||
app_sec_init <= USED 0
|
||||
;FILE app_task.o
|
||||
__asm___10_app_task_c_conn_dev____REV16 <= USED 0
|
||||
__asm___10_app_task_c_conn_dev____REVSH <= USED 0
|
||||
app_set_dev_name <= USED 0
|
||||
app_set_scan_rsp_data <= USED 0
|
||||
app_stop_advertising <= USED 0
|
||||
app_stop_init <= USED 0
|
||||
app_stop_scanning <= USED 0
|
||||
;FILE arch_main.o
|
||||
__asm___11_arch_main_c_fd31ea27____REV16 <= USED 0
|
||||
__asm___11_arch_main_c_fd31ea27____REVSH <= USED 0
|
||||
system_lightsleep_cfg <= USED 0
|
||||
;FILE rf_extrc.o
|
||||
__asm___10_rf_extrc_c_8fc8a65a____REV16 <= USED 0
|
||||
__asm___10_rf_extrc_c_8fc8a65a____REVSH <= USED 0
|
||||
auto_agc_init <= USED 0
|
||||
rf_test_pin_init <= USED 0
|
||||
rf_xtal_cal_set <= USED 0
|
||||
;FILE ringbuffer.o
|
||||
ring_buffer_create <= USED 0
|
||||
ring_buffer_dequeue <= USED 0
|
||||
ring_buffer_dequeue_arr <= USED 0
|
||||
ring_buffer_is_empty <= USED 0
|
||||
ring_buffer_is_full <= USED 0
|
||||
ring_buffer_num_items <= USED 0
|
||||
ring_buffer_peek <= USED 0
|
||||
ring_buffer_queue <= USED 0
|
||||
ring_buffer_queue_arr <= USED 0
|
||||
;FILE sleep.o
|
||||
__asm___7_sleep_c_efd8dd31____REV16 <= USED 0
|
||||
__asm___7_sleep_c_efd8dd31____REVSH <= USED 0
|
||||
;FILE startup_xinc.o
|
||||
;FILE system_xinc.o
|
||||
__asm___13_system_xinc_c_bf2b7dca____REV16 <= USED 0
|
||||
__asm___13_system_xinc_c_bf2b7dca____REVSH <= USED 0
|
||||
_ttywrch <= USED 0
|
||||
;FILE uart.o
|
||||
__asm___6_uart_c____REV16 <= USED 0
|
||||
__asm___6_uart_c____REVSH <= USED 0
|
||||
;FILE usr_client.o
|
||||
__asm___12_usr_client_c_3096fd6e____REV16 <= USED 0
|
||||
__asm___12_usr_client_c_3096fd6e____REVSH <= USED 0
|
||||
get_cli_user_ild <= USED 0
|
||||
send_data <= USED 0
|
||||
;FILE usr_server.o
|
||||
__asm___12_usr_server_c_16ab253a____REV16 <= USED 0
|
||||
__asm___12_usr_server_c_16ab253a____REVSH <= USED 0
|
||||
;FILE xc_drv_clock.o
|
||||
__asm___14_xc_drv_clock_c_54f5dcab____REV16 <= USED 0
|
||||
__asm___14_xc_drv_clock_c_54f5dcab____REVSH <= USED 0
|
||||
xc_clock_hfclk_src_get <= USED 0
|
||||
xc_clock_lfclk_in_get <= USED 0
|
||||
xc_clock_lfclk_src_get <= USED 0
|
||||
xc_clock_set_osc32m <= USED 0
|
||||
xc_clock_set_osc32m_bbpll_16m <= USED 0
|
||||
xc_clock_set_osc32m_bbpll_24m <= USED 0
|
||||
xc_clock_set_osc32m_bbpll_32m <= USED 0
|
||||
xc_clock_set_osc32m_bbpll_48m <= USED 0
|
||||
xc_clock_set_osc32m_bbpll_64m <= USED 0
|
||||
xc_clock_set_osc32m_bbpll_96m <= USED 0
|
||||
xc_clock_set_osc32m_div_16m <= USED 0
|
||||
xc_clock_set_rc16m <= USED 0
|
||||
xc_clock_set_rc16m_bbpll_32m <= USED 0
|
||||
xc_clock_set_rc16m_bbpll_48m <= USED 0
|
||||
xc_clock_set_rc16m_bbpll_64m <= USED 0
|
||||
xc_clock_set_rc16m_bbpll_96m <= USED 0
|
||||
xc_system_param_check <= USED 0
|
||||
xc_system_param_check_rf24g <= USED 0
|
||||
;FILE xc_drv_fmc_spi.o
|
||||
__asm___16_xc_drv_fmc_spi_c_0d19a3b4____REV16 <= USED 0
|
||||
__asm___16_xc_drv_fmc_spi_c_0d19a3b4____REVSH <= USED 0
|
||||
xc_adc_2v4_calibrate_read <= USED 0
|
||||
xc_fmc_spi_flash_erase_page <= USED 0
|
||||
xc_fmc_spi_flash_erase_sector <= USED 0
|
||||
xc_fmc_spi_flash_power_down <= USED 0
|
||||
xc_fmc_spi_flash_write <= USED 0
|
||||
xc_fmc_spi_flash_write_page <= USED 0
|
||||
;FILE xc_drv_gpio.o
|
||||
__asm___13_xc_drv_gpio_c_f617b6af____REV16 <= USED 0
|
||||
__asm___13_xc_drv_gpio_c_f617b6af____REVSH <= USED 0
|
||||
xc_gpio_read_pin <= USED 0
|
||||
xc_gpio_toggle_pin <= USED 0
|
||||
xc_gpio_write_pin <= USED 0
|
||||
;FILE xc_drv_pwr.o
|
||||
__asm___12_xc_drv_pwr_c_ed5c409a____REV16 <= USED 0
|
||||
__asm___12_xc_drv_pwr_c_ed5c409a____REVSH <= USED 0
|
||||
xc_adc_powerdown <= USED 0
|
||||
xc_adc_wakeup <= USED 0
|
||||
xc_deep_sleep <= USED 0
|
||||
xc_pwr_ao_timer_pclk32k_set <= USED 0
|
||||
xc_pwr_ao_timer_pclk32m_Set <= USED 0
|
||||
xc_pwr_ble_sleep_enter <= USED 0
|
||||
xc_pwr_cpu_sleep_enter <= USED 0
|
||||
xc_pwr_dcdc_close <= USED 0
|
||||
xc_pwr_dcdc_init <= USED 0
|
||||
xc_pwr_dcdc_open <= USED 0
|
||||
xc_pwr_gpio_lightsleep_wake_config <= USED 0
|
||||
xc_pwr_gpio_sleep_config <= USED 0
|
||||
xc_pwr_pwrkey_deepsleep_wake_config <= USED 0
|
||||
xc_pwr_pwrkey_init <= USED 0
|
||||
xc_pwr_pwrkey_toggle_pin <= USED 0
|
||||
xc_pwr_pwrkey_write_pin <= USED 0
|
||||
xc_pwr_sleep_init <= USED 0
|
||||
xc_sleep <= USED 0
|
||||
;FILE xc_drv_systick.o
|
||||
__asm___16_xc_drv_systick_c_b672aa62____REV16 <= USED 0
|
||||
__asm___16_xc_drv_systick_c_b672aa62____REVSH <= USED 0
|
||||
delay_ms <= USED 0
|
||||
;FILE xc_drv_timer.o
|
||||
__asm___14_xc_drv_timer_c_a67257da____REV16 <= USED 0
|
||||
__asm___14_xc_drv_timer_c_a67257da____REVSH <= USED 0
|
||||
xc_timer_init <= USED 0
|
||||
xc_timer_set_value <= USED 0
|
||||
xc_timer_start <= USED 0
|
||||
xc_timer_stop <= USED 0
|
||||
;FILE xc_drv_uart.o
|
||||
__asm___13_xc_drv_uart_c_c8f8d781____REV16 <= USED 0
|
||||
__asm___13_xc_drv_uart_c_c8f8d781____REVSH <= USED 0
|
||||
xc_uart_ctl_block_reset <= USED 0
|
||||
xc_uart_disable_rx_it <= USED 0
|
||||
xc_uart_enable_rx_it <= USED 0
|
||||
xc_uart_register_receive_cb <= USED 0
|
||||
xc_uart_send_byte <= USED 0
|
||||
xc_uart_send_data <= USED 0
|
||||
;FILE xc_drv_wdt.o
|
||||
__asm___12_xc_drv_wdt_c_acf1ef54____REV16 <= USED 0
|
||||
__asm___12_xc_drv_wdt_c_acf1ef54____REVSH <= USED 0
|
||||
xc_ext32k_wdt_init <= USED 0
|
||||
xc_ext32k_wdt_start <= USED 0
|
||||
xc_wdt_stop <= USED 0
|
||||
;FILE xc_gap_api.o
|
||||
__asm___12_xc_gap_api_c_76ebb078____REV16 <= USED 0
|
||||
__asm___12_xc_gap_api_c_76ebb078____REVSH <= USED 0
|
||||
xc_ble_activity_delete <= USED 0
|
||||
xc_ble_activity_stop <= USED 0
|
||||
xc_ble_bond <= USED 0
|
||||
xc_ble_bond_cfm <= USED 0
|
||||
xc_ble_disconnect <= USED 0
|
||||
xc_ble_encrypt <= USED 0
|
||||
xc_ble_encrypt_cfm <= USED 0
|
||||
xc_ble_gen_random_addr <= USED 0
|
||||
xc_ble_gen_random_nb <= USED 0
|
||||
xc_ble_get_dev_info <= USED 0
|
||||
xc_ble_get_ral_addr <= USED 0
|
||||
xc_ble_req_security <= USED 0
|
||||
xc_ble_resolve_addr <= USED 0
|
||||
xc_ble_set_channel_map <= USED 0
|
||||
xc_ble_set_pkt_size <= USED 0
|
||||
xc_ble_set_ral_list <= USED 0
|
||||
xc_ble_set_rx_pkt_size <= USED 0
|
||||
xc_ble_set_scan_rsp_data <= USED 0
|
||||
xc_ble_set_white_list <= USED 0
|
||||
xc_ble_update_param <= USED 0
|
||||
;FILE xc_gatt_client_api.o
|
||||
__asm___20_xc_gatt_client_api_c_d2fbc8a0____REV16 <= USED 0
|
||||
__asm___20_xc_gatt_client_api_c_d2fbc8a0____REVSH <= USED 0
|
||||
xc_ble_gatt_cli_discover_cancel <= USED 0
|
||||
xc_ble_gatt_cli_discover_char <= USED 0
|
||||
xc_ble_gatt_cli_discover_desc <= USED 0
|
||||
xc_ble_gatt_cli_discover_svc <= USED 0
|
||||
xc_ble_gatt_cli_mtu_exch <= USED 0
|
||||
xc_ble_gatt_cli_read <= USED 0
|
||||
xc_ble_gatt_cli_read_by_uuid <= USED 0
|
||||
;FILE xc_gatt_server_api.o
|
||||
__asm___20_xc_gatt_server_api_c_f4c610f4____REV16 <= USED 0
|
||||
__asm___20_xc_gatt_server_api_c_f4c610f4____REVSH <= USED 0
|
||||
xc_ble_gatt_service16_add <= USED 0
|
||||
xc_ble_gatt_srv_indicate <= USED 0
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
cd ./output_tool
|
||||
copy ..\app.bin .\
|
||||
xinchip_bootloader2_tool.exe boot2 ^
|
||||
stack.bin 0x11002000 0 ^
|
||||
app.bin 0x11014000 1 ^
|
||||
ble_Central.bin 1
|
||||
del ..\app.bin
|
||||
copy .\ble_Central.bin ..\
|
||||
+417
-328
@@ -1,328 +1,417 @@
|
||||
#!/usr/bin/env python
|
||||
#-*- coding:UTF-8 -*-
|
||||
import socket
|
||||
from select import select
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import json
|
||||
import struct
|
||||
import binascii
|
||||
import time
|
||||
import re
|
||||
import fileinput
|
||||
import io
|
||||
import logging
|
||||
|
||||
replace = {
|
||||
"co_default_bdaddr":"0x0",
|
||||
"ke_msg_alloc":"0x0",
|
||||
"ke_msg_send":"0x0",
|
||||
"ke_msg_send_basic":"0x0",
|
||||
"ke_state_set":"0x0",
|
||||
"ke_task_create":"0x0",
|
||||
"ke_state_get":"0x0",
|
||||
"ke_msg_discard":"0x0",
|
||||
"ke_msg_forward":"0x0",
|
||||
"ke_msg_in_queue":"0x0",
|
||||
"ke_msg_src_id_get":"0x0",
|
||||
"ke_free":"0x0",
|
||||
"ke_msg_free":"0x0",
|
||||
"ke_check_malloc":"0x0",
|
||||
"rwip_init":"0x0",
|
||||
"rwip_schedule":"0x0",
|
||||
"rwip_rf":"0x0",
|
||||
"BLE_Handler":"0x0",
|
||||
"co_buf_alloc":"0x0",
|
||||
"co_buf_copy_data_from_mem":"0x0",
|
||||
"co_buf_release":"0x0",
|
||||
"co_djob_prepare":"0x0",
|
||||
"co_djob_reg":"0x0",
|
||||
"co_djob_unreg":"0x0",
|
||||
"co_list_extract":"0x0",
|
||||
"co_list_extract_after":"0x0",
|
||||
"co_list_pop_front":"0x0",
|
||||
"co_list_push_back":"0x0",
|
||||
"co_list_push_front":"0x0",
|
||||
"co_time_get":"0x0",
|
||||
"co_time_timer_init":"0x0",
|
||||
"co_time_timer_set":"0x0",
|
||||
"co_time_timer_stop":"0x0",
|
||||
"aes_c1":"0x0",
|
||||
"aes_encrypt":"0x0",
|
||||
"aes_f4":"0x0",
|
||||
"aes_f5":"0x0",
|
||||
"aes_f6":"0x0",
|
||||
"aes_g2":"0x0",
|
||||
"aes_rand":"0x0",
|
||||
"aes_cmac":"0x0",
|
||||
"co_buf_head_release":"0x0",
|
||||
"co_buf_head_reserve":"0x0",
|
||||
"co_util_pack":"0x0",
|
||||
"co_util_unpack":"0x0",
|
||||
"rwip_reset":"0x0",
|
||||
"aes_rpa_resolve":"0x0",
|
||||
"co_buf_reuse":"0x0",
|
||||
"co_buf_size":"0x0",
|
||||
"co_buf_copy":"0x0",
|
||||
"co_buf_duplicate":"0x0",
|
||||
"co_buf_tail_release":"0x0",
|
||||
"co_list_init":"0x0",
|
||||
"ble_util_buf_rx_free":"0x0",
|
||||
"ble_util_buf_acl_tx_alloc":"0x0",
|
||||
"co_buf_cb_free_set":"0x0",
|
||||
"ke_malloc":"0x0",
|
||||
"co_list_insert_after":"0x0",
|
||||
"ke_timer_active":"0x0",
|
||||
"ke_timer_clear":"0x0",
|
||||
"ke_timer_set":"0x0",
|
||||
"co_buf_acquire":"0x0",
|
||||
"co_buf_tail_reserve":"0x0",
|
||||
"co_buf_copy_data_to_mem":"0x0",
|
||||
"co_list_insert_before":"0x0",
|
||||
"rom_env":"0x0",
|
||||
"rwip_param":"0x0",
|
||||
"one_bits":"0x0",
|
||||
"hci_rd_rem_ver_info_cmd_handler":"0x0",
|
||||
"hci_le_con_upd_cmd_handler":"0x0",
|
||||
"hci_le_rd_chnl_map_cmd_handler":"0x0",
|
||||
"hci_le_rd_rem_feats_cmd_handler":"0x0",
|
||||
"hci_le_en_enc_cmd_handler":"0x0",
|
||||
"hci_le_ltk_req_reply_cmd_handler":"0x0",
|
||||
"hci_le_ltk_req_neg_reply_cmd_handler":"0x0",
|
||||
"hci_le_rem_con_param_req_reply_cmd_handler":"0x0",
|
||||
"hci_le_rem_con_param_req_neg_reply_cmd_handler":"0x0",
|
||||
"hci_le_set_data_len_cmd_handler":"0x0",
|
||||
"hci_vs_set_pref_slave_latency_cmd_handler":"0x0",
|
||||
"hci_vs_set_pref_slave_evt_dur_cmd_handler":"0x0",
|
||||
"hci_vs_set_max_rx_size_and_time_cmd_handler":"0x0",
|
||||
"hci_rd_rssi_cmd_handler":"0x0",
|
||||
"llm_ch_map_update_ind_handler":"0x0",
|
||||
"llc_loc_llcp_rsp_to_handler":"0x0",
|
||||
"llc_rem_llcp_rsp_to_handler":"0x0",
|
||||
"llc_encrypt_ind_handler":"0x0",
|
||||
"llc_op_ver_exch_ind_handler":"0x0",
|
||||
"llc_op_feats_exch_ind_handler":"0x0",
|
||||
"llc_op_encrypt_ind_handler":"0x0",
|
||||
"llc_op_dl_upd_ind_handler":"0x0",
|
||||
"llc_op_con_upd_ind_handler":"0x0",
|
||||
"llc_op_ch_map_upd_ind_handler":"0x0",
|
||||
"lld_llcp_rx_ind_handler":"0x0",
|
||||
"lld_llcp_tx_cfm_handler":"0x0",
|
||||
"lld_acl_rx_ind_handler":"0x0",
|
||||
"lld_acl_tx_cfm_handler":"0x0",
|
||||
"lld_con_param_upd_cfm_handler":"0x0",
|
||||
"lld_ch_map_upd_cfm_handler":"0x0",
|
||||
"lld_con_offset_upd_ind_handler":"0x0",
|
||||
"hci_command_llc_handler":"0x0",
|
||||
"hci_acl_data_handler":"0x0",
|
||||
"ke_event_callback_set":"0x0",
|
||||
"ke_event_clear":"0x0",
|
||||
"ke_event_set":"0x0",
|
||||
"ble_util_nb_good_channels":"0x0",
|
||||
"ble_util_pkt_dur_in_us":"0x0",
|
||||
"co_bdaddr_compare":"0x0",
|
||||
"lld_ch_assess_data_get":"0x0",
|
||||
"lld_ch_map_set":"0x0",
|
||||
"lld_read_clock":"0x0",
|
||||
"lld_res_list_peer_update":"0x0",
|
||||
"lld_white_list_add":"0x0",
|
||||
"rwip_prevent_sleep_clear":"0x0",
|
||||
"rwip_prevent_sleep_set":"0x0",
|
||||
"sch_plan_rem":"0x0",
|
||||
"aes_rpa_gen":"0x0",
|
||||
"ble_util_buf_adv_tx_alloc":"0x0",
|
||||
"ble_util_buf_adv_tx_free":"0x0",
|
||||
"co_null_bdaddr":"0x0",
|
||||
"co_null_key":"0x0",
|
||||
"llc_con_move_cbk":"0x0",
|
||||
"llc_start":"0x0",
|
||||
"lld_adv_adv_data_update":"0x0",
|
||||
"lld_adv_rand_addr_update":"0x0",
|
||||
"lld_adv_restart":"0x0",
|
||||
"lld_adv_scan_rsp_data_update":"0x0",
|
||||
"lld_adv_start":"0x0",
|
||||
"lld_adv_stop":"0x0",
|
||||
"lld_white_list_rem":"0x0",
|
||||
"lld_init_rand_addr_update":"0x0",
|
||||
"lld_res_list_add":"0x0",
|
||||
"lld_res_list_clear":"0x0",
|
||||
"lld_res_list_local_rpa_get":"0x0",
|
||||
"lld_res_list_peer_rpa_get":"0x0",
|
||||
"lld_res_list_priv_mode_update":"0x0",
|
||||
"lld_res_list_rem":"0x0",
|
||||
"lld_scan_rand_addr_update":"0x0",
|
||||
"lld_init_start":"0x0",
|
||||
"lld_init_stop":"0x0",
|
||||
"sch_plan_req":"0x0",
|
||||
"sch_plan_set":"0x0",
|
||||
"co_rate_to_phy":"0x0",
|
||||
"lld_scan_params_update":"0x0",
|
||||
"lld_scan_start":"0x0",
|
||||
"lld_scan_stop":"0x0",
|
||||
"lld_rpa_renew":"0x0",
|
||||
"ke_mem_init":"0x0",
|
||||
"co_buf_init":"0x0",
|
||||
"rwip_sleep":"0x0",
|
||||
"em_ble_base_address_table_0":"0x0",
|
||||
"em_ble_base_address_table_1":"0x0",
|
||||
"em_ble_base_address_table_2":"0x0",
|
||||
"em_ble_base_address_table_3":"0x0",
|
||||
"em_ble_base_address_table_4":"0x0",
|
||||
"em_ble_base_address_table_5":"0x0",
|
||||
"em_ble_base_address_table_6":"0x0",
|
||||
"em_ble_base_address_table_7":"0x0",
|
||||
"em_ble_base_address_table_8":"0x0",
|
||||
"em_ble_base_address_table_9":"0x0",
|
||||
"em_ble_base_address_table_10":"0x0",
|
||||
"ble_util_buf_init_env":"0x0",
|
||||
"PATCH_FUN":"0x0",
|
||||
"lld_adv_env":"0x0",
|
||||
"sch_arb_remove":"0x0",
|
||||
"sch_slice_fg_remove":"0x0",
|
||||
"llc_env":"0x0",
|
||||
"llc_proc_err_ind":"0x0",
|
||||
"llc_stop":"0x0",
|
||||
"ll_channel_map_ind_handler":"0x0",
|
||||
"ll_connection_param_req_handler":"0x0",
|
||||
"ll_connection_param_rsp_handler":"0x0",
|
||||
"ll_connection_update_ind_handler":"0x0",
|
||||
"ll_enc_req_handler":"0x0",
|
||||
"ll_enc_rsp_handler":"0x0",
|
||||
"ll_feature_req_handler":"0x0",
|
||||
"ll_feature_rsp_handler":"0x0",
|
||||
"ll_length_req_handler":"0x0",
|
||||
"ll_length_rsp_handler":"0x0",
|
||||
"ll_min_used_channels_ind_handler":"0x0",
|
||||
"ll_pause_enc_req_handler":"0x0",
|
||||
"ll_pause_enc_rsp_handler":"0x0",
|
||||
"ll_reject_ext_ind_handler":"0x0",
|
||||
"ll_reject_ind_handler":"0x0",
|
||||
"ll_slave_feature_req_handler":"0x0",
|
||||
"ll_start_enc_req_handler":"0x0",
|
||||
"ll_start_enc_rsp_handler":"0x0",
|
||||
"ll_unknown_rsp_handler":"0x0",
|
||||
"ll_version_ind_handler":"0x0",
|
||||
"ble_util_buf_acl_tx_free":"0x0",
|
||||
"lld_rxdesc_check":"0x0",
|
||||
"lld_rxdesc_free":"0x0",
|
||||
"rwip_priority":"0x0",
|
||||
"sch_arb_insert":"0x0",
|
||||
"sch_prog_push":"0x0",
|
||||
"FMC_SPI_Flash_RDID":"0x0",
|
||||
"FMC_SPI_Flash_RUID":"0x0",
|
||||
"FMC_SPI_Flash_WakeUp":"0x0",
|
||||
"FMC_SPI_Init_Oprt":"0x0",
|
||||
"FMC_SPI_Flash_PowerDown":"0x0",
|
||||
"FMC_SPI_FlashRead":"0x0",
|
||||
"FMC_SPI_FlashWrite":"0x0",
|
||||
"FMC_SPI_Flash_Erase_Sector":"0x0",
|
||||
"FMC_SPI_Flash_PowerDown":"0x0",
|
||||
"FMC_SPI_Flash_WakeUp":"0x0",
|
||||
"llc_cleanup":"0x0",
|
||||
"llc_cmd_stat_send":"0x0",
|
||||
"llc_llcp_send":"0x0",
|
||||
"llc_llcp_state_set":"0x0",
|
||||
"llc_proc_get":"0x0",
|
||||
"llc_proc_id_get":"0x0",
|
||||
"llc_proc_init":"0x0",
|
||||
"llc_proc_reg":"0x0",
|
||||
"llc_proc_state_get":"0x0",
|
||||
"llc_proc_state_set":"0x0",
|
||||
"llc_proc_timer_pause_set":"0x0",
|
||||
"llc_proc_timer_set":"0x0",
|
||||
"llc_proc_unreg":"0x0",
|
||||
"lld_con_stop":"0x0",
|
||||
"lld_adv_evt_start_cbk":"0x0",
|
||||
"rwip_env":"0x0",
|
||||
"rwip_prog_delay":"0x0",
|
||||
"rwip_time_get":"0x0",
|
||||
"rwip_wakeup_end":"0x0",
|
||||
"sch_arb_env":"0x0",
|
||||
"lld_adv_frm_cbk":"0x0",
|
||||
"rwip_timer_alarm_handler":"0x0",
|
||||
"rwip_timer_arb_handler":"0x0",
|
||||
"rwip_timer_co_handler":"0x0",
|
||||
}
|
||||
|
||||
def traverse(f):
|
||||
fs = os.listdir(f)
|
||||
for f1 in fs:
|
||||
tmp_path = os.path.join(f, f1)
|
||||
if not os.path.isdir(tmp_path):
|
||||
if os.path.isfile(tmp_path):
|
||||
if isinstance(tmp_path, str):
|
||||
if tmp_path.endswith('rom_symdefs.o'):
|
||||
#print("ssss", tmp_path)
|
||||
logger.info(tmp_path)
|
||||
find_str(tmp_path)
|
||||
else:
|
||||
traverse(tmp_path)
|
||||
|
||||
def traverse_for_replace(f):
|
||||
fs = os.listdir(f)
|
||||
for f1 in fs:
|
||||
tmp_path = os.path.join(f, f1)
|
||||
if not os.path.isdir(tmp_path):
|
||||
if os.path.isfile(tmp_path):
|
||||
if isinstance(tmp_path, str):
|
||||
if tmp_path.endswith('rom_symdefs.o'):
|
||||
|
||||
logger.info(tmp_path)
|
||||
replace_str(tmp_path)
|
||||
|
||||
|
||||
def find_str(file):
|
||||
with io.open(file, 'r', encoding='utf-8') as fd:
|
||||
for line in fd:
|
||||
for key, value in replace.items():
|
||||
if re.search(key, line.strip()) != None and len(key)+13== len(line.strip()):
|
||||
#print(line)
|
||||
logger.info(line)
|
||||
replace[key] = line
|
||||
fd.close()
|
||||
logger.info(str(replace))
|
||||
|
||||
def replace_str(file):
|
||||
header = "#<SYMDEFS># ARM Linker, 5060750: Last Updated: Tue Sep 05 15:30:26 2023\n"
|
||||
with io.open(r'tmp.c', 'w', encoding='utf-8') as fw:
|
||||
fw.write(header)
|
||||
for key, value in replace.items():
|
||||
#print(len(key)+13, len(line.strip()), key, line.strip())
|
||||
replace_flag = False
|
||||
fw.write(value)
|
||||
logger.info(value)
|
||||
#print("line2", value, key)
|
||||
print("line2", value)
|
||||
fw.close()
|
||||
|
||||
with io.open(file, 'w', encoding='utf-8') as fw:
|
||||
with io.open(r'tmp.c', 'r', encoding='utf-8') as file:
|
||||
for line in file:
|
||||
fw.write(line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if(os.path.exists("log.txt")):
|
||||
os.remove("log.txt")
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(level = logging.INFO)
|
||||
handler = logging.FileHandler("log.txt")
|
||||
handler.setLevel(logging.INFO)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
|
||||
traverse("./Project/example/ble/rom_stack/mdk/")
|
||||
#print(replace)
|
||||
traverse_for_replace("./Project/example/ble/ble_peripheral/app/src")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#!/usr/bin/env python
|
||||
#-*- coding:UTF-8 -*-
|
||||
import socket
|
||||
from select import select
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import json
|
||||
import struct
|
||||
import binascii
|
||||
import time
|
||||
import re
|
||||
import fileinput
|
||||
import io
|
||||
import logging
|
||||
|
||||
replace = {
|
||||
"co_default_bdaddr":"0x0",
|
||||
"ke_msg_alloc":"0x0",
|
||||
"ke_msg_send":"0x0",
|
||||
"ke_msg_send_basic":"0x0",
|
||||
"ke_state_set":"0x0",
|
||||
"ke_task_create":"0x0",
|
||||
"ke_state_get":"0x0",
|
||||
"ke_msg_discard":"0x0",
|
||||
"ke_msg_forward":"0x0",
|
||||
"ke_msg_in_queue":"0x0",
|
||||
"ke_msg_src_id_get":"0x0",
|
||||
"ke_free":"0x0",
|
||||
"ke_msg_free":"0x0",
|
||||
"ke_check_malloc":"0x0",
|
||||
"rwip_init":"0x0",
|
||||
"rwip_schedule":"0x0",
|
||||
"rwip_rf":"0x0",
|
||||
"BLE_Handler":"0x0",
|
||||
"co_buf_alloc":"0x0",
|
||||
"co_buf_copy_data_from_mem":"0x0",
|
||||
"co_buf_release":"0x0",
|
||||
"co_djob_prepare":"0x0",
|
||||
"co_djob_reg":"0x0",
|
||||
"co_djob_unreg":"0x0",
|
||||
"co_list_extract":"0x0",
|
||||
"co_list_extract_after":"0x0",
|
||||
"co_list_pop_front":"0x0",
|
||||
"co_list_push_back":"0x0",
|
||||
"co_list_push_front":"0x0",
|
||||
"co_time_get":"0x0",
|
||||
"co_time_timer_init":"0x0",
|
||||
"co_time_timer_set":"0x0",
|
||||
"co_time_timer_stop":"0x0",
|
||||
"aes_c1":"0x0",
|
||||
"aes_decrypt":"0x0",
|
||||
"aes_encrypt":"0x0",
|
||||
"aes_f4":"0x0",
|
||||
"aes_f5":"0x0",
|
||||
"aes_f6":"0x0",
|
||||
"aes_g2":"0x0",
|
||||
"aes_rand":"0x0",
|
||||
"aes_cmac":"0x0",
|
||||
"co_buf_head_release":"0x0",
|
||||
"co_buf_head_reserve":"0x0",
|
||||
"co_util_pack":"0x0",
|
||||
"co_util_unpack":"0x0",
|
||||
"rwip_reset":"0x0",
|
||||
"aes_rpa_resolve":"0x0",
|
||||
"co_buf_reuse":"0x0",
|
||||
"co_buf_size":"0x0",
|
||||
"co_buf_copy":"0x0",
|
||||
"co_buf_duplicate":"0x0",
|
||||
"co_buf_tail_release":"0x0",
|
||||
"co_list_init":"0x0",
|
||||
"ble_util_buf_rx_free":"0x0",
|
||||
"ble_util_buf_acl_tx_alloc":"0x0",
|
||||
"co_buf_cb_free_set":"0x0",
|
||||
"ke_malloc":"0x0",
|
||||
"co_list_insert_after":"0x0",
|
||||
"ke_timer_active":"0x0",
|
||||
"ke_timer_clear":"0x0",
|
||||
"ke_timer_set":"0x0",
|
||||
"co_buf_acquire":"0x0",
|
||||
"co_buf_tail_reserve":"0x0",
|
||||
"co_buf_copy_data_to_mem":"0x0",
|
||||
"co_list_insert_before":"0x0",
|
||||
"rom_env":"0x0",
|
||||
"rwip_param":"0x0",
|
||||
"one_bits":"0x0",
|
||||
"hci_rd_rem_ver_info_cmd_handler":"0x0",
|
||||
"hci_le_con_upd_cmd_handler":"0x0",
|
||||
"hci_le_rd_chnl_map_cmd_handler":"0x0",
|
||||
"hci_le_rd_rem_feats_cmd_handler":"0x0",
|
||||
"hci_le_en_enc_cmd_handler":"0x0",
|
||||
"hci_le_ltk_req_reply_cmd_handler":"0x0",
|
||||
"hci_le_ltk_req_neg_reply_cmd_handler":"0x0",
|
||||
"hci_le_rem_con_param_req_reply_cmd_handler":"0x0",
|
||||
"hci_le_rem_con_param_req_neg_reply_cmd_handler":"0x0",
|
||||
"hci_le_set_data_len_cmd_handler":"0x0",
|
||||
"hci_vs_set_pref_slave_latency_cmd_handler":"0x0",
|
||||
"hci_vs_set_pref_slave_evt_dur_cmd_handler":"0x0",
|
||||
"hci_vs_set_max_rx_size_and_time_cmd_handler":"0x0",
|
||||
"hci_rd_rssi_cmd_handler":"0x0",
|
||||
"llm_ch_map_update_ind_handler":"0x0",
|
||||
"llc_loc_llcp_rsp_to_handler":"0x0",
|
||||
"llc_rem_llcp_rsp_to_handler":"0x0",
|
||||
"llc_encrypt_ind_handler":"0x0",
|
||||
"llc_op_ver_exch_ind_handler":"0x0",
|
||||
"llc_op_feats_exch_ind_handler":"0x0",
|
||||
"llc_op_encrypt_ind_handler":"0x0",
|
||||
"llc_op_dl_upd_ind_handler":"0x0",
|
||||
"llc_op_con_upd_ind_handler":"0x0",
|
||||
"llc_op_ch_map_upd_ind_handler":"0x0",
|
||||
"lld_llcp_rx_ind_handler":"0x0",
|
||||
"lld_llcp_tx_cfm_handler":"0x0",
|
||||
"lld_acl_rx_ind_handler":"0x0",
|
||||
"lld_acl_tx_cfm_handler":"0x0",
|
||||
"lld_con_param_upd_cfm_handler":"0x0",
|
||||
"lld_ch_map_upd_cfm_handler":"0x0",
|
||||
"lld_con_offset_upd_ind_handler":"0x0",
|
||||
"hci_command_llc_handler":"0x0",
|
||||
"hci_acl_data_handler":"0x0",
|
||||
"ke_event_callback_set":"0x0",
|
||||
"ke_event_clear":"0x0",
|
||||
"ke_event_set":"0x0",
|
||||
"ble_util_nb_good_channels":"0x0",
|
||||
"ble_util_pkt_dur_in_us":"0x0",
|
||||
"co_bdaddr_compare":"0x0",
|
||||
"lld_ch_assess_data_get":"0x0",
|
||||
"lld_ch_map_set":"0x0",
|
||||
"lld_read_clock":"0x0",
|
||||
"lld_res_list_peer_update":"0x0",
|
||||
"lld_white_list_add":"0x0",
|
||||
"rwip_prevent_sleep_clear":"0x0",
|
||||
"rwip_prevent_sleep_set":"0x0",
|
||||
"sch_plan_rem":"0x0",
|
||||
"aes_rpa_gen":"0x0",
|
||||
"ble_util_buf_adv_tx_alloc":"0x0",
|
||||
"ble_util_buf_adv_tx_free":"0x0",
|
||||
"co_null_bdaddr":"0x0",
|
||||
"co_null_key":"0x0",
|
||||
"llc_con_move_cbk":"0x0",
|
||||
"llc_start":"0x0",
|
||||
"lld_adv_adv_data_update":"0x0",
|
||||
"lld_adv_rand_addr_update":"0x0",
|
||||
"lld_adv_restart":"0x0",
|
||||
"lld_adv_scan_rsp_data_update":"0x0",
|
||||
"lld_adv_start":"0x0",
|
||||
"lld_adv_stop":"0x0",
|
||||
"lld_white_list_rem":"0x0",
|
||||
"lld_init_rand_addr_update":"0x0",
|
||||
"lld_res_list_add":"0x0",
|
||||
"lld_res_list_clear":"0x0",
|
||||
"lld_res_list_local_rpa_get":"0x0",
|
||||
"lld_res_list_peer_rpa_get":"0x0",
|
||||
"lld_res_list_priv_mode_update":"0x0",
|
||||
"lld_res_list_rem":"0x0",
|
||||
"lld_scan_rand_addr_update":"0x0",
|
||||
"lld_init_start":"0x0",
|
||||
"lld_init_stop":"0x0",
|
||||
"sch_plan_req":"0x0",
|
||||
"sch_plan_set":"0x0",
|
||||
"co_rate_to_phy":"0x0",
|
||||
"lld_scan_params_update":"0x0",
|
||||
"lld_scan_start":"0x0",
|
||||
"lld_scan_stop":"0x0",
|
||||
"lld_rpa_renew":"0x0",
|
||||
"ke_mem_init":"0x0",
|
||||
"co_buf_init":"0x0",
|
||||
"rwip_sleep":"0x0",
|
||||
"em_ble_base_address_table_0":"0x0",
|
||||
"em_ble_base_address_table_1":"0x0",
|
||||
"em_ble_base_address_table_2":"0x0",
|
||||
"em_ble_base_address_table_3":"0x0",
|
||||
"em_ble_base_address_table_4":"0x0",
|
||||
"em_ble_base_address_table_5":"0x0",
|
||||
"em_ble_base_address_table_6":"0x0",
|
||||
"em_ble_base_address_table_7":"0x0",
|
||||
"em_ble_base_address_table_8":"0x0",
|
||||
"em_ble_base_address_table_9":"0x0",
|
||||
"em_ble_base_address_table_10":"0x0",
|
||||
"ble_util_buf_init_env":"0x0",
|
||||
"PATCH_FUN":"0x0",
|
||||
"lld_adv_env":"0x0",
|
||||
"sch_arb_remove":"0x0",
|
||||
"sch_slice_fg_remove":"0x0",
|
||||
"llc_env":"0x0",
|
||||
"llc_proc_err_ind":"0x0",
|
||||
"llc_stop":"0x0",
|
||||
"ll_channel_map_ind_handler":"0x0",
|
||||
"ll_connection_param_req_handler":"0x0",
|
||||
"ll_connection_param_rsp_handler":"0x0",
|
||||
"ll_connection_update_ind_handler":"0x0",
|
||||
"ll_enc_req_handler":"0x0",
|
||||
"ll_enc_rsp_handler":"0x0",
|
||||
"ll_feature_req_handler":"0x0",
|
||||
"ll_feature_rsp_handler":"0x0",
|
||||
"ll_length_req_handler":"0x0",
|
||||
"ll_length_rsp_handler":"0x0",
|
||||
"ll_min_used_channels_ind_handler":"0x0",
|
||||
"ll_pause_enc_req_handler":"0x0",
|
||||
"ll_pause_enc_rsp_handler":"0x0",
|
||||
"ll_reject_ext_ind_handler":"0x0",
|
||||
"ll_reject_ind_handler":"0x0",
|
||||
"ll_slave_feature_req_handler":"0x0",
|
||||
"ll_start_enc_req_handler":"0x0",
|
||||
"ll_start_enc_rsp_handler":"0x0",
|
||||
"ll_unknown_rsp_handler":"0x0",
|
||||
"ll_version_ind_handler":"0x0",
|
||||
"ble_util_buf_acl_tx_free":"0x0",
|
||||
"lld_rxdesc_check":"0x0",
|
||||
"lld_rxdesc_free":"0x0",
|
||||
"rwip_priority":"0x0",
|
||||
"sch_arb_insert":"0x0",
|
||||
"sch_prog_push":"0x0",
|
||||
"FMC_SPI_Flash_RDID":"0x0",
|
||||
"FMC_SPI_Flash_RUID":"0x0",
|
||||
"FMC_SPI_Flash_WakeUp":"0x0",
|
||||
"FMC_SPI_Init_Oprt":"0x0",
|
||||
"FMC_SPI_Flash_PowerDown":"0x0",
|
||||
"FMC_SPI_FlashRead":"0x0",
|
||||
"FMC_SPI_FlashWrite":"0x0",
|
||||
"FMC_SPI_Flash_Erase_Sector":"0x0",
|
||||
"FMC_SPI_Flash_PowerDown":"0x0",
|
||||
"FMC_SPI_Flash_WakeUp":"0x0",
|
||||
"llc_cleanup":"0x0",
|
||||
"llc_cmd_stat_send":"0x0",
|
||||
"llc_llcp_send":"0x0",
|
||||
"llc_llcp_state_set":"0x0",
|
||||
"llc_proc_get":"0x0",
|
||||
"llc_proc_id_get":"0x0",
|
||||
"llc_proc_init":"0x0",
|
||||
"llc_proc_reg":"0x0",
|
||||
"llc_proc_state_get":"0x0",
|
||||
"llc_proc_state_set":"0x0",
|
||||
"llc_proc_timer_pause_set":"0x0",
|
||||
"llc_proc_timer_set":"0x0",
|
||||
"llc_proc_unreg":"0x0",
|
||||
"lld_con_stop":"0x0",
|
||||
"lld_adv_evt_start_cbk":"0x0",
|
||||
"rwip_env":"0x0",
|
||||
"rwip_prog_delay":"0x0",
|
||||
"rwip_time_get":"0x0",
|
||||
"rwip_wakeup_end":"0x0",
|
||||
"sch_arb_env":"0x0",
|
||||
"lld_adv_frm_cbk":"0x0",
|
||||
"rwip_timer_alarm_handler":"0x0",
|
||||
"rwip_timer_arb_handler":"0x0",
|
||||
"rwip_timer_co_handler":"0x0",
|
||||
"lld_env":"0x0",
|
||||
"aa_gen":"0x0",
|
||||
"lld_adv_init":"0x0",
|
||||
"lld_con_init":"0x0",
|
||||
"lld_core_init":"0x0",
|
||||
"lld_rpa_renew_env":"0x0",
|
||||
"lld_channel_assess":"0x0",
|
||||
"lld_con_env":"0x0",
|
||||
"lld_con_tx_len_update":"0x0",
|
||||
"lld_exp_sync_pos_tab":"0x0",
|
||||
"lld_instant_proc_end":"0x0",
|
||||
"prf_dst_task_get":"0x0",
|
||||
"rom_env_init":"0x0",
|
||||
"gapc_get_bdaddr":"0x0",
|
||||
"gatt_db_svc16_add":"0x0",
|
||||
"gatt_db_svc_add":"0x0",
|
||||
"gatt_db_svc_remove":"0x0",
|
||||
"gatt_srv_att_read_get_cfm":"0x0",
|
||||
"gatt_srv_att_val_set_cfm":"0x0",
|
||||
"gatt_srv_event_send":"0x0",
|
||||
"gatt_user_srv_register":"0x0",
|
||||
"llc_msg_handler_tab":"0x0",
|
||||
"rom_llc_state":"0x0",
|
||||
"lld_con_evt_start_cbk":"0x0",
|
||||
"lld_con_evt_canceled_cbk":"0x0",
|
||||
"co_sca2ppm":"0x0",
|
||||
"lld_con_evt_time_update":"0x0",
|
||||
"lld_con_max_lat_calc":"0x0",
|
||||
"lld_con_sched":"0x0",
|
||||
"sch_slice_per_add":"0x0",
|
||||
"rwble_isr":"0x0",
|
||||
"rwip_isr":"0x0",
|
||||
"lld_con_frm_isr":"0x0",
|
||||
"ke_task_schedule":"0x0",
|
||||
"lld_adv_frm_isr":"0x0",
|
||||
"sv_lock":"0x0",
|
||||
"sv_txlen":"0x0",
|
||||
"rom_lld_con_rx":"0x0",
|
||||
"rom_lld_con_evt_start_cbk":"0x0",
|
||||
"rom_lld_con_frm_isr":"0x0",
|
||||
"gatt_cli_mtu_exch":"0x0",
|
||||
"rom_lld_disable_latency":"0x0",
|
||||
"rom_lld_enable_latency":"0x0",
|
||||
"evt_start":"0x0",
|
||||
"gatt_cli_discover_svc":"0x0",
|
||||
"gatt_uuid16_comp":"0x0",
|
||||
"gatt_cli_att_event_cfm":"0x0",
|
||||
"gatt_cli_discover_cancel":"0x0",
|
||||
"gatt_cli_discover_char":"0x0",
|
||||
"gatt_cli_discover_desc":"0x0",
|
||||
"gatt_cli_event_register":"0x0",
|
||||
"gatt_cli_read":"0x0",
|
||||
"gatt_cli_read_by_uuid":"0x0",
|
||||
"gatt_cli_write":"0x0",
|
||||
"gatt_user_cli_register":"0x0",
|
||||
"gatt_cli_discover_inc_svc":"0x0",
|
||||
"gatt_cli_event_unregister":"0x0",
|
||||
"co_rand_word":"0x0",
|
||||
"co_random_init":"0x0",
|
||||
"adv_evt_start":"0x0",
|
||||
"gatt_srv_read_api_tbl":"0x0",
|
||||
"gatt_srv_write_api_tbl":"0x0",
|
||||
}
|
||||
|
||||
def traverse(f):
|
||||
fs = os.listdir(f)
|
||||
for f1 in fs:
|
||||
tmp_path = os.path.join(f, f1)
|
||||
if not os.path.isdir(tmp_path):
|
||||
if os.path.isfile(tmp_path):
|
||||
if isinstance(tmp_path, str):
|
||||
# if tmp_path.endswith('2023_11_22.o'):
|
||||
if tmp_path.endswith('addr_0x800.o'):
|
||||
#print("ssss", tmp_path)
|
||||
logger.info(tmp_path)
|
||||
find_str(tmp_path)
|
||||
else:
|
||||
traverse(tmp_path)
|
||||
|
||||
def traverse_host(f):
|
||||
fs = os.listdir(f)
|
||||
for f1 in fs:
|
||||
tmp_path = os.path.join(f, f1)
|
||||
if not os.path.isdir(tmp_path):
|
||||
if os.path.isfile(tmp_path):
|
||||
if isinstance(tmp_path, str):
|
||||
if tmp_path.endswith('rom_symdefs.o'):
|
||||
#print("ssss", tmp_path)
|
||||
logger.info(tmp_path)
|
||||
find_str(tmp_path)
|
||||
else:
|
||||
traverse_host(tmp_path)
|
||||
|
||||
def traverse_for_replace(f):
|
||||
fs = os.listdir(f)
|
||||
for f1 in fs:
|
||||
tmp_path = os.path.join(f, f1)
|
||||
if not os.path.isdir(tmp_path):
|
||||
if os.path.isfile(tmp_path):
|
||||
if isinstance(tmp_path, str):
|
||||
if tmp_path.endswith('rom_symdefs.o'):
|
||||
|
||||
logger.info(tmp_path)
|
||||
replace_str(tmp_path)
|
||||
|
||||
|
||||
def find_str(file):
|
||||
text_lines = set()
|
||||
with io.open(file, 'r', encoding='utf-8') as fd:
|
||||
for line in fd:
|
||||
for key, value in replace.items():
|
||||
if re.search(key, line.strip()) != None and len(key)+13== len(line.strip()):
|
||||
#print(line)
|
||||
logger.info(line)
|
||||
replace[key] = line
|
||||
text_lines.add(line.strip())
|
||||
text_functions = {line.split()[-1] for line in text_lines}
|
||||
replace_keys = set(replace.keys())
|
||||
print("del record key start")
|
||||
for func in list(replace.keys()):
|
||||
if func not in text_functions:
|
||||
print(func)
|
||||
del replace[func]
|
||||
print("del record key end")
|
||||
fd.close()
|
||||
logger.info(str(replace))
|
||||
|
||||
def replace_str(file):
|
||||
header = "#<SYMDEFS># ARM Linker, 5060750: Last Updated: Tue Sep 05 15:30:26 2023\n"
|
||||
with io.open(r'tmp.c', 'w', encoding='utf-8') as fw:
|
||||
fw.write(header)
|
||||
for key, value in replace.items():
|
||||
#print(len(key)+13, len(line.strip()), key, line.strip())
|
||||
replace_flag = False
|
||||
fw.write(value)
|
||||
logger.info(value)
|
||||
#print("line2", value, key)
|
||||
print("line2", value)
|
||||
fw.close()
|
||||
|
||||
with io.open(file, 'w', encoding='utf-8') as fw:
|
||||
with io.open(r'tmp.c', 'r', encoding='utf-8') as file:
|
||||
for line in file:
|
||||
fw.write(line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if(os.path.exists("log.txt")):
|
||||
os.remove("log.txt")
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(level = logging.INFO)
|
||||
handler = logging.FileHandler("log.txt")
|
||||
handler.setLevel(logging.INFO)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
|
||||
#traverse("./Project/example/ble/rom_stack/mdk/")
|
||||
traverse_host("./Project/example/ble/ble_central_lib/mdk/")
|
||||
#print(replace)
|
||||
traverse_for_replace("./Project/example/ble/ble_central/app/src")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,319 +1,320 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_task.h
|
||||
*
|
||||
* @brief Header file - APPTASK.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_TASK_H_
|
||||
#define APP_TASK_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APPTASK Task
|
||||
* @ingroup APP
|
||||
* @brief Routes ALL messages to/from APP block.
|
||||
*
|
||||
* The APPTASK is the block responsible for bridging the final application with
|
||||
*the RWBLE software host stack. It communicates with the different modules of
|
||||
*the BLE host, i.e. @ref SMP, @ref GAP and @ref GATT.
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "co_bt_defines.h"
|
||||
#include "dbg.h"
|
||||
#include "gapm_int.h"
|
||||
#include "gatt_msg_int.h" // GATTC Definitions
|
||||
#include "ke_task.h" // Kernel Task
|
||||
#include "rwip_task.h" // Task definitions
|
||||
#include "ota_server.h"
|
||||
#include "xc_gap_api.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include <stdio.h>
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
#include "nvds.h"
|
||||
#endif // (NVDS_SUPPORT)
|
||||
|
||||
#define APP_HANDLERS(subtask) \
|
||||
{ \
|
||||
&subtask##_msg_handler_list[0], ARRAY_LEN(subtask##_msg_handler_list) \
|
||||
}
|
||||
|
||||
/// Default Device Name
|
||||
#define APP_DFLT_DEVICE_NAME ("MARVEL")
|
||||
#define APP_DFLT_DEVICE_NAME_LEN (sizeof(APP_DFLT_DEVICE_NAME))
|
||||
/// Maximal length of the Device Name value
|
||||
#define APP_DEVICE_NAME_MAX_LEN (18)
|
||||
#define APP_MAX_TX_POWER (0)
|
||||
// Advertising channel map - 37, 38, 39
|
||||
#define APP_ADV_CHMAP (0x07)
|
||||
// Advertising minimum interval - 40ms (64*0.625ms)
|
||||
#define APP_ADV_INT_MIN (64)
|
||||
// Advertising maximum interval - 40ms (64*0.625ms)
|
||||
#define APP_ADV_INT_MAX (64)
|
||||
#define ADV_DATA_MAX_LENGTH 28
|
||||
|
||||
#define MANUFACTURER_DATA "\x09\xFF\x00\x60\x52\x57\x2D\x42\x4C\x45"
|
||||
#define MANUFACTURER_DATA_LEN 10
|
||||
|
||||
/// Advertising duration (in unit of 10ms). 0 means that advertising continues
|
||||
/// until the host disable it
|
||||
#define ADV_DURATION 0
|
||||
|
||||
#define APP_SCAN_INTERVAL (0xa0)
|
||||
#define APP_SCAN_WINDOW (0x50)
|
||||
|
||||
#define APP_CONN_EST_TIME_OUT (0)
|
||||
#define APP_CONN_SCNA_INTV (32)
|
||||
#define APP_CONN_SCAN_WD (20)
|
||||
#define APP_CONN_INTV_MIN (80)
|
||||
#define APP_CONN_INV_MAX (80)
|
||||
#define APP_CONN_LATENCY (0)
|
||||
#define APP_CONN_TIME_OUT (500)
|
||||
|
||||
/// Number of APP Task Instances
|
||||
#define APP_IDX_MAX 1
|
||||
#define DEV_APPEARANCE 0
|
||||
|
||||
#define BLE_UAPDATA_MIN_INTVALUE 8
|
||||
#define BLE_UAPDATA_MAX_INTVALUE 10
|
||||
#define BLE_UAPDATA_LATENCY 0
|
||||
#define BLE_UAPDATA_TIMEOUT 200
|
||||
|
||||
#define INVALID_DATA 0xFF
|
||||
|
||||
#define TAGET_DEVICE_ADDR ("\x12\x34\x56\x78\x90\xAB")
|
||||
|
||||
|
||||
/// Application environment structure
|
||||
struct app_env_tag
|
||||
{
|
||||
/// Connection handle
|
||||
uint16_t conhdl;
|
||||
/// Connection Index
|
||||
uint8_t conidx;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t adv_state;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t scan_state;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t init_state;
|
||||
/// Next expected operation completed event
|
||||
uint8_t adv_op;
|
||||
|
||||
/// Last initialized profile
|
||||
uint8_t next_svc;
|
||||
|
||||
/// Bonding status
|
||||
bool bonded;
|
||||
|
||||
/// Device Name length
|
||||
uint8_t dev_name_len;
|
||||
/// Device Name
|
||||
uint8_t dev_name[APP_DEVICE_NAME_MAX_LEN];
|
||||
|
||||
/// Local device IRK
|
||||
uint8_t loc_irk[KEY_LEN];
|
||||
|
||||
/// Secure Connections on current link
|
||||
bool sec_con_enabled;
|
||||
|
||||
/// Counter used to generate IRK
|
||||
uint8_t rand_cnt;
|
||||
|
||||
/// Demonstration type length
|
||||
uint8_t demo_type_len;
|
||||
/// Demonstration type
|
||||
uint8_t demo_type;
|
||||
/// GATT user local identifier
|
||||
uint8_t user_lid;
|
||||
uint8_t adv_actv_idx;
|
||||
uint8_t slave_conidx;
|
||||
bool slave_connected;
|
||||
|
||||
};
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
/// List of Application NVDS TAG identifiers
|
||||
enum app_nvds_tag
|
||||
{
|
||||
/// Device Name
|
||||
NVDS_TAG_DEVICE_NAME = 0x02,
|
||||
NVDS_LEN_DEVICE_NAME = 62,
|
||||
|
||||
/// BD Address
|
||||
NVDS_TAG_BD_ADDRESS = 0x01,
|
||||
NVDS_LEN_BD_ADDRESS = 6,
|
||||
|
||||
/// Local device Identity resolving key
|
||||
NVDS_TAG_LOC_IRK = 0xA0,
|
||||
NVDS_LEN_LOC_IRK = KEY_LEN,
|
||||
|
||||
#if (BLE_APP_PRF)
|
||||
/// BLE Application Advertising data
|
||||
NVDS_TAG_APP_BLE_ADV_DATA = 0x0B,
|
||||
NVDS_LEN_APP_BLE_ADV_DATA = 32,
|
||||
|
||||
/// BLE Application Scan response data
|
||||
NVDS_TAG_APP_BLE_SCAN_RESP_DATA = 0x0C,
|
||||
NVDS_LEN_APP_BLE_SCAN_RESP_DATA = 32,
|
||||
|
||||
/// Mouse Sample Rate
|
||||
NVDS_TAG_MOUSE_SAMPLE_RATE = 0x38,
|
||||
NVDS_LEN_MOUSE_SAMPLE_RATE = 1,
|
||||
|
||||
/// Peripheral Bonded
|
||||
NVDS_TAG_PERIPH_BONDED = 0x39,
|
||||
NVDS_LEN_PERIPH_BONDED = 1,
|
||||
|
||||
/// Mouse NTF Cfg
|
||||
NVDS_TAG_MOUSE_NTF_CFG = 0x3A,
|
||||
NVDS_LEN_MOUSE_NTF_CFG = 2,
|
||||
|
||||
/// Mouse Timeout value
|
||||
NVDS_TAG_MOUSE_TIMEOUT = 0x3B,
|
||||
NVDS_LEN_MOUSE_TIMEOUT = 2,
|
||||
|
||||
/// Peer Device BD Address
|
||||
NVDS_TAG_PEER_BD_ADDRESS = 0x3C,
|
||||
NVDS_LEN_PEER_BD_ADDRESS = 7,
|
||||
|
||||
/// Mouse Energy Safe
|
||||
NVDS_TAG_MOUSE_ENERGY_SAFE = 0x3D,
|
||||
NVDS_LEN_MOUSE_SAFE_ENERGY = 2,
|
||||
|
||||
/// EDIV (2bytes), RAND NB (8bytes), LTK (16 bytes), Key Size (1 byte)
|
||||
NVDS_TAG_LTK = 0x3E,
|
||||
NVDS_LEN_LTK = 28,
|
||||
|
||||
/// PAIRING
|
||||
NVDS_TAG_PAIRING = 0x3F,
|
||||
NVDS_LEN_PAIRING = 54,
|
||||
|
||||
/// Audio mode 0 task
|
||||
NVDS_TAG_AM0_FIRST = 0x90,
|
||||
NVDS_TAG_AM0_LAST = 0x9F,
|
||||
|
||||
/// Peer device Resolving identity key (+identity address)
|
||||
NVDS_TAG_PEER_IRK = 0xA1,
|
||||
NVDS_LEN_PEER_IRK = sizeof(struct gapc_irk),
|
||||
|
||||
#endif //(BLE_APP_PRF)
|
||||
};
|
||||
#endif // (NVDS_SUPPORT)
|
||||
|
||||
/// Advertising state machine
|
||||
enum app_adv_state
|
||||
{
|
||||
/// Advertising activity does not exists
|
||||
APP_ADV_STATE_IDLE = 0,
|
||||
#if BLE_APP_PRF
|
||||
/// Creating advertising activity
|
||||
APP_ADV_STATE_CREATING,
|
||||
/// Setting advertising data
|
||||
APP_ADV_STATE_SETTING_ADV_DATA,
|
||||
/// Setting scan response data
|
||||
APP_ADV_STATE_SETTING_SCAN_RSP_DATA,
|
||||
|
||||
/// Advertising activity created
|
||||
APP_ADV_STATE_CREATED,
|
||||
/// Starting advertising activity
|
||||
APP_ADV_STATE_STARTING,
|
||||
/// Advertising activity started
|
||||
APP_ADV_STATE_STARTED,
|
||||
/// Stopping advertising activity
|
||||
APP_ADV_STATE_STOPPING,
|
||||
APP_ADV_STATE_STOPPED,
|
||||
#endif //(BLE_APP_PRF)
|
||||
};
|
||||
|
||||
/// Scanning state machine
|
||||
enum app_scan_state
|
||||
{
|
||||
APP_SCAN_STATE_IDLE = 0,
|
||||
APP_SCAN_STATE_CREATING,
|
||||
APP_SCAN_STATE_CREATED,
|
||||
APP_SCAN_STATE_STARTING,
|
||||
APP_SCAN_STATE_STARTED,
|
||||
APP_SCAN_STATE_STOPPING,
|
||||
APP_SCAN_STATE_STOPPED,
|
||||
};
|
||||
|
||||
/// initting state machine
|
||||
enum app_init_state
|
||||
{
|
||||
APP_INIT_STATE_IDLE = 0,
|
||||
APP_INIT_STATE_CREATING,
|
||||
APP_INIT_STATE_CREATED,
|
||||
APP_INIT_STATE_STARTING,
|
||||
APP_INIT_STATE_STARTED,
|
||||
APP_INIT_STATE_STOPPING,
|
||||
APP_INIT_STATE_STOPPED,
|
||||
};
|
||||
|
||||
/// States of APP task
|
||||
enum app_state
|
||||
{
|
||||
/// Initialization state
|
||||
APP_INIT,
|
||||
/// Database create state
|
||||
APP_CREATE_DB,
|
||||
/// Ready State
|
||||
APP_READY,
|
||||
/// Connected state
|
||||
APP_CONNECTED,
|
||||
|
||||
/// Number of defined states.
|
||||
APP_STATE_MAX
|
||||
};
|
||||
|
||||
/// APP Task messages
|
||||
/*@TRACE*/
|
||||
enum app_msg_id
|
||||
{
|
||||
APP_DUMMY_MSG = TASK_FIRST_MSG(TASK_ID_APP),
|
||||
|
||||
#if (BLE_APP_PRF)
|
||||
#if (BLE_APP_HT)
|
||||
/// Timer used to refresh the temperature measurement value
|
||||
APP_HT_MEAS_INTV_TIMER,
|
||||
#endif //(BLE_APP_HT)
|
||||
|
||||
#if (BLE_APP_HID)
|
||||
/// Timer used to disconnect the moue if no activity is detecter
|
||||
APP_HID_MOUSE_TIMEOUT_TIMER,
|
||||
#endif //(BLE_APP_HID)
|
||||
#endif //(BLE_APP_PRF)
|
||||
|
||||
};
|
||||
|
||||
struct app_subtask_handlers
|
||||
{
|
||||
/// Pointer to the message handler table
|
||||
const struct ke_msg_handler *p_msg_handler_tab;
|
||||
/// Number of messages handled
|
||||
uint16_t msg_cnt;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize the BLE demo application.
|
||||
****************************************************************************************
|
||||
*/
|
||||
extern struct app_env_tag app_env;
|
||||
void app_init(void);
|
||||
struct app_env_tag *get_app_env(void);
|
||||
/// @} APPTASK
|
||||
|
||||
#endif // APP_TASK_H_
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_task.h
|
||||
*
|
||||
* @brief Header file - APPTASK.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_TASK_H_
|
||||
#define APP_TASK_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APPTASK Task
|
||||
* @ingroup APP
|
||||
* @brief Routes ALL messages to/from APP block.
|
||||
*
|
||||
* The APPTASK is the block responsible for bridging the final application with
|
||||
*the RWBLE software host stack. It communicates with the different modules of
|
||||
*the BLE host, i.e. @ref SMP, @ref GAP and @ref GATT.
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "co_bt_defines.h"
|
||||
#include "dbg.h"
|
||||
#include "gapm_int.h"
|
||||
#include "gatt_msg_int.h" // GATTC Definitions
|
||||
#include "ke_task.h" // Kernel Task
|
||||
#include "rwip_task.h" // Task definitions
|
||||
#include "ota_server.h"
|
||||
#include "xc_gap_api.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include <stdio.h>
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
#include "nvds.h"
|
||||
#endif // (NVDS_SUPPORT)
|
||||
|
||||
#define APP_HANDLERS(subtask) \
|
||||
{ \
|
||||
&subtask##_msg_handler_list[0], ARRAY_LEN(subtask##_msg_handler_list) \
|
||||
}
|
||||
|
||||
/// Default Device Name
|
||||
#define APP_DFLT_DEVICE_NAME ("STAIR56E-02")
|
||||
#define APP_DFLT_DEVICE_NAME_LEN (sizeof(APP_DFLT_DEVICE_NAME))//must not be greater than APP_DEVICE_NAME_MAX_LEN
|
||||
/// Maximal length of the Device Name value
|
||||
#define APP_DEVICE_NAME_MAX_LEN (18)
|
||||
#define APP_MAX_TX_POWER (0)
|
||||
// Advertising channel map - 37, 38, 39
|
||||
#define APP_ADV_CHMAP (0x07)
|
||||
// Advertising minimum interval - 40ms (64*0.625ms)
|
||||
#define APP_ADV_INT_MIN (64)
|
||||
// Advertising maximum interval - 40ms (64*0.625ms)
|
||||
#define APP_ADV_INT_MAX (64)
|
||||
#define ADV_DATA_MAX_LENGTH 28
|
||||
|
||||
// Stair66E factory/manufacturer payload preserved from the product project.
|
||||
#define MANUFACTURER_DATA "\x09\xFF\x32\x60\x47\x99"
|
||||
#define MANUFACTURER_DATA_LEN 6
|
||||
|
||||
/// Advertising duration (in unit of 10ms). 0 means that advertising continues
|
||||
/// until the host disable it
|
||||
#define ADV_DURATION 0
|
||||
|
||||
#define APP_SCAN_INTERVAL (0xa0)
|
||||
#define APP_SCAN_WINDOW (0x50)
|
||||
|
||||
#define APP_CONN_EST_TIME_OUT (0)
|
||||
#define APP_CONN_SCNA_INTV (32)
|
||||
#define APP_CONN_SCAN_WD (20)
|
||||
#define APP_CONN_INTV_MIN (80)
|
||||
#define APP_CONN_INV_MAX (80)
|
||||
#define APP_CONN_LATENCY (0)
|
||||
#define APP_CONN_TIME_OUT (500)
|
||||
|
||||
/// Number of APP Task Instances
|
||||
#define APP_IDX_MAX 1
|
||||
#define DEV_APPEARANCE 0
|
||||
|
||||
#define BLE_UAPDATA_MIN_INTVALUE 8
|
||||
#define BLE_UAPDATA_MAX_INTVALUE 10
|
||||
#define BLE_UAPDATA_LATENCY 0
|
||||
#define BLE_UAPDATA_TIMEOUT 200
|
||||
|
||||
#define INVALID_DATA 0xFF
|
||||
|
||||
#define TAGET_DEVICE_ADDR ("\x12\x34\x56\x78\x90\xAB")
|
||||
|
||||
|
||||
/// Application environment structure
|
||||
struct app_env_tag
|
||||
{
|
||||
/// Connection handle
|
||||
uint16_t conhdl;
|
||||
/// Connection Index
|
||||
uint8_t conidx;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t adv_state;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t scan_state;
|
||||
/// Current advertising state (@see enum app_adv_state)
|
||||
uint8_t init_state;
|
||||
/// Next expected operation completed event
|
||||
uint8_t adv_op;
|
||||
|
||||
/// Last initialized profile
|
||||
uint8_t next_svc;
|
||||
|
||||
/// Bonding status
|
||||
bool bonded;
|
||||
|
||||
/// Device Name length
|
||||
uint8_t dev_name_len;
|
||||
/// Device Name
|
||||
uint8_t dev_name[APP_DEVICE_NAME_MAX_LEN];
|
||||
|
||||
/// Local device IRK
|
||||
uint8_t loc_irk[KEY_LEN];
|
||||
|
||||
/// Secure Connections on current link
|
||||
bool sec_con_enabled;
|
||||
|
||||
/// Counter used to generate IRK
|
||||
uint8_t rand_cnt;
|
||||
|
||||
/// Demonstration type length
|
||||
uint8_t demo_type_len;
|
||||
/// Demonstration type
|
||||
uint8_t demo_type;
|
||||
/// GATT user local identifier
|
||||
uint8_t user_lid;
|
||||
uint8_t adv_actv_idx;
|
||||
uint8_t slave_conidx;
|
||||
bool slave_connected;
|
||||
|
||||
};
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
/// List of Application NVDS TAG identifiers
|
||||
enum app_nvds_tag
|
||||
{
|
||||
/// Device Name
|
||||
NVDS_TAG_DEVICE_NAME = 0x02,
|
||||
NVDS_LEN_DEVICE_NAME = 62,
|
||||
|
||||
/// BD Address
|
||||
NVDS_TAG_BD_ADDRESS = 0x01,
|
||||
NVDS_LEN_BD_ADDRESS = 6,
|
||||
|
||||
/// Local device Identity resolving key
|
||||
NVDS_TAG_LOC_IRK = 0xA0,
|
||||
NVDS_LEN_LOC_IRK = KEY_LEN,
|
||||
|
||||
#if (BLE_APP_PRF)
|
||||
/// BLE Application Advertising data
|
||||
NVDS_TAG_APP_BLE_ADV_DATA = 0x0B,
|
||||
NVDS_LEN_APP_BLE_ADV_DATA = 32,
|
||||
|
||||
/// BLE Application Scan response data
|
||||
NVDS_TAG_APP_BLE_SCAN_RESP_DATA = 0x0C,
|
||||
NVDS_LEN_APP_BLE_SCAN_RESP_DATA = 32,
|
||||
|
||||
/// Mouse Sample Rate
|
||||
NVDS_TAG_MOUSE_SAMPLE_RATE = 0x38,
|
||||
NVDS_LEN_MOUSE_SAMPLE_RATE = 1,
|
||||
|
||||
/// Peripheral Bonded
|
||||
NVDS_TAG_PERIPH_BONDED = 0x39,
|
||||
NVDS_LEN_PERIPH_BONDED = 1,
|
||||
|
||||
/// Mouse NTF Cfg
|
||||
NVDS_TAG_MOUSE_NTF_CFG = 0x3A,
|
||||
NVDS_LEN_MOUSE_NTF_CFG = 2,
|
||||
|
||||
/// Mouse Timeout value
|
||||
NVDS_TAG_MOUSE_TIMEOUT = 0x3B,
|
||||
NVDS_LEN_MOUSE_TIMEOUT = 2,
|
||||
|
||||
/// Peer Device BD Address
|
||||
NVDS_TAG_PEER_BD_ADDRESS = 0x3C,
|
||||
NVDS_LEN_PEER_BD_ADDRESS = 7,
|
||||
|
||||
/// Mouse Energy Safe
|
||||
NVDS_TAG_MOUSE_ENERGY_SAFE = 0x3D,
|
||||
NVDS_LEN_MOUSE_SAFE_ENERGY = 2,
|
||||
|
||||
/// EDIV (2bytes), RAND NB (8bytes), LTK (16 bytes), Key Size (1 byte)
|
||||
NVDS_TAG_LTK = 0x3E,
|
||||
NVDS_LEN_LTK = 28,
|
||||
|
||||
/// PAIRING
|
||||
NVDS_TAG_PAIRING = 0x3F,
|
||||
NVDS_LEN_PAIRING = 54,
|
||||
|
||||
/// Audio mode 0 task
|
||||
NVDS_TAG_AM0_FIRST = 0x90,
|
||||
NVDS_TAG_AM0_LAST = 0x9F,
|
||||
|
||||
/// Peer device Resolving identity key (+identity address)
|
||||
NVDS_TAG_PEER_IRK = 0xA1,
|
||||
NVDS_LEN_PEER_IRK = sizeof(struct gapc_irk),
|
||||
|
||||
#endif //(BLE_APP_PRF)
|
||||
};
|
||||
#endif // (NVDS_SUPPORT)
|
||||
|
||||
/// Advertising state machine
|
||||
enum app_adv_state
|
||||
{
|
||||
/// Advertising activity does not exists
|
||||
APP_ADV_STATE_IDLE = 0,
|
||||
#if BLE_APP_PRF
|
||||
/// Creating advertising activity
|
||||
APP_ADV_STATE_CREATING,
|
||||
/// Setting advertising data
|
||||
APP_ADV_STATE_SETTING_ADV_DATA,
|
||||
/// Setting scan response data
|
||||
APP_ADV_STATE_SETTING_SCAN_RSP_DATA,
|
||||
|
||||
/// Advertising activity created
|
||||
APP_ADV_STATE_CREATED,
|
||||
/// Starting advertising activity
|
||||
APP_ADV_STATE_STARTING,
|
||||
/// Advertising activity started
|
||||
APP_ADV_STATE_STARTED,
|
||||
/// Stopping advertising activity
|
||||
APP_ADV_STATE_STOPPING,
|
||||
APP_ADV_STATE_STOPPED,
|
||||
#endif //(BLE_APP_PRF)
|
||||
};
|
||||
|
||||
/// Scanning state machine
|
||||
enum app_scan_state
|
||||
{
|
||||
APP_SCAN_STATE_IDLE = 0,
|
||||
APP_SCAN_STATE_CREATING,
|
||||
APP_SCAN_STATE_CREATED,
|
||||
APP_SCAN_STATE_STARTING,
|
||||
APP_SCAN_STATE_STARTED,
|
||||
APP_SCAN_STATE_STOPPING,
|
||||
APP_SCAN_STATE_STOPPED,
|
||||
};
|
||||
|
||||
/// initting state machine
|
||||
enum app_init_state
|
||||
{
|
||||
APP_INIT_STATE_IDLE = 0,
|
||||
APP_INIT_STATE_CREATING,
|
||||
APP_INIT_STATE_CREATED,
|
||||
APP_INIT_STATE_STARTING,
|
||||
APP_INIT_STATE_STARTED,
|
||||
APP_INIT_STATE_STOPPING,
|
||||
APP_INIT_STATE_STOPPED,
|
||||
};
|
||||
|
||||
/// States of APP task
|
||||
enum app_state
|
||||
{
|
||||
/// Initialization state
|
||||
APP_INIT,
|
||||
/// Database create state
|
||||
APP_CREATE_DB,
|
||||
/// Ready State
|
||||
APP_READY,
|
||||
/// Connected state
|
||||
APP_CONNECTED,
|
||||
|
||||
/// Number of defined states.
|
||||
APP_STATE_MAX
|
||||
};
|
||||
|
||||
/// APP Task messages
|
||||
/*@TRACE*/
|
||||
enum app_msg_id
|
||||
{
|
||||
APP_DUMMY_MSG = TASK_FIRST_MSG(TASK_ID_APP),
|
||||
|
||||
#if (BLE_APP_PRF)
|
||||
#if (BLE_APP_HT)
|
||||
/// Timer used to refresh the temperature measurement value
|
||||
APP_HT_MEAS_INTV_TIMER,
|
||||
#endif //(BLE_APP_HT)
|
||||
|
||||
#if (BLE_APP_HID)
|
||||
/// Timer used to disconnect the moue if no activity is detecter
|
||||
APP_HID_MOUSE_TIMEOUT_TIMER,
|
||||
#endif //(BLE_APP_HID)
|
||||
#endif //(BLE_APP_PRF)
|
||||
|
||||
};
|
||||
|
||||
struct app_subtask_handlers
|
||||
{
|
||||
/// Pointer to the message handler table
|
||||
const struct ke_msg_handler *p_msg_handler_tab;
|
||||
/// Number of messages handled
|
||||
uint16_t msg_cnt;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize the BLE demo application.
|
||||
****************************************************************************************
|
||||
*/
|
||||
extern struct app_env_tag app_env;
|
||||
void app_init(void);
|
||||
struct app_env_tag *get_app_env(void);
|
||||
/// @} APPTASK
|
||||
|
||||
#endif // APP_TASK_H_
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file rwapp_config.h
|
||||
*
|
||||
* @brief Application configuration definition
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2016
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _RWAPP_CONFIG_H_
|
||||
#define _RWAPP_CONFIG_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup app
|
||||
* @brief Application configuration definition
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#define CFG_APP_BATT
|
||||
/******************************************************************************************/
|
||||
/* ------------------------- BLE APPLICATION SETTINGS
|
||||
* -----------------------------*/
|
||||
/******************************************************************************************/
|
||||
|
||||
/// Application Profile
|
||||
#if defined(CFG_APP_PRF)
|
||||
#define BLE_APP_PRF 1
|
||||
#else // defined(CFG_APP_PRF)
|
||||
#define BLE_APP_PRF 0
|
||||
#endif // defined(CFG_APP_PRF)
|
||||
|
||||
/// Health Thermometer Application
|
||||
#if defined(CFG_APP_HT)
|
||||
#define BLE_APP_HT 1
|
||||
#else // defined(CFG_APP_HT)
|
||||
#define BLE_APP_HT 0
|
||||
#endif // defined(CFG_APP_HT)
|
||||
|
||||
/// HID Application
|
||||
#if defined(CFG_APP_HID)
|
||||
#define BLE_APP_HID 1
|
||||
#else // defined(CFG_APP_HID)
|
||||
#define BLE_APP_HID 0
|
||||
#endif // defined(CFG_APP_HID)
|
||||
|
||||
/// DIS Application
|
||||
#if defined(CFG_APP_DIS)
|
||||
#define BLE_APP_DIS 1
|
||||
#else // defined(CFG_APP_DIS)
|
||||
#define BLE_APP_DIS 0
|
||||
#endif // defined(CFG_APP_DIS)
|
||||
|
||||
/// Battery Service Application
|
||||
#if defined(CFG_APP_BATT)
|
||||
#define BLE_APP_BATT 1
|
||||
#else
|
||||
#define BLE_APP_BATT 0
|
||||
#endif //(BLE_APP_BATT)
|
||||
|
||||
/// @} rwapp_config
|
||||
|
||||
#endif /* _RWAPP_CONFIG_H_ */
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file rwapp_config.h
|
||||
*
|
||||
* @brief Application configuration definition
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2016
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _RWAPP_CONFIG_H_
|
||||
#define _RWAPP_CONFIG_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup app
|
||||
* @brief Application configuration definition
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#define CFG_APP_BATT
|
||||
/******************************************************************************************/
|
||||
/* ------------------------- BLE APPLICATION SETTINGS
|
||||
* -----------------------------*/
|
||||
/******************************************************************************************/
|
||||
|
||||
/// Application Profile
|
||||
#if defined(CFG_APP_PRF)
|
||||
#define BLE_APP_PRF 1
|
||||
#else // defined(CFG_APP_PRF)
|
||||
#define BLE_APP_PRF 0
|
||||
#endif // defined(CFG_APP_PRF)
|
||||
|
||||
/// Health Thermometer Application
|
||||
#if defined(CFG_APP_HT)
|
||||
#define BLE_APP_HT 1
|
||||
#else // defined(CFG_APP_HT)
|
||||
#define BLE_APP_HT 0
|
||||
#endif // defined(CFG_APP_HT)
|
||||
|
||||
/// HID Application
|
||||
#if defined(CFG_APP_HID)
|
||||
#define BLE_APP_HID 1
|
||||
#else // defined(CFG_APP_HID)
|
||||
#define BLE_APP_HID 0
|
||||
#endif // defined(CFG_APP_HID)
|
||||
|
||||
/// DIS Application
|
||||
#if defined(CFG_APP_DIS)
|
||||
#define BLE_APP_DIS 1
|
||||
#else // defined(CFG_APP_DIS)
|
||||
#define BLE_APP_DIS 0
|
||||
#endif // defined(CFG_APP_DIS)
|
||||
|
||||
/// Battery Service Application
|
||||
#if defined(CFG_APP_BATT)
|
||||
#define BLE_APP_BATT 1
|
||||
#else
|
||||
#define BLE_APP_BATT 0
|
||||
#endif //(BLE_APP_BATT)
|
||||
|
||||
/// @} rwapp_config
|
||||
|
||||
#endif /* _RWAPP_CONFIG_H_ */
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
* *
|
||||
* @file aes.c
|
||||
*
|
||||
* @brief Definition file for AES crypto module functions
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2017-2018
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
#if (RWIP_AES_ENCRYPT)
|
||||
#define USE_AES_ENCRYPT 0
|
||||
#define USE_AES_DECRYPT 1
|
||||
|
||||
#if USE_AES_ENCRYPT
|
||||
uint8_t key[16]={0x10,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x0d,0x0c,0x0b};
|
||||
uint8_t src_val[16]={0x0a,0x0a,0x0e,0x0d,0x0c,0x0b,0x0a,0x13,0x12,0x07,0x06,0x05,0x04,0x0d,0x02,0x01};
|
||||
uint8_t encrypt_val[16]={0xf7,0x3b,0x9a,0xe6,0x88,0xb0,0x06,0x3e,0x10,0xd4,0x0f,0xb6,0x80,0x4a,0x10,0xee};
|
||||
#elif USE_AES_DECRYPT
|
||||
uint8_t key[16]={0x10,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x0d,0x0c,0x0b};
|
||||
uint8_t src_val[16]={0xf7,0x3b,0x9a,0xe6,0x88,0xb0,0x06,0x3e,0x10,0xd4,0x0f,0xb6,0x80,0x4a,0x10,0xee};
|
||||
uint8_t encrypt_val[16]={0x0a,0x0a,0x0e,0x0d,0x0c,0x0b,0x0a,0x13,0x12,0x07,0x06,0x05,0x04,0x0d,0x02,0x01};
|
||||
#endif
|
||||
|
||||
aes_func_result_cb aes_res(uint8_t status, const uint8_t* aes_res_data, uint32_t src_info)
|
||||
{
|
||||
printf("src_info:0x%x\n",src_info);
|
||||
printf("aes_res:");
|
||||
for(int i=0;i<16;i++){
|
||||
printf("%02x-",aes_res_data[i]);
|
||||
}printf("\n");
|
||||
|
||||
if(!memcmp(aes_res_data,encrypt_val,sizeof(encrypt_val))){
|
||||
printf("aes right\n");
|
||||
}else{
|
||||
printf("aes error\n");
|
||||
}
|
||||
}
|
||||
|
||||
void aes_test(void)
|
||||
{
|
||||
uint8_t copy=0;
|
||||
static uint8_t cnt;
|
||||
|
||||
if(xc_gpio_read_pin(GPIO_1) == GPIO_PIN_SET){
|
||||
if(cnt++ > 100){
|
||||
cnt = 0;
|
||||
#if USE_AES_ENCRYPT
|
||||
printf("aes_encrypt\n");
|
||||
aes_encrypt(key, src_val, 1, aes_res, 0xff);
|
||||
#elif USE_AES_DECRYPT
|
||||
printf("aes_decrypt\n");
|
||||
aes_decrypt(key, src_val, copy, aes_res, 0xff);
|
||||
#endif
|
||||
}
|
||||
}else{
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,189 +1,186 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_batt.c
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // SW configuration
|
||||
|
||||
#if (BLE_APP_BATT)
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "app_batt.h" // Battery Application Module Definitions
|
||||
#include "app_task.h" // application task definitions
|
||||
#include "bass_msg.h" // health thermometer functions
|
||||
#include "co_bt.h"
|
||||
#include "co_utils.h"
|
||||
#include "prf_types.h" // Profile common types definition
|
||||
#include "arch.h" // Platform Definitions
|
||||
#include "prf.h"
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application Module Environment Structure
|
||||
struct app_batt_env_tag app_batt_env;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTION DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
void app_batt_init(void)
|
||||
{
|
||||
// Reset the environment
|
||||
memset(&app_batt_env, 0, sizeof(struct app_batt_env_tag));
|
||||
|
||||
// Initial battery level: 100
|
||||
app_batt_env.batt_lvl = 100;
|
||||
}
|
||||
|
||||
void app_batt_add_bas(void)
|
||||
{
|
||||
struct bass_db_cfg* db_cfg;
|
||||
// Allocate the BASS_CREATE_DB_REQ
|
||||
struct gapm_profile_task_add_cmd *req = KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD,
|
||||
TASK_GAPM, TASK_APP,
|
||||
gapm_profile_task_add_cmd, sizeof(struct bass_db_cfg));
|
||||
// Fill message
|
||||
req->operation = GAPM_PROFILE_TASK_ADD;
|
||||
req->sec_lvl = 0;//PERM(SVC_AUTH, AUTH);
|
||||
req->prf_api_id = TASK_ID_BASS;
|
||||
req->app_task = TASK_APP;
|
||||
req->start_hdl = 0;
|
||||
|
||||
// Set parameters
|
||||
db_cfg = (struct bass_db_cfg* ) req->param;
|
||||
|
||||
// Add a BAS instance
|
||||
db_cfg->bas_nb = 1;
|
||||
// Sending of notifications is supported
|
||||
db_cfg->features[0] = BAS_BATT_LVL_NTF_SUP;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
void app_batt_enable_prf(uint8_t conidx)
|
||||
{
|
||||
app_batt_env.conidx = conidx;
|
||||
|
||||
// Allocate the message
|
||||
struct bass_enable_req * req = KE_MSG_ALLOC(BASS_ENABLE_REQ,
|
||||
prf_dst_task_get(TASK_ID_BASS),
|
||||
TASK_APP,
|
||||
bass_enable_req);
|
||||
|
||||
// Fill in the parameter structure
|
||||
req->conidx = conidx;
|
||||
|
||||
// NTF initial status - Disabled
|
||||
req->ntf_cfg = PRF_CLI_STOP_NTFIND;
|
||||
req->old_batt_lvl[0] = 50;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
void app_batt_send_lvl(uint8_t batt_lvl)
|
||||
{
|
||||
ASSERT_ERR(batt_lvl <= BAS_BATTERY_LVL_MAX);
|
||||
|
||||
// Allocate the message
|
||||
struct bass_batt_level_upd_req * req = KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_REQ,
|
||||
prf_dst_task_get(TASK_ID_BASS),
|
||||
TASK_APP,
|
||||
bass_batt_level_upd_req);
|
||||
|
||||
// Fill in the parameter structure
|
||||
req->bas_instance = 0;
|
||||
req->batt_level = batt_lvl;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
static int bass_batt_level_ntf_cfg_ind_handler(ke_msg_id_t const msgid,
|
||||
struct bass_batt_level_ntf_cfg_ind const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static int batt_level_upd_handler(ke_msg_id_t const msgid,
|
||||
struct bass_batt_level_upd_rsp const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in] msgid Id of the message received.
|
||||
* @param[in] param Pointer to the parameters of the message.
|
||||
* @param[in] dest_id ID of the receiving task instance (TASK_GAP).
|
||||
* @param[in] src_id ID of the sending task instance.
|
||||
*
|
||||
* @return If the message was consumed or not.
|
||||
****************************************************************************************
|
||||
*/
|
||||
static int app_batt_msg_dflt_handler(ke_msg_id_t const msgid,
|
||||
void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
// Drop the message
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/*
|
||||
* LOCAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Default State handlers definition
|
||||
const struct ke_msg_handler app_batt_msg_handler_list[] =
|
||||
{
|
||||
// Note: first message is latest message checked by kernel so default is put on top.
|
||||
{KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_batt_msg_dflt_handler},
|
||||
|
||||
{BASS_BATT_LEVEL_NTF_CFG_IND, (ke_msg_func_t)bass_batt_level_ntf_cfg_ind_handler},
|
||||
{BASS_BATT_LEVEL_UPD_RSP, (ke_msg_func_t)batt_level_upd_handler},
|
||||
};
|
||||
|
||||
const struct app_subtask_handlers app_batt_handlers = APP_HANDLERS(app_batt);
|
||||
|
||||
#endif //BLE_APP_BATT
|
||||
|
||||
/// @} APP
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_batt.c
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // SW configuration
|
||||
|
||||
#if (BLE_APP_BATT)
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "app_batt.h" // Battery Application Module Definitions
|
||||
#include "app_task.h" // application task definitions
|
||||
#include "arch.h" // Platform Definitions
|
||||
#include "bass_msg.h" // health thermometer functions
|
||||
#include "co_bt.h"
|
||||
#include "co_utils.h"
|
||||
#include "prf.h"
|
||||
#include "prf_types.h" // Profile common types definition
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application Module Environment Structure
|
||||
struct app_batt_env_tag app_batt_env;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTION DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
void app_batt_init(void)
|
||||
{
|
||||
// Reset the environment
|
||||
memset(&app_batt_env, 0, sizeof(struct app_batt_env_tag));
|
||||
|
||||
// Initial battery level: 100
|
||||
app_batt_env.batt_lvl = 100;
|
||||
}
|
||||
|
||||
void app_batt_add_bas(void)
|
||||
{
|
||||
struct bass_db_cfg *db_cfg;
|
||||
// Allocate the BASS_CREATE_DB_REQ
|
||||
struct gapm_profile_task_add_cmd *req =
|
||||
KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP,
|
||||
gapm_profile_task_add_cmd, sizeof(struct bass_db_cfg));
|
||||
// Fill message
|
||||
req->operation = GAPM_PROFILE_TASK_ADD;
|
||||
req->sec_lvl = 0; // PERM(SVC_AUTH, AUTH);
|
||||
req->prf_api_id = TASK_ID_BASS;
|
||||
req->app_task = TASK_APP;
|
||||
req->start_hdl = 0;
|
||||
|
||||
// Set parameters
|
||||
db_cfg = (struct bass_db_cfg *)req->param;
|
||||
|
||||
// Add a BAS instance
|
||||
db_cfg->bas_nb = 1;
|
||||
// Sending of notifications is supported
|
||||
db_cfg->features[0] = BAS_BATT_LVL_NTF_SUP;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
void app_batt_enable_prf(uint8_t conidx)
|
||||
{
|
||||
app_batt_env.conidx = conidx;
|
||||
|
||||
// Allocate the message
|
||||
struct bass_enable_req *req =
|
||||
KE_MSG_ALLOC(BASS_ENABLE_REQ, prf_dst_task_get(TASK_ID_BASS), TASK_APP,
|
||||
bass_enable_req);
|
||||
|
||||
// Fill in the parameter structure
|
||||
req->conidx = conidx;
|
||||
|
||||
// NTF initial status - Disabled
|
||||
req->ntf_cfg = PRF_CLI_START_NTF;
|
||||
req->old_batt_lvl[0] = 50;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
void app_batt_send_lvl(uint8_t batt_lvl)
|
||||
{
|
||||
ASSERT_ERR(batt_lvl <= BAS_BATTERY_LVL_MAX);
|
||||
|
||||
// Allocate the message
|
||||
struct bass_batt_level_upd_req *req =
|
||||
KE_MSG_ALLOC(BASS_BATT_LEVEL_UPD_REQ, prf_dst_task_get(TASK_ID_BASS),
|
||||
TASK_APP, bass_batt_level_upd_req);
|
||||
|
||||
// Fill in the parameter structure
|
||||
req->bas_instance = 0;
|
||||
req->batt_level = batt_lvl;
|
||||
|
||||
// Send the message
|
||||
ke_msg_send(req);
|
||||
}
|
||||
|
||||
static int bass_batt_level_ntf_cfg_ind_handler(
|
||||
ke_msg_id_t const msgid, struct bass_batt_level_ntf_cfg_ind const *param,
|
||||
ke_task_id_t const dest_id, ke_task_id_t const src_id)
|
||||
{
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static int batt_level_upd_handler(ke_msg_id_t const msgid,
|
||||
struct bass_batt_level_upd_rsp const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in] msgid Id of the message received.
|
||||
* @param[in] param Pointer to the parameters of the message.
|
||||
* @param[in] dest_id ID of the receiving task instance (TASK_GAP).
|
||||
* @param[in] src_id ID of the sending task instance.
|
||||
*
|
||||
* @return If the message was consumed or not.
|
||||
****************************************************************************************
|
||||
*/
|
||||
static int app_batt_msg_dflt_handler(ke_msg_id_t const msgid, void const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
// Drop the message
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
/*
|
||||
* LOCAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Default State handlers definition
|
||||
const struct ke_msg_handler app_batt_msg_handler_list[] = {
|
||||
// Note: first message is latest message checked by kernel so default is put
|
||||
// on top.
|
||||
{KE_MSG_DEFAULT_HANDLER, (ke_msg_func_t)app_batt_msg_dflt_handler},
|
||||
|
||||
{BASS_BATT_LEVEL_NTF_CFG_IND,
|
||||
(ke_msg_func_t)bass_batt_level_ntf_cfg_ind_handler},
|
||||
{BASS_BATT_LEVEL_UPD_RSP, (ke_msg_func_t)batt_level_upd_handler},
|
||||
};
|
||||
|
||||
const struct app_subtask_handlers app_batt_handlers = APP_HANDLERS(app_batt);
|
||||
|
||||
#endif // BLE_APP_BATT
|
||||
|
||||
/// @} APP
|
||||
|
||||
@@ -1,110 +1,110 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_batt.h
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_BATT_H_
|
||||
#define APP_BATT_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @ingroup RICOW
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // SW configuration
|
||||
|
||||
#if (BLE_APP_BATT)
|
||||
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include "ke_task.h" // Kernel Task Definition
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application Module Environment Structure
|
||||
struct app_batt_env_tag
|
||||
{
|
||||
/// Connection handle
|
||||
uint8_t conidx;
|
||||
/// Current Battery Level
|
||||
uint8_t batt_lvl;
|
||||
};
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLES DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application environment
|
||||
extern struct app_batt_env_tag app_batt_env;
|
||||
|
||||
/// Table of message handlers
|
||||
extern const struct app_subtask_handlers app_batt_handlers;
|
||||
|
||||
/*
|
||||
* FUNCTIONS DECLARATION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* Health Thermometer Application Functions
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize Battery Application Module
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_init(void);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Add a Battery Service instance in the DB
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_add_bas(void);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Enable the Battery Service
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_enable_prf(uint8_t conidx);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Send a Battery level value
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_send_lvl(uint8_t batt_lvl);
|
||||
|
||||
#endif //(BLE_APP_BATT)
|
||||
|
||||
/// @} APP
|
||||
|
||||
#endif // APP_BATT_H_
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_batt.h
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_BATT_H_
|
||||
#define APP_BATT_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @ingroup RICOW
|
||||
*
|
||||
* @brief Battery Application Module entry point
|
||||
*
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // SW configuration
|
||||
|
||||
#if (BLE_APP_BATT)
|
||||
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include "ke_task.h" // Kernel Task Definition
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application Module Environment Structure
|
||||
struct app_batt_env_tag
|
||||
{
|
||||
/// Connection handle
|
||||
uint8_t conidx;
|
||||
/// Current Battery Level
|
||||
uint8_t batt_lvl;
|
||||
};
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLES DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Battery Application environment
|
||||
extern struct app_batt_env_tag app_batt_env;
|
||||
|
||||
/// Table of message handlers
|
||||
extern const struct app_subtask_handlers app_batt_handlers;
|
||||
|
||||
/*
|
||||
* FUNCTIONS DECLARATION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* Health Thermometer Application Functions
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize Battery Application Module
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_init(void);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Add a Battery Service instance in the DB
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_add_bas(void);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Enable the Battery Service
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_enable_prf(uint8_t conidx);
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Send a Battery level value
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_batt_send_lvl(uint8_t batt_lvl);
|
||||
|
||||
#endif //(BLE_APP_BATT)
|
||||
|
||||
/// @} APP
|
||||
|
||||
#endif // APP_BATT_H_
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
#if 0
|
||||
/*@TRACE*/
|
||||
enum basc_msg_id
|
||||
{
|
||||
/// Start the Battery Service Client Role - at connection
|
||||
// BASC_ENABLE_REQ = MSG_ID(BASC, 0x00),
|
||||
///Confirm that cfg connection has finished with discovery results, or that normal cnx started
|
||||
BASC_ENABLE_RSP = MSG_ID(BASC, 0x01),
|
||||
|
||||
/// Read Characteristic Value Request
|
||||
// BASC_READ_INFO_REQ = MSG_ID(BASC, 0x02),
|
||||
/// Read Characteristic Value Request
|
||||
BASC_READ_INFO_RSP = MSG_ID(BASC, 0x03),
|
||||
|
||||
/// Write Battery Level Notification Configuration Value request
|
||||
// BASC_BATT_LEVEL_NTF_CFG_REQ = MSG_ID(BASC, 0x04),
|
||||
/// Write Battery Level Notification Configuration Value response
|
||||
BASC_BATT_LEVEL_NTF_CFG_RSP = MSG_ID(BASC, 0x05),
|
||||
|
||||
/// Indicate to APP that the Battery Level value has been received
|
||||
BASC_BATT_LEVEL_IND = MSG_ID(BASC, 0x06),
|
||||
};
|
||||
#endif
|
||||
|
||||
void xc_basc_enbale_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_ENABLE_REQ
|
||||
}
|
||||
|
||||
void xc_basc_read_info_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_READ_INFO_REQ
|
||||
}
|
||||
|
||||
void xc_basc_batt_leval_ntf_cfg_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_BATT_LEVEL_NTF_CFG_REQ
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Default State handlers definition
|
||||
KE_MSG_HANDLER_TAB(basc)
|
||||
{
|
||||
// Note: all messages must be sorted in ID ascending order
|
||||
|
||||
{BASC_ENABLE_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_READ_INFO_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_BATT_LEVEL_NTF_CFG_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_BATT_LEVEL_IND, (ke_msg_func_t) xxx_handler },
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
/*@TRACE*/
|
||||
enum basc_msg_id
|
||||
{
|
||||
/// Start the Battery Service Client Role - at connection
|
||||
// BASC_ENABLE_REQ = MSG_ID(BASC, 0x00),
|
||||
///Confirm that cfg connection has finished with discovery results, or that normal cnx started
|
||||
BASC_ENABLE_RSP = MSG_ID(BASC, 0x01),
|
||||
|
||||
/// Read Characteristic Value Request
|
||||
// BASC_READ_INFO_REQ = MSG_ID(BASC, 0x02),
|
||||
/// Read Characteristic Value Request
|
||||
BASC_READ_INFO_RSP = MSG_ID(BASC, 0x03),
|
||||
|
||||
/// Write Battery Level Notification Configuration Value request
|
||||
// BASC_BATT_LEVEL_NTF_CFG_REQ = MSG_ID(BASC, 0x04),
|
||||
/// Write Battery Level Notification Configuration Value response
|
||||
BASC_BATT_LEVEL_NTF_CFG_RSP = MSG_ID(BASC, 0x05),
|
||||
|
||||
/// Indicate to APP that the Battery Level value has been received
|
||||
BASC_BATT_LEVEL_IND = MSG_ID(BASC, 0x06),
|
||||
};
|
||||
#endif
|
||||
|
||||
void xc_basc_enbale_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_ENABLE_REQ
|
||||
}
|
||||
|
||||
void xc_basc_read_info_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_READ_INFO_REQ
|
||||
}
|
||||
|
||||
void xc_basc_batt_leval_ntf_cfg_req()
|
||||
{
|
||||
//send msg
|
||||
BASC_BATT_LEVEL_NTF_CFG_REQ
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Default State handlers definition
|
||||
KE_MSG_HANDLER_TAB(basc)
|
||||
{
|
||||
// Note: all messages must be sorted in ID ascending order
|
||||
|
||||
{BASC_ENABLE_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_READ_INFO_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_BATT_LEVEL_NTF_CFG_RSP, (ke_msg_func_t) xxx_handler },
|
||||
{BASC_BATT_LEVEL_IND, (ke_msg_func_t) xxx_handler },
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +1,96 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_sec.h
|
||||
*
|
||||
* @brief Application Security Entry Point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP_SEC
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_SEC_H_
|
||||
#define APP_SEC_H_
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h"
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include <stdbool.h>
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
struct app_sec_env_tag
|
||||
{
|
||||
// Bond status
|
||||
bool bonded;
|
||||
};
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Application Security Environment
|
||||
extern struct app_sec_env_tag app_sec_env;
|
||||
|
||||
/// Table of message handlers
|
||||
extern const struct app_subtask_handlers app_sec_handlers;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTIONS DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize the Application Security Module
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_init(void);
|
||||
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Remove all bond data stored in NVDS
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_remove_bond(void);
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Send a security request to the peer device. This function is used to require the
|
||||
* central to start the encryption with a LTK that would have shared during a previous
|
||||
* bond procedure.
|
||||
*
|
||||
* @param[in] - conidx: Connection Index
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_send_security_req(uint8_t conidx);
|
||||
|
||||
|
||||
|
||||
#endif // APP_SEC_H_
|
||||
|
||||
/// @} APP_SEC
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_sec.h
|
||||
*
|
||||
* @brief Application Security Entry Point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP_SEC
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef APP_SEC_H_
|
||||
#define APP_SEC_H_
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h"
|
||||
#include <stdint.h> // Standard Integer Definition
|
||||
#include <stdbool.h>
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
struct app_sec_env_tag
|
||||
{
|
||||
// Bond status
|
||||
bool bonded;
|
||||
};
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Application Security Environment
|
||||
extern struct app_sec_env_tag app_sec_env;
|
||||
|
||||
/// Table of message handlers
|
||||
extern const struct app_subtask_handlers app_sec_handlers;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTIONS DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Initialize the Application Security Module
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_init(void);
|
||||
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Remove all bond data stored in NVDS
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_remove_bond(void);
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief Send a security request to the peer device. This function is used to require the
|
||||
* central to start the encryption with a LTK that would have shared during a previous
|
||||
* bond procedure.
|
||||
*
|
||||
* @param[in] - conidx: Connection Index
|
||||
****************************************************************************************
|
||||
*/
|
||||
void app_sec_send_security_req(uint8_t conidx);
|
||||
|
||||
|
||||
|
||||
#endif // APP_SEC_H_
|
||||
|
||||
/// @} APP_SEC
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,294 +1,700 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // RW SW configuration
|
||||
#include "xc_drv_pwr.h"
|
||||
#if (USE_ROM_FLASH)
|
||||
#include "xc6xxx_fmc_spi.h"
|
||||
#endif // (USE_ROM_FLASH)
|
||||
#include "app_task.h"
|
||||
#include "rom_port.h"
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
#include "uart.h" // UART initialization
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
|
||||
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
||||
#include "rf.h" // RF initialization
|
||||
#endif // BLE_EMB_PRESENT || BT_EMB_PRESENT
|
||||
|
||||
#if (PLF_NVDS)
|
||||
#include "nvds.h" // NVDS definitions
|
||||
#endif // PLF_NVDS
|
||||
|
||||
#include "xc6xxx.h"
|
||||
|
||||
#include "gpio.h"
|
||||
#include "xc_drv_gpio.h"
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup DRIVERS
|
||||
* @{
|
||||
*
|
||||
*
|
||||
* ****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
/// NVDS location in FLASH : 0x000E0000 (896KB (1Mo - 128KB))
|
||||
#define NVDS_FLASH_ADDRESS (0x0003F800)//((256-2)*1024)
|
||||
|
||||
/// NVDS size in RAM : 0x00010000 (128KB)
|
||||
#define NVDS_FLASH_SIZE (0x00000800)
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* MAIN FUNCTION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief RW main function.
|
||||
*
|
||||
* This function is called right after the booting process has completed.
|
||||
*
|
||||
* @return status exit status
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#define clrbit(x,y) ((x) &= ~(1<<(y)))
|
||||
#define AHB_CTL clrbit(*(uint32_t volatile*)(0x40000000+0x130),0)
|
||||
#define _TOSTRING(s) #s
|
||||
#define TOSTRING(s) _TOSTRING(s)
|
||||
|
||||
extern void clock_init(void);
|
||||
extern uint8_t ota_flag;
|
||||
void rc32k_testpin_cfg(void)
|
||||
{
|
||||
printf("rc 32k \n");
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
gpio_cfg.FunSel = GPIO_Dx;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.Pull = GPIO_PULLDOWN;
|
||||
gpio_cfg.Pin = 4;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
xc_gpio_write_pin(4, 1);
|
||||
xc_gpio_write_pin(4, 0);
|
||||
|
||||
xc_gpio_write_pin(4, 1);
|
||||
xc_gpio_write_pin(4, 0);
|
||||
|
||||
xc_gpio_fun_sel(4, GPIO_Dx);
|
||||
xc_gpio_mux_ctl(4, GPIO_Mux3); // en test_pin[0]
|
||||
*((uint32_t volatile *)0x40000174) = 26;
|
||||
}
|
||||
|
||||
void flash_init()
|
||||
{
|
||||
FMC_SPI_Init_Oprt();
|
||||
FMC_SPI_Flash_WakeUp();
|
||||
|
||||
uint32_t mid = 0;
|
||||
FMC_SPI_Flash_RDID((uint8_t *)&mid);
|
||||
LOGI("Flash RDID: 0x%08x\n", mid);
|
||||
|
||||
uint8_t ruid[16];
|
||||
FMC_SPI_Flash_RUID(ruid);
|
||||
LOGI("Flash RUID11: ");
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
LOGI("%02x ", ruid[i]);
|
||||
}
|
||||
LOGI("\n");
|
||||
}
|
||||
|
||||
void app_uart_init(void)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.FunSel = UART0_TX;
|
||||
|
||||
gpio_cfg.Pin = GPIO_18;
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.FunSel = UART0_RX;
|
||||
gpio_cfg.Pin = GPIO_19;
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_STOP_1_BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_115200;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(UART0_IDX, &uart_cfg);
|
||||
}
|
||||
|
||||
/* Zero the host global variable. */
|
||||
void rom_env_host_init()
|
||||
{
|
||||
uint8_t *ptr = 0x10001400;
|
||||
memset(ptr, 0, 0x10004700 - 0x10001400); //ram code 需要手动搬移
|
||||
|
||||
ptr = (uint32_t *)(0x10000800);
|
||||
memset(ptr, 0, 0x10001300 - 0x10000800);
|
||||
|
||||
rom_env.stack_printf = printf;
|
||||
rom_env.stack_printf("%s %d\n", __func__, __LINE__);
|
||||
}
|
||||
|
||||
/* Add a protection field to determine if the stack is overflowing. */
|
||||
void stack_tag()
|
||||
{
|
||||
uint32_t StackPos;
|
||||
__IO uint32_t *pStack;
|
||||
StackPos = __get_MSP();
|
||||
printf("StackPos=0x%x\n", StackPos);
|
||||
// 0x800 is the size of the stack, which should be changed according to the configuration of the project.
|
||||
pStack = (uint32_t *)(StackPos - 0x800);
|
||||
*pStack = 0xa5a5a5a5;
|
||||
}
|
||||
|
||||
void board_init()
|
||||
{
|
||||
clock_init();
|
||||
app_uart_init();
|
||||
LOGI("sdk version: %s build time: %s %s\n", TOSTRING(SDK_VERSION), __DATE__, __TIME__);
|
||||
|
||||
stack_tag();
|
||||
rom_env_host_init();
|
||||
#if (SLEEP_ENABLE)
|
||||
xc_rc32k_calib_by_hw();
|
||||
//xc_rc32k_calib_by_soft();
|
||||
#endif // (SLEEP_ENABLE)
|
||||
rom_env_init();
|
||||
uint8_t mac_addr[] = {0xac, 0xc3, 0x33, 0x46, 0x55, 0x66};
|
||||
memcpy(co_default_bdaddr.addr, mac_addr, 6);
|
||||
AHB_CTL;
|
||||
/*
|
||||
************************************************************************************
|
||||
* Platform initialization
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
// Initialize random process
|
||||
srand(1);
|
||||
}
|
||||
|
||||
void bluetooth_init()
|
||||
{
|
||||
uint32_t error = RESET_NO_ERROR;
|
||||
#if (PLF_NVDS)
|
||||
flash_init();
|
||||
// Initialize NVDS module
|
||||
nvds_init((uint8_t *)NVDS_FLASH_ADDRESS, NVDS_FLASH_SIZE);
|
||||
#endif // PLF_NVDS
|
||||
/*
|
||||
************************************************************************************
|
||||
* RW SW stack initialization
|
||||
************************************************************************************
|
||||
*/
|
||||
NVIC_SetPriority((IRQn_Type)BLE_IRQn, 0);
|
||||
NVIC_EnableIRQ((IRQn_Type)BLE_IRQn);
|
||||
#if (!HCI_TEST_NO_IP)
|
||||
// Initialize modem
|
||||
modem_init();
|
||||
#endif
|
||||
// Initialize RF
|
||||
#if (BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
||||
rf_init(&rwip_rf);
|
||||
#endif //BT_EMB_PRESENT || BLE_EMB_PRESENT
|
||||
// Initialize RW SW stack
|
||||
rwip_init(error);
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
enter_test_mode();
|
||||
#else // (BLE_TEST_MODE_SUPPORT)
|
||||
// Initialize APP
|
||||
app_init();
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
// finally start interrupt handling
|
||||
GLOBAL_INT_START();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Set the broadcast address of the device. */
|
||||
board_init();
|
||||
bluetooth_init();
|
||||
|
||||
|
||||
app_ir_init();
|
||||
app_key_init();
|
||||
// app_pga_init();
|
||||
// delay_ms(1);//Wait for the pga to stabilize
|
||||
|
||||
//app_audio_record_init();
|
||||
|
||||
app_pwm_init();
|
||||
timer0_2_init();
|
||||
#if (SLEEP_ENABLE)
|
||||
// sleep_init();
|
||||
#endif // (SLEEP_ENABLE)
|
||||
// rc32k_testpin_cfg();
|
||||
#if (BLE_APP_PRESENT)
|
||||
// rf_test_pin_init();
|
||||
|
||||
while (1)
|
||||
{
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // RW SW configuration
|
||||
#include "xc_drv_pwr.h"
|
||||
#if (USE_ROM_FLASH)
|
||||
#include "xc6xxx_fmc_spi.h"
|
||||
#endif // (USE_ROM_FLASH)
|
||||
#include "app_task.h"
|
||||
#include "rom_port.h"
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
#include "uart.h" // UART initialization
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
|
||||
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
||||
#include "rf.h" // RF initialization
|
||||
#endif // BLE_EMB_PRESENT || BT_EMB_PRESENT
|
||||
|
||||
#if (PLF_NVDS)
|
||||
#include "nvds.h" // NVDS definitions
|
||||
#endif // PLF_NVDS
|
||||
|
||||
#include "core_cm0.h"
|
||||
#include "xc6xxx.h"
|
||||
#include "xc6xxx_fmc_spi.h"
|
||||
#include "xc_drv_fmc_spi.h"
|
||||
#include "sleep.h"
|
||||
#include "ota_protocol.h"
|
||||
#include "mcu_bridge.h"
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup DRIVERS
|
||||
* @{
|
||||
*
|
||||
*
|
||||
* ****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFINES
|
||||
****************************************************************************************
|
||||
*/
|
||||
/// NVDS location in FLASH : 0x000E0000 (896KB (1Mo - 128KB))
|
||||
#define NVDS_FLASH_ADDRESS (0x0003F800) //((256-2)*1024)
|
||||
|
||||
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* MAIN FUNCTION
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief RW main function.
|
||||
*
|
||||
* This function is called right after the booting process has completed.
|
||||
*
|
||||
* @return status exit status
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#define clrbit(x, y) ((x) &= ~(1 << (y)))
|
||||
#define AHB_CTL clrbit(*(uint32_t volatile *)(0x40000000 + 0x130), 0)
|
||||
#define _TOSTRING(s) #s
|
||||
#define TOSTRING(s) _TOSTRING(s)
|
||||
|
||||
extern void clock_init(void);
|
||||
#if !FAST_OTA
|
||||
extern uint8_t ota_flag;
|
||||
#endif
|
||||
void flash_init()
|
||||
{
|
||||
uint32_t mid = 0;
|
||||
uint32_t flash_size;
|
||||
uint16_t flash_type;
|
||||
xc_fmc_spi_init_oprt();
|
||||
xc_fmc_spi_flash_wake_up();
|
||||
|
||||
xc_fmc_spi_flash_rdid((uint8_t *)&mid);
|
||||
LOGI("Flash RDID: 0x%08x\n", mid);
|
||||
|
||||
uint8_t ruid[16];
|
||||
xc_fmc_spi_flash_ruid(ruid);
|
||||
LOGI("Flash RUID11: ");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
LOGI("%02x ", ruid[i]);
|
||||
}
|
||||
LOGI("\n");
|
||||
#if (PLF_NVDS)
|
||||
if (false == flash_size_and_type_get(&flash_size, &flash_type)) {
|
||||
LOGI("Flash Memory size Get ERROR ! ");
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
nvds_space_init(flash_size);
|
||||
#endif
|
||||
// if chip unique get failed,then use flash RUID
|
||||
if (false == xc_unique_identification_read(co_default_bdaddr.addr)) {
|
||||
// int iter = 0;
|
||||
LOGI("The chip does not have unique , then use flash RUID\n");
|
||||
memset(co_default_bdaddr.addr, 0, 6);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
co_default_bdaddr.addr[i % 6] += ruid[i];
|
||||
}
|
||||
}
|
||||
|
||||
LOGI("mac addr: %02x %02x %02x %02x %02x %02x\n", co_default_bdaddr.addr[0],
|
||||
co_default_bdaddr.addr[1], co_default_bdaddr.addr[2],
|
||||
co_default_bdaddr.addr[3], co_default_bdaddr.addr[4],
|
||||
co_default_bdaddr.addr[5]);
|
||||
}
|
||||
|
||||
void app_uart_init(void)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.FunSel = UART0_TX;
|
||||
|
||||
gpio_cfg.Pin = GPIO_18;
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.FunSel = UART0_RX;
|
||||
gpio_cfg.Pin = GPIO_19;
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_STOP_1_BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_115200;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(UART0_IDX, &uart_cfg);
|
||||
}
|
||||
|
||||
void wdt_init(void)
|
||||
{
|
||||
#if XTAL_32K
|
||||
WDT_InitCfg_t wdt_cfg ;
|
||||
|
||||
wdt_cfg.WorkMode = WDT_WORK_MODE1;
|
||||
wdt_cfg.ReloadValue = WDT_CLK_32M_RESET_MODE1_2097152US;
|
||||
wdt_cfg.PclkSel = WDT_WORK_32M;
|
||||
xc_ext32k_wdt_init(&wdt_cfg);
|
||||
xc_ext32k_wdt_start();
|
||||
NVIC_EnableIRQ(WDT_IRQn);
|
||||
#else
|
||||
|
||||
WDT_InitCfg_t wdt_cfg ;
|
||||
|
||||
wdt_cfg.WorkMode = WDT_WORK_MODE0;
|
||||
wdt_cfg.ReloadValue = WDT_CLK_32K_RESET_MODE0_2048MS;
|
||||
wdt_cfg.PclkSel = WDT_WORK_32K;
|
||||
xc_wdt_init(&wdt_cfg);
|
||||
xc_wdt_start();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Zero the host global variable. */
|
||||
void rom_env_host_init()
|
||||
{
|
||||
uint32_t *ptr = (uint32_t *)(0x10000800);
|
||||
memset(ptr, 0, 0x10001300 - 0x10000800);
|
||||
|
||||
rom_env.stack_printf = printf;
|
||||
}
|
||||
|
||||
/* Add a protection field to determine if the stack is overflowing. */
|
||||
void stack_tag()
|
||||
{
|
||||
uint32_t StackPos;
|
||||
__IO uint32_t *pStack;
|
||||
StackPos = __get_MSP();
|
||||
printf("StackPos=0x%x\n", StackPos);
|
||||
// 0x800 is the size of the stack, which should be changed according to the
|
||||
// configuration of the project.
|
||||
pStack = (uint32_t *)(StackPos - 0x800);
|
||||
*pStack = 0xa5a5a5a5;
|
||||
}
|
||||
|
||||
void board_init()
|
||||
{
|
||||
clock_init();
|
||||
app_uart_init();
|
||||
#if (POWER_ON)
|
||||
power_on_check();
|
||||
#endif // (POWER_ON)
|
||||
LOGI("sdk version: %s build time: %s %s\n", TOSTRING(SDK_VERSION), __DATE__,
|
||||
__TIME__);
|
||||
// stack_tag();
|
||||
rom_env_host_init();
|
||||
#if (SLEEP_ENABLE)
|
||||
#if XTAL_32K
|
||||
#else
|
||||
// xc_rc32k_calib_by_hw();
|
||||
xc_rc32k_calib_by_soft();
|
||||
#endif// (XTAL_32K)
|
||||
#endif // (SLEEP_ENABLE)
|
||||
rom_env_init();
|
||||
AHB_CTL;
|
||||
/*
|
||||
************************************************************************************
|
||||
* Platform initialization
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
// // Initialize random process
|
||||
// srand(1);
|
||||
}
|
||||
|
||||
void bluetooth_init()
|
||||
{
|
||||
uint32_t error = RESET_NO_ERROR;
|
||||
#if (PLF_NVDS)
|
||||
flash_init();
|
||||
// Initialize NVDS module
|
||||
nvds_init(NVDS_FLASH_SIZE);
|
||||
#endif // PLF_NVDS
|
||||
/*
|
||||
************************************************************************************
|
||||
* RW SW stack initialization
|
||||
************************************************************************************
|
||||
*/
|
||||
NVIC_SetPriority((IRQn_Type)BLE_IRQn, 0);
|
||||
NVIC_EnableIRQ((IRQn_Type)BLE_IRQn);
|
||||
#if (!HCI_TEST_NO_IP)
|
||||
// Initialize modem
|
||||
modem_init();
|
||||
#endif
|
||||
// Initialize RF
|
||||
#if (BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
||||
rf_init(&rwip_rf);
|
||||
#endif // BT_EMB_PRESENT || BLE_EMB_PRESENT
|
||||
// Initialize RW SW stack
|
||||
rwip_init(error);
|
||||
|
||||
uint32_t seed;
|
||||
rwip_time_t current_time = rwip_time_get();
|
||||
seed = current_time.hs;
|
||||
seed += current_time.hus;
|
||||
//Init the random seed
|
||||
co_random_init(seed);
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
enter_test_mode();
|
||||
#else // (BLE_TEST_MODE_SUPPORT)
|
||||
// Initialize APP
|
||||
app_init();
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
// finally start interrupt handling
|
||||
GLOBAL_INT_START();
|
||||
}
|
||||
|
||||
extern uint8_t adv_evt_start ; // adv event
|
||||
extern uint8_t evt_start ; // conn event
|
||||
extern volatile uint8_t sv_lock;
|
||||
extern volatile uint8_t sv_txlen;
|
||||
|
||||
#if defined(USE_64M_CRYSTAL)
|
||||
#include "reg_ipcore.h"
|
||||
#define EVT_TX_EN (0x1)
|
||||
#define EVT_RX_EN (0x2)
|
||||
uint32_t fra_base = 0x4b1; // 0x4b1
|
||||
uint32_t fra_rx_base = 0x4b0; // 0x4b1
|
||||
uint32_t cur_channel;
|
||||
__RAM_CODE void tx_channel(void)
|
||||
{
|
||||
uint32_t new_val = fra_base;
|
||||
*((uint32_t volatile *)0x53022050) = new_val;
|
||||
*((uint32_t volatile *)0x53022064) = *((uint32_t volatile *)0x53022064) & (~(1 << 31));
|
||||
}
|
||||
|
||||
__RAM_CODE void rx_channel(uint8_t channel)
|
||||
{
|
||||
uint8_t ch_sel_ofst = 0;
|
||||
// ��������Ҫ��ƫ�ƣ�Ӳ���Զ���
|
||||
switch (channel)
|
||||
{
|
||||
case 37:
|
||||
ch_sel_ofst = 0;
|
||||
break;
|
||||
case 38:
|
||||
ch_sel_ofst = 12;
|
||||
break;
|
||||
case 39:
|
||||
ch_sel_ofst = 39;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (channel <= 10)
|
||||
{
|
||||
ch_sel_ofst = channel + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch_sel_ofst = channel + 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint32_t new_val = fra_rx_base + ch_sel_ofst;
|
||||
*((uint32_t volatile *)0x53022064) = ((new_val << 16) | 0x80008000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
__RAM_CODE void PendSV_Handler(void)
|
||||
{
|
||||
|
||||
ip_diagcntl_pack(0, 0, 1, 0x38, 1, 0x3, 1, 0x20);
|
||||
if (adv_evt_start)
|
||||
{ // adv event
|
||||
#if (ADV_EVENT_NOT_RUN_XIP == 1)
|
||||
#if defined(USE_64M_CRYSTAL)
|
||||
tx_channel();
|
||||
while (!sv_lock)
|
||||
{
|
||||
uint8_t val1 = ip_diagstat_diag1stat_getf();
|
||||
// tx
|
||||
if ((val1 & 0x01))
|
||||
{
|
||||
*((uint32_t volatile *)0x53022064) = *((uint32_t volatile *)0x53022064) & (~(1 << 31));
|
||||
while (val1 & 0x01)
|
||||
{
|
||||
val1 = ip_diagstat_diag1stat_getf();
|
||||
}
|
||||
uint8_t val2 = ip_diagstat_diag2stat_getf() & 0x3f;
|
||||
rx_channel(val2);
|
||||
}
|
||||
// rx
|
||||
if ((val1 & 0x02))
|
||||
{
|
||||
uint8_t val2 = ip_diagstat_diag2stat_getf() & 0x3f;
|
||||
rx_channel(val2);
|
||||
}
|
||||
}
|
||||
#else
|
||||
while (!sv_lock)
|
||||
;
|
||||
#endif
|
||||
#endif // (ADV_EVENT_NOT_RUN_XIP ==1)
|
||||
}
|
||||
else if (evt_start)
|
||||
{ // conn event
|
||||
#if defined(USE_64M_CRYSTAL)
|
||||
uint8_t val1 = 0;
|
||||
uint8_t val2 = ip_diagstat_diag2stat_getf() & 0x3f;
|
||||
rx_channel(val2);
|
||||
*((uint32_t volatile*)0x40000178) = 11;
|
||||
GLOBAL_INT_DISABLE();
|
||||
|
||||
while (1)
|
||||
{
|
||||
cur_channel = (ip_diagstat_diag2stat_getf() & 0x3f);
|
||||
if (val2 != cur_channel)
|
||||
{
|
||||
rx_channel(cur_channel);
|
||||
break;
|
||||
}
|
||||
uint8_t val1 = ip_diagstat_diag1stat_getf();
|
||||
if ((val1 & 0x02))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
GLOBAL_INT_RESTORE();
|
||||
// ��rx_en �� tx_en ���½������л�
|
||||
|
||||
// while (!sv_lock)
|
||||
// {
|
||||
// uint8_t tx_rx_en = 0;
|
||||
// GLOBAL_INT_DISABLE();
|
||||
// tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
// GLOBAL_INT_RESTORE();
|
||||
// if (tx_rx_en & EVT_RX_EN)
|
||||
// {
|
||||
// while (tx_rx_en & EVT_RX_EN)
|
||||
// {
|
||||
// GLOBAL_INT_DISABLE();
|
||||
// tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
// GLOBAL_INT_RESTORE();
|
||||
// }
|
||||
// GLOBAL_INT_DISABLE();
|
||||
// // xc_gpio_write_pin(4, 1);
|
||||
// *((uint32_t volatile *)0x53022064) = *((uint32_t volatile *)0x53022064) & (~(1 << 31));
|
||||
// // xc_gpio_write_pin(4, 0);
|
||||
// GLOBAL_INT_RESTORE();
|
||||
// // tx ��delay��
|
||||
// // NVIC_SetPriority((IRQn_Type)PendSV_IRQn, 0x1);
|
||||
// // tx delay��
|
||||
// }
|
||||
|
||||
// if (tx_rx_en & EVT_TX_EN)
|
||||
// {
|
||||
// while (tx_rx_en & EVT_TX_EN)
|
||||
// {
|
||||
// tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
// }
|
||||
// for (int i = 0; i < 10; i++)
|
||||
// ; // must delay
|
||||
// rx_channel(cur_channel);
|
||||
// }
|
||||
// }
|
||||
#else
|
||||
while (!sv_lock)
|
||||
;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__RAM_CODE void tx_rx_freq()
|
||||
{
|
||||
uint8_t tx_rx_en = 0;
|
||||
tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
if (tx_rx_en & EVT_RX_EN){
|
||||
*((uint32_t volatile*)0x40000178) = 10;
|
||||
}
|
||||
|
||||
if (tx_rx_en & EVT_TX_EN){
|
||||
*((uint32_t volatile*)0x40000178) = 11;
|
||||
}
|
||||
|
||||
if (evt_start){
|
||||
|
||||
#if 1
|
||||
if (tx_rx_en & EVT_RX_EN)
|
||||
{
|
||||
// xc_gpio_write_pin(8,1);
|
||||
while (tx_rx_en & EVT_RX_EN)
|
||||
{
|
||||
GLOBAL_INT_DISABLE();
|
||||
tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
GLOBAL_INT_DISABLE();
|
||||
*((uint32_t volatile *)0x53022064) = *((uint32_t volatile *)0x53022064) & (~(1 << 31));
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
|
||||
if (tx_rx_en & EVT_TX_EN)
|
||||
{
|
||||
// xc_gpio_write_pin(9,1);
|
||||
while (tx_rx_en & EVT_TX_EN)
|
||||
{
|
||||
tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
}
|
||||
for (volatile i = 0; i < 10; i++)
|
||||
; // must delay
|
||||
rx_channel(cur_channel);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (tx_rx_en & EVT_TX_EN)
|
||||
{
|
||||
*((uint32_t volatile *)0x53022064) = *((uint32_t volatile *)0x53022064) & (~(1 << 31));
|
||||
while (tx_rx_en & EVT_TX_EN)
|
||||
{
|
||||
tx_rx_en = ip_diagstat_diag1stat_getf();
|
||||
}
|
||||
for (int i = 0; i < 10; i++)
|
||||
; // must delay
|
||||
rx_channel(cur_channel);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define __write_hw_reg32(reg,val) ((*reg) = (val))
|
||||
#define __read_hw_reg32(reg, val) ((val) = (*reg))
|
||||
|
||||
#define CPR_CTLAPBCLKEN_GRCTL ((volatile unsigned *)(0x40000000 + 0x070))
|
||||
#define CPR_AOCLKEN_GRCTL ((volatile unsigned *)( 0x40002400 + 0x7C))
|
||||
#define AO_GPIO_MODE ((volatile unsigned *)(0x40002000 + 0x0044))
|
||||
#define AO_GPIO_CTL ((volatile unsigned *)(0x40002000 + 0x0048))
|
||||
|
||||
void Init_rtc_gpio(uint32_t num,uint8_t inter_mode)
|
||||
{
|
||||
uint32_t val;
|
||||
// if(!((inter_mode>=0x08) &&(inter_mode<=0x0c))) return;
|
||||
__write_hw_reg32(CPR_CTLAPBCLKEN_GRCTL, 0x20002);
|
||||
__write_hw_reg32(CPR_AOCLKEN_GRCTL, 0x20002);
|
||||
|
||||
__read_hw_reg32(AO_GPIO_MODE , val);
|
||||
val &= ~(0x0f<<(num<<2));
|
||||
val |= (inter_mode<<(num<<2));
|
||||
__write_hw_reg32(AO_GPIO_MODE, val);
|
||||
|
||||
__read_hw_reg32(AO_GPIO_CTL , val);
|
||||
val |= (1<<(8+num));
|
||||
__write_hw_reg32(AO_GPIO_CTL, val);
|
||||
// rtc_ao_gpio_mode__aogpio_debounce_en3__setf(1);
|
||||
NVIC_SetPriority(RTC_IRQn, 0x0);
|
||||
NVIC_EnableIRQ(RTC_IRQn);
|
||||
}
|
||||
#else
|
||||
#if ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1))
|
||||
__RAM_CODE void PendSV_Handler(void)
|
||||
{
|
||||
if(adv_evt_start){ // adv event
|
||||
#if (ADV_EVENT_NOT_RUN_XIP ==1)
|
||||
while (!sv_lock)
|
||||
;
|
||||
#endif // (ADV_EVENT_NOT_RUN_XIP ==1)
|
||||
}else if(evt_start){ // conn event
|
||||
#if (CONN_EVENT_NOT_RUN_XIP == 0)
|
||||
uint32_t nus = sv_txlen * 8 + 148;
|
||||
uint32_t unit = 32;
|
||||
uint32_t temp;
|
||||
|
||||
SysTick->CTRL = 0x00;
|
||||
SysTick->LOAD = unit * nus - unit + 1;
|
||||
|
||||
SysTick->VAL = 0;
|
||||
SysTick->CTRL = 0x05;
|
||||
|
||||
do {
|
||||
temp = SysTick->CTRL;
|
||||
if (sv_lock) {
|
||||
break;
|
||||
}
|
||||
} while ((temp & 0x01) && (!(temp & (1 << 16))));
|
||||
#endif // (CONN_EVENT_NOT_RUN_XIP == 0)
|
||||
|
||||
#if (CONN_EVENT_NOT_RUN_XIP == 1)
|
||||
while (!sv_lock)
|
||||
;
|
||||
#endif // (CONN_EVENT_NOT_RUN_XIP == 1)
|
||||
}
|
||||
|
||||
}
|
||||
#endif // ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1))
|
||||
#endif // defined(USE_64M_CRYSTAL)
|
||||
#if (CONFIG_BT_WAKEUP_VIA_GPIO)
|
||||
void gpio_intr_callback(uint64_t intr_sta)
|
||||
{
|
||||
uint32_t value = ((*(volatile uint32_t *)(0x53022044)));
|
||||
|
||||
value |= 1 << 14;
|
||||
((*(volatile uint32_t *)(0x53022044))) = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONN_EVENT_NOT_RUN_XIP == 3)
|
||||
|
||||
#define __write_hw_reg32(reg,val) ((*reg) = (val))
|
||||
#define __read_hw_reg32(reg, val) ((val) = (*reg))
|
||||
|
||||
#define CPR_CTLAPBCLKEN_GRCTL ((volatile unsigned *)(0x40000000 + 0x070))
|
||||
#define CPR_AOCLKEN_GRCTL ((volatile unsigned *)( 0x40002400 + 0x7C))
|
||||
#define AO_GPIO_MODE ((volatile unsigned *)(0x40002000 + 0x0044))
|
||||
#define AO_GPIO_CTL ((volatile unsigned *)(0x40002000 + 0x0048))
|
||||
|
||||
void Init_rtc_gpio(uint32_t num,uint8_t inter_mode)
|
||||
{
|
||||
uint32_t val;
|
||||
// if(!((inter_mode>=0x08) &&(inter_mode<=0x0c))) return;
|
||||
__write_hw_reg32(CPR_CTLAPBCLKEN_GRCTL, 0x20002);
|
||||
__write_hw_reg32(CPR_AOCLKEN_GRCTL, 0x20002);
|
||||
|
||||
__read_hw_reg32(AO_GPIO_MODE , val);
|
||||
val &= ~(0x0f<<(num<<2));
|
||||
val |= (inter_mode<<(num<<2));
|
||||
__write_hw_reg32(AO_GPIO_MODE, val);
|
||||
|
||||
__read_hw_reg32(AO_GPIO_CTL , val);
|
||||
val |= (1<<(8+num));
|
||||
__write_hw_reg32(AO_GPIO_CTL, val);
|
||||
// rtc_ao_gpio_mode__aogpio_debounce_en3__setf(1);
|
||||
NVIC_SetPriority(RTC_IRQn, 0x0);
|
||||
NVIC_EnableIRQ(RTC_IRQn);
|
||||
}
|
||||
|
||||
#include "reg_ipcore.h"
|
||||
#define EVT_TX_EN (0x1)
|
||||
#define EVT_RX_EN (0x2)
|
||||
__RAM_CODE void tx_on_delay()
|
||||
{
|
||||
|
||||
uint8_t tx_rx_en = 0;
|
||||
tx_rx_en = ip_diagstat_diag0stat_getf();
|
||||
if (tx_rx_en & EVT_TX_EN){
|
||||
while(tx_rx_en & EVT_TX_EN){
|
||||
tx_rx_en = ip_diagstat_diag0stat_getf();
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // (CONN_EVENT_NOT_RUN_XIP == 3)
|
||||
|
||||
void ble_tx_rx_on_irq_config()
|
||||
{
|
||||
#if (defined(USE_64M_CRYSTAL) || defined(NOT_RUN_XIP_TX_ONLY))
|
||||
writel(0x53022040, 0);
|
||||
// xc_gpio_fun_sel(3,0);
|
||||
// xc_gpio_mux_ctl(3,3); // en test_pin[0]
|
||||
// *((uint32_t volatile*)0x40000170) = 0;
|
||||
xc_gpio_fun_sel(GPIO_2,0);
|
||||
xc_gpio_mux_ctl(GPIO_2,1); // en test_pin[1]
|
||||
*((uint32_t volatile*)0x40000178) = 10;
|
||||
#if defined(NOT_RUN_XIP_TX_ONLY)
|
||||
*((uint32_t volatile*)0x40000178) = 0;
|
||||
|
||||
#endif // defined(NOT_RUN_XIP_TX_ONLY)
|
||||
xc_pwr_pwrkey_init();
|
||||
Init_rtc_gpio(GPIO_2,0x00);
|
||||
#endif // (defined(USE_64M_CRYSTAL) || defined(NOT_RUN_XIP_TX_ONLY))
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
wdt_init();
|
||||
/* Set the broadcast address of the device. */
|
||||
board_init();
|
||||
bluetooth_init();
|
||||
|
||||
#if (SLEEP_ENABLE)
|
||||
//lvr bor_intr
|
||||
cprao_aon_bor_ctr_reg0__bor_ctrl__setf(0x0);
|
||||
cprao_aon_bor_ctr_reg0__bor_rstn_mask__setf(1);
|
||||
cprao_aon_bor_ctr_reg0__bor_intr_mask__setf(0);
|
||||
NVIC_EnableIRQ(MPU_IRQn);
|
||||
#endif // (SLEEP_ENABLE)
|
||||
|
||||
#if ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1) || defined(USE_64M_CRYSTAL))
|
||||
NVIC_SetPriority(PendSV_IRQn, 0xff);
|
||||
NVIC_EnableIRQ(PendSV_IRQn);
|
||||
#endif // ((ADV_EVENT_NOT_RUN_XIP ==1) || (CONN_EVENT_NOT_RUN_XIP == 0) || (CONN_EVENT_NOT_RUN_XIP == 1) || defined(USE_64M_CRYSTAL))
|
||||
|
||||
#if (CONFIG_BT_WAKEUP_VIA_GPIO)
|
||||
uint32_t value = ((*(volatile uint32_t *)(0x53022044)));
|
||||
value |= 1 << 12;
|
||||
((*(volatile uint32_t *)(0x53022044))) = value;
|
||||
#endif // (CONFIG_BT_WAKEUP_VIA_GPIO)
|
||||
#if (SLEEP_ENABLE)
|
||||
sleep_init();
|
||||
#endif // (SLEEP_ENABLE)
|
||||
ble_tx_rx_on_irq_config();
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
while (1) {
|
||||
// schedule all pending events
|
||||
rwip_schedule();
|
||||
xc_ota_schedule();
|
||||
// LOGI("GAPM_DEV_BDADDR_IND\r\n");
|
||||
#if (SLEEP_ENABLE)
|
||||
if (!ota_flag)
|
||||
{
|
||||
// sleep_schedule();
|
||||
// feedback();
|
||||
}
|
||||
#endif // (SLEEP_ENABLE)
|
||||
//用户应用程序
|
||||
// scan_uart();
|
||||
ble_message_process();//BLE接收信息处理
|
||||
ir_message_process();//ir遥控按键处理
|
||||
key_message_process(app_key_message_get());//按键检测处理
|
||||
app_record_process();//ADC_MIC检测处理
|
||||
}
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
}
|
||||
|
||||
/// @} DRIVERS
|
||||
mcu_bridge_process();
|
||||
#if !FAST_OTA
|
||||
xc_ota_schedule();
|
||||
#endif
|
||||
#if OTA_AES_USED
|
||||
process_aes_decrypt();
|
||||
#endif
|
||||
#if (SLEEP_ENABLE)
|
||||
#if !FAST_OTA
|
||||
if (!ota_flag)
|
||||
#endif
|
||||
{
|
||||
sleep_schedule();
|
||||
}
|
||||
#endif // (SLEEP_ENABLE)
|
||||
|
||||
xc_wdt_reload(); //TOOD
|
||||
|
||||
}
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
}
|
||||
|
||||
/// @} DRIVERS
|
||||
|
||||
@@ -0,0 +1,380 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_ota.c
|
||||
*
|
||||
* @brief Custom ota.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#if FAST_OTA
|
||||
#include "fast_ota.h"
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
#include "ota_protocol.h"
|
||||
#include "ota_flash_interface.h"
|
||||
#include "aes.h"
|
||||
#if (BLE_APP_PRESENT)
|
||||
|
||||
static volatile uint16_t write_index = 0;
|
||||
static volatile uint32_t aes_index_at = 0;
|
||||
static volatile uint32_t write_index_all = 0;
|
||||
static volatile uint32_t should_recived_length = 0;
|
||||
static volatile uint32_t app_start_addr = 0;
|
||||
static volatile uint16_t last_erase_block = 0;
|
||||
static volatile uint32_t header_app_crc32 = 0;
|
||||
static ota_process_state_t process_sta = OTA_PROCESS_SEARCH_HEADER;
|
||||
static uint8_t head_data_temp[256] ={0};
|
||||
__attribute__((aligned(4))) __RAM_EM uint8_t write_buffer[NVDS_FLASH_SIZE+247];
|
||||
|
||||
|
||||
|
||||
#if OTA_AES_USED
|
||||
__attribute__((aligned(4))) uint8_t data_save_buffer[ASE_DATA_BUFFER_SIZE];
|
||||
static volatile uint16_t data_save_index = 0;
|
||||
static volatile uint16_t aes_decrypt_index = 0;
|
||||
static volatile uint8_t aes_decrypt_run = 1;
|
||||
uint8_t AES_KEY[16] = OTA_AES_KEY;
|
||||
#endif
|
||||
|
||||
extern __RAM_CODE void FMC_SPI_Flash_ReadPage(uint32_t ReadAddr, uint8_t *data, uint16_t size);
|
||||
extern __RAM_CODE void xc_fmc_spi_flash_erase_page(uint32_t addr);
|
||||
extern __RAM_CODE void xc_fmc_spi_flash_write_page(uint32_t addr, uint8_t *data, uint16_t size);
|
||||
void ota_state_restore(void){
|
||||
write_index =0;
|
||||
aes_index_at = 0;
|
||||
write_index_all = 0;
|
||||
should_recived_length = 0;
|
||||
app_start_addr = 0;
|
||||
last_erase_block = 0;
|
||||
header_app_crc32 =0;
|
||||
process_sta = OTA_PROCESS_SEARCH_HEADER;
|
||||
memset(head_data_temp,0,256);
|
||||
|
||||
//aes
|
||||
#if OTA_AES_USED
|
||||
data_save_index = 0;
|
||||
aes_decrypt_index = 0;
|
||||
aes_decrypt_run = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t *get_fota_env_addr(uint16_t len)
|
||||
{
|
||||
if (len > sizeof(write_buffer)) {
|
||||
LOGI(" len error\n ");
|
||||
return NULL;
|
||||
}
|
||||
return (uint8_t *)(&write_buffer);
|
||||
}
|
||||
|
||||
|
||||
unsigned int get_crc32(unsigned int crc, unsigned char *buf, unsigned int len) {
|
||||
const unsigned char *buffer = (const unsigned char *)buf;
|
||||
int i = 0;
|
||||
while (len--) {
|
||||
crc ^= (unsigned int)(*buffer++) << 24;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (crc & 0x80000000) {
|
||||
crc = (crc << 1) ^ 0xEDB88320;
|
||||
} else {
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
uint32_t calc_crc32(uint32_t addr, uint32_t len)
|
||||
{
|
||||
uint8_t buff[FLASH_PAGE_SIZE];
|
||||
uint32_t size;
|
||||
|
||||
uint32_t crc = CRC32_INITIAL;
|
||||
|
||||
GLOBAL_INT_DISABLE();
|
||||
while(len > 0)
|
||||
{
|
||||
size = (len > FLASH_PAGE_SIZE)? FLASH_PAGE_SIZE : len;
|
||||
FMC_SPI_Flash_ReadPage(addr, buff, FLASH_PAGE_SIZE);
|
||||
crc = get_crc32(crc, buff, size);
|
||||
addr += size;
|
||||
len -= size;
|
||||
// for(uint16_t i = 0;i<256;i++)
|
||||
// {
|
||||
// LOGI("%02x ",buff[i]);
|
||||
// }
|
||||
// LOGI("\r\n");
|
||||
// LOGI("crc:%x \r\n",crc);
|
||||
}
|
||||
GLOBAL_INT_RESTORE();
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
uint32_t calc_crc32_head(uint8_t *buff, uint32_t len)
|
||||
{
|
||||
uint32_t size;
|
||||
uint32_t crc = CRC32_INITIAL;
|
||||
while(len > 0)
|
||||
{
|
||||
size = (len > FLASH_PAGE_SIZE)? FLASH_PAGE_SIZE : len;
|
||||
crc = get_crc32(crc, buff, size);
|
||||
len -= size;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
//erase code flash if header vailed is true
|
||||
bool app_header_vailed(uint8_t *app_image_header,uint8_t *data) {
|
||||
uint32_t head_crc=(app_image_header[243+8]<<24)+(app_image_header[242+8]<<16)+(app_image_header[241+8]<<8)+(app_image_header[240+8]);
|
||||
if(head_crc != calc_crc32_head(data,240)) {
|
||||
LOGI("header crc32 filed \r\n");
|
||||
LOGI("crc header=%08x cal_crc :%08x \r\n",head_crc,calc_crc32((uint32_t)(app_image_header+8),240));
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t size = (app_image_header[7]<<24)+(app_image_header[6]<<16)+(app_image_header[5]<<8)+app_image_header[4];// data
|
||||
uint32_t app_image_start_addr = (app_image_header[27+8]<<24)+(app_image_header[26+8]<<16)+(app_image_header[25+8]<<8)+(app_image_header[24+8]); // data
|
||||
uint32_t app_image_end_addr = app_image_start_addr + size - 1;
|
||||
LOGI("app_image_start_addr:%x ,app_image_end_addr:%x\r\n",app_image_start_addr,app_image_end_addr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void app_header_update(uint8_t *header)
|
||||
{
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Erase_Page(PARAM_ADDR);
|
||||
FMC_SPI_Flash_WritePage(PARAM_ADDR, header, 256);
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
|
||||
void xc_ota_wdt_init(WDT_InitCfg_t *wdt_cfg)
|
||||
{
|
||||
cpr_ctlapbclken_grctl__wdt_pclk_en__setf(ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_DISABLE);
|
||||
cpr_rstctl_wdtrst_mask_set(
|
||||
(WDT_SYS_RSTN_MASK_DISABLE | WDT_M0_RSTN_MASK_ENABLE));
|
||||
cpr_lp_ctl__wdt_pclk_sel__setf(DISABLE);
|
||||
cpr_lp_ctl__wdt_tclk_en__setf(ENABLE);
|
||||
wdt_cr__wdt_rmod__setf(wdt_cfg->WorkMode);
|
||||
wdt_torr__wdt_top__setf(wdt_cfg->ReloadValue);
|
||||
}
|
||||
|
||||
void wdt_reset_system(void)
|
||||
{
|
||||
|
||||
WDT_InitCfg_t wdt_cfg;
|
||||
NVIC_EnableIRQ(WDT_IRQn);
|
||||
wdt_cfg.WorkMode = WDT_WORK_MODE0;
|
||||
wdt_cfg.ReloadValue = WDT_CLK_32M_RESET_MODE0_4096US;
|
||||
xc_ota_wdt_init(&wdt_cfg);
|
||||
xc_wdt_start();
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void process_ota(uint8_t *data, uint16_t length) {
|
||||
volatile uint16_t max_write = 0;
|
||||
memcpy(&write_buffer[write_index], data, length);
|
||||
write_index += length;
|
||||
aes_index_at = write_index;
|
||||
switch (process_sta) {
|
||||
case OTA_PROCESS_SEARCH_HEADER:
|
||||
if (aes_index_at >= sizeof(sBOOT_MESSAGE_OTA))
|
||||
{
|
||||
LOGI("write_index=%d\r\n",aes_index_at);
|
||||
//uint16_t k = 0;
|
||||
// for(uint16_t i = 0;i<write_index;i++)
|
||||
// {
|
||||
// LOGI(" %02x ",write_buffer[i]);
|
||||
// k++;
|
||||
// if((k%16 == 0))
|
||||
// {
|
||||
// LOGI("\r\n");
|
||||
// }
|
||||
// }
|
||||
uint16_t sotf_v = (write_buffer[1] <<8) +write_buffer[0]; // data
|
||||
uint16_t rom_v = (write_buffer[3] <<8)+ write_buffer[2];
|
||||
uint32_t size = (write_buffer[7]<<24)+(write_buffer[6]<<16)+(write_buffer[5]<<8)+write_buffer[4];// data
|
||||
uint32_t erase_addr = (write_buffer[27+8]<<24)+(write_buffer[26+8]<<16)+(write_buffer[25+8]<<8)+(write_buffer[24+8]); // data
|
||||
//uint32_t write_addr = (write_buffer[27+8]<<24)+(write_buffer[26+8]<<16)+(write_buffer[25+8]<<8)+(write_buffer[24+8]); // start para
|
||||
uint32_t app_bin_crc=(write_buffer[11+8]<<24)+(write_buffer[10+8]<<16)+(write_buffer[9+8]<<8)+(write_buffer[8+8]);
|
||||
LOGI("sotf_v :%x rom_v:%x, size:%x addr:%x app_crc:%x \r\n",sotf_v,rom_v,size,erase_addr,app_bin_crc);
|
||||
memcpy(head_data_temp,write_buffer+8,256);
|
||||
if (true == app_header_vailed(write_buffer,head_data_temp))
|
||||
{
|
||||
header_app_crc32 = (write_buffer[11+8]<<24)+(write_buffer[10+8]<<16)+(write_buffer[9+8]<<8)+(write_buffer[8+8]);
|
||||
LOGI("header vaild,app crc =%08x\r\n",header_app_crc32);
|
||||
should_recived_length = (write_buffer[7]<<24)+(write_buffer[6]<<16)+(write_buffer[5]<<8)+write_buffer[4];// data
|
||||
app_start_addr = (write_buffer[27+8]<<24)+(write_buffer[26+8]<<16)+(write_buffer[25+8]<<8)+(write_buffer[24+8]); // data
|
||||
last_erase_block = 0;
|
||||
process_sta = OTA_PROCESS_DATA_STORE;
|
||||
aes_index_at = aes_index_at - sizeof(sBOOT_MESSAGE_OTA);
|
||||
write_index = write_index - sizeof(sBOOT_MESSAGE_OTA);
|
||||
memcpy(write_buffer, write_buffer + sizeof(sBOOT_MESSAGE_OTA),write_index);
|
||||
LOGI("new_aes_idx = %d,new_w_idx=%d\r\n",aes_index_at,write_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
ota_state_restore();
|
||||
xc_ble_disconnect(app_env.slave_conidx, 0x16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OTA_PROCESS_DATA_STORE:
|
||||
// LOGI("write_index_all:%d ,aes_index_at:%d should_recived_length: %d \r\n",write_index_all,aes_index_at,should_recived_length);
|
||||
if ((write_index_all + aes_index_at) < should_recived_length) {
|
||||
if (aes_index_at >= 1024) {
|
||||
|
||||
if(0==(last_erase_block&0x03)){
|
||||
// LOGI("eraes adddr :%x\r\n",app_start_addr+last_erase_block*1024);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Erase_Sector(app_start_addr+last_erase_block*1024);
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
last_erase_block ++;
|
||||
for(uint8_t i = 0;i<4;i++)
|
||||
{
|
||||
FMC_SPI_Flash_WritePage(app_start_addr + write_index_all+i*256, write_buffer+i*256, 256);
|
||||
}
|
||||
// LOGI("w=%08x\r\n",app_start_addr+write_index_all);
|
||||
aes_index_at -= 1024;
|
||||
write_index -= 1024;
|
||||
write_index_all += 1024;
|
||||
memcpy(write_buffer, write_buffer + 1024, write_index);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("aes_index_at:%d write_index:%d \r\n",aes_index_at,write_index);
|
||||
if (aes_index_at == write_index) {
|
||||
if (0 == (last_erase_block & 0x03)) {
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Erase_Sector(app_start_addr+last_erase_block*1024);
|
||||
GLOBAL_INT_RESTORE();
|
||||
// LOGI("e=%08x\r\n",app_start_addr+last_erase_block*1024);
|
||||
}
|
||||
for(uint8_t i = 0;i<4;i++)
|
||||
{
|
||||
FMC_SPI_Flash_WritePage(app_start_addr + write_index_all+i*256, write_buffer+i*256, 256);
|
||||
}
|
||||
LOGI("write_index_all+write_index=%d\r\n",write_index_all+write_index);
|
||||
LOGI("app_start_addr=%08x,should_recived_length= %d\r\n",app_start_addr,should_recived_length);
|
||||
uint32_t crc32_firmware = calc_crc32(app_start_addr,should_recived_length);
|
||||
LOGI("CRC32 firmware=%08x\r\n",crc32_firmware);
|
||||
if (crc32_firmware == header_app_crc32) {
|
||||
app_header_update(head_data_temp);
|
||||
LOGI("app crc ok\r\n");
|
||||
wdt_reset_system();
|
||||
}
|
||||
else{
|
||||
LOGI("app crc err\r\n");
|
||||
ota_state_restore();
|
||||
xc_ble_disconnect(app_env.slave_conidx, 0x13);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if OTA_AES_USED
|
||||
void reverseArray(uint8_t arr[], uint16_t size) {
|
||||
uint8_t temp;
|
||||
for (uint16_t i = 0; i < size / 2; i++) {
|
||||
temp = arr[i];
|
||||
arr[i] = arr[size - 1 - i];
|
||||
arr[size - 1 - i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
aes_func_result_cb ota_aes_res(uint8_t status, const uint8_t* aes_res_data, uint32_t src_info)
|
||||
{
|
||||
//xc_gpio_write_pin(8, GPIO_PIN_RESET);
|
||||
// LOGI("src_info:0x%x\n",src_info);
|
||||
// LOGI("aes_res:");
|
||||
// for(int i=0;i<16;i++){
|
||||
// LOGI("%02x-",aes_res_data[i]);
|
||||
// }LOGI("\n");
|
||||
|
||||
reverseArray(aes_res_data,16);
|
||||
// for(int i=0;i<16;i++){
|
||||
// LOGI("%02x-",aes_res_data[i]);
|
||||
// }LOGI("\n");
|
||||
process_ota(aes_res_data, 16);
|
||||
// LOGI(".");
|
||||
// if(!memcmp(aes_res_data,encrypt_val,sizeof(encrypt_val))){
|
||||
// LOGI("aes right\n");
|
||||
// }else{
|
||||
// LOGI("aes error\n");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void process_aes_decrypt(void)
|
||||
{
|
||||
if((data_save_index - aes_decrypt_index>=16) && aes_decrypt_run)
|
||||
{
|
||||
//xc_gpio_write_pin(8, GPIO_PIN_SET);
|
||||
// LOGI("src data:");
|
||||
// for(int i=0;i<16;i++){
|
||||
// LOGI("%02x,",data_save_buffer[i+aes_decrypt_index]);
|
||||
// }LOGI("\n");
|
||||
|
||||
reverseArray(&data_save_buffer[aes_decrypt_index],16);
|
||||
// for(int i=0;i<16;i++){
|
||||
// LOGI("%02x,",data_save_buffer[i+aes_decrypt_index]);
|
||||
// }LOGI("\n");
|
||||
|
||||
aes_decrypt(AES_KEY, &data_save_buffer[aes_decrypt_index], 0, ota_aes_res, 0xff);
|
||||
aes_decrypt_index += 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void process_save_data(uint8_t *data, uint16_t length)
|
||||
{
|
||||
aes_decrypt_run = 0;
|
||||
while(aes_decrypt_index>=160)
|
||||
{
|
||||
aes_decrypt_index = aes_decrypt_index - 160;
|
||||
data_save_index = data_save_index -160;
|
||||
memcpy(data_save_buffer,data_save_buffer+160,data_save_index);
|
||||
// LOGI("%d %d %d \r\n",data_save_index,aes_decrypt_index,aes_decrypt_run);
|
||||
}
|
||||
|
||||
memcpy(&data_save_buffer[data_save_index], data, length);
|
||||
data_save_index += length;
|
||||
if(data_save_index>=ASE_DATA_BUFFER_SIZE-48)
|
||||
{
|
||||
LOGI("data_save_index too large ,error!!!! \r\n");
|
||||
ota_state_restore();
|
||||
xc_ble_disconnect(app_env.slave_conidx, 0x16);
|
||||
}
|
||||
aes_decrypt_run = 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _FAST_OTA_H_
|
||||
#define _FAST_OTA_H_
|
||||
|
||||
#define OTA_AES_KEY {0x10,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x0d,0x0c,0x0b};
|
||||
#define ASE_DATA_BUFFER_SIZE 2048
|
||||
#define PARAM_ADDR ((8*1024)-512)
|
||||
typedef enum {
|
||||
OTA_PROCESS_SEARCH_HEADER,
|
||||
OTA_PROCESS_DATA_STORE,
|
||||
} ota_process_state_t;
|
||||
|
||||
|
||||
#endif // _USR_SERVER_H_
|
||||
@@ -0,0 +1,245 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.c
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#if FAST_OTA
|
||||
#include "fast_ota_server.h"
|
||||
#include "fast_ota.h"
|
||||
#if (BLE_APP_PRESENT)
|
||||
|
||||
uint8_t fast_ota_srv_user_lid = GATT_INVALID_USER_LID;
|
||||
uint16_t fast_ota_svc_start_hdl = GATT_INVALID_HDL;
|
||||
uint8_t fast_ota_svc_tx_char_notify = DISABLE;
|
||||
|
||||
static const gatt_att16_desc_t fast_ota_server_atts[] = {
|
||||
[FAST_OTA_SVC_DECL] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_PRIMARY_SERVICE,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[FAST_OTA_SVC_TX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[FAST_OTA_SVC_TX_CHAR_VAL] =
|
||||
{
|
||||
.uuid16 = FAST_OTA_SVC_TX_CHAR_UUID,
|
||||
.info = GATT_ATT_N_BIT| GATT_ATT_WC_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | FAST_OTA_SVC_TX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[FAST_OTA_SVC_TX_CHAR_CFG] =
|
||||
{
|
||||
.uuid16 = GATT_DESC_CLIENT_CHAR_CFG,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[FAST_OTA_SVC_RX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[FAST_OTA_SVC_RX_CHAR_VAL] =
|
||||
{
|
||||
.uuid16 = FAST_OTA_SVC_RX_CHAR_UUID,
|
||||
.info = GATT_ATT_WC_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | FAST_OTA_SVC_RX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
extern unsigned int get_crc32(unsigned int crc, unsigned char *buf, unsigned int len);
|
||||
extern void wdt_reset_system(void);
|
||||
extern void process_ota(uint8_t *data, uint16_t length);
|
||||
extern __RAM_CODE void xc_fmc_spi_init_oprt(void);
|
||||
extern __RAM_CODE void xc_fmc_spi_flash_wake_up(void);
|
||||
extern __RAM_CODE void xc_fmc_spi_flash_read_page(uint32_t addr, uint8_t *data, uint16_t size);
|
||||
extern __RAM_CODE void xc_fmc_spi_flash_erase_page(uint32_t addr);
|
||||
extern __RAM_CODE void xc_fmc_spi_flash_write_page(uint32_t addr, uint8_t *data, uint16_t size);
|
||||
|
||||
void enter_ota_mode()
|
||||
{
|
||||
printf("%s\n", __func__);
|
||||
xc_fmc_spi_init_oprt();
|
||||
xc_fmc_spi_flash_wake_up();
|
||||
uint8_t para_buf[256];
|
||||
uint8_t data[256];
|
||||
xc_fmc_spi_flash_read_page(((8*1024)-512), para_buf, FLASH_PAGE_SIZE);
|
||||
|
||||
para_buf[0]=0x00;
|
||||
para_buf[48]=0x01;
|
||||
para_buf[96]=0x00;
|
||||
uint32_t crc =0;
|
||||
crc=get_crc32(crc,para_buf,240);
|
||||
para_buf[243]=crc>>24;
|
||||
para_buf[242]=crc>>16;
|
||||
para_buf[241]=crc>>8;
|
||||
para_buf[240]=crc;
|
||||
|
||||
GLOBAL_INT_DISABLE();
|
||||
xc_fmc_spi_flash_erase_page(0x1e00);
|
||||
xc_fmc_spi_flash_erase_page(0x1f00);
|
||||
GLOBAL_INT_RESTORE();
|
||||
|
||||
GLOBAL_INT_DISABLE();
|
||||
xc_fmc_spi_flash_write_page(((8*1024)-512), para_buf, 256);
|
||||
GLOBAL_INT_RESTORE();
|
||||
|
||||
for(int i=0; i<256; i+=2){
|
||||
data[i] = para_buf[i+1];
|
||||
data[i+1] = para_buf[i];
|
||||
}
|
||||
|
||||
GLOBAL_INT_DISABLE();
|
||||
xc_fmc_spi_flash_write_page(((8*1024)-256), data, 256);
|
||||
GLOBAL_INT_RESTORE();
|
||||
|
||||
xc_fmc_spi_flash_read_page(((8*1024)-256), para_buf, FLASH_PAGE_SIZE);
|
||||
xc_fmc_spi_flash_read_page(((8*1024)-512), para_buf, FLASH_PAGE_SIZE);
|
||||
wdt_reset_system();
|
||||
}
|
||||
|
||||
uint8_t fast_ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
|
||||
uint16_t fast_ota_srv_get_hdl_from_att_idx(uint8_t idx)
|
||||
{
|
||||
return fast_ota_svc_start_hdl + idx;
|
||||
}
|
||||
|
||||
// This function is called when GATT server user has initiated event send to
|
||||
// peer device or if an error occurs.
|
||||
__STATIC void fast_ota_svc_cb_event_sent(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t dummy, uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, dummy:%d, status:%d \r\n", __func__,
|
||||
conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
// This function is called when peer want to read local attribute database
|
||||
// value.
|
||||
__STATIC void fast_ota_svc_cb_att_read_get(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, uint16_t max_length)
|
||||
{
|
||||
uint16_t status;
|
||||
uint8_t data[512] = {0x12, 0x15, 0x46, 0x62};
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d, "
|
||||
"max_length:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset, max_length);
|
||||
// Send result to peer device
|
||||
status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
sizeof(data), sizeof(data), data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_read_cfm error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t upd_flag = 1;
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC void fast_ota_svc_cb_att_val_set(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
uint16_t status;
|
||||
// LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d \r\n",
|
||||
// __func__, conidx, user_lid, token, hdl, offset);
|
||||
status =
|
||||
xc_ble_gatt_srv_write_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_write_cfm error 0x%x", status);
|
||||
}
|
||||
//LOGI("length:%d data:\r\n", length);
|
||||
// DUMP_DATA_PRINTF(&(co_buf_data(p_data)[0]), length);
|
||||
if (hdl == fast_ota_srv_get_hdl_from_att_idx(FAST_OTA_SVC_TX_CHAR_CFG)) {
|
||||
if ((co_buf_data(p_data)[0] == 0) && (co_buf_data(p_data)[1] == 0)) {
|
||||
fast_ota_svc_tx_char_notify = DISABLE;
|
||||
} else {
|
||||
fast_ota_svc_tx_char_notify = ENABLE;
|
||||
}
|
||||
}
|
||||
#if !SINGLE_OTA
|
||||
if(upd_flag)
|
||||
{
|
||||
xc_ble_update_param(conidx, 9, 12,0, 400);
|
||||
upd_flag = 0;
|
||||
}
|
||||
#endif
|
||||
#if SINGLE_OTA
|
||||
if ((hdl == fast_ota_srv_get_hdl_from_att_idx(FAST_OTA_SVC_TX_CHAR_VAL)) && (length == 1))
|
||||
{
|
||||
if(co_buf_data(p_data)[0] == SINGLE_OTA_ENTER_CMD)
|
||||
{
|
||||
LOGI(" enter single ota mode\r\n");
|
||||
enter_ota_mode();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if !SINGLE_OTA
|
||||
if (hdl == fast_ota_srv_get_hdl_from_att_idx(FAST_OTA_SVC_RX_CHAR_VAL))
|
||||
{
|
||||
|
||||
#if OTA_AES_USED
|
||||
process_save_data(&(co_buf_data(p_data)[0]), length);
|
||||
#else
|
||||
process_ota(&(co_buf_data(p_data)[0]), length);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static const gatt_srv_cb_t fast_ota_svc_cb = {
|
||||
.cb_event_sent = fast_ota_svc_cb_event_sent,
|
||||
.cb_att_read_get = fast_ota_svc_cb_att_read_get,
|
||||
.cb_att_val_set = fast_ota_svc_cb_att_val_set,
|
||||
};
|
||||
|
||||
uint8_t fast_ota_svc_add(void)
|
||||
{
|
||||
int nb_att = sizeof(fast_ota_server_atts) / sizeof(fast_ota_server_atts[0]);
|
||||
uint16_t status;
|
||||
uint16_t svc_uuid = FAST_OTA_SVC_UUID;
|
||||
status = xc_ble_gatt_user_srv_register(133, 0, &fast_ota_svc_cb, &fast_ota_srv_user_lid);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_user_srv_register error 0x%x", status);
|
||||
}
|
||||
status = xc_ble_gatt_service16_add(
|
||||
fast_ota_srv_user_lid, GATT_UUID_16 << GATT_SVC_UUID_TYPE_LSB, svc_uuid,
|
||||
nb_att, NULL, &(fast_ota_server_atts[0]), nb_att, &fast_ota_svc_start_hdl);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_service16_add error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t fast_ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx)
|
||||
{
|
||||
uint16_t status = INVALID_DATA;
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
if (app_env->slave_connected && fast_ota_svc_tx_char_notify) {
|
||||
status = xc_ble_gatt_srv_notify(app_env->slave_conidx, fast_ota_srv_user_lid, 0,
|
||||
fast_ota_srv_get_hdl_from_att_idx(att_idx), len,
|
||||
data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_notify error 0x%x", status);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _FAST_OTA_SERVER_H_
|
||||
#define _FAST_OTA_SERVER_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
|
||||
#define FAST_OTA_SVC_UUID 0xFFF6
|
||||
#define FAST_OTA_SVC_TX_CHAR_UUID 0xFFF7
|
||||
#define FAST_OTA_SVC_RX_CHAR_UUID 0xFFF8
|
||||
#define FAST_OTA_SVC_RX_CHAR_VAL_MAX_LENGTH 512
|
||||
#define FAST_OTA_SVC_TX_CHAR_VAL_MAX_LENGTH 512
|
||||
|
||||
#define SINGLE_OTA_ENTER_CMD 1
|
||||
|
||||
enum cust_svc
|
||||
{
|
||||
FAST_OTA_SVC_DECL = 0,
|
||||
FAST_OTA_SVC_TX_CHAR_DECL_CHAR,
|
||||
FAST_OTA_SVC_TX_CHAR_VAL,
|
||||
FAST_OTA_SVC_TX_CHAR_CFG,
|
||||
FAST_OTA_SVC_RX_CHAR_DECL_CHAR,
|
||||
FAST_OTA_SVC_RX_CHAR_VAL,
|
||||
|
||||
};
|
||||
uint8_t fast_ota_svc_add(void);
|
||||
#endif // _USR_SERVER_H_
|
||||
@@ -1,159 +0,0 @@
|
||||
#ifndef _FFT_C_
|
||||
#define _FFT_C_
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define FFTN 32 //fft的点数
|
||||
#define PWE 5 //2^PWE=NFFT
|
||||
#define LEN FFTN*2
|
||||
#define FRE 2000 //采样频率
|
||||
#define RS 62.5 //分辨率=FRE/FFTN
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Local Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
//由于一个点是复数,因此用偶数脚标表示实部,奇数脚标表示虚部
|
||||
float fft_input[LEN] = {0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,
|
||||
8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,
|
||||
16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,
|
||||
24,0,25,0,26,0,27,0,28,0,29,0,30,0,31,0};
|
||||
|
||||
float fft_output[LEN];
|
||||
float MAX[2]; //保存最后得出的结果
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Function
|
||||
-------------------------------------------------------------------------------------*/
|
||||
//void main(void)
|
||||
//{
|
||||
// int i;
|
||||
// clock_t begin, end;
|
||||
//
|
||||
// begin = clock();
|
||||
// ReverseArrange(); //倒序
|
||||
// Redix2FFT(); //FFT变换
|
||||
// end = clock();
|
||||
// printf("%lfs\n",(double)(end-begin)/CLOCKS_PER_SEC);
|
||||
|
||||
//}
|
||||
/*倒序函数,将fft_input进行逆向排序
|
||||
* 0 1 2 3 4 5 6 7
|
||||
倒序前脚标: 0-1 2-3 4-5 6-7 8-9 10-11 12-13 14-15
|
||||
0 4 2 6 1 5 3 7
|
||||
倒序后脚标: 0-1 8-9 4-5 12-13 2-3 10-11 6-7 14-15
|
||||
*/
|
||||
//其中:2^PWE=NFFT,PWE表示次幂,即脚标由几位二进制组成
|
||||
int ReverseArrange(void)
|
||||
{
|
||||
int8_t i,j;
|
||||
int8_t tmp = 0x00; //用来表示脚标
|
||||
//先给第一个复数赋值
|
||||
fft_output[0] = fft_input[0];
|
||||
fft_output[1] = fft_input[1];
|
||||
//对剩下的数进行倒序
|
||||
for(i=0;i<(FFTN-1)*2;i+=2){
|
||||
j = PWE-1; //得出需要左移的位数
|
||||
//逆向二进制加法
|
||||
while((tmp & (1<<j)) != 0){
|
||||
tmp &= ~(1<<j); //把第j位置零
|
||||
j--;
|
||||
}
|
||||
tmp |= (1<<j); //这里最后得出的是:0 4 2 6 1 5 3 7
|
||||
fft_output[i+2] = fft_input[tmp*2]; //按照新的顺序给输出赋值
|
||||
fft_output[i+3] = fft_input[tmp*2+1];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*基2fft运算,需先将fft_input倒序输入到fft_out中*/
|
||||
int Redix2FFT(void)
|
||||
{
|
||||
int8_t layer; //表示FFT的层数
|
||||
int8_t pmul; //= 2^(PWE - layer),表示当前层中需要进行几次小FFT,FFTN/pmul表示当前小FFT的点数
|
||||
int8_t i; //表示正在进行第几次小FFT
|
||||
int8_t j; //= 2^(layer - 1),表示当前层小FFT中蝶形运算的次数
|
||||
int8_t k; //每次小FFT中,正在进行第几次蝶形运算
|
||||
int8_t currentBase; //表示当前层的小FFT中,第一个元素的脚标
|
||||
int8_t current; //=currentBase + k,表示当前需要进行蝶形运算的元素的脚标
|
||||
int8_t another; //=current + j,表示当前需要进行蝶形运算的元素的脚标
|
||||
int8_t m;
|
||||
float Re,Im; //实部、虚部的暂存区
|
||||
float TPOA; //=2 * pi / FFTN,FFT旋转因子WNK的w值
|
||||
float TPOATP;//=TPOA * pmul,表示小FFT中WNK的w值
|
||||
float reFactor,imFactor; //=cos(TPOATP * k),=-sin(TPOATP * k),表示WNK的实部和虚部
|
||||
|
||||
//下面的注释假设FFTN=8
|
||||
|
||||
TPOA = 2 * M_PI / FFTN; //TPOA = PI/4
|
||||
for(layer=1;layer<=PWE;layer++){ //layer = 1,2,3
|
||||
j = 0x01<<(layer-1); //使用math中的pow()会出现bug,使用左移运算减轻计算量
|
||||
pmul = 0x01<<(PWE - layer);
|
||||
for(i=0;i<pmul;i++){ //pmul=4时,i = 0,1,2,3
|
||||
currentBase = i * 4 *j; //j = 1时,currentBase = 0,4,8,12
|
||||
TPOATP = TPOA * pmul; //pmul=4时,TPOATP = PI
|
||||
for(k=0;k<j;k++){ //j=1时,k=0
|
||||
current = currentBase + k*2; //current = 0,4,8,12;
|
||||
another = current + j*2; //another = 2,6,10,14;
|
||||
//准备WNK
|
||||
reFactor = cos(TPOATP * k); //1
|
||||
imFactor = -sin(TPOATP * k);//0
|
||||
//乘上WNK
|
||||
Re = fft_output[another]; //备份实部
|
||||
fft_output[another] = fft_output[another] * reFactor
|
||||
- fft_output[another+1] * imFactor; //fft_output[2] = 8
|
||||
fft_output[another+1] = fft_output[another+1] * reFactor
|
||||
+ Re * imFactor; //fft_output[3] = 0
|
||||
//蝶形加法
|
||||
Re = fft_output[current]; //Re=0
|
||||
Im = fft_output[current+1]; //Im=0
|
||||
fft_output[current] += fft_output[another]; //fft_output[0] = 8;
|
||||
fft_output[current+1] += fft_output[another+1]; //fft_output[1] = 0
|
||||
|
||||
fft_output[another] = Re - fft_output[another]; //fft[2] = -8
|
||||
fft_output[another+1] = Im - fft_output[another+1]; //fft[3] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
for(m = 0; m < LEN; m += 2) {
|
||||
// printf("[%d]: %f+%fi\n", m/2, fft_output[m], fft_output[m+1]);
|
||||
}
|
||||
}
|
||||
/* 输出整合,计算出每个频率的幅值,取出幅值最大的点
|
||||
*/
|
||||
void IntegrateData(void)
|
||||
{
|
||||
//计算复数的模,注意,所有的模都存到偶数项中
|
||||
//fft_output[0] = sqrt(fft_output[0]*fft_output[0]+fft_output[1]*fft_output[1])/FFTN;
|
||||
fft_output[LEN-2] = sqrt(fft_output[LEN-2]*fft_output[LEN-2]+fft_output[LEN-1]*fft_output[LEN-1])/FFTN;
|
||||
for(uint8_t i=2;i<(LEN-2);i+=2){ //最后一个点和第一个点已单独处理
|
||||
fft_output[i] = 2*sqrt(fft_output[i]*fft_output[i]+fft_output[i+1]*fft_output[i+1])/FFTN;
|
||||
}
|
||||
//找出其中模长最大的值,记录脚标和模长
|
||||
MAX[0] = 2; //脚标
|
||||
MAX[1] = fft_output[2]; //模长
|
||||
for(uint8_t i=4;i<LEN;i+=2){
|
||||
if(MAX[1]<fft_output[i]){ //替换
|
||||
MAX[0] = i;
|
||||
MAX[1] = fft_output[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef _FFT_H_
|
||||
#define _FFT_H_
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
int ReverseArrange(void);
|
||||
int Redix2FFT(void);
|
||||
void IntegrateData(void);
|
||||
#endif
|
||||
@@ -1,261 +0,0 @@
|
||||
/*!
|
||||
* \file gpio.c
|
||||
*
|
||||
* \brief Target gpio implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "gpio.h"
|
||||
#include "xc_drv_gpio.h"
|
||||
#include "nec_infrared.h"
|
||||
#include "dbg.h"
|
||||
#include "key.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
//uint8_t gpio_intr_flag = false;
|
||||
//uint64_t intr_val = 0;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief gpio_demo
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void gpio_demo(void)
|
||||
{
|
||||
// DEBUG("__GPIO_DEMO__\r");
|
||||
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Pull = GPIO_PULLUP;
|
||||
|
||||
// // Board KEY_MODE Initialization
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
// GPIO_InitCfg.Int = NOT_INT;
|
||||
// GPIO_InitCfg.Pin = KEY_MODE;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// // Board KEY_UP Initialization
|
||||
// GPIO_InitCfg.Pin = KEY_UP;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// // Board KEY_DOWN Initialization
|
||||
// GPIO_InitCfg.Pin = KEY_DOWN;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// // Gpio NVIC Enable
|
||||
// NVIC_EnableIRQ(GPIO_IRQn);
|
||||
}
|
||||
|
||||
void feedback(void)
|
||||
{
|
||||
//LOGI("LED3_PIN:%d",xc_gpio_read_pin(LED3_PIN));
|
||||
}
|
||||
|
||||
|
||||
///**
|
||||
// * @brief gpio_intr_callback
|
||||
// * @details Gpio interrupt callback function
|
||||
// * @param void
|
||||
// * @retval void
|
||||
// */
|
||||
//__RAM_CODE void gpio_intr_callback(uint64_t intr_sta)
|
||||
//{
|
||||
// intr_val = intr_sta;
|
||||
// gpio_intr_flag = true;
|
||||
// // Determine the interrupt of IRINPUT_PIN
|
||||
// if((intr_sta & (1 << IR_PIN)) != 0)
|
||||
// {
|
||||
// ir_callback();
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//void gpio_pulldown_input_test(void)
|
||||
//{
|
||||
// //input test
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
// GPIO_InitCfg.Int = NOT_INT;
|
||||
// GPIO_InitCfg.Pull = GPIO_PULLDOWN;
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// }
|
||||
// while(1)
|
||||
// {
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// DEBUG("gaio [%d] Val: %d\r\n", i,xc_gpio_read_pin(i));
|
||||
// for(int i=0;i<0x45500;i++);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
//void gpio_pullup_input_test(void)
|
||||
//{
|
||||
// //input test
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
// GPIO_InitCfg.Int = NOT_INT;
|
||||
// GPIO_InitCfg.Pull = GPIO_PULLUP;
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// }
|
||||
// while(1)
|
||||
// {
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// DEBUG("gaio [%d] Val: %d\r\n", i,xc_gpio_read_pin(i));
|
||||
// for(int i=0;i<0x45500;i++);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
//void gpio_nopull_input_test(void)
|
||||
//{
|
||||
// //input test
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
// GPIO_InitCfg.Int = NOT_INT;
|
||||
// GPIO_InitCfg.Pull = GPIO_NOPULL;
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// }
|
||||
// while(1)
|
||||
// {
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// DEBUG("gaio [%d] Val: %d\r\n", i,xc_gpio_read_pin(i));
|
||||
// for(int i=0;i<0x45500;i++);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
//void gpio_pulldown_input_inter_test(void)
|
||||
//{
|
||||
// //input test
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
// GPIO_InitCfg.Int = RIS_EDGE_INT;
|
||||
// GPIO_InitCfg.Pull = GPIO_PULLDOWN;
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// }
|
||||
// // Gpio NVIC Enable
|
||||
// NVIC_EnableIRQ(GPIO_IRQn);
|
||||
//
|
||||
// while(1)
|
||||
// {
|
||||
// if(gpio_intr_flag == true)
|
||||
// {
|
||||
// DEBUG("Intr Status Val: 0x%016llx\n", intr_val);
|
||||
// gpio_intr_flag = false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//void gpio_pullup_input_inter_test(void)
|
||||
//{
|
||||
// //input test
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
// GPIO_InitCfg.Int = FAIL_EDGE_INT;
|
||||
// GPIO_InitCfg.Pull = GPIO_PULLUP;
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// }
|
||||
// // Gpio NVIC Enable
|
||||
// NVIC_EnableIRQ(GPIO_IRQn);
|
||||
//
|
||||
// while(1)
|
||||
// {
|
||||
// if(gpio_intr_flag == true)
|
||||
// {
|
||||
// DEBUG("Intr Status Val: 0x%016llx\n", intr_val);
|
||||
// gpio_intr_flag = false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//void gpio_output_test(void)
|
||||
//{
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
// GPIO_InitCfg.Pull = GPIO_PULLDOWN;
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT;
|
||||
// GPIO_InitCfg.Int = NOT_INT;
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// xc_gpio_write_pin(i,GPIO_PIN_RESET);
|
||||
// }
|
||||
// for(int i=0;i<0x455000;i++);
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// xc_gpio_write_pin(i,GPIO_PIN_SET);
|
||||
// }
|
||||
// for(int i=0;i<0x455000;i++);
|
||||
// for(uint8_t i = 0;i < 8; i++)
|
||||
// {
|
||||
// GPIO_InitCfg.Pin = i;
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// xc_gpio_write_pin(i,GPIO_PIN_RESET);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*!
|
||||
* \file gpio.h
|
||||
*
|
||||
* \brief The head file of gpio.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __GPIO_H__
|
||||
#define __GPIO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
//#define LED1_PIN GPIO_6
|
||||
//#define LED2_PIN GPIO_24
|
||||
|
||||
|
||||
//#define LED3_PIN GPIO_10
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void gpio_demo(void);
|
||||
void feedback(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GPIO_H__ */
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
/*!
|
||||
* \file key.c
|
||||
*
|
||||
* \brief Target key implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "xc_drv_gpio.h"
|
||||
#include "xc60xx.h"
|
||||
#include "key.h"
|
||||
#include "message.h"
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define IS_KEY_DOWN(n) (!(xc_gpio_read_pin(n)))
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
static uint16_t last_key_val = NO_KEY;
|
||||
static uint16_t key_down_count = 0;
|
||||
static uint16_t key_up_count = 0;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief app_key_hold_detection
|
||||
* @details
|
||||
* @param curren_key_val
|
||||
* @retval key_num
|
||||
*/
|
||||
__RAM_CODE uint16_t app_key_hold_detection(uint16_t curren_key_val)
|
||||
{
|
||||
uint16_t key_num = NO_KEY;
|
||||
|
||||
if (key_down_count < 0xff)
|
||||
key_down_count++;
|
||||
|
||||
if (key_down_count == KEY_DOWN_TIMER)
|
||||
{
|
||||
key_num = (curren_key_val | KEY_SHORT_DOWN); // shor key
|
||||
}
|
||||
else if(key_down_count == KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = (curren_key_val | KEY_LONG_DOWN); // loog key
|
||||
}
|
||||
key_up_count = 0;
|
||||
|
||||
return key_num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief app_new_key_detection
|
||||
* @details key up or new key detection
|
||||
* @param curren_key_val
|
||||
* @retval key_num
|
||||
*/
|
||||
__RAM_CODE uint16_t app_new_key_detection(uint16_t curren_key_val)
|
||||
{
|
||||
uint16_t key_num = NO_KEY;
|
||||
|
||||
key_up_count++;
|
||||
if (key_up_count >= KEY_UP_TIMER)
|
||||
{
|
||||
if (key_down_count >= KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = (last_key_val | KEY_LONG_UP); // long key up
|
||||
last_key_val = 0;
|
||||
}
|
||||
else if (key_down_count >= KEY_DOWN_TIMER && key_down_count < KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = (last_key_val | KEY_SHORT_UP); // shor key up
|
||||
last_key_val = 0;
|
||||
}
|
||||
key_down_count = 0;
|
||||
key_up_count = 0;
|
||||
}
|
||||
if ((curren_key_val && curren_key_val != last_key_val))
|
||||
{
|
||||
if (key_down_count >= KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = (last_key_val | KEY_LONG_UP); // long key up
|
||||
}
|
||||
else if (key_down_count >= KEY_DOWN_TIMER && key_down_count < KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = (last_key_val | KEY_SHORT_UP); // shor key up
|
||||
}
|
||||
last_key_val = curren_key_val;
|
||||
key_down_count = 0;
|
||||
key_up_count = 0;
|
||||
}
|
||||
|
||||
return key_num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief key_check_process
|
||||
* @details
|
||||
* @param curren_key_val
|
||||
* @retval key_num
|
||||
*/
|
||||
__RAM_CODE uint16_t key_check_process(uint16_t curren_key_val)
|
||||
{
|
||||
uint16_t key_num = NO_KEY;
|
||||
|
||||
if ( curren_key_val == last_key_val && last_key_val != NO_KEY )
|
||||
{
|
||||
key_num = app_key_hold_detection(curren_key_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
key_num = app_new_key_detection(curren_key_val);
|
||||
}
|
||||
|
||||
return key_num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief gpio_key_check
|
||||
* @details
|
||||
* @param void
|
||||
* @retval key_num
|
||||
*/
|
||||
uint16_t gpio_key_check(void)
|
||||
{
|
||||
uint16_t key_val = NO_KEY;
|
||||
|
||||
if ( IS_KEY_DOWN(KEY_MODE) )
|
||||
{
|
||||
key_val = REC_KEY;
|
||||
}
|
||||
else if( IS_KEY_DOWN(KEY_UP) )
|
||||
{
|
||||
key_val = REC_KEY_UP;
|
||||
}
|
||||
else if( IS_KEY_DOWN(KEY_DOWN) )
|
||||
{
|
||||
key_val = REC_KEY_DOWN;
|
||||
}
|
||||
|
||||
return key_val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief key_check_process
|
||||
* @details key scan and send
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_key_scan(void)
|
||||
{
|
||||
uint16_t key_num = NO_KEY;
|
||||
uint16_t key_val = NO_KEY;
|
||||
|
||||
key_val = gpio_key_check();
|
||||
key_num = key_check_process(key_val);
|
||||
|
||||
if (key_num != NO_KEY)
|
||||
{
|
||||
app_key_message_send( key_num );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief app_key_init
|
||||
* @details key init
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_key_init(void)
|
||||
{
|
||||
GPIO_InitCfg_t GPIO_InitCfg = {0};
|
||||
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
GPIO_InitCfg.Pull = GPIO_PULLUP;
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
GPIO_InitCfg.Int = NOT_INT;
|
||||
GPIO_InitCfg.Pin = KEY_MODE;
|
||||
xc_gpio_init(&GPIO_InitCfg);
|
||||
|
||||
GPIO_InitCfg.Pin = KEY_UP;
|
||||
xc_gpio_init(&GPIO_InitCfg);
|
||||
|
||||
GPIO_InitCfg.Pin = KEY_DOWN;
|
||||
xc_gpio_init(&GPIO_InitCfg);
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*!
|
||||
* \file key.h
|
||||
*
|
||||
* \brief The head file of key.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __KEY_H__
|
||||
#define __KEY_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define KEY_MODE GPIO_18
|
||||
#define KEY_UP GPIO_19
|
||||
#define KEY_DOWN GPIO_5
|
||||
|
||||
#define KEY_DOWN_TIMER 10
|
||||
#define KEY_LONG_TIMER 20
|
||||
#define KEY_LOH_TIMER 20
|
||||
#define KEY_UP_TIMER 10
|
||||
|
||||
// KEY NUM 0- 255
|
||||
#define KEY_NUM1 0X0001
|
||||
#define KEY_NUM2 0X0002
|
||||
#define KEY_NUM3 0X0004
|
||||
|
||||
#define KEY_SHORT_DOWN 0X0000
|
||||
#define KEY_SHORT_UP 0X0100
|
||||
#define KEY_LONG_DOWN 0X0200
|
||||
#define KEY_LONG_UP 0X0400
|
||||
|
||||
#define NO_KEY 0
|
||||
|
||||
#define REC_KEY KEY_NUM1
|
||||
#define REC_KEY_UP KEY_NUM2
|
||||
#define REC_KEY_DOWN KEY_NUM3
|
||||
|
||||
#define REC_KEY_SHORT_DOWN (REC_KEY | KEY_SHORT_DOWN)
|
||||
#define REC_KEY_SHORT_UP (REC_KEY | KEY_SHORT_UP)
|
||||
#define REC_KEY_LONG_DOWN (REC_KEY | KEY_LONG_DOWN)
|
||||
#define REC_KEY_LONG_UP (REC_KEY | KEY_LONG_UP)
|
||||
|
||||
#define REC_KEY_UP_SHORT_DOWN (REC_KEY_UP | KEY_SHORT_DOWN)
|
||||
#define REC_KEY_UP_SHORT_UP (REC_KEY_UP | KEY_SHORT_UP)
|
||||
#define REC_KEY_UP_LONG_DOWN (REC_KEY_UP | KEY_LONG_DOWN)
|
||||
#define REC_KEY_UP_LONG_UP (REC_KEY_UP | KEY_LONG_UP)
|
||||
|
||||
#define REC_KEY_DOWN_SHORT_DOWN (REC_KEY_DOWN | KEY_SHORT_DOWN)
|
||||
#define REC_KEY_DOWN_SHORT_UP (REC_KEY_DOWN | KEY_SHORT_UP)
|
||||
#define REC_KEY_DOWN_LONG_DOWN (REC_KEY_DOWN | KEY_LONG_DOWN)
|
||||
#define REC_KEY_DOWN_LONG_UP (REC_KEY_DOWN | KEY_LONG_UP)
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void app_key_init(void);
|
||||
void app_key_scan(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __KEY_H__ */
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "mcu_bridge.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "uart.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t r_value;
|
||||
uint8_t g_value;
|
||||
uint8_t b_value_mode_speed_brightness;
|
||||
uint8_t type;
|
||||
} mcu_bridge_packet_t;
|
||||
|
||||
static volatile bool packet_pending;
|
||||
static mcu_bridge_packet_t pending_packet;
|
||||
|
||||
/* These callbacks replace the weak callbacks supplied by usr_server.c. */
|
||||
void ble_callback(uint8_t value0, uint8_t value1, uint8_t value2, uint8_t value3)
|
||||
{
|
||||
pending_packet.r_value = value0;
|
||||
pending_packet.g_value = value1;
|
||||
pending_packet.b_value_mode_speed_brightness = value2;
|
||||
pending_packet.type = value3;
|
||||
packet_pending = true;
|
||||
}
|
||||
|
||||
void ble_diy_callback(uint8_t value, uint8_t *color, uint8_t length)
|
||||
{
|
||||
pending_packet.type = value;
|
||||
if (length > 1) {
|
||||
pending_packet.r_value = color[1];
|
||||
}
|
||||
if (length > 2) {
|
||||
pending_packet.g_value = color[2];
|
||||
}
|
||||
if (length > 3) {
|
||||
pending_packet.b_value_mode_speed_brightness = color[3];
|
||||
}
|
||||
packet_pending = true;
|
||||
}
|
||||
|
||||
void mcu_bridge_process(void)
|
||||
{
|
||||
uint8_t data[4];
|
||||
|
||||
if (!packet_pending) {
|
||||
return;
|
||||
}
|
||||
|
||||
data[0] = pending_packet.r_value;
|
||||
data[1] = pending_packet.g_value;
|
||||
data[2] = pending_packet.b_value_mode_speed_brightness;
|
||||
data[3] = pending_packet.type;
|
||||
packet_pending = false;
|
||||
scan_uart(data);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef MCU_BRIDGE_H_
|
||||
#define MCU_BRIDGE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void mcu_bridge_process(void);
|
||||
|
||||
#endif
|
||||
@@ -1,123 +0,0 @@
|
||||
/*!
|
||||
* \file key.c
|
||||
*
|
||||
* \brief Target key implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "message.h"
|
||||
#include "xc6xxx.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define MESSAGE_MAX 40
|
||||
|
||||
|
||||
#define MSG_ADD_MAX(msg) (msg >= MESSAGE_MAX) ? (MESSAGE_MAX) : (msg+1)
|
||||
#define MSG_REDUCE_MIN(msg) (msg) ? (msg - 1) : 0
|
||||
#define MSG_LOOP_MAX_MIN(msg) (msg >= MESSAGE_MAX) ? (0) : (msg)
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
uint16_t message_buff[MESSAGE_MAX] = {0};
|
||||
volatile uint16_t message_in_count = 0;
|
||||
volatile uint16_t message_out_index = 0;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief app_key_message_send
|
||||
* @details key msg send
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_key_message_send(uint16_t msg)
|
||||
{
|
||||
if (message_in_count >= MESSAGE_MAX )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < MESSAGE_MAX ; i++)
|
||||
{
|
||||
if (message_buff[i] == 0)
|
||||
{
|
||||
message_buff[i] = msg;
|
||||
message_in_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief app_key_message_get
|
||||
* @details get key msg
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
uint16_t app_key_message_get(void)
|
||||
{
|
||||
uint16_t msg = 0;
|
||||
|
||||
if (!message_in_count)
|
||||
{
|
||||
message_out_index = 0;
|
||||
return msg;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < MESSAGE_MAX ; i++)
|
||||
{
|
||||
if (message_buff[message_out_index])
|
||||
{
|
||||
msg = message_buff[message_out_index];
|
||||
message_buff[message_out_index] = 0;
|
||||
message_out_index = MSG_ADD_MAX(message_out_index);
|
||||
message_out_index = MSG_LOOP_MAX_MIN(message_out_index);
|
||||
message_in_count = MSG_REDUCE_MIN(message_in_count);
|
||||
break;
|
||||
}
|
||||
message_out_index = MSG_ADD_MAX(message_out_index);
|
||||
message_out_index = MSG_LOOP_MAX_MIN(message_out_index);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief app_key_message_clr
|
||||
* @details clear key msg
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_key_message_clr(void)
|
||||
{
|
||||
memset(message_buff,0x00,MESSAGE_MAX);
|
||||
message_in_count = 0;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*!
|
||||
* \file key_message.h
|
||||
*
|
||||
* \brief The head file of key_message.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __KEY_MESSAGE_H__
|
||||
#define __KEY_MESSAGE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void app_key_message_send(uint16_t msg);
|
||||
uint16_t app_key_message_get(void);
|
||||
void app_key_message_clr(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __KEY_MESSAGE_H__ */
|
||||
@@ -1,207 +0,0 @@
|
||||
/*!
|
||||
* \file nec_infrared.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "xc6xxx.h"
|
||||
#include "gpio.h"
|
||||
#include "nec_infrared.h"
|
||||
#include "xc_drv_gpio.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
IR_struct IR = {0};
|
||||
//uint8_t gpio_intr_flag = false;
|
||||
uint64_t intr_val = 0;
|
||||
|
||||
extern uint8_t only_read_charactertics_buffer[];
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpio_demo
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_ir_init(void)
|
||||
{
|
||||
// Board IrInput Initialization
|
||||
GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0;
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx;
|
||||
GPIO_InitCfg.Pull = GPIO_PULLUP;
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_INPUT;
|
||||
GPIO_InitCfg.Int = RIS_FAIL_EDGE_INT;
|
||||
GPIO_InitCfg.Pin = IR_PIN;
|
||||
xc_gpio_init(&GPIO_InitCfg);
|
||||
// Gpio NVIC Enable
|
||||
NVIC_EnableIRQ(GPIO_IRQn);
|
||||
}
|
||||
/**
|
||||
* @brief gpio_intr_callback
|
||||
* @details Gpio interrupt callback function
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
__RAM_CODE void gpio_intr_callback(uint64_t intr_sta)
|
||||
{
|
||||
intr_val = intr_sta;
|
||||
if ((intr_sta & (1 << IR_PIN)) != 0)
|
||||
{
|
||||
ir_callback();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief This function handles EXIT Interrupt .
|
||||
*/
|
||||
void ir_callback(void)
|
||||
{
|
||||
uint32_t us = 20000;
|
||||
IR.timer_count = 640 - timer_tcv_get(TIMER2_IDX); //每次进外部中断,先保存当前的计数值 CNT加1的时间为31.25us
|
||||
|
||||
static uint8_t acunt = 0;
|
||||
acunt++;
|
||||
if (acunt == 255)
|
||||
acunt = 0;
|
||||
|
||||
xc_timer_stop(TIMER2_IDX);
|
||||
|
||||
if (xc_gpio_read_pin(IR_PIN) == 1) //检查PA5电平 上升沿 IR.timer_count的值为上一个下降沿到这次的上升沿,中间的间隔时间(即低电平时间)
|
||||
{
|
||||
if (IR.IR_event == 0 && IR.f_head == 0) //既没有开始接受01数据,也没有开始接受头码,那么进入接收头码判断
|
||||
{
|
||||
if (IR.timer_count > 280 && IR.timer_count < 296) //头码为9ms的低电平,允许误差100us
|
||||
{
|
||||
IR.f_head = 1; //如果符合,开始判定头码
|
||||
|
||||
}
|
||||
else if (IR.timer_count > 296) //如果头码已经大于9.1ms 认为是错误
|
||||
{
|
||||
IR.f_head = 0;
|
||||
IR.IR_decode_bit = 0; //电平计数超过了码元长度 清除位数计数
|
||||
IR.IR_code = 0;
|
||||
IR.IR_event = 0;
|
||||
|
||||
IR.IR_code_get = 0;
|
||||
IR.low_8bit = 0;
|
||||
IR.hig_8bit = 0;
|
||||
IR.rece_ok = 0;
|
||||
}
|
||||
}
|
||||
else if (IR.IR_event == 1) //如果头码判定正确,开始接受01数据
|
||||
{
|
||||
if (IR.timer_count > 12 && IR.timer_count < 25) //所有的01数据,开头都是0.56ms的低电平
|
||||
{
|
||||
IR.get_bit = 1; //如果符合,那么开始根据后面的高电平时间来判定此次为0还是1
|
||||
}
|
||||
else //否则清除所有数据
|
||||
{
|
||||
IR.f_head = 0;
|
||||
IR.IR_decode_bit = 0; //电平计数超过了码元长度 清除位数计数
|
||||
IR.IR_code = 0;
|
||||
IR.IR_event = 0;
|
||||
|
||||
IR.IR_code_get = 0;
|
||||
IR.low_8bit = 0;
|
||||
IR.hig_8bit = 0;
|
||||
IR.rece_ok = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //上一个上升沿到这次的下降沿,之间的时间间隔(即高电平时间)
|
||||
{
|
||||
if (IR.f_head == 1) //如果9ms的低电平成立了,开始判断是否有4.5ms的高电平时间
|
||||
{
|
||||
if (IR.timer_count > 135 && IR.timer_count < 153)
|
||||
{
|
||||
IR.IR_event = 1; //4.5ms成立,认为此次的头码成立,开始接收01数据
|
||||
}
|
||||
else
|
||||
{
|
||||
IR.IR_decode_bit = 0; //电平计数超过了码元长度 清除位数计数
|
||||
IR.IR_code = 0;
|
||||
IR.IR_event = 0;
|
||||
|
||||
IR.IR_code_get = 0;
|
||||
IR.low_8bit = 0;
|
||||
IR.hig_8bit = 0;
|
||||
IR.rece_ok = 0;
|
||||
}
|
||||
IR.f_head = 0; //清除接受头码标志
|
||||
}
|
||||
if (IR.IR_event == 1) //接收数据内容成立
|
||||
{
|
||||
if (IR.get_bit == 1) //如果0.56ms的低电平已经成立,那么开始判断这次的高电平时间
|
||||
{
|
||||
if (IR.timer_count > 12 && IR.timer_count < 25) //0.56ms低+0.56ms高,说明传输的数据为 0
|
||||
{
|
||||
IR.IR_code <<= 1;
|
||||
IR.IR_decode_bit ++;
|
||||
}
|
||||
else if (IR.timer_count > 43 && IR.timer_count < 63) //0.56ms低+1.68ms高,说明传输的数据为 1
|
||||
{
|
||||
IR.IR_code <<= 1;
|
||||
IR.IR_code ++; //数据位置1
|
||||
IR.IR_decode_bit ++;
|
||||
}
|
||||
else //如果0.56ms的低电平后接着的是不符合要求的高电平时间,那么清零所有数据
|
||||
{
|
||||
IR.f_head = 0;
|
||||
IR.IR_decode_bit = 0; //电平计数超过了码元长度 清除位数计数
|
||||
IR.IR_event = 0;
|
||||
IR.IR_code = 0;
|
||||
|
||||
IR.IR_code_get = 0;
|
||||
IR.low_8bit = 0;
|
||||
IR.hig_8bit = 0;
|
||||
IR.rece_ok = 0;
|
||||
}
|
||||
|
||||
if (IR.IR_decode_bit == 32) //接收了32位数据之后,开始判断内容
|
||||
{
|
||||
IR.IR_code_get = IR.IR_code;
|
||||
|
||||
IR.user_code = (uint16_t)(IR.IR_code_get >> 16); //获取遥控用户码
|
||||
|
||||
IR.IR_code_get = IR.IR_code;
|
||||
IR.low_8bit = IR.IR_code_get & 0x000000FF; //对于本项目而言之后低16位数据有用,其中15-8为数据,7-0为数据反码
|
||||
IR.hig_8bit = (IR.IR_code_get & 0x0000FF00) >> 8;
|
||||
IR.low_8bit ^= 0xFF; //拿反码异或1 得到取反数据
|
||||
|
||||
if (IR.low_8bit == IR.hig_8bit) //判定数据跟数据反码是否相符,如果相符则为有用数据,否则舍弃所有数据
|
||||
{
|
||||
IR.rece_ok = 1;
|
||||
only_read_charactertics_buffer[5] = IR.hig_8bit;
|
||||
}
|
||||
else
|
||||
{
|
||||
IR.rece_ok = 0;
|
||||
IR.low_8bit = 0;
|
||||
IR.hig_8bit = 0;
|
||||
IR.IR_code_get = 0;
|
||||
}
|
||||
IR.IR_decode_bit = 0;
|
||||
IR.IR_code = 0;
|
||||
IR.f_head = 0;
|
||||
IR.IR_event = 0;
|
||||
}
|
||||
IR.get_bit = 0; //每次处理完一位数据之后,清楚标志位,待下次0.56ms低电平成立之后再次判断
|
||||
}
|
||||
}
|
||||
}
|
||||
xc_timer_set_value(TIMER2_IDX, us); //设置定时器初值,自减
|
||||
xc_timer_start(TIMER2_IDX); //每次进入外部中断都要启动计数器
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __NEC_INFRARED_H__
|
||||
#define __NEC_INFRARED_H__
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define IR_PIN GPIO_2
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
typedef struct IR_decode
|
||||
{
|
||||
uint32_t timer_count; //定时器数据
|
||||
uint32_t IR_code; //读取到的红外码
|
||||
uint32_t IR_code_get;
|
||||
uint32_t IR_decode_bit;//解码接收位数
|
||||
uint32_t IR_event; //红外输出事件
|
||||
uint16_t user_code;//用户码
|
||||
uint8_t data_recving_flag;//红外接收中的标志
|
||||
uint8_t f_head;
|
||||
uint8_t get_bit;
|
||||
uint8_t low_8bit;
|
||||
uint8_t hig_8bit;
|
||||
uint8_t rece_ok;
|
||||
|
||||
uint8_t printf_datalen;
|
||||
|
||||
}IR_struct;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern IR_struct IR;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void ir_callback(void);
|
||||
void app_ir_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///* Private defines -----------------------------------------------------------*/
|
||||
|
||||
//#define IR_CODE_GET_POWER (uint8_t)(0xE2)
|
||||
//#define IR_CODE_GET_SPEED (uint8_t)(0xA2)
|
||||
//#define IR_CODE_GET_TIMER (uint8_t)(0xA8)
|
||||
//#define IR_CODE_GET_SHAKE (uint8_t)(0x18)
|
||||
|
||||
|
||||
|
||||
///* Exported variables prototypes ---------------------------------------------*/
|
||||
//extern UART_HandleTypeDef UartHandle;
|
||||
//extern __IO ITStatus UartReady;
|
||||
//extern TIM_HandleTypeDef TimHandle,Tim3Handle,Tim1Handle, Tim17Handle;
|
||||
//extern EXTI_HandleTypeDef exti_handle;
|
||||
//extern GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
|
||||
|
||||
//extern IR_struct IR;
|
||||
|
||||
|
||||
///* Exported functions prototypes ---------------------------------------------*/
|
||||
//void APP_ErrorHandler(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,143 +1,139 @@
|
||||
#include "ota_flash_interface.h"
|
||||
#include "arch.h"
|
||||
#include "dbg.h"
|
||||
// extern uint8_t ble_flash_operation_can_check(void);
|
||||
#include "ota_protocol.h"
|
||||
op_flash_t op_flash =
|
||||
{
|
||||
OP_IDEL,
|
||||
};
|
||||
|
||||
// extern op_flash_t op_flash;
|
||||
int ble_flash_later_sector_erase(uint32_t addr)
|
||||
{
|
||||
if (op_flash.op_state != OP_IDEL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// SPI_TypeDef *spi_handle = XC_SPI0;
|
||||
|
||||
// op_flash.spi_handle = spi_handle;
|
||||
op_flash.op_state = OP_WIAT_ERASE;
|
||||
op_flash.op_addr = addr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ble_flash_later_write_page(uint8_t *buff, uint32_t PageAddR)
|
||||
{
|
||||
if (op_flash.op_state != OP_IDEL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// SPI_TypeDef *spi_handle = XC_SPI0;
|
||||
|
||||
// op_flash.spi_handle = spi_handle;
|
||||
op_flash.op_state = OP_WIAT_WRITE;
|
||||
op_flash.op_addr = PageAddR;
|
||||
|
||||
for (int i = 0; i < FLASH_PAGE_SIZE; i++)
|
||||
{
|
||||
op_flash.op_buff[i] = buff[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
int ble_flash_later_page_erase(uint32_t addr)
|
||||
{
|
||||
if (op_flash.op_state != OP_IDEL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
op_flash.op_state = OP_WIAT_PAGE_ERASE;
|
||||
op_flash.op_addr = addr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
__RAM_CODE void ble_flash_handle(void)
|
||||
{
|
||||
if (op_flash.op_state == OP_IDEL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (op_flash.op_state == OP_WIAT_WRITE)
|
||||
{
|
||||
{
|
||||
// LOGI("FMC_SPI_Flash_WritePage: op_flash.op_addr=%x\n", op_flash.op_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_WritePage(op_flash.op_addr, op_flash.op_buff, 256);
|
||||
// if(op_flash.op_addr==0x31000 || op_flash.op_addr==OTA_PARAM_ADDR){
|
||||
// uint8_t data[FLASH_PAGE_SIZE];
|
||||
// FMC_SPI_Flash_ReadPage(op_flash.op_addr, data, FLASH_PAGE_SIZE);
|
||||
// LOGI("Flash Read data: \n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", data[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// LOGI("raw data: \n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", op_flash.op_buff[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// }
|
||||
// if( op_flash.op_addr==OTA_PARAM_ADDR){
|
||||
// LOGI("Flash write data: \n");
|
||||
// FMC_SPI_Flash_ReadPage(op_flash.op_addr, data, FLASH_PAGE_SIZE);
|
||||
// LOGI("Flash Read data: \n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", op_flash.op_buff[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", data[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// }
|
||||
GLOBAL_INT_RESTORE();
|
||||
op_flash.op_state = OP_IDEL;
|
||||
}
|
||||
}
|
||||
else if (op_flash.op_state == OP_WIAT_ERASE)
|
||||
{
|
||||
{
|
||||
// LOGI("FMC_SPI_Flash_Erase_Sector: op_flash.op_addr=%x\n", op_flash.op_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Erase_Sector(op_flash.op_addr);
|
||||
GLOBAL_INT_RESTORE();
|
||||
// LOGI("FMC_SPI_Flash_Erase_Sector: op_flash.op_addr1=%x\n", op_flash.op_addr);
|
||||
// {
|
||||
// uint8_t data[FLASH_PAGE_SIZE];
|
||||
// FMC_SPI_Flash_ReadPage(op_flash.op_addr, data, FLASH_PAGE_SIZE);
|
||||
//// LOGI("Erase Read data: \n");
|
||||
//// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
//// {
|
||||
//// LOGI("%02x ", data[i]);
|
||||
//// }
|
||||
//// LOGI("\n");
|
||||
// }
|
||||
op_flash.op_state = OP_IDEL;
|
||||
}
|
||||
} else if (op_flash.op_state == OP_WIAT_PAGE_ERASE)
|
||||
{
|
||||
{
|
||||
|
||||
LOGI("FMC_SPI_Flash_Erase_Page: op_flash.op_addr=%x\n", op_flash.op_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Page_Sector(op_flash.op_addr);
|
||||
GLOBAL_INT_RESTORE();
|
||||
op_flash.op_state = OP_IDEL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if !FAST_OTA
|
||||
#include "ota_flash_interface.h"
|
||||
#include "arch.h"
|
||||
#include "dbg.h"
|
||||
// extern uint8_t ble_flash_operation_can_check(void);
|
||||
#include "ota_protocol.h"
|
||||
#include "xc_drv_fmc_spi.h"
|
||||
|
||||
op_flash_t op_flash = {
|
||||
OP_IDEL,
|
||||
};
|
||||
|
||||
// extern op_flash_t op_flash;
|
||||
int ble_flash_later_sector_erase(uint32_t addr)
|
||||
{
|
||||
if (op_flash.op_state != OP_IDEL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// SPI_TypeDef *spi_handle = XC_SPI0;
|
||||
|
||||
// op_flash.spi_handle = spi_handle;
|
||||
op_flash.op_state = OP_WIAT_ERASE;
|
||||
op_flash.op_addr = addr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ble_flash_later_write_page(uint8_t *buff, uint32_t PageAddR)
|
||||
{
|
||||
if (op_flash.op_state != OP_IDEL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// SPI_TypeDef *spi_handle = XC_SPI0;
|
||||
|
||||
// op_flash.spi_handle = spi_handle;
|
||||
op_flash.op_state = OP_WIAT_WRITE;
|
||||
op_flash.op_addr = PageAddR;
|
||||
|
||||
for (int i = 0; i < FLASH_PAGE_SIZE; i++) {
|
||||
op_flash.op_buff[i] = buff[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
int ble_flash_later_page_erase(uint32_t addr)
|
||||
{
|
||||
if (op_flash.op_state != OP_IDEL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
op_flash.op_state = OP_WIAT_PAGE_ERASE;
|
||||
op_flash.op_addr = addr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ble_flash_handle(void)
|
||||
{
|
||||
if (op_flash.op_state == OP_IDEL) {
|
||||
return;
|
||||
} else if (op_flash.op_state == OP_WIAT_WRITE) {
|
||||
{
|
||||
// LOGI("FMC_SPI_Flash_WritePage: op_flash.op_addr=%x\n",
|
||||
// op_flash.op_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_WritePage(op_flash.op_addr, op_flash.op_buff, 256);
|
||||
// if(op_flash.op_addr==0x31000 ||
|
||||
// op_flash.op_addr==OTA_PARAM_ADDR){
|
||||
// uint8_t data[FLASH_PAGE_SIZE];
|
||||
// FMC_SPI_Flash_ReadPage(op_flash.op_addr, data,
|
||||
// FLASH_PAGE_SIZE); LOGI("Flash Read data: \n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", data[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// LOGI("raw data: \n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", op_flash.op_buff[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// }
|
||||
// if( op_flash.op_addr==OTA_PARAM_ADDR){
|
||||
// LOGI("Flash write data: \n");
|
||||
// FMC_SPI_Flash_ReadPage(op_flash.op_addr, data,
|
||||
// FLASH_PAGE_SIZE);
|
||||
// LOGI("Flash Read data: \n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", op_flash.op_buff[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
// {
|
||||
// LOGI("%02x ", data[i]);
|
||||
// }
|
||||
// LOGI("\n");
|
||||
// }
|
||||
GLOBAL_INT_RESTORE();
|
||||
op_flash.op_state = OP_IDEL;
|
||||
}
|
||||
} else if (op_flash.op_state == OP_WIAT_ERASE) {
|
||||
{
|
||||
// LOGI("FMC_SPI_Flash_Erase_Sector: op_flash.op_addr=%x\n",
|
||||
// op_flash.op_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Erase_Sector(op_flash.op_addr);
|
||||
GLOBAL_INT_RESTORE();
|
||||
// LOGI("FMC_SPI_Flash_Erase_Sector:
|
||||
// op_flash.op_addr1=%x\n", op_flash.op_addr);
|
||||
// {
|
||||
// uint8_t data[FLASH_PAGE_SIZE];
|
||||
// FMC_SPI_Flash_ReadPage(op_flash.op_addr, data,
|
||||
// FLASH_PAGE_SIZE);
|
||||
//// LOGI("Erase Read data: \n");
|
||||
//// for(uint16_t i = 0; i<FLASH_PAGE_SIZE; i++)
|
||||
//// {
|
||||
//// LOGI("%02x ", data[i]);
|
||||
//// }
|
||||
//// LOGI("\n");
|
||||
// }
|
||||
op_flash.op_state = OP_IDEL;
|
||||
}
|
||||
} else if (op_flash.op_state == OP_WIAT_PAGE_ERASE) {
|
||||
{
|
||||
|
||||
LOGI("FMC_SPI_Flash_Erase_Page: op_flash.op_addr=%x\n",
|
||||
op_flash.op_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
FMC_SPI_Flash_Erase_Page(op_flash.op_addr);
|
||||
GLOBAL_INT_RESTORE();
|
||||
op_flash.op_state = OP_IDEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,44 +1,45 @@
|
||||
#ifndef __OTA_FLASH_INTERFACE_H_
|
||||
#define __OTA_FLASH_INTERFACE_H_
|
||||
|
||||
#if (USE_XIP)
|
||||
#if (USE_ROM_FLASH)
|
||||
#include "xc6xxx_fmc_spi.h"
|
||||
#endif // (USE_ROM_FLASH)
|
||||
#endif // !(USE_XIP)
|
||||
#include <stdint.h>
|
||||
#define FMC_SPI_Flash_WritePage xc_fmc_spi_flash_write_page
|
||||
#define FMC_SPI_Flash_ReadPage xc_fmc_spi_flash_read_page
|
||||
#define FMC_SPI_Flash_Erase_Sector xc_fmc_spi_flash_erase_sector
|
||||
#define FMC_SPI_Flash_Page_Sector xc_fmc_spi_flash_erase_page
|
||||
typedef enum
|
||||
{
|
||||
OP_IDEL = 0,
|
||||
OP_WIAT_WRITE ,
|
||||
OP_DO_WRITE ,
|
||||
OP_DONE_WRITE ,
|
||||
OP_WIAT_ERASE ,
|
||||
OP_DO_ERASE ,
|
||||
OP_DONE_ERASE ,
|
||||
OP_WIAT_PAGE_ERASE,
|
||||
} op_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t op_state;
|
||||
uint32_t op_addr;
|
||||
uint8_t __attribute__((aligned(4))) op_buff[(256+8)];
|
||||
// SPI_TypeDef *spi_handle;
|
||||
} op_flash_t;
|
||||
|
||||
extern op_flash_t op_flash;
|
||||
|
||||
void ble_flash_handle(void);
|
||||
|
||||
int ble_flash_later_write_page(uint8_t *buff, uint32_t PageAddR);
|
||||
|
||||
int ble_flash_later_sector_erase(uint32_t addr);
|
||||
|
||||
#endif // __OTA_FLASH_INTERFACE_H_
|
||||
|
||||
|
||||
#ifndef __OTA_FLASH_INTERFACE_H_
|
||||
#define __OTA_FLASH_INTERFACE_H_
|
||||
|
||||
#if (USE_XIP)
|
||||
#if (USE_ROM_FLASH)
|
||||
#include "xc6xxx_fmc_spi.h"
|
||||
#endif // (USE_ROM_FLASH)
|
||||
#endif // !(USE_XIP)
|
||||
#include <stdint.h>
|
||||
#define FMC_SPI_Flash_WritePage xc_fmc_spi_flash_write_page
|
||||
#define FMC_SPI_Flash_ReadPage xc_fmc_spi_flash_read_page
|
||||
#define FMC_SPI_Flash_Erase_Sector FMC_SPI_Flash_Erase_Sector
|
||||
#define FMC_SPI_Flash_Erase_Page xc_fmc_spi_flash_erase_page
|
||||
typedef enum
|
||||
{
|
||||
OP_IDEL = 0,
|
||||
OP_WIAT_WRITE ,
|
||||
OP_DO_WRITE ,
|
||||
OP_DONE_WRITE ,
|
||||
OP_WIAT_ERASE ,
|
||||
OP_DO_ERASE ,
|
||||
OP_DONE_ERASE ,
|
||||
OP_WIAT_PAGE_ERASE,
|
||||
} op_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t op_state;
|
||||
uint32_t op_addr;
|
||||
uint8_t __attribute__((aligned(4))) op_buff[(256+8)];
|
||||
// SPI_TypeDef *spi_handle;
|
||||
} op_flash_t;
|
||||
|
||||
extern op_flash_t op_flash;
|
||||
|
||||
void ble_flash_handle(void);
|
||||
|
||||
int ble_flash_later_write_page(uint8_t *buff, uint32_t PageAddR);
|
||||
|
||||
int ble_flash_later_sector_erase(uint32_t addr);
|
||||
|
||||
int ble_flash_later_page_erase(uint32_t addr);
|
||||
#endif // __OTA_FLASH_INTERFACE_H_
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,233 +1,249 @@
|
||||
#ifndef __OTA_PROTOCOL_H_
|
||||
#define __OTA_PROTOCOL_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "arch.h"
|
||||
//#include "ble.h"
|
||||
//#include "ble_flash_operation.h"
|
||||
|
||||
|
||||
// extern void data_sent(uint8_t *buffer, uint16_t length);
|
||||
|
||||
// #define DEBUG(...) //DEBUG(__VA_ARGS__)
|
||||
|
||||
#define PARAM_CNT 5
|
||||
#define TRUES 1
|
||||
#define FALSE 0
|
||||
#define CRC32_INITIAL 0
|
||||
#define DELAY_MS
|
||||
#define FLASH_INIT
|
||||
#define FLASH_WRITE_PAGE ble_flash_later_write_page
|
||||
#define FLASH_READ_PAGE
|
||||
#define FLASH_SECTOR_ERASE ble_flash_later_sector_erase
|
||||
#define FlASH_WR_ENABLE
|
||||
#define FLASH_WAIT_READY
|
||||
#define FLASH_RELEASE_PD
|
||||
#define FLASH_ENTER_PD
|
||||
#define FLASH_PAGE_ERASE
|
||||
#define CEILING(dividend, divisor) ((dividend) / (divisor) + (((dividend) % (divisor)) ? 1 : 0))
|
||||
#define FOTAS_NOTIFY ota_slave_send_data
|
||||
#define FOTA_PAGE_NUM 16
|
||||
#define OTA_PARAM_ADDR ((8*1024)-512)
|
||||
enum fota_write_cmd
|
||||
{
|
||||
FOTAS_STA_CMD = 1,
|
||||
FOTAS_STA_RSP_CMD,
|
||||
FOTAS_INFO_CMD,
|
||||
FOTAS_INFO_RSP_CMD,
|
||||
FOTAS_DATA_CMD,
|
||||
FOTAS_COM_CMD,
|
||||
FOTAS_RES_CMD,
|
||||
};
|
||||
enum fota_result_rsp
|
||||
{
|
||||
FOTAS_SUCCEES,
|
||||
FOTAS_FAIL,
|
||||
};
|
||||
enum fota_inf_stat
|
||||
{
|
||||
FOTAS_INF_OK,
|
||||
FOTAS_INF_ERR,
|
||||
};
|
||||
enum fota_stat_rsp
|
||||
{
|
||||
FOTAS_STAT_OK,
|
||||
FOTAS_SW_DIF,
|
||||
FOTAS_ROM_DIF,
|
||||
FOTAS_OVERLOUP,
|
||||
};
|
||||
|
||||
enum fota_sn
|
||||
{
|
||||
FOTAS_RSP,
|
||||
FOTAS_SENT,
|
||||
};
|
||||
|
||||
enum fota_cmd_type
|
||||
{
|
||||
FOTAS_CMD,
|
||||
FOTAS_ACK,
|
||||
};
|
||||
|
||||
enum fota_ack_type
|
||||
{
|
||||
FOTAS_TRANS_SUC,
|
||||
FOTAS_DEV_READY,
|
||||
FOTAS_DEV_BUSY,
|
||||
FOTAS_TANS_TIOUT,
|
||||
FOTAS_TANS_CANCEL,
|
||||
FOTAS_TANS_LOSE,
|
||||
FOTAS_TANS_BIN_ACK,
|
||||
FOTAS_STATE_MAX,
|
||||
};
|
||||
enum fota_rsp_stat
|
||||
{
|
||||
FOTAS_RSP_READY,
|
||||
FOTAS_RCV_SECT_START,
|
||||
FOTAS_RCV_SECT_CANCEL,
|
||||
};
|
||||
enum fota_rcv_rsp
|
||||
{
|
||||
FOTAS_RSP_START,
|
||||
FOTAS_RSP_CMD,
|
||||
FOTAS_RECV_START,
|
||||
};
|
||||
struct img_hdr_t
|
||||
{
|
||||
// Secure OTA uses the Signature for image validation instead of calculating a CRC, but the use
|
||||
// of CRC==CRC-Shadow for quick boot-up determination of a validated image is still used.
|
||||
// User-defined Image Version Number - default logic uses simple a '!=' comparison to start an OTA .
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint16_t len;
|
||||
uint16_t sw_ver;
|
||||
uint16_t rom_ver; // Rom ver.
|
||||
uint32_t bin_size; // Image fotas_write_env.length in 4-byte blocks ().
|
||||
uint32_t crc; // CRC must not be 0x00000000 or 0xFFFFFFFF.
|
||||
uint16_t pack_num;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct fota_data_att
|
||||
{
|
||||
uint16_t sn;
|
||||
uint16_t len;
|
||||
uint8_t cmd;
|
||||
uint32_t segment_id;
|
||||
uint32_t crc;
|
||||
uint16_t sector_size;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct fota_data
|
||||
{
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint8_t data[256];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
APP->DEV
|
||||
sn,cmd,data,fnum
|
||||
DEV->APP
|
||||
sn,cmd,atype,para
|
||||
*/
|
||||
struct opencode_or_ack
|
||||
{
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint8_t data_or_atype; // data or ack type
|
||||
uint16_t fnum_or_para; // frame num or parameter
|
||||
uint16_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct dev_send_buf
|
||||
{
|
||||
uint16_t sn;
|
||||
uint16_t len;
|
||||
uint8_t cmd;
|
||||
uint16_t status;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct fotas_env
|
||||
{
|
||||
uint16_t sn;
|
||||
uint32_t crc;
|
||||
uint8_t status;
|
||||
uint32_t bin_size;
|
||||
uint8_t sector_buf[FOTA_PAGE_NUM][FLASH_PAGE_SIZE];
|
||||
uint16_t pack_num;
|
||||
struct opencode_or_ack ack;
|
||||
struct dev_send_buf send_buf;
|
||||
struct fota_data_att data_att;
|
||||
} __attribute__((packed));
|
||||
struct fotas_write_env
|
||||
{
|
||||
int old_length;
|
||||
int length;
|
||||
uint32_t write_addr;
|
||||
uint32_t erase_addr;
|
||||
uint16_t all_fnum;
|
||||
uint16_t cur_num;
|
||||
uint8_t para_buf[256];
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Status; /**/
|
||||
uint32_t SoftVer; /**/
|
||||
uint32_t ACheck; /*crc32*/
|
||||
uint32_t AAddr; /*sector align*/
|
||||
uint32_t ALen; /*page align*/
|
||||
uint32_t BCheck; /**/
|
||||
uint32_t BAddr; /**/
|
||||
uint32_t BLen; /**/
|
||||
uint32_t ALoadAddr;
|
||||
uint32_t BLoadAddr;
|
||||
uint32_t RESERVED0[2];
|
||||
} PARAM_UNIT;
|
||||
struct fotas_flag
|
||||
{
|
||||
uint8_t fir_ack_idx;
|
||||
uint8_t fir_rsp_stat;
|
||||
uint8_t first_pack_write_flag;
|
||||
uint8_t ota_succ_flag ;
|
||||
uint8_t rsp_stat;
|
||||
uint8_t ack_idx ;
|
||||
uint8_t sector_erase_flag;
|
||||
uint8_t wtitten_page_num ; //
|
||||
uint8_t wtite_flag; // Only when the valid data of the bin file is received, it will be set to 1
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
InvalidStat = 0,
|
||||
ActiveAStat = 1,
|
||||
EraseAStat = 2,
|
||||
OverwriteAStat = 3,
|
||||
ActiveBStat = 4,
|
||||
EraseBStat = 5,
|
||||
OverwriteBStat = 6,
|
||||
} STATUS_T;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PARAM_UNIT ParamUnit[PARAM_CNT];
|
||||
uint32_t ParamCrc32;
|
||||
uint32_t RESERVED1[3];
|
||||
} sBOOT_MESSAGE;
|
||||
extern uint32_t GenerateCrc32(uint32_t PartialCrc, char *Buffer, uint32_t Length);
|
||||
|
||||
void fota_disconnect_reset(void);
|
||||
|
||||
void xc_fota_dev_ack_cmd(uint16_t sn,
|
||||
uint8_t cmd,
|
||||
uint8_t data_or_atype,
|
||||
uint16_t fnum_or_para);
|
||||
|
||||
void xc_fota_server_write_ind(uint8_t *buffer, uint16_t buff_size);
|
||||
|
||||
void ota_write_flash(void);
|
||||
|
||||
void xc_ota_schedule(void);
|
||||
|
||||
void wdt_reset_system(void);
|
||||
|
||||
#endif // __OTA_PROTOCOL_H_
|
||||
#ifndef __OTA_PROTOCOL_H_
|
||||
#define __OTA_PROTOCOL_H_
|
||||
|
||||
#include "arch.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PARAM_CNT 5
|
||||
#define TRUES 1
|
||||
#define FALSE 0
|
||||
#define CRC32_INITIAL 0
|
||||
#define DELAY_MS
|
||||
#define FLASH_INIT
|
||||
#define FLASH_WRITE_PAGE ble_flash_later_write_page
|
||||
#define FLASH_READ_PAGE
|
||||
#define FLASH_SECTOR_ERASE ble_flash_later_sector_erase
|
||||
#define FlASH_WR_ENABLE
|
||||
#define FLASH_WAIT_READY
|
||||
#define FLASH_RELEASE_PD
|
||||
#define FLASH_ENTER_PD
|
||||
#define FLASH_PAGE_ERASE
|
||||
#define CEILING(dividend, divisor) \
|
||||
((dividend) / (divisor) + (((dividend) % (divisor)) ? 1 : 0))
|
||||
#define FOTAS_NOTIFY ota_slave_send_data
|
||||
// #define FOTA_PAGE_NUM 16
|
||||
#define FOTA_PAGE_NUM 8
|
||||
#define OTA_PARAM_ADDR ((8 * 1024) - 512)
|
||||
enum fota_write_cmd
|
||||
{
|
||||
FOTAS_STA_CMD = 1,
|
||||
FOTAS_STA_RSP_CMD,
|
||||
FOTAS_INFO_CMD,
|
||||
FOTAS_INFO_RSP_CMD,
|
||||
FOTAS_DATA_CMD,
|
||||
FOTAS_COM_CMD,
|
||||
FOTAS_RES_CMD,
|
||||
};
|
||||
enum fota_result_rsp
|
||||
{
|
||||
FOTAS_SUCCEES,
|
||||
FOTAS_FAIL,
|
||||
};
|
||||
enum fota_inf_stat
|
||||
{
|
||||
FOTAS_INF_OK,
|
||||
FOTAS_INF_ERR,
|
||||
};
|
||||
enum fota_stat_rsp
|
||||
{
|
||||
FOTAS_STAT_OK,
|
||||
FOTAS_SW_DIF,
|
||||
FOTAS_ROM_DIF,
|
||||
FOTAS_OVERLOUP,
|
||||
};
|
||||
|
||||
enum fota_sn
|
||||
{
|
||||
FOTAS_RSP,
|
||||
FOTAS_SENT,
|
||||
};
|
||||
|
||||
enum fota_cmd_type
|
||||
{
|
||||
FOTAS_CMD,
|
||||
FOTAS_ACK,
|
||||
};
|
||||
|
||||
enum fota_ack_type
|
||||
{
|
||||
FOTAS_TRANS_SUC,
|
||||
FOTAS_DEV_READY,
|
||||
FOTAS_DEV_BUSY,
|
||||
FOTAS_TANS_TIOUT,
|
||||
FOTAS_TANS_CANCEL,
|
||||
FOTAS_TANS_LOSE,
|
||||
FOTAS_TANS_BIN_ACK,
|
||||
FOTAS_STATE_MAX,
|
||||
};
|
||||
enum fota_rsp_stat
|
||||
{
|
||||
FOTAS_RSP_READY,
|
||||
FOTAS_RCV_SECT_START,
|
||||
FOTAS_RCV_SECT_CANCEL,
|
||||
};
|
||||
enum fota_rcv_rsp
|
||||
{
|
||||
FOTAS_RSP_START,
|
||||
FOTAS_RSP_CMD,
|
||||
FOTAS_RECV_START,
|
||||
};
|
||||
struct img_hdr_t
|
||||
{
|
||||
// Secure OTA uses the Signature for image validation instead of calculating
|
||||
// a CRC, but the use of CRC==CRC-Shadow for quick boot-up determination of
|
||||
// a validated image is still used. User-defined Image Version Number -
|
||||
// default logic uses simple a '!=' comparison to start an OTA .
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint16_t len;
|
||||
uint16_t sw_ver;
|
||||
uint16_t rom_ver; // Rom ver.
|
||||
uint32_t bin_size; // Image fotas_write_env.length in 4-byte blocks ().
|
||||
uint32_t crc; // CRC must not be 0x00000000 or 0xFFFFFFFF.
|
||||
uint16_t pack_num;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct fota_data_att
|
||||
{
|
||||
uint16_t sn;
|
||||
uint16_t len;
|
||||
uint8_t cmd;
|
||||
uint32_t segment_id;
|
||||
uint32_t crc;
|
||||
uint16_t sector_size;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct fota_data
|
||||
{
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint8_t data[256];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
APP->DEV
|
||||
sn,cmd,data,fnum
|
||||
DEV->APP
|
||||
sn,cmd,atype,para
|
||||
*/
|
||||
struct opencode_or_ack
|
||||
{
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint8_t data_or_atype; // data or ack type
|
||||
uint16_t fnum_or_para; // frame num or parameter
|
||||
uint16_t data;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct dev_send_buf
|
||||
{
|
||||
uint16_t sn;
|
||||
uint16_t len;
|
||||
uint8_t cmd;
|
||||
uint16_t status;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct fotas_env
|
||||
{
|
||||
uint16_t sn;
|
||||
uint32_t crc;
|
||||
uint8_t status;
|
||||
uint32_t bin_size;
|
||||
uint8_t sector_buf[FOTA_PAGE_NUM][FLASH_PAGE_SIZE];
|
||||
uint16_t pack_num;
|
||||
struct opencode_or_ack ack;
|
||||
struct dev_send_buf send_buf;
|
||||
struct fota_data_att data_att;
|
||||
} __attribute__((packed));
|
||||
struct fotas_write_env
|
||||
{
|
||||
int old_length;
|
||||
int length;
|
||||
uint32_t write_addr;
|
||||
uint32_t erase_addr;
|
||||
uint16_t all_fnum;
|
||||
uint16_t cur_num;
|
||||
uint8_t para_buf[256];
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Status; /**/
|
||||
uint32_t SoftVer; /**/
|
||||
uint32_t ACheck; /*crc32*/
|
||||
uint32_t AAddr; /*sector align*/
|
||||
uint32_t ALen; /*page align*/
|
||||
uint32_t BCheck; /**/
|
||||
uint32_t BAddr; /**/
|
||||
uint32_t BLen; /**/
|
||||
uint32_t ALoadAddr;
|
||||
uint32_t BLoadAddr;
|
||||
uint32_t RESERVED0[2];
|
||||
} PARAM_UNIT;
|
||||
struct fotas_flag
|
||||
{
|
||||
uint8_t ota_status;
|
||||
uint8_t fir_ack_idx;
|
||||
uint8_t fir_rsp_stat;
|
||||
uint8_t first_pack_write_flag;
|
||||
uint8_t ota_succ_flag;
|
||||
uint8_t rsp_stat;
|
||||
uint8_t ack_idx;
|
||||
uint8_t sector_erase_flag;
|
||||
uint8_t wtitten_page_num; //
|
||||
uint8_t wtite_flag; // Only when the valid data of the bin file is received,
|
||||
// it will be set to 1
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
InvalidStat = 0,
|
||||
ActiveAStat = 1,
|
||||
EraseAStat = 2,
|
||||
OverwriteAStat = 3,
|
||||
ActiveBStat = 4,
|
||||
EraseBStat = 5,
|
||||
OverwriteBStat = 6,
|
||||
} STATUS_T;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PARAM_UNIT ParamUnit[PARAM_CNT];
|
||||
uint32_t ParamCrc32;
|
||||
uint32_t RESERVED1[3];
|
||||
} sBOOT_MESSAGE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t sw_ver; //sw_ver
|
||||
uint16_t rom_ver; // Rom ver.
|
||||
uint32_t bin_size; // Image length in 4-byte blocks ().
|
||||
} img_hdr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
img_hdr_t img;
|
||||
PARAM_UNIT ParamUnit[PARAM_CNT];
|
||||
uint32_t ParamCrc32;
|
||||
uint32_t RESERVED1[3];
|
||||
} sBOOT_MESSAGE_OTA;
|
||||
|
||||
extern struct fotas_flag fotas_status;
|
||||
|
||||
extern uint32_t GenerateCrc32(uint32_t PartialCrc, char *Buffer,
|
||||
uint32_t Length);
|
||||
|
||||
void fota_disconnect_reset(void);
|
||||
|
||||
void xc_fota_dev_ack_cmd(uint16_t sn, uint8_t cmd, uint8_t data_or_atype,
|
||||
uint16_t fnum_or_para);
|
||||
|
||||
void xc_fota_server_write_ind(uint8_t *buffer, uint16_t buff_size);
|
||||
|
||||
void ota_write_flash(void);
|
||||
|
||||
void xc_ota_schedule(void);
|
||||
|
||||
void wdt_reset_system(void);
|
||||
void xc_ota_schedule(void);
|
||||
|
||||
#endif // __OTA_PROTOCOL_H_
|
||||
|
||||
@@ -1,170 +1,180 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file ota_server.c
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#include "rwip_config.h"
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
#include "ota_server.h"
|
||||
#include "ota_protocol.h"
|
||||
|
||||
uint8_t ota_srv_user_lid = GATT_INVALID_USER_LID;
|
||||
uint16_t ota_svc_start_hdl = GATT_INVALID_HDL;
|
||||
uint8_t ota_svc_tx_char_notify = DISABLE;
|
||||
|
||||
static const gatt_att_desc_t ota_server_atts[] = {
|
||||
[OTA_SVC_DECL] =
|
||||
{
|
||||
.uuid = 0x00,0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[OTA_SVC_RX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid = 0x03, 0x28,
|
||||
.info = GATT_ATT_RD_BIT| ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[OTA_SVC_RX_CHAR_VAL] =
|
||||
{
|
||||
.uuid = OTA_SVC_RX_CHAR_UUID,
|
||||
.info = GATT_ATT_WC_BIT | GATT_ATT_RD_BIT | ATT_UUID(128),
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | OTA_SVC_RX_CHAR_VAL_MAX_LENGTH ,
|
||||
},
|
||||
[OTA_SVC_TX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid = 0x03, 0x28,
|
||||
.info = GATT_ATT_RD_BIT| ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[OTA_SVC_TX_CHAR_VAL] =
|
||||
{
|
||||
.uuid = OTA_SVC_TX_CHAR_UUID,
|
||||
.info = GATT_ATT_N_BIT | ATT_UUID(128),
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | OTA_SVC_TX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[OTA_SVC_TX_CHAR_CFG] =
|
||||
{
|
||||
.uuid = 0x02, 0x29,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WR_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
|
||||
uint16_t ota_srv_get_hdl_from_att_idx(uint8_t idx)
|
||||
{
|
||||
return ota_svc_start_hdl + idx ;
|
||||
}
|
||||
|
||||
// This function is called when GATT server user has initiated event send to
|
||||
// peer device or if an error occurs.
|
||||
__STATIC void ota_svc_cb_event_sent(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t dummy, uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, dummy:%d, status:%d \r\n", __func__,
|
||||
conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
// This function is called when peer want to read local attribute database
|
||||
// value.
|
||||
__STATIC void ota_svc_cb_att_read_get(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, uint16_t max_length)
|
||||
{
|
||||
uint16_t status;
|
||||
uint8_t data[] = {0x12, 0x15, 0x46, 0x62};
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d, "
|
||||
"max_length:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset, max_length);
|
||||
// Send result to peer device
|
||||
status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
sizeof(data), sizeof(data), data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_read_cfm error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC void ota_svc_cb_att_val_set(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
uint16_t status;
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset);
|
||||
status =
|
||||
xc_ble_gatt_srv_write_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_write_cfm error 0x%x", status);
|
||||
}
|
||||
LOGI("length:%d data:\r\n", length);
|
||||
// DUMP_DATA_PRINTF(co_buf_data(p_data), length);
|
||||
xc_fota_server_write_ind(co_buf_data(p_data), length);
|
||||
// LOGI("hdl=%x %x\r\n", hdl, ota_srv_get_hdl_from_att_idx(OTA_SVC_TX_CHAR_CFG));
|
||||
if (hdl == ota_srv_get_hdl_from_att_idx(OTA_SVC_TX_CHAR_CFG)) {
|
||||
if ((co_buf_data(p_data)[1] == 0) && (co_buf_data(p_data)[0] == 0)) {
|
||||
ota_svc_tx_char_notify = DISABLE;
|
||||
} else {
|
||||
ota_svc_tx_char_notify = ENABLE;
|
||||
LOGI("ota_svc_tx_char_notify ENABLE\r\n");
|
||||
// uint8_t data[] = {0x12, 0x13, 0x14};
|
||||
// ota_slave_send_data(data, sizeof(data), OTA_SVC_TX_CHAR_VAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const gatt_srv_cb_t ota_src_cb = {
|
||||
.cb_event_sent = ota_svc_cb_event_sent,
|
||||
.cb_att_read_get = ota_svc_cb_att_read_get,
|
||||
.cb_att_val_set = ota_svc_cb_att_val_set,
|
||||
};
|
||||
|
||||
uint8_t ota_svc_add(void)
|
||||
{
|
||||
int nb_att = sizeof(ota_server_atts) / sizeof(ota_server_atts[0]);
|
||||
uint16_t status;
|
||||
uint8_t ota_svc_uuid[GATT_UUID_128_LEN] = OTA_SVC_UUID;
|
||||
status = xc_ble_gatt_user_srv_register(GAP_LE_MTU_MAX, 0, &ota_src_cb,
|
||||
&ota_srv_user_lid);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_user_srv_register error 0x%x", status);
|
||||
}
|
||||
status = xc_ble_gatt_service_add(
|
||||
ota_srv_user_lid, GATT_UUID_128 << GATT_SVC_UUID_TYPE_LSB, ota_svc_uuid,
|
||||
nb_att, NULL, &(ota_server_atts[0]), nb_att, &ota_svc_start_hdl);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("xc_ble_gatt_service_add error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx)
|
||||
{
|
||||
uint16_t status = INVALID_DATA;
|
||||
struct app_env_tag * app_env = get_app_env();
|
||||
if (app_env->slave_connected && ota_svc_tx_char_notify) {
|
||||
status = xc_ble_gatt_srv_notify(app_env->slave_conidx, ota_srv_user_lid, 0,
|
||||
ota_srv_get_hdl_from_att_idx(att_idx), len,
|
||||
data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_notify error 0x%x", status);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file ota_server.c
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#if !FAST_OTA
|
||||
#include "rwip_config.h"
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
#include "ota_protocol.h"
|
||||
#include "ota_server.h"
|
||||
|
||||
uint8_t ota_srv_user_lid = GATT_INVALID_USER_LID;
|
||||
uint16_t ota_svc_start_hdl = GATT_INVALID_HDL;
|
||||
uint8_t ota_svc_tx_char_notify = DISABLE;
|
||||
uint8_t ota_start_cmd[6] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x00};
|
||||
static const gatt_att_desc_t ota_server_atts[] = {
|
||||
[OTA_SVC_DECL] =
|
||||
{
|
||||
.uuid = 0x00,
|
||||
0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[OTA_SVC_RX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid = 0x03,
|
||||
0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[OTA_SVC_RX_CHAR_VAL] =
|
||||
{
|
||||
.uuid = OTA_SVC_RX_CHAR_UUID,
|
||||
.info = GATT_ATT_WC_BIT | GATT_ATT_RD_BIT | ATT_UUID(128),
|
||||
.ext_info = GATT_ATT_NO_OFFSET_BIT | OTA_SVC_RX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[OTA_SVC_TX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid = 0x03,
|
||||
0x28,
|
||||
.info = GATT_ATT_RD_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
[OTA_SVC_TX_CHAR_VAL] =
|
||||
{
|
||||
.uuid = OTA_SVC_TX_CHAR_UUID,
|
||||
.info = GATT_ATT_N_BIT | ATT_UUID(128),
|
||||
.ext_info = GATT_ATT_NO_OFFSET_BIT | OTA_SVC_TX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[OTA_SVC_TX_CHAR_CFG] =
|
||||
{
|
||||
.uuid = 0x02,
|
||||
0x29,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WR_BIT | ATT_UUID(16),
|
||||
.ext_info = 0,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
|
||||
uint16_t ota_srv_get_hdl_from_att_idx(uint8_t idx)
|
||||
{
|
||||
return ota_svc_start_hdl + idx;
|
||||
}
|
||||
|
||||
// This function is called when GATT server user has initiated event send to
|
||||
// peer device or if an error occurs.
|
||||
__STATIC void ota_svc_cb_event_sent(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t dummy, uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, dummy:%d, status:%d \r\n", __func__,
|
||||
conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
// This function is called when peer want to read local attribute database
|
||||
// value.
|
||||
__STATIC void ota_svc_cb_att_read_get(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, uint16_t max_length)
|
||||
{
|
||||
uint16_t status;
|
||||
uint8_t data[] = {0x12, 0x15, 0x46, 0x62};
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d, "
|
||||
"max_length:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset, max_length);
|
||||
// Send result to peer device
|
||||
status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
sizeof(data), sizeof(data), data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_read_cfm error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC void ota_svc_cb_att_val_set(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
uint16_t status;
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset);
|
||||
status =
|
||||
xc_ble_gatt_srv_write_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_write_cfm error 0x%x", status);
|
||||
}
|
||||
LOGI("length:%d data:\r\n", length);
|
||||
// DUMP_DATA_PRINTF(co_buf_data(p_data), length);
|
||||
if (!memcmp(co_buf_data(p_data), ota_start_cmd, 6) || fotas_status.ota_status)
|
||||
{
|
||||
fotas_status.ota_status = 1;
|
||||
xc_fota_server_write_ind(co_buf_data(p_data), length);
|
||||
}
|
||||
|
||||
// LOGI("hdl=%x %x\r\n", hdl,
|
||||
// ota_srv_get_hdl_from_att_idx(OTA_SVC_TX_CHAR_CFG));
|
||||
if (hdl == ota_srv_get_hdl_from_att_idx(OTA_SVC_TX_CHAR_CFG)) {
|
||||
if ((co_buf_data(p_data)[1] == 0) && (co_buf_data(p_data)[0] == 0)) {
|
||||
ota_svc_tx_char_notify = DISABLE;
|
||||
} else {
|
||||
ota_svc_tx_char_notify = ENABLE;
|
||||
LOGI("ota_svc_tx_char_notify ENABLE\r\n");
|
||||
// uint8_t data[] = {0x12, 0x13, 0x14};
|
||||
// ota_slave_send_data(data, sizeof(data), OTA_SVC_TX_CHAR_VAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const gatt_srv_cb_t ota_src_cb = {
|
||||
.cb_event_sent = ota_svc_cb_event_sent,
|
||||
.cb_att_read_get = ota_svc_cb_att_read_get,
|
||||
.cb_att_val_set = ota_svc_cb_att_val_set,
|
||||
};
|
||||
|
||||
uint8_t ota_svc_add(void)
|
||||
{
|
||||
int nb_att = sizeof(ota_server_atts) / sizeof(ota_server_atts[0]);
|
||||
uint16_t status;
|
||||
uint8_t ota_svc_uuid[GATT_UUID_128_LEN] = OTA_SVC_UUID;
|
||||
status =
|
||||
xc_ble_gatt_user_srv_register(133, 0, &ota_src_cb, &ota_srv_user_lid);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_user_srv_register error 0x%x", status);
|
||||
}
|
||||
status = xc_ble_gatt_service_add(
|
||||
ota_srv_user_lid, GATT_UUID_128 << GATT_SVC_UUID_TYPE_LSB, ota_svc_uuid,
|
||||
nb_att, NULL, &(ota_server_atts[0]), nb_att, &ota_svc_start_hdl);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("xc_ble_gatt_service_add error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx)
|
||||
{
|
||||
uint16_t status = INVALID_DATA;
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
if (app_env->slave_connected && ota_svc_tx_char_notify) {
|
||||
status = xc_ble_gatt_srv_notify(
|
||||
app_env->slave_conidx, ota_srv_user_lid, 0,
|
||||
ota_srv_get_hdl_from_att_idx(att_idx), len, data);
|
||||
if (status != GATT_NO_ERROR) {
|
||||
LOGI_ERR("gatt_srv_notify error 0x%x", status);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
#endif
|
||||
|
||||
@@ -1,45 +1,50 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file ota_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _OTA_SERVER_H_
|
||||
#define _OTA_SERVER_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
#include "xc6xxx.h"
|
||||
|
||||
#define OTA_SVC_UUID {0xFA, 0x34,0x9B,0x5F,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x10,0xFF,0x00,0x00}
|
||||
#define OTA_SVC_TX_CHAR_UUID 0xFB,0x34,0x9B,0x5F,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x11,0xFF,0x00,0x00
|
||||
#define OTA_SVC_RX_CHAR_UUID 0xFB,0x34,0x9B,0x5F,0x80,0x00,0x00,0x80,0x00,0x10,0x00,0x00,0x12,0xFF,0x00,0x00
|
||||
|
||||
|
||||
|
||||
#define OTA_SVC_RX_CHAR_VAL_MAX_LENGTH (512)
|
||||
#define OTA_SVC_TX_CHAR_VAL_MAX_LENGTH (512)
|
||||
|
||||
enum ota_svc
|
||||
{
|
||||
OTA_SVC_DECL = 0,
|
||||
OTA_SVC_RX_CHAR_DECL_CHAR,
|
||||
OTA_SVC_RX_CHAR_VAL,
|
||||
OTA_SVC_TX_CHAR_DECL_CHAR,
|
||||
OTA_SVC_TX_CHAR_VAL,
|
||||
OTA_SVC_TX_CHAR_CFG,
|
||||
};
|
||||
uint8_t ota_svc_add(void);
|
||||
uint8_t ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
#endif // _OTA_SERVER_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file ota_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _OTA_SERVER_H_
|
||||
#define _OTA_SERVER_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc6xxx.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
|
||||
#define OTA_SVC_UUID \
|
||||
{ \
|
||||
0xFA, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, \
|
||||
0x00, 0x10, 0xFF, 0x00, 0x00 \
|
||||
}
|
||||
#define OTA_SVC_TX_CHAR_UUID \
|
||||
0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \
|
||||
0x11, 0xFF, 0x00, 0x00
|
||||
#define OTA_SVC_RX_CHAR_UUID \
|
||||
0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, \
|
||||
0x12, 0xFF, 0x00, 0x00
|
||||
|
||||
#define OTA_SVC_RX_CHAR_VAL_MAX_LENGTH (512)
|
||||
#define OTA_SVC_TX_CHAR_VAL_MAX_LENGTH (512)
|
||||
|
||||
enum ota_svc
|
||||
{
|
||||
OTA_SVC_DECL = 0,
|
||||
OTA_SVC_RX_CHAR_DECL_CHAR,
|
||||
OTA_SVC_RX_CHAR_VAL,
|
||||
OTA_SVC_TX_CHAR_DECL_CHAR,
|
||||
OTA_SVC_TX_CHAR_VAL,
|
||||
OTA_SVC_TX_CHAR_CFG,
|
||||
};
|
||||
uint8_t ota_svc_add(void);
|
||||
uint8_t ota_slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
#endif // _OTA_SERVER_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,146 +0,0 @@
|
||||
/*!
|
||||
* \file pga_adc.h
|
||||
*
|
||||
* \brief The head file of pga_adc.h
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __BSP_AUDIO_ADC_H_
|
||||
#define __BSP_AUDIO_ADC_H_
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "stdint.h"
|
||||
#include "xc60xx.h"
|
||||
#include "xc_drv_adc.h"
|
||||
#include "xc_drv_pga.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define DMA_ENABLE 0
|
||||
#define DMA_MULTIPLE_TRANS_ENABLE 0
|
||||
#define ADC_PWM_MODE 1
|
||||
#define MIC_SAMPLING_DEBUG 0 ///
|
||||
|
||||
#define USER_KEY_EN 1// KEY
|
||||
|
||||
#define MIC_GAIN_1_EN 1 // The first-level gain is enabled : 20DB
|
||||
#define MIC_GAIN_2_LEVEN 0X08 // Second-stage gain : 1.6DB * N( 0 - 0X0E )
|
||||
|
||||
#define ADC_CLK_DIV_0 (0x00UL)
|
||||
#define ADC_CLK_DIV_2 (0x01UL)
|
||||
#define ADC_CLK_DIV_4 (0x03UL)
|
||||
#define ADC_CLK_DIV_8 (0x07UL)
|
||||
#define ADC_CLK_DIV_16 (0x0fUL)
|
||||
|
||||
#define ADC_CLOCK_FREQ_8M ADC_CLK_DIV_0 // ADC_FREQ_8M
|
||||
#define ADC_CLOCK_FREQ_4M ADC_CLK_DIV_2 // ADC_FREQ_4M
|
||||
#define ADC_CLOCK_FREQ_2M ADC_CLK_DIV_4 // ADC_FREQ_2M
|
||||
#define ADC_CLOCK_FREQ_1M ADC_CLK_DIV_8 // ADC_FREQ_1M
|
||||
#define ADC_CLOCK_FREQ_500K ADC_CLK_DIV_16 // ADC_FREQ_500K
|
||||
|
||||
#define ADC_FREQ_CLOCK ADC_CLOCK_FREQ_2M // ADC CLOCK select (ADC_CLOCK_FREQ_1M - ADC_CLOCK_FREQ_4M )
|
||||
|
||||
#define MIC_SAMPLING_8K 0
|
||||
#define MIC_SAMPLING_16K 1
|
||||
#define SAMPLING_TYPE MIC_SAMPLING_16K
|
||||
|
||||
|
||||
#define MIC_SAMPLING_MAX_LEN 480//Recording cache buff length
|
||||
#define MIC_SAMPLING_BUFF_MAX 2//
|
||||
|
||||
|
||||
#define PCM_DATA_DEBUG_EN 0 // uart DEBUG pcm data
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t data_buff[MIC_SAMPLING_BUFF_MAX][MIC_SAMPLING_MAX_LEN]; //audio data to the buff
|
||||
uint16_t data_rx_index; //data_buff index
|
||||
uint16_t data_rx_len; //data_buff len
|
||||
uint8_t save_buf_index; //double mic buff 1 index,data_buff[save_buf_index] []
|
||||
uint8_t get_buf_index; //double mic buff 1 index,data_buff[save_buf_index] []
|
||||
uint8_t save_data_buff_count; // mic buff SAVE index CON
|
||||
uint8_t buf_full_flag;
|
||||
|
||||
uint8_t sampling_wait_count; // Audio sampling data interval ,The sampling frequency is calculated based on the sampling speed of the ADC ,For example, 16K sampling
|
||||
uint8_t sampling_count; // Calculate the audio sampling points
|
||||
|
||||
int16_t pga_offset_val;
|
||||
} mic_audio_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if (MIC_SAMPLING_DEBUG)
|
||||
uint32_t audio_adc_rx_con;
|
||||
uint8_t audio_rx_stop_flag;
|
||||
#endif // MIC_SAMPLING_DEBUG
|
||||
|
||||
#if (MIC_SAMPLING_DEBUG)
|
||||
uint16_t rec_time;
|
||||
uint16_t rec_time_con;
|
||||
#endif //( MIC_SAMPLING_DEBUG)
|
||||
|
||||
uint8_t state;
|
||||
|
||||
} mic_record_t;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
REC_INIT,
|
||||
REC_START,
|
||||
REC_STOP,
|
||||
};
|
||||
|
||||
#if (ADC_PWM_MODE)
|
||||
enum adc_fs {
|
||||
adc_fs_8k = 0,
|
||||
adc_fs_16k,
|
||||
};
|
||||
#endif
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern mic_audio_t mic_audio;
|
||||
extern mic_record_t record;
|
||||
extern uint16_t adc_mic_average_val;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void audio_adc_rx_dma_event_handler(void);
|
||||
void audio_adc_rx_event_handler(uint16_t pga_adc_val);
|
||||
void audio_adc_start_get_value(ADC_ChannelTypeDef_t Channel, uint16_t *adc_val);
|
||||
void app_pga_init(void);
|
||||
void app_audio_record_init(void);
|
||||
void app_audio_record_start(void);
|
||||
void app_audio_record_stop(void);
|
||||
uint8_t app_get_record_state(void);
|
||||
uint8_t app_get_record_buff_full_state(void);
|
||||
void app_clr_record_buff_full_state(void);
|
||||
void app_record_process(void);
|
||||
void mic_pga_adc_demo(void);
|
||||
|
||||
#endif //__BSP_AUDIO_ADC_H_
|
||||
@@ -1,100 +0,0 @@
|
||||
/*!
|
||||
* \file pwm.c
|
||||
*
|
||||
* \brief Target pwm implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
/*------------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
--------------------------------------------------------------------------------------*/
|
||||
#include "pwm.h"
|
||||
#include "xc_drv_pwm.h"
|
||||
#include "rgblight.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Local Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
uint16_t ch0_capture_data[CAPTURE_DATA_MAX];
|
||||
uint16_t ch1_capture_data[CAPTURE_DATA_MAX];
|
||||
uint16_t ch2_capture_data[CAPTURE_DATA_MAX];
|
||||
|
||||
PWM_CAP_STA_TypeDef pwm_cap_state = PWM_CAP_IDLE;
|
||||
PWM_BRK_STA_TypeDef pwm_brk_state = PWM_BRK_IDLE;
|
||||
PWM_BRK_CAP_STA_TypeDef pwm_brk_cap_state = PWM_BRK_CAP_VALID;
|
||||
pwm_ch_cap_dutycycle_t pwm_ch_cap_dutycycle;
|
||||
pwm_ch_cap_freq_t pwm_ch_cap_freq;
|
||||
pwm_ch_cap_type_t pwm_ch_cap_type;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void UpdateDisplay(void)
|
||||
{
|
||||
xc_pwm_dutycycle_set(PWM2_IDX,256,r_DutyCycle*Brightness/10);
|
||||
xc_pwm_dutycycle_set(PWM3_IDX,256,g_DutyCycle*Brightness/10);
|
||||
xc_pwm_dutycycle_set(PWM5_IDX,256,b_DutyCycle*Brightness/10);
|
||||
}
|
||||
/**
|
||||
* @brief app_pwm_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_pwm_init()
|
||||
{
|
||||
// PWM0 and PWM1 can be mapped to other pins, PWM0 and PWM1 have inverted output.
|
||||
// PWM(HZ) = PWMCLK(16000000)/(DutyCycleAcc*(period+1))/2
|
||||
PWM_InitCfg_t pwm_cfg;
|
||||
|
||||
pwm_cfg.DutyCycleAcc = 256;
|
||||
pwm_cfg.Period = 29;
|
||||
pwm_cfg.SrcClk = PWM_CLK_SRC_32M_DIV;
|
||||
pwm_cfg.SrcEnable = PWM_EN_SEL_ALL;
|
||||
|
||||
pwm_cfg.DutyCycle =240; //r_DutyCycle*Brightness/10;
|
||||
pwm_cfg.OutputPin = GPIO_12;
|
||||
xc_pwm_init(PWM2_IDX, &pwm_cfg);//R
|
||||
|
||||
pwm_cfg.DutyCycle = g_DutyCycle*Brightness/10;
|
||||
pwm_cfg.OutputPin = GPIO_13; // The pin cannot be changed
|
||||
xc_pwm_init(PWM3_IDX, &pwm_cfg);//G
|
||||
|
||||
pwm_cfg.DutyCycle = b_DutyCycle*Brightness/10;
|
||||
pwm_cfg.OutputPin = GPIO_1; // The pin cannot be changed
|
||||
xc_pwm_init(PWM5_IDX, &pwm_cfg);//B
|
||||
|
||||
xc_pwm_start_all();
|
||||
}
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*!
|
||||
* \file pwm_test.h
|
||||
*
|
||||
* \brief The head file of pwm_test.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PWM_TEST_H__
|
||||
#define __PWM_TEST_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define DEVIATION_FREQ 10
|
||||
#define DEVIATION_DUTYCYCLE 10
|
||||
#define CAPTURE_DATA_MAX 101
|
||||
#define CAPTURE_VALID_POS 4
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
PWM_CAP_IDLE = 0,
|
||||
PWM_CAP_FREQ,
|
||||
PWM_CAP_DUTYCYCLE,
|
||||
PWM_CAP_RIGHT,
|
||||
PWM_CAP_ERROR,
|
||||
} PWM_CAP_STA_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PWM_BRK_IDLE = 0,
|
||||
PWM_BRK_START,
|
||||
PWM_BRK_STOP,
|
||||
} PWM_BRK_STA_TypeDef;
|
||||
typedef enum
|
||||
{
|
||||
PWM_BRK_CAP_VALID,
|
||||
PWM_BRK_CAP_RECOVERY,
|
||||
PWM_BRK_CAP_ERROR,
|
||||
} PWM_BRK_CAP_STA_TypeDef;
|
||||
typedef struct pwm_ch_cap_freq
|
||||
{
|
||||
uint16_t ch0_cap_freq;
|
||||
uint16_t ch1_cap_freq;
|
||||
uint16_t ch2_cap_freq;
|
||||
} pwm_ch_cap_freq_t;
|
||||
typedef struct pwm_ch_cap_dutycycle
|
||||
{
|
||||
uint16_t ch0_cap_dutycycle;
|
||||
uint16_t ch1_cap_dutycycle;
|
||||
uint16_t ch2_cap_dutycycle;
|
||||
} pwm_ch_cap_dutycycle_t;
|
||||
typedef struct pwm_ch_cap_type
|
||||
{
|
||||
uint8_t ch0_cap_type;
|
||||
uint8_t ch1_cap_type;
|
||||
uint8_t ch2_cap_type;
|
||||
} pwm_ch_cap_type_t;
|
||||
typedef enum
|
||||
{
|
||||
PWM_CAP_TYPE_FREQ,
|
||||
PWM_CAP_TYPE_DUTYCYCLE,
|
||||
} PWM_CAP_TYPE_TypeDef;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void app_pwm_init(void);
|
||||
void UpdateDisplay(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PWM_TEST_H__ */
|
||||
|
||||
|
||||
@@ -1,804 +0,0 @@
|
||||
#ifndef _RGBLIGHT_C_
|
||||
#define _RGBLIGHT_C_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "pwm.h"
|
||||
#include "xc_drv_pwm.h"
|
||||
#include "rgblight.h"
|
||||
#include "timer.h"
|
||||
#include "key.h"
|
||||
#include "nec_infrared.h"
|
||||
#include "usr_server.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
PWM_DutyCycle_t pwm_duty_cycle;
|
||||
|
||||
uint32_t rgb_DutyCycleAcc = 255;
|
||||
uint32_t r_DutyCycle = 127;
|
||||
uint32_t g_DutyCycle = 127;
|
||||
uint32_t b_DutyCycle = 127;
|
||||
|
||||
uint8_t direction = 0;
|
||||
uint8_t mode = 0;
|
||||
uint8_t Brightness = 10;
|
||||
uint8_t TimeSpeed = 0;//跳变和频闪速度200ms
|
||||
uint8_t FadeSpeed = 2;//渐变速度2ms
|
||||
uint8_t CurrentStatus = STATICEFFECT;
|
||||
uint8_t CurrentModel = DYNAMICMODE;
|
||||
uint8_t deviceStatus = POWERON; // 0:POWERON 1:POWEROFF
|
||||
uint8_t ModeTemp = 0;//mode缓存
|
||||
uint8_t MatchOverFlag = 0;//上电定时5S结束标志
|
||||
uint8_t MODE19_i = 0;
|
||||
|
||||
uint16_t speedOption[10] = {200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100}; //跳变和频闪速度ms
|
||||
//uint8_t ble_value = 0;
|
||||
//uint8_t ble_user_code = 0;
|
||||
|
||||
ble_data_msg user_ble_data_msg;
|
||||
ble_data_msg *p_ble_data_msg = NULL;
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Function
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ble_callback
|
||||
* @details
|
||||
* @param value0:对应遥控的的码值
|
||||
value1:应用程序的掩码,必须掩码相同,才会进出BLE信息处理
|
||||
* @retval void
|
||||
*/
|
||||
void ble_callback(uint8_t value0,uint8_t value1,uint8_t value2,uint8_t value3)
|
||||
{
|
||||
// ble_value = value0;
|
||||
// ble_user_code = value1;
|
||||
|
||||
user_ble_data_msg.tpye = value3;
|
||||
user_ble_data_msg.r_value = value2;
|
||||
user_ble_data_msg.g_value = value1;
|
||||
user_ble_data_msg.b_value_mode_speed_brightness = value0;
|
||||
|
||||
p_ble_data_msg = &user_ble_data_msg;
|
||||
|
||||
// only_read_charactertics_buffer[0] = p_ble_data_msg->r_value;
|
||||
// only_read_charactertics_buffer[1] = p_ble_data_msg->g_value;
|
||||
// only_read_charactertics_buffer[2] = p_ble_data_msg->b_value_mode_speed_brightness;
|
||||
// only_read_charactertics_buffer[3] = p_ble_data_msg->tpye;
|
||||
}
|
||||
/**
|
||||
* @brief ir_message_process
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void ble_message_process(void)
|
||||
{
|
||||
|
||||
// if(ble_user_code ==0xEE)//核对BLE用户码
|
||||
// {
|
||||
// ble_user_code = 0;
|
||||
// functionOption(ble_value);
|
||||
// }
|
||||
if(p_ble_data_msg != NULL)
|
||||
{
|
||||
switch(p_ble_data_msg->tpye)
|
||||
{
|
||||
case 00://rgb
|
||||
r_DutyCycle = p_ble_data_msg->r_value;
|
||||
g_DutyCycle = p_ble_data_msg->g_value;
|
||||
b_DutyCycle = p_ble_data_msg->b_value_mode_speed_brightness;
|
||||
|
||||
CurrentStatus = STATICEFFECT;
|
||||
CurrentModel = TEMPERATUREMODE;
|
||||
break;
|
||||
case 01://亮度
|
||||
Brightness = p_ble_data_msg->b_value_mode_speed_brightness;
|
||||
break;
|
||||
case 02://速度
|
||||
TimeSpeed = p_ble_data_msg->b_value_mode_speed_brightness;
|
||||
FadeSpeed = p_ble_data_msg->b_value_mode_speed_brightness + 2;
|
||||
break;
|
||||
case 03://模式
|
||||
mode = p_ble_data_msg->b_value_mode_speed_brightness;
|
||||
CurrentStatus = mode > MODE0 ? DYNAMICEEFECT : STATICEFFECT;
|
||||
CurrentModel = DYNAMICMODE;
|
||||
updateParameter();//更新动态模式参数
|
||||
startTimer(&timer1, 1); // 立刻启动定时器1,设定间隔为1ms,执行1次
|
||||
break;
|
||||
case 04://开机,关机,音频
|
||||
functionOption(p_ble_data_msg->b_value_mode_speed_brightness);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// only_read_charactertics_buffer[1] = (uint8_t)(r_DutyCycle*Brightness/10);
|
||||
// only_read_charactertics_buffer[2] = g_DutyCycle;
|
||||
// only_read_charactertics_buffer[3] = b_DutyCycle;
|
||||
// only_read_charactertics_buffer[4] = Brightness;
|
||||
UpdateDisplay();//更新显示
|
||||
p_ble_data_msg = NULL;
|
||||
|
||||
// only_read_charactertics_buffer[0] = (uint8_t)(r_DutyCycle*Brightness/10);
|
||||
// only_read_charactertics_buffer[1] = Brightness;
|
||||
// only_read_charactertics_buffer[2] = (uint8_t)r_DutyCycle;
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief ir_message_process
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void ir_message_process(void)
|
||||
{
|
||||
if(IR.rece_ok && IR.user_code ==0x47DF)//核对用户码
|
||||
{
|
||||
IR.rece_ok = 0;
|
||||
IR.user_code = 0;
|
||||
functionOption(IR.hig_8bit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief key_message_process
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void key_message_process(uint16_t msg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case REC_KEY_SHORT_DOWN:
|
||||
mode = mode >= MODE19 ? MODE0 : mode++;
|
||||
break;
|
||||
case REC_KEY_UP_SHORT_DOWN:
|
||||
|
||||
break;
|
||||
case REC_KEY_DOWN_SHORT_DOWN:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief adc_mic_pwm_process
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void adc_mic_pwm_process(void)
|
||||
{
|
||||
|
||||
}
|
||||
// 将音频信号值映射到RGB颜色空间中
|
||||
void mapAudioToRGB(uint16_t audioValue)
|
||||
{
|
||||
if(audioValue > 1023)
|
||||
{
|
||||
audioValue = 1023;
|
||||
}
|
||||
// 映射到红色通道
|
||||
r_DutyCycle= audioValue % 256;
|
||||
// 映射到绿色通道
|
||||
g_DutyCycle= (audioValue / 2) % 256;
|
||||
// 映射到蓝色通道
|
||||
b_DutyCycle = (audioValue / 4) % 256;
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
|
||||
///*********************************************************************************************************************
|
||||
//色温调节
|
||||
//*********************************************************************************************************************/
|
||||
//void TemperatureAdjustment(unsigned char value)
|
||||
//{
|
||||
// if (value < 201)
|
||||
// {
|
||||
// g_DutyCycle = value;
|
||||
// b_DutyCycle = MAXDUTY - value;
|
||||
// }
|
||||
//}
|
||||
/*********************************************************************************************************************
|
||||
RGB色彩调节
|
||||
*********************************************************************************************************************/
|
||||
void rgbColorModel(uint8_t value, uint32_t *r_DutyCycle, uint32_t *g_DutyCycle, uint32_t *b_DutyCycle)
|
||||
{
|
||||
if (value < 67)
|
||||
{
|
||||
*b_DutyCycle = 0;
|
||||
*g_DutyCycle = (unsigned char)((value / 66.0) * 200);
|
||||
*r_DutyCycle = 200 - *g_DutyCycle;
|
||||
}
|
||||
else if (value < 134)
|
||||
{
|
||||
value -= 67;
|
||||
*r_DutyCycle = 0;
|
||||
*b_DutyCycle = (unsigned char)((value / 66.0) * 200);
|
||||
*g_DutyCycle = 200 - *b_DutyCycle;
|
||||
}
|
||||
else if (value < 201)
|
||||
{
|
||||
value -= 134;
|
||||
*g_DutyCycle = 0;
|
||||
*r_DutyCycle = (unsigned char)((value / 66.0) * 200);
|
||||
*b_DutyCycle = 200 - *r_DutyCycle;
|
||||
}
|
||||
}
|
||||
/*********************************************************************************************************************
|
||||
亮度,速度,开关调节
|
||||
*********************************************************************************************************************/
|
||||
void functionOption(uint8_t key_value)
|
||||
{
|
||||
if (deviceStatus == POWERON || key_value == ON) //关机状态只有ON可以识别
|
||||
{
|
||||
switch (key_value)
|
||||
{
|
||||
case BRIGHTNESS_IN:
|
||||
if (Brightness < 10)
|
||||
Brightness++;
|
||||
break;
|
||||
case BRIGHTNESS_RE:
|
||||
if (Brightness > 1)
|
||||
Brightness--;
|
||||
break;
|
||||
case SPEED_IN:
|
||||
if (TimeSpeed > 0 && CurrentStatus == DYNAMICEEFECT && mode != MODE19)
|
||||
{
|
||||
TimeSpeed --;
|
||||
FadeSpeed --;
|
||||
}
|
||||
else if (TimeSpeed > 0 && CurrentStatus == DYNAMICEEFECT && mode == MODE19 && MODE19_i != MODE0)
|
||||
{
|
||||
TimeSpeed --;
|
||||
FadeSpeed --;
|
||||
}
|
||||
break;
|
||||
case SPEED_RE:
|
||||
if (TimeSpeed < 9 && CurrentStatus == DYNAMICEEFECT && mode != MODE19)
|
||||
{
|
||||
TimeSpeed ++;
|
||||
FadeSpeed ++;
|
||||
}
|
||||
else if (TimeSpeed < 9 && CurrentStatus == DYNAMICEEFECT && mode == MODE19 && MODE19_i != MODE0)
|
||||
{
|
||||
TimeSpeed ++;
|
||||
FadeSpeed ++;
|
||||
}
|
||||
break;
|
||||
case MODE_IN:
|
||||
if (mode <= MODE19)
|
||||
{
|
||||
if (CurrentModel == TEMPERATUREMODE)
|
||||
mode = ModeTemp;
|
||||
else if (mode < MODE19)
|
||||
mode ++;
|
||||
|
||||
CurrentStatus = mode > MODE0 ? DYNAMICEEFECT : STATICEFFECT;
|
||||
|
||||
CurrentModel = DYNAMICMODE;
|
||||
|
||||
updateParameter();//更新动态模式,初始值
|
||||
startTimer(&timer1, 1); // 立刻启动定时器1,设定间隔为1ms,执行1次
|
||||
}
|
||||
break;
|
||||
case MODE_RE:
|
||||
if (mode >= MODE0)
|
||||
{
|
||||
if (CurrentModel == TEMPERATUREMODE)
|
||||
mode = ModeTemp;
|
||||
else if (mode > MODE0)
|
||||
mode --;
|
||||
|
||||
CurrentStatus = mode > MODE0 ? DYNAMICEEFECT : STATICEFFECT;
|
||||
|
||||
CurrentModel = DYNAMICMODE;
|
||||
|
||||
updateParameter();//更新动态模式参数
|
||||
startTimer(&timer1, 1); // 立刻启动定时器1,设定间隔为1ms,执行1次
|
||||
}
|
||||
break;
|
||||
case ON:
|
||||
if (deviceStatus == POWEROFF) //关机状态按开机才有识别
|
||||
{
|
||||
if (CurrentStatus == DYNAMICEEFECT) //动态效果才进入,mode>=MODE3,必须更新参数
|
||||
{
|
||||
updateParameter();
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
// xc_pwm_start(PWM2_IDX);
|
||||
// xc_pwm_start(PWM3_IDX);
|
||||
// xc_pwm_start(PWM5_IDX);
|
||||
xc_pwm_start_all();
|
||||
|
||||
startTimer(&timer1, 1); // 立刻启动定时器1,设定间隔为1ms,执行1次
|
||||
deviceStatus = POWERON;//开机
|
||||
}
|
||||
break;
|
||||
case OFF:
|
||||
// xc_pwm_stop(PWM2_IDX);
|
||||
// xc_pwm_stop(PWM3_IDX);
|
||||
// xc_pwm_stop(PWM5_IDX);
|
||||
|
||||
xc_pwm_stop_all();
|
||||
|
||||
stopTimer(&timer1);
|
||||
deviceStatus = POWEROFF;//关机
|
||||
break;
|
||||
case MUSIC1:
|
||||
app_audio_record_start();
|
||||
break;
|
||||
default:
|
||||
// if (key_value < 201)
|
||||
// {
|
||||
// rgbColorModel(key_value, &r_DutyCycle, &g_DutyCycle, &b_DutyCycle);
|
||||
// stopTimer(&timer1);
|
||||
// CurrentStatus = STATICEFFECT;
|
||||
// CurrentModel = TEMPERATUREMODE;
|
||||
// ModeTemp = mode;//缓存
|
||||
// }
|
||||
break;
|
||||
}
|
||||
if(key_value != MUSIC1)
|
||||
app_audio_record_stop();//关闭adc
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
|
||||
}
|
||||
void updateParameter(void)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MODE0:
|
||||
break;
|
||||
case MODE2:
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
case MODE19:
|
||||
MODE19_i = 0;
|
||||
startTimer(&timer5, 20000); // 立刻启动定时器5,设定间隔为20s
|
||||
default:
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
void updateParameterMode19(unsigned char mode)//mode19()函数特定使用
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MODE0:
|
||||
break;
|
||||
case MODE2:
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
default:
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*********************************************************************************************************************
|
||||
模式
|
||||
*********************************************************************************************************************/
|
||||
void Mode0(void)//rgb同时显示白色
|
||||
{
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode1(void)//RGB同时呼吸
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
r_DutyCycle ++;
|
||||
g_DutyCycle ++;
|
||||
b_DutyCycle ++;
|
||||
if (r_DutyCycle == MAXDUTY)
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_DutyCycle --;
|
||||
g_DutyCycle --;
|
||||
b_DutyCycle --;
|
||||
if (r_DutyCycle == MINDUTY)
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode2(void) // RGB渐变
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
r_DutyCycle++;
|
||||
g_DutyCycle = 0;
|
||||
b_DutyCycle --;
|
||||
if (r_DutyCycle == MAXDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 1:
|
||||
r_DutyCycle--;
|
||||
g_DutyCycle ++;
|
||||
b_DutyCycle = 0;
|
||||
if (g_DutyCycle == MAXDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 2:
|
||||
r_DutyCycle = 0;
|
||||
g_DutyCycle--;
|
||||
b_DutyCycle ++;
|
||||
if (b_DutyCycle == MAXDUTY)
|
||||
direction = 0;
|
||||
break;
|
||||
}
|
||||
UpdateDisplay(); // 更新显示
|
||||
}
|
||||
|
||||
void Mode3(void) // RGB呼吸
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
r_DutyCycle++;
|
||||
g_DutyCycle = 0;
|
||||
b_DutyCycle = 0;
|
||||
if (r_DutyCycle == MAXDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 1:
|
||||
r_DutyCycle--;
|
||||
g_DutyCycle = 0;
|
||||
b_DutyCycle = 0;
|
||||
if (r_DutyCycle == MINDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 2:
|
||||
r_DutyCycle = 0;
|
||||
g_DutyCycle++;
|
||||
b_DutyCycle = 0;
|
||||
if (g_DutyCycle == MAXDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 3:
|
||||
r_DutyCycle = 0;
|
||||
g_DutyCycle--;
|
||||
b_DutyCycle = 0;
|
||||
if (g_DutyCycle == MINDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 4:
|
||||
r_DutyCycle = 0;
|
||||
g_DutyCycle = 0;
|
||||
b_DutyCycle++;
|
||||
if (b_DutyCycle == MAXDUTY)
|
||||
direction++;
|
||||
break;
|
||||
case 5:
|
||||
r_DutyCycle = 0;
|
||||
g_DutyCycle = 0;
|
||||
b_DutyCycle--;
|
||||
if (b_DutyCycle == MINDUTY)
|
||||
direction = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateDisplay(); // 更新显示
|
||||
}
|
||||
|
||||
void Mode4(void) // RGB七彩跳动
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
case 2:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
case 4:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
case 6:
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
case 8:
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
case 10:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
case 12:
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
default:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
}
|
||||
direction++;
|
||||
if (direction == 14)
|
||||
direction = 0;
|
||||
UpdateDisplay(); // 更新显示
|
||||
}
|
||||
void Mode5(void) // RGB跳动
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
case 2:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
case 4:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
break;
|
||||
default:
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
break;
|
||||
}
|
||||
direction++;
|
||||
if (direction == 6)
|
||||
direction = 0;
|
||||
UpdateDisplay(); // 更新显示
|
||||
}
|
||||
void Mode6(void)//R闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode7(void)//G闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode8(void)//B闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
direction = 0;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode9(void)//W 闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
direction = 1;
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode10(void)//W 频闪
|
||||
{
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
startTimer(&timer2, 50); // 重新启动定时器2,设定间隔为100ms
|
||||
}
|
||||
void Mode11(void)//R 闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
direction = 1;
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode12(void)//R 频闪
|
||||
{
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
startTimer(&timer2, 50); // 重新启动定时器2,设定间隔为100ms
|
||||
}
|
||||
void Mode13(void)//G 闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
direction = 1;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode14(void)//G 频闪
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
startTimer(&timer2, 50); // 重新启动定时器2,设定间隔为100ms
|
||||
}
|
||||
void Mode15(void)//B 闪动
|
||||
{
|
||||
if (!direction)
|
||||
{
|
||||
direction = 1;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 0;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode16(void)//B 频闪
|
||||
{
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MAXDUTY;
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
startTimer(&timer2, 50); // 重新启动定时器2,设定间隔为100ms
|
||||
}
|
||||
void Mode17(void)//Y 闪动
|
||||
{
|
||||
if (direction)
|
||||
{
|
||||
direction = 0;
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 1;
|
||||
r_DutyCycle = MINDUTY;
|
||||
g_DutyCycle = MINDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
}
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
void Mode18(void)//Y 频闪
|
||||
{
|
||||
r_DutyCycle = MAXDUTY;
|
||||
g_DutyCycle = MAXDUTY;
|
||||
b_DutyCycle = MINDUTY;
|
||||
|
||||
UpdateDisplay();//更新显示
|
||||
startTimer(&timer2, 50); // 重新启动定时器2,设定间隔为100ms
|
||||
}
|
||||
|
||||
void Mode19(void)//0-18 模式循环
|
||||
{
|
||||
MODE19_i = 0;
|
||||
modefunctin[MODE19_i]();
|
||||
}
|
||||
pfunc modefunctin[] =//模式切换,一共15个模式
|
||||
{
|
||||
Mode0, Mode1, Mode2, Mode3, Mode4, Mode5, Mode6, Mode7, Mode8, Mode9, Mode10, Mode11, Mode12, Mode13, Mode14, Mode15, Mode16, Mode17, Mode18, Mode19
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,174 +0,0 @@
|
||||
#ifndef _RGBLIGHT_H_
|
||||
#define _RGBLIGHT_H_
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define MINDUTY 0
|
||||
#define MAXDUTY 255
|
||||
|
||||
//#define ON 0X00
|
||||
//#define AUTO 0X01
|
||||
//#define OFF 0X02
|
||||
//#define MUSIC1 0X03
|
||||
//#define MUSIC2 0X04
|
||||
//#define MUSIC3 0X05
|
||||
//#define TIMER1 0X06
|
||||
//#define TIMER2 0X07
|
||||
//#define TIMER3 0X08
|
||||
//#define SPEED_IN 0X09
|
||||
//#define SPEED_RE 0X0A
|
||||
//#define MODE_IN 0X0B
|
||||
//#define MODE_RE 0X0C
|
||||
//#define BRIGHTNESS_IN 0X0D
|
||||
//#define BRIGHTNESS_RE 0X0F
|
||||
//#define RED 0X10
|
||||
//#define GREED 0X11
|
||||
//#define BLUE 0X12
|
||||
//#define YELLOW 0X13
|
||||
//#define CYAN 0X14
|
||||
//#define BLUISH 0X15
|
||||
//#define PINK 0X16
|
||||
//#define PURPLE 0X17
|
||||
//#define WHITE 0X17
|
||||
#define ON 0x25
|
||||
#define AUTO 0x2D
|
||||
#define OFF 0xA4
|
||||
|
||||
#define BRIGHTNESS_IN 0x0B
|
||||
#define BRIGHTNESS_RE 0x5B
|
||||
|
||||
#define SPEED_IN 0x0A
|
||||
#define SPEED_RE 0x5C
|
||||
|
||||
#define MODE_IN 0x0F
|
||||
#define MODE_RE 0x6E
|
||||
|
||||
#define RED 0x06
|
||||
#define GREED 0x08
|
||||
#define BLUE 0x5A
|
||||
|
||||
#define YELLOW 0x09
|
||||
#define CYAN 0x8A
|
||||
#define BLUISH 0x10
|
||||
|
||||
#define TIMER1H 0x1C
|
||||
#define WHITE 0x52
|
||||
#define TIMER2H 0x53
|
||||
|
||||
#define MUSIC1 0x0C
|
||||
#define MUSIC2 0x1A
|
||||
#define MUSIC3 0x1F
|
||||
|
||||
#define FLASH1 0x01
|
||||
#define FLASH2 0x00
|
||||
#define FLASH3 0x02
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
// // 定义RGB颜色结构体
|
||||
//typedef struct {
|
||||
// uint8_t r; // 红色通道
|
||||
// uint8_t g; // 绿色通道
|
||||
// uint8_t b; // 蓝色通道
|
||||
//} RGBColor;
|
||||
|
||||
typedef struct BLE_DATA_MSG
|
||||
{
|
||||
uint8_t tpye;
|
||||
uint8_t r_value;
|
||||
uint8_t g_value;
|
||||
uint8_t b_value_mode_speed_brightness;
|
||||
}ble_data_msg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t DutyCycleAcc;
|
||||
uint32_t DutyCycle;
|
||||
} PWM_DutyCycle_t;
|
||||
|
||||
typedef void (*pfunc)(void);
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MODE0,
|
||||
MODE1,
|
||||
MODE2,
|
||||
MODE3,
|
||||
MODE4,
|
||||
MODE5,
|
||||
MODE6,
|
||||
MODE7,
|
||||
MODE8,
|
||||
MODE9,
|
||||
MODE10,
|
||||
MODE11,
|
||||
MODE12,
|
||||
MODE13,
|
||||
MODE14,
|
||||
MODE15,
|
||||
MODE16,
|
||||
MODE17,
|
||||
MODE18,
|
||||
MODE19,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
STATICEFFECT,//色环+静态
|
||||
DYNAMICEEFECT//动态
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TEMPERATUREMODE,//色环模式
|
||||
DYNAMICMODE //动态+静态模式
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POWERON,
|
||||
POWEROFF
|
||||
};
|
||||
|
||||
extern pfunc modefunctin[];
|
||||
extern uint8_t refreshRfFlag;
|
||||
extern uint8_t MatchOverFlag;//上电定时5S结束标志
|
||||
extern uint8_t MODE19_i;
|
||||
|
||||
extern uint32_t r_DutyCycle;
|
||||
extern uint32_t g_DutyCycle;
|
||||
extern uint32_t b_DutyCycle;
|
||||
extern uint8_t Brightness;
|
||||
|
||||
extern uint8_t CurrentStatus;
|
||||
extern uint8_t CurrentModel;
|
||||
extern uint8_t mode;
|
||||
extern uint8_t FadeSpeed;
|
||||
extern uint16_t speedOption[10];
|
||||
extern uint8_t TimeSpeed;
|
||||
extern uint8_t MODE19_i;
|
||||
|
||||
extern uint8_t only_read_charactertics_buffer[];
|
||||
|
||||
void TemperatureAdjustment(unsigned char value);
|
||||
void rgbColorModel(uint8_t value, uint32_t *r_DutyCycle, uint32_t *g_DutyCycle, uint32_t *b_DutyCycle);
|
||||
void functionOption(uint8_t key_value);
|
||||
void UpdateDisplay(void);
|
||||
void PWM_On(unsigned char on, unsigned char PWM_CHINAEL);
|
||||
void PWM_Off(unsigned char off, unsigned char PWM_CHINAEL);
|
||||
void updateParameter(void);
|
||||
void updateParameterMode19(unsigned char mode);
|
||||
void key_message_process(uint16_t msg);
|
||||
void ir_message_process(void);
|
||||
void ble_message_process(void);
|
||||
void mapAudioToRGB(uint16_t audioValue) ;
|
||||
void ble_callback(uint8_t value0,uint8_t value1,uint8_t value2,uint8_t value3);
|
||||
#endif
|
||||
@@ -1,262 +1,275 @@
|
||||
#<SYMDEFS># ARM Linker, 5060750: Last Updated: Tue Sep 05 15:30:26 2023
|
||||
0x10000808 D co_default_bdaddr
|
||||
0x00004169 T ke_msg_alloc
|
||||
0x000041ed T ke_msg_send
|
||||
0x00004225 T ke_msg_send_basic
|
||||
0x000042e9 T ke_state_set
|
||||
0x00004359 T ke_task_create
|
||||
0x000042b9 T ke_state_get
|
||||
0x000041af T ke_msg_discard
|
||||
0x000041b3 T ke_msg_forward
|
||||
0x000041dd T ke_msg_in_queue
|
||||
0x00004233 T ke_msg_src_id_get
|
||||
0x00003e05 T ke_free
|
||||
0x000041d5 T ke_msg_free
|
||||
0x00003c21 T ke_check_malloc
|
||||
0x0000dbf5 T rwip_init
|
||||
0x0000de79 T rwip_schedule
|
||||
0x10000938 D rwip_rf
|
||||
0x00000df9 T BLE_Handler
|
||||
0x0000238d T co_buf_alloc
|
||||
0x000024fd T co_buf_copy_data_from_mem
|
||||
0x00002721 T co_buf_release
|
||||
0x000028c9 T co_djob_prepare
|
||||
0x000028d5 T co_djob_reg
|
||||
0x0000291d T co_djob_unreg
|
||||
0x00002969 T co_list_extract
|
||||
0x000029ad T co_list_extract_after
|
||||
0x00002ac5 T co_list_pop_front
|
||||
0x00002ae9 T co_list_push_back
|
||||
0x00002b39 T co_list_push_front
|
||||
0x00002b55 T co_time_get
|
||||
0x00002ce5 T co_time_timer_init
|
||||
0x00002dcd T co_time_timer_set
|
||||
0x00002df9 T co_time_timer_stop
|
||||
0x00000e95 T aes_c1
|
||||
0x00001465 T aes_encrypt
|
||||
0x000014cd T aes_f4
|
||||
0x00001521 T aes_f5
|
||||
0x00001641 T aes_f6
|
||||
0x000016bd T aes_g2
|
||||
0x00001c35 T aes_rand
|
||||
0x000012a1 T aes_cmac
|
||||
0x000025b1 T co_buf_head_release
|
||||
0x000025dd T co_buf_head_reserve
|
||||
0x00002ec5 T co_util_pack
|
||||
0x000030d5 T co_util_unpack
|
||||
0x0000ddd9 T rwip_reset
|
||||
0x00001da5 T aes_rpa_resolve
|
||||
0x00002799 T co_buf_reuse
|
||||
0x000027dd T co_buf_size
|
||||
0x00002489 T co_buf_copy
|
||||
0x00002569 T co_buf_duplicate
|
||||
0x000027ed T co_buf_tail_release
|
||||
0x00002a0d T co_list_init
|
||||
0x00002285 T ble_util_buf_rx_free
|
||||
0x00001f69 T ble_util_buf_acl_tx_alloc
|
||||
0x00002439 T co_buf_cb_free_set
|
||||
0x00003fad T ke_malloc
|
||||
0x00002a25 T co_list_insert_after
|
||||
0x0000459d T ke_timer_active
|
||||
0x000045ad T ke_timer_clear
|
||||
0x00004641 T ke_timer_set
|
||||
0x00002369 T co_buf_acquire
|
||||
0x00002819 T co_buf_tail_reserve
|
||||
0x00002531 T co_buf_copy_data_to_mem
|
||||
0x00002a55 T co_list_insert_before
|
||||
0x10000e90 D rom_env
|
||||
0x1000096c D rwip_param
|
||||
0x0000fe8d D one_bits
|
||||
0x000039bd T hci_rd_rem_ver_info_cmd_handler
|
||||
0x00003445 T hci_le_con_upd_cmd_handler
|
||||
0x00003705 T hci_le_rd_chnl_map_cmd_handler
|
||||
0x00003761 T hci_le_rd_rem_feats_cmd_handler
|
||||
0x0000354d T hci_le_en_enc_cmd_handler
|
||||
0x0000369d T hci_le_ltk_req_reply_cmd_handler
|
||||
0x0000360d T hci_le_ltk_req_neg_reply_cmd_handler
|
||||
0x00003851 T hci_le_rem_con_param_req_reply_cmd_handler
|
||||
0x000037f9 T hci_le_rem_con_param_req_neg_reply_cmd_handler
|
||||
0x000038d9 T hci_le_set_data_len_cmd_handler
|
||||
0x00003be5 T hci_vs_set_pref_slave_latency_cmd_handler
|
||||
0x00003b9d T hci_vs_set_pref_slave_evt_dur_cmd_handler
|
||||
0x00003ab9 T hci_vs_set_max_rx_size_and_time_cmd_handler
|
||||
0x00003a39 T hci_rd_rssi_cmd_handler
|
||||
0x0000d749 T llm_ch_map_update_ind_handler
|
||||
0x0000650d T llc_loc_llcp_rsp_to_handler
|
||||
0x00007161 T llc_rem_llcp_rsp_to_handler
|
||||
0x00005255 T llc_encrypt_ind_handler
|
||||
0x00006739 T llc_op_ver_exch_ind_handler
|
||||
0x000066d5 T llc_op_feats_exch_ind_handler
|
||||
0x00006675 T llc_op_encrypt_ind_handler
|
||||
0x00006609 T llc_op_dl_upd_ind_handler
|
||||
0x0000657d T llc_op_con_upd_ind_handler
|
||||
0x00006525 T llc_op_ch_map_upd_ind_handler
|
||||
0x0000bda9 T lld_llcp_rx_ind_handler
|
||||
0x0000bf1d T lld_llcp_tx_cfm_handler
|
||||
0x00007551 T lld_acl_rx_ind_handler
|
||||
0x000075dd T lld_acl_tx_cfm_handler
|
||||
0x00009509 T lld_con_param_upd_cfm_handler
|
||||
0x00008921 T lld_ch_map_upd_cfm_handler
|
||||
0x000094cd T lld_con_offset_upd_ind_handler
|
||||
0x00003435 T hci_command_llc_handler
|
||||
0x00003385 T hci_acl_data_handler
|
||||
0x00003cc1 T ke_event_callback_set
|
||||
0x00003cd9 T ke_event_clear
|
||||
0x00003db1 T ke_event_set
|
||||
0x000022e5 T ble_util_nb_good_channels
|
||||
0x0000230d T ble_util_pkt_dur_in_us
|
||||
0x0000234d T co_bdaddr_compare
|
||||
0x000088bd T lld_ch_assess_data_get
|
||||
0x000088c5 T lld_ch_map_set
|
||||
0x0000c16d T lld_read_clock
|
||||
0x0000c30d T lld_res_list_peer_update
|
||||
0x0000d60d T lld_white_list_add
|
||||
0x0000dd99 T rwip_prevent_sleep_clear
|
||||
0x0000ddb9 T rwip_prevent_sleep_set
|
||||
0x0000f071 T sch_plan_rem
|
||||
0x00001ce5 T aes_rpa_gen
|
||||
0x00002029 T ble_util_buf_adv_tx_alloc
|
||||
0x00002061 T ble_util_buf_adv_tx_free
|
||||
0x0000feae D co_null_bdaddr
|
||||
0x0000feb4 D co_null_key
|
||||
0x000050c9 T llc_con_move_cbk
|
||||
0x000071d9 T llc_start
|
||||
0x00007669 T lld_adv_adv_data_update
|
||||
0x00007ff5 T lld_adv_rand_addr_update
|
||||
0x00008071 T lld_adv_restart
|
||||
0x0000817d T lld_adv_scan_rsp_data_update
|
||||
0x000081c5 T lld_adv_start
|
||||
0x00008831 T lld_adv_stop
|
||||
0x0000d6c1 T lld_white_list_rem
|
||||
0x0000b401 T lld_init_rand_addr_update
|
||||
0x0000c179 T lld_res_list_add
|
||||
0x0000c251 T lld_res_list_clear
|
||||
0x0000c27d T lld_res_list_local_rpa_get
|
||||
0x0000c2c5 T lld_res_list_peer_rpa_get
|
||||
0x0000c341 T lld_res_list_priv_mode_update
|
||||
0x0000c37d T lld_res_list_rem
|
||||
0x0000cedd T lld_scan_rand_addr_update
|
||||
0x0000b699 T lld_init_start
|
||||
0x0000bc9d T lld_init_stop
|
||||
0x0000f081 T sch_plan_req
|
||||
0x0000f0d5 T sch_plan_set
|
||||
0x0000fec4 D co_rate_to_phy
|
||||
0x0000cb81 T lld_scan_params_update
|
||||
0x0000d115 T lld_scan_start
|
||||
0x0000d5c5 T lld_scan_stop
|
||||
0x0000c3ad T lld_rpa_renew
|
||||
0x0000408d T ke_mem_init
|
||||
0x00002609 T co_buf_init
|
||||
0x0000de9d T rwip_sleep
|
||||
0x10000810 D em_ble_base_address_table_0
|
||||
0x10000812 D em_ble_base_address_table_1
|
||||
0x10000814 D em_ble_base_address_table_2
|
||||
0x10000816 D em_ble_base_address_table_3
|
||||
0x10000818 D em_ble_base_address_table_4
|
||||
0x1000081a D em_ble_base_address_table_5
|
||||
0x10000822 D em_ble_base_address_table_6
|
||||
0x1000081c D em_ble_base_address_table_7
|
||||
0x10000824 D em_ble_base_address_table_8
|
||||
0x1000081e D em_ble_base_address_table_9
|
||||
0x10000820 D em_ble_base_address_table_10
|
||||
0x000021d9 T ble_util_buf_init_env
|
||||
0x10000978 D PATCH_FUN
|
||||
0x1000108c D lld_adv_env
|
||||
0x0000ebe5 T sch_arb_remove
|
||||
0x0000f739 T sch_slice_fg_remove
|
||||
0x10000f44 D llc_env
|
||||
0x0000693d T llc_proc_err_ind
|
||||
0x000073c1 T llc_stop
|
||||
0x00004695 T ll_channel_map_ind_handler
|
||||
0x0000471d T ll_connection_param_req_handler
|
||||
0x00004809 T ll_connection_param_rsp_handler
|
||||
0x0000489d T ll_connection_update_ind_handler
|
||||
0x000049c1 T ll_enc_req_handler
|
||||
0x00004a85 T ll_enc_rsp_handler
|
||||
0x00004af9 T ll_feature_req_handler
|
||||
0x00004b4d T ll_feature_rsp_handler
|
||||
0x00004ba1 T ll_length_req_handler
|
||||
0x00004bf9 T ll_length_rsp_handler
|
||||
0x00004c75 T ll_min_used_channels_ind_handler
|
||||
0x00004cf1 T ll_pause_enc_req_handler
|
||||
0x00004d5d T ll_pause_enc_rsp_handler
|
||||
0x00004db5 T ll_reject_ext_ind_handler
|
||||
0x00004dd5 T ll_reject_ind_handler
|
||||
0x00004df5 T ll_slave_feature_req_handler
|
||||
0x00004e49 T ll_start_enc_req_handler
|
||||
0x00004e99 T ll_start_enc_rsp_handler
|
||||
0x00004ee9 T ll_unknown_rsp_handler
|
||||
0x00004ef9 T ll_version_ind_handler
|
||||
0x00001fd9 T ble_util_buf_acl_tx_free
|
||||
0x0000c5c1 T lld_rxdesc_check
|
||||
0x0000c609 T lld_rxdesc_free
|
||||
0x0000fee4 D rwip_priority
|
||||
0x0000e8b1 T sch_arb_insert
|
||||
0x0000f355 T sch_prog_push
|
||||
0x0000fde5 T FMC_SPI_Flash_RDID
|
||||
0x0000fd8d T FMC_SPI_Flash_RUID
|
||||
0x0000fa71 T FMC_SPI_Flash_WakeUp
|
||||
0x0000f9f1 T FMC_SPI_Init_Oprt
|
||||
0x0000fa49 T FMC_SPI_Flash_PowerDown
|
||||
0x0000fceb T FMC_SPI_FlashRead
|
||||
0x0000fc1f T FMC_SPI_FlashWrite
|
||||
0x0000fb09 T FMC_SPI_Flash_Erase_Sector
|
||||
0x00004fc9 T llc_cleanup
|
||||
0x00005091 T llc_cmd_stat_send
|
||||
0x00005a39 T llc_llcp_send
|
||||
0x00005ac9 T llc_llcp_state_set
|
||||
0x00006981 T llc_proc_get
|
||||
0x00006999 T llc_proc_id_get
|
||||
0x000069b5 T llc_proc_init
|
||||
0x000069c1 T llc_proc_reg
|
||||
0x00006a05 T llc_proc_state_get
|
||||
0x00006a09 T llc_proc_state_set
|
||||
0x00006a0d T llc_proc_timer_pause_set
|
||||
0x00006a7d T llc_proc_timer_set
|
||||
0x00006ae5 T llc_proc_unreg
|
||||
0x0000a1c1 T lld_con_stop
|
||||
0x00007869 T lld_adv_evt_start_cbk
|
||||
0x10000e68 D rwip_env
|
||||
0x1000080e D rwip_prog_delay
|
||||
0x0000e041 T rwip_time_get
|
||||
0x0000e2cd T rwip_wakeup_end
|
||||
0x1000112c D sch_arb_env
|
||||
0x00007905 T lld_adv_frm_cbk
|
||||
0x0000e0b1 T rwip_timer_alarm_handler
|
||||
0x0000e11d T rwip_timer_arb_handler
|
||||
0x0000e189 T rwip_timer_co_handler
|
||||
0x10000f94 D lld_env
|
||||
0x10000828 D aa_gen
|
||||
0x00007c25 T lld_adv_init
|
||||
0x00009301 T lld_con_init
|
||||
0x0000a7f1 T lld_core_init
|
||||
0x1000082c D lld_rpa_renew_env
|
||||
0x00008959 T lld_channel_assess
|
||||
0x100010dc D lld_con_env
|
||||
0x0000a4ad T lld_con_tx_len_update
|
||||
0x10000830 D lld_exp_sync_pos_tab
|
||||
0x0000bce5 T lld_instant_proc_end
|
||||
0x11010c9d T prf_dst_task_get
|
||||
0x11010dd1 T rom_env_init
|
||||
0x110035c5 T gapc_get_bdaddr
|
||||
0x11009261 T gatt_db_svc16_add
|
||||
0x11009411 T gatt_db_svc_add
|
||||
0x11009955 T gatt_db_svc_remove
|
||||
0x1100a445 T gatt_srv_att_read_get_cfm
|
||||
0x1100a57d T gatt_srv_att_val_set_cfm
|
||||
0x1100b0d1 T gatt_srv_event_send
|
||||
0x1100bfe1 T gatt_user_srv_register
|
||||
0x11011ddc D llc_msg_handler_tab
|
||||
0x10001698 D rom_llc_state
|
||||
0x00008e4d T lld_con_evt_start_cbk
|
||||
0x00008ddd T lld_con_evt_canceled_cbk
|
||||
0x0000fe9e D co_sca2ppm
|
||||
0x00009051 T lld_con_evt_time_update
|
||||
0x00009415 T lld_con_max_lat_calc
|
||||
0x00009a69 T lld_con_sched
|
||||
0x0000f7e1 T sch_slice_per_add
|
||||
0x0000d801 T rwble_isr
|
||||
0x0000dc75 T rwip_isr
|
||||
0x00009189 T lld_con_frm_isr
|
||||
0x000044f9 T ke_task_schedule
|
||||
0x00007949 T lld_adv_frm_isr
|
||||
#<SYMDEFS># ARM Linker, 5060750: Last Updated: Tue Sep 05 15:30:26 2023
|
||||
0x10000808 D co_default_bdaddr
|
||||
0x00004169 T ke_msg_alloc
|
||||
0x000041ed T ke_msg_send
|
||||
0x00004225 T ke_msg_send_basic
|
||||
0x000042e9 T ke_state_set
|
||||
0x00004359 T ke_task_create
|
||||
0x000042b9 T ke_state_get
|
||||
0x000041af T ke_msg_discard
|
||||
0x000041b3 T ke_msg_forward
|
||||
0x000041dd T ke_msg_in_queue
|
||||
0x00004233 T ke_msg_src_id_get
|
||||
0x00003e05 T ke_free
|
||||
0x000041d5 T ke_msg_free
|
||||
0x00003c21 T ke_check_malloc
|
||||
0x0000dbf5 T rwip_init
|
||||
0x0000de79 T rwip_schedule
|
||||
0x10000938 D rwip_rf
|
||||
0x00000df9 T BLE_Handler
|
||||
0x0000238d T co_buf_alloc
|
||||
0x000024fd T co_buf_copy_data_from_mem
|
||||
0x00002721 T co_buf_release
|
||||
0x000028c9 T co_djob_prepare
|
||||
0x000028d5 T co_djob_reg
|
||||
0x0000291d T co_djob_unreg
|
||||
0x00002969 T co_list_extract
|
||||
0x000029ad T co_list_extract_after
|
||||
0x00002ac5 T co_list_pop_front
|
||||
0x00002ae9 T co_list_push_back
|
||||
0x00002b39 T co_list_push_front
|
||||
0x00002b55 T co_time_get
|
||||
0x00002ce5 T co_time_timer_init
|
||||
0x00002dcd T co_time_timer_set
|
||||
0x00002df9 T co_time_timer_stop
|
||||
0x00000e95 T aes_c1
|
||||
0x00001465 T aes_encrypt
|
||||
0x000014cd T aes_f4
|
||||
0x00001521 T aes_f5
|
||||
0x00001641 T aes_f6
|
||||
0x000016bd T aes_g2
|
||||
0x00001c35 T aes_rand
|
||||
0x000012a1 T aes_cmac
|
||||
0x000025b1 T co_buf_head_release
|
||||
0x000025dd T co_buf_head_reserve
|
||||
0x00002ec5 T co_util_pack
|
||||
0x000030d5 T co_util_unpack
|
||||
0x0000ddd9 T rwip_reset
|
||||
0x00001da5 T aes_rpa_resolve
|
||||
0x00002799 T co_buf_reuse
|
||||
0x000027dd T co_buf_size
|
||||
0x00002489 T co_buf_copy
|
||||
0x00002569 T co_buf_duplicate
|
||||
0x000027ed T co_buf_tail_release
|
||||
0x00002a0d T co_list_init
|
||||
0x00002285 T ble_util_buf_rx_free
|
||||
0x00001f69 T ble_util_buf_acl_tx_alloc
|
||||
0x00002439 T co_buf_cb_free_set
|
||||
0x00003fad T ke_malloc
|
||||
0x00002a25 T co_list_insert_after
|
||||
0x0000459d T ke_timer_active
|
||||
0x000045ad T ke_timer_clear
|
||||
0x00004641 T ke_timer_set
|
||||
0x00002369 T co_buf_acquire
|
||||
0x00002819 T co_buf_tail_reserve
|
||||
0x00002531 T co_buf_copy_data_to_mem
|
||||
0x00002a55 T co_list_insert_before
|
||||
0x10000e90 D rom_env
|
||||
0x1000096c D rwip_param
|
||||
0x0000fe8d D one_bits
|
||||
0x000039bd T hci_rd_rem_ver_info_cmd_handler
|
||||
0x00003445 T hci_le_con_upd_cmd_handler
|
||||
0x00003705 T hci_le_rd_chnl_map_cmd_handler
|
||||
0x00003761 T hci_le_rd_rem_feats_cmd_handler
|
||||
0x0000354d T hci_le_en_enc_cmd_handler
|
||||
0x0000369d T hci_le_ltk_req_reply_cmd_handler
|
||||
0x0000360d T hci_le_ltk_req_neg_reply_cmd_handler
|
||||
0x00003851 T hci_le_rem_con_param_req_reply_cmd_handler
|
||||
0x000037f9 T hci_le_rem_con_param_req_neg_reply_cmd_handler
|
||||
0x000038d9 T hci_le_set_data_len_cmd_handler
|
||||
0x00003be5 T hci_vs_set_pref_slave_latency_cmd_handler
|
||||
0x00003b9d T hci_vs_set_pref_slave_evt_dur_cmd_handler
|
||||
0x00003ab9 T hci_vs_set_max_rx_size_and_time_cmd_handler
|
||||
0x00003a39 T hci_rd_rssi_cmd_handler
|
||||
0x0000d749 T llm_ch_map_update_ind_handler
|
||||
0x0000650d T llc_loc_llcp_rsp_to_handler
|
||||
0x00007161 T llc_rem_llcp_rsp_to_handler
|
||||
0x00005255 T llc_encrypt_ind_handler
|
||||
0x00006739 T llc_op_ver_exch_ind_handler
|
||||
0x000066d5 T llc_op_feats_exch_ind_handler
|
||||
0x00006675 T llc_op_encrypt_ind_handler
|
||||
0x00006609 T llc_op_dl_upd_ind_handler
|
||||
0x0000657d T llc_op_con_upd_ind_handler
|
||||
0x00006525 T llc_op_ch_map_upd_ind_handler
|
||||
0x0000bda9 T lld_llcp_rx_ind_handler
|
||||
0x0000bf1d T lld_llcp_tx_cfm_handler
|
||||
0x00007551 T lld_acl_rx_ind_handler
|
||||
0x000075dd T lld_acl_tx_cfm_handler
|
||||
0x00009509 T lld_con_param_upd_cfm_handler
|
||||
0x00008921 T lld_ch_map_upd_cfm_handler
|
||||
0x000094cd T lld_con_offset_upd_ind_handler
|
||||
0x00003435 T hci_command_llc_handler
|
||||
0x00003385 T hci_acl_data_handler
|
||||
0x00003cc1 T ke_event_callback_set
|
||||
0x00003cd9 T ke_event_clear
|
||||
0x00003db1 T ke_event_set
|
||||
0x000022e5 T ble_util_nb_good_channels
|
||||
0x0000230d T ble_util_pkt_dur_in_us
|
||||
0x0000234d T co_bdaddr_compare
|
||||
0x000088bd T lld_ch_assess_data_get
|
||||
0x000088c5 T lld_ch_map_set
|
||||
0x0000c16d T lld_read_clock
|
||||
0x0000c30d T lld_res_list_peer_update
|
||||
0x0000d60d T lld_white_list_add
|
||||
0x0000dd99 T rwip_prevent_sleep_clear
|
||||
0x0000ddb9 T rwip_prevent_sleep_set
|
||||
0x0000f071 T sch_plan_rem
|
||||
0x00001ce5 T aes_rpa_gen
|
||||
0x00002029 T ble_util_buf_adv_tx_alloc
|
||||
0x00002061 T ble_util_buf_adv_tx_free
|
||||
0x0000feae D co_null_bdaddr
|
||||
0x0000feb4 D co_null_key
|
||||
0x000050c9 T llc_con_move_cbk
|
||||
0x000071d9 T llc_start
|
||||
0x00007669 T lld_adv_adv_data_update
|
||||
0x00007ff5 T lld_adv_rand_addr_update
|
||||
0x00008071 T lld_adv_restart
|
||||
0x0000817d T lld_adv_scan_rsp_data_update
|
||||
0x000081c5 T lld_adv_start
|
||||
0x00008831 T lld_adv_stop
|
||||
0x0000d6c1 T lld_white_list_rem
|
||||
0x0000b401 T lld_init_rand_addr_update
|
||||
0x0000c179 T lld_res_list_add
|
||||
0x0000c251 T lld_res_list_clear
|
||||
0x0000c27d T lld_res_list_local_rpa_get
|
||||
0x0000c2c5 T lld_res_list_peer_rpa_get
|
||||
0x0000c341 T lld_res_list_priv_mode_update
|
||||
0x0000c37d T lld_res_list_rem
|
||||
0x0000cedd T lld_scan_rand_addr_update
|
||||
0x0000b699 T lld_init_start
|
||||
0x0000bc9d T lld_init_stop
|
||||
0x0000f081 T sch_plan_req
|
||||
0x0000f0d5 T sch_plan_set
|
||||
0x0000fec4 D co_rate_to_phy
|
||||
0x0000cb81 T lld_scan_params_update
|
||||
0x0000d115 T lld_scan_start
|
||||
0x0000d5c5 T lld_scan_stop
|
||||
0x0000c3ad T lld_rpa_renew
|
||||
0x0000408d T ke_mem_init
|
||||
0x00002609 T co_buf_init
|
||||
0x0000de9d T rwip_sleep
|
||||
0x10000810 D em_ble_base_address_table_0
|
||||
0x10000812 D em_ble_base_address_table_1
|
||||
0x10000814 D em_ble_base_address_table_2
|
||||
0x10000816 D em_ble_base_address_table_3
|
||||
0x10000818 D em_ble_base_address_table_4
|
||||
0x1000081a D em_ble_base_address_table_5
|
||||
0x10000822 D em_ble_base_address_table_6
|
||||
0x1000081c D em_ble_base_address_table_7
|
||||
0x10000824 D em_ble_base_address_table_8
|
||||
0x1000081e D em_ble_base_address_table_9
|
||||
0x10000820 D em_ble_base_address_table_10
|
||||
0x000021d9 T ble_util_buf_init_env
|
||||
0x10000978 D PATCH_FUN
|
||||
0x1000108c D lld_adv_env
|
||||
0x0000ebe5 T sch_arb_remove
|
||||
0x0000f739 T sch_slice_fg_remove
|
||||
0x10000f44 D llc_env
|
||||
0x0000693d T llc_proc_err_ind
|
||||
0x000073c1 T llc_stop
|
||||
0x00004695 T ll_channel_map_ind_handler
|
||||
0x0000471d T ll_connection_param_req_handler
|
||||
0x00004809 T ll_connection_param_rsp_handler
|
||||
0x0000489d T ll_connection_update_ind_handler
|
||||
0x000049c1 T ll_enc_req_handler
|
||||
0x00004a85 T ll_enc_rsp_handler
|
||||
0x00004af9 T ll_feature_req_handler
|
||||
0x00004b4d T ll_feature_rsp_handler
|
||||
0x00004ba1 T ll_length_req_handler
|
||||
0x00004bf9 T ll_length_rsp_handler
|
||||
0x00004c75 T ll_min_used_channels_ind_handler
|
||||
0x00004cf1 T ll_pause_enc_req_handler
|
||||
0x00004d5d T ll_pause_enc_rsp_handler
|
||||
0x00004db5 T ll_reject_ext_ind_handler
|
||||
0x00004dd5 T ll_reject_ind_handler
|
||||
0x00004df5 T ll_slave_feature_req_handler
|
||||
0x00004e49 T ll_start_enc_req_handler
|
||||
0x00004e99 T ll_start_enc_rsp_handler
|
||||
0x00004ee9 T ll_unknown_rsp_handler
|
||||
0x00004ef9 T ll_version_ind_handler
|
||||
0x00001fd9 T ble_util_buf_acl_tx_free
|
||||
0x0000c5c1 T lld_rxdesc_check
|
||||
0x0000c609 T lld_rxdesc_free
|
||||
0x0000fee4 D rwip_priority
|
||||
0x0000e8b1 T sch_arb_insert
|
||||
0x0000f355 T sch_prog_push
|
||||
0x0000fde5 T FMC_SPI_Flash_RDID
|
||||
0x0000fd8d T FMC_SPI_Flash_RUID
|
||||
0x0000fa71 T FMC_SPI_Flash_WakeUp
|
||||
0x0000f9f1 T FMC_SPI_Init_Oprt
|
||||
0x0000fa49 T FMC_SPI_Flash_PowerDown
|
||||
0x0000fceb T FMC_SPI_FlashRead
|
||||
0x0000fc1f T FMC_SPI_FlashWrite
|
||||
0x0000fb09 T FMC_SPI_Flash_Erase_Sector
|
||||
0x00004fc9 T llc_cleanup
|
||||
0x00005091 T llc_cmd_stat_send
|
||||
0x00005a39 T llc_llcp_send
|
||||
0x00005ac9 T llc_llcp_state_set
|
||||
0x00006981 T llc_proc_get
|
||||
0x00006999 T llc_proc_id_get
|
||||
0x000069b5 T llc_proc_init
|
||||
0x000069c1 T llc_proc_reg
|
||||
0x00006a05 T llc_proc_state_get
|
||||
0x00006a09 T llc_proc_state_set
|
||||
0x00006a0d T llc_proc_timer_pause_set
|
||||
0x00006a7d T llc_proc_timer_set
|
||||
0x00006ae5 T llc_proc_unreg
|
||||
0x0000a1c1 T lld_con_stop
|
||||
0x00007869 T lld_adv_evt_start_cbk
|
||||
0x10000e68 D rwip_env
|
||||
0x1000080e D rwip_prog_delay
|
||||
0x0000e041 T rwip_time_get
|
||||
0x0000e2cd T rwip_wakeup_end
|
||||
0x1000112c D sch_arb_env
|
||||
0x00007905 T lld_adv_frm_cbk
|
||||
0x0000e0b1 T rwip_timer_alarm_handler
|
||||
0x0000e11d T rwip_timer_arb_handler
|
||||
0x0000e189 T rwip_timer_co_handler
|
||||
0x10000f94 D lld_env
|
||||
0x10000828 D aa_gen
|
||||
0x00007c25 T lld_adv_init
|
||||
0x00009301 T lld_con_init
|
||||
0x0000a7f1 T lld_core_init
|
||||
0x1000082c D lld_rpa_renew_env
|
||||
0x00008959 T lld_channel_assess
|
||||
0x100010dc D lld_con_env
|
||||
0x0000a4ad T lld_con_tx_len_update
|
||||
0x10000830 D lld_exp_sync_pos_tab
|
||||
0x0000bce5 T lld_instant_proc_end
|
||||
0x1100e3c9 T prf_dst_task_get
|
||||
0x1100e501 T rom_env_init
|
||||
0x11004309 T gapc_get_bdaddr
|
||||
0x11008c05 T gatt_db_svc16_add
|
||||
0x11008d89 T gatt_db_svc_add
|
||||
0x11002ba7 T _gatt_srv_att_read_get_cfm
|
||||
0x11002c1b T _gatt_srv_att_val_set_cfm
|
||||
0x1100a2f5 T gatt_srv_event_send
|
||||
0x1100a6ad T gatt_user_srv_register
|
||||
0x1100f070 D llc_msg_handler_tab
|
||||
0x10001c70 D rom_llc_state
|
||||
0x00008e4d T lld_con_evt_start_cbk
|
||||
0x00008ddd T lld_con_evt_canceled_cbk
|
||||
0x0000fe9e D co_sca2ppm
|
||||
0x00009051 T lld_con_evt_time_update
|
||||
0x00009415 T lld_con_max_lat_calc
|
||||
0x00009a69 T lld_con_sched
|
||||
0x0000f7e1 T sch_slice_per_add
|
||||
0x0000d801 T rwble_isr
|
||||
0x0000dc75 T rwip_isr
|
||||
0x00009189 T lld_con_frm_isr
|
||||
0x000044f9 T ke_task_schedule
|
||||
0x00007949 T lld_adv_frm_isr
|
||||
0x10001c8b D sv_lock
|
||||
0x10001c92 D sv_txlen
|
||||
0x1000179d T rom_lld_con_rx
|
||||
0x10001a2d T rom_lld_con_evt_start_cbk
|
||||
0x10001a85 T rom_lld_con_frm_isr
|
||||
0x1100866d T gatt_cli_mtu_exch
|
||||
0x1100e6ad T rom_lld_disable_latency
|
||||
0x1100e6d9 T rom_lld_enable_latency
|
||||
0x10001c8a D evt_start
|
||||
0x11003c39 T co_rand_word
|
||||
0x11003c41 T co_random_init
|
||||
0x10001c88 D adv_evt_start
|
||||
0x10001c34 D gatt_srv_read_api_tbl
|
||||
0x10001c48 D gatt_srv_write_api_tbl
|
||||
|
||||
@@ -1,331 +1,473 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // RW SW configuration
|
||||
|
||||
#include "arch.h" // architectural platform definitions
|
||||
#include <stdlib.h> // standard lib functions
|
||||
#include <stddef.h> // standard definitions
|
||||
#include <stdint.h> // standard integer definition
|
||||
#include <stdbool.h> // boolean definition
|
||||
#include "boot.h" // boot definition
|
||||
#include "rwip.h" // RW SW initialization
|
||||
#include "xc_drv_pwr.h"
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
#include "uart.h" // UART initialization
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
|
||||
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
||||
#include "rf.h" // RF initialization
|
||||
#endif // BLE_EMB_PRESENT || BT_EMB_PRESENT
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
//#include "app.h" // application functions
|
||||
#endif // BLE_APP_PRESENT
|
||||
|
||||
#if PLF_DMA
|
||||
#include "dma.h" // DMA initialization
|
||||
#endif // PLF_DMA
|
||||
|
||||
#if (PLF_NVDS)
|
||||
#include "nvds.h" // NVDS definitions
|
||||
#endif // PLF_NVDS
|
||||
|
||||
#include "reg_assert_mgr.h"
|
||||
#if (PLF_PROFILING || PLF_MEM_PROTECTION)
|
||||
#include "reg_sw_profiling.h"
|
||||
#endif // (PLF_PROFILING || PLF_MEM_PROTECTION)
|
||||
#include "platform.h"
|
||||
|
||||
#include "xc6xxx.h"
|
||||
|
||||
//CPU early wake-up time (unit:us)
|
||||
#define SLEEP_TIME_EARLY (3300)
|
||||
|
||||
#define HS_TO_US(frame) (((frame) * SLOT_SIZE) >> 1)
|
||||
|
||||
/**
|
||||
* @brief clock_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void clock_init(void)
|
||||
{
|
||||
CLOCK_InitCfg_t clock_cfg;
|
||||
|
||||
clock_cfg.hfclk_src = CLOCK_HFCLK_SRC_XTAL;
|
||||
clock_cfg.hfclk_in = CLOCK_HFCLK_IN_32M;
|
||||
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_RC;
|
||||
|
||||
// clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_XTAL;
|
||||
if(clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_XTAL) {
|
||||
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32768;
|
||||
} else if(clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_RC) {
|
||||
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32K;
|
||||
}
|
||||
|
||||
xc_clock_init_cfg(&clock_cfg);
|
||||
|
||||
SysTick_Config(xc_clock_hfclk_in_get( ) / 100);
|
||||
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
||||
}
|
||||
|
||||
#if (SLEEP_ENABLE)
|
||||
|
||||
void system_sleep_init()
|
||||
{
|
||||
uint32_t wake_it_src;
|
||||
#if (USE_XIP == 1)
|
||||
xc_fmc_spi_init_oprt();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if (USE_XIP!=1)
|
||||
SPI_InitCfg_t spi_cfg = {0};
|
||||
spi_cfg.Mode = SPI_MODE_MASTER;
|
||||
spi_cfg.DataSize = SSI_CTRL0_DFS_LEN_8BIT;
|
||||
spi_cfg.Direction = SSI_CTRL0_TMOD_WR;
|
||||
spi_cfg.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
spi_cfg.CLKPolarity = SSI_CTRL0_SCPOL_LOW;
|
||||
spi_cfg.CLKPhase = SPI_CPHA_LEAD;
|
||||
spi_cfg.FirstBit = SPI_FirstBit_MSB;
|
||||
|
||||
xc_spi_init(XC_SPI0, &spi_cfg);
|
||||
SPI_Flash_PowerDown(XC_SPI0);
|
||||
#endif
|
||||
#endif
|
||||
xc_pwr_gpio_sleep_config();
|
||||
|
||||
wake_it_src = GPIO_IRQn_WAKE | RTC_IRQn_WAKE|TIMER_AO0_IRQn_WAKE| TIMER0_IRQn_WAKE;
|
||||
|
||||
xc_pwr_wake_it_set(wake_it_src);
|
||||
}
|
||||
|
||||
void system_lightsleep_cfg()
|
||||
{
|
||||
#if (USE_XIP!=1)
|
||||
cprao_aon_puctrl1_set(0x4);/* puctrl1= 0x4 , SSI0RX must pulldown*/
|
||||
#endif
|
||||
cprao_aon_sys_time_set((RST_READY_TIME<<12) | (OSC32_STABLE_TIME));
|
||||
|
||||
xc_pwr_pd_lightsleep_set();
|
||||
xc_pwr_sleepsrc_mask_set(0x1e001e);
|
||||
xc_pwr_osc_off();
|
||||
}
|
||||
|
||||
void cpu_switch_16M()
|
||||
{
|
||||
//M0_FCLK
|
||||
cpr_m0_fclk_ctl__m0_fclk_div_p__setf(0x1);
|
||||
cpr_m0_fclk_ctl__m0_fclk_direct_sw__setf(0x1);
|
||||
|
||||
//CTL_PCLK
|
||||
cpr_ctl_pclk_grctl__ctl_pclk_gr__setf(0x8);
|
||||
cpr_ctl_pclk_grctl__ctl_pclk_gr_upd__setf(0x1);
|
||||
|
||||
cprao_aon_bbldo_adj_set(0x3c);
|
||||
/* The value needs to be configured to 7,
|
||||
otherwise the current drop will be slower during sleep
|
||||
and the clock accuracy of the rc32k will be affected.
|
||||
*/
|
||||
cprao_aon_lpoldo_adj_set(0x7);
|
||||
}
|
||||
|
||||
void sleep_init(void)
|
||||
{
|
||||
system_sleep_init();
|
||||
system_lightsleep_cfg();
|
||||
/* Timer for sleep-wake*/
|
||||
Timer_InitCfg_t timer_cfg;
|
||||
|
||||
timer_cfg.timer_src_clk = TIMER_CLK_SRC_32K;
|
||||
timer_cfg.timer_div_clk = TIMER_DIV_CLK_32000Hz;
|
||||
timer_cfg.timer_mode = TIMER_MODE_SINGLE;
|
||||
|
||||
xc_timer_init(TIMER0_IDX, &timer_cfg);
|
||||
//cpu 32M->16M
|
||||
// cpu_switch_16M();
|
||||
}
|
||||
|
||||
__RAM_CODE void xc_ble_sleep(void)
|
||||
{
|
||||
xc_adc_powerdown();
|
||||
xc_pwr_usb_off();
|
||||
xc_pwr_rc16m_off();
|
||||
|
||||
xc_pwr_rc32k_calib_off();
|
||||
|
||||
xc_pwr_opa_tempsensor_off();
|
||||
xc_pwr_opa_volr_off();
|
||||
xc_pwr_revddldo_off();
|
||||
|
||||
xc_pwr_dcdc_close();
|
||||
xc_pwr_rfdigital_off();
|
||||
xc_pwr_rc32k_calib_off();
|
||||
|
||||
xc_pwr_modem_off();
|
||||
xc_pwr_pd_lightsleep_set();
|
||||
|
||||
|
||||
#if (USE_XIP == 1)
|
||||
|
||||
#if (USE_ROM_FLASH)
|
||||
FMC_SPI_Flash_PowerDown();
|
||||
xc_pwr_rom_off();
|
||||
#else // (USE_ROM_FLASH)
|
||||
// xc_fmc_spi_flash_power_down();
|
||||
#endif // (USE_ROM_FLASH)
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
// cpr_fmc_ctl_set(0x3000 | (1 << 9)); // close FMC
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
}
|
||||
#endif
|
||||
|
||||
// __disable_irq();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
__WFI();
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
// cpr_fmc_ctl_set(0x3503);
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
#if (USE_ROM_FLASH)
|
||||
xc_pwr_rom_on();
|
||||
FMC_SPI_Flash_WakeUp();
|
||||
#else // (USE_ROM_FLASH)
|
||||
// xc_fmc_spi_flash_wake_up();
|
||||
#endif // (USE_ROM_FLASH)
|
||||
|
||||
|
||||
xc_pwr_ao_timer_pclk32m_Set();
|
||||
|
||||
// __enable_irq();
|
||||
|
||||
#ifdef USED_DCDC
|
||||
PWR_DCDC_Open();
|
||||
#endif
|
||||
|
||||
xc_pwr_modem_on();
|
||||
|
||||
xc_pwr_rfdigital_on();
|
||||
|
||||
xc_adc_wakeup();
|
||||
}
|
||||
|
||||
void enter_cpu_sleep()
|
||||
{
|
||||
cpr_ctlapbclken_grctl__uart0_pclk_en__setf(0);
|
||||
cpr_ahbclken_grctl__dmas_hclk_en__setf(0);
|
||||
|
||||
cpr_slp_src_mask_set(0x1e000e);
|
||||
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
|
||||
__WFI();
|
||||
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
|
||||
cpr_slp_src_mask_set(0x1e001e);
|
||||
|
||||
// open uart clk
|
||||
cpr_ctlapbclken_grctl__uart0_pclk_en__setf(1);
|
||||
}
|
||||
|
||||
void sleep_schedule()
|
||||
{
|
||||
// Checks for sleep have to be done with interrupt disabled
|
||||
GLOBAL_INT_DISABLE();
|
||||
|
||||
// Check if the processor clock can be gated
|
||||
uint32_t duration = 0;
|
||||
uint32_t duration_timer = 0;
|
||||
switch(rwip_sleep(&duration, 2, \
|
||||
0x7D00, RWIP_MINIMUM_SLEEP_TIME)){
|
||||
case RWIP_DEEP_SLEEP:
|
||||
{
|
||||
delay_us(200);
|
||||
|
||||
duration_timer = (HS_TO_US(duration) - SLEEP_TIME_EARLY);
|
||||
xc_timer_set_value(TIMER0_IDX, duration_timer);
|
||||
xc_timer_start(TIMER0_IDX);
|
||||
|
||||
xc_ble_sleep();
|
||||
|
||||
xc_timer_stop(TIMER0_IDX);
|
||||
}
|
||||
// no break
|
||||
case RWIP_CPU_SLEEP:
|
||||
{
|
||||
enter_cpu_sleep();
|
||||
}
|
||||
break;
|
||||
case RWIP_ACTIVE:
|
||||
default:
|
||||
{
|
||||
// nothing to do.
|
||||
} break;
|
||||
}
|
||||
// Checks for sleep have to be done with interrupt disabled
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
#endif // (SLEEP_ENABLE)
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h" // RW SW configuration
|
||||
|
||||
#include "arch.h" // architectural platform definitions
|
||||
#include "boot.h" // boot definition
|
||||
#include "rwip.h" // RW SW initialization
|
||||
#include "xc_drv_pwr.h"
|
||||
#include <stdbool.h> // boolean definition
|
||||
#include <stddef.h> // standard definitions
|
||||
#include <stdint.h> // standard integer definition
|
||||
#include <stdlib.h> // standard lib functions
|
||||
|
||||
#if (BLE_TEST_MODE_SUPPORT)
|
||||
#include "uart.h" // UART initialization
|
||||
#endif // (BLE_TEST_MODE_SUPPORT)
|
||||
|
||||
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
||||
#include "rf.h" // RF initialization
|
||||
#endif // BLE_EMB_PRESENT || BT_EMB_PRESENT
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
// #include "app.h" // application functions
|
||||
#endif // BLE_APP_PRESENT
|
||||
|
||||
#if PLF_DMA
|
||||
#include "dma.h" // DMA initialization
|
||||
#endif // PLF_DMA
|
||||
|
||||
#if (PLF_NVDS)
|
||||
#include "nvds.h" // NVDS definitions
|
||||
#endif // PLF_NVDS
|
||||
|
||||
#include "reg_assert_mgr.h"
|
||||
#if (PLF_PROFILING || PLF_MEM_PROTECTION)
|
||||
#include "reg_sw_profiling.h"
|
||||
#endif // (PLF_PROFILING || PLF_MEM_PROTECTION)
|
||||
#include "platform.h"
|
||||
|
||||
#include "sleep.h"
|
||||
#include "xc6xxx.h"
|
||||
|
||||
// CPU early wake-up time (unit:us)
|
||||
#define SLEEP_TIME_EARLY (3300)
|
||||
|
||||
#define HS_TO_US(frame) (((frame) * SLOT_SIZE) >> 1)
|
||||
|
||||
/**
|
||||
* @brief clock_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void clock_init(void)
|
||||
{
|
||||
CLOCK_InitCfg_t clock_cfg;
|
||||
|
||||
clock_cfg.hfclk_src = CLOCK_HFCLK_SRC_XTAL;
|
||||
clock_cfg.hfclk_in = CLOCK_HFCLK_IN_32M;
|
||||
#if XTAL_32K
|
||||
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_XTAL;
|
||||
#else
|
||||
clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_RC;
|
||||
#endif
|
||||
// clock_cfg.lfclk_src = CLOCK_LFCLK_SRC_XTAL;
|
||||
if (clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_XTAL) {
|
||||
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32768;
|
||||
} else if (clock_cfg.lfclk_src == CLOCK_LFCLK_SRC_RC) {
|
||||
clock_cfg.lfclk_in = CLOCK_LFCLK_IN_32K;
|
||||
}
|
||||
|
||||
xc_clock_init_cfg(&clock_cfg);
|
||||
|
||||
SysTick_Config(xc_clock_hfclk_in_get() / 100);
|
||||
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
|
||||
}
|
||||
|
||||
#if (SLEEP_ENABLE)
|
||||
|
||||
void system_sleep_init()
|
||||
{
|
||||
uint32_t wake_it_src;
|
||||
#if (USE_XIP == 1)
|
||||
#if (USE_ROM_FLASH)
|
||||
FMC_SPI_Init_Oprt();
|
||||
#else // (USE_ROM_FLASH)
|
||||
xc_fmc_spi_init_oprt();
|
||||
#endif // (USE_ROM_FLASH)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if (USE_XIP != 1)
|
||||
SPI_InitCfg_t spi_cfg = {0};
|
||||
spi_cfg.Mode = SPI_MODE_MASTER;
|
||||
spi_cfg.DataSize = SSI_CTRL0_DFS_LEN_8BIT;
|
||||
spi_cfg.Direction = SSI_CTRL0_TMOD_WR;
|
||||
spi_cfg.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
spi_cfg.CLKPolarity = SSI_CTRL0_SCPOL_LOW;
|
||||
spi_cfg.CLKPhase = SPI_CPHA_LEAD;
|
||||
spi_cfg.FirstBit = SPI_FirstBit_MSB;
|
||||
|
||||
xc_spi_init(XC_SPI0, &spi_cfg);
|
||||
SPI_Flash_PowerDown(XC_SPI0);
|
||||
#endif
|
||||
#endif
|
||||
xc_pwr_gpio_sleep_config();
|
||||
|
||||
wake_it_src =
|
||||
GPIO_IRQn_WAKE | RTC_IRQn_WAKE | TIMER_AO0_IRQn_WAKE | TIMER0_IRQn_WAKE | MPU_IRQn_WAKE;
|
||||
|
||||
xc_pwr_wake_it_set(wake_it_src);
|
||||
}
|
||||
|
||||
void system_lightsleep_cfg()
|
||||
{
|
||||
#if (USE_XIP != 1)
|
||||
cprao_aon_puctrl1_set(0x4); /* puctrl1= 0x4 , SSI0RX must pulldown*/
|
||||
#endif
|
||||
cprao_aon_sys_time_set((RST_READY_TIME << 12) | (OSC32_STABLE_TIME));
|
||||
|
||||
xc_pwr_pd_lightsleep_set();
|
||||
xc_pwr_sleepsrc_mask_set(0x1e001e);
|
||||
xc_pwr_osc_off();
|
||||
}
|
||||
|
||||
void cpu_switch_16M()
|
||||
{
|
||||
// M0_FCLK
|
||||
cpr_m0_fclk_ctl__m0_fclk_div_p__setf(0x1);
|
||||
cpr_m0_fclk_ctl__m0_fclk_direct_sw__setf(0x1);
|
||||
|
||||
// CTL_PCLK
|
||||
cpr_ctl_pclk_grctl__ctl_pclk_gr__setf(0x8);
|
||||
cpr_ctl_pclk_grctl__ctl_pclk_gr_upd__setf(0x1);
|
||||
|
||||
cprao_aon_bbldo_adj_set(0x3c);
|
||||
/* The value needs to be configured to 7,
|
||||
otherwise the current drop will be slower during sleep
|
||||
and the clock accuracy of the rc32k will be affected.
|
||||
*/
|
||||
cprao_aon_lpoldo_adj_set(0x7);
|
||||
}
|
||||
|
||||
void sleep_init(void)
|
||||
{
|
||||
system_sleep_init();
|
||||
system_lightsleep_cfg();
|
||||
/* Timer for sleep-wake*/
|
||||
Timer_InitCfg_t timer_cfg;
|
||||
|
||||
timer_cfg.timer_src_clk = TIMER_CLK_SRC_32K;
|
||||
timer_cfg.timer_div_clk = TIMER_DIV_CLK_32000Hz;
|
||||
timer_cfg.timer_mode = TIMER_MODE_SINGLE;
|
||||
|
||||
xc_timer_init(TIMER0_IDX, &timer_cfg);
|
||||
// cpu 32M->16M
|
||||
// cpu_switch_16M();
|
||||
cprao_aon_bbldo_adj_set(0x2a);
|
||||
cprao_aon_lpoldo_adj_set(0x7);
|
||||
}
|
||||
|
||||
__RAM_CODE void xc_ble_sleep(void)
|
||||
{
|
||||
xc_adc_powerdown();
|
||||
xc_pwr_usb_off();
|
||||
xc_pwr_rc16m_off();
|
||||
|
||||
xc_pwr_rc32k_calib_off();
|
||||
|
||||
xc_pwr_opa_tempsensor_off();
|
||||
xc_pwr_opa_volr_off();
|
||||
xc_pwr_revddldo_off();
|
||||
|
||||
xc_pwr_dcdc_close();
|
||||
xc_pwr_rfdigital_off();
|
||||
xc_pwr_rc32k_calib_off();
|
||||
cprao_aon_reg4__bb_coreldo_normal_sw_mux__setf(1);
|
||||
xc_pwr_modem_off();
|
||||
xc_pwr_pd_lightsleep_set();
|
||||
|
||||
#if (USE_XIP == 1)
|
||||
|
||||
#if (USE_ROM_FLASH)
|
||||
FMC_SPI_Flash_PowerDown();
|
||||
#else // (USE_ROM_FLASH)
|
||||
// xc_fmc_spi_flash_power_down();
|
||||
#endif // (USE_ROM_FLASH)
|
||||
xc_pwr_rom_off();
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
// cpr_fmc_ctl_set(0x3000 | (1 << 9)); // close FMC
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
}
|
||||
#endif
|
||||
|
||||
// __disable_irq();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
__WFI();
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
// cpr_fmc_ctl_set(0x3503);
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
xc_pwr_rom_on();
|
||||
#if (USE_ROM_FLASH)
|
||||
FMC_SPI_Flash_WakeUp();
|
||||
#else // (USE_ROM_FLASH)
|
||||
// xc_fmc_spi_flash_wake_up();
|
||||
#endif // (USE_ROM_FLASH)
|
||||
|
||||
xc_pwr_ao_timer_pclk32m_Set();
|
||||
|
||||
// __enable_irq();
|
||||
|
||||
#ifdef USED_DCDC
|
||||
xc_pwr_dcdc_open();
|
||||
#endif
|
||||
|
||||
xc_pwr_modem_on();
|
||||
|
||||
xc_pwr_rfdigital_on();
|
||||
|
||||
xc_adc_wakeup();
|
||||
}
|
||||
|
||||
void enter_cpu_sleep()
|
||||
{
|
||||
cpr_ctlapbclken_grctl__uart0_pclk_en__setf(0);
|
||||
cpr_ahbclken_grctl__dmas_hclk_en__setf(0);
|
||||
|
||||
cpr_slp_src_mask_set(0x1e000e);
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__WFI();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
cpr_slp_src_mask_set(0x1e001e);
|
||||
|
||||
// open uart clk
|
||||
cpr_ctlapbclken_grctl__uart0_pclk_en__setf(1);
|
||||
}
|
||||
|
||||
void sleep_schedule()
|
||||
{
|
||||
// Checks for sleep have to be done with interrupt disabled
|
||||
GLOBAL_INT_DISABLE();
|
||||
|
||||
// Check if the processor clock can be gated
|
||||
uint32_t duration = 0;
|
||||
uint32_t duration_timer = 0;
|
||||
switch (rwip_sleep(&duration, 2, 0x7D00, RWIP_MINIMUM_SLEEP_TIME)) {
|
||||
case RWIP_DEEP_SLEEP: {
|
||||
|
||||
duration_timer = (HS_TO_US(duration) - SLEEP_TIME_EARLY);
|
||||
xc_timer_set_value(TIMER0_IDX, duration_timer);
|
||||
xc_timer_start(TIMER0_IDX);
|
||||
// Before you sleep, turn off the peripheral to make sure it doesn't generate interrupts,
|
||||
// and then turn it on again after you sleep up.
|
||||
// For example, timer interrupts
|
||||
xc_rc32k_soft_calib_disable();
|
||||
xc_ble_sleep();
|
||||
|
||||
xc_timer_stop(TIMER0_IDX);
|
||||
xc_rc32k_soft_calib_enable();
|
||||
|
||||
}
|
||||
// no break
|
||||
case RWIP_CPU_SLEEP: {
|
||||
// enter_cpu_sleep();
|
||||
} break;
|
||||
case RWIP_ACTIVE:
|
||||
default: {
|
||||
// nothing to do.
|
||||
} break;
|
||||
}
|
||||
// Checks for sleep have to be done with interrupt disabled
|
||||
GLOBAL_INT_RESTORE();
|
||||
|
||||
#if (POWER_ON)
|
||||
power_off_check();
|
||||
#endif // (POWER_ON)
|
||||
}
|
||||
#endif // (SLEEP_ENABLE)
|
||||
|
||||
#if (POWER_ON)
|
||||
|
||||
void system_deepsleep_init()
|
||||
{
|
||||
uint32_t wake_it_src;
|
||||
#if (USE_XIP == 1)
|
||||
xc_fmc_spi_init_oprt();
|
||||
#endif
|
||||
xc_pwr_gpio_sleep_config();
|
||||
|
||||
wake_it_src = GPIO_IRQn_WAKE | RTC_IRQn_WAKE;
|
||||
xc_pwr_wake_it_set(wake_it_src);
|
||||
}
|
||||
|
||||
void system_deepsleep_cfg()
|
||||
{
|
||||
#if (USE_XIP != 1)
|
||||
cprao_aon_puctrl1_set(0xf);
|
||||
#endif
|
||||
cprao_aon_sys_time_set((RST_READY_TIME << 12) | (OSC32_STABLE_TIME));
|
||||
xc_pwr_pd_deepsleep_set();
|
||||
xc_pwr_sleepsrc_mask_set(0x1e001e);
|
||||
xc_pwr_osc_off();
|
||||
}
|
||||
|
||||
void cpu_enter_deepsleep()
|
||||
{
|
||||
system_deepsleep_init();
|
||||
// PWRKEY Initialization is required after deep sleep wakeup
|
||||
xc_pwr_pwrkey_init();
|
||||
xc_pwr_pwrkey_deepsleep_wake_config(TOUCH_KEY,
|
||||
DEEP_SLEEP_GPIO_WAKE_HIGH_LEVEL);
|
||||
// xc_pwr_pwrkey_deepsleep_wake_config(TOUCH_KEY,
|
||||
// DEEP_SLEEP_GPIO_WAKE_LOW_LEVEL);
|
||||
system_deepsleep_cfg();
|
||||
xc_deep_sleep();
|
||||
}
|
||||
|
||||
void power_on_check()
|
||||
{
|
||||
uint16_t power_key_scan = 0;
|
||||
uint16_t resleep_count = 0;
|
||||
uint16_t power_on_count = 0;
|
||||
|
||||
while (1) {
|
||||
if (power_key_scan == POWER_KEY_SCAN_COUNT) {
|
||||
power_key_scan = 0;
|
||||
if (xc_gpio_read_pin(TOUCH_KEY) == 0) {
|
||||
if (resleep_count >= GENERAL_RESLEEP_TIME_COUNT) {
|
||||
cpu_enter_deepsleep();
|
||||
}
|
||||
resleep_count++;
|
||||
power_on_count = 0;
|
||||
} else {
|
||||
if (power_on_count == POWER_ON_TIME) {
|
||||
break;
|
||||
}
|
||||
power_on_count++;
|
||||
resleep_count = 0;
|
||||
}
|
||||
}
|
||||
power_key_scan++;
|
||||
}
|
||||
xc_pwr_pwrkey_init();
|
||||
}
|
||||
|
||||
void power_off_check()
|
||||
{
|
||||
if (xc_gpio_read_pin(TOUCH_KEY) == 1) {
|
||||
uint16_t power_key_scan = 0;
|
||||
uint16_t resleep_count = 0;
|
||||
uint16_t power_off_count = 0;
|
||||
|
||||
while (1) {
|
||||
if (power_key_scan == POWER_KEY_SCAN_COUNT) {
|
||||
power_key_scan = 0;
|
||||
if (xc_gpio_read_pin(TOUCH_KEY) == 0) {
|
||||
if (resleep_count >= GENERAL_RESLEEP_TIME_COUNT) {
|
||||
break;
|
||||
}
|
||||
resleep_count++;
|
||||
power_off_count = 0;
|
||||
} else {
|
||||
if (power_off_count == POWER_OFF_TIME) {
|
||||
cpu_enter_deepsleep();
|
||||
}
|
||||
power_off_count++;
|
||||
resleep_count = 0;
|
||||
}
|
||||
}
|
||||
power_key_scan++;
|
||||
}
|
||||
xc_pwr_pwrkey_init();
|
||||
}
|
||||
}
|
||||
#endif // (POWER_ON)
|
||||
|
||||
__RAM_CODE void MPU_Handler(void)
|
||||
{
|
||||
cprao_aon_slp_pd_mask_set(0x001);
|
||||
#if XTAL_32K
|
||||
cprao_aon_ctl_clk32k_set(0x109);
|
||||
#endif
|
||||
printf("MPU_Handler\n");
|
||||
WDT_InitCfg_t wdt_cfg ;
|
||||
|
||||
wdt_cfg.WorkMode = WDT_WORK_MODE0;
|
||||
wdt_cfg.ReloadValue = WDT_CLK_32M_RESET_MODE0_4096US;
|
||||
wdt_cfg.PclkSel = WDT_WORK_32M;
|
||||
xc_wdt_init(&wdt_cfg);
|
||||
xc_wdt_start();
|
||||
while(1);
|
||||
|
||||
}
|
||||
|
||||
// Timer 0 is occupied by sleep and cannot register interrupt functions.
|
||||
__RAM_CODE void timer0_callback(void *context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _SLEEP_H_
|
||||
#define _SLEEP_H_
|
||||
|
||||
#if (POWER_ON)
|
||||
|
||||
#define POWER_KEY_SCAN_COUNT 4000
|
||||
#define GENERAL_RESLEEP_TIME_COUNT 30
|
||||
#define POWER_ON_TIME 1200
|
||||
#define POWER_OFF_TIME 1200
|
||||
#define TOUCH_KEY GPIO_4
|
||||
|
||||
#endif //(POWER_ON)
|
||||
|
||||
void sleep_init(void);
|
||||
void sleep_schedule(void);
|
||||
|
||||
#endif //_SLEEP_H_
|
||||
@@ -1,244 +1,245 @@
|
||||
|
||||
;/*****************************************************************************
|
||||
; * @file: startup_xinc.s
|
||||
; * @purpose: CMSIS Cortex-M0 Core Device Startup File for the
|
||||
; * Device xinc.
|
||||
; *****************************************************************************/
|
||||
|
||||
Stack_Size EQU 0x00000800
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
Heap_Size EQU 0x00000000
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
; ToDo: Add here the vectors for the device specific external interrupts handler
|
||||
DCD BLE_Handler ; 0
|
||||
DCD DMA_Handler ; 1
|
||||
DCD CPR_Handler ; 2
|
||||
DCD GPIO_Handler ; 3
|
||||
DCD RTC_Handler ; 4
|
||||
DCD TIMER0_Handler ; 5
|
||||
DCD TIMER1_Handler ; 6
|
||||
DCD TIMER2_Handler ; 7
|
||||
DCD TIMER3_Handler ; 8
|
||||
DCD WDT_Handler ; 9
|
||||
DCD I2C_Handler ; 10
|
||||
DCD UART0_Handler ; 11
|
||||
DCD UART1_Handler ; 12
|
||||
DCD SPI0_Handler ; 13
|
||||
DCD SPI1_Handler ; 14
|
||||
DCD 0 ; 15
|
||||
DCD 0 ; 16
|
||||
DCD GADC_Handler ; 17
|
||||
DCD PWM_Handler ; 18
|
||||
DCD AES_Handler ; 19
|
||||
DCD USB_Handler ; 20
|
||||
DCD AUDIO_Handler ; 21
|
||||
DCD RF24G_Handler ; 22
|
||||
DCD SPI2_Handler ; 23
|
||||
DCD 0 ; 24
|
||||
DCD UART2_Handler ; 25
|
||||
DCD I2S_Handler ; 26
|
||||
DCD AOTIMER0_Handler ; 27
|
||||
DCD AOTIMER1_Handler ; 28
|
||||
DCD CMP_Handler ; 29
|
||||
DCD FMC_Handler ; 30
|
||||
DCD CAN_Handler ; 31
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
; Reset Handler
|
||||
|
||||
Reset_Handler PROC
|
||||
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
LDR r0, =0x4000013C ; remap
|
||||
LDR r1, =0x10000001
|
||||
STR r1, [r0]
|
||||
|
||||
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
EXPORT BLE_Handler [WEAK]
|
||||
EXPORT DMA_Handler [WEAK]
|
||||
EXPORT CPR_Handler [WEAK]
|
||||
EXPORT GPIO_Handler [WEAK]
|
||||
EXPORT RTC_Handler [WEAK]
|
||||
EXPORT TIMER0_Handler [WEAK]
|
||||
EXPORT TIMER1_Handler [WEAK]
|
||||
EXPORT TIMER2_Handler [WEAK]
|
||||
EXPORT TIMER3_Handler [WEAK]
|
||||
EXPORT WDT_Handler [WEAK]
|
||||
EXPORT I2C_Handler [WEAK]
|
||||
EXPORT UART0_Handler [WEAK]
|
||||
EXPORT UART1_Handler [WEAK]
|
||||
EXPORT SPI0_Handler [WEAK]
|
||||
EXPORT SPI1_Handler [WEAK]
|
||||
;EXPORT KBS_Handler [WEAK]
|
||||
;EXPORT QDEC_Handler [WEAK]
|
||||
EXPORT GADC_Handler [WEAK]
|
||||
EXPORT PWM_Handler [WEAK]
|
||||
EXPORT AES_Handler [WEAK]
|
||||
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
|
||||
EXPORT USB_Handler [WEAK];20
|
||||
EXPORT AUDIO_Handler [WEAK];21
|
||||
EXPORT RF24G_Handler [WEAK];22
|
||||
EXPORT SPI2_Handler [WEAK];23
|
||||
;EXPORT MPU_Handler [WEAK];24
|
||||
EXPORT UART2_Handler [WEAK];25
|
||||
EXPORT I2S_Handler [WEAK];26
|
||||
EXPORT AOTIMER0_Handler [WEAK];27
|
||||
EXPORT AOTIMER1_Handler [WEAK];28
|
||||
EXPORT CMP_Handler [WEAK];29
|
||||
EXPORT FMC_Handler [WEAK];30
|
||||
EXPORT CAN_Handler [WEAK];31
|
||||
|
||||
PendSV_Handler
|
||||
SysTick_Handler
|
||||
BLE_Handler
|
||||
RF24G_Handler
|
||||
DMA_Handler
|
||||
CPR_Handler
|
||||
GPIO_Handler
|
||||
RTC_Handler
|
||||
TIMER0_Handler
|
||||
TIMER1_Handler
|
||||
TIMER2_Handler
|
||||
TIMER3_Handler
|
||||
WDT_Handler
|
||||
I2C_Handler
|
||||
I2S_Handler
|
||||
UART0_Handler
|
||||
UART1_Handler
|
||||
UART2_Handler
|
||||
SPI0_Handler
|
||||
SPI1_Handler
|
||||
SPI2_Handler
|
||||
;KBS_Handler
|
||||
;QDEC_Handler
|
||||
GADC_Handler
|
||||
PWM_Handler
|
||||
AUDIO_Handler
|
||||
;SIM_Handler
|
||||
AES_Handler
|
||||
AOTIMER0_Handler
|
||||
AOTIMER1_Handler
|
||||
CMP_Handler
|
||||
FMC_Handler
|
||||
CAN_Handler
|
||||
USB_Handler
|
||||
|
||||
B .
|
||||
ENDP
|
||||
|
||||
|
||||
ALIGN
|
||||
|
||||
; User Initial Stack & Heap
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, = (Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
END
|
||||
|
||||
;/*****************************************************************************
|
||||
; * @file: startup_xinc.s
|
||||
; * @purpose: CMSIS Cortex-M0 Core Device Startup File for the
|
||||
; * Device xinc.
|
||||
; *****************************************************************************/
|
||||
|
||||
Stack_Size EQU 0x000006f0
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
Heap_Size EQU 0x00000000
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
; ToDo: Add here the vectors for the device specific external interrupts handler
|
||||
DCD BLE_Handler ; 0
|
||||
DCD DMA_Handler ; 1
|
||||
DCD CPR_Handler ; 2
|
||||
DCD GPIO_Handler ; 3
|
||||
DCD RTC_Handler ; 4
|
||||
DCD TIMER0_Handler ; 5
|
||||
DCD TIMER1_Handler ; 6
|
||||
DCD TIMER2_Handler ; 7
|
||||
DCD TIMER3_Handler ; 8
|
||||
DCD WDT_Handler ; 9
|
||||
DCD I2C_Handler ; 10
|
||||
DCD UART0_Handler ; 11
|
||||
DCD UART1_Handler ; 12
|
||||
DCD SPI0_Handler ; 13
|
||||
DCD SPI1_Handler ; 14
|
||||
DCD 0 ; 15
|
||||
DCD 0 ; 16
|
||||
DCD GADC_Handler ; 17
|
||||
DCD PWM_Handler ; 18
|
||||
DCD AES_Handler ; 19
|
||||
DCD USB_Handler ; 20
|
||||
DCD AUDIO_Handler ; 21
|
||||
DCD RF24G_Handler ; 22
|
||||
DCD SPI2_Handler ; 23
|
||||
DCD MPU_Handler ; 24
|
||||
DCD UART2_Handler ; 25
|
||||
DCD I2S_Handler ; 26
|
||||
DCD AOTIMER0_Handler ; 27
|
||||
DCD AOTIMER1_Handler ; 28
|
||||
DCD CMP_Handler ; 29
|
||||
DCD FMC_Handler ; 30
|
||||
DCD CAN_Handler ; 31
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
; Reset Handler
|
||||
|
||||
Reset_Handler PROC
|
||||
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
LDR r0, =0x4000013C ; remap
|
||||
LDR r1, =0x10000001
|
||||
STR r1, [r0]
|
||||
|
||||
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
EXPORT BLE_Handler [WEAK]
|
||||
EXPORT DMA_Handler [WEAK]
|
||||
EXPORT CPR_Handler [WEAK]
|
||||
EXPORT GPIO_Handler [WEAK]
|
||||
EXPORT RTC_Handler [WEAK]
|
||||
EXPORT TIMER0_Handler [WEAK]
|
||||
EXPORT TIMER1_Handler [WEAK]
|
||||
EXPORT TIMER2_Handler [WEAK]
|
||||
EXPORT TIMER3_Handler [WEAK]
|
||||
EXPORT WDT_Handler [WEAK]
|
||||
EXPORT I2C_Handler [WEAK]
|
||||
EXPORT UART0_Handler [WEAK]
|
||||
EXPORT UART1_Handler [WEAK]
|
||||
EXPORT SPI0_Handler [WEAK]
|
||||
EXPORT SPI1_Handler [WEAK]
|
||||
;EXPORT KBS_Handler [WEAK]
|
||||
;EXPORT QDEC_Handler [WEAK]
|
||||
EXPORT GADC_Handler [WEAK]
|
||||
EXPORT PWM_Handler [WEAK]
|
||||
EXPORT AES_Handler [WEAK]
|
||||
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
|
||||
EXPORT USB_Handler [WEAK];20
|
||||
EXPORT AUDIO_Handler [WEAK];21
|
||||
EXPORT RF24G_Handler [WEAK];22
|
||||
EXPORT SPI2_Handler [WEAK];23
|
||||
EXPORT MPU_Handler [WEAK];24
|
||||
EXPORT UART2_Handler [WEAK];25
|
||||
EXPORT I2S_Handler [WEAK];26
|
||||
EXPORT AOTIMER0_Handler [WEAK];27
|
||||
EXPORT AOTIMER1_Handler [WEAK];28
|
||||
EXPORT CMP_Handler [WEAK];29
|
||||
EXPORT FMC_Handler [WEAK];30
|
||||
EXPORT CAN_Handler [WEAK];31
|
||||
|
||||
PendSV_Handler
|
||||
SysTick_Handler
|
||||
BLE_Handler
|
||||
RF24G_Handler
|
||||
DMA_Handler
|
||||
CPR_Handler
|
||||
GPIO_Handler
|
||||
RTC_Handler
|
||||
TIMER0_Handler
|
||||
TIMER1_Handler
|
||||
TIMER2_Handler
|
||||
TIMER3_Handler
|
||||
WDT_Handler
|
||||
I2C_Handler
|
||||
I2S_Handler
|
||||
UART0_Handler
|
||||
UART1_Handler
|
||||
UART2_Handler
|
||||
SPI0_Handler
|
||||
SPI1_Handler
|
||||
SPI2_Handler
|
||||
MPU_Handler
|
||||
;KBS_Handler
|
||||
;QDEC_Handler
|
||||
GADC_Handler
|
||||
PWM_Handler
|
||||
AUDIO_Handler
|
||||
;SIM_Handler
|
||||
AES_Handler
|
||||
AOTIMER0_Handler
|
||||
AOTIMER1_Handler
|
||||
CMP_Handler
|
||||
FMC_Handler
|
||||
CAN_Handler
|
||||
USB_Handler
|
||||
|
||||
B .
|
||||
ENDP
|
||||
|
||||
|
||||
ALIGN
|
||||
|
||||
; User Initial Stack & Heap
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, = (Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
END
|
||||
|
||||
@@ -1,123 +1,128 @@
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xc6xxx.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define __DEBUG_OUT_PORT 0
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define VECTOR_NUM 48
|
||||
|
||||
void set_vector(void)
|
||||
{
|
||||
#if (USE_XIP == 1)
|
||||
__disable_irq();
|
||||
for (uint32_t i = 0, *Pvector = (uint32_t *)(0x11013000 + 0),
|
||||
*_vector_table = (uint32_t *)(0x10000000);
|
||||
i < VECTOR_NUM; i++) // copy vertor table
|
||||
{
|
||||
_vector_table[i] = *Pvector++;
|
||||
}
|
||||
|
||||
*((volatile unsigned int *)(0x4000013C)) =
|
||||
0x10000001; // inter vertor table remap
|
||||
__enable_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void WDT_ResetInit(void)
|
||||
{
|
||||
cpr_ctlapbclken_grctl__wdt_pclk_en__setf(ENABLE);
|
||||
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_DISABLE);
|
||||
|
||||
cpr_rstctl_wdtrst_mask_set(
|
||||
(WDT_SYS_RSTN_MASK_DISABLE | WDT_M0_RSTN_MASK_ENABLE));
|
||||
|
||||
cpr_lp_ctl__wdt_tclk_en__setf(DISABLE);
|
||||
wdt_cr__wdt_en__setf(DISABLE);
|
||||
}
|
||||
|
||||
#if (SCATTER_LOAD_RAM_EM)
|
||||
#define readl(addr) (*(volatile unsigned int *) (addr))
|
||||
#define writel(addr, value) (*(volatile unsigned int *) (addr) = (value))
|
||||
#endif
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
WDT_ResetInit();
|
||||
|
||||
#if (USE_XIP == 1)
|
||||
|
||||
set_vector();
|
||||
#endif
|
||||
|
||||
#if (SCATTER_LOAD_RAM_EM)
|
||||
//enable BT CLK
|
||||
writel(0x40000040, readl(0x40000040) | (0x01 << 4) | 0xFFFF0000);
|
||||
#endif
|
||||
}
|
||||
|
||||
__RAM_CODE int sendchar(int c)
|
||||
{
|
||||
unsigned int status;
|
||||
#if (__DEBUG_OUT_PORT == 1)
|
||||
for (;;) {
|
||||
status = (*((volatile unsigned *)(0x40011000 + 0x14)));
|
||||
status &= 0x20;
|
||||
if (status == 0x20)
|
||||
break;
|
||||
}
|
||||
(*((volatile unsigned *)(0x40011000 + 0x00))) = c;
|
||||
return (1);
|
||||
#else
|
||||
for (;;) {
|
||||
status = (*((volatile unsigned *)(0x40010000 + 0x14)));
|
||||
status &= 0x20;
|
||||
if (status == 0x20)
|
||||
break;
|
||||
}
|
||||
(*((volatile unsigned *)(0x40010000 + 0x00))) = c;
|
||||
return (1);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct __FILE
|
||||
{
|
||||
int handle; /* Add whatever you need here */
|
||||
};
|
||||
|
||||
FILE __stdout;
|
||||
__RAM_CODE int fputc(int ch, FILE *f) { return (sendchar(ch)); }
|
||||
|
||||
int ferror(FILE *f)
|
||||
{
|
||||
/* Your implementation of ferror */
|
||||
return EOF;
|
||||
}
|
||||
|
||||
void _ttywrch(int ch) { sendchar(ch); }
|
||||
|
||||
void _sys_exit(int return_code)
|
||||
{
|
||||
label:
|
||||
goto label; /* endless loop */
|
||||
}
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xc6xxx.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define __DEBUG_OUT_PORT 0
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define VECTOR_NUM 48
|
||||
|
||||
#if SINGLE_OTA
|
||||
#define LOADING_ADDR 0x11015000
|
||||
#else
|
||||
#define LOADING_ADDR 0x11013000
|
||||
#endif
|
||||
void set_vector(void)
|
||||
{
|
||||
#if (USE_XIP == 1)
|
||||
__disable_irq();
|
||||
for (uint32_t i = 0, *Pvector = (uint32_t *)(LOADING_ADDR + 0),
|
||||
*_vector_table = (uint32_t *)(0x10000000);
|
||||
i < VECTOR_NUM; i++) // copy vertor table
|
||||
{
|
||||
_vector_table[i] = *Pvector++;
|
||||
}
|
||||
|
||||
*((volatile unsigned int *)(0x4000013C)) =
|
||||
0x10000001; // inter vertor table remap
|
||||
__enable_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void WDT_ResetInit(void)
|
||||
{
|
||||
cpr_ctlapbclken_grctl__wdt_pclk_en__setf(ENABLE);
|
||||
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__wdt_rstn__setf(RSTCTL_DISABLE);
|
||||
|
||||
cpr_rstctl_wdtrst_mask_set(
|
||||
(WDT_SYS_RSTN_MASK_DISABLE | WDT_M0_RSTN_MASK_ENABLE));
|
||||
|
||||
cpr_lp_ctl__wdt_tclk_en__setf(DISABLE);
|
||||
wdt_cr__wdt_en__setf(DISABLE);
|
||||
}
|
||||
|
||||
#if (SCATTER_LOAD_RAM_EM)
|
||||
#define readl(addr) (*(volatile unsigned int *)(addr))
|
||||
#define writel(addr, value) (*(volatile unsigned int *)(addr) = (value))
|
||||
#endif
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
WDT_ResetInit();
|
||||
|
||||
#if (USE_XIP == 1)
|
||||
|
||||
set_vector();
|
||||
#endif
|
||||
|
||||
#if (SCATTER_LOAD_RAM_EM)
|
||||
// enable BT CLK
|
||||
writel(0x40000040, readl(0x40000040) | (0x01 << 4) | 0xFFFF0000);
|
||||
#endif
|
||||
}
|
||||
|
||||
__RAM_CODE int sendchar(int c)
|
||||
{
|
||||
unsigned int status;
|
||||
#if (__DEBUG_OUT_PORT == 1)
|
||||
for (;;) {
|
||||
status = (*((volatile unsigned *)(0x40011000 + 0x14)));
|
||||
status &= 0x20;
|
||||
if (status == 0x20)
|
||||
break;
|
||||
}
|
||||
(*((volatile unsigned *)(0x40011000 + 0x00))) = c;
|
||||
return (1);
|
||||
#else
|
||||
for (;;) {
|
||||
status = (*((volatile unsigned *)(0x40010000 + 0x14)));
|
||||
status &= 0x20;
|
||||
if (status == 0x20)
|
||||
break;
|
||||
}
|
||||
(*((volatile unsigned *)(0x40010000 + 0x00))) = c;
|
||||
return (1);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct __FILE
|
||||
{
|
||||
int handle; /* Add whatever you need here */
|
||||
};
|
||||
|
||||
FILE __stdout;
|
||||
__RAM_CODE int fputc(int ch, FILE *f) { return (sendchar(ch)); }
|
||||
|
||||
int ferror(FILE *f)
|
||||
{
|
||||
/* Your implementation of ferror */
|
||||
return EOF;
|
||||
}
|
||||
|
||||
void _ttywrch(int ch) { sendchar(ch); }
|
||||
|
||||
void _sys_exit(int return_code)
|
||||
{
|
||||
label:
|
||||
goto label; /* endless loop */
|
||||
}
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
/*!
|
||||
* \file timer.c
|
||||
*
|
||||
* \brief Target timer implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "timer.h"
|
||||
#include "xc_drv_timer.h"
|
||||
#include "rgblight.h"
|
||||
#include "nec_infrared.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
TimerStatus_t timer_status =
|
||||
{
|
||||
.t0_flag = false,
|
||||
// .t1_flag = false,
|
||||
// .t2_flag = false,
|
||||
// .t3_flag = false,
|
||||
};
|
||||
// 定义多个软定时器
|
||||
Timer timer1, timer2, timer4, timer5;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
// 初始化定时器
|
||||
void initTimer(Timer *timer)
|
||||
{
|
||||
timer->count = 0;
|
||||
timer->active = 1;
|
||||
}
|
||||
|
||||
// 更新定时器
|
||||
void updateTimer(Timer *timer)
|
||||
{
|
||||
if (timer->active && timer->count > 0)
|
||||
{
|
||||
timer->count--;
|
||||
if (timer->count == 0)
|
||||
{
|
||||
timer->active = 0; // 定时器到达设定时间,将活跃状态置为0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 启动定时器
|
||||
void startTimer(Timer *timer, unsigned int duration)
|
||||
{
|
||||
timer->count = duration;
|
||||
timer->active = 1;
|
||||
}
|
||||
// 中止定时器
|
||||
void stopTimer(Timer *timer)
|
||||
{
|
||||
timer->active = 1;
|
||||
timer->count = 0;
|
||||
}
|
||||
|
||||
// 软定时器1到达设定时间时执行的函数
|
||||
void timer1Callback(uint8_t mode)//模式切换回调
|
||||
{
|
||||
modefunctin[mode]();
|
||||
}
|
||||
|
||||
// 软定时器2到达设定时间时执行的函数
|
||||
void timer2Callback(void)//占空比刷新回调
|
||||
{
|
||||
UpdateDisplay();//更新显示
|
||||
}
|
||||
// 软定时器4到达设定时间时执行的函数
|
||||
void timer4Callback(void)//对码计时
|
||||
{
|
||||
MatchOverFlag = 1;
|
||||
}
|
||||
// 软定时器5到达设定时间时执行的函数
|
||||
void timer5Callback(uint8_t mode)//模式循环
|
||||
{
|
||||
|
||||
if (++MODE19_i > 18) //先自增,如果大于20,就赋值0;
|
||||
MODE19_i = 0;
|
||||
|
||||
if (mode == MODE19)
|
||||
{
|
||||
updateParameterMode19(MODE19_i);
|
||||
startTimer(&timer1, 1); // 立刻启动定时器1,设定间隔为1ms,执行1次,每次进来就是切换到下一个程序,需要立刻切换,
|
||||
startTimer(&timer5, 20000);//程序切换周期20s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief timer0_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void timer0_2_init(void)
|
||||
{
|
||||
uint32_t us = 1000;//定时1ms
|
||||
Timer_InitCfg_t timer_cfg;
|
||||
|
||||
timer_cfg.timer_src_clk = TIMER_CLK_SRC_32K;
|
||||
timer_cfg.timer_div_clk = TIMER_DIV_CLK_16MHzOr16K;
|
||||
timer_cfg.timer_mode = TIMER_MODE_CYCLE;
|
||||
|
||||
// Timer0 Config & Start
|
||||
xc_timer_init(TIMER0_IDX, &timer_cfg);
|
||||
xc_timer_set_value(TIMER0_IDX, us);//for(int m=0;m<0x455000;m++);
|
||||
xc_timer_start(TIMER0_IDX);
|
||||
// Timer1 Config & Start
|
||||
us = 20000;//定时20ms
|
||||
timer_cfg.timer_mode = TIMER_MODE_SINGLE;//单次计时
|
||||
xc_timer_init(TIMER2_IDX, &timer_cfg);
|
||||
xc_timer_set_value(TIMER2_IDX, us);
|
||||
// xc_timer_start(TIMER2_IDX);
|
||||
|
||||
startTimer(&timer1, 1); // 立刻启动定时器1,设定间隔为1ms,执行1次
|
||||
startTimer(&timer4, 5000); // 立刻启动定时器1,设定间隔为5s,执行1次
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Timer0_Callback
|
||||
* @details Timer0 handler callback function
|
||||
* @param void *context
|
||||
* @retval void
|
||||
*/
|
||||
__RAM_CODE void timer0_callback(void *context)
|
||||
{
|
||||
// 在中断服务函数中更新定时器0的状态
|
||||
updateTimer(&timer1);
|
||||
updateTimer(&timer2);
|
||||
// updateTimer(&timer3);
|
||||
updateTimer(&timer4);
|
||||
updateTimer(&timer5);
|
||||
|
||||
if (!timer1.active && timer1.count == 0)
|
||||
{
|
||||
stopTimer(&timer1);
|
||||
if (CurrentModel == DYNAMICMODE)
|
||||
{
|
||||
timer1Callback(mode); // 执行定时器1到达设定时间时的函数
|
||||
}
|
||||
if (CurrentStatus == DYNAMICEEFECT) //处于动态效果才重复启动定时器
|
||||
{
|
||||
if (mode == MODE19)
|
||||
{
|
||||
if (MODE19_i == MODE0)
|
||||
return;
|
||||
else if (MODE19_i == MODE1 || MODE19_i == MODE2 || MODE19_i == MODE3)
|
||||
startTimer(&timer1, FadeSpeed); // 重新启动定时器1,设定间隔为10ms
|
||||
|
||||
else
|
||||
startTimer(&timer1, speedOption[TimeSpeed]); // 重新启动定时器1,设定间隔为500ms
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mode == MODE1 || mode == MODE2 || mode == MODE3)
|
||||
startTimer(&timer1, FadeSpeed); // 重新启动定时器1,设定间隔为10ms
|
||||
else
|
||||
startTimer(&timer1, speedOption[TimeSpeed]); // 重新启动定时器1,设定间隔为500ms
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// 检查定时器2是否到达设定时间
|
||||
if (!timer2.active && timer2.count == 0)
|
||||
{
|
||||
stopTimer(&timer2);
|
||||
timer2Callback(); // 执行定时器2到达设定时间时的函数
|
||||
}
|
||||
if (!timer4.active && timer4.count == 0)
|
||||
{
|
||||
stopTimer(&timer4);
|
||||
timer4Callback(); // 执行定时器4到达设定时间时的函数
|
||||
}
|
||||
if (!timer5.active && timer5.count == 0)
|
||||
{
|
||||
stopTimer(&timer5);
|
||||
timer5Callback(mode); // 执行定时器5到达设定时间时的函数
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Timer1_Callback
|
||||
* @details Timer1 handler callback function
|
||||
* @param void *context
|
||||
* @retval void
|
||||
*/
|
||||
__RAM_CODE void timer2_callback(void *context)
|
||||
{
|
||||
xc_timer_stop(TIMER2_IDX);
|
||||
uint32_t us = 20000;
|
||||
xc_timer_set_value(TIMER2_IDX, us);
|
||||
|
||||
IR.IR_decode_bit = 0; //电平计数超过了码元长度 清除位数计数
|
||||
IR.IR_code = 0;
|
||||
IR.IR_event = 0;
|
||||
|
||||
IR.IR_code_get = 0;
|
||||
IR.low_8bit = 0;
|
||||
IR.hig_8bit = 0;
|
||||
IR.rece_ok = 0;
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*!
|
||||
* \file timer.h
|
||||
*
|
||||
* \brief The head file of timer.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TIMER_H__
|
||||
#define __TIMER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
typedef struct TimerStatus_s
|
||||
{
|
||||
uint8_t t0_flag;
|
||||
uint8_t t1_flag;
|
||||
uint8_t t2_flag;
|
||||
uint8_t t3_flag;
|
||||
|
||||
} TimerStatus_t;
|
||||
|
||||
// 定义定时器结构体
|
||||
typedef struct {
|
||||
unsigned int count; // 计数器
|
||||
unsigned char active; // 活跃状态
|
||||
} Timer;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern Timer timer1, timer2, timer4, timer5;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void timer0_2_init(void);
|
||||
void initTimer(Timer *timer);
|
||||
void updateTimer(Timer *timer);
|
||||
void startTimer(Timer *timer, unsigned int duration);
|
||||
void stopTimer(Timer *timer);
|
||||
void timer1Callback(uint8_t mode);
|
||||
void timer2Callback(void);
|
||||
//void timer3Callback(void);
|
||||
void timer4Callback(void);
|
||||
void timer5Callback(uint8_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TIMER_H__ */
|
||||
|
||||
@@ -1,181 +1,209 @@
|
||||
/*!
|
||||
* \file uart.c
|
||||
*
|
||||
* \brief Target uart implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "uart.h"
|
||||
#include "xc_drv_uart.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
uint8_t only_read_charactertics_buffer[5] = {5, 4, 3, 2, 1};
|
||||
uint8_t only_read_charactertics_buffer_length = 5;
|
||||
|
||||
uint8_t buffer[5] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
|
||||
extern bool buffer_complet_flag;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief uart_demo
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void uart_demo(void)
|
||||
{
|
||||
DEBUG("__UART_DEMO__\n");
|
||||
|
||||
|
||||
uint8_t uart_handle = UART0_IDX;
|
||||
|
||||
if (uart_handle == UART1_IDX)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
|
||||
gpio_cfg.Pin = GPIO_3;
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
gpio_cfg.FunSel = UART1_TX;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.Pin = GPIO_2;
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
gpio_cfg.FunSel = UART1_RX;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_TCR_STOP_1BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_2400;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(uart_handle, &uart_cfg);
|
||||
}
|
||||
else if (uart_handle == UART2_IDX)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux1;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.FunSel = GPIO_Dx;
|
||||
|
||||
gpio_cfg.Pin = GPIO_32; // uart2 tx
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.Pin = GPIO_31; // uart2 rx
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_STOP_1_BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_115200;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(uart_handle, &uart_cfg);
|
||||
}
|
||||
|
||||
xc_uart_enable_rx_it(uart_handle);
|
||||
|
||||
if (uart_handle == UART0_IDX)
|
||||
{
|
||||
NVIC_EnableIRQ(UART0_IRQn);
|
||||
}
|
||||
else if (uart_handle == UART1_IDX)
|
||||
{
|
||||
NVIC_EnableIRQ(UART1_IRQn);
|
||||
}
|
||||
else if (uart_handle == UART2_IDX)
|
||||
{
|
||||
NVIC_EnableIRQ(UART2_IRQn);
|
||||
}
|
||||
|
||||
// for(int i=0; i<26; i++)
|
||||
// {
|
||||
// rxbuff[i] = i+'A';
|
||||
// }
|
||||
// xc_uart_send_data(uart_handle,rxbuff,26);
|
||||
|
||||
|
||||
|
||||
printf("test\n");
|
||||
|
||||
|
||||
// while(1)
|
||||
// {
|
||||
// data_len = xc_uart_receive_data(uart_handle, rxbuff);
|
||||
// if(data_len)
|
||||
// {
|
||||
// xc_uart_send_data(uart_handle,rxbuff,data_len);
|
||||
// data_len = 0;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void scan_uart(void)
|
||||
{
|
||||
// data_len = xc_uart_receive_data(uart_handle, rxbuff);
|
||||
if (buffer_complet_flag)
|
||||
{
|
||||
static uint8_t n = 1;
|
||||
|
||||
// uint16_t data_len = 0;
|
||||
uint8_t *rxbuff;
|
||||
uint8_t uart_handle = UART0_IDX;
|
||||
|
||||
buffer_complet_flag = 0;
|
||||
xc_uart_receive_data(uart_handle, rxbuff);
|
||||
for (uint8_t i = 0; i < 5; i++)
|
||||
{
|
||||
only_read_charactertics_buffer[i] = rxbuff[i];
|
||||
}
|
||||
|
||||
if (n == 1)
|
||||
{
|
||||
n--;
|
||||
xc_uart_send_data(uart_handle, only_read_charactertics_buffer, 5);
|
||||
}
|
||||
|
||||
|
||||
// data_len = 0;
|
||||
}
|
||||
}
|
||||
/*!
|
||||
* \file uart.c
|
||||
*
|
||||
* \brief Target uart implementation
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include "uart.h"
|
||||
#include "xc_drv_uart.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
uint8_t only_read_charactertics_buffer[5] = {5, 4, 3, 2, 1};
|
||||
uint8_t only_read_charactertics_buffer_length = 5;
|
||||
|
||||
uint8_t buffer[5] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
|
||||
extern bool buffer_complet_flag;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief uart_demo
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void uart_demo(void)
|
||||
{
|
||||
DEBUG("__UART_DEMO__\n");
|
||||
|
||||
|
||||
uint8_t uart_handle = UART0_IDX;
|
||||
|
||||
if (uart_handle == UART1_IDX)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
|
||||
gpio_cfg.Pin = GPIO_3;
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
gpio_cfg.FunSel = UART1_TX;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.Pin = GPIO_2;
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
gpio_cfg.FunSel = UART1_RX;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_TCR_STOP_1BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_2400;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(uart_handle, &uart_cfg);
|
||||
}
|
||||
else if (uart_handle == UART2_IDX)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg = {0};
|
||||
|
||||
gpio_cfg.Mux = GPIO_Mux1;
|
||||
gpio_cfg.Pull = GPIO_PULLUP;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.FunSel = GPIO_Dx;
|
||||
|
||||
gpio_cfg.Pin = GPIO_32; // uart2 tx
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
gpio_cfg.Pin = GPIO_31; // uart2 rx
|
||||
gpio_cfg.Dir = GPIO_DIR_INPUT;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
UART_InitCfg_t uart_cfg = {0};
|
||||
|
||||
uart_cfg.Parity = UART_PARITY_DISABLE;
|
||||
uart_cfg.StopBits = UART_STOP_1_BITS;
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS;
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_115200;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE;
|
||||
|
||||
xc_uart_init(uart_handle, &uart_cfg);
|
||||
}
|
||||
|
||||
xc_uart_enable_rx_it(uart_handle);
|
||||
|
||||
if (uart_handle == UART0_IDX)
|
||||
{
|
||||
NVIC_EnableIRQ(UART0_IRQn);
|
||||
}
|
||||
else if (uart_handle == UART1_IDX)
|
||||
{
|
||||
NVIC_EnableIRQ(UART1_IRQn);
|
||||
}
|
||||
else if (uart_handle == UART2_IDX)
|
||||
{
|
||||
NVIC_EnableIRQ(UART2_IRQn);
|
||||
}
|
||||
|
||||
// for(int i=0; i<26; i++)
|
||||
// {
|
||||
// rxbuff[i] = i+'A';
|
||||
// }
|
||||
// xc_uart_send_data(uart_handle,rxbuff,26);
|
||||
|
||||
|
||||
|
||||
// printf("test\n");
|
||||
|
||||
|
||||
// while(1)
|
||||
// {
|
||||
// data_len = xc_uart_receive_data(uart_handle, rxbuff);
|
||||
// if(data_len)
|
||||
// {
|
||||
// xc_uart_send_data(uart_handle,rxbuff,data_len);
|
||||
// data_len = 0;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//void scan_uart(uint8_t *arr)
|
||||
//{
|
||||
//// data_len = xc_uart_receive_data(uart_handle, rxbuff);
|
||||
// if (buffer_complet_flag)
|
||||
// {
|
||||
// static uint8_t n = 1;
|
||||
|
||||
// // uint16_t data_len = 0;
|
||||
// uint8_t *rxbuff;
|
||||
// uint8_t uart_handle = UART0_IDX;
|
||||
|
||||
// buffer_complet_flag = 0;
|
||||
//// xc_uart_receive_data(uart_handle, rxbuff);
|
||||
//// for (uint8_t i = 0; i < 5; i++)
|
||||
//// {
|
||||
//// only_read_charactertics_buffer[i] = rxbuff[i];
|
||||
//// }
|
||||
|
||||
// if (n == 1)
|
||||
// {
|
||||
// n--;
|
||||
// xc_uart_send_data(uart_handle, arr, 4);
|
||||
// }
|
||||
|
||||
|
||||
// // data_len = 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
void scan_uart(uint8_t *arr)
|
||||
{
|
||||
uint8_t uart_handle = UART0_IDX;
|
||||
|
||||
buffer_complet_flag = false; // 清除标志
|
||||
|
||||
// 组帧:帧头 + 数据 + 校验
|
||||
uint8_t frame[6]; // 1字节帧头 + 4字节数据 + 1字节校验位
|
||||
frame[0] = 0xAA; // 帧头标志
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
frame[1 + i] = arr[i]; // 填充数据
|
||||
}
|
||||
|
||||
// 校验位:简单累加校验
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < 5; i++) // 帧头和数据
|
||||
{
|
||||
checksum += frame[i];
|
||||
}
|
||||
frame[5] = checksum; // 校验位
|
||||
|
||||
// 发送帧
|
||||
|
||||
xc_uart_send_data(uart_handle, frame, 6); // 发送完整帧
|
||||
// DEBUG("temp[0]:%d,temp[1]:%d,temp[2]:%d,temp[3]:%d,temp[4]:%d,temp[5]:%d\n",frame[0],frame[1],frame[2],frame[3],frame[4],frame[5]);
|
||||
}
|
||||
@@ -1,64 +1,64 @@
|
||||
/*!
|
||||
* \file uart.h
|
||||
*
|
||||
* \brief The head file of uart.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __UART_H__
|
||||
#define __UART_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void uart_demo(void);
|
||||
void scan_uart(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __UART_H__ */
|
||||
|
||||
|
||||
/*!
|
||||
* \file uart.h
|
||||
*
|
||||
* \brief The head file of uart.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __UART_H__
|
||||
#define __UART_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void uart_demo(void);
|
||||
void scan_uart(uint8_t *arr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __UART_H__ */
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
// The product UART implementation references this application-level flag.
|
||||
// Keep it independent from the old RGB application during SDK migration.
|
||||
bool buffer_complet_flag = false;
|
||||
@@ -1,219 +1,219 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.c
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#include "usr_server.h"
|
||||
#include "gpio.h"
|
||||
#include "xc_drv_gpio.h"
|
||||
|
||||
#include "rgblight.h"
|
||||
#if (BLE_APP_PRESENT)
|
||||
|
||||
uint8_t srv_user_lid = GATT_INVALID_USER_LID;
|
||||
uint16_t custom_svc_start_hdl = GATT_INVALID_HDL;
|
||||
uint8_t custom_svc_tx_char_notify = DISABLE;
|
||||
|
||||
|
||||
|
||||
extern uint8_t only_read_charactertics_buffer[5];
|
||||
extern uint8_t only_read_charactertics_buffer_length;
|
||||
|
||||
__WEAK void ble_callback(uint8_t value0,uint8_t value1,uint8_t value2,uint8_t value3)
|
||||
{
|
||||
|
||||
}
|
||||
static const gatt_att16_desc_t custom_server_atts[] =
|
||||
{
|
||||
[CUSTOM_SVC_DECL] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_PRIMARY_SERVICE,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_RX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_RX_CHAR_VAL] =
|
||||
{
|
||||
.uuid16 = CUSTOM_SVC_RX_CHAR_UUID,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WC_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_VAL] =
|
||||
{
|
||||
.uuid16 = CUSTOM_SVC_TX_CHAR_UUID,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_N_BIT,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_CFG] =
|
||||
{
|
||||
.uuid16 = GATT_DESC_CLIENT_CHAR_CFG,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
|
||||
uint16_t srv_get_hdl_from_att_idx(uint8_t idx)
|
||||
{
|
||||
return custom_svc_start_hdl + idx ;
|
||||
}
|
||||
|
||||
// This function is called when GATT server user has initiated event send to
|
||||
// peer device or if an error occurs.
|
||||
__STATIC void custom_svc_cb_event_sent(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t dummy, uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, dummy:%d, status:%d \r\n", __func__,
|
||||
conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
// This function is called when peer want to read local attribute database
|
||||
// value.
|
||||
__STATIC void custom_svc_cb_att_read_get(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, uint16_t max_length)
|
||||
{
|
||||
uint16_t status;
|
||||
//接收到的串口数据,写入该缓存,手机可以读取
|
||||
// uint8_t data[] = {0x12, 0x15, 0x46, 0x62,0x22};
|
||||
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d, "
|
||||
"max_length:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset, max_length);
|
||||
// Send result to peer device
|
||||
// status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
// sizeof(data), sizeof(data), data);
|
||||
status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
sizeof(only_read_charactertics_buffer), sizeof(only_read_charactertics_buffer), only_read_charactertics_buffer);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_srv_read_cfm error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC void custom_svc_cb_att_val_set(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
uint16_t status;
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset);
|
||||
status =
|
||||
xc_ble_gatt_srv_write_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_srv_write_cfm error 0x%x", status);
|
||||
}
|
||||
LOGI("length:%d data:\r\n", length);
|
||||
// DUMP_DATA_PRINTF(&(co_buf_data(p_data)[0]), length);
|
||||
|
||||
// 检查写入的数据是否是 0x12
|
||||
// if (length == 1 && co_buf_data(p_data)[0] == 0x12)
|
||||
if (length == 4)
|
||||
{
|
||||
|
||||
|
||||
ble_callback(co_buf_data(p_data)[0],co_buf_data(p_data)[1],co_buf_data(p_data)[2],co_buf_data(p_data)[3]);
|
||||
// 设置指定的 GPIO 引脚为高电平
|
||||
// xc_gpio_write_pin(LED3_PIN, GPIO_PIN_SET);
|
||||
|
||||
|
||||
// only_read_charactertics_buffer[0] = co_buf_data(p_data)[0];r_DutyCycle*Brightness/10
|
||||
// only_read_charactertics_buffer[0] = (uint8_t)(r_DutyCycle*Brightness/10);
|
||||
// only_read_charactertics_buffer[1] = co_buf_data(p_data)[1];
|
||||
// only_read_charactertics_buffer[2] = co_buf_data(p_data)[2];
|
||||
// only_read_charactertics_buffer[3] = co_buf_data(p_data)[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
// xc_gpio_write_pin(LED3_PIN, GPIO_PIN_RESET);
|
||||
// LOGI("LED3_PIN:%d", xc_gpio_read_pin(LED3_PIN));
|
||||
}
|
||||
|
||||
if (hdl == srv_get_hdl_from_att_idx(CUSTOM_SVC_TX_CHAR_CFG))
|
||||
{
|
||||
if ((co_buf_data(p_data)[0] == 0) && (co_buf_data(p_data)[1] == 0))
|
||||
{
|
||||
custom_svc_tx_char_notify = DISABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
custom_svc_tx_char_notify = ENABLE;
|
||||
uint8_t data[] = {0x12, 0x13, 0x14};
|
||||
slave_send_data(data, sizeof(data), CUSTOM_SVC_TX_CHAR_VAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const gatt_srv_cb_t custom_src_cb =
|
||||
{
|
||||
.cb_event_sent = custom_svc_cb_event_sent,
|
||||
.cb_att_read_get = custom_svc_cb_att_read_get,
|
||||
.cb_att_val_set = custom_svc_cb_att_val_set,
|
||||
};
|
||||
|
||||
uint8_t custom_svc_add(void)
|
||||
{
|
||||
int nb_att = sizeof(custom_server_atts) / sizeof(custom_server_atts[0]);
|
||||
uint16_t status;
|
||||
uint16_t custom_svc_uuid = CUSTOM_SVC_UUID;
|
||||
status = xc_ble_gatt_user_srv_register(GAP_LE_MTU_MAX, 0, &custom_src_cb,
|
||||
&srv_user_lid);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_user_srv_register error 0x%x", status);
|
||||
}
|
||||
status = xc_ble_gatt_service16_add(
|
||||
srv_user_lid, GATT_UUID_16 << GATT_SVC_UUID_TYPE_LSB, custom_svc_uuid,
|
||||
nb_att, NULL, &(custom_server_atts[0]), nb_att, &custom_svc_start_hdl);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_service16_add error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx)
|
||||
{
|
||||
uint16_t status = INVALID_DATA;
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
if (app_env->slave_connected && custom_svc_tx_char_notify)
|
||||
{
|
||||
status = xc_ble_gatt_srv_notify(app_env->slave_conidx, srv_user_lid, 0,
|
||||
srv_get_hdl_from_att_idx(att_idx), len,
|
||||
data);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_srv_notify error 0x%x", status);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.c
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#include "usr_server.h"
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
|
||||
uint8_t srv_user_lid = GATT_INVALID_USER_LID;
|
||||
uint16_t custom_svc_start_hdl = GATT_INVALID_HDL;
|
||||
uint8_t custom_svc_tx_char_notify = DISABLE;
|
||||
|
||||
|
||||
|
||||
extern uint8_t only_read_charactertics_buffer[5];
|
||||
extern uint8_t only_read_charactertics_buffer_length;
|
||||
|
||||
__WEAK void ble_callback(uint8_t value0,uint8_t value1,uint8_t value2,uint8_t value3)
|
||||
{
|
||||
|
||||
}
|
||||
__WEAK void ble_diy_callback(uint8_t value,uint8_t* color,uint8_t length)
|
||||
{
|
||||
|
||||
}
|
||||
static const gatt_att16_desc_t custom_server_atts[] =
|
||||
{
|
||||
[CUSTOM_SVC_DECL] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_PRIMARY_SERVICE,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_RX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_RX_CHAR_VAL] =
|
||||
{
|
||||
.uuid16 = CUSTOM_SVC_RX_CHAR_UUID,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WC_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_DECL_CHAR] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_VAL] =
|
||||
{
|
||||
.uuid16 = CUSTOM_SVC_TX_CHAR_UUID,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_N_BIT,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT | CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_CFG] =
|
||||
{
|
||||
.uuid16 = GATT_DESC_CLIENT_CHAR_CFG,
|
||||
.info = GATT_ATT_RD_BIT | GATT_ATT_WR_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
|
||||
uint16_t srv_get_hdl_from_att_idx(uint8_t idx)
|
||||
{
|
||||
return custom_svc_start_hdl + idx ;
|
||||
}
|
||||
|
||||
// This function is called when GATT server user has initiated event send to
|
||||
// peer device or if an error occurs.
|
||||
__STATIC void custom_svc_cb_event_sent(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t dummy, uint16_t status)
|
||||
{
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, dummy:%d, status:%d \r\n", __func__,
|
||||
conidx, user_lid, dummy, status);
|
||||
}
|
||||
|
||||
// This function is called when peer want to read local attribute database
|
||||
// value.
|
||||
__STATIC void custom_svc_cb_att_read_get(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, uint16_t max_length)
|
||||
{
|
||||
uint16_t status;
|
||||
//接收到的串口数据,写入该缓存,手机可以读取
|
||||
// uint8_t data[] = {0x12, 0x15, 0x46, 0x62,0x22};
|
||||
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d, "
|
||||
"max_length:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset, max_length);
|
||||
// Send result to peer device
|
||||
// status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
// sizeof(data), sizeof(data), data);
|
||||
status = xc_ble_gatt_srv_read_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR,
|
||||
sizeof(only_read_charactertics_buffer), sizeof(only_read_charactertics_buffer), only_read_charactertics_buffer);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_srv_read_cfm error 0x%x", status);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC void custom_svc_cb_att_val_set(uint8_t conidx, uint8_t user_lid,
|
||||
uint16_t token, uint16_t hdl,
|
||||
uint16_t offset, co_buf_t *p_data)
|
||||
{
|
||||
uint16_t length = co_buf_data_len(p_data);
|
||||
uint16_t status;
|
||||
LOGI("[%s] conidx:%d, usr_lid:%d, token:%d, hdl:%d, offset:%d \r\n",
|
||||
__func__, conidx, user_lid, token, hdl, offset);
|
||||
status =
|
||||
xc_ble_gatt_srv_write_cfm(conidx, user_lid, token, GAP_ERR_NO_ERROR);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_srv_write_cfm error 0x%x", status);
|
||||
}
|
||||
LOGI("length:%d data:\r\n", length);
|
||||
// DUMP_DATA_PRINTF(&(co_buf_data(p_data)[0]), length);
|
||||
|
||||
// 检查写入的数据是否是 0x12
|
||||
// if (length == 1 && co_buf_data(p_data)[0] == 0x12)
|
||||
if (length == 4)
|
||||
{
|
||||
|
||||
|
||||
ble_callback(co_buf_data(p_data)[0],co_buf_data(p_data)[1],co_buf_data(p_data)[2],co_buf_data(p_data)[3]);
|
||||
// 设置指定的 GPIO 引脚为高电平
|
||||
// xc_gpio_write_pin(LED3_PIN, GPIO_PIN_SET);
|
||||
|
||||
|
||||
// only_read_charactertics_buffer[0] = co_buf_data(p_data)[0];r_DutyCycle*Brightness/10
|
||||
// only_read_charactertics_buffer[0] = (uint8_t)(r_DutyCycle*Brightness/10);
|
||||
// only_read_charactertics_buffer[1] = co_buf_data(p_data)[1];
|
||||
// only_read_charactertics_buffer[2] = co_buf_data(p_data)[2];
|
||||
// only_read_charactertics_buffer[3] = co_buf_data(p_data)[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
ble_diy_callback(co_buf_data(p_data)[0],co_buf_data(p_data),length);
|
||||
}
|
||||
|
||||
if (hdl == srv_get_hdl_from_att_idx(CUSTOM_SVC_TX_CHAR_CFG))
|
||||
{
|
||||
if ((co_buf_data(p_data)[0] == 0) && (co_buf_data(p_data)[1] == 0))
|
||||
{
|
||||
custom_svc_tx_char_notify = DISABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
custom_svc_tx_char_notify = ENABLE;
|
||||
uint8_t data[] = {0x12, 0x13, 0x14};
|
||||
slave_send_data(data, sizeof(data), CUSTOM_SVC_TX_CHAR_VAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const gatt_srv_cb_t custom_src_cb =
|
||||
{
|
||||
.cb_event_sent = custom_svc_cb_event_sent,
|
||||
.cb_att_read_get = custom_svc_cb_att_read_get,
|
||||
.cb_att_val_set = custom_svc_cb_att_val_set,
|
||||
};
|
||||
|
||||
uint8_t custom_svc_add(void)
|
||||
{
|
||||
int nb_att = sizeof(custom_server_atts) / sizeof(custom_server_atts[0]);
|
||||
uint16_t status;
|
||||
uint16_t custom_svc_uuid = CUSTOM_SVC_UUID;
|
||||
status = xc_ble_gatt_user_srv_register(GAP_LE_MTU_MAX, 0, &custom_src_cb,
|
||||
&srv_user_lid);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_user_srv_register error 0x%x", status);
|
||||
}
|
||||
status = xc_ble_gatt_service16_add(
|
||||
srv_user_lid, GATT_UUID_16 << GATT_SVC_UUID_TYPE_LSB, custom_svc_uuid,
|
||||
nb_att, NULL, &(custom_server_atts[0]), nb_att, &custom_svc_start_hdl);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_service16_add error 0x%x", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx)
|
||||
{
|
||||
uint16_t status = INVALID_DATA;
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
if (app_env->slave_connected && custom_svc_tx_char_notify)
|
||||
{
|
||||
status = xc_ble_gatt_srv_notify(app_env->slave_conidx, srv_user_lid, 0,
|
||||
srv_get_hdl_from_att_idx(att_idx), len,
|
||||
data);
|
||||
if (status != GATT_NO_ERROR)
|
||||
{
|
||||
LOGI_ERR("gatt_srv_notify error 0x%x", status);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _USR_SERVER_H_
|
||||
#define _USR_SERVER_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
|
||||
#define CUSTOM_SVC_UUID 0xFFF0
|
||||
#define CUSTOM_SVC_RX_CHAR_UUID 0xFFF3
|
||||
#define CUSTOM_SVC_TX_CHAR_UUID 0xFFF4
|
||||
#define CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH 20
|
||||
#define CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH 20
|
||||
|
||||
|
||||
|
||||
|
||||
enum cust_svc
|
||||
{
|
||||
CUSTOM_SVC_DECL = 0,
|
||||
CUSTOM_SVC_RX_CHAR_DECL_CHAR,
|
||||
CUSTOM_SVC_RX_CHAR_VAL,
|
||||
CUSTOM_SVC_TX_CHAR_DECL_CHAR,
|
||||
CUSTOM_SVC_TX_CHAR_VAL,
|
||||
CUSTOM_SVC_TX_CHAR_CFG,
|
||||
};
|
||||
uint8_t custom_svc_add(void);
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
#endif // _USR_SERVER_H_
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file usr_server.h
|
||||
*
|
||||
* @brief Custom Server profile database definitions.
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#ifndef _USR_SERVER_H_
|
||||
#define _USR_SERVER_H_
|
||||
|
||||
#include "app_task.h"
|
||||
#include "dbg.h"
|
||||
#include "gatt.h"
|
||||
#include "gatt_msg.h"
|
||||
#include "rwble_hl_config.h"
|
||||
#include "xc_gatt_server_api.h"
|
||||
|
||||
#define CUSTOM_SVC_UUID 0xFFF0
|
||||
#define CUSTOM_SVC_RX_CHAR_UUID 0xFFE6
|
||||
#define CUSTOM_SVC_TX_CHAR_UUID 0xFFF4
|
||||
#define CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH 20
|
||||
#define CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH 20
|
||||
|
||||
|
||||
|
||||
|
||||
enum cust_svc
|
||||
{
|
||||
CUSTOM_SVC_DECL = 0,
|
||||
CUSTOM_SVC_RX_CHAR_DECL_CHAR,
|
||||
CUSTOM_SVC_RX_CHAR_VAL,
|
||||
CUSTOM_SVC_TX_CHAR_DECL_CHAR,
|
||||
CUSTOM_SVC_TX_CHAR_VAL,
|
||||
CUSTOM_SVC_TX_CHAR_CFG,
|
||||
};
|
||||
uint8_t custom_svc_add(void);
|
||||
uint8_t slave_send_data(uint8_t *data, uint8_t len, uint8_t att_idx);
|
||||
#endif // _USR_SERVER_H_
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
FUNC void Initialization(void)
|
||||
{
|
||||
SP = _RDWORD(0x10000000);
|
||||
PC = _RDWORD(0x10000004);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOAD %L INCREMENTAL
|
||||
|
||||
FUNC void Initialization(void)
|
||||
{
|
||||
SP = _RDWORD(0x10000000);
|
||||
PC = _RDWORD(0x10000004);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOAD %L INCREMENTAL
|
||||
Initialization();
|
||||
@@ -1,39 +1,39 @@
|
||||
[BREAKPOINTS]
|
||||
ForceImpTypeAny = 0
|
||||
ShowInfoWin = 1
|
||||
EnableFlashBP = 2
|
||||
BPDuringExecution = 0
|
||||
[CFI]
|
||||
CFISize = 0x00
|
||||
CFIAddr = 0x00
|
||||
[CPU]
|
||||
MonModeVTableAddr = 0xFFFFFFFF
|
||||
MonModeDebug = 0
|
||||
MaxNumAPs = 0
|
||||
LowPowerHandlingMode = 0
|
||||
OverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
[FLASH]
|
||||
CacheExcludeSize = 0x00
|
||||
CacheExcludeAddr = 0x00
|
||||
MinNumBytesFlashDL = 0
|
||||
SkipProgOnCRCMatch = 1
|
||||
VerifyDownload = 1
|
||||
AllowCaching = 1
|
||||
EnableFlashDL = 2
|
||||
Override = 0
|
||||
Device="ARM7"
|
||||
[GENERAL]
|
||||
WorkRAMSize = 0x00
|
||||
WorkRAMAddr = 0x00
|
||||
RAMUsageLimit = 0x00
|
||||
[SWO]
|
||||
SWOLogFile=""
|
||||
[MEM]
|
||||
RdOverrideOrMask = 0x00
|
||||
RdOverrideAndMask = 0xFFFFFFFF
|
||||
RdOverrideAddr = 0xFFFFFFFF
|
||||
WrOverrideOrMask = 0x00
|
||||
WrOverrideAndMask = 0xFFFFFFFF
|
||||
WrOverrideAddr = 0xFFFFFFFF
|
||||
[BREAKPOINTS]
|
||||
ForceImpTypeAny = 0
|
||||
ShowInfoWin = 1
|
||||
EnableFlashBP = 2
|
||||
BPDuringExecution = 0
|
||||
[CFI]
|
||||
CFISize = 0x00
|
||||
CFIAddr = 0x00
|
||||
[CPU]
|
||||
MonModeVTableAddr = 0xFFFFFFFF
|
||||
MonModeDebug = 0
|
||||
MaxNumAPs = 0
|
||||
LowPowerHandlingMode = 0
|
||||
OverrideMemMap = 0
|
||||
AllowSimulation = 1
|
||||
ScriptFile=""
|
||||
[FLASH]
|
||||
CacheExcludeSize = 0x00
|
||||
CacheExcludeAddr = 0x00
|
||||
MinNumBytesFlashDL = 0
|
||||
SkipProgOnCRCMatch = 1
|
||||
VerifyDownload = 1
|
||||
AllowCaching = 1
|
||||
EnableFlashDL = 2
|
||||
Override = 0
|
||||
Device="ARM7"
|
||||
[GENERAL]
|
||||
WorkRAMSize = 0x00
|
||||
WorkRAMAddr = 0x00
|
||||
RAMUsageLimit = 0x00
|
||||
[SWO]
|
||||
SWOLogFile=""
|
||||
[MEM]
|
||||
RdOverrideOrMask = 0x00
|
||||
RdOverrideAndMask = 0xFFFFFFFF
|
||||
RdOverrideAddr = 0xFFFFFFFF
|
||||
WrOverrideOrMask = 0x00
|
||||
WrOverrideAndMask = 0xFFFFFFFF
|
||||
WrOverrideAddr = 0xFFFFFFFF
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
LOAD 0x10000000
|
||||
{
|
||||
EXE 0x10000000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
|
||||
RW +0000
|
||||
{
|
||||
* (+RW,+ZI)
|
||||
}
|
||||
|
||||
ScatterAssert(ImageLength(RW) < 1024 * 28)
|
||||
}
|
||||
LOAD 0x10000000
|
||||
{
|
||||
EXE 0x10000000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
|
||||
RW +0000
|
||||
{
|
||||
* (+RW,+ZI)
|
||||
}
|
||||
|
||||
ScatterAssert(ImageLength(RW) < 1024 * 28)
|
||||
}
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
LOAD 0x11013000
|
||||
{
|
||||
EXE 0x11013000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
|
||||
RW 0x10004800
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
}
|
||||
ScatterAssert((0x4800+ImageLength(RW)) < 1024 * 32 )
|
||||
|
||||
; RW1 0x10016000
|
||||
; {
|
||||
|
||||
; }
|
||||
RW2 0x53005B00
|
||||
{
|
||||
*(ram_em)
|
||||
}
|
||||
}
|
||||
LOAD 0x11013000
|
||||
{
|
||||
EXE 0x11013000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
;This area is vector
|
||||
RW1 0x10000100
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
}
|
||||
ScatterAssert(ImageLength(RW1) < (0x800 - 0x100))
|
||||
RW 0x10001F00
|
||||
{
|
||||
; startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
aeabi_sdiv.o(.text)
|
||||
uread4.o(.text)
|
||||
rt_memclr.o(.text)
|
||||
|
||||
}
|
||||
ScatterAssert((0x1F00+ImageLength(RW)) < 1024 * 32 )
|
||||
RW2 (0x53004000+10*1024)
|
||||
{
|
||||
*(ram_em)
|
||||
}
|
||||
ScatterAssert((0x53004000+10*1024)+ImageLength(RW2) < (0x53004000+16*1024))
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
LOAD 0x11015000
|
||||
{
|
||||
EXE 0x11015000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
;This area is vector
|
||||
RW1 0x10000100
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
}
|
||||
ScatterAssert(ImageLength(RW1) < (0x800 - 0x100))
|
||||
RW 0x10001F00
|
||||
{
|
||||
; startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
aeabi_sdiv.o(.text)
|
||||
uread4.o(.text)
|
||||
|
||||
}
|
||||
ScatterAssert((0x1F00+ImageLength(RW)) < 1024 * 32 )
|
||||
RW2 (0x53004000+10*1024)
|
||||
{
|
||||
*(ram_em)
|
||||
}
|
||||
ScatterAssert((0x53004000+10*1024)+ImageLength(RW2) < (0x53004000+16*1024))
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
[EXTDLL]
|
||||
Count=0
|
||||
Binary file not shown.
@@ -1,129 +1,158 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>礦ision Build Log</h1>
|
||||
<h2>Tool Versions:</h2>
|
||||
IDE-Version: μVision V5.38.0.0
|
||||
Copyright (C) 2022 ARM Ltd and ARM Germany GmbH. All rights reserved.
|
||||
License Information: 1 850080437@qq.com, 1, LIC=NQQMA-13CNA-CXTU6-D7Z3Q-D9AMV-Y9G1D
|
||||
|
||||
Tool Versions:
|
||||
Toolchain: MDK-ARM Plus Version: 5.38.0.0
|
||||
Toolchain Path: D:\Program Files\Keil_v5\ARM\ARMCC\Bin
|
||||
C Compiler: Armcc.exe V5.06 update 6 (build 750)
|
||||
Assembler: Armasm.exe V5.06 update 6 (build 750)
|
||||
Linker/Locator: ArmLink.exe V5.06 update 6 (build 750)
|
||||
Library Manager: ArmAr.exe V5.06 update 6 (build 750)
|
||||
Hex Converter: FromElf.exe V5.06 update 6 (build 750)
|
||||
CPU DLL: SARMCM3.DLL V5.38.0.0
|
||||
Dialog DLL: DARMCM1.DLL V1.19.6.0
|
||||
Target DLL: UL2CM3.DLL V1.164.8.0
|
||||
Dialog DLL: TARMCM1.DLL V1.14.6.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
D:\workplace\工作文件\程序\新向远XC6517蓝牙芯片\IR_RGB\project\example\ble\ble_peripheral\mdk\ble_peripheral.uvprojx
|
||||
Project File Date: 06/07/2024
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Program Files\Keil_v5\ARM\ARMCC\Bin'
|
||||
Build target 'ble-sdk-xip'
|
||||
Note: source file '..\..\..\..\..\component\ble\plf\refip\src\driver\uart\uart.c' - object file renamed from '.\Objects\uart.o' to '.\Objects\uart_1.o'.
|
||||
compiling arch_main.c...
|
||||
..\app\src\arch_main.c(103): warning: #188-D: enumerated type mixed with another type
|
||||
xc_gpio_write_pin(4, 1);
|
||||
..\app\src\arch_main.c(104): warning: #188-D: enumerated type mixed with another type
|
||||
xc_gpio_write_pin(4, 0);
|
||||
..\app\src\arch_main.c(106): warning: #188-D: enumerated type mixed with another type
|
||||
xc_gpio_write_pin(4, 1);
|
||||
..\app\src\arch_main.c(107): warning: #188-D: enumerated type mixed with another type
|
||||
xc_gpio_write_pin(4, 0);
|
||||
..\app\src\arch_main.c(165): warning: #144-D: a value of type "int" cannot be used to initialize an entity of type "uint8_t *"
|
||||
uint8_t *ptr = 0x10001400;
|
||||
..\app\src\arch_main.c(165): warning: #152-D: conversion of nonzero integer to pointer
|
||||
uint8_t *ptr = 0x10001400;
|
||||
..\app\src\arch_main.c(168): warning: #513-D: a value of type "uint32_t *" cannot be assigned to an entity of type "uint8_t *"
|
||||
ptr = (uint32_t *)(0x10000800);
|
||||
..\app\src\arch_main.c(255): warning: #223-D: function "app_ir_init" declared implicitly
|
||||
app_ir_init();
|
||||
..\app\src\arch_main.c(256): warning: #223-D: function "app_key_init" declared implicitly
|
||||
app_key_init();
|
||||
..\app\src\arch_main.c(262): warning: #223-D: function "app_pwm_init" declared implicitly
|
||||
app_pwm_init();
|
||||
..\app\src\arch_main.c(263): warning: #223-D: function "timer0_2_init" declared implicitly
|
||||
timer0_2_init();
|
||||
..\app\src\arch_main.c(275): warning: #223-D: function "xc_ota_schedule" declared implicitly
|
||||
xc_ota_schedule();
|
||||
..\app\src\arch_main.c(286): warning: #223-D: function "ble_message_process" declared implicitly
|
||||
ble_message_process();//BLE接收信息处理
|
||||
..\app\src\arch_main.c(287): warning: #223-D: function "ir_message_process" declared implicitly
|
||||
ir_message_process();//ir遥控按键处理
|
||||
..\app\src\arch_main.c(288): warning: #223-D: function "key_message_process" declared implicitly
|
||||
key_message_process(app_key_message_get());//按键检测处理
|
||||
..\app\src\arch_main.c(288): warning: #223-D: function "app_key_message_get" declared implicitly
|
||||
key_message_process(app_key_message_get());//按键检测处理
|
||||
..\app\src\arch_main.c(289): warning: #223-D: function "app_record_process" declared implicitly
|
||||
app_record_process();//ADC_MIC检测处理
|
||||
..\app\src\arch_main.c: 17 warnings, 0 errors
|
||||
compiling rgblight.c...
|
||||
..\app\src\rgblight.c(298): warning: #186-D: pointless comparison of unsigned integer with zero
|
||||
if (mode >= MODE0)
|
||||
..\app\src\rgblight.c(341): warning: #223-D: function "app_audio_record_start" declared implicitly
|
||||
app_audio_record_start();
|
||||
..\app\src\rgblight.c(355): warning: #223-D: function "app_audio_record_stop" declared implicitly
|
||||
app_audio_record_stop();//关闭adc
|
||||
..\app\src\rgblight.c(804): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\rgblight.c: 4 warnings, 0 errors
|
||||
linking...
|
||||
Program Size: Code=26308 RO-data=1300 RW-data=4468 ZI-data=7880
|
||||
After Build - User command #1: fromelf --bin --output=app.bin .\Objects\Xinc_ble_sdk.axf
|
||||
After Build - User command #2: .\output_tool\ge_ota.bat
|
||||
Size of file: 27788 bytes.
|
||||
dual_xip
|
||||
Addr:13000
|
||||
Size:0x6c8c
|
||||
BAddr:0x40000
|
||||
Acheck:0x81d55a20
|
||||
SoftVer:0x10
|
||||
RomVer:0x20
|
||||
LoadAddr:0x11013000
|
||||
Is xip ota?:1
|
||||
ota_data.bin success总有10个命令行参数
|
||||
可 执 行文 件 名:.\output_tool\xinchip_bootloader2_tool.exe
|
||||
第一个命令行参数[bootloader program ]:.\output_tool\boot2
|
||||
第二个命令行参数[APP1 program]:.\output_tool\host
|
||||
第三个命令行参数[load_addr: sector align]:0x11002000
|
||||
第四个命令行参数[1:active,0:invalid]:1
|
||||
第五个命令行参数[APP2 program]:app.bin
|
||||
第六个命令行参数[load_addr: sector align]:0x11013000
|
||||
第七个命令行参数[1:active,0:invalid]:0
|
||||
第八个命令行参数[生成的最终bin]:.\output_bin\ble_peripheral.bin
|
||||
第九个命令行参数[是否跑两个程序]:1
|
||||
src1=.\output_tool\boot2
|
||||
src2=.\output_tool\host
|
||||
src3=app.bin
|
||||
des=.\output_bin\ble_peripheral.bin
|
||||
laod_addr1=0x11002000
|
||||
laod_addr2=0x11013000
|
||||
status1=1
|
||||
status2=0
|
||||
需要填充0个sector
|
||||
updata file success !
|
||||
已复制 1 个文件。
|
||||
".\Objects\Xinc_ble_sdk.axf" - 0 Error(s), 21 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
|
||||
Package Vendor: ARM
|
||||
http://www.keil.com/pack/ARM.CMSIS.5.9.0.pack
|
||||
ARM.CMSIS.5.9.0
|
||||
CMSIS (Common Microcontroller Software Interface Standard)
|
||||
|
||||
<h2>Collection of Component include folders:</h2>
|
||||
D:/Program Files/Keil_v5/ARM/Packs/ARM/CMSIS/5.9.0/Device/ARM/ARMCM0/Include
|
||||
|
||||
<h2>Collection of Component Files used:</h2>
|
||||
Build Time Elapsed: 00:00:05
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>礦ision Build Log</h1>
|
||||
<h2>Tool Versions:</h2>
|
||||
IDE-Version: μVision V5.38.0.0
|
||||
Copyright (C) 2022 ARM Ltd and ARM Germany GmbH. All rights reserved.
|
||||
License Information: 1 850080437@qq.com, 1, LIC=NQQMA-13CNA-CXTU6-D7Z3Q-D9AMV-Y9G1D
|
||||
|
||||
Tool Versions:
|
||||
Toolchain: MDK-ARM Plus Version: 5.38.0.0
|
||||
Toolchain Path: D:\Program Files\Keil_v5\ARM\ARMCC\Bin
|
||||
C Compiler: Armcc.exe V5.06 update 6 (build 750)
|
||||
Assembler: Armasm.exe V5.06 update 6 (build 750)
|
||||
Linker/Locator: ArmLink.exe V5.06 update 6 (build 750)
|
||||
Library Manager: ArmAr.exe V5.06 update 6 (build 750)
|
||||
Hex Converter: FromElf.exe V5.06 update 6 (build 750)
|
||||
CPU DLL: SARMCM3.DLL V5.38.0.0
|
||||
Dialog DLL: DARMCM1.DLL V1.19.6.0
|
||||
Target DLL: UL2CM3.DLL V1.164.8.0
|
||||
Dialog DLL: TARMCM1.DLL V1.14.6.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
D:\workplace\工作文件\程序\新向远XC6517蓝牙芯片\Stair66E_urat\project\example\ble\ble_peripheral\mdk\ble_peripheral.uvprojx
|
||||
Project File Date: 07/28/2026
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Program Files\Keil_v5\ARM\ARMCC\Bin'
|
||||
Rebuild target 'ble-sdk-xip_single'
|
||||
Note: source file '..\..\..\..\..\component\ble\plf\refip\src\driver\uart\uart.c' - object file renamed from '.\Objects\uart.o' to '.\Objects\uart_1.o'.
|
||||
assembling startup_xinc.s...
|
||||
compiling ota_flash_interface.c...
|
||||
..\app\src\ota_flash_interface.c(139): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\ota_flash_interface.c: 1 warning, 0 errors
|
||||
compiling ota_server.c...
|
||||
compiling uart_state.c...
|
||||
compiling ota_protocol.c...
|
||||
..\app\src\ota_protocol.c(546): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\ota_protocol.c: 1 warning, 0 errors
|
||||
compiling mcu_bridge.c...
|
||||
compiling ringbuffer.c...
|
||||
compiling system_xinc.c...
|
||||
compiling uart.c...
|
||||
..\app\src\uart.c(209): warning: #1-D: last line of file ends without a newline
|
||||
}
|
||||
..\app\src\uart.c: 1 warning, 0 errors
|
||||
compiling sleep.c...
|
||||
compiling aes.c...
|
||||
compiling xc_drv_clock.c...
|
||||
compiling app_batt.c...
|
||||
compiling usr_server.c...
|
||||
compiling app_sec.c...
|
||||
compiling arch_main.c...
|
||||
compiling fast_ota_server.c...
|
||||
..\app\src\fast_ota_server.c(245): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\fast_ota_server.c: 1 warning, 0 errors
|
||||
compiling xc_drv_gpio.c...
|
||||
compiling fast_ota.c...
|
||||
..\app\src\fast_ota.c(380): warning: #1-D: last line of file ends without a newline
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
..\app\src\fast_ota.c: 1 warning, 0 errors
|
||||
compiling app_task.c...
|
||||
compiling xc_drv_pwr.c...
|
||||
compiling xc_drv_timer.c...
|
||||
compiling xc_drv_systick.c...
|
||||
compiling xc_drv_wdt.c...
|
||||
compiling xc_drv_uart.c...
|
||||
compiling xc_drv_calib.c...
|
||||
compiling rf_extrc.c...
|
||||
compiling xc_drv_fmc_spi.c...
|
||||
compiling xc_drv_adc.c...
|
||||
compiling xc_drv_aotimer.c...
|
||||
compiling xc_drv_fmc_spi_dma.c...
|
||||
compiling xc_drv_rtc.c...
|
||||
compiling xc_drv_dma.c...
|
||||
compiling xc_drv_i2c.c...
|
||||
compiling xc_drv_pga.c...
|
||||
compiling xc_drv_qdec.c...
|
||||
compiling xc_drv_pwm.c...
|
||||
compiling xc_drv_spi.c...
|
||||
compiling xc_drv_sw_i2c.c...
|
||||
compiling xc_drv_spi_dma.c...
|
||||
compiling xc_drv_uart_dma.c...
|
||||
compiling xc_gatt_client_api.c...
|
||||
compiling nvds.c...
|
||||
compiling xc_gatt_server_api.c...
|
||||
compiling xc_gap_api.c...
|
||||
compiling uart.c...
|
||||
linking...
|
||||
.\Linker\cpu_xip_single_ota.scat(21): warning: L6314W: No section matches pattern uread4.o(.text).
|
||||
Program Size: Code=25424 RO-data=1576 RW-data=2464 ZI-data=2180
|
||||
Finished: 0 information, 1 warning and 0 error messages.
|
||||
After Build - User command #1: fromelf --bin --output=app.bin .\Objects\Xinc_ble_sdk.axf
|
||||
After Build - User command #2: .\output_tool\Single_ota\ge_ota_single.bat
|
||||
Size of file: 27188 bytes.
|
||||
all_size=27188
|
||||
size:27188 PageCNT107
|
||||
dual_xip
|
||||
Addr:15000
|
||||
Size:0x6a34
|
||||
BAddr:0x15000
|
||||
Acheck:0x30c371a0
|
||||
SoftVer:0x10
|
||||
RomVer:0x20
|
||||
LoadAddr:0x11015000
|
||||
Is xip ota?:1
|
||||
ota_data.bin success总有13个命令行参数
|
||||
可 执 行文 件 名:.\output_tool\Single_ota\xinchip_bootloader2_tool_single.exe
|
||||
第一个命令行参数[bootloader program ]:.\output_tool\Single_ota\boot2_single_ota
|
||||
第二个命令行参数[APP1 program]:.\output_tool\host
|
||||
第三个命令行参数[load_addr: sector align]:0x11002000
|
||||
第四个命令行参数[1:active,0:invalid]:0
|
||||
第五个命令行参数[APP2 program]:.\ota_app.bin
|
||||
第六个命令行参数[load_addr: sector align]:0x11011000
|
||||
第七个命令行参数[1:active,0:invalid]:0
|
||||
第五个命令行参数[APP2 program]:.\app.bin
|
||||
第六个命令行参数[load_addr: sector align]:0x11015000
|
||||
第七个命令行参数[1:active,0:invalid]:1
|
||||
第八个命令行参数[生成的最终bin]:.\output_bin\ble_peripheral_single.bin
|
||||
第九个命令行参数[是否跑两个程序]:1
|
||||
src1=.\output_tool\Single_ota\boot2_single_ota
|
||||
src2=.\output_tool\host
|
||||
src3=.\ota_app.bin
|
||||
src4=.\app.bin
|
||||
des=.\output_bin\ble_peripheral_single.bin
|
||||
laod_addr1=0x11002000
|
||||
laod_addr2=0x11011000
|
||||
laod_addr3=0x11015000
|
||||
status1=0
|
||||
status2=0
|
||||
status3=1
|
||||
需要填充11个sector
|
||||
需要填充15个sector
|
||||
all_size:114688
|
||||
all_size:114688
|
||||
crc:a748f0e0 len:57284
|
||||
updata file success !
|
||||
已复制 1 个文件。
|
||||
".\Objects\Xinc_ble_sdk.axf" - 0 Error(s), 6 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
|
||||
Package Vendor: ARM
|
||||
http://www.keil.com/pack/ARM.CMSIS.5.9.0.pack
|
||||
ARM.CMSIS.5.9.0
|
||||
CMSIS (Common Microcontroller Software Interface Standard)
|
||||
|
||||
<h2>Collection of Component include folders:</h2>
|
||||
D:/Program Files/Keil_v5/ARM/Packs/ARM/CMSIS/5.9.0/Device/ARM/ARMCM0/Include
|
||||
|
||||
<h2>Collection of Component Files used:</h2>
|
||||
Build Time Elapsed: 00:00:27
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,44 +1,52 @@
|
||||
--cpu Cortex-M0
|
||||
".\objects\startup_xinc.o"
|
||||
".\objects\system_xinc.o"
|
||||
".\objects\app_batt.o"
|
||||
".\objects\app_task.o"
|
||||
".\objects\arch_main.o"
|
||||
".\objects\app_sec.o"
|
||||
"..\app\src\rom_symdefs.o"
|
||||
".\objects\sleep.o"
|
||||
".\objects\ota_server.o"
|
||||
".\objects\ota_flash_interface.o"
|
||||
".\objects\ota_protocol.o"
|
||||
".\objects\usr_server.o"
|
||||
".\objects\uart.o"
|
||||
".\objects\timer.o"
|
||||
".\objects\pwm.o"
|
||||
".\objects\rgblight.o"
|
||||
".\objects\nec_infrared.o"
|
||||
".\objects\pga_adc.o"
|
||||
".\objects\key.o"
|
||||
".\objects\message.o"
|
||||
".\objects\rf_extrc.o"
|
||||
".\objects\ringbuffer.o"
|
||||
".\objects\xc_drv_clock.o"
|
||||
".\objects\xc_drv_gpio.o"
|
||||
".\objects\xc_drv_pwr.o"
|
||||
".\objects\xc_drv_timer.o"
|
||||
".\objects\xc_drv_uart.o"
|
||||
".\objects\xc_drv_wdt.o"
|
||||
".\objects\xc_drv_systick.o"
|
||||
".\objects\xc_drv_fmc_spi.o"
|
||||
".\objects\xc_drv_calib.o"
|
||||
".\objects\xc_drv_pwm.o"
|
||||
".\objects\xc_drv_pga.o"
|
||||
".\objects\xc_drv_adc.o"
|
||||
".\objects\xc_gap_api.o"
|
||||
".\objects\xc_gatt_client_api.o"
|
||||
".\objects\xc_gatt_server_api.o"
|
||||
".\objects\nvds.o"
|
||||
".\objects\uart_1.o"
|
||||
--strict --scatter ".\Linker\cpu_xip.scat"
|
||||
--summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
|
||||
--info sizes --info totals --info unused --info veneers
|
||||
--cpu Cortex-M0
|
||||
".\objects\startup_xinc.o"
|
||||
".\objects\system_xinc.o"
|
||||
".\objects\app_batt.o"
|
||||
".\objects\app_task.o"
|
||||
".\objects\arch_main.o"
|
||||
".\objects\app_sec.o"
|
||||
"..\app\src\rom_symdefs.o"
|
||||
".\objects\sleep.o"
|
||||
".\objects\ota_server.o"
|
||||
".\objects\ota_flash_interface.o"
|
||||
".\objects\ota_protocol.o"
|
||||
".\objects\usr_server.o"
|
||||
".\objects\uart.o"
|
||||
".\objects\uart_state.o"
|
||||
".\objects\mcu_bridge.o"
|
||||
".\objects\aes.o"
|
||||
".\objects\fast_ota.o"
|
||||
".\objects\fast_ota_server.o"
|
||||
".\objects\rf_extrc.o"
|
||||
".\objects\ringbuffer.o"
|
||||
".\objects\xc_drv_clock.o"
|
||||
".\objects\xc_drv_gpio.o"
|
||||
".\objects\xc_drv_pwr.o"
|
||||
".\objects\xc_drv_timer.o"
|
||||
".\objects\xc_drv_uart.o"
|
||||
".\objects\xc_drv_wdt.o"
|
||||
".\objects\xc_drv_systick.o"
|
||||
".\objects\xc_drv_fmc_spi.o"
|
||||
".\objects\xc_drv_calib.o"
|
||||
".\objects\xc_drv_rtc.o"
|
||||
".\objects\xc_drv_adc.o"
|
||||
".\objects\xc_drv_aotimer.o"
|
||||
".\objects\xc_drv_dma.o"
|
||||
".\objects\xc_drv_fmc_spi_dma.o"
|
||||
".\objects\xc_drv_i2c.o"
|
||||
".\objects\xc_drv_pga.o"
|
||||
".\objects\xc_drv_pwm.o"
|
||||
".\objects\xc_drv_qdec.o"
|
||||
".\objects\xc_drv_spi.o"
|
||||
".\objects\xc_drv_spi_dma.o"
|
||||
".\objects\xc_drv_sw_i2c.o"
|
||||
".\objects\xc_drv_uart_dma.o"
|
||||
".\objects\xc_gap_api.o"
|
||||
".\objects\xc_gatt_client_api.o"
|
||||
".\objects\xc_gatt_server_api.o"
|
||||
".\objects\nvds.o"
|
||||
".\objects\uart_1.o"
|
||||
--strict --scatter ".\Linker\cpu_xip_single_ota.scat"
|
||||
--feedback fb.txt --summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
|
||||
--info sizes --info totals --info unused --info veneers
|
||||
--list ".\Listings\Xinc_ble_sdk.map" -o .\Objects\Xinc_ble_sdk.axf
|
||||
Binary file not shown.
@@ -0,0 +1,74 @@
|
||||
.\objects\aes.o: ..\app\src\aes.c
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\aes\api\aes.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\rwip\api\rwip_config.h
|
||||
.\objects\aes.o: D:\Program Files\Keil_v5\ARM\ARMCC\Bin\..\include\string.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\ip\ble\ll\api\rwble_config.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\rwip\api\rwip_config.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\ip\ble\hl\inc\rwble_hl_config.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\rwble_hl_error.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\ip\ble\hl\inc\rwprf_config.h
|
||||
.\objects\aes.o: ..\app\api\rwapp_config.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\common\api\co_bt.h
|
||||
.\objects\aes.o: D:\Program Files\Keil_v5\ARM\ARMCC\Bin\..\include\stdbool.h
|
||||
.\objects\aes.o: D:\Program Files\Keil_v5\ARM\ARMCC\Bin\..\include\stddef.h
|
||||
.\objects\aes.o: D:\Program Files\Keil_v5\ARM\ARMCC\Bin\..\include\stdint.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\common\api\co_bt_defines.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\common\api\co_lmp.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\common\api\co_bt.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\common\api\co_hci.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc6xxx.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc65xx.h
|
||||
.\objects\aes.o: D:\Program Files\Keil_v5\ARM\ARMCC\Bin\..\include\stdio.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cm0.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cmInstr.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cmFunc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\xc_drv_config.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_conf.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_cpr.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_offset.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc6xxx.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_cprao.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_rf.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_adc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_aotimer.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_dma.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_fmc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_fmc_cache.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_gpio.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_i2c.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_qdec.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_i2s.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_pwm.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_pwm_comn.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_rtc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_spi.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_timer.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_uart.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_wdt.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_pwm_timer.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_cdc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_calib.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_clock.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_systick.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_pwr.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_gpio.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_aotimer.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_timer.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_rtc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_uart.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\ringbuffer.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_dma.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_flash.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi_dma.h
|
||||
.\objects\aes.o: D:\Program Files\Keil_v5\ARM\ARMCC\Bin\..\include\stdlib.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi_dma.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_uart_dma.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_i2c.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_sw_i2c.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_wdt.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_adc.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_pwm.h
|
||||
.\objects\aes.o: ..\..\..\..\..\component\ble\modules\common\api\co_error.h
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user