hpw422初始版本
This commit is contained in:
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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 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))
|
||||
/// 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)
|
||||
|
||||
};
|
||||
|
||||
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,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_ */
|
||||
Binary file not shown.
@@ -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,458 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_sec.c
|
||||
*
|
||||
* @brief Application Security Entry Point
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup APP
|
||||
* @{
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDE FILES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "co_math.h"
|
||||
#include "co_utils.h"
|
||||
#include "rwip_config.h"
|
||||
#include <string.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)
|
||||
/*
|
||||
* GLOBAL VARIABLE DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/// Application Security Environment Structure
|
||||
struct app_sec_env_tag app_sec_env;
|
||||
uint8_t g_irk[GAP_KEY_LEN] = {0};
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
#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)
|
||||
|
||||
static int gapc_bond_req_ind_handler(ke_msg_id_t const msgid,
|
||||
struct gapc_bond_req_ind const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
LOGI(" [debug] gapc_bond_req_ind_handler,request:0x%x \r\n",
|
||||
param->request);
|
||||
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;
|
||||
cfm->data.pairing_feat.auth =
|
||||
GAP_AUTH_REQ_NO_MITM_BOND; // GAP_AUTH_REQ_MITM_BOND;//GAP_AUTH_REQ_MITM_BOND;
|
||||
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;
|
||||
app_env.sec_con_enabled = false;
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
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");
|
||||
#if (NVDS_SUPPORT)
|
||||
uint8_t err = nvds_del(NVDS_TAG_LTK);
|
||||
LOGI("nvds_del err = %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);
|
||||
}
|
||||
#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,
|
||||
struct gapc_bond_ind const *param,
|
||||
ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
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;
|
||||
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 (NVDS_SUPPORT)
|
||||
uint8_t err = nvds_del(NVDS_TAG_PERIPH_BONDED);
|
||||
LOGI("nvds_del err =%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);
|
||||
}
|
||||
// Set the BD Address of the peer device in NVDS
|
||||
uint8_t err2 = nvds_del(NVDS_TAG_PEER_BD_ADDRESS);
|
||||
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
struct gap_bdaddr *peer =
|
||||
gapc_get_bdaddr(app_env->master_conidx, GAPC_SMP_INFO_PEER);
|
||||
LOGI(" addr_type:%d addr:%x %x %x %x %x %x\r\n", peer->addr_type,
|
||||
peer->addr[0], peer->addr[1], peer->addr[2], peer->addr[3],
|
||||
peer->addr[4], peer->addr[5]);
|
||||
LOGI("nvds_del err =%d \n", err2);
|
||||
if (nvds_put(NVDS_TAG_PEER_BD_ADDRESS, NVDS_LEN_PEER_BD_ADDRESS,
|
||||
(uint8_t *)gapc_get_bdaddr(app_env->master_conidx,
|
||||
GAPC_SMP_INFO_PEER)) !=
|
||||
NVDS_OK) {
|
||||
// An error has occurred during access to the NVDS
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#endif //(NVDS_SUPPORT)
|
||||
|
||||
} break;
|
||||
|
||||
case (GAPC_REPEATED_ATTEMPT): {
|
||||
struct app_env_tag *app_env = get_app_env();
|
||||
xc_ble_disconnect(app_env->master_conidx,
|
||||
CO_ERROR_CON_TERM_BY_LOCAL_HOST);
|
||||
} break;
|
||||
|
||||
case (GAPC_IRK_EXCH): {
|
||||
LOGI("irk exch :addr_type:%d addr :%x %x %x %x %x %x \r\n",
|
||||
param->data.irk.addr.addr_type, param->data.irk.addr.addr[0],
|
||||
param->data.irk.addr.addr[1], param->data.irk.addr.addr[2],
|
||||
param->data.irk.addr.addr[3], param->data.irk.addr.addr[4],
|
||||
param->data.irk.addr.addr[5]);
|
||||
memcpy(&g_irk[0], ¶m->data.irk.irk.key[0], GAP_KEY_LEN);
|
||||
for (uint8_t k = 0; k < GAP_KEY_LEN; k++) {
|
||||
LOGI(" %x ", param->data.irk.irk.key[k]);
|
||||
}
|
||||
|
||||
#if (NVDS_SUPPORT)
|
||||
// Store peer identity in NVDS
|
||||
uint8_t err = nvds_del(NVDS_TAG_PEER_IRK);
|
||||
LOGI("nvds_del =%d \r\n", err);
|
||||
if (nvds_put(NVDS_TAG_PEER_IRK, NVDS_LEN_PEER_IRK,
|
||||
(uint8_t *)¶m->data.irk) != NVDS_OK) {
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#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): {
|
||||
|
||||
if (app_env.sec_con_enabled == true) {
|
||||
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 (NVDS_SUPPORT)
|
||||
uint8_t err = nvds_del(NVDS_TAG_LTK);
|
||||
LOGI("nvds_del err = %d \n", err);
|
||||
// Store the generated value in NVDS
|
||||
if (nvds_put(NVDS_TAG_LTK, NVDS_LEN_LTK,
|
||||
(uint8_t *)¶m->data.ltk) != NVDS_OK) {
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#endif // #if (NVDS_SUPPORT)
|
||||
}
|
||||
} break;
|
||||
|
||||
default: {
|
||||
ASSERT_ERR(0);
|
||||
} break;
|
||||
}
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
static int gapc_encrypt_req_ind_handler(
|
||||
ke_msg_id_t const msgid, struct gapc_encrypt_req_ind const *param,
|
||||
ke_task_id_t const dest_id, ke_task_id_t const src_id)
|
||||
{
|
||||
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));
|
||||
} else {
|
||||
LOGI("EDIV and randnb not same!!!\r\n");
|
||||
}
|
||||
/*
|
||||
* else we are bonded with another device, disconnect the link
|
||||
*/
|
||||
} else {
|
||||
ASSERT_ERR(0);
|
||||
}
|
||||
#endif // #if (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);
|
||||
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)};
|
||||
|
||||
/// @} 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,831 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
__RAM_EM struct conn_dev_info conn_dev[CONNECT_DEV_NUM] = {0};
|
||||
uint8_t 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 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();
|
||||
}
|
||||
|
||||
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;
|
||||
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 (app_env.init_state == APP_INIT_STATE_CREATING ||
|
||||
app_env.init_state == APP_INIT_STATE_STOPPED)
|
||||
|
||||
{
|
||||
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;
|
||||
param->type = GAPM_INIT_TYPE_DIRECT_CONN_EST;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @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);
|
||||
// ((*(volatile uint32_t *)(0x53000050)) = (1<<15) | (0x7<<8) | (1
|
||||
// << 7) | (0x3 << 0));
|
||||
xc_ble_set_dev_config(&cfg_param);
|
||||
if (CFG_CON > 1) {
|
||||
extern uint8_t rwip_prog_delay;
|
||||
rwip_prog_delay = 6;
|
||||
}
|
||||
} break;
|
||||
case GAPM_SET_DEV_CONFIG: {
|
||||
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 cfm = {0};
|
||||
switch (param->req) {
|
||||
case GAPC_DEV_NAME: {
|
||||
cfm.req = param->req;
|
||||
cfm.token = param->token;
|
||||
cfm.status = GAP_ERR_NO_ERROR;
|
||||
cfm.info.name.value_length = app_get_dev_name(cfm.info.name.value);
|
||||
xc_ble_get_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
|
||||
case GAPC_DEV_APPEARANCE: {
|
||||
cfm.req = param->req;
|
||||
cfm.info.appearance = DEV_APPEARANCE;
|
||||
cfm.token = param->token;
|
||||
cfm.status = GAP_ERR_NO_ERROR;
|
||||
xc_ble_get_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
|
||||
case GAPC_DEV_SLV_PREF_PARAMS: {
|
||||
cfm.req = param->req;
|
||||
cfm.info.slv_pref_params.con_intv_min = BLE_UAPDATA_MIN_INTVALUE;
|
||||
// Slave preferred Connection interval Max
|
||||
cfm.info.slv_pref_params.con_intv_max = BLE_UAPDATA_MAX_INTVALUE;
|
||||
// Slave preferred Connection latency
|
||||
cfm.info.slv_pref_params.slave_latency = BLE_UAPDATA_LATENCY;
|
||||
// Slave preferred Link supervision timeout
|
||||
cfm.info.slv_pref_params.conn_timeout = BLE_UAPDATA_TIMEOUT;
|
||||
cfm.token = param->token;
|
||||
cfm.status = GAP_ERR_NO_ERROR;
|
||||
xc_ble_get_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
} 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 (memcmp(p_param->trans_addr.addr, TAGET_DEVICE_ADDR,
|
||||
GAP_BD_ADDR_LEN) == 0) {
|
||||
// app_stop_scanning();
|
||||
app_start_init(p_param->trans_addr.addr_type,
|
||||
p_param->trans_addr.addr);
|
||||
}
|
||||
} 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++) {
|
||||
printf(" %02x ", p_param->peer_addr.addr[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
connect_dev_num++;
|
||||
LOGI("--------- connect num :%d --------\r\n", connect_dev_num);
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
connect_dev_num--;
|
||||
LOGI("--------- connect num :%d --------\r\n", connect_dev_num);
|
||||
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;
|
||||
}
|
||||
if (conidx == app_env.master_conidx) {
|
||||
app_env.master_conidx = INVALID_DATA;
|
||||
app_env.master_connected = false;
|
||||
app_start_scan();
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
/* Default State handlers definition. */
|
||||
KE_MSG_HANDLER_TAB(app){
|
||||
{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,279 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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"
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @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);
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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 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()
|
||||
{
|
||||
|
||||
uint8_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__);
|
||||
// while(1);
|
||||
#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((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();
|
||||
}
|
||||
|
||||
extern volatile uint8_t sv_lock;
|
||||
extern volatile uint8_t sv_txlen;
|
||||
#if (!CONN_EVENT_NOT_RUN_XIP)
|
||||
__RAM_CODE void PendSV_Handler(void)
|
||||
{
|
||||
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))));
|
||||
}
|
||||
#else // (!CONN_EVENT_NOT_RUN_XIP)
|
||||
__RAM_CODE void PendSV_Handler(void)
|
||||
{
|
||||
while (!sv_lock)
|
||||
;
|
||||
}
|
||||
#endif // (!CONN_EVENT_NOT_RUN_XIP)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
bluetooth_init();
|
||||
set_channel_scan(37);
|
||||
#if (BLE_APP_PRESENT)
|
||||
while (1) {
|
||||
// schedule all pending events
|
||||
rwip_schedule();
|
||||
// xc_ota_schedule();
|
||||
#if (SLEEP_ENABLE)
|
||||
sleep_schedule();
|
||||
#endif // (SLEEP_ENABLE)
|
||||
}
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
}
|
||||
|
||||
/// @} DRIVERS
|
||||
@@ -0,0 +1,259 @@
|
||||
#<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
|
||||
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
|
||||
0x0000c811 T lld_scan_evt_start_cbk
|
||||
0x00007799 T lld_adv_evt_canceled_cbk
|
||||
0x000075fd T lld_adv_adv_data_set
|
||||
0x000076b1 T lld_adv_duration_update
|
||||
0x000080d9 T lld_adv_scan_rsp_data_set
|
||||
0x0000f709 T sch_slice_fg_add
|
||||
0x10000858 D sch_slice_params
|
||||
0x00007709 T lld_adv_end
|
||||
0x00007c69 T lld_adv_pkt_rx
|
||||
@@ -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_cb.lfclk_src = CLOCK_LFCLK_SRC_RC;
|
||||
#endif //(RC_32K)
|
||||
|
||||
#if (XTAL_32K)
|
||||
clock_cb.lfclk_src = CLOCK_LFCLK_SRC_XTAL;
|
||||
#endif // (XTAL_32K)
|
||||
|
||||
#if (XTAL_32768K)
|
||||
clock_cb.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,244 @@
|
||||
|
||||
;/*****************************************************************************
|
||||
; * @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
|
||||
@@ -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 *)(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);
|
||||
}
|
||||
|
||||
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,181 @@
|
||||
#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 0xFFF0
|
||||
#define CUSTOM_SVC_RX_CHAR_UUID 0xFFF3
|
||||
#define CUSTOM_SVC_TX_CHAR_UUID 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_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);
|
||||
//(&(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);
|
||||
}
|
||||
}
|
||||
|
||||
int usr_cli_feat_enable(uint8_t conidx)
|
||||
{
|
||||
uint16_t svc_uuid = CUSTOM_SVC_UUID;
|
||||
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);
|
||||
int 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,39 @@
|
||||
LOAD 0x11013000
|
||||
{
|
||||
EXE 0x11013000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
RW2 (0x53004000+(5*1024));EM_BLE_END=0x129c < 5*1024
|
||||
{
|
||||
*(ke_heap1)
|
||||
}
|
||||
ScatterAssert((0x53004000+(5*1024))+ImageLength(RW2) < 0x53008000)
|
||||
RW 0x10001400
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
}
|
||||
|
||||
|
||||
|
||||
;RW1 0x1000100 ; 0x100~ 800 total 700h
|
||||
;{
|
||||
;
|
||||
;}
|
||||
|
||||
; RW3 (0x530077b0)
|
||||
; {
|
||||
; *(ram_em)
|
||||
; }
|
||||
; ScatterAssert((0x530077b0)+ImageLength(RW2) < 0x53008000)
|
||||
; RW2 (0x53004000+(8*1024)) ;EM_BLE_END=0x129c < 0x1800
|
||||
; {
|
||||
; *(ram_em)
|
||||
; }
|
||||
; ScatterAssert(((0x53004000+(8*1024))+ImageLength(RW2)) < (0x53004000+0x4000) )
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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</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,597 @@
|
||||
<?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>5060750::V5.06 update 6 (build 750)::.\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</MiscControls>
|
||||
<Define>SDK_VERSION="2b8e78c6" RC_32K=1 XC60XX CFG_BLE CFG_EMB CFG_STATIC USE_XIP=0 HCI_TEST_NO_IP=0 CFG_ACT=20 CFG_CON=2 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 APP_SEC_CON=1 ROM_ENV_ENABLE=0 CODE_USE_XIP CFG_PRF_BASS USE_ROM_FLASH=1 CFG_SCAN_PERFORMANCE</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\xc60xx;..\..\..\..\..\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></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>
|
||||
<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>
|
||||
<LayDesc></LayDesc>
|
||||
<LayUrl></LayUrl>
|
||||
<LayKeys></LayKeys>
|
||||
<LayCat></LayCat>
|
||||
<LayLic></LayLic>
|
||||
<LayTarg>0</LayTarg>
|
||||
<LayPrjMark>1</LayPrjMark>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</LayerInfo>
|
||||
|
||||
</Project>
|
||||
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 0x11013000 1 ^
|
||||
ble_Central.bin 1
|
||||
del ..\app.bin
|
||||
copy .\ble_Central.bin ..\
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,337 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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 ("abc66888")
|
||||
#define APP_DFLT_DEVICE_NAME_LEN (sizeof(APP_DFLT_DEVICE_NAME))
|
||||
#define APP_DFLT_DEVICE_NAME_LEN1 (sizeof(APP_DFLT_DEVICE_NAME1))
|
||||
#define APP_DFLT_DEVICE_NAME2 ("Second_test")
|
||||
#define APP_DFLT_DEVICE_NAME_LEN2 (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\x32\x60\x47\x99"
|
||||
#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 second_adv_actv_idx;
|
||||
uint8_t slave_conidx;
|
||||
bool slave_connected;
|
||||
uint8_t scan_actv_idx;
|
||||
};
|
||||
|
||||
#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
|
||||
};
|
||||
/// States of APP task
|
||||
enum app_mode
|
||||
{
|
||||
/// Initialization state
|
||||
APP_CONN_MODE,
|
||||
/// Database create state
|
||||
APP_SCAN_SLEEP_MODE,
|
||||
/// Number of defined modes.
|
||||
APP_MODE_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)
|
||||
APP_SCAN_START,
|
||||
APP_SCAN_STOP,
|
||||
APP_TEST_MODE,
|
||||
APP_SECOND_ADV_START,
|
||||
RF_RESET_TIMER_MSG,
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#endif // APP_TASK_H_
|
||||
@@ -0,0 +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_ */
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "pwm.h"
|
||||
#include "xc_drv_pwm.h"
|
||||
#include "rgblight.h"
|
||||
#include "mode.h"
|
||||
#include "timer.h"
|
||||
#include "math.h"
|
||||
#include "timeslice.h"
|
||||
#include "RF433.h"
|
||||
#include "usr_server.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void chx_gpio_init(void)
|
||||
{
|
||||
GPIO_InitCfg_t GPIO_InitCfg = { 0 }; // 清零初始化配置结构体
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0; // 选择功能复用器0
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx; // 选择GPIO功能(非特殊功能)
|
||||
GPIO_InitCfg.Pull = GPIO_NOPULL; //下拉电阻使能
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
|
||||
GPIO_InitCfg.Pin = RELAY_CH1_PIN; // 设置通道5引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
|
||||
GPIO_InitCfg.Pin = RELAY_CH2_PIN; // 设置通道2引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
}
|
||||
|
||||
|
||||
void led_gpio_init(void)
|
||||
{
|
||||
|
||||
PWM_InitCfg_t pwm_cfg;
|
||||
pwm_cfg.DutyCycleAcc = 5000;
|
||||
pwm_cfg.Period = 15; //ARR? 7 -8 2-10k 5 30 ->1k
|
||||
pwm_cfg.SrcClk = PWM_CLK_SRC_32M_DIV;
|
||||
pwm_cfg.SrcEnable = PWM_EN_SEL_ALL;
|
||||
pwm_cfg.DutyCycle = 0;
|
||||
pwm_cfg.OutputPin = GPIO_13; // The pin cannot be changed
|
||||
xc_pwm_init(PWM3_IDX, &pwm_cfg);
|
||||
//xc_pwm_start(PWM3_IDX);
|
||||
xc_pwm_start_all();
|
||||
//xc_pwm_start(PWM2_IDX);
|
||||
|
||||
|
||||
|
||||
// //占空比 = DutyCycle / DutyCycleAcc
|
||||
// PWM_InitCfg_t pwm_cfg;
|
||||
// pwm_cfg.DutyCycleAcc = 255;
|
||||
// pwm_cfg.DutyCycle = 125;
|
||||
// pwm_cfg.Period = 15;
|
||||
// pwm_cfg.InvertDelay = 0;
|
||||
// pwm_cfg.InvertEnable = false;
|
||||
// pwm_cfg.OutputInvertPin = 0;
|
||||
// pwm_cfg.OutputPin = GPIO_13;
|
||||
// pwm_cfg.SrcClk = PWM_CLK_SRC_32M_DIV;
|
||||
// pwm_cfg.SrcEnable = PWM_EN_SEL_ALL;
|
||||
// xc_pwm_init( PWM3_IDX,&pwm_cfg);
|
||||
// // xc_pwm_start(PWM3_IDX);
|
||||
|
||||
|
||||
|
||||
|
||||
// GPIO_InitCfg_t GPIO_InitCfg = { 0 }; // 清零初始化配置结构体
|
||||
// GPIO_InitCfg.Mux = GPIO_Mux0; // 选择功能复用器0
|
||||
// GPIO_InitCfg.FunSel = GPIO_Dx; // 选择GPIO功能(非特殊功能)
|
||||
// GPIO_InitCfg.Pull = GPIO_NOPULL;
|
||||
//
|
||||
// GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
|
||||
// GPIO_InitCfg.Int = NOT_INT; // 不使能中断
|
||||
// GPIO_InitCfg.Pin = GPIO_1; // 设置led引脚
|
||||
// xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
//
|
||||
// xc_gpio_write_pin(GPIO_1, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef __Mode_H__
|
||||
#define __Mode_H__
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
void chx_gpio_init(void);
|
||||
void led_gpio_init(void);
|
||||
|
||||
#endif /* __Mode_H__ */
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "pwm.h"
|
||||
#include "xc_drv_pwm.h"
|
||||
#include "rgblight.h"
|
||||
#include "mode.h"
|
||||
#include "math.h"
|
||||
#include <stdint.h>
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
|
||||
// 定义一个变量来保存当前的 PWM 输出管脚设置
|
||||
uint8_t pwm_red_idx = PWM2_IDX;
|
||||
uint8_t pwm_green_idx = PWM3_IDX;
|
||||
uint8_t pwm_blue_idx = PWM5_IDX;
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
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;
|
||||
|
||||
uint8_t Brightness=100; //100级
|
||||
PWM_Channel_t PWM_WarmLight_t={100,127,0,1}; // 暖光PWM
|
||||
PWM_Channel_t PWM_CoolLight_t={100,127,0,1}; // 冷光PWM
|
||||
|
||||
|
||||
// 切换 PWM 输出管脚,蓝牙调用此方法,切换设备输出线序
|
||||
void switch_pwm_pins(uint8_t red_pwm, uint8_t green_pwm, uint8_t blue_pwm)
|
||||
{
|
||||
pwm_red_idx = red_pwm;
|
||||
pwm_green_idx = green_pwm;
|
||||
pwm_blue_idx = blue_pwm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float brightness_table[101] = {
|
||||
0.006f, 0.006f, 0.006f, 0.006f, 0.006f,
|
||||
0.006f, 0.006f, 0.006f, 0.007f, 0.008f,
|
||||
0.009f, 0.010f, 0.011f, 0.013f, 0.015f,
|
||||
0.018f, 0.020f, 0.023f, 0.026f, 0.029f,
|
||||
0.032f, 0.036f, 0.039f, 0.043f, 0.047f,
|
||||
0.052f, 0.056f, 0.061f, 0.066f, 0.071f,
|
||||
0.076f, 0.082f, 0.087f, 0.093f, 0.099f,
|
||||
0.106f, 0.112f, 0.119f, 0.126f, 0.133f,
|
||||
0.141f, 0.148f, 0.156f, 0.164f, 0.173f,
|
||||
0.181f, 0.190f, 0.199f, 0.208f, 0.218f,
|
||||
0.227f, 0.237f, 0.247f, 0.258f, 0.268f,
|
||||
0.279f, 0.290f, 0.302f, 0.313f, 0.325f,
|
||||
0.337f, 0.349f, 0.362f, 0.375f, 0.388f,
|
||||
0.401f, 0.414f, 0.428f, 0.442f, 0.456f,
|
||||
0.471f, 0.485f, 0.500f, 0.516f, 0.531f,
|
||||
0.547f, 0.563f, 0.579f, 0.595f, 0.612f,
|
||||
0.629f, 0.646f, 0.664f, 0.681f, 0.699f,
|
||||
0.718f, 0.736f, 0.755f, 0.774f, 0.793f,
|
||||
0.813f, 0.832f, 0.852f, 0.873f, 0.893f,
|
||||
0.914f, 0.935f, 0.957f, 0.978f, 1.000f,1.000f
|
||||
};
|
||||
|
||||
|
||||
|
||||
void _PWM_INIT(){
|
||||
|
||||
GPIO_InitCfg_t GPIO_InitCfg = { 0 }; // 清零初始化配置结构体
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0; // 选择功能复用器0
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx; // 选择GPIO功能(非特殊功能)
|
||||
GPIO_InitCfg.Pull = GPIO_PULLUP; // 上拉电阻使能
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
|
||||
GPIO_InitCfg.Pin = _PWM_W; // 设置LED1引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
|
||||
GPIO_InitCfg.Pin = _PWM_C; // 设置LED1引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PWM_SetDuty(uint8_t PWMX ,uint8_t duty) {
|
||||
if(PWMX==_PWM_W){
|
||||
PWM_WarmLight_t.duty_cycle=duty;
|
||||
}else if(PWMX ==_PWM_C){
|
||||
PWM_CoolLight_t.duty_cycle=duty;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDisplay(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief app_pwm_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_pwm_init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/*!
|
||||
* \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_H__
|
||||
#define __PWM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define MAXDUTY 255
|
||||
#define MINDUTY 0
|
||||
#define GAMMA 2.2
|
||||
|
||||
|
||||
#define _PWM_W (GPIO_1)
|
||||
#define _PWM_C (GPIO_2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#define R_PWM ((uint32_t)(r_DutyCycle * ((uint16_t)pow(Brightness,GAMMA))/ 25118)) // R
|
||||
//#define G_PWM ((uint32_t)(g_DutyCycle * ((uint16_t)pow(Brightness,GAMMA))/ 25118)) // G
|
||||
//#define B_PWM ((uint32_t)(b_DutyCycle * ((uint16_t)pow(Brightness,GAMMA))/ 25118)) // B
|
||||
|
||||
|
||||
#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
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern uint8_t pwm_red_idx;
|
||||
extern uint8_t pwm_green_idx;
|
||||
extern uint8_t pwm_blue_idx;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t period_count; // 周期需要的定时器中断次数 100
|
||||
uint8_t duty_cycle; // 占空比 0-255
|
||||
uint8_t counter; // 当前计数器值
|
||||
uint8_t enabled; // 通道使能标志
|
||||
} PWM_Channel_t; //暖光PWM
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t period_count; // 周期需要的定时器中断次数
|
||||
uint8_t duty_cycle; // 占空比 0-255
|
||||
uint8_t counter; // 当前计数器值
|
||||
uint8_t enabled; // 通道使能标志
|
||||
} PWM_Channe2_t; //冷光PWM
|
||||
|
||||
|
||||
extern PWM_Channel_t PWM_WarmLight_t; // 暖光PWM
|
||||
extern PWM_Channel_t PWM_CoolLight_t; // 冷光PWM
|
||||
extern uint8_t Brightness;
|
||||
|
||||
void _PWM_INIT(void);
|
||||
void PWM_SetDuty(uint8_t PWMX ,uint8_t duty);
|
||||
void app_pwm_init(void);
|
||||
void UpdateDisplay(void);
|
||||
void switch_pwm_pins(uint8_t red_pwm, uint8_t green_pwm, uint8_t blue_pwm);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PWM_TEST_H__ */
|
||||
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
#ifndef _RF433_H_
|
||||
#define _RF433_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
///*
|
||||
// 09 07 01 03
|
||||
//
|
||||
//
|
||||
//
|
||||
// 0B 05 0A 0C
|
||||
//*/
|
||||
|
||||
//白色八位调光遥控
|
||||
#define white_mode_plus 0x09
|
||||
#define white_mode_less 0x07
|
||||
#define white_w 0x01
|
||||
#define white_on_off 0x03
|
||||
#define white_bright_plus 0x0B
|
||||
#define white_bright_less 0x05
|
||||
#define white_speed_plus 0x0A
|
||||
#define white_speed_less 0x0C
|
||||
|
||||
//黑色调光遥控
|
||||
#define black_on 0x02
|
||||
#define black_off 0x04
|
||||
#define black_B_plus 0x00
|
||||
#define black_B_less 0x0F
|
||||
#define black_S_plus 0x0A
|
||||
#define black_S_less 0x0C
|
||||
#define black_M_plus 0x06
|
||||
#define black_M_less 0x0E
|
||||
|
||||
#define RELAY_CH1 50
|
||||
#define RELAY_CH2 49
|
||||
#define RELAY_CH3 52
|
||||
|
||||
#define KEY_STATE_IDLE 0
|
||||
#define KEY_STATE_PRESSED 1
|
||||
|
||||
#define KEY_LONG 1
|
||||
#define KEY_SHORT 2
|
||||
|
||||
#define key_read xc_gpio_read_pin(GPIO_1)
|
||||
extern volatile uint8_t led_state;
|
||||
extern uint8_t KEY_EVENT;
|
||||
extern uint16_t key_press_timer;
|
||||
|
||||
extern uint8_t adress_ch_flag[5];
|
||||
extern uint8_t rf433_value[5];
|
||||
extern uint8_t adress_index;
|
||||
|
||||
extern uint8_t flash_ch1_state;
|
||||
extern uint8_t flash_ch2_state;
|
||||
|
||||
|
||||
#define ON_OFF 0X03 //开关
|
||||
|
||||
#define Mode_choose 0X01 //七彩
|
||||
|
||||
#define Brightness_L 0X09 //
|
||||
|
||||
#define Brightness_H 0X07
|
||||
|
||||
#define Time_1h 0x0B
|
||||
|
||||
#define Time_2h 0x05
|
||||
|
||||
#define Speed_add 0x0C
|
||||
|
||||
#define Speed_dow 0x0A
|
||||
|
||||
|
||||
#define ON 0XF1 //开关
|
||||
|
||||
#define OFF 0XF0 //七彩
|
||||
|
||||
#define Mode_add 0XF2 //
|
||||
|
||||
#define Mode_dow 0XF3
|
||||
|
||||
#define Brightness_H 0xF4
|
||||
|
||||
#define Brightness_L 0xF5
|
||||
|
||||
|
||||
|
||||
|
||||
//椭圆
|
||||
#define ON 0X02 //开关
|
||||
|
||||
#define OFF 0X04 //七彩
|
||||
|
||||
#define Mode_add 0X06 //
|
||||
|
||||
#define Mode_dow 0X0E
|
||||
|
||||
#define Brightness_H 0x08
|
||||
|
||||
#define Brightness_L 0x0D
|
||||
|
||||
#define Speed_H 0x08
|
||||
|
||||
#define Speed_L 0x0D
|
||||
|
||||
|
||||
|
||||
//扁形
|
||||
#define B_Brightness_H 0x00
|
||||
|
||||
#define B_Brightness_L 0x0F
|
||||
|
||||
#define B_Speed_L 0x0A //F_Speed_dow 0x0A
|
||||
|
||||
#define B_Speed_H 0x0C // F_Speed_add 0x0C
|
||||
|
||||
|
||||
//方形
|
||||
#define F_ON_OFF 0X03 //开关
|
||||
|
||||
#define F_Mode_choose 0X01 //七彩
|
||||
|
||||
#define F_Brightness_100 0X07 //
|
||||
|
||||
#define F_Brightness_10 0X09
|
||||
|
||||
#define F_Time_1h 0x0B
|
||||
|
||||
#define F_Time_2h 0x05
|
||||
|
||||
#define F_Speed_add 0x0C
|
||||
|
||||
#define F_Speed_dow 0x0A
|
||||
|
||||
|
||||
|
||||
//#define RF_DATA P15 //RF433接收引脚,根据具体单片机定义引脚
|
||||
|
||||
//#define RF433_PIN GPIO_5 //RF433接收引脚,根据具体单片机定义引脚
|
||||
|
||||
//#define RF_DATA P15 //RF433接收引脚,根据具体单片机定义引脚
|
||||
|
||||
|
||||
#define RF_DATA xc_gpio_read_pin(GPIO_0) //RF433接收引脚,根据具体单片机定义引脚
|
||||
|
||||
#define RF433_PIN GPIO_0 //RF433接收引脚,根据具体单片机定义引脚
|
||||
|
||||
#define RELAY_CH1_PIN (GPIO_5)
|
||||
#define RELAY_CH2_PIN (GPIO_2)
|
||||
|
||||
|
||||
|
||||
#define frames_time 30 //该值要大于68,68指代通过逻辑分析仪抓取一帧的时间 20
|
||||
#define LongPress_time 100 //长按时间 100ms触发一次
|
||||
#define Short_time 35 // 时间 60ms触发一次
|
||||
//enum
|
||||
//{
|
||||
// SHUT_DOWN,
|
||||
// POWER_ON
|
||||
//};
|
||||
|
||||
enum
|
||||
{
|
||||
LOW_LEVEL, //0
|
||||
HIGH_LEVEL //1
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FAIL,
|
||||
SUCCESS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NOMATCH,
|
||||
MATCHED
|
||||
};
|
||||
|
||||
struct receive_data_page//接收数据包结构
|
||||
{
|
||||
unsigned char idh;
|
||||
unsigned char idl;
|
||||
unsigned char key_value;
|
||||
};
|
||||
struct address
|
||||
{
|
||||
unsigned char address_l;
|
||||
unsigned char address_h;
|
||||
};
|
||||
union rf433_flag
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned char study: 1; //表示占用1位
|
||||
unsigned char long_press_flag:1;
|
||||
unsigned char short_press_flag:1;
|
||||
unsigned char current_level: 1;
|
||||
unsigned char sync_code: 1;
|
||||
unsigned char decode_success_flag:1; //松手检测标志
|
||||
unsigned char new_remote_flag:1;
|
||||
unsigned char receive_finish: 1;
|
||||
unsigned char raised_long_press_flag: 1;
|
||||
} rf_receive_flag;
|
||||
unsigned char flag;
|
||||
}; //联合体赋初值 rf_flag = {0}
|
||||
|
||||
|
||||
|
||||
extern union rf433_flag rf_flag;
|
||||
extern struct receive_data_page Receive_data_page;
|
||||
extern struct address Remote_adress;
|
||||
extern uint8_t match_success;
|
||||
extern unsigned char match_time_over_flag;
|
||||
extern uint32_t receive_data;
|
||||
extern uint32_t flag_1h;
|
||||
extern uint8_t is_time;
|
||||
extern uint32_t adress;
|
||||
extern unsigned char receive_data_cnt;
|
||||
|
||||
extern uint8_t res_data;
|
||||
|
||||
|
||||
extern uint8_t adress_H;
|
||||
extern uint8_t adress_L;
|
||||
extern uint8_t adress_H_array[5];
|
||||
extern uint8_t adress_L_array[5];
|
||||
extern uint8_t long_flag_s;
|
||||
|
||||
|
||||
void rf433_receive(void);
|
||||
void rf433_gpio_init(void);
|
||||
void scan_433(void);
|
||||
void Lock_Pwm7xd(void);
|
||||
void Delay_50us(unsigned int n);
|
||||
void _433_fun(void);
|
||||
|
||||
void key_scan(void);
|
||||
void ble_mode_scan(void);
|
||||
void pwm3_toggle(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,563 @@
|
||||
#include "RF433.h" // Device header
|
||||
#include "xc_drv_gpio.h"
|
||||
#include "uart.h"
|
||||
#include "xc_drv_uart.h"
|
||||
#include "mode.h"
|
||||
#include "timer.h"
|
||||
#include "pwm.h"
|
||||
#include "key.h"
|
||||
#include "switch_s.h"
|
||||
|
||||
|
||||
//用bit表示通道
|
||||
#define CH_GPIO2 (1 << 0) // bit0 = GPIO2
|
||||
#define CH_GPIO5 (1 << 1) // bit1 = GPIO5
|
||||
|
||||
|
||||
union rf433_flag rf_flag = {0};
|
||||
unsigned char high_level_time;
|
||||
unsigned char low_level_time;
|
||||
unsigned char receive_data_cnt;
|
||||
uint32_t receive_temp;
|
||||
uint32_t receive_data;
|
||||
|
||||
|
||||
|
||||
uint8_t res_data=255; //433返回的最后一个控制字节(低八位)
|
||||
static uint16_t long_time=0; //表示长按短按 该值一定要大于8,68是指68ms通过逻辑分析仪测量一帧433的时间
|
||||
static uint16_t time_300ms=1; //表示:当长按的时候要300ms执行一次
|
||||
static uint8_t POWER_flag;
|
||||
|
||||
uint32_t flag_1h =0;
|
||||
uint8_t is_time=0;
|
||||
|
||||
|
||||
uint32_t adress=0;
|
||||
uint32_t time_5s=1;
|
||||
uint16_t long_press_cnt=0;
|
||||
|
||||
uint8_t adress_index=0; //地址下标
|
||||
uint8_t adress_H=0;
|
||||
uint8_t adress_L=0;
|
||||
uint8_t adress_H_array[5]={0,0,0,0,0};
|
||||
uint8_t adress_L_array[5]={0,0,0,0,0};
|
||||
uint8_t match_success=0;
|
||||
|
||||
uint8_t flash_ch1_state=0;
|
||||
uint8_t flash_ch2_state=0;
|
||||
|
||||
|
||||
|
||||
void Delay_50us(unsigned int n)
|
||||
{
|
||||
unsigned char i;
|
||||
while(n--)
|
||||
{
|
||||
for(i=0;i<104;i++);
|
||||
}
|
||||
}
|
||||
void Delay_ms(unsigned int n)
|
||||
{
|
||||
while(n--)
|
||||
{
|
||||
Delay_50us(20);
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t power=2;
|
||||
void Lock_Pwm7xd(void){
|
||||
power=1;
|
||||
}
|
||||
void rf433_gpio_init(){
|
||||
GPIO_InitCfg_t GPIO_InitCfg = { 0 }; // 清零初始化配置结构体
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0; // 选择功能复用器0
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx; // 选择GPIO功能(非特殊功能)
|
||||
GPIO_InitCfg.Pull = GPIO_PULLUP; // 上拉电阻使能
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_INPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
|
||||
GPIO_InitCfg.Pin = RF433_PIN; // 设置RF引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
|
||||
}
|
||||
|
||||
static uint8_t ssse=0;
|
||||
uint8_t long_flag_s=0;
|
||||
|
||||
// 在固定大小数组中添加新元素(滑动窗口)
|
||||
void addToFixedArray(uint8_t arr[], uint8_t newValue) {
|
||||
uint8_t i;
|
||||
// 所有元素向后移动一位
|
||||
for( i = 4; i > 0; i--) {
|
||||
arr[i] = arr[i - 1];
|
||||
}
|
||||
|
||||
// 在头部插入新值
|
||||
arr[0] = newValue;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t KEY_STATE_Click; // 单击
|
||||
uint32_t KEY_STATE_LONG_PRESS; // 长按
|
||||
} _Key_TypeDef;
|
||||
|
||||
_Key_TypeDef Key_TypeDef={0,0};
|
||||
uint32_t KEY_STATE_re=0; // 长按
|
||||
|
||||
|
||||
//该函数选择哪个按键为单击,哪个为长按按键
|
||||
static void set_click()
|
||||
{
|
||||
if(res_data==RELAY_CH1||res_data==RELAY_CH2||res_data==RELAY_CH3||res_data==black_on||res_data==black_off||res_data==white_on_off||res_data==0x01){
|
||||
Key_TypeDef.KEY_STATE_Click=1; //单击
|
||||
}
|
||||
else{
|
||||
Key_TypeDef.KEY_STATE_LONG_PRESS=1; //长按
|
||||
KEY_STATE_re=1;
|
||||
}
|
||||
}
|
||||
|
||||
//static uint16_t press_timer=0; //累计按下时间
|
||||
//static uint16_t realx_timer=0; //距离上一帧时间
|
||||
//static uint8_t last_key_code=0; //记录按下键值
|
||||
//static uint8_t key_active_flag=0; //是否处于键值激活状态
|
||||
|
||||
|
||||
|
||||
|
||||
void rf433_receive(void)//rf433接收,查询周期100us
|
||||
{
|
||||
|
||||
if (RF_DATA == LOW_LEVEL)
|
||||
{
|
||||
low_level_time++;//记录低电平时间
|
||||
rf_flag.rf_receive_flag.current_level = 0; //当前电平状态
|
||||
}
|
||||
else if (RF_DATA == HIGH_LEVEL)
|
||||
{
|
||||
high_level_time++;//记录高电平时间
|
||||
|
||||
if (!rf_flag.rf_receive_flag.current_level)//每个上升沿检测,0→1,一个完整的周期检测
|
||||
{
|
||||
|
||||
|
||||
if ((high_level_time > 1 && high_level_time < 7) && (low_level_time > 100 && low_level_time < 130)) //判同步码,时间间隔12ms //1-7,115-130 12 15 115-130 100
|
||||
{
|
||||
//进来这里需要13ms
|
||||
rf_flag.rf_receive_flag.sync_code = 1;//同步码接收成功标志
|
||||
receive_data_cnt = 0;
|
||||
receive_temp = 0;
|
||||
long_time=frames_time;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (rf_flag.rf_receive_flag.sync_code)//开始接收数据包
|
||||
{
|
||||
|
||||
if ((high_level_time >= 1 && high_level_time <= 7) && (low_level_time >= 7 && low_level_time <= 16)) //数据低电平
|
||||
{
|
||||
|
||||
receive_temp = receive_temp << 1;
|
||||
receive_data_cnt++;//接收24位位数
|
||||
if (receive_data_cnt == 24)//24位数据接收完成
|
||||
{
|
||||
//进来这个if需要40ms
|
||||
rf_flag.rf_receive_flag.receive_finish = 1;//24位数据接收完成标志
|
||||
rf_flag.rf_receive_flag.sync_code = 0;
|
||||
receive_data = receive_temp;//将接收到的编码复制到解码寄存器中
|
||||
res_data=receive_temp; //将接收到的编码复制到解码寄存器中
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if ((high_level_time >= 7 && high_level_time <= 16) && (low_level_time >= 2 && low_level_time<= 7)) //数据高电平
|
||||
{
|
||||
receive_temp = receive_temp << 1;
|
||||
receive_temp |= 1;
|
||||
receive_data_cnt++;
|
||||
if (receive_data_cnt == 24)
|
||||
{
|
||||
//进来这个if需要40ms3748f3
|
||||
rf_flag.rf_receive_flag.receive_finish = 1;//24位数据接收完成标志
|
||||
rf_flag.rf_receive_flag.sync_code = 0;
|
||||
receive_data = receive_temp;//将接收到的编码复制到解码寄存器中
|
||||
res_data=receive_temp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rf_flag.rf_receive_flag.sync_code = 0;//接收失败
|
||||
}
|
||||
|
||||
|
||||
long_time=frames_time;//该值一定要大与68,68是指68ms通过逻辑分析仪测量一帧的时间
|
||||
}
|
||||
|
||||
if(long_time>0)
|
||||
{ //一直按着会进入该if
|
||||
//P05=0; //433LED灯
|
||||
long_time--;
|
||||
long_flag_s=0;
|
||||
if( KEY_STATE_re==1)
|
||||
{
|
||||
if(time_300ms==0)
|
||||
{
|
||||
time_300ms=Short_time;
|
||||
long_flag_s=1;
|
||||
KEY_STATE_re=0;
|
||||
}
|
||||
else if(time_300ms>0)
|
||||
time_300ms--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //松手
|
||||
time_300ms=LongPress_time;
|
||||
long_time=0;
|
||||
long_flag_s=0;
|
||||
Key_TypeDef.KEY_STATE_Click=0;
|
||||
KEY_STATE_re=0;
|
||||
}
|
||||
|
||||
low_level_time = 0;//清零低电平时间
|
||||
high_level_time = 1;//高电平时间开始计数
|
||||
|
||||
}
|
||||
rf_flag.rf_receive_flag.current_level = 1;//当前电平状态
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pwm3_toggle(void)
|
||||
{
|
||||
static uint8_t pwm_state = 0;
|
||||
|
||||
if(pwm_state == 0)
|
||||
{
|
||||
|
||||
xc_pwm_dutycycle_set(PWM3_IDX,5000,5000);
|
||||
pwm_state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
xc_pwm_dutycycle_set(PWM3_IDX,5000,0);
|
||||
pwm_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
volatile uint8_t led_state=0;
|
||||
uint16_t key_press_timer=0;
|
||||
uint8_t KEY_EVENT=0;
|
||||
uint8_t key_state=0;
|
||||
uint8_t sw_700ms_check=0;
|
||||
|
||||
|
||||
|
||||
void app_key_callback_handler(uint16_t key_value) //按键回调函数
|
||||
{
|
||||
switch(key_value)
|
||||
{
|
||||
// case REC_KEY_UP_SHORT_UP: //短按
|
||||
//
|
||||
// key_state=KEY_SHORT;
|
||||
// power=4;
|
||||
// led_state=2;
|
||||
// break;
|
||||
|
||||
case REC_KEY_UP_LONG_DOWN: //长按
|
||||
|
||||
led_state=1;
|
||||
key_state=KEY_LONG;
|
||||
break;
|
||||
|
||||
case MODE_DOUBLE_CLICK: //双击
|
||||
|
||||
key_state=KEY_SHORT;
|
||||
power=3;
|
||||
led_state=2;
|
||||
break;
|
||||
|
||||
case MODE_QUAD_CLICK: //四击
|
||||
key_state=KEY_SHORT;
|
||||
power=4;
|
||||
led_state=3;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//void key_scan(void)
|
||||
//{
|
||||
|
||||
|
||||
|
||||
// if(key_read==0)
|
||||
// {
|
||||
// KEY_EVENT=KEY_STATE_PRESSED;
|
||||
//
|
||||
// if(key_press_timer>5&&sw_700ms_check==0)
|
||||
// {
|
||||
// key_press_timer=0;
|
||||
// key_state=KEY_LONG;
|
||||
// led_state=1;
|
||||
// sw_700ms_check=1;
|
||||
// KEY_EVENT=KEY_STATE_IDLE;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else if(key_read==1&& KEY_EVENT==KEY_STATE_PRESSED)
|
||||
// {
|
||||
// sw_700ms_check=0;
|
||||
// KEY_EVENT=KEY_STATE_IDLE;
|
||||
// if(key_press_timer>0&&key_press_timer<=5)
|
||||
// {
|
||||
// key_press_timer=0;
|
||||
// key_state=KEY_SHORT;
|
||||
// power=1;
|
||||
// led_state=2;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void ble_mode_scan(void)
|
||||
{
|
||||
if(receive_mode)
|
||||
{
|
||||
switch(receive_mode)
|
||||
{
|
||||
case 1:
|
||||
receive_mode=0;
|
||||
key_state=KEY_SHORT;
|
||||
power=3;
|
||||
led_state=2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
receive_mode=0;
|
||||
key_state=KEY_SHORT;
|
||||
power=4;
|
||||
led_state=3;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
receive_mode=0;
|
||||
led_state=1;
|
||||
key_state=KEY_LONG;
|
||||
break;
|
||||
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t adress_ture_flag=0;
|
||||
uint8_t adress_ch_flag[5]={0,0,0,0,0};
|
||||
uint8_t rf433_value[5]={0,0,0,0,0};
|
||||
uint8_t adress_index_ture=0;
|
||||
|
||||
void _433_fun(void)
|
||||
{
|
||||
if(Key_TypeDef.KEY_STATE_Click==1||KEY_STATE_re==1) return;
|
||||
set_click(); //设置单击长按
|
||||
|
||||
if(res_data==0x03)
|
||||
{
|
||||
uint8_t ch_mask = adress_ch_flag[adress_index_ture];
|
||||
|
||||
if(ch_mask & CH_GPIO2){
|
||||
xc_gpio_toggle_pin(GPIO_2);
|
||||
flash_ch2_state=xc_gpio_read_pin(GPIO_2);
|
||||
}
|
||||
|
||||
if(ch_mask & CH_GPIO5){
|
||||
xc_gpio_toggle_pin(GPIO_5);
|
||||
flash_ch1_state=xc_gpio_read_pin(GPIO_5);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void scan_433(void)
|
||||
{
|
||||
uint8_t i=0;
|
||||
|
||||
if(rf433_sw_flag==1)
|
||||
{
|
||||
rf433_sw_flag=0;
|
||||
power=3;
|
||||
key_state=KEY_SHORT;
|
||||
led_state=2;
|
||||
}
|
||||
else if(rf433_sw_flag==2)
|
||||
{
|
||||
rf433_sw_flag=0;
|
||||
power=4;
|
||||
key_state=KEY_SHORT;
|
||||
led_state=3;
|
||||
}
|
||||
|
||||
if(power==3 && rf_flag.rf_receive_flag.receive_finish==1 && key_state==KEY_SHORT ) //双击对码GPIO2
|
||||
{
|
||||
|
||||
|
||||
key_state=0;
|
||||
power=2;
|
||||
led_state=0;
|
||||
|
||||
|
||||
uint8_t ch_mask=CH_GPIO2; //对应位掩码
|
||||
|
||||
adress_H=((receive_data>>16)&0xff); //读取高八位地址码
|
||||
adress_L=((receive_data>>8)&0xff); //读取低八位地址码
|
||||
|
||||
|
||||
adress_ture_flag=0;
|
||||
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
if(adress_H_array[i]==adress_H && adress_L_array[i]==adress_L)
|
||||
{
|
||||
adress_ture_flag=1;
|
||||
adress_index_ture=i; //存放找到的地址下标
|
||||
adress_ch_flag[i] |= ch_mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(adress_ture_flag==0)
|
||||
{
|
||||
uint8_t current_idx = adress_index % 5;
|
||||
adress_H_array[current_idx] = adress_H;
|
||||
adress_L_array[current_idx] = adress_L;
|
||||
adress_ch_flag[current_idx] = ch_mask; // 初始掩码
|
||||
rf433_value[current_idx]=res_data;
|
||||
adress_index++;
|
||||
}
|
||||
adress_ture_flag=0;
|
||||
|
||||
|
||||
|
||||
// set_TaskComps_timer(5,500);
|
||||
}
|
||||
|
||||
|
||||
else if(power==4 && rf_flag.rf_receive_flag.receive_finish==1 && key_state==KEY_SHORT ) //四击对码GPIO5
|
||||
{
|
||||
|
||||
|
||||
key_state=0;
|
||||
power=2;
|
||||
led_state=0;
|
||||
|
||||
uint8_t ch_mask=CH_GPIO5; //对应位掩码
|
||||
|
||||
adress_H=((receive_data>>16)&0xff); //读取高八位地址码
|
||||
adress_L=((receive_data>>8)&0xff); //读取低八位地址码
|
||||
|
||||
|
||||
|
||||
adress_ture_flag=0;
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
if(adress_H_array[i]==adress_H && adress_L_array[i]==adress_L)
|
||||
{
|
||||
adress_ture_flag=1;
|
||||
adress_index_ture=i; //存放找到的地址下标
|
||||
adress_ch_flag[i] |= ch_mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(adress_ture_flag==0)
|
||||
{
|
||||
uint8_t current_idx = adress_index % 5;
|
||||
adress_H_array[current_idx] = adress_H;
|
||||
adress_L_array[current_idx] = adress_L;
|
||||
adress_ch_flag[current_idx] = ch_mask; // 初始掩码
|
||||
rf433_value[current_idx]=res_data;
|
||||
adress_index++;
|
||||
}
|
||||
adress_ture_flag=0;
|
||||
|
||||
|
||||
|
||||
// set_TaskComps_timer(5,500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(power==2 && rf_flag.rf_receive_flag.receive_finish==1)
|
||||
{
|
||||
|
||||
adress_index_ture = 0xFF; // 默认无效
|
||||
for(i=0; i<5; i++)
|
||||
{
|
||||
if( adress_H_array[i] == ((receive_data>>16)&0xff) &&
|
||||
adress_L_array[i] == ((receive_data>>8)&0xff) )
|
||||
{
|
||||
adress_index_ture = i; // 找到索引
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 找到有效索引执行
|
||||
if(adress_index_ture != 0xFF)
|
||||
{
|
||||
|
||||
_433_fun();
|
||||
set_TaskComps_timer(6,1000);
|
||||
// printf("adress_index %d\r\n",adress_index);
|
||||
// printf("flash_ch1_state %d\r\n",flash_ch1_state);
|
||||
// printf("flash_ch2_state %d\r\n",flash_ch1_state);
|
||||
// printf("flash_ch3_state %d\r\n",flash_ch1_state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
rf_flag.rf_receive_flag.receive_finish=0;
|
||||
}
|
||||
|
||||
if( key_state==KEY_LONG )
|
||||
{
|
||||
key_state=0;
|
||||
memset(adress_H_array, 0, sizeof(adress_H_array));
|
||||
memset(adress_L_array, 0, sizeof(adress_L_array));
|
||||
memset(adress_ch_flag, 0, sizeof(adress_ch_flag));
|
||||
memset(rf433_value, 0, sizeof(rf433_value));
|
||||
adress_index=0;
|
||||
set_TaskComps_timer(6,1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +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 "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_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,547 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
struct gapc_encrypt_req_ind const *param = (struct gapc_encrypt_req_ind const *)p_param;
|
||||
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 // #if (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,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
|
||||
@@ -0,0 +1,865 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file app_task.c
|
||||
*
|
||||
* @brief RW APP Task implementation
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
#include "rwip_config.h"
|
||||
#if (BLE_APP_PRESENT)
|
||||
#include "app_sec.h"
|
||||
#include "app_task.h" // Application Manager Task API
|
||||
|
||||
|
||||
#if APP_SCAN_FUNCTION
|
||||
extern void set_channel_scan(uint8_t channel);
|
||||
|
||||
#endif
|
||||
/// Application Task Descriptor
|
||||
const struct ke_task_desc TASK_DESC_APP;
|
||||
/// Application Environment Structure
|
||||
struct app_env_tag app_env = {
|
||||
.adv_actv_idx = INVALID_DATA,
|
||||
.slave_conidx = INVALID_DATA,
|
||||
.slave_connected = false,
|
||||
|
||||
};
|
||||
bool start_second_adv = false;
|
||||
struct app_env_tag *get_app_env(void) { return &app_env; }
|
||||
uint8_t set_data_flag = 0;
|
||||
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);
|
||||
|
||||
extern struct bd_addr co_default_bdaddr;
|
||||
|
||||
uint8_t app_mode = APP_CONN_MODE;
|
||||
#define TEST_MODE_STATUS 0
|
||||
|
||||
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)
|
||||
|
||||
xc_ble_gapm_reset();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
extern bool start_second_adv;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern uint32_t non_conn_adv_intv;
|
||||
|
||||
void app_change_non_adv_interval(uint32_t ms) { non_conn_adv_intv = ms * 1000 / 625; }
|
||||
|
||||
void app_create_advertising_non_conn(void)
|
||||
{
|
||||
|
||||
struct gapm_activity_create_adv_cmd param = {0};
|
||||
param.own_addr_type = GAPM_STATIC_ADDR;
|
||||
printf("second adv\n");
|
||||
param.adv_param.type = GAPM_ADV_TYPE_LEGACY;
|
||||
|
||||
param.adv_param.disc_mode = GAPM_ADV_MODE_BEACON;
|
||||
param.adv_param.prop = GAPM_ADV_PROP_NON_CONN_NON_SCAN_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 = 16; // 0.625ms
|
||||
param.adv_param.prim_cfg.adv_intv_max = 16; // 0.625ms
|
||||
non_conn_adv_intv = param.adv_param.prim_cfg.adv_intv_min;
|
||||
param.adv_param.prim_cfg.chnl_map = 0x1; // 0x1 : 37 channle
|
||||
param.adv_param.prim_cfg.phy = GAP_PHY_1MBPS;
|
||||
|
||||
printf("%s %d\n", __func__, __LINE__);
|
||||
xc_ble_advertise_create(¶m);
|
||||
app_env.adv_state = APP_ADV_STATE_STARTING;
|
||||
// }
|
||||
}
|
||||
uint8_t app_actv_idx = 0;
|
||||
|
||||
|
||||
|
||||
//void app_set_adv_data(void)
|
||||
//{
|
||||
// if (app_env.adv_state == APP_ADV_STATE_STARTING) {
|
||||
|
||||
// if (start_second_adv) {
|
||||
// uint8_t adv_data[ADV_DATA_MAX_LENGTH] = {0};
|
||||
// adv_data[0] = 27; // APP_DFLT_DEVICE_NAME_LEN2 + 1;
|
||||
// adv_data[1] = 0; // GAP_AD_TYPE_COMPLETE_NAME;
|
||||
// memcpy(&adv_data[2], APP_DFLT_DEVICE_NAME2, APP_DFLT_DEVICE_NAME_LEN2);
|
||||
// xc_ble_set_adv_data(app_env.second_adv_actv_idx, 28, adv_data);
|
||||
// } else {
|
||||
// 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_adv_data(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_STARTING) {
|
||||
uint8_t adv_data[ADV_DATA_MAX_LENGTH] = {0}; // 初始化广播数据数组
|
||||
uint8_t pos = 0; // 追踪广播数据的位置
|
||||
|
||||
// 添加设备名称
|
||||
adv_data[pos] = APP_DFLT_DEVICE_NAME_LEN + 1; // 设备名称长度 + 1 字节的类型字段
|
||||
pos++;
|
||||
adv_data[pos] = GAP_AD_TYPE_COMPLETE_NAME; // 设备名称类型
|
||||
pos++;
|
||||
memcpy(&adv_data[pos], APP_DFLT_DEVICE_NAME, APP_DFLT_DEVICE_NAME_LEN); // 复制设备名称
|
||||
pos += APP_DFLT_DEVICE_NAME_LEN;
|
||||
|
||||
// 添加制造商数据
|
||||
adv_data[pos] = MANUFACTURER_DATA_LEN + 1; // 制造商数据长度 + 1 字节的类型字段
|
||||
pos++;
|
||||
adv_data[pos] = GAP_AD_TYPE_MANU_SPECIFIC_DATA; // 制造商数据类型
|
||||
pos++;
|
||||
memcpy(&adv_data[pos], MANUFACTURER_DATA, MANUFACTURER_DATA_LEN); // 复制制造商数据
|
||||
pos += MANUFACTURER_DATA_LEN;
|
||||
|
||||
// 设置广播数据
|
||||
xc_ble_set_adv_data(app_env.adv_actv_idx, pos, 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);
|
||||
if (start_second_adv) {
|
||||
xc_ble_set_scan_rsp_data(app_env.second_adv_actv_idx, MANUFACTURER_DATA_LEN + 2, scan_rsp_data);
|
||||
} else {
|
||||
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};
|
||||
if (start_second_adv) {
|
||||
param.actv_idx = app_env.second_adv_actv_idx;
|
||||
start_second_adv = false;
|
||||
} else {
|
||||
param.actv_idx = app_env.adv_actv_idx;
|
||||
}
|
||||
|
||||
if (0x2 == param.actv_idx) {
|
||||
set_data_flag = 1;
|
||||
}
|
||||
printf("param.actv_idx = 0x%x\n", param.actv_idx);
|
||||
param.u_param.adv_add_param.duration = ADV_DURATION;
|
||||
|
||||
xc_ble_advertise_start(¶m);
|
||||
app_env.adv_state = APP_ADV_STATE_STARTING;
|
||||
}
|
||||
}
|
||||
#if APP_SCAN_FUNCTION
|
||||
// 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);
|
||||
printf("app_create_scan\n");
|
||||
app_env.scan_state = APP_SCAN_STATE_CREATING;
|
||||
app_env.scan_actv_idx = 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
void app_start_scan(void)
|
||||
{
|
||||
|
||||
if (app_env.scan_state == APP_SCAN_STATE_CREATING || app_env.scan_state == APP_SCAN_STATE_STOPPED ||
|
||||
app_env.scan_state == APP_SCAN_STATE_STOPPING) {
|
||||
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;
|
||||
param->dup_filt_pol = GAPM_DUP_FILT_DIS;
|
||||
param->scan_param_1m.scan_intv = 32; // 0.625 ms
|
||||
param->scan_param_1m.scan_wd = 32; // 0.625 ms
|
||||
param->duration = 0;
|
||||
printf("xc_ble_scan_start\n");
|
||||
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) {
|
||||
printf("xc_ble_activity_stop\n");
|
||||
xc_ble_activity_stop(app_env.scan_actv_idx);
|
||||
app_env.scan_state = APP_SCAN_STATE_STOPPING;
|
||||
}
|
||||
}
|
||||
#endif // APP_SCAN_FUNCTION
|
||||
void app_stop_advertising(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_STARTING) {
|
||||
if (start_second_adv) {
|
||||
xc_ble_activity_stop(app_env.second_adv_actv_idx);
|
||||
set_data_flag = 0;
|
||||
} else {
|
||||
xc_ble_activity_stop(app_env.adv_actv_idx);
|
||||
}
|
||||
|
||||
app_env.adv_state = APP_ADV_STATE_STOPPING;
|
||||
}
|
||||
}
|
||||
void app_delete_advertising(void)
|
||||
{
|
||||
if (app_env.adv_state == APP_ADV_STATE_STOPPED) {
|
||||
printf("app_delete_advertising\n");
|
||||
if (start_second_adv) {
|
||||
xc_ble_activity_delete(app_env.second_adv_actv_idx);
|
||||
} else {
|
||||
xc_ble_activity_delete(app_env.adv_actv_idx);
|
||||
}
|
||||
|
||||
app_env.adv_state = APP_ADV_STATE_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
||||
#if 0 // ((BLE_HOST_SUPPORT_SMP))
|
||||
|
||||
// Call the Security Module
|
||||
msg_pol =
|
||||
app_get_handler(&app_sec_handlers, msgid, p_param, src_id);
|
||||
#endif
|
||||
} 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, status :0x%02x\r\n",
|
||||
// p_param->operation, 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 = {
|
||||
#if APP_SCAN_FUNCTION
|
||||
.role = GAP_ROLE_PERIPHERAL | GAP_ROLE_OBSERVER,
|
||||
#else
|
||||
.role = GAP_ROLE_PERIPHERAL,
|
||||
#endif
|
||||
.sugg_max_tx_octets = BLE_MAX_OCTETS,
|
||||
// .sugg_max_tx_time = BLE_MAX_TIME,
|
||||
.sugg_max_tx_time = 2120,
|
||||
// .pairing_mode = GAPM_PAIRING_DISABLE,
|
||||
|
||||
#if (BLE_SEC_CON)
|
||||
.pairing_mode = GAPM_PAIRING_SEC_CON,
|
||||
#else // (BLE_SEC_CON)
|
||||
.pairing_mode = GAPM_PAIRING_LEGACY,
|
||||
#endif // (BLE_SEC_CON)
|
||||
|
||||
};
|
||||
xc_ble_set_dev_config(&cfg_param);
|
||||
|
||||
|
||||
|
||||
ke_timer_set(APP_SECOND_ADV_START, TASK_APP, 400); // start open noconnect adv
|
||||
|
||||
|
||||
// ((*(volatile uint32_t *)(0x53000050)) = (1<<15) | (0x7<<8) | (1
|
||||
// << 7) | (0x3 << 0));
|
||||
// ((*(volatile uint32_t *)(0x53000050)) = (1<<15) | (0x3<<8) | (1
|
||||
// << 7) | ( 0x1b<< 0));
|
||||
// ((*(volatile uint32_t *)(0x53000050)) = (1<<15) | (0x5<<8) | (1
|
||||
// << 7) | (0x5 << 0));
|
||||
|
||||
ip_diagcntl_pack(0, 0, 0, 0, 1, 0x7c, 1, 0x3);
|
||||
|
||||
uint32_t value = (*(volatile uint32_t *)(0x53000050));
|
||||
value &= ~(0xff << 24);
|
||||
value |= (0x8 << 24); // diag3[3]: auto_skip_event_en
|
||||
(*(volatile uint32_t *)(0x53000050)) = value;
|
||||
LOGI("init value=%x\n", value >> 24);
|
||||
#if TEST_MODE_STATUS
|
||||
if (app_mode == APP_SCAN_SLEEP_MODE)
|
||||
ke_timer_set(APP_TEST_MODE, TASK_APP, 5000); // start test mode switch
|
||||
#endif
|
||||
} break;
|
||||
case GAPM_SET_DEV_CONFIG: {
|
||||
if (!custom_svc_add()) {
|
||||
app_create_advertising();
|
||||
}
|
||||
|
||||
#if APP_SCAN_FUNCTION
|
||||
app_create_scan();
|
||||
#endif
|
||||
} break;
|
||||
|
||||
case GAPM_SET_ADV_DATA: {
|
||||
if (app_mode == APP_CONN_MODE) {
|
||||
app_start_advertising();
|
||||
}
|
||||
} break;
|
||||
case GAPM_START_ACTIVITY: // 64
|
||||
{
|
||||
|
||||
} break;
|
||||
case GAPM_CREATE_SCAN_ACTIVITY: // 61
|
||||
{
|
||||
#if APP_SCAN_FUNCTION
|
||||
|
||||
printf("GAPM_CREATE_SCAN_ACTIVITY \n");
|
||||
ke_timer_set(APP_SCAN_START, TASK_APP, 10);
|
||||
// app_start_scan();
|
||||
#endif
|
||||
} break;
|
||||
case GAPM_STOP_ACTIVITY: {
|
||||
app_delete_advertising();
|
||||
} break;
|
||||
case GAPM_DELETE_ACTIVITY: {
|
||||
} break;
|
||||
case GAPM_CREATE_ADV_ACTIVITY:
|
||||
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 cfm = {0};
|
||||
switch (param->req) {
|
||||
case GAPC_DEV_NAME: {
|
||||
cfm.req = param->req;
|
||||
cfm.token = param->token;
|
||||
cfm.status = GAP_ERR_NO_ERROR;
|
||||
cfm.info.name.value_length = app_get_dev_name(cfm.info.name.value);
|
||||
xc_ble_get_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
|
||||
case GAPC_DEV_APPEARANCE: {
|
||||
cfm.req = param->req;
|
||||
cfm.info.appearance = DEV_APPEARANCE;
|
||||
cfm.token = param->token;
|
||||
cfm.status = GAP_ERR_NO_ERROR;
|
||||
xc_ble_get_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
|
||||
case GAPC_DEV_SLV_PREF_PARAMS: {
|
||||
cfm.req = param->req;
|
||||
cfm.info.slv_pref_params.con_intv_min = BLE_UAPDATA_MIN_INTVALUE;
|
||||
// Slave preferred Connection interval Max
|
||||
cfm.info.slv_pref_params.con_intv_max = BLE_UAPDATA_MAX_INTVALUE;
|
||||
// Slave preferred Connection latency
|
||||
cfm.info.slv_pref_params.slave_latency = BLE_UAPDATA_LATENCY;
|
||||
// Slave preferred Link supervision timeout
|
||||
cfm.info.slv_pref_params.conn_timeout = BLE_UAPDATA_TIMEOUT;
|
||||
cfm.token = param->token;
|
||||
cfm.status = GAP_ERR_NO_ERROR;
|
||||
xc_ble_get_dev_info_cfm(conidx, &cfm);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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 \r\n", p_param->actv_idx, p_param->actv_type);
|
||||
switch (p_param->actv_type) {
|
||||
case GAPM_ACTV_TYPE_ADV: {
|
||||
if (start_second_adv) {
|
||||
app_env.second_adv_actv_idx = p_param->actv_idx;
|
||||
} else {
|
||||
app_env.adv_actv_idx = p_param->actv_idx;
|
||||
}
|
||||
app_set_adv_data();
|
||||
} 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(" 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.adv_actv_idx) {
|
||||
app_env.adv_state = APP_ADV_STATE_STOPPED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t fir = 1;
|
||||
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:
|
||||
LOGI("GAPM_DEV_BDADDR_IND\r\n");
|
||||
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 == 1) {
|
||||
memcpy(&app_env.loc_irk[0], &p_param->randnb.nb[0], 8);
|
||||
}
|
||||
// Second part of IRK
|
||||
else if (app_env.rand_cnt == 2) {
|
||||
memcpy(&app_env.loc_irk[8], &p_param->randnb.nb[0], 8);
|
||||
}
|
||||
} 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_EXT_ADV_REPORT_IND: {
|
||||
// LOGI("GAPM_EXT_ADV_REPORT_IND\r\n");
|
||||
struct gapm_ext_adv_report_ind *p_param = (struct gapm_ext_adv_report_ind *)param;
|
||||
|
||||
#if 0
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
LOGI("%02x ", p_param->trans_addr.addr[i]);
|
||||
}
|
||||
LOGI("\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
//LOGI("msgid:%x \r\n", msgid);
|
||||
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);
|
||||
// device as slave
|
||||
if (p_param->role == GAPM_ROLE_SLAVE) {
|
||||
app_env.slave_conidx = conidx;
|
||||
app_env.slave_connected = true;
|
||||
}
|
||||
// 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);
|
||||
xc_ble_gatt_cli_mtu_exch(conidx, app_env.user_lid);
|
||||
}
|
||||
// #if (BLE_SEC_CON)
|
||||
// xc_ble_req_security(conidx, GAP_AUTH_REQ_SEC_CON_BOND);
|
||||
// #else // (BLE_SEC_CON)
|
||||
// xc_ble_req_security(conidx, GAP_AUTH_REQ_NO_MITM_BOND);
|
||||
// #endif // (BLE_SEC_CON)
|
||||
|
||||
// xc_ble_set_pkt_size(conidx, 251, 2120);
|
||||
|
||||
} break;
|
||||
case GAPC_DISCONNECT_IND: {
|
||||
struct gapc_disconnect_ind *p_param = (struct gapc_disconnect_ind *)param;
|
||||
LOGI("GAPC_DISCONNECT_IND conidx = 0x%x,%x reason = 0x%x\r\n", conidx, app_env.slave_conidx,
|
||||
p_param->reason);
|
||||
app_env.adv_state = APP_ADV_STATE_STOPPED;
|
||||
if (conidx == app_env.slave_conidx) {
|
||||
printf("app_start_advertising\n");
|
||||
app_env.slave_conidx = INVALID_DATA;
|
||||
app_env.slave_connected = false;
|
||||
app_start_advertising();
|
||||
}
|
||||
|
||||
} 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);
|
||||
LOGI("xc_ble_param_update_cfm\r\n", );
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
|
||||
static int app_second_adv_start_handler(ke_msg_id_t const msgid, void *p_param, ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
LOGI("start the sec adv \n");
|
||||
|
||||
start_second_adv = true;
|
||||
app_create_advertising_non_conn();
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
extern uint8_t app_sleep_flag;
|
||||
static int app_scan_start_handler(ke_msg_id_t const msgid, void *p_param, ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
LOGI("app_scan_start_handler \n");
|
||||
|
||||
// start_second_adv = true;
|
||||
// app_create_advertising_non_conn();
|
||||
#if APP_SCAN_FUNCTION
|
||||
app_start_scan();
|
||||
#endif
|
||||
if (app_mode == APP_SCAN_SLEEP_MODE) {
|
||||
ke_timer_set(APP_SCAN_STOP, TASK_APP, 200); // start open noconnect adv
|
||||
}
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
static int app_scan_stop_handler(ke_msg_id_t const msgid, void *p_param, ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
LOGI("app_scan_stop_handler \n");
|
||||
|
||||
/// start_second_adv = true;
|
||||
/// app_create_advertising_non_conn();
|
||||
#if APP_SCAN_FUNCTION
|
||||
app_stop_scanning();
|
||||
#endif
|
||||
ke_timer_set(APP_SCAN_START, TASK_APP, 900); // start open noconnect adv
|
||||
app_sleep_flag = 1;
|
||||
return (KE_MSG_CONSUMED);
|
||||
}
|
||||
static int app_mode_switch_handler(ke_msg_id_t const msgid, void *p_param, ke_task_id_t const dest_id,
|
||||
ke_task_id_t const src_id)
|
||||
{
|
||||
|
||||
if (app_mode == APP_SCAN_SLEEP_MODE) {
|
||||
app_mode = APP_CONN_MODE;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// app_mode = APP_SCAN_SLEEP_MODE;
|
||||
|
||||
// }
|
||||
printf("mode switch:%d\n", app_mode);
|
||||
app_switch_mode(app_mode);
|
||||
}
|
||||
void app_switch_mode(uint8_t mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case APP_CONN_MODE:
|
||||
app_sleep_flag = 0;
|
||||
printf("app_switch_mode\n");
|
||||
app_start_advertising();
|
||||
|
||||
ke_timer_set(APP_SECOND_ADV_START, TASK_APP, 400); // start open noconnect adv
|
||||
|
||||
break;
|
||||
|
||||
case APP_SCAN_SLEEP_MODE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Default State handlers definition. */
|
||||
KE_MSG_HANDLER_TAB(app){
|
||||
{APP_SCAN_START, (ke_msg_func_t)app_scan_start_handler},
|
||||
{APP_SCAN_STOP, (ke_msg_func_t)app_scan_stop_handler},
|
||||
{APP_TEST_MODE, (ke_msg_func_t)app_mode_switch_handler},
|
||||
{APP_SECOND_ADV_START, (ke_msg_func_t)app_second_adv_start_handler},
|
||||
{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)};
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
/// @} APPTASK
|
||||
@@ -0,0 +1,513 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file arch_main.c
|
||||
*
|
||||
* @brief Main loop of the application.
|
||||
*
|
||||
* Copyright (C) RivieraWaves 2009-2015
|
||||
*
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
/**-----------------------------------------------------------
|
||||
- \brief: Y68 GPIO ���Ź��ֲܷ�
|
||||
--------------------------------------------------------------
|
||||
(SPI-led)(led-B)(GPIO12/PWM2/SWCK )01----16(ANT )
|
||||
(led-R)(GPIO11/BOOT )02----15(GND )
|
||||
(led-G)(GPIO02/ADC12 )03----14(VCC/3V3 )
|
||||
(GPIO13/PWM3/SWD )04----13(XC2_OUT )
|
||||
(LPO_IN )05----12(XC1_IN )
|
||||
(LDO_OUT )06----11(GPIO18/ADC3/PGA-/TX )
|
||||
(GPIO01/PWM5 )07----10(GPIO19/ADC2/RX )
|
||||
(GPIO05/ADC7 )08----09(GPIO00/PWM4/ADC4/PGA+/SPGA)
|
||||
--------------------------------------------------------------
|
||||
- @note: GPIO11(BOOT) ��ֻ����������Ҳ������ⲿ��ƽ����
|
||||
------------------------------------------------------------*/
|
||||
|
||||
#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"
|
||||
#include "xc_drv_wdt.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 "pwm.h"
|
||||
#include "mode.h"
|
||||
#include "RF433.h"
|
||||
#include "rgblight.h"
|
||||
#include "timer.h"
|
||||
#include "fmc_spi.h"
|
||||
#include "key.h"
|
||||
#include "switch_s.h"
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @addtogroup DRIVERS
|
||||
* @{
|
||||
*printf
|
||||
*
|
||||
* ****************************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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)
|
||||
|
||||
//#define PWM7xD_EN;//注释后无需对码即可使用
|
||||
|
||||
|
||||
extern void clock_init(void);
|
||||
extern uint8_t ota_flag;
|
||||
volatile uint32_t pga_mon_timer;
|
||||
extern void clean_g24_buf(void);
|
||||
|
||||
uint32_t sync_100ms_discnt;
|
||||
|
||||
volatile uint64_t __attribute__((aligned(4))) g64vaira_begin = 0;
|
||||
|
||||
volatile uint64_t __attribute__((aligned(4))) gModeChangeTime = 0;
|
||||
volatile uint64_t __attribute__((aligned(4))) pixel_show_tick = 0;
|
||||
volatile uint32_t __attribute__((aligned(4))) gModeChangeTime_offset = 0;
|
||||
|
||||
volatile uint64_t __attribute__((aligned(4))) gModeChangeTime_temp = 0;
|
||||
volatile uint32_t __attribute__((aligned(4))) gModeChangeTime_offset_temp = 0;
|
||||
|
||||
volatile uint64_t __attribute__((aligned(4))) g64vaira_end = 0;
|
||||
|
||||
volatile uint32_t g_100ms_cnt = 0;
|
||||
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; //停止位:1位
|
||||
uart_cfg.WordLength = UART_DATA_8_BITS; //8个数据位
|
||||
uart_cfg.BaudRate = UART_BAUDRATE_115200;
|
||||
uart_cfg.HardwareFlowControl = UART_HWFC_DISABLE; //硬件流控制
|
||||
xc_uart_init(UART0_IDX, &uart_cfg);
|
||||
}
|
||||
|
||||
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);
|
||||
//h
|
||||
// LOGI("Flash RDID: 0x%08x\n", mid);
|
||||
|
||||
uint8_t ruid[16];
|
||||
xc_fmc_spi_flash_ruid(ruid);
|
||||
//h
|
||||
// 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];
|
||||
}
|
||||
}
|
||||
//h
|
||||
// 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 printf_null(void)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
__asm volatile("nop");
|
||||
__asm volatile("nop");
|
||||
__asm volatile("nop");
|
||||
__asm volatile("nop");
|
||||
}
|
||||
}
|
||||
|
||||
/* Zero the host global variable. */
|
||||
void rom_env_host_init()
|
||||
{
|
||||
uint8_t *ptr = (uint32_t *)(0x10000800);
|
||||
memset(ptr, 0, 0x10001300 - 0x10000800);
|
||||
|
||||
#if (_DEBUG_ == 1)
|
||||
rom_env.stack_printf = printf; // printf_null;//printf;
|
||||
#else
|
||||
rom_env.stack_printf = printf_null;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Add a protection field to determine if the stack is overflowing. */
|
||||
void stack_tag()
|
||||
{
|
||||
uint32_t StackPos;
|
||||
__IO uint32_t *pStack;
|
||||
StackPos = __get_MSP();
|
||||
//h
|
||||
// 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();
|
||||
rf433_gpio_init();
|
||||
#if (_DEBUG_ == 1)
|
||||
app_uart_init();
|
||||
|
||||
#endif
|
||||
//h
|
||||
// LOGI("ytt 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();
|
||||
AHB_CTL;
|
||||
/*
|
||||
************************************************************************************
|
||||
* Platform initialization
|
||||
************************************************************************************
|
||||
*/
|
||||
|
||||
// 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);
|
||||
// rf_xtal_cal_set(FREQUENCY_OFFSET); // 0-255; ����Ƶƫ
|
||||
#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();
|
||||
}
|
||||
|
||||
extern volatile uint8_t sv_lock;
|
||||
extern volatile uint8_t sv_txlen;
|
||||
extern uint8_t adv_evt_start; // adv event
|
||||
extern uint8_t evt_start; // conn event
|
||||
#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))
|
||||
|
||||
#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
|
||||
|
||||
int8_t deep_flag = 0;
|
||||
int16_t pluscnt = 0;
|
||||
uint8_t app_sleep_flag = 0;
|
||||
extern uint8_t app_mode;
|
||||
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
|
||||
}
|
||||
//#include "xc_drv_spi.h"
|
||||
//#include "xc_drv_spi_dma.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
#ifdef PWM7xD_EN
|
||||
Lock_Pwm7xd();
|
||||
#endif
|
||||
|
||||
|
||||
wdt_init();
|
||||
/* Set the broadcast address of the device. */
|
||||
board_init();
|
||||
fmc_spi_read();
|
||||
bluetooth_init();
|
||||
timer0_2_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)
|
||||
|
||||
// //static uint8_t i = 0;
|
||||
// if (WS2815_Init() != DMA_OK) {
|
||||
// DEBUG("WS2815 Init Failed!\n");
|
||||
// // return;
|
||||
// while (1);
|
||||
// }else{
|
||||
// DEBUG("WS2815 Init Finish\n");
|
||||
// }
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
//Twhile (1) {
|
||||
// schedule all pending events
|
||||
//T rwip_schedule();
|
||||
#if !FAST_OTA
|
||||
//T xc_ota_schedule();
|
||||
#endif
|
||||
#if OTA_AES_USED
|
||||
process_aes_decrypt();
|
||||
#endif
|
||||
|
||||
chx_gpio_init();
|
||||
app_key_init();
|
||||
led_gpio_init();
|
||||
switch_init();
|
||||
|
||||
|
||||
|
||||
if(flash_ch1_state)
|
||||
{
|
||||
xc_gpio_write_pin(GPIO_5,GPIO_PIN_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
xc_gpio_write_pin(GPIO_5,GPIO_PIN_RESET);
|
||||
}
|
||||
if(flash_ch2_state)
|
||||
{
|
||||
xc_gpio_write_pin(GPIO_2,GPIO_PIN_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
xc_gpio_write_pin(GPIO_2,GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
//startTimer(&timer1,1);
|
||||
while (1) {
|
||||
|
||||
TaskProcess();
|
||||
xc_wdt_reload(); // TOOD
|
||||
|
||||
// if(!timer1.active&&timer1.count==0){
|
||||
//
|
||||
// stopTimer(&timer1);
|
||||
// //startTimer(&timer1,60000);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if (SLEEP_ENABLE)
|
||||
#if !FAST_OTA
|
||||
if (!ota_flag)
|
||||
#endif
|
||||
{
|
||||
sleep_schedule();
|
||||
}
|
||||
#endif // (SLEEP_ENABLE)
|
||||
// ble_trans_loop();
|
||||
|
||||
//T }
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
}
|
||||
|
||||
/// @} DRIVERS
|
||||
@@ -0,0 +1,112 @@
|
||||
#include "fmc.h"
|
||||
#include "xc_drv_fmc_spi.h"
|
||||
#include "xc_drv_fmc_spi_dma.h"
|
||||
#include "rgblight.h"
|
||||
#include "mode.h"
|
||||
#include "PWM.h"
|
||||
#include "RF433.h"
|
||||
#include "xc60xx.h"
|
||||
|
||||
|
||||
//uint8_t app_data[256] = {0};
|
||||
uint8_t r_data[256];
|
||||
|
||||
|
||||
void read_user_data(void)
|
||||
{
|
||||
uint8_t i = 2;
|
||||
|
||||
Mode = r_data[i++];
|
||||
Brightness = r_data[i++];
|
||||
Brightness_buff=Brightness;
|
||||
Color.R = r_data[i++];
|
||||
Color.G = r_data[i++];
|
||||
Color.B = r_data[i++];
|
||||
sspeed = r_data[i++];
|
||||
deviceStatus = r_data[i++];
|
||||
|
||||
r_DutyCycle = r_data[i++];
|
||||
g_DutyCycle = r_data[i++];
|
||||
b_DutyCycle = r_data[i++];
|
||||
|
||||
is_time = r_data[i++];
|
||||
flag_1h = r_data[i++];
|
||||
adress = r_data[i++];
|
||||
adress =adress<<8|r_data[i++];
|
||||
match_success = r_data[i++];
|
||||
}
|
||||
|
||||
|
||||
void wright_user_data(void)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
app_data[i++] = 0xAA;
|
||||
app_data[i++] = 0x55;
|
||||
|
||||
app_data[i++] = Mode;
|
||||
app_data[i++] = Brightness;
|
||||
|
||||
app_data[i++] = Color.R;
|
||||
app_data[i++] = Color.G;
|
||||
app_data[i++] = Color.B;
|
||||
|
||||
app_data[i++] = sspeed;
|
||||
app_data[i++] = deviceStatus;
|
||||
app_data[i++] = r_DutyCycle;
|
||||
app_data[i++] = g_DutyCycle;
|
||||
app_data[i++] = b_DutyCycle;
|
||||
app_data[i++] = is_time;
|
||||
app_data[i++] = flag_1h;
|
||||
app_data[i++] = adress>>8;
|
||||
app_data[i++] = adress&0xFF;
|
||||
app_data[i++] = match_success;
|
||||
}
|
||||
|
||||
void fmc_read(void)
|
||||
{
|
||||
xc_fmc_spi_flash_read(w_addr, r_data, FLASH_PAGE_SIZE);
|
||||
if(r_data[0] == 0xAA&&r_data[1] == 0x55){
|
||||
read_user_data();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint8_t flash_start=0;
|
||||
uint16_t flash_Time=0;
|
||||
|
||||
void Set_flashTime(){
|
||||
// if(flash_Time==1){
|
||||
// flash_start=1;
|
||||
// }
|
||||
// if(flash_Time)flash_Time--;
|
||||
}
|
||||
|
||||
void W_Flash(){
|
||||
if(flash_Time==1){
|
||||
wright_user_data();
|
||||
|
||||
xc_fmc_spi_flash_erase_sector(w_addr);
|
||||
GLOBAL_INT_DISABLE();
|
||||
xc_fmc_spi_flash_write(w_addr,app_data,FLASH_PAGE_SIZE);
|
||||
GLOBAL_INT_RESTORE();
|
||||
memset(r_data, 0xFF, sizeof(r_data));
|
||||
xc_fmc_spi_flash_read(w_addr, r_data, FLASH_PAGE_SIZE);
|
||||
for(uint8_t i=0;i<16;i++){
|
||||
DEBUG("adress=%d\r\n",r_data[i]);
|
||||
}
|
||||
// __enable_irq();
|
||||
flash_start=0;
|
||||
}
|
||||
if(flash_Time){
|
||||
flash_Time--;
|
||||
}
|
||||
}
|
||||
|
||||
// GLOBAL_INT_DISABLE();
|
||||
// FMC_SPI_Flash_WritePage(op_flash.op_addr, op_flash.op_buff, 256);
|
||||
// GLOBAL_INT_RESTORE();
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*!
|
||||
* \file fmc_spi.h
|
||||
*
|
||||
* \brief The head file of fmc_spi.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 __FMC_H__
|
||||
#define __FMC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
#define w_addr 0x1FF00
|
||||
extern uint8_t flash_start;
|
||||
extern uint16_t flash_Time;
|
||||
|
||||
extern uint8_t app_data[256];
|
||||
extern void fmc_read(void);
|
||||
extern void W_Flash();
|
||||
void Set_flashTime();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __FMC_SPI_H__ */
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/*!
|
||||
* \file fmc_spi.c
|
||||
*
|
||||
* \brief Target fmc spi 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 "fmc_spi.h"
|
||||
#include "xc_drv_fmc_spi.h"
|
||||
#include "xc_drv_fmc_spi_dma.h"
|
||||
#include "rgblight.h"
|
||||
#include "mode.h"
|
||||
#include "PWM.h"
|
||||
#include "RF433.h"
|
||||
#include "xc60xx.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in]
|
||||
* @param[in]
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
// uint8_t data[FLASH_PAGE_SIZE];
|
||||
uint8_t r_data[256];
|
||||
unsigned char get_checksum(unsigned char *ptrdata, unsigned char length)
|
||||
{
|
||||
unsigned char i;
|
||||
unsigned char CheckSum = 0;
|
||||
|
||||
for(i=0; i<length; i++)
|
||||
{
|
||||
CheckSum += *ptrdata;
|
||||
ptrdata++;
|
||||
}
|
||||
return CheckSum;
|
||||
}
|
||||
|
||||
void read_user_data(void)
|
||||
{
|
||||
if(r_data[25] == get_checksum(&r_data[2],23))
|
||||
{
|
||||
adress_H_array[0]=r_data[2];
|
||||
adress_H_array[1]=r_data[3];
|
||||
adress_H_array[2]=r_data[4];
|
||||
adress_H_array[3]=r_data[5];
|
||||
adress_H_array[4]=r_data[6];
|
||||
adress_L_array[0]=r_data[7];
|
||||
adress_L_array[1]=r_data[8];
|
||||
adress_L_array[2]=r_data[9];
|
||||
adress_L_array[3]=r_data[10];
|
||||
adress_L_array[4]=r_data[11];
|
||||
adress_ch_flag[0]=r_data[12];
|
||||
adress_ch_flag[1]=r_data[13];
|
||||
adress_ch_flag[2]=r_data[14];
|
||||
adress_ch_flag[3]=r_data[15];
|
||||
adress_ch_flag[4]=r_data[16];
|
||||
rf433_value[0]= r_data[17];
|
||||
rf433_value[1]= r_data[18];
|
||||
rf433_value[2]= r_data[19];
|
||||
rf433_value[3]= r_data[20];
|
||||
rf433_value[4]=r_data[21];
|
||||
adress_index=r_data[22];
|
||||
flash_ch1_state=r_data[23];
|
||||
flash_ch2_state=r_data[24];
|
||||
|
||||
}
|
||||
|
||||
// DEBUG("read flash_ch1_state %d\r\n",flash_ch1_state);
|
||||
// DEBUG("read flash_ch2_state %d\r\n",flash_ch2_state);
|
||||
// DEBUG("read flash_ch3_state %d\r\n",flash_ch3_state);
|
||||
// DEBUG("read adress_index %d\r\n",adress_index);
|
||||
// DEBUG("read adress_H_array[0] %d\r\n",adress_H_array[0]);
|
||||
// DEBUG("read adress_H_array[1] %d\r\n",adress_H_array[1]);
|
||||
// DEBUG("read adress_H_array[2] %d\r\n",adress_H_array[2]);
|
||||
// DEBUG("read adress_H_array[3] %d\r\n",adress_H_array[3]);
|
||||
// DEBUG("read adress_H_array[4] %d\r\n",adress_H_array[4]);
|
||||
// DEBUG("read adress_L_array[0] %d\r\n",adress_L_array[0]);
|
||||
// DEBUG("read adress_L_array[1] %d\r\n",adress_L_array[1]);
|
||||
// DEBUG("read adress_L_array[2] %d\r\n",adress_L_array[2]);
|
||||
// DEBUG("read adress_L_array[3] %d\r\n",adress_L_array[3]);
|
||||
// DEBUG("read adress_L_array[4] %d\r\n",adress_L_array[4]);
|
||||
|
||||
|
||||
// if(r_data[31] == get_checksum(&r_data[2],29))
|
||||
// {
|
||||
//// Mode = r_data[2];
|
||||
//// Brightness_buff = r_data[3];
|
||||
//// Brightness=Brightness_buff;
|
||||
//// Color.R = r_data[4];
|
||||
//// Color.G = r_data[5];
|
||||
//// Color.B = r_data[6];
|
||||
//// sspeed = r_data[7];
|
||||
//// deviceStatus = r_data[8];
|
||||
|
||||
//// Pwm2Duty = r_data[9];
|
||||
//// Pwm1Duty = r_data[10];
|
||||
//// Pwm0Duty = r_data[11];
|
||||
////
|
||||
//// is_time = r_data[12];
|
||||
//// flag_1h = r_data[13];
|
||||
//// adress = r_data[14];
|
||||
//// match_success = r_data[15];
|
||||
////
|
||||
//// adress_H_array[0]=r_data[16];
|
||||
//// adress_L_array[0]=r_data[17];
|
||||
//// adress_H_array[1]=r_data[18];
|
||||
//// adress_L_array[1]=r_data[19];
|
||||
//// adress_H_array[2]=r_data[20];
|
||||
//// adress_L_array[2]=r_data[21];
|
||||
//// adress_H_array[3]=r_data[22];
|
||||
//// adress_L_array[3]=r_data[23];
|
||||
//// adress_H_array[4]=r_data[24];
|
||||
//// adress_L_array[4]=r_data[25];
|
||||
//// pwm_frequency_buff=r_data[26];
|
||||
//// flag_1h = (r_data[30] << 24) | (r_data[29] << 16) | (r_data[28] << 8) | r_data[27];
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void wright_user_data(void)
|
||||
{
|
||||
|
||||
app_data[0] = 0xAA;
|
||||
app_data[1] = 0x55;
|
||||
app_data[2] = adress_H_array[0];
|
||||
app_data[3] = adress_H_array[1];
|
||||
app_data[4] = adress_H_array[2];
|
||||
app_data[5] = adress_H_array[3];
|
||||
app_data[6] = adress_H_array[4];
|
||||
app_data[7] = adress_L_array[0];
|
||||
app_data[8] = adress_L_array[1];
|
||||
app_data[9] = adress_L_array[2];
|
||||
app_data[10] =adress_L_array[3];
|
||||
app_data[11] =adress_L_array[4];
|
||||
app_data[12] =adress_ch_flag[0];
|
||||
app_data[13] =adress_ch_flag[1];
|
||||
app_data[14] =adress_ch_flag[2];
|
||||
app_data[15] =adress_ch_flag[3];
|
||||
app_data[16] =adress_ch_flag[4];
|
||||
app_data[17] =rf433_value[0];
|
||||
app_data[18] =rf433_value[1];
|
||||
app_data[19] =rf433_value[2];
|
||||
app_data[20] =rf433_value[3];
|
||||
app_data[21] =rf433_value[4];
|
||||
app_data[22] = adress_index;
|
||||
app_data[23] = flash_ch1_state;
|
||||
app_data[24] = flash_ch2_state;
|
||||
|
||||
|
||||
|
||||
app_data[25] = get_checksum(&app_data[2],23);
|
||||
|
||||
// app_data[0] = 0xAA;
|
||||
// app_data[1] = 0x55;
|
||||
|
||||
// app_data[2] = Mode;
|
||||
// app_data[3] = Brightness_buff;
|
||||
//
|
||||
// app_data[4] = Color.R;
|
||||
// app_data[5] = Color.G;
|
||||
// app_data[6] = Color.B;
|
||||
//
|
||||
// app_data[7] = sspeed;
|
||||
// app_data[8] = deviceStatus;
|
||||
// app_data[9] = Pwm2Duty;
|
||||
// app_data[10] = Pwm1Duty;
|
||||
// app_data[11] = Pwm0Duty;
|
||||
// app_data[12] = is_time;
|
||||
// app_data[13] = flag_1h;
|
||||
// app_data[15] = match_success;
|
||||
//
|
||||
//
|
||||
//
|
||||
// app_data[16]=adress_H_array[0];
|
||||
// app_data[17]=adress_L_array[0];
|
||||
// app_data[18]=adress_H_array[1];
|
||||
// app_data[19]=adress_L_array[1];
|
||||
// app_data[20]=adress_H_array[2];
|
||||
// app_data[21]=adress_L_array[2];
|
||||
// app_data[22]=adress_H_array[3];
|
||||
// app_data[23]=adress_L_array[3];
|
||||
// app_data[24]=adress_H_array[4];
|
||||
// app_data[25]=adress_L_array[4];
|
||||
// app_data[26]=pwm_frequency_buff;
|
||||
// //
|
||||
// app_data[27]=(flag_1h >> 0) & 0xFF; // 0x89;
|
||||
// app_data[28]=(flag_1h >> 8) & 0xFF; // 0x67
|
||||
// app_data[29]=(flag_1h >> 16) & 0xFF; // 0x45
|
||||
// app_data[30]=(flag_1h >> 24) & 0xFF; // 0x23
|
||||
// app_data[31] = get_checksum(&app_data[2], 29);
|
||||
// DEBUG("д\r\n");
|
||||
}
|
||||
|
||||
|
||||
void fmc_spi_read(void)
|
||||
{
|
||||
// xc_fmc_spi_flash_wake_up();
|
||||
|
||||
xc_fmc_spi_flash_read_page(0x1E000,&r_data, FLASH_PAGE_SIZE);
|
||||
if(r_data[0] == 0xAA&&r_data[1] == 0x55)
|
||||
{
|
||||
read_user_data();
|
||||
__nop();
|
||||
//// for(uint8_t i=0;i<16;i++){
|
||||
//// DEBUG("app_data=%d\r\n",r_data[i]);
|
||||
//// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*!
|
||||
* \file fmc_spi.h
|
||||
*
|
||||
* \brief The head file of fmc_spi.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 __FMC_SPI_H__
|
||||
#define __FMC_SPI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern uint8_t data[];
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void fmc_spi_wright(void);
|
||||
void fmc_spi_dma_demo(void);
|
||||
void fmc_spi_read(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __FMC_SPI_H__ */
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,386 @@
|
||||
/*!
|
||||
* \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"
|
||||
#include "rgblight.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;
|
||||
KeyMessageCallback key_callback = NULL;
|
||||
|
||||
|
||||
KeyClickState_t g_key_click_state = {
|
||||
.click_count = 0,
|
||||
.click_interval_cnt = 0,
|
||||
.last_click_key = NO_KEY,
|
||||
.is_waiting_click = 0
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
static uint16_t app_key_click_detection(uint16_t key_val);
|
||||
static void key_click_state_reset(void);
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
static void key_click_state_reset(void)
|
||||
{
|
||||
g_key_click_state.click_count = 0;
|
||||
g_key_click_state.click_interval_cnt = 0;
|
||||
g_key_click_state.last_click_key = NO_KEY;
|
||||
g_key_click_state.is_waiting_click = 0;
|
||||
}
|
||||
|
||||
|
||||
void app_key_register_callback(KeyMessageCallback callback)
|
||||
{
|
||||
key_callback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
else if(key_down_count == KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = (curren_key_val | KEY_LONG_DOWN);
|
||||
key_click_state_reset();
|
||||
}
|
||||
key_up_count = 0;
|
||||
|
||||
return key_num;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief app_new_key_detection
|
||||
* @details ????/????
|
||||
* @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);
|
||||
last_key_val = 0;
|
||||
key_click_state_reset();
|
||||
}
|
||||
// ????(?????)
|
||||
else if (key_down_count >= KEY_DOWN_TIMER && key_down_count < KEY_LONG_TIMER)
|
||||
{
|
||||
// ????/??
|
||||
key_num = app_key_click_detection(last_key_val);
|
||||
}
|
||||
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);
|
||||
key_click_state_reset();
|
||||
}
|
||||
// ??????
|
||||
else if (key_down_count >= KEY_DOWN_TIMER && key_down_count < KEY_LONG_TIMER)
|
||||
{
|
||||
key_num = app_key_click_detection(last_key_val);
|
||||
}
|
||||
last_key_val = curren_key_val;
|
||||
key_down_count = 0;
|
||||
key_up_count = 0;
|
||||
}
|
||||
|
||||
return key_num;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief app_key_click_detection
|
||||
* @details ??/??/??/????(???MODE?,?????????)
|
||||
* @param key_val ???
|
||||
* @retval key_num ????(??/??/??/??)
|
||||
*/
|
||||
static uint16_t app_key_click_detection(uint16_t key_val)
|
||||
{
|
||||
uint16_t key_num = NO_KEY;
|
||||
|
||||
// ?????????
|
||||
if (key_val == NO_KEY)
|
||||
{
|
||||
key_click_state_reset();
|
||||
return NO_KEY;
|
||||
}
|
||||
|
||||
// ???MODE?(REC_KEY_UP)???,?????????
|
||||
uint8_t is_mode_key = (key_val == REC_KEY_UP) ? 1 : 0;
|
||||
|
||||
// 1. ????:??????
|
||||
if (g_key_click_state.last_click_key == NO_KEY)
|
||||
{
|
||||
g_key_click_state.click_count = 1;
|
||||
g_key_click_state.last_click_key = key_val;
|
||||
g_key_click_state.is_waiting_click = 1;
|
||||
g_key_click_state.click_interval_cnt = 0;
|
||||
return NO_KEY; // ?????????,??????
|
||||
}
|
||||
|
||||
// 2. ??????:????????,??????
|
||||
if (g_key_click_state.last_click_key != key_val)
|
||||
{
|
||||
key_num = (g_key_click_state.last_click_key | KEY_SHORT_UP); // ??????
|
||||
key_click_state_reset();
|
||||
// ??????
|
||||
g_key_click_state.click_count = 1;
|
||||
g_key_click_state.last_click_key = key_val;
|
||||
g_key_click_state.is_waiting_click = 1;
|
||||
g_key_click_state.click_interval_cnt = 0;
|
||||
return key_num;
|
||||
}
|
||||
|
||||
// 3. ????????:??+1
|
||||
g_key_click_state.click_count++;
|
||||
g_key_click_state.click_interval_cnt = 0;
|
||||
|
||||
// ?MODE?????
|
||||
if (is_mode_key)
|
||||
{
|
||||
// ????
|
||||
if (g_key_click_state.click_count == 2)
|
||||
{
|
||||
key_num = (key_val | KEY_DOUBLE_CLICK);
|
||||
// ??????,??????/??
|
||||
return key_num;
|
||||
}
|
||||
// ????
|
||||
else if (g_key_click_state.click_count == 4)
|
||||
{
|
||||
key_num = (key_val | KEY_QUAD_CLICK);
|
||||
// ??????,??????
|
||||
return key_num;
|
||||
}
|
||||
// ????
|
||||
else if (g_key_click_state.click_count == 6)
|
||||
{
|
||||
key_num = (key_val | KEY_SIX_CLICK);
|
||||
key_click_state_reset(); // ????????
|
||||
return key_num;
|
||||
}
|
||||
// ?????????
|
||||
else if (g_key_click_state.click_count > 6)
|
||||
{
|
||||
key_num = (key_val | KEY_SHORT_UP);
|
||||
key_click_state_reset();
|
||||
return key_num;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ?MODE????????????
|
||||
key_num = (key_val | KEY_SHORT_UP);
|
||||
key_click_state_reset();
|
||||
return key_num;
|
||||
}
|
||||
|
||||
return NO_KEY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 GPIO????(???GPIO18-MODE?)
|
||||
* @param void
|
||||
* @retval key_val ???
|
||||
*/
|
||||
uint16_t gpio_key_check(void)
|
||||
{
|
||||
uint16_t key_val = NO_KEY;
|
||||
|
||||
if (IS_KEY_DOWN(KEY_MODE)) // GPIO_18 - MODE?
|
||||
{
|
||||
key_val = REC_KEY_UP; // 0x0002 MODE?
|
||||
}
|
||||
|
||||
// ??ON_OFF?SPEED?
|
||||
// else if ( IS_KEY_DOWN(KEY_ON_OFF) ) // GPIO_19
|
||||
// {
|
||||
// key_val = REC_KEY; // 0x0001 ON_OFF?
|
||||
// }
|
||||
// else if ( IS_KEY_DOWN(KEY_SPEED) ) // GPIO_17
|
||||
// {
|
||||
// key_val = REC_KEY_DOWN; // 0x0004 SPEED?
|
||||
// }
|
||||
return key_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief app_key_scan
|
||||
* @details ????(??10ms/???)
|
||||
* @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 && key_callback != NULL)
|
||||
{
|
||||
key_callback(key_num);
|
||||
}
|
||||
|
||||
|
||||
if (g_key_click_state.is_waiting_click)
|
||||
{
|
||||
g_key_click_state.click_interval_cnt++;
|
||||
|
||||
|
||||
uint16_t interval_timer = (g_key_click_state.click_count >= 2) ? KEY_QUAD_INTERVAL_TIMER : KEY_DOUBLE_INTERVAL_TIMER;
|
||||
|
||||
|
||||
if (g_key_click_state.click_interval_cnt >= interval_timer)
|
||||
{
|
||||
|
||||
if (g_key_click_state.click_count == 1)
|
||||
{
|
||||
key_num = (g_key_click_state.last_click_key | KEY_SHORT_UP); // ??
|
||||
if (key_num != NO_KEY && key_callback != NULL)
|
||||
{
|
||||
key_callback(key_num);
|
||||
}
|
||||
}
|
||||
|
||||
else if (g_key_click_state.click_count == 2 || g_key_click_state.click_count == 4)
|
||||
{
|
||||
key_click_state_reset();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
key_click_state_reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief app_key_init
|
||||
* @details ?????
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void app_key_init(void)
|
||||
{
|
||||
GPIO_InitCfg_t GPIO_InitCfg = { 0 };
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0; // ???GPIO0
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx; // ??GPIO??
|
||||
GPIO_InitCfg.Pull = GPIO_PULLUP; // ????
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_INPUT; // ????
|
||||
GPIO_InitCfg.Int = NOT_INT; // ????
|
||||
GPIO_InitCfg.Pin = GPIO_18; // GPIO18(MODE?)
|
||||
xc_gpio_init(&GPIO_InitCfg);
|
||||
|
||||
// ??ON_OFF?SPEED????
|
||||
// GPIO_InitCfg.Pin = GPIO_19; // GPIO19(ON_OFF?)
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
// GPIO_InitCfg.Pin = GPIO_17; // GPIO17(SPEED?)
|
||||
// xc_gpio_init(&GPIO_InitCfg);
|
||||
|
||||
app_key_register_callback(app_key_callback_handler); // ??????
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/*!
|
||||
* \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_SPEED GPIO_17
|
||||
#define KEY_ON_OFF GPIO_19
|
||||
#define KEY_MODE GPIO_18
|
||||
|
||||
// ????/????(??:????,??10ms/?)
|
||||
#define KEY_DOWN_TIMER 2 // ????(20ms,??????)
|
||||
#define KEY_LONG_TIMER 60 // ????(600ms)
|
||||
#define KEY_UP_TIMER 2 // ??????(20ms)
|
||||
|
||||
// ????(????:300ms????????)
|
||||
#define KEY_DOUBLE_INTERVAL_TIMER 30 // ????(30*10ms=300ms,????????)
|
||||
#define KEY_QUAD_INTERVAL_TIMER 80 // ??/????(80*10ms=800ms,??????)
|
||||
|
||||
// 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 KEY_DOUBLE_CLICK 0X0800 // ??
|
||||
#define KEY_QUAD_CLICK 0X1000 // ??
|
||||
#define KEY_SIX_CLICK 0X2000 // ??
|
||||
|
||||
#define NO_KEY 0
|
||||
|
||||
#define REC_KEY KEY_NUM1
|
||||
#define REC_KEY_UP KEY_NUM2
|
||||
#define REC_KEY_DOWN KEY_NUM3
|
||||
|
||||
// ??????
|
||||
#define ON_OFF_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 MODE_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 SPEED_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)
|
||||
|
||||
// ????(???MODE?,??????)
|
||||
#define MODE_DOUBLE_CLICK (REC_KEY_UP | KEY_DOUBLE_CLICK)
|
||||
#define MODE_QUAD_CLICK (REC_KEY_UP | KEY_QUAD_CLICK)
|
||||
#define MODE_SIX_CLICK (REC_KEY_UP | KEY_SIX_CLICK)
|
||||
#define ON_OFF_DOUBLE_CLICK (REC_KEY | KEY_DOUBLE_CLICK)
|
||||
#define SPEED_DOUBLE_CLICK (REC_KEY_DOWN | KEY_DOUBLE_CLICK)
|
||||
|
||||
// ??/??(??,?MODE?)
|
||||
#define ON_OFF_QUAD_CLICK (REC_KEY | KEY_QUAD_CLICK)
|
||||
#define SPEED_QUAD_CLICK (REC_KEY_DOWN | KEY_QUAD_CLICK)
|
||||
#define ON_OFF_SIX_CLICK (REC_KEY | KEY_SIX_CLICK)
|
||||
#define SPEED_SIX_CLICK (REC_KEY_DOWN | KEY_SIX_CLICK)
|
||||
|
||||
typedef void (*KeyMessageCallback)(uint16_t key_msg);
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
// ???????
|
||||
typedef struct
|
||||
{
|
||||
uint16_t click_count; // ????
|
||||
uint16_t click_interval_cnt; // ??????
|
||||
uint16_t last_click_key; // ????????
|
||||
uint8_t is_waiting_click; // ????????(0:? 1:?)
|
||||
} KeyClickState_t;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern KeyClickState_t g_key_click_state;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void app_key_init(void);
|
||||
void app_key_scan(void);
|
||||
void app_op_flash(void);
|
||||
void app_op_flash_on(void);
|
||||
void app_key_callback_handler(uint16_t key_value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __KEY_H__ */
|
||||
@@ -0,0 +1,120 @@
|
||||
#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 "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;
|
||||
}
|
||||
uint8_t app_op_flash_flag = 2;
|
||||
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);
|
||||
GLOBAL_INT_RESTORE();
|
||||
op_flash.op_state = OP_IDEL;
|
||||
|
||||
app_op_flash_flag = 2;
|
||||
//DEBUG("finish\n");
|
||||
}
|
||||
} 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();
|
||||
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;
|
||||
app_op_flash_flag = 1;
|
||||
//DEBUG("olok\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t app_data[128] = {0};
|
||||
|
||||
//uint16_t app_op_flash_start = 10000;
|
||||
void app_op_flash(void)
|
||||
{
|
||||
if(op_flash.op_state == OP_IDEL&&app_op_flash_flag ==0)
|
||||
{
|
||||
ble_flash_later_page_erase(0x1E000);
|
||||
|
||||
}
|
||||
else if(op_flash.op_state == OP_IDEL &&app_op_flash_flag ==1)
|
||||
{
|
||||
ble_flash_later_write_page(app_data,0x1E000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void app_op_flash_on(void)
|
||||
{
|
||||
if(app_op_flash_flag==2)
|
||||
app_op_flash_flag=0;
|
||||
wright_user_data();
|
||||
|
||||
// DEBUG("zhixing\n");
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#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_WIAT_FLASH_TEST,
|
||||
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 app_op_flash_on(void);
|
||||
void app_op_flash(void);
|
||||
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_
|
||||
|
||||
|
||||
@@ -0,0 +1,519 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @file ota_m4.c
|
||||
*
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2022 - 2025, XinChip
|
||||
* All rights reserved.p
|
||||
*
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
#include "rwip_config.h"
|
||||
|
||||
#if (BLE_APP_PRESENT)
|
||||
|
||||
#include "ota_flash_interface.h"
|
||||
#include "ota_protocol.h"
|
||||
#include "ota_server.h"
|
||||
#include "xc_drv_wdt.h"
|
||||
uint8_t ota_flag = 0;
|
||||
extern struct app_env_tag app_env;
|
||||
static struct fotas_write_env fotas_write_env;
|
||||
__RAM_EM struct fotas_env fota_env;
|
||||
struct fotas_flag fotas_status = {1, 1, TRUES, FALSE, 0, 0, 0, 1, 0};
|
||||
|
||||
uint8_t *get_fota_env_addr(uint16_t len)
|
||||
{
|
||||
if (len > FOTA_PAGE_NUM * FLASH_PAGE_SIZE + 20) {
|
||||
// LOGI(" len error\n ");
|
||||
return NULL;
|
||||
}
|
||||
return &fota_env;
|
||||
}
|
||||
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_ReloadValue_0xFFFF;
|
||||
|
||||
xc_ota_wdt_init(&wdt_cfg);
|
||||
xc_wdt_start();
|
||||
}
|
||||
|
||||
static void fota_status_set(uint8_t status) { fota_env.status = status; }
|
||||
|
||||
static uint8_t fota_status_get(void) { return fota_env.status; }
|
||||
|
||||
// DEV->APP RSP OR CMD
|
||||
void xc_fota_dev_ack_cmd(uint16_t sn, uint8_t cmd,
|
||||
uint8_t data_or_atype, // data or ack type
|
||||
uint16_t fnum_or_para) // frame num or parameter
|
||||
{
|
||||
fota_env.ack.sn = sn;
|
||||
fota_env.ack.cmd = cmd;
|
||||
fota_env.ack.data_or_atype = data_or_atype;
|
||||
fota_env.ack.fnum_or_para = fnum_or_para;
|
||||
FOTAS_NOTIFY((uint8_t *)&fota_env.ack, sizeof(fota_env.ack),
|
||||
OTA_SVC_TX_CHAR_VAL);
|
||||
}
|
||||
|
||||
// The sector CRC check and write data to flash.
|
||||
static void xc_fotas_flash_write()
|
||||
{
|
||||
// only 1 time
|
||||
if (fotas_status.first_pack_write_flag) {
|
||||
fotas_status.first_pack_write_flag = FALSE;
|
||||
fotas_status.sector_erase_flag = 1;
|
||||
for (int j = 0; j < 256; j++) {
|
||||
fotas_write_env.para_buf[j] = fota_env.sector_buf[0][j];
|
||||
}
|
||||
|
||||
// 0x1b000
|
||||
fotas_write_env.erase_addr = (fotas_write_env.para_buf[27] << 24) +
|
||||
(fotas_write_env.para_buf[26] << 16) +
|
||||
(fotas_write_env.para_buf[25] << 8) +
|
||||
(fotas_write_env.para_buf[24]); // data
|
||||
fotas_write_env.write_addr =
|
||||
(fotas_write_env.para_buf[27] << 24) +
|
||||
(fotas_write_env.para_buf[26] << 16) +
|
||||
(fotas_write_env.para_buf[25] << 8) +
|
||||
(fotas_write_env.para_buf[24]); // start para
|
||||
LOGI(" ota parameter fotas_write_env.write_addr=%x "
|
||||
"fotas_write_env.erase_addr=%x\n ",
|
||||
fotas_write_env.write_addr, fotas_write_env.erase_addr);
|
||||
|
||||
FLASH_SECTOR_ERASE(fotas_write_env.erase_addr);
|
||||
fotas_status.wtite_flag = 1;
|
||||
} else // second sector
|
||||
{
|
||||
ble_flash_later_write_page(fota_env.sector_buf[0],
|
||||
fotas_write_env.write_addr);
|
||||
|
||||
fotas_status.wtite_flag = 1;
|
||||
fotas_write_env.write_addr += 256;
|
||||
}
|
||||
fotas_write_env.erase_addr +=
|
||||
256; // The erase address needs to be aligned to 4096
|
||||
|
||||
LOGI(".");
|
||||
|
||||
fotas_write_env.cur_num = 0;
|
||||
}
|
||||
|
||||
// first sector, 15 page
|
||||
void ota_write_flash()
|
||||
{
|
||||
// LOGI("yes %x
|
||||
// %d\n",fotas_write_env.write_addr,fotas_status.wtitten_page_num);
|
||||
ble_flash_later_write_page(
|
||||
fota_env.sector_buf[fotas_status.wtitten_page_num],
|
||||
fotas_write_env.write_addr);
|
||||
fotas_write_env.write_addr += 256;
|
||||
fotas_status.wtitten_page_num += 1;
|
||||
fotas_write_env.erase_addr += 256;
|
||||
}
|
||||
// OTA data handler.
|
||||
|
||||
void xc_fota_write_data_handle(uint8_t *buffer, uint8_t cmd2)
|
||||
{
|
||||
uint16_t pid;
|
||||
struct img_hdr_t *img;
|
||||
struct fota_data *fota_data1;
|
||||
struct fota_data_att *data_att;
|
||||
uint16_t sn;
|
||||
uint8_t cmd;
|
||||
uint16_t len;
|
||||
uint16_t sw_ver;
|
||||
uint16_t rom_ver;
|
||||
|
||||
(void)sn;
|
||||
(void)cmd;
|
||||
(void)len;
|
||||
|
||||
if (fota_status_get() == FOTAS_DEV_READY) {
|
||||
switch (cmd2) {
|
||||
// FOTAS_STA_CMD = 1
|
||||
case FOTAS_STA_CMD: // 1.3 App->Dev, ota start req
|
||||
LOGI("line=%d, app->dev 1.3, ver same dev->app 2.1, ver diff "
|
||||
"dev->app 1.4\n",
|
||||
__LINE__);
|
||||
img = (struct img_hdr_t *)buffer;
|
||||
sn = img->sn;
|
||||
cmd = img->cmd;
|
||||
len = img->len;
|
||||
sw_ver = img->sw_ver;
|
||||
rom_ver = img->rom_ver;
|
||||
fota_env.crc = img->crc;
|
||||
fota_env.bin_size = img->bin_size;
|
||||
fota_env.pack_num = img->pack_num;
|
||||
|
||||
fota_status_set(FOTAS_DEV_READY);
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_CMD, FOTAS_TRANS_SUC,
|
||||
1); // 1 means fnum
|
||||
break;
|
||||
// FOTAS_INFO_CMD = 3
|
||||
case FOTAS_INFO_CMD: // 3.3 App->Dev, ota current info packet
|
||||
LOGI("line=%d,current info packet, 3.3 app->dev, 4.1 dev->app \n",
|
||||
__LINE__);
|
||||
if (fotas_status.sector_erase_flag &&
|
||||
(fotas_write_env.erase_addr % 4096 == 0)) {
|
||||
ble_flash_later_sector_erase(fotas_write_env.erase_addr);
|
||||
LOGI("addr:%x\n", fotas_write_env.erase_addr);
|
||||
}
|
||||
|
||||
data_att = (struct fota_data_att *)buffer;
|
||||
fota_env.data_att.sn = data_att->sn;
|
||||
fota_env.data_att.len = data_att->len;
|
||||
fota_env.data_att.cmd = data_att->cmd;
|
||||
fota_env.data_att.segment_id = data_att->segment_id;
|
||||
fota_env.data_att.sector_size = data_att->sector_size; // 4096
|
||||
fota_env.data_att.crc = data_att->crc;
|
||||
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_CMD, FOTAS_TRANS_SUC, 1);
|
||||
break;
|
||||
// FOTAS_DATA_CMD = 5
|
||||
case FOTAS_DATA_CMD: // 5.3 App->Dev
|
||||
LOGI("line=%d, 5.3 ota current data packet\n", __LINE__);
|
||||
fota_data1 = (struct fota_data *)buffer;
|
||||
pid = fota_data1->sn;
|
||||
fotas_write_env.cur_num += 1;
|
||||
memcpy((uint8_t *)fota_env.sector_buf +
|
||||
(pid - 1) * fotas_write_env.old_length,
|
||||
fota_data1->data, fotas_write_env.length);
|
||||
fotas_write_env.old_length = fotas_write_env.length;
|
||||
LOGI("fotas_write_env.cur_num=%x fotas_write_env.all_fnum=%x\n",
|
||||
fotas_write_env.cur_num, fotas_write_env.all_fnum);
|
||||
if (fotas_write_env.cur_num != fotas_write_env.all_fnum) {
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_ACK, FOTAS_TANS_LOSE, 0);
|
||||
} else {
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_CMD, FOTAS_TRANS_SUC, 0);
|
||||
|
||||
uint16_t last_sector_size = fota_env.data_att.sector_size %
|
||||
(FOTA_PAGE_NUM * FLASH_PAGE_SIZE);
|
||||
|
||||
if (last_sector_size) {
|
||||
memset(
|
||||
(uint8_t *)fota_env.sector_buf + last_sector_size, 0xff,
|
||||
(FOTA_PAGE_NUM * FLASH_PAGE_SIZE) - last_sector_size);
|
||||
}
|
||||
|
||||
fota_status_set(FOTAS_DEV_BUSY);
|
||||
|
||||
xc_fotas_flash_write();
|
||||
}
|
||||
break;
|
||||
// FOTAS_DATA_CMD = 6
|
||||
case FOTAS_COM_CMD:
|
||||
LOGI("line=%d, 7.3 ota over\n", __LINE__);
|
||||
ble_flash_later_write_page(fotas_write_env.para_buf,
|
||||
OTA_PARAM_ADDR);
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_CMD, FOTAS_SUCCEES, 1);
|
||||
|
||||
fotas_status.rsp_stat = 0;
|
||||
fotas_status.ack_idx = 0;
|
||||
|
||||
fota_status_set(FOTAS_TRANS_SUC);
|
||||
fotas_status.ota_succ_flag = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
LOGI("err cmd\n");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_CMD, FOTAS_DEV_BUSY, 0);
|
||||
}
|
||||
}
|
||||
void fota_disconnect_reset()
|
||||
{
|
||||
fotas_status.rsp_stat = 0;
|
||||
fotas_status.ack_idx = 0;
|
||||
fotas_status.fir_rsp_stat = 1;
|
||||
fotas_status.first_pack_write_flag = TRUES;
|
||||
}
|
||||
|
||||
void ota_clear_status()
|
||||
{
|
||||
fotas_status.ota_succ_flag = 0;
|
||||
fotas_status.rsp_stat = 0;
|
||||
fotas_status.ack_idx = 0;
|
||||
fotas_write_env.cur_num = 0;
|
||||
fotas_status.fir_rsp_stat = 1;
|
||||
fotas_status.first_pack_write_flag = TRUES;
|
||||
fotas_status.sector_erase_flag = 0;
|
||||
fotas_status.wtitten_page_num = 1;
|
||||
fotas_status.wtite_flag = 0; // Only when the valid data of the bin file is
|
||||
// received, it will be set to 1
|
||||
fota_status_set(FOTAS_DEV_BUSY);
|
||||
}
|
||||
|
||||
uint16_t trans_size_cmd_ack(uint8_t num_page)
|
||||
{
|
||||
uint16_t size = 0;
|
||||
switch (num_page) {
|
||||
case 16: {
|
||||
size = 0x0001; // 4096
|
||||
} break;
|
||||
case 8: {
|
||||
size = 0x0101; // 2048
|
||||
} break;
|
||||
case 4: {
|
||||
size = 0x0201; // 1024
|
||||
} break;
|
||||
case 2: {
|
||||
size = 0x0301; // 512
|
||||
} break;
|
||||
case 1: {
|
||||
size = 0x0401; // 256
|
||||
} break;
|
||||
defult:
|
||||
LOGI("not support size = %d\n", num_page * 256);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
// CMD and RSP handler.
|
||||
void xc_fota_cmd_rsp_handle(struct opencode_or_ack *wr_req)
|
||||
{
|
||||
uint8_t cmd = wr_req->cmd;
|
||||
uint8_t type = wr_req->data_or_atype;
|
||||
uint16_t fnum = wr_req->fnum_or_para;
|
||||
|
||||
// Each stage of ota will perform an empty packet interaction before
|
||||
// starting data interaction
|
||||
if (cmd == FOTAS_CMD) {
|
||||
if (type == 0) // type is transmission
|
||||
{
|
||||
// ���յ���ǰ����Ϣ�� FOTAS_INFO_CMD ʱ�� fotas_status.rsp_stat = 1
|
||||
// ���յ� 2.2 app ������ack, �� fotas_status.ack_idx = 0 ʱ��rsp_stat
|
||||
// += 1
|
||||
|
||||
switch (fotas_status.rsp_stat) {
|
||||
|
||||
// FOTAS_RSP_READY = 0
|
||||
case FOTAS_RSP_READY:
|
||||
LOGI("line=%d, [1.1 app->dev, 1.2 dev->app]\n", __LINE__);
|
||||
|
||||
ble_flash_later_page_erase(OTA_PARAM_ADDR);
|
||||
|
||||
// xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_ACK, FOTAS_TRANS_SUC,
|
||||
// 0x0001);
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_ACK, FOTAS_TRANS_SUC,
|
||||
trans_size_cmd_ack(FOTA_PAGE_NUM));
|
||||
fota_status_set(FOTAS_DEV_READY);
|
||||
break;
|
||||
|
||||
// FOTAS_RCV_SECT_START = 1
|
||||
case FOTAS_RCV_SECT_START:
|
||||
// �˴��յ���Ϣ2.4 App->Dev, ����û��2.5�������Ϣ�Ƿ���Ҫ�豸�˻ظ�
|
||||
//
|
||||
LOGI("line=%d, [2.4,3.1 app->dev 3.2 dev->app] or [4.4,5.1 "
|
||||
"app->dev 5.2 dev->app ]\n",
|
||||
__LINE__);
|
||||
// start recv data
|
||||
fotas_write_env.all_fnum = fnum;
|
||||
xc_fota_dev_ack_cmd(FOTAS_RSP, FOTAS_ACK, FOTAS_TRANS_SUC, 1);
|
||||
fota_status_set(FOTAS_DEV_READY);
|
||||
|
||||
// when default =1, disconnect=1, ota over=1,
|
||||
// fotas_status.fir_ack_idx = 1
|
||||
|
||||
fotas_status.ack_idx = FOTAS_RECV_START;
|
||||
|
||||
break;
|
||||
|
||||
case FOTAS_RCV_SECT_CANCEL: // no use, maybe use in the future
|
||||
LOGI("FOTAS_RCV_SECT_CANCEL\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
LOGI("err fotas_status.rsp_stat:%d\n", fotas_status.rsp_stat);
|
||||
}
|
||||
}
|
||||
} else if (cmd == FOTAS_ACK) // type is ack, app -> dev, ������Ҫ dev ����
|
||||
// app һ����
|
||||
{
|
||||
if (fnum == 1) {
|
||||
// fotas_status.ack_idx = 1, When fotas_status.ack_idx=1, it means
|
||||
// that the ota data packet has been delivered
|
||||
switch (
|
||||
fotas_status
|
||||
.ack_idx) // ��Ϊ app
|
||||
// ����ָ��һ���������豸�ص�ָ�һ��
|
||||
{
|
||||
// FOTAS_RSP_START = 0
|
||||
case FOTAS_RSP_START:
|
||||
LOGI("line=%d, sn=0, app->dev ack 2.2, dev->app 2.3 \n",
|
||||
__LINE__);
|
||||
|
||||
fotas_status.rsp_stat = FOTAS_RCV_SECT_START;
|
||||
|
||||
fota_env.send_buf.sn = FOTAS_SENT;
|
||||
fota_env.send_buf.len = 3;
|
||||
|
||||
if (fotas_status.ota_succ_flag) {
|
||||
fota_env.send_buf.cmd =
|
||||
7; // 8.3 Dev->App (ota upgrade result)
|
||||
} else {
|
||||
fota_env.send_buf.cmd = 2; // 2.3 Dev->App (ota start rsp)
|
||||
}
|
||||
fota_env.send_buf.status = fota_status_get();
|
||||
FOTAS_NOTIFY((uint8_t *)&fota_env.send_buf,
|
||||
sizeof(fota_env.send_buf), OTA_SVC_TX_CHAR_VAL);
|
||||
break;
|
||||
|
||||
// FOTAS_RSP_START = 1
|
||||
case FOTAS_RSP_CMD:
|
||||
// 4.3 Dev->App (ota current packet rsp)
|
||||
LOGI("line=%d,ota current packet rsp, app->dev 4.2 ack, "
|
||||
"dev->app 4.3 req\n",
|
||||
__LINE__);
|
||||
fota_status_set(FOTAS_DEV_READY);
|
||||
fota_env.send_buf.sn = FOTAS_SENT;
|
||||
fota_env.send_buf.len = 3;
|
||||
fota_env.send_buf.cmd = 4;
|
||||
fota_env.send_buf.status = fota_status_get();
|
||||
FOTAS_NOTIFY((uint8_t *)&fota_env.send_buf,
|
||||
sizeof(fota_env.send_buf), OTA_SVC_TX_CHAR_VAL);
|
||||
break;
|
||||
|
||||
// FOTAS_RECV_START = 2
|
||||
case FOTAS_RECV_START:
|
||||
LOGI("line=%d, 4.3 ota current packet rsp \n", __LINE__);
|
||||
fota_status_set(FOTAS_DEV_READY);
|
||||
fota_env.send_buf.sn = FOTAS_SENT;
|
||||
fota_env.send_buf.len = 3;
|
||||
fota_env.send_buf.cmd = 4;
|
||||
fota_env.send_buf.status = fota_status_get();
|
||||
FOTAS_NOTIFY((uint8_t *)&fota_env.send_buf,
|
||||
sizeof(fota_env.send_buf), OTA_SVC_TX_CHAR_VAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOGI("fotas_status.ack_idx:%d\n", fotas_status.ack_idx);
|
||||
break;
|
||||
}
|
||||
} else if (fnum == 0) {
|
||||
switch (fotas_status.ack_idx) {
|
||||
case FOTAS_RSP_START:
|
||||
if (fotas_status.ota_succ_flag) {
|
||||
LOGI("\r\n");
|
||||
LOGI("fotas_status.ota_succ_flag\n");
|
||||
xc_ble_disconnect(app_env.slave_conidx, 0x16);
|
||||
wdt_reset_system();
|
||||
} else {
|
||||
// LOGI("ota start rsp succeed 2.4\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case FOTAS_RECV_START:
|
||||
LOGI("line=%d, ota start recv data 4.4 \n", __LINE__);
|
||||
fota_status_set(FOTAS_DEV_READY);
|
||||
fotas_status.ack_idx = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
// LOGI(" fnum:%d
|
||||
//fotas_status.ack_idx:%d\n",fnum,fotas_status.ack_idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGI("error!!!!rsp\n");
|
||||
}
|
||||
}
|
||||
typedef void (*iapfun)(void); // 定义一个函数类型的参数.
|
||||
iapfun jump2app;
|
||||
__asm void MSR_MSP(uint32_t addr) // 设置栈顶地址 addr:栈顶地址
|
||||
{
|
||||
MSR MSP, r0 // set Main Stack value
|
||||
BX r14
|
||||
}
|
||||
void enter_ota_mode()
|
||||
{
|
||||
#define OTA_ADDR 0x1100F000
|
||||
|
||||
uint32_t pes=OTA_ADDR;
|
||||
typedef void (*iapfun)(void); // 定义一个函数类型的参数static iapfun jump2app;
|
||||
jump2app = (iapfun) * (uint32_t *)(pes + 4);
|
||||
MSR_MSP(*(uint32_t *) (pes));
|
||||
jump2app ();
|
||||
|
||||
while(1);
|
||||
}
|
||||
// uint8_t flash_size;
|
||||
void xc_fota_server_write_ind(uint8_t *buffer, uint16_t buff_size)
|
||||
{
|
||||
struct opencode_or_ack *wr_req = (struct opencode_or_ack *)buffer;
|
||||
uint16_t sn = wr_req->sn;
|
||||
#if SINGLE_OTA
|
||||
enter_ota_mode();
|
||||
#endif
|
||||
if (buff_size >= 3) {
|
||||
fotas_write_env.length = buff_size - 3;
|
||||
} else {
|
||||
fotas_write_env.length = buff_size;
|
||||
LOGI("err buff_size=%d\n", buff_size);
|
||||
}
|
||||
ota_flag = 1;
|
||||
LOGI("debug: sn = %x \n", sn);
|
||||
switch (sn) {
|
||||
case FOTAS_RSP:
|
||||
LOGI("FOTAS_RSP\n");
|
||||
xc_fota_cmd_rsp_handle(wr_req);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOGI("FOTAS_DATA\n");
|
||||
xc_fota_write_data_handle(buffer, wr_req->cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void xc_ota_schedule()
|
||||
{
|
||||
ble_flash_handle();
|
||||
|
||||
if(fotas_status.wtite_flag)
|
||||
{
|
||||
if(op_flash.op_state == OP_IDEL)
|
||||
{
|
||||
if(fotas_status.wtitten_page_num == FOTA_PAGE_NUM)
|
||||
{
|
||||
fotas_status.wtitten_page_num = 1;
|
||||
fotas_status.wtite_flag = 0;
|
||||
LOGI("func=%s,line=%d\n",__func__,__LINE__);
|
||||
xc_fota_dev_ack_cmd(0, 1, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//LOGI("func=%s,line=%d\n",__func__,__LINE__);
|
||||
ota_write_flash();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (BLE_APP_PRESENT)
|
||||
@@ -0,0 +1,229 @@
|
||||
#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 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_
|
||||
@@ -0,0 +1,173 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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_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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
extern uint8_t fir ;
|
||||
// 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);
|
||||
|
||||
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)
|
||||
@@ -0,0 +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 "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_
|
||||
@@ -0,0 +1,92 @@
|
||||
#include "uart.h"
|
||||
#include "xc_drv_uart.h"
|
||||
#include "rgblight.h"
|
||||
#include "usr_server.h"
|
||||
|
||||
ble_data_msg user_ble_data_msg; //更新了,暂时用不上
|
||||
ble_data_msg *p_ble_data_msg = NULL;
|
||||
|
||||
|
||||
|
||||
ble_usr_data user_ble_usr_data; //用户 在255个字节中,任意选发送多少个字节 0xAA+字节数+data
|
||||
ble_usr_data *p_ble_usr_data;
|
||||
|
||||
|
||||
ble_ota_data user_ble_ota_data; //OTA 固定139个字节
|
||||
ble_ota_data *p_ble_ota_data=NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief ir_message_process
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
void ble_message_process(void)
|
||||
{
|
||||
|
||||
if (p_ble_data_msg != NULL)
|
||||
{
|
||||
uint8_t temp[5] = {p_ble_data_msg->r_value,p_ble_data_msg->g_value,p_ble_data_msg->b_value_mode_speed_brightness,p_ble_data_msg->tpye};
|
||||
|
||||
|
||||
scan_uart(temp);
|
||||
|
||||
// DEBUG("temp[0]:%d,temp[1]:%d,temp[2]:%d,temp[3]:%d\n",temp[0],temp[1],temp[2],temp[3],temp[4]);
|
||||
p_ble_data_msg = NULL;
|
||||
|
||||
}
|
||||
// else if(p_ble_ota_data!=NULL){
|
||||
// // DEBUG("temp[0]:%d,temp[1]:%d,temp[2]:%d,temp[3]:%d\n",p_ble_ota_data->data_buf[0],p_ble_ota_data->data_buf[1],p_ble_ota_data->data_buf[2],p_ble_ota_data->data_buf[3]);
|
||||
// scan_uart_ota(p_ble_ota_data->data_buf);
|
||||
// p_ble_ota_data = NULL;
|
||||
// }else if(p_ble_usr_data!=NULL){
|
||||
// scan_uart_usr(p_ble_usr_data->data_buf);
|
||||
// p_ble_usr_data = NULL;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
|
||||
user_ble_data_msg.r_value = value0;
|
||||
user_ble_data_msg.g_value = value1;
|
||||
user_ble_data_msg.b_value_mode_speed_brightness = value2;
|
||||
user_ble_data_msg.tpye = value3;
|
||||
|
||||
|
||||
p_ble_data_msg = &user_ble_data_msg;
|
||||
// DEBUG("value0:%d value1:%d value2:%d value3:%d\n", value0, value1, value2, value3);
|
||||
// DEBUG("value0:%d value1:%d value2:%d value3:%d\n", p_ble_data_msg->r_value,p_ble_data_msg->g_value,p_ble_data_msg->b_value_mode_speed_brightness,p_ble_data_msg->tpye);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 串口接收数据
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void uar_rdate(void){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __rgblight_H__
|
||||
#define __rgblight_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef struct BLE_DATA_MSG
|
||||
{
|
||||
uint8_t tpye;
|
||||
uint8_t r_value;
|
||||
uint8_t g_value;
|
||||
uint8_t b_value_mode_speed_brightness;
|
||||
uint8_t colors[21];
|
||||
}ble_data_msg;
|
||||
|
||||
|
||||
|
||||
typedef struct BLE_USR_DATA
|
||||
{
|
||||
uint8_t data_buf[132];//数据最大 1字节帧头+1字节长度+128字节(数据)+类型+1字节累加合校验
|
||||
}ble_usr_data;
|
||||
|
||||
extern ble_usr_data user_ble_usr_data;
|
||||
extern ble_usr_data *p_ble_usr_data;
|
||||
|
||||
|
||||
typedef struct BLE_OTA_DATA
|
||||
{
|
||||
uint8_t data_buf[255];
|
||||
|
||||
}ble_ota_data;
|
||||
|
||||
extern ble_ota_data user_ble_ota_data;
|
||||
extern ble_ota_data *p_ble_ota_data;
|
||||
|
||||
extern uint8_t app_data[];
|
||||
|
||||
|
||||
void ble_message_process(void);
|
||||
void uar_rdate(void);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __UART_H__ */
|
||||
@@ -0,0 +1,276 @@
|
||||
#<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
|
||||
0x1100e991 T prf_dst_task_get
|
||||
0x1100eac5 T rom_env_init
|
||||
0x11003489 T gapc_get_bdaddr
|
||||
0x11008019 T gatt_db_svc16_add
|
||||
0x1100819d T gatt_db_svc_add
|
||||
0x110090b9 T gatt_srv_att_read_get_cfm
|
||||
0x110091f1 T gatt_srv_att_val_set_cfm
|
||||
0x11009bc9 T gatt_srv_event_send
|
||||
0x1100aa61 T gatt_user_srv_register
|
||||
0x1100f6d8 D llc_msg_handler_tab
|
||||
0x10001afc 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
|
||||
0x10001a15 D sv_lock
|
||||
0x10001a18 D sv_txlen
|
||||
0x100014d1 T rom_lld_con_rx
|
||||
0x10001793 T rom_lld_con_evt_start_cbk
|
||||
0x100017eb T rom_lld_con_frm_isr
|
||||
0x11007a15 T gatt_cli_mtu_exch
|
||||
0x1100efb1 T rom_lld_disable_latency
|
||||
0x1100efd9 T rom_lld_enable_latency
|
||||
0x10001a14 D evt_start
|
||||
0x1100abd5 T get_adv_time
|
||||
0x0000e021 T rwip_sw_int_req
|
||||
0x0000eb09 T sch_arb_prog_timer
|
||||
0x10001a0c D non_conn_adv_intv
|
||||
0x1100f019 T set_seed
|
||||
0x10001a08 D adv_evt_start
|
||||
@@ -0,0 +1,270 @@
|
||||
#<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
|
||||
0x1100d5e9 T prf_dst_task_get
|
||||
0x1100d71d T rom_env_init
|
||||
0x11003229 T gapc_get_bdaddr
|
||||
0x110075d9 T gatt_db_svc16_add
|
||||
0x1100775d T gatt_db_svc_add
|
||||
0x11008679 T gatt_srv_att_read_get_cfm
|
||||
0x110087b1 T gatt_srv_att_val_set_cfm
|
||||
0x11009189 T gatt_srv_event_send
|
||||
0x1100a021 T gatt_user_srv_register
|
||||
0x1100e0a8 D llc_msg_handler_tab
|
||||
0x100025b8 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
|
||||
0x10001ba3 D sv_lock
|
||||
0x10001baa D sv_txlen
|
||||
0x1000171d T rom_lld_con_rx
|
||||
0x1000199b T rom_lld_con_evt_start_cbk
|
||||
0x100019eb T rom_lld_con_frm_isr
|
||||
0x11007039 T gatt_cli_mtu_exch
|
||||
0x1100d8f5 T rom_lld_disable_latency
|
||||
0x1100d941 T rom_lld_enable_latency
|
||||
0x10001ba2 D evt_start
|
||||
@@ -0,0 +1,460 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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_64M;
|
||||
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)
|
||||
#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;
|
||||
|
||||
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);
|
||||
}
|
||||
__RAM_CODE void sleep_close_all()
|
||||
{
|
||||
xc_timer_stop(TIMER1_IDX);
|
||||
xc_adc_disable();
|
||||
// xc_pwm_stop((uint8_t reg_idx);
|
||||
}
|
||||
|
||||
__RAM_CODE void sleep_open_all()
|
||||
{
|
||||
xc_timer_start(TIMER1_IDX);
|
||||
xc_adc_enable();
|
||||
// xc_pwm_start(uint8_t reg_idx);
|
||||
}
|
||||
|
||||
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
|
||||
sleep_close_all();
|
||||
|
||||
xc_ble_sleep();
|
||||
|
||||
xc_timer_stop(TIMER0_IDX);
|
||||
sleep_open_all();
|
||||
// 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)
|
||||
@@ -0,0 +1,14 @@
|
||||
#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)
|
||||
|
||||
#endif //_SLEEP_H_
|
||||
@@ -0,0 +1,244 @@
|
||||
|
||||
;/*****************************************************************************
|
||||
; * @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 0x000000ff
|
||||
|
||||
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
|
||||
@@ -0,0 +1,387 @@
|
||||
#include "switch_s.h"
|
||||
#include "xc_drv_gpio.h"
|
||||
#include "xc60xx.h"
|
||||
#include "RF433.h"
|
||||
#include "pwm.h"
|
||||
// ==================== GPIO1 检测 ====================
|
||||
uint8_t trig1_cnt = 0; // 连续触发次数
|
||||
uint16_t trig1_timeout = 0; // 300ms 倒计时
|
||||
uint8_t trig1_wait = 0; // 0=空闲 1=连续出触发
|
||||
|
||||
// ==================== GPIO19 检测 ====================
|
||||
uint8_t trig2_cnt = 0; // 连续触发次数
|
||||
uint16_t trig2_timeout = 0; // 300ms 倒计时
|
||||
uint8_t trig2_wait = 0; // 0=空闲 1=连续出触发
|
||||
|
||||
uint8_t rf433_sw_flag=0; //进入对码标志
|
||||
|
||||
static volatile debounce_state_t s1_state = DB_IDLE;
|
||||
static volatile debounce_state_t s2_state = DB_IDLE;
|
||||
static volatile uint16_t s1_debounce_cnt = 0;
|
||||
static volatile uint16_t s2_debounce_cnt = 0;
|
||||
|
||||
|
||||
|
||||
#define DEBOUNCE_MS 2 //消抖时间40ms
|
||||
|
||||
//uint16_t switch1_debounce = 0;
|
||||
//uint16_t switch2_debounce = 0;
|
||||
|
||||
uint8_t switch1_RELEASE_flag=0;
|
||||
uint8_t switch2_RELEASE_flag=0;
|
||||
|
||||
uint8_t s1_first_press_flag = 0; //S2首次按下标志
|
||||
uint8_t s2_first_press_flag = 0; //S2首次按下标志
|
||||
|
||||
|
||||
|
||||
void switch_init(void)
|
||||
{
|
||||
|
||||
GPIO_InitCfg_t GPIO_InitCfg = { 0 }; // 清零初始化配置结构体
|
||||
GPIO_InitCfg.Mux = GPIO_Mux0; // 选择功能复用器0
|
||||
GPIO_InitCfg.FunSel = GPIO_Dx; // 选择GPIO功能(非特殊功能)
|
||||
GPIO_InitCfg.Pull = GPIO_PULLUP; //上拉电阻使能
|
||||
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_INPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = FAIL_EDGE_INT; //使能中断
|
||||
GPIO_InitCfg.Pin = SWITCH_S1_PIN; // 设置S1引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
GPIO_InitCfg.Dir = GPIO_DIR_INPUT; // 输出方向
|
||||
GPIO_InitCfg.Int = FAIL_EDGE_INT; //使能中断
|
||||
GPIO_InitCfg.Pin = SWITCH_S2_PIN; // 设置S2引脚
|
||||
xc_gpio_init(&GPIO_InitCfg); // 初始化GPIO
|
||||
|
||||
xc_gpio_it_config(GPIO_1,FAIL_EDGE_INT);
|
||||
xc_gpio_it_config(GPIO_19,FAIL_EDGE_INT);
|
||||
NVIC_EnableIRQ(GPIO_IRQn);
|
||||
}
|
||||
|
||||
|
||||
void trigger_check_process(void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch(s1_state)
|
||||
{
|
||||
case DB_IDLE: //空闲状态
|
||||
break;
|
||||
|
||||
case DB_PRESS_DEBOUNCE: //按下防抖
|
||||
if(s1_debounce_cnt>0) s1_debounce_cnt--;
|
||||
if(s1_debounce_cnt==0)
|
||||
{
|
||||
//防抖时间到,采样当前电平是否是低电平
|
||||
if(xc_gpio_read_pin(SWITCH_S1_PIN)==0)
|
||||
{
|
||||
s1_state = DB_PRESSED; //进入按下状态,不响应中断
|
||||
if(trig1_wait == 0)
|
||||
{
|
||||
trig1_cnt = 1;
|
||||
trig1_timeout = TRIGGER_TIMEOUT_MS;
|
||||
trig1_wait = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(trig1_timeout>0)
|
||||
{
|
||||
trig1_cnt++;
|
||||
}
|
||||
|
||||
trig1_timeout = TRIGGER_TIMEOUT_MS;
|
||||
//
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 杂波导致误触,回到空闲
|
||||
s1_state = DB_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DB_PRESSED: //确认按下
|
||||
|
||||
|
||||
|
||||
// 等待引脚回高电平
|
||||
if(xc_gpio_read_pin(SWITCH_S1_PIN) == 1)
|
||||
{
|
||||
s1_state = DB_RELEASE_DEBOUNCE;
|
||||
s1_debounce_cnt = DEBOUNCE_MS; // 释放30ms防抖
|
||||
}
|
||||
break;
|
||||
|
||||
case DB_RELEASE_DEBOUNCE: //释放防抖
|
||||
if(s1_debounce_cnt > 0) s1_debounce_cnt--;
|
||||
if(s1_debounce_cnt == 0)
|
||||
{
|
||||
if(xc_gpio_read_pin(SWITCH_S1_PIN) == 1) // 确认释放
|
||||
{
|
||||
s1_state = DB_IDLE; // 回到空闲
|
||||
trig1_timeout = TRIGGER_TIMEOUT_MS;
|
||||
|
||||
switch1_RELEASE_flag=1;
|
||||
if(s1_first_press_flag==1)
|
||||
{
|
||||
s1_first_press_flag=2;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 再等20ms
|
||||
s1_debounce_cnt = DEBOUNCE_MS; // 30ms
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
switch(s2_state)
|
||||
{
|
||||
case DB_IDLE: //空闲状态
|
||||
break;
|
||||
|
||||
case DB_PRESS_DEBOUNCE: //按下防抖
|
||||
if(s2_debounce_cnt>0) s2_debounce_cnt--;
|
||||
if(s2_debounce_cnt==0)
|
||||
{
|
||||
//防抖时间到,采样当前电平是否是低电平
|
||||
if(xc_gpio_read_pin(SWITCH_S2_PIN)==0)
|
||||
{
|
||||
s2_state = DB_PRESSED; //进入按下状态,不响应中断
|
||||
if(trig2_wait == 0)
|
||||
{
|
||||
trig2_cnt = 1;
|
||||
trig2_timeout = TRIGGER_TIMEOUT_MS;
|
||||
trig2_wait = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(trig2_timeout>0)
|
||||
{
|
||||
trig2_cnt++;
|
||||
}
|
||||
|
||||
trig2_timeout = TRIGGER_TIMEOUT_MS;
|
||||
// if(trig2_cnt >= TRIGGER_CONTINUE_CNT )
|
||||
// {
|
||||
// rf433_sw_flag = 1;
|
||||
// trig2_cnt = 0;
|
||||
// trig2_timeout = 0;
|
||||
// trig2_wait = 0;
|
||||
// s2_state = DB_IDLE;
|
||||
// }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 杂波导致误触,回到空闲
|
||||
s2_state = DB_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DB_PRESSED: //确认按下
|
||||
// 等待引脚回高电平
|
||||
if(xc_gpio_read_pin(SWITCH_S2_PIN) == 1)
|
||||
{
|
||||
s2_state = DB_RELEASE_DEBOUNCE;
|
||||
s2_debounce_cnt = DEBOUNCE_MS; // 释放30ms防抖
|
||||
}
|
||||
break;
|
||||
|
||||
case DB_RELEASE_DEBOUNCE: //释放防抖
|
||||
if(s2_debounce_cnt > 0) s2_debounce_cnt--;
|
||||
if(s2_debounce_cnt == 0)
|
||||
{
|
||||
if(xc_gpio_read_pin(SWITCH_S2_PIN) == 1) // 确认释放
|
||||
{
|
||||
s2_state = DB_IDLE; // 回到空闲
|
||||
trig2_timeout = TRIGGER_TIMEOUT_MS;
|
||||
switch2_RELEASE_flag=1;
|
||||
if(s2_first_press_flag==1)
|
||||
{
|
||||
s2_first_press_flag=2;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 再等20ms
|
||||
s2_debounce_cnt = DEBOUNCE_MS; // 30ms
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// S1 超时处理
|
||||
if(trig1_timeout > 0)
|
||||
{
|
||||
trig1_timeout--;
|
||||
}
|
||||
else if(trig1_timeout==0 && switch1_RELEASE_flag==1 )
|
||||
{
|
||||
switch1_RELEASE_flag=2;
|
||||
}
|
||||
|
||||
|
||||
// 600ms倒计时结束,且有计数
|
||||
if(trig1_timeout == 0 && trig1_cnt == 1 && trig1_wait == 1 && s1_state == DB_PRESSED) //确定按下1次
|
||||
{
|
||||
//printf("按下一次 trig1_cnt %d\r\n",trig1_cnt);
|
||||
trig1_cnt = 0;
|
||||
trig1_wait = 0;
|
||||
s1_first_press_flag=1;
|
||||
xc_gpio_write_pin(GPIO_5,GPIO_PIN_SET);
|
||||
|
||||
}
|
||||
|
||||
else if(trig1_timeout == 0 && (trig1_cnt > 1 && trig1_cnt < 5))
|
||||
{
|
||||
// printf("乱按 trig1_cnt %d\r\n",trig1_cnt);
|
||||
trig1_cnt = 0;
|
||||
trig1_wait = 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(trig1_timeout == 0 && trig1_cnt >= TRIGGER_CONTINUE_CNT)
|
||||
{
|
||||
//printf("对码 trig1_cnt %d\r\n",trig1_cnt);
|
||||
if( s1_state == DB_IDLE)
|
||||
{
|
||||
rf433_sw_flag = 1;
|
||||
trig1_cnt = 0;
|
||||
trig1_wait = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
trig1_cnt = 0;
|
||||
trig1_wait = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if(trig1_timeout == 0 && switch1_RELEASE_flag==2 && s1_state == DB_IDLE && s1_first_press_flag==2 )
|
||||
{
|
||||
// printf("低电平 trig2_cnt %d\r\n",trig2_cnt);
|
||||
s1_state = DB_IDLE;
|
||||
switch1_RELEASE_flag=0;
|
||||
s1_first_press_flag=0;
|
||||
xc_gpio_write_pin(GPIO_5,GPIO_PIN_RESET);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// S2 超时处理
|
||||
if(trig2_timeout > 0)
|
||||
{
|
||||
trig2_timeout--;
|
||||
}
|
||||
else if(trig2_timeout==0 && switch2_RELEASE_flag==1 )
|
||||
{
|
||||
switch2_RELEASE_flag=2;
|
||||
}
|
||||
|
||||
|
||||
// 600ms倒计时结束,且有计数
|
||||
if(trig2_timeout == 0 && trig2_cnt == 1 && trig2_wait == 1 && s2_state == DB_PRESSED) //确定按下1次
|
||||
{
|
||||
|
||||
trig2_cnt = 0;
|
||||
trig2_wait = 0;
|
||||
s2_first_press_flag=1;
|
||||
xc_gpio_write_pin(GPIO_2,GPIO_PIN_SET);
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(trig2_timeout == 0 && (trig2_cnt > 1 && trig2_cnt < 5))
|
||||
{
|
||||
|
||||
trig2_cnt = 0;
|
||||
trig2_wait = 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(trig2_timeout == 0 && trig2_cnt >= TRIGGER_CONTINUE_CNT)
|
||||
{
|
||||
|
||||
|
||||
if( s2_state == DB_IDLE)
|
||||
{
|
||||
rf433_sw_flag = 2;
|
||||
trig2_cnt = 0;
|
||||
trig2_wait = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
trig2_cnt = 0;
|
||||
trig2_wait = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if(trig2_timeout == 0 && switch2_RELEASE_flag==2 && s2_state == DB_IDLE && s2_first_press_flag==2 )
|
||||
{
|
||||
|
||||
|
||||
|
||||
s2_state = DB_IDLE;
|
||||
switch2_RELEASE_flag=0;
|
||||
s2_first_press_flag=0;
|
||||
|
||||
xc_gpio_write_pin(GPIO_2,GPIO_PIN_RESET);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gpio_intr_callback(uint64_t intr_sta)
|
||||
{
|
||||
if((intr_sta & ((uint64_t)1 << SWITCH_S1_PIN)) != 0) //如果是GPIO_1的中断
|
||||
{
|
||||
if(s1_state == DB_IDLE) // 只有空闲才响应
|
||||
{
|
||||
s1_state = DB_PRESS_DEBOUNCE;
|
||||
s1_debounce_cnt = DEBOUNCE_MS; // 40ms防抖
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((intr_sta & ((uint64_t)1 << SWITCH_S2_PIN)) != 0) //如果是GPIO_19的中断
|
||||
{
|
||||
if(s2_state == DB_IDLE)
|
||||
{
|
||||
s2_state = DB_PRESS_DEBOUNCE;
|
||||
s2_debounce_cnt = DEBOUNCE_MS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef __switch_s_H__
|
||||
#define __switch_s_H__
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// 400ms 超时
|
||||
#define TRIGGER_TIMEOUT_MS 25
|
||||
// 连续触发次数
|
||||
#define TRIGGER_CONTINUE_CNT 5
|
||||
|
||||
#define SWITCH_S1_PIN GPIO_1
|
||||
#define SWITCH_S2_PIN GPIO_19
|
||||
|
||||
|
||||
// 防抖状态机
|
||||
typedef enum {
|
||||
DB_IDLE = 0, // 空闲,等待下降沿
|
||||
DB_PRESS_DEBOUNCE, // 按下防抖中
|
||||
DB_PRESSED, // 确认按下,等待释放
|
||||
DB_RELEASE_DEBOUNCE // 释放防抖
|
||||
} debounce_state_t;
|
||||
|
||||
extern uint8_t rf433_sw_flag;
|
||||
|
||||
void trigger_check_process(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xc6xxx.h"
|
||||
#include "dbg.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define __DEBUG_OUT_PORT 0
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define VECTOR_NUM 48
|
||||
|
||||
void set_vector(void)
|
||||
{
|
||||
#if (USE_XIP == 1)
|
||||
__disable_irq();
|
||||
#if APP_SCAN_FUNCTION
|
||||
for (uint32_t i = 0, *Pvector = (uint32_t *)(0x11011000 + 0),
|
||||
*_vector_table = (uint32_t *)(0x10000000);
|
||||
#else
|
||||
for (uint32_t i = 0, *Pvector = (uint32_t *)(0x1100E000 + 0),
|
||||
*_vector_table = (uint32_t *)(0x10000000);
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
|
||||
#if(_DEBUG_ ==0 )
|
||||
|
||||
return 1;
|
||||
|
||||
#endif
|
||||
|
||||
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,258 @@
|
||||
#include "timer.h"
|
||||
#include "xc_drv_timer.h"
|
||||
#include "timeslice.h"
|
||||
#include "PWM.h"
|
||||
#include "mode.h"
|
||||
#include "uart.h"
|
||||
#include "RF433.h"
|
||||
#include "pwm.h"
|
||||
#include "switch_s.h"
|
||||
TimerStatus_t timer_status =
|
||||
{
|
||||
.t0_flag = false,
|
||||
.t1_flag = false,
|
||||
.t2_flag = false,
|
||||
.t3_flag = false,
|
||||
};
|
||||
// 定义多个软定时器
|
||||
Timer timer1, timer2,timer3, 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, uint32_t 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()
|
||||
{
|
||||
// 在这里编写定时器2到达设定时间时需要执行的代码
|
||||
|
||||
|
||||
}
|
||||
// 软定时器4到达设定时间时执行的函数
|
||||
void timer4Callback(void)//对码计时
|
||||
{
|
||||
// MatchOverFlag = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief timer0_init
|
||||
* @details
|
||||
* @param void
|
||||
* @retval void
|
||||
*/
|
||||
|
||||
uint8_t dd=0;
|
||||
void timer0_2_init(void)
|
||||
{
|
||||
uint32_t us = 1000;
|
||||
Timer_InitCfg_t timer_cfg;
|
||||
|
||||
timer_cfg.timer_src_clk = TIMER_CLK_SRC_32M_DIV;
|
||||
timer_cfg.timer_div_clk = TIMER_DIV_CLK_16MHzOr16K;
|
||||
timer_cfg.timer_mode = TIMER_MODE_CYCLE;
|
||||
|
||||
xc_timer_init(TIMER1_IDX, &timer_cfg);
|
||||
xc_timer_set_value(TIMER1_IDX, us);
|
||||
xc_timer_start(TIMER1_IDX);
|
||||
// Timer2 Config & Start
|
||||
|
||||
xc_timer_init(TIMER2_IDX, &timer_cfg);
|
||||
xc_timer_set_value(TIMER2_IDX, 100); //100us
|
||||
xc_timer_start(TIMER2_IDX);
|
||||
|
||||
xc_timer_init(TIMER0_IDX, &timer_cfg);
|
||||
xc_timer_set_value(TIMER0_IDX, 50000); //50ms
|
||||
xc_timer_start(TIMER0_IDX);
|
||||
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)TIMER2_IRQn,2);
|
||||
NVIC_EnableIRQ((IRQn_Type)TIMER2_IRQn);
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)TIMER0_IRQn,1);
|
||||
NVIC_EnableIRQ((IRQn_Type)TIMER0_IRQn);
|
||||
}
|
||||
|
||||
|
||||
uint16_t led_1_count_time=0;
|
||||
uint16_t led_2_count_time=0;
|
||||
uint16_t led_3_count_time=0;
|
||||
|
||||
|
||||
uint16_t led1_on_timer=0;
|
||||
uint16_t led2_on_timer=0;
|
||||
uint16_t led3_on_timer=0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Timer0_Callback
|
||||
* @details Timer0 handler callback function
|
||||
* @param void *context
|
||||
* @retval void
|
||||
* 100
|
||||
*/
|
||||
__RAM_CODE void timer0_callback(void *context)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if(led_state==1) //清码
|
||||
{
|
||||
|
||||
|
||||
led1_on_timer++;
|
||||
|
||||
if(led1_on_timer>=2)
|
||||
{
|
||||
led1_on_timer=0;
|
||||
led_1_count_time++; //清码3s计时
|
||||
|
||||
pwm3_toggle();
|
||||
if(led_1_count_time >= 30)
|
||||
{
|
||||
led_1_count_time=0;
|
||||
led_state=0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if(led_state==2) //对码
|
||||
{
|
||||
|
||||
|
||||
//led_on_timer++;
|
||||
led2_on_timer++;
|
||||
|
||||
if(led2_on_timer>=10)
|
||||
{
|
||||
led2_on_timer=0;
|
||||
led_2_count_time++; //对码一分钟计时
|
||||
|
||||
pwm3_toggle();
|
||||
if(led_2_count_time >= 120)
|
||||
{
|
||||
led_2_count_time=0;
|
||||
led_state=0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if(led_state==3) //对码
|
||||
{
|
||||
|
||||
|
||||
led3_on_timer++;
|
||||
|
||||
if(led3_on_timer>=20)
|
||||
{
|
||||
led3_on_timer=0;
|
||||
led_3_count_time++;
|
||||
pwm3_toggle();
|
||||
if(led_3_count_time >= 60)
|
||||
{
|
||||
led_3_count_time=0;
|
||||
led_state=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if(led_state==0)
|
||||
{
|
||||
led_1_count_time=0;
|
||||
led_2_count_time=0;
|
||||
led_3_count_time=0;
|
||||
xc_pwm_dutycycle_set(PWM3_IDX,5000,0);
|
||||
|
||||
}
|
||||
|
||||
// if(KEY_EVENT==KEY_STATE_PRESSED)
|
||||
// {
|
||||
// key_press_timer++;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Timer1_Callback
|
||||
* @details Timer1 handler callback function
|
||||
* @param void *context
|
||||
* @retval void
|
||||
*/
|
||||
|
||||
uint8_t isssss=0;
|
||||
|
||||
|
||||
__RAM_CODE void timer1_callback(void *context)
|
||||
{
|
||||
TaskRemarks();
|
||||
updateTimer(&timer2);
|
||||
updateTimer(&timer1);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
__RAM_CODE void timer2_callback(void *context)
|
||||
{
|
||||
rf433_receive();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*!
|
||||
* \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 {
|
||||
uint32_t count; // 计数器
|
||||
uint8_t active; // 活跃状态
|
||||
} Timer;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
extern Timer timer1, timer2,timer3,timer4, timer5;
|
||||
extern uint32_t ir_cnt;
|
||||
|
||||
extern uint8_t dd;
|
||||
extern TimerStatus_t timer_status;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void timer0_2_init(void);
|
||||
void initTimer(Timer *timer);
|
||||
void updateTimer(Timer *timer);
|
||||
void startTimer(Timer *timer, uint32_t 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__ */
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#ifndef _TIMESLICE_C_
|
||||
#define _TIMESLICE_C_
|
||||
/*********************************************************************************************************************/
|
||||
#include "timeslice.h"
|
||||
#include "stdint.h"
|
||||
#include "uart.h"
|
||||
#include "xc_drv_uart.h"
|
||||
#include "rgblight.h"
|
||||
#include "timer.h"
|
||||
#include "mode.h"
|
||||
#include "RF433.h"
|
||||
#include "ota_flash_interface.h"
|
||||
#include "ota_protocol.h"
|
||||
#include "key.h"
|
||||
#include "switch_s.h"
|
||||
/*********************************************************************************************************************/
|
||||
|
||||
void rwip_schedule(void);
|
||||
TASK_COMPONENTS TaskComps[] =
|
||||
{
|
||||
{0, 1, 1, rwip_schedule}, //协议栈调度任务
|
||||
{0, 1, 1, ble_message_process}, //蓝牙处理任务
|
||||
{0, 1, 1, scan_433} , //处理任务
|
||||
{0, 1, 10, app_key_scan}, // 按键检测任务
|
||||
{0, 1, 1, ble_mode_scan}, //蓝牙指令处理任务
|
||||
{0, 10,10,trigger_check_process}, //开关任务处理
|
||||
{0, 0, 0, app_op_flash_on},
|
||||
{0, 300, 300, app_op_flash}, //用户数据持久化 fmc_spi_read9
|
||||
{0, 300, 300, xc_ota_schedule}, //保存flash数据任务 8
|
||||
|
||||
};
|
||||
|
||||
/**************************************************************************************
|
||||
* FunctionName : TaskRemarks()
|
||||
* Description : 任务标志处理
|
||||
* EntryParameter : None
|
||||
* ReturnValue : None
|
||||
**************************************************************************************/
|
||||
void TaskRemarks(void)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
for (i=0; i<TASKS_MAX; i++) // 逐个任务时间处理
|
||||
{
|
||||
if (TaskComps[i].Timer) // 时间不为0
|
||||
{
|
||||
TaskComps[i].Timer--; // 减去一个节拍
|
||||
if (TaskComps[i].Timer == 0) // 时间减完了
|
||||
{
|
||||
TaskComps[i].Timer = TaskComps[i].ItvTime; // 恢复计时器值�重新下一次
|
||||
TaskComps[i].Run = 1; // 任务可以运行
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**************************************************************************************
|
||||
* FunctionName : TaskProcess()
|
||||
* Description : 任务处理
|
||||
* EntryParameter : None
|
||||
* ReturnValue : None
|
||||
**************************************************************************************/
|
||||
void TaskProcess(void)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
for (i=0; i<TASKS_MAX; i++) // 逐个任务时间处理
|
||||
{
|
||||
if (TaskComps[i].Run) // 时间不为0
|
||||
{
|
||||
TaskComps[i].Run = 0; // 标志清0
|
||||
TaskComps[i].TaskHook(); // 运行任务
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_TaskComps_timer(uint8_t index,uint16_t value)
|
||||
{
|
||||
TaskComps[index].Timer = value;
|
||||
}
|
||||
|
||||
/*********************************************************************************************************************/
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef _TIMESLICE_H
|
||||
#define _TIMESLICE_H
|
||||
|
||||
#define TASKS_MAX sizeof(TaskComps)/sizeof(TaskComps[0])
|
||||
|
||||
typedef struct _TASK_COMPONENTS
|
||||
{
|
||||
unsigned char Run; // 程序运行标记:0-不运行,1运行
|
||||
unsigned int Timer; // 计时器
|
||||
unsigned int ItvTime; // 任务运行间隔时间
|
||||
void (*TaskHook)(void); // 要运行的任务函数
|
||||
} TASK_COMPONENTS; // 任务定义
|
||||
|
||||
//extern TASK_COMPONENTS TaskComps[1];
|
||||
|
||||
extern TASK_COMPONENTS TaskComps[];
|
||||
|
||||
|
||||
void TaskProcess(void);
|
||||
void TaskRemarks(void);
|
||||
void set_TaskComps_timer(unsigned char index,unsigned short value);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/*!
|
||||
* \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"
|
||||
#include "timer.h"
|
||||
#include "RF433.h"
|
||||
|
||||
#include "pwm.h"
|
||||
#include "xc_drv_pwm.h"
|
||||
#include "rgblight.h"
|
||||
#include "mode.h"
|
||||
#include "timer.h"
|
||||
#include "math.h"
|
||||
#include "timeslice.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
uint8_t only_read_charactertics_buffer[5];
|
||||
uint8_t only_read_charactertics_buffer_length = 5;
|
||||
ring_buffer_t uart0_ring_buff;
|
||||
|
||||
|
||||
|
||||
uint8_t buffer[5] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
|
||||
uint8_t uart0_buff[UART0_BUFFER_LEN];
|
||||
|
||||
extern bool buffer_complet_flag;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
void uart_receive_cb(uint8_t *buff, uint16_t len)
|
||||
{
|
||||
// static uint8_t cnt = 0;
|
||||
|
||||
// for (int i = 0; i < len; i++) {
|
||||
// // uart_user_ctl.r_buff[cnt++] = buff[i];
|
||||
// // uart_user_ctl.r_len++;
|
||||
// ring_buffer_queue(&uart0_ring_buff, buff[i]);
|
||||
// }
|
||||
|
||||
// // if (cnt == sizeof(uart_user_ctl.r_buff))
|
||||
// {
|
||||
// //uart_user_ctl.rx_done = true;
|
||||
// cnt = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
bool xc_is_data_ready()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void scan_uar_data(uint8_t *frame){
|
||||
|
||||
}
|
||||
|
||||
uint8_t rx_date;
|
||||
uint8_t receive_mode=0;
|
||||
void scan_uart(uint8_t *arr)
|
||||
{
|
||||
uint8_t uart_handle = UART0_IDX;
|
||||
buffer_complet_flag=false;
|
||||
|
||||
// 组帧:帧头 + 数据 + 校验
|
||||
uint8_t user_rx_buf[6]; // 1字节帧头 + 4字节数据 + 1字节校验位
|
||||
user_rx_buf[0] = 0xAA; // 帧头标志
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
user_rx_buf[1 + i] = arr[i]; // 填充数据
|
||||
}
|
||||
|
||||
// 校验位:简单累加校验
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < 5; i++) // 帧头和数据
|
||||
{
|
||||
checksum += user_rx_buf[i];
|
||||
}
|
||||
user_rx_buf[5] = checksum; // 校验位
|
||||
|
||||
switch(user_rx_buf[4])
|
||||
{
|
||||
case 0x01:
|
||||
switch(user_rx_buf[1])
|
||||
{
|
||||
case 0x01:
|
||||
xc_gpio_toggle_pin(GPIO_5);
|
||||
break;
|
||||
|
||||
case 0x02:
|
||||
xc_gpio_toggle_pin(GPIO_2);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 0x02:
|
||||
switch(user_rx_buf[1])
|
||||
{
|
||||
case 0x04:
|
||||
receive_mode=1;
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
receive_mode=2;
|
||||
break;
|
||||
|
||||
|
||||
case 0x07:
|
||||
receive_mode=4;
|
||||
break;
|
||||
|
||||
default:break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// switch(user_rx_buf[4])
|
||||
// {
|
||||
// case 0x01:
|
||||
// xc_gpio_toggle_pin(GPIO_5);
|
||||
// break;
|
||||
// case 0x02:
|
||||
// xc_gpio_toggle_pin(GPIO_18);
|
||||
// break;
|
||||
// case 0x03:
|
||||
// xc_gpio_toggle_pin(GPIO_19);
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void scan_uart_ota(uint8_t *arr){
|
||||
// uint8_t uart_handle = UART0_IDX;
|
||||
// buffer_complet_flag = false; // 清除标志
|
||||
// xc_uart_send_data(uart_handle, arr,139); // 发送完整帧
|
||||
}
|
||||
|
||||
|
||||
|
||||
void scan_uart_usr(uint8_t *arr){
|
||||
// uint8_t uart_handle = UART0_IDX;
|
||||
// buffer_complet_flag = false; // 清除标志
|
||||
// xc_uart_send_data(uart_handle, arr,arr[1]); // 发送完整帧
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* \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>
|
||||
#include "RINGBUFFER.h"
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define UART0_BUFFER_LEN 255
|
||||
#define OTA_DATA_SIZE (139) //0-138
|
||||
#define CRC16_lentg (OTA_DATA_SIZE-2)
|
||||
#define CRC16_H (OTA_DATA_SIZE-2)
|
||||
#define CRC16_L (OTA_DATA_SIZE-1)
|
||||
extern ring_buffer_t uart0_ring_buff;
|
||||
extern uint8_t uart0_buff[UART0_BUFFER_LEN];
|
||||
extern uint8_t receive_mode;
|
||||
|
||||
void scan_uart(uint8_t *arr);
|
||||
void scan_uart_ota(uint8_t *arr);
|
||||
void scan_uart_usr(uint8_t *arr);
|
||||
void scan_uar_data(uint8_t *frame);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __UART_H__ */
|
||||
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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;
|
||||
|
||||
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_TX_CHAR_DECL_CHAR1] =
|
||||
{
|
||||
.uuid16 = GATT_DECL_CHARACTERISTIC,
|
||||
.info = GATT_ATT_RD_BIT,
|
||||
.ext_info = 0,
|
||||
},
|
||||
[CUSTOM_SVC_TX_CHAR_VAL1] =
|
||||
{
|
||||
.uuid16 = 0xAE10,
|
||||
.info = GATT_ATT_RD_BIT ,
|
||||
.ext_info =
|
||||
GATT_ATT_NO_OFFSET_BIT ,
|
||||
},
|
||||
[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;
|
||||
}
|
||||
|
||||
uint8_t send_flag=1;
|
||||
// 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)
|
||||
{
|
||||
send_flag=1;
|
||||
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[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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function is called during a write procedure to modify attribute handle.
|
||||
__STATIC __RAM_CODE 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);
|
||||
}
|
||||
// DEBUG("length:%d data:\r\n", length);
|
||||
/*========================================*/
|
||||
if ( length == 4)
|
||||
{
|
||||
// printf("%x %x %x %x\r\n",co_buf_data(p_data)[0],co_buf_data(p_data)[1],co_buf_data(p_data)[2],co_buf_data(p_data)[3]);
|
||||
|
||||
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]);
|
||||
|
||||
}
|
||||
|
||||
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(133, 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&&send_flag) {
|
||||
send_flag=0;
|
||||
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)
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
****************************************************************************************
|
||||
*
|
||||
* @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 0xFFFC
|
||||
#define CUSTOM_SVC_TX_CHAR_UUID 0xFFF4
|
||||
#define CUSTOM_SVC_RX_CHAR_VAL_MAX_LENGTH 120
|
||||
#define CUSTOM_SVC_TX_CHAR_VAL_MAX_LENGTH 120
|
||||
|
||||
enum cust_svc
|
||||
{
|
||||
CUSTOM_SVC_DECL = 0,
|
||||
CUSTOM_SVC_TX_CHAR_DECL_CHAR1,
|
||||
CUSTOM_SVC_TX_CHAR_VAL1,
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
extern uint8_t srv_user_lid;
|
||||
extern uint16_t custom_svc_start_hdl;
|
||||
extern uint8_t custom_svc_tx_char_notify;
|
||||
|
||||
|
||||
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 diff suppressed because it is too large
Load Diff
@@ -0,0 +1,218 @@
|
||||
/*!
|
||||
* \file ws2815.h
|
||||
*
|
||||
* \brief The header of ws2815.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
#ifndef __WS2815_H__
|
||||
#define __WS2815_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "xc6xxx.h"
|
||||
|
||||
/* 模式选择宏定义 */
|
||||
/* 可选值: SPI_DMA_MODE / GPIO_DELAY_MODE */
|
||||
#define SPI_DMA_MODE (0)
|
||||
#define GPIO_DELAY_MODE (1)
|
||||
#define WS2815_CONTROL_MODE (SPI_DMA_MODE)
|
||||
|
||||
#define WS2815_TX_PIN (1) //GPIO_1
|
||||
#define LEDC_RGB_CODE_LEN 7
|
||||
//红外命令
|
||||
#define ON 0x26
|
||||
#define OFF 0x25
|
||||
|
||||
#define SPEED_IN 0x0A
|
||||
#define SPEED_RE 0x08
|
||||
|
||||
#define MODE_IN 0x5B
|
||||
#define MODE_RE 0x6E
|
||||
|
||||
#define IR_AUTO 0x5C
|
||||
#define IR_INMUSIC 0x0F
|
||||
#define IR_DEMUSIC 0x0B
|
||||
|
||||
#define IR_TIME1H 0x06 //中部
|
||||
#define IR_TIME2H 0x5A
|
||||
|
||||
#define BRIGHTNESS_IN 0x09
|
||||
#define BRIGHTNESS_RE 0x1C
|
||||
|
||||
#define IR_INTEMP 0x10
|
||||
#define IR_DETEMP 0x53
|
||||
|
||||
#define IR_WHITE 0x52
|
||||
#define IR_YELLOW 0x0C //7种颜色
|
||||
#define IR_CHING 0x1A
|
||||
#define IR_PINK 0x1F
|
||||
#define IR_RED 0x01
|
||||
#define IR_GREEN 0x00
|
||||
#define IR_BLUE 0x02
|
||||
|
||||
//数据格式
|
||||
#define LEDC_BRG 1
|
||||
#define LEDC_BGR 2
|
||||
#define LEDC_GRB 3
|
||||
#define LEDC_GBR 4
|
||||
#define LEDC_RBG 5
|
||||
#define LEDC_RGB 6
|
||||
|
||||
// RGB format
|
||||
#define Color_RED 0xff0000 //红色
|
||||
#define Color_GREEN 0x00ff00 //绿色
|
||||
#define Color_BLUE 0x0000ff //蓝色
|
||||
#define Color_WHITE 0xffffff //白色
|
||||
#define Color_YELLOW 0xffff00 //黄色
|
||||
#define Color_ORANGE 0xff7800 //橙色
|
||||
#define Color_BLACK 0x000000 //黑色
|
||||
#define Color_PURPLE 0x9400D3 //紫色
|
||||
#define Color_INDIGO 0x480082 //靛色
|
||||
#define Color_CHING 0x00ffff //青色
|
||||
#define Color_PINK 0xE2001C //粉色
|
||||
//bool isModeSwitching = false; // 当前是否在切换模式
|
||||
|
||||
//色温调节相关数据
|
||||
#define K2700 0xff5810 //色温阶段1
|
||||
#define K3000 0xff6818 //色温阶段2
|
||||
#define K3300 0xff7828 //色温阶段3
|
||||
#define K3600 0xff8838 //色温阶段4
|
||||
#define K3900 0xff9848 //色温阶段5
|
||||
#define K4200 0xffa858 //色温阶段6
|
||||
#define K4500 0xffb868 //色温阶段7
|
||||
#define K5000 0xffc878 //色温阶段8
|
||||
#define K5500 0xffd888 //色温阶段9
|
||||
#define K6000 0xffe898 //色温阶段10
|
||||
#define K6500 0xfff8a8 //色温阶段11
|
||||
|
||||
|
||||
|
||||
// mode3常量定义
|
||||
#define COLOR_BLOCK_SIZE 5 // 每组颜色灯珠数量
|
||||
#define RAINBOW_COLORS 7 // 彩虹颜色数量
|
||||
extern uint8_t auto_Flag;
|
||||
extern bool shutdown_Flag;
|
||||
typedef uint32_t u32;
|
||||
extern uint8_t Muisc_Flag;
|
||||
extern uint8_t Task_tamp;
|
||||
extern uint8_t Temp_Flag;
|
||||
extern uint8_t auto_Flag;
|
||||
extern uint8_t Muisc_mode;
|
||||
extern uint8_t Muisc_Flag;
|
||||
extern volatile uint8_t dma_busy;
|
||||
extern uint8_t T1H; // 1码高电平(937.5ns)
|
||||
extern uint8_t T0H;
|
||||
// 颜色结构体
|
||||
typedef struct {
|
||||
uint8_t r; // 红色
|
||||
uint8_t g; // 绿色
|
||||
uint8_t b; // 蓝色
|
||||
} RGB_Color;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t LED_SWITCH; // LEDC开关 (0 = off 1 = on)
|
||||
uint8_t ledc_kick_state; // LEDC空闲状态(0为空闲 1为忙碌)
|
||||
uint8_t ledc_fill_state; // LEDC填充计数(看灯光效果)
|
||||
|
||||
uint8_t RGB_CODE_LEN; // 实际发送长度((RGB_XLED_NUM * 3) + 3) / 4
|
||||
uint16_t RGB_XLED_NUM; // 灯珠像素数量(1 - 1000)
|
||||
uint8_t CURRENT_TASK; // 当前执行任务
|
||||
uint8_t Temp_Step; // 色温阶段(0-29)共30个阶段
|
||||
volatile uint16_t LEDC_TICK_Speed; // LEDC调节速度(1 - 10(100ms - 1s))
|
||||
volatile uint8_t Timer_count; // LEDC时间计数
|
||||
uint8_t LED_Brightne; // LEDX亮度(0 - 1.0 (100))0-100
|
||||
uint8_t xianxu;
|
||||
|
||||
}LEDX_Task_TypeDef;//灯带相关数据结构体
|
||||
|
||||
|
||||
extern LEDX_Task_TypeDef LED_TaskDef;
|
||||
|
||||
typedef void (*pfunc)(void);
|
||||
|
||||
#if(WS2815_CONTROL_MODE == SPI_DMA_MODE)
|
||||
// 配置参数 - 用户可修改
|
||||
#define WS2815_SPI_IDX (SPI1_IDX)
|
||||
#define WS2815_DMA_CHANNEL (DMA_CHANNEL0)
|
||||
#define GPIO_DUMMY (0xFF)
|
||||
#define LEDS_NUM (700) // 支持的最大LED数量 1000
|
||||
#define SPI_FREQUENCY (6400000) // SPI频率6.4MHz
|
||||
|
||||
// SPI时序参数
|
||||
//#define T1H (0xf8) // 1码高电平(937.5ns)
|
||||
//#define T0H (0xc0) // 0码高电平(312.5ns)
|
||||
|
||||
#define RESET_BYTES (24) // 30μs / 1.25μs = 24字节
|
||||
#define DMA_MAX_BLOCK_SIZE (2400) // DMA单次传输最大字节数
|
||||
//uint16_t LEDS_NUM = 1000;
|
||||
// 传输状态
|
||||
typedef enum {
|
||||
TRANSFER_IDLE,
|
||||
TRANSFER_LEDS,
|
||||
TRANSFER_RESET
|
||||
} TransferState;
|
||||
#elif(WS2815_CONTROL_MODE == GPIO_DELAY_MODE)
|
||||
#define LEDS_NUM (16) // 支持的最大LED数量
|
||||
|
||||
#if(WS2815_TX_PIN < 16)
|
||||
#define GPIO_PIN_REG (*(volatile uint32_t *)(0x40001000))
|
||||
#else
|
||||
#define GPIO_PIN_REG (*(volatile uint32_t *)(0x40001004))
|
||||
#endif
|
||||
|
||||
#define WS2815_GPIO_PIN_HIGH (GPIO_PIN_REG = 0x10001 << (WS2815_TX_PIN & 0xFUL))
|
||||
#define WS2815_GPIO_PIN_LOW (GPIO_PIN_REG = 0x10000 << (WS2815_TX_PIN & 0xFUL))
|
||||
|
||||
#else
|
||||
#error "WS2815 CONTROL MODE IS ERR!"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// 函数声明
|
||||
int WS2815_Init(void);
|
||||
void WS2815_SetColor(uint16_t led_num, RGB_Color color);
|
||||
void WS2815_SetAll(RGB_Color color);
|
||||
void WS2815_Update(void);
|
||||
void WS2815_Clear(void);
|
||||
|
||||
//灯效函数声明
|
||||
void light_mode(void);
|
||||
void LED_Mode_Change(uint8_t mode);//模式修改函数
|
||||
static uint32_t ws2815_rgb_color_format_conversion(uint32_t display_color,unsigned char display_format);
|
||||
void ws2815_rgb_color_out_32to24bit_code_fill(uint32_t buf_code_grb[], uint32_t buf_grb[]);
|
||||
void ws2815_ledc_show(uint8_t display_format,uint32_t LED_Maincolor);
|
||||
void ws2815_ledc_multicolor(uint8_t display_format,uint8_t direction);
|
||||
void ledc_dma_kick(uint32_t addr, uint16_t len);
|
||||
void ws2815_ledc_multstroboscopic(uint8_t display_format);
|
||||
void ws2815_ledc_singleflu(uint8_t display_format, uint32_t LED_Maincolor, uint32_t LED_Background_color);
|
||||
void Music_Mode_Change(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __WS2815_H__ */
|
||||
@@ -0,0 +1,436 @@
|
||||
/*!
|
||||
* \file xc_drv_pwm.c
|
||||
*
|
||||
* \brief Target xc pwm driver 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_pwm.h"
|
||||
#include "xc_drv_gpio.h"
|
||||
#include "mode.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
STATE_UNINITIALIZED,
|
||||
STATE_INITIALIZED,
|
||||
} xincx_drv_state_t;
|
||||
|
||||
pwm_handler_callback pwm_n_callback[3] = {
|
||||
pwm_capture_ch0_callback,
|
||||
pwm_capture_ch1_callback,
|
||||
pwm_capture_ch2_callback,
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Local Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
static uint32_t pwm_clk_init_state = STATE_UNINITIALIZED;
|
||||
|
||||
static uint16_t pwm_freq_to_period(PWM_InitCfg_t *pwm_cfg, PWM_ClkDiv_TypeDef div_clk);
|
||||
|
||||
double period;
|
||||
/*------------------------------------------------------------------------------------
|
||||
Func Prototype
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
|
||||
void xc_pwm_init(uint8_t reg_idx, PWM_InitCfg_t *init_cfg)
|
||||
{
|
||||
if (pwm_clk_init_state == STATE_UNINITIALIZED) {
|
||||
|
||||
cpr_ctlapbclken_grctl__pwm_pclk_en__setf(ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__pwm_rstn__setf(RSTCTL_ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__pwm_rstn__setf(RSTCTL_DISABLE);
|
||||
|
||||
cpr_pwm_clk_ctl__pwm_clk_en__setf(ENABLE);
|
||||
cpr_pwm_clk_ctl__pwm_clksel__setf(init_cfg->SrcClk);
|
||||
cpr_pwm_clk_ctl__pwm_clk0_div__setf(init_cfg->DivClk);
|
||||
cpr_pwm_clk_ctl__pwm_clk1_div__setf(init_cfg->DivClk);
|
||||
|
||||
pwm_clk_init_state = STATE_INITIALIZED;
|
||||
}
|
||||
|
||||
pwm_pin_set(reg_idx, init_cfg);
|
||||
|
||||
pwm_en__en__setf(reg_idx, DISABLE);
|
||||
|
||||
pwm_en__en_sel__setf(reg_idx, init_cfg->SrcEnable);
|
||||
|
||||
xc_pwm_dutycycle_set(reg_idx, init_cfg->DutyCycleAcc, init_cfg->DutyCycle);
|
||||
|
||||
pwm_period__period__setf(reg_idx, pwm_freq_to_period(init_cfg, PWM_CLK_DIV0));
|
||||
|
||||
pwm_compen__pwmcompen__setf(reg_idx, init_cfg->InvertEnable);
|
||||
|
||||
pwm_comptime__comptime__setf(reg_idx, init_cfg->InvertDelay);
|
||||
}
|
||||
|
||||
void xc_pwm_start(uint8_t reg_idx) { pwm_en__en__setf(reg_idx, PWM_EN_ENABLE); }
|
||||
|
||||
void xc_pwm_stop(uint8_t reg_idx) { pwm_en__en__setf(reg_idx, PWM_EN_DISABLE); }
|
||||
|
||||
void pwm_src_enable_set(uint8_t reg_idx, uint8_t src_enable) { pwm_en__en_sel__setf(reg_idx, src_enable); }
|
||||
|
||||
void xc_pwm_start_all(void) { pwm_en__pwm_en_all__setf(PWM0_IDX, PWM_EN_ALL_ENABLE);}
|
||||
|
||||
void xc_pwm_stop_all(void) { pwm_en__pwm_en_all__setf(PWM0_IDX, PWM_EN_ALL_DISABLE); }
|
||||
|
||||
void pwm_pin_set(uint8_t reg_idx, PWM_InitCfg_t *pwm_cfg)
|
||||
{
|
||||
GPIO_InitCfg_t gpio_cfg;
|
||||
if(pwm_cfg->OutputPin==GPIO_11||pwm_cfg->OutputPin==GPIO_12||pwm_cfg->OutputPin==GPIO_13){
|
||||
gpio_cfg.Mux = GPIO_Mux1;
|
||||
}else
|
||||
{
|
||||
gpio_cfg.Mux = GPIO_Mux0;
|
||||
}
|
||||
gpio_cfg.Dir = GPIO_DIR_OUTPUT;
|
||||
gpio_cfg.Pull = GPIO_PULLDOWN;
|
||||
gpio_cfg.Int = NOT_INT;
|
||||
gpio_cfg.Pin = pwm_cfg->OutputPin;
|
||||
|
||||
if (reg_idx == PWM0_IDX || reg_idx == PWM1_IDX) {
|
||||
gpio_cfg.FunSel = (reg_idx == PWM0_IDX) ? PWM0 : PWM1;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
|
||||
if (pwm_cfg->InvertEnable) {
|
||||
gpio_cfg.FunSel = (reg_idx == PWM0_IDX) ? PWM0_INV : PWM1_INV;
|
||||
|
||||
gpio_cfg.Pin = pwm_cfg->OutputInvertPin;
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
}
|
||||
} else if (reg_idx == PWM2_IDX) {
|
||||
gpio_cfg.Mux = GPIO_Mux3;
|
||||
if (pwm_cfg->OutputPin == GPIO_12) {
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
}
|
||||
} else if (reg_idx == PWM3_IDX) {
|
||||
gpio_cfg.Mux = GPIO_Mux3;
|
||||
if (pwm_cfg->OutputPin == GPIO_13) {
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
}
|
||||
} else if (reg_idx == PWM4_IDX) {
|
||||
gpio_cfg.Mux = GPIO_Mux2;
|
||||
if (pwm_cfg->OutputPin == GPIO_0) {
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
}
|
||||
} else if (reg_idx == PWM5_IDX) {
|
||||
gpio_cfg.Mux = GPIO_Mux2;
|
||||
if (pwm_cfg->OutputPin == GPIO_1) {
|
||||
xc_gpio_init(&gpio_cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t pwm_freq_to_period(PWM_InitCfg_t *pwm_cfg, PWM_ClkDiv_TypeDef div_clk)
|
||||
{
|
||||
uint32_t pwm_clk;
|
||||
|
||||
switch (pwm_cfg->SrcClk) {
|
||||
case PWM_CLK_SRC_32M_DIV: {
|
||||
pwm_clk = xc_clock_hfclk_in_get() / PWM_CLK_DIV_CAL(div_clk);
|
||||
} break;
|
||||
|
||||
case PWM_CLK_SRC_32K_DIV: {
|
||||
pwm_clk = xc_clock_lfclk_in_get() / PWM_CLK_DIV_CAL(div_clk);
|
||||
} break;
|
||||
|
||||
case PWM_CLK_SRC_32K: {
|
||||
pwm_clk = CLOCK_LFCLK_IN_32K;
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t freq_max = PWM_FREQ_MAX_CAL(pwm_clk, pwm_cfg->DutyCycleAcc);
|
||||
|
||||
uint32_t freq = PWM_FREQ_CAL(pwm_clk, pwm_cfg->DutyCycleAcc, pwm_cfg->Period);
|
||||
|
||||
if (freq > freq_max) {
|
||||
//h
|
||||
// DEBUG("%s,line=%d,set freq=%d,The maximum configurable frequency %d hz "
|
||||
// "has been exceeded.\n",
|
||||
// __func__, __LINE__, freq, freq_max);
|
||||
} else {
|
||||
// DEBUG("%s,line=%d,set freq=%d,maximum configurable frequency %d hz\n", __func__, __LINE__, freq, freq_max);
|
||||
}
|
||||
|
||||
return pwm_cfg->Period;
|
||||
}
|
||||
|
||||
void xc_pwm_dutycycle_set(uint8_t reg_idx, uint32_t dutycycle_acc, uint32_t dutycycle)
|
||||
{
|
||||
pwm_en__mode__setf(reg_idx, PWM_EN_MODE_ACC_65535);
|
||||
|
||||
pwm_ocpy__ocpy_ratio_config__setf(reg_idx, (dutycycle_acc - 1));
|
||||
|
||||
pwm_ocpy__ocpy_ratio__setf(reg_idx, dutycycle_acc - dutycycle);
|
||||
|
||||
pwm_up__update__setf(reg_idx, PWM_UP_UPDATE_ENABLE);
|
||||
}
|
||||
|
||||
void xc_pwm_lowpower_enable(uint8_t reg_idx) { pwm_en__sleep_en__setf(reg_idx, PWM_EN_SLEEP_EN_ENABLE); }
|
||||
|
||||
void xc_pwm_lowpower_disable(uint8_t reg_idx) { pwm_en__sleep_en__setf(reg_idx, PWM_EN_SLEEP_EN_DISABLE); }
|
||||
|
||||
void xc_pwm_lowpower_countdirection_set(uint8_t reg_idx, uint32_t direction)
|
||||
{
|
||||
pwm_en__sleep_incr__setf(reg_idx, direction);
|
||||
}
|
||||
|
||||
void xc_pwm_brake_enable(uint8_t reg_idx)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = pwm_break_ctl__pwm_brk_enable__getf(PWM0_IDX);
|
||||
|
||||
if (reg_idx == PWM0_IDX || reg_idx == PWM1_IDX) {
|
||||
val &= ~(PWM_BRK0_ENABLE_ENABLE);
|
||||
val |= (PWM_BRK0_ENABLE_ENABLE);
|
||||
} else if (reg_idx == PWM2_IDX || reg_idx == PWM3_IDX) {
|
||||
val &= ~(PWM_BRK1_ENABLE_ENABLE);
|
||||
val |= (PWM_BRK1_ENABLE_ENABLE);
|
||||
} else if (reg_idx == PWM4_IDX || reg_idx == PWM5_IDX) {
|
||||
val &= ~(PWM_BRK2_ENABLE_ENABLE);
|
||||
val |= (PWM_BRK2_ENABLE_ENABLE);
|
||||
}
|
||||
|
||||
pwm_break_ctl__pwm_brk_enable__setf(PWM0_IDX, val);
|
||||
}
|
||||
|
||||
void xc_pwm_brake_disable(uint8_t reg_idx)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = pwm_break_ctl__pwm_brk_enable__getf(PWM0_IDX);
|
||||
|
||||
if (reg_idx == PWM0_IDX || reg_idx == PWM1_IDX) {
|
||||
val &= ~(PWM_BRK0_ENABLE_ENABLE);
|
||||
} else if (reg_idx == PWM2_IDX || reg_idx == PWM3_IDX) {
|
||||
val &= ~(PWM_BRK1_ENABLE_ENABLE);
|
||||
} else if (reg_idx == PWM4_IDX || reg_idx == PWM5_IDX) {
|
||||
val &= ~(PWM_BRK2_ENABLE_ENABLE);
|
||||
}
|
||||
|
||||
pwm_break_ctl__pwm_brk_enable__setf(PWM0_IDX, val);
|
||||
}
|
||||
|
||||
uint8_t xc_pwm_brake_signal_valid_get(void) { return pwm_break_ctl__pwm_brk_sync__getf(PWM0_IDX); }
|
||||
|
||||
void xc_pwm_brake_signal_mask_set(uint32_t mask) { pwm_break_ctl__pwm_brk_mask__setf(PWM0_IDX, mask); }
|
||||
|
||||
void xc_pwm_brake_signal_trigger_level_set(uint32_t level) { pwm_break_ctl__pwm_brk_inv__setf(PWM0_IDX, level); }
|
||||
|
||||
void xc_pwm_brake_recovery_mode_set(uint32_t mode) { pwm_break_ctl__brk_mode__setf(PWM0_IDX, mode); }
|
||||
|
||||
uint8_t xc_pwm_brake_recovery_mode_get(void) { return (pwm_break_ctl__brk_mode__getf(PWM0_IDX)); }
|
||||
|
||||
void xc_pwm_brake_debounce_set(uint32_t debounce, uint32_t step)
|
||||
{
|
||||
pwm_break_ctl__brk_dbc_en__setf(PWM0_IDX, debounce);
|
||||
pwm_break_ctl__brk_dbc_step__setf(PWM0_IDX, step);
|
||||
}
|
||||
|
||||
void xc_pwm_brake_clear() { pwm_break_ctl__clear__setf(PWM0_IDX, PWM_BRK_BRK_CLEAR_EXIT); }
|
||||
|
||||
void xc_pwm_capture_enable(uint8_t ch) { cap_tim_ctl__capture_enable__setf(ch, PWM_CAPTURE_ENABLE); }
|
||||
|
||||
void xc_pwm_capture_disable(uint8_t ch) { cap_tim_ctl__capture_enable__setf(ch, PWM_CAPTURE_DISABLE); }
|
||||
|
||||
void xc_pwm_capture_enable_it(uint8_t ch)
|
||||
{
|
||||
if (ch == 0) {
|
||||
pwm_cap_tim_int_en__capture_upd_0_en__setf(ENABLE);
|
||||
} else if (ch == 1) {
|
||||
pwm_cap_tim_int_en__capture_upd_1_en__setf(ENABLE);
|
||||
} else if (ch == 2) {
|
||||
pwm_cap_tim_int_en__capture_upd_2_en__setf(ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void xc_pwm_capture_disable_it(uint8_t ch)
|
||||
{
|
||||
if (ch == PWM_IC_CH0) {
|
||||
pwm_cap_tim_int_en__capture_upd_0_en__setf(DISABLE);
|
||||
} else if (ch == PWM_IC_CH1) {
|
||||
pwm_cap_tim_int_en__capture_upd_1_en__setf(DISABLE);
|
||||
} else if (ch == PWM_IC_CH2) {
|
||||
pwm_cap_tim_int_en__capture_upd_2_en__setf(DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void xc_pwm_capture_signal_set(uint8_t ch, uint32_t signal) { cap_tim_ctl__capture_sig_sel__setf(ch, signal); }
|
||||
|
||||
void xc_pwm_capture_debounce_enable(uint8_t ch, uint32_t step)
|
||||
{
|
||||
cap_tim_ctl__dbc_en__setf(ch, PWM_CAPTURE_DBC_ENABLE);
|
||||
|
||||
cap_tim_ctl__dbc_step__setf(ch, step);
|
||||
}
|
||||
|
||||
void xc_pwm_capture_debounce_disable(uint8_t ch, uint32_t step)
|
||||
{
|
||||
cap_tim_ctl__dbc_en__setf(ch, PWM_CAPTURE_DBC_DISABLE);
|
||||
|
||||
cap_tim_ctl__dbc_step__setf(ch, step);
|
||||
}
|
||||
|
||||
void xc_pwm_capture_edge_set(uint8_t ch, uint32_t edge) { cap_tim_ctl__capture_mode__setf(ch, edge); }
|
||||
|
||||
void xc_pwm_capture_psc_set(uint8_t ch, uint32_t psc) { cap_tim_ctl__capture_psc__setf(ch, psc); }
|
||||
|
||||
void xc_pwm_capture_counter_enable(uint8_t ch)
|
||||
{
|
||||
cap_tim_ctl__common_cnt_enable__setf(ch, PWM_CAPTURE_COMMON_CNT_ENABLE);
|
||||
}
|
||||
|
||||
void xc_pwm_capture_counter_disable(uint8_t ch)
|
||||
{
|
||||
cap_tim_ctl__common_cnt_enable__setf(ch, PWM_CAPTURE_COMMON_CNT_DISABLE);
|
||||
}
|
||||
|
||||
uint16_t xc_pwm_capture_val_get(uint8_t ch) { return cap_tim_val__capture_value__getf(ch); }
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------------------------
|
||||
* PWM Timer
|
||||
*-----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in]
|
||||
* @param[in]
|
||||
****************************************************************************************
|
||||
*/
|
||||
void xc_pwm_timer_init(uint8_t reg_idx, PWM_Timer_InitCfg_t *init_cfg)
|
||||
{
|
||||
if (reg_idx > PWM_TIMER5_IDX)
|
||||
return;
|
||||
|
||||
if (pwm_clk_init_state == STATE_UNINITIALIZED) {
|
||||
cpr_ctlapbclken_grctl__pwm_pclk_en__setf(ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__pwm_rstn__setf(RSTCTL_ENABLE);
|
||||
cpr_rstctl_ctlapb_sw__pwm_rstn__setf(RSTCTL_DISABLE);
|
||||
|
||||
cpr_pwm_clk_ctl__pwm_clk_en__setf(ENABLE);
|
||||
cpr_pwm_clk_ctl__pwm_clksel__setf(init_cfg->src_clk);
|
||||
cpr_pwm_clk_ctl__pwm_clk0_div__setf(init_cfg->clk_div);
|
||||
cpr_pwm_clk_ctl__pwm_clk1_div__setf(init_cfg->clk_div);
|
||||
|
||||
pwm_clk_init_state = STATE_INITIALIZED;
|
||||
}
|
||||
|
||||
uint32_t ctl_reg = (init_cfg->timer_mode << TIMER_MODE_POS) | (init_cfg->timer_int_mask_en << TIMER_INT_MASK_POS) |
|
||||
(init_cfg->timer_pwm_en << TIMER_PWM_POS) |
|
||||
(init_cfg->timer_0to100_pwm_en << TIMER_ON10OPWM_EN_POS);
|
||||
|
||||
pwm_timer_controlreg_set(reg_idx, ctl_reg);
|
||||
}
|
||||
|
||||
void xc_pwm_timer_deinit(uint8_t reg_idx)
|
||||
{
|
||||
pwm_clk_init_state = STATE_UNINITIALIZED;
|
||||
cpr_ctlapbclken_grctl__pwm_pclk_en__setf(DISABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in]
|
||||
* @param[in]
|
||||
****************************************************************************************
|
||||
*/
|
||||
void xc_pwm_timer_set_freq(uint8_t reg_idx, uint32_t freq) { period = xc_clock_hfclk_in_get() / 2 / freq; }
|
||||
|
||||
void xc_pwm_timer_set_dutycycle(uint8_t reg_idx, double dutycycle)
|
||||
{
|
||||
uint16_t high_cnt = ((uint32_t)(period * dutycycle) / 100);
|
||||
uint16_t low_cnt = (uint32_t)(period - high_cnt);
|
||||
|
||||
pwm_timer_loadcount__timer_lc__setf(reg_idx, low_cnt);
|
||||
pwm_timer_loadcount2__timer_lc2__setf(reg_idx, high_cnt);
|
||||
}
|
||||
|
||||
void xc_pwm_timer_set_high_cnt(uint8_t reg_idx, uint16_t high_cnt)
|
||||
{
|
||||
pwm_timer_loadcount2__timer_lc2__setf(reg_idx, high_cnt);
|
||||
}
|
||||
|
||||
void xc_pwm_timer_set_low_cnt(uint8_t reg_idx, uint16_t low_cnt)
|
||||
{
|
||||
pwm_timer_loadcount__timer_lc__setf(reg_idx, low_cnt);
|
||||
}
|
||||
/**
|
||||
****************************************************************************************
|
||||
* @brief
|
||||
*
|
||||
* @param[in]
|
||||
* @param[in]
|
||||
****************************************************************************************
|
||||
*/
|
||||
void xc_pwm_timer_start(uint8_t reg_idx) { pwm_timer_controlreg__timer_en__setf(reg_idx, ENABLE); }
|
||||
|
||||
void xc_pwm_timer_stop(uint8_t reg_idx) { pwm_timer_controlreg__timer_en__setf(reg_idx, DISABLE); }
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------*/
|
||||
|
||||
void PWM_Handler(void)
|
||||
{
|
||||
uint32_t cap_tim_int;
|
||||
|
||||
cap_tim_int = pwm_cap_tim_int_get();
|
||||
|
||||
pwm_cap_tim_int_set(cap_tim_int); // clear inter
|
||||
|
||||
if ((cap_tim_int & PWM_CAPTURE_UPD0_EN_ENABLE) == PWM_CAPTURE_UPD0_EN_ENABLE) {
|
||||
pwm_capture_ch0_callback(NULL);
|
||||
}
|
||||
if ((cap_tim_int & PWM_CAPTURE_UPD1_EN_ENABLE) == PWM_CAPTURE_UPD1_EN_ENABLE) {
|
||||
pwm_capture_ch1_callback(NULL);
|
||||
}
|
||||
if ((cap_tim_int & PWM_CAPTURE_UPD2_EN_ENABLE) == PWM_CAPTURE_UPD2_EN_ENABLE) {
|
||||
pwm_capture_ch2_callback(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
__WEAK uint8_t pwm_capture_ch0_callback(void *context) { return 0; }
|
||||
|
||||
__WEAK uint8_t pwm_capture_ch1_callback(void *context) { return 0; }
|
||||
|
||||
__WEAK uint8_t pwm_capture_ch2_callback(void *context) { return 0; }
|
||||
@@ -0,0 +1,317 @@
|
||||
/*!
|
||||
* \file xc_drv_pwm.h
|
||||
*
|
||||
* \brief The header of xc_drv_pwm.c
|
||||
*
|
||||
* \copyright Revised BSD License, see section \ref LICENSE.
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* _ __ _ ________ _
|
||||
* | |/ /(_)___ / ____/ /_ (_)___
|
||||
* | // / __ \/ / / __ \/ / __ \
|
||||
* / |/ / / / / /___/ / / / / /_/ /
|
||||
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
|
||||
* /_/
|
||||
* (C) 2022-2025 XinChip
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* \author ( XinChip ) Alex-J
|
||||
*
|
||||
* \author ( XinChip )
|
||||
*/
|
||||
|
||||
#ifndef _XC_DRV_PWM_H_
|
||||
#define _XC_DRV_PWM_H_
|
||||
|
||||
/*-----------------------------------------------------------------------------------
|
||||
INCLUDE HEADE FILES
|
||||
------------------------------------------------------------------------------------*/
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xc6xxx.h"
|
||||
/*------------------------------------------------------------------------------------
|
||||
Macros
|
||||
-------------------------------------------------------------------------------------*/
|
||||
#define PWM_CLK_DIV_CAL(div) (2 * (div + 1))
|
||||
#define PWM_FREQ_MAX_CAL(pwm_clk, dutycycle_acc) \
|
||||
(pwm_clk / (dutycycle_acc * (0 + 1)) / 2)
|
||||
#define PWM_FREQ_CAL(pwm_clk, dutycycle_acc, period) \
|
||||
(pwm_clk / (dutycycle_acc * (period + 1)) / 2)
|
||||
|
||||
#define PWM_UP_UPDATE_ENABLE (1UL)
|
||||
#define PWM_UP_UPDATE_DISABLE (0UL)
|
||||
|
||||
#define PWM_EN_ENABLE (0x01UL)
|
||||
#define PWM_EN_DISABLE (0x00UL)
|
||||
#define PWM_EN_ALL_ENABLE (0x01UL)
|
||||
#define PWM_EN_ALL_DISABLE (0x00UL)
|
||||
#define PWM_EN_SLEEP_EN_ENABLE (0x01UL)
|
||||
#define PWM_EN_SLEEP_EN_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_EN_MODE_ACC_65535 (0x02UL)
|
||||
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_Pos (0x00UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_Msk (0xFFUL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_1CLK (0x00UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_2CLK (0x01UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_3CLK (0x02UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_4CLK (0x03UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_5CLK (0x04UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_6CLK (0x05UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_7CLK (0x06UL)
|
||||
#define PWM_COMP_TIME_PWMCOMPTIME_VAL_8CLK (0x07UL)
|
||||
|
||||
#define PWM_BRK_BRK_CLEAR_EXIT (0x01UL)
|
||||
|
||||
#define PWM_BRK_DBC_EN_ENABLE (0x01UL)
|
||||
#define PWM_BRK_DBC_EN_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_BRK_DBC_STEP1 (0x01UL)
|
||||
#define PWM_BRK_DBC_STEP2 (0x02UL)
|
||||
#define PWM_BRK_DBC_STEP3 (0x03UL)
|
||||
#define PWM_BRK_DBC_STEP4 (0x04UL)
|
||||
#define PWM_BRK_DBC_STEP5 (0x05UL)
|
||||
#define PWM_BRK_DBC_STEP6 (0x06UL)
|
||||
#define PWM_BRK_DBC_STEP7 (0x07UL)
|
||||
#define PWM_BRK_DBC_STEP8 (0x08UL)
|
||||
#define PWM_BRK_DBC_STEP9 (0x09UL)
|
||||
#define PWM_BRK_DBC_STEP10 (0x0AUL)
|
||||
|
||||
#define PWM_BRK0_INV_ENABLE (0x01UL)
|
||||
#define PWM_BRK0_INV_DISABLE (0x00UL)
|
||||
#define PWM_BRK1_INV_ENABLE (0x02UL)
|
||||
#define PWM_BRK1_INV_DISABLE (0x00UL)
|
||||
#define PWM_BRK2_INV_ENABLE (0x04UL)
|
||||
#define PWM_BRK2_INV_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_BRK0_MASK_ENABLE (0x01UL)
|
||||
#define PWM_BRK0_MASK_DISABLE (0x00UL)
|
||||
#define PWM_BRK1_MASK_ENABLE (0x02UL)
|
||||
#define PWM_BRK1_MASK_DISABLE (0x00UL)
|
||||
#define PWM_BRK2_MASK_ENABLE (0x04UL)
|
||||
#define PWM_BRK2_MASK_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_BRK0_ENABLE_ENABLE (0x01UL)
|
||||
#define PWM_BRK0_ENABLE_DISABLE (0x00UL)
|
||||
#define PWM_BRK1_ENABLE_ENABLE (0x02UL)
|
||||
#define PWM_BRK1_ENABLE_DISABLE (0x00UL)
|
||||
#define PWM_BRK2_ENABLE_ENABLE (0x04UL)
|
||||
#define PWM_BRK2_ENABLE_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_CAPTURE_UPD0_EN_ENABLE (0x01UL)
|
||||
#define PWM_CAPTURE_UPD1_EN_ENABLE (0x02UL)
|
||||
#define PWM_CAPTURE_UPD2_EN_ENABLE (0x04UL)
|
||||
|
||||
#define PWM_CAPTURE_PSC_1 (0x00UL)
|
||||
#define PWM_CAPTURE_PSC_2 (0x01UL)
|
||||
#define PWM_CAPTURE_PSC_3 (0x02UL)
|
||||
|
||||
#define PWM_CAPTURE_MODE_RISE (0x00UL)
|
||||
#define PWM_CAPTURE_MODE_FALL (0x01UL)
|
||||
#define PWM_CAPTURE_MODE_BOTH (0x02UL)
|
||||
|
||||
#define PWM_CAPTURE_DBC_STEP0 (0x00UL)
|
||||
#define PWM_CAPTURE_DBC_STEP1 (0x01UL)
|
||||
#define PWM_CAPTURE_DBC_STEP2 (0x02UL)
|
||||
#define PWM_CAPTURE_DBC_STEP3 (0x03UL)
|
||||
#define PWM_CAPTURE_DBC_STEP4 (0x04UL)
|
||||
#define PWM_CAPTURE_DBC_STEP5 (0x05UL)
|
||||
#define PWM_CAPTURE_DBC_STEP6 (0x06UL)
|
||||
#define PWM_CAPTURE_DBC_STEP7 (0x07UL)
|
||||
#define PWM_CAPTURE_DBC_STEP8 (0x08UL)
|
||||
#define PWM_CAPTURE_DBC_STEP9 (0x09UL)
|
||||
#define PWM_CAPTURE_DBC_STEP10 (0x0AUL)
|
||||
#define PWM_CAPTURE_DBC_STEP11 (0x0BUL)
|
||||
#define PWM_CAPTURE_DBC_STEP12 (0x0CUL)
|
||||
|
||||
#define PWM_CAPTURE_SIG_SEL_PWM_CAPTURE0 (0x00UL)
|
||||
#define PWM_CAPTURE_SIG_SEL_PWM_CAPTURE1 (0x01UL)
|
||||
#define PWM_CAPTURE_SIG_SEL_PWM_CAPTURE2 (0x02UL)
|
||||
#define PWM_CAPTURE_SIG_SEL_PWM_BRK0 (0x03UL)
|
||||
#define PWM_CAPTURE_SIG_SEL_PWM_BRK1 (0x04UL)
|
||||
#define PWM_CAPTURE_SIG_SEL_PWM_BRK2 (0x05UL)
|
||||
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_0 (0x00UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_2 (0x01UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_3 (0x02UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_4 (0x03UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_5 (0x04UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_6 (0x05UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_7 (0x06UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_8 (0x07UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_9 (0x08UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_10 (0x09UL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_11 (0x0AUL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_12 (0x0BUL)
|
||||
#define PWM_CAPTURE_CLK_DIV_VAL_13 (0x0CUL)
|
||||
|
||||
#define PWM_CAPTURE_ENABLE (0x01UL)
|
||||
#define PWM_CAPTURE_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_CAPTURE_DBC_ENABLE (0x01UL)
|
||||
#define PWM_CAPTURE_DBC_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_CAPTURE_COMMON_CNT_ENABLE (0x01UL)
|
||||
#define PWM_CAPTURE_COMMON_CNT_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_CAPTURE_UPD_EN_ENABLE (0x01UL)
|
||||
#define PWM_CAPTURE_UPD_EN_DISABLE (0x00UL)
|
||||
|
||||
#define PWM_SIGNAL_CAPTURE0_GPIO3 GPIO_3
|
||||
#define PWM_SIGNAL_CAPTURE1_GPIO8 GPIO_8
|
||||
#define PWM_SIGNAL_CAPTURE2_GPIO9 GPIO_9
|
||||
#define PWM_SIGNAL_BRK0_GPIO4 GPIO_4
|
||||
#define PWM_SIGNAL_BRK1_GPIO5 GPIO_5
|
||||
#define PWM_SIGNAL_BRK2_GPIO6 GPIO_6
|
||||
|
||||
#define PWM_IC_CH0 0
|
||||
#define PWM_IC_CH1 1
|
||||
#define PWM_IC_CH2 2
|
||||
|
||||
#define PWM_BRK_SYNC_VALID 1
|
||||
#define PWM_BRK_SYNC_INVALID 0
|
||||
|
||||
#define PWM_BRK0_HIGH_LEVEL PWM_BRK0_INV_DISABLE
|
||||
#define PWM_BRK0_LOW_LEVEL PWM_BRK0_INV_ENABLE
|
||||
#define PWM_BRK1_HIGH_LEVEL PWM_BRK1_INV_DISABLE
|
||||
#define PWM_BRK1_LOW_LEVEL PWM_BRK1_INV_ENABLE
|
||||
#define PWM_BRK2_HIGH_LEVEL PWM_BRK2_INV_DISABLE
|
||||
#define PWM_BRK2_LOW_LEVEL PWM_BRK2_INV_ENABLE
|
||||
|
||||
#define PWM_ICSIG_CAPTURE0 PWM_CAPTURE_SIG_SEL_PWM_CAPTURE0
|
||||
#define PWM_ICSIG_CAPTURE1 PWM_CAPTURE_SIG_SEL_PWM_CAPTURE1
|
||||
#define PWM_ICSIG_CAPTURE2 PWM_CAPTURE_SIG_SEL_PWM_CAPTURE2
|
||||
|
||||
#define PWM_ALL_ENABLE PWM_EN_ALL_ENABLE
|
||||
#define PWM_ALL_DISABLE PWM_EN_ALL_DISABLE
|
||||
|
||||
#define PWM_SLEEP_COUNT_DIRECTION_UP (0x01UL)
|
||||
#define PWM_SLEEP_COUNT_DIRECTION_DOWN (0x00UL)
|
||||
|
||||
#define PWM_SLEEP_ENABLE PWM_SLEEP_EN_ENABLE
|
||||
#define PWM_SLEEP_DISABLE PWM_SLEEP_EN_DISABLE
|
||||
|
||||
#define PWM_EN_SEL_SELF (0x00UL)
|
||||
#define PWM_EN_SEL_ALL (0x01UL)
|
||||
|
||||
#define PWM_BRK_MODE_HARDWARE (0x00UL)
|
||||
#define PWM_BRK_MODE_SOFTWARE (0x01UL)
|
||||
|
||||
#define PWM_TIMER_MODE_USER_DEFINED (0x01UL)
|
||||
#define PWM_TIMER_MODE_FREE_RUNNING (0x00UL)
|
||||
/*------------------------------------------------------------------------------------
|
||||
TypeDef
|
||||
-------------------------------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
PWM_CLK_SRC_32M_DIV = 0, /*PWM CLK SRC 32MHz div.*/
|
||||
PWM_CLK_SRC_32K_DIV = 1, /*PWM CLK SRC 32kHz div.*/
|
||||
PWM_CLK_SRC_32K = 4, /*PWM CLK SRC 32kHz.*/
|
||||
} PWM_ClkSrc_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PWM_CLK_DIV0 = 0UL, /*PWM CLK 16 MHz or 16KHz*/
|
||||
PWM_CLK_DIV1 = 1UL, /*PWM CLK 8 MHz or 8KHz*/
|
||||
PWM_CLK_DIV3 = 3UL, /*PWM CLK 4 MHz or 4KHz.*/
|
||||
PWM_CLK_DIV7 = 7UL, /*PWM CLK 2 MHz or 2KHz.*/
|
||||
PWM_CLK_DIV15 = 15UL, /*PWM CLK 1 MHz or 1KHz.*/
|
||||
PWM_CLK_DIV31 = 31UL, /*PWM CLK 500 kHz or 500Hz.*/
|
||||
PWM_CLK_DIV63 = 63UL, /*PWM CLK 250 kHz or 250Hz.*/
|
||||
PWM_CLK_DIV127 = 127UL, /*PWM CLK 125 kHz or 125Hz.*/
|
||||
PWM_CLK_DIV255 = 255UL, /*PWM CLK 62500 Hz or 62.5Hz.*/
|
||||
} PWM_ClkDiv_TypeDef;
|
||||
|
||||
typedef enum pwm_timer_number
|
||||
{
|
||||
PWM_NO_TIMER = 0x00,
|
||||
PWM_TIMER_1 = 0x01,
|
||||
PWM_TIMER_2 = 0x02,
|
||||
PWM_TIMER_3 = 0x04,
|
||||
PWM_TIMER_4 = 0x08,
|
||||
PWM_TIMER_5 = 0x10,
|
||||
PWM_TIMER_6 = 0x20,
|
||||
PWM_ALL_TIMER = 0x3F,
|
||||
} ePWM_Timer_Num;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PWM_ClkSrc_TypeDef SrcClk;
|
||||
uint32_t DutyCycleAcc;
|
||||
uint32_t DutyCycle;
|
||||
uint8_t SrcEnable;
|
||||
uint8_t Period;
|
||||
uint8_t DivClk;
|
||||
uint8_t OutputPin;
|
||||
uint8_t OutputInvertPin;
|
||||
uint8_t InvertDelay;
|
||||
bool InvertEnable;
|
||||
|
||||
} PWM_InitCfg_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PWM_ClkSrc_TypeDef src_clk;
|
||||
PWM_ClkDiv_TypeDef clk_div;
|
||||
uint8_t timer_0to100_pwm_en;
|
||||
uint8_t timer_pwm_en;
|
||||
uint8_t timer_int_mask_en;
|
||||
uint8_t timer_mode; /* 0x0 FREE_RUNNING; 0x1 USER_DEFINED */
|
||||
} PWM_Timer_InitCfg_t;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Global Variables
|
||||
-------------------------------------------------------------------------------------*/
|
||||
typedef uint8_t (*pwm_handler_callback)(void *context);
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
Exported Functions
|
||||
-------------------------------------------------------------------------------------*/
|
||||
void xc_pwm_init(uint8_t reg_idx, PWM_InitCfg_t *pwm_cfg);
|
||||
void xc_pwm_start(uint8_t reg_idx);
|
||||
void xc_pwm_stop(uint8_t reg_idx);
|
||||
void xc_pwm_start_all(void);
|
||||
void xc_pwm_stop_all(void);
|
||||
void pwm_pin_set(uint8_t reg_idx, PWM_InitCfg_t *pwm_cfg);
|
||||
void xc_pwm_dutycycle_set(uint8_t reg_idx, uint32_t dutycycle_acc, uint32_t dutycycle);
|
||||
void xc_pwm_lowpower_enable(uint8_t reg_idx);
|
||||
void xc_pwm_lowpower_disable(uint8_t reg_idx);
|
||||
void xc_pwm_lowpower_countdirection_set(uint8_t reg_idx, uint32_t direction);
|
||||
void xc_pwm_brake_enable(uint8_t reg_idx);
|
||||
void xc_pwm_brake_disable(uint8_t reg_idx);
|
||||
uint8_t xc_pwm_brake_signal_valid_get(void);
|
||||
void xc_pwm_brake_signal_mask_set(uint32_t mask);
|
||||
void xc_pwm_brake_signal_trigger_level_set(uint32_t invert);
|
||||
void xc_pwm_brake_recovery_mode_set(uint32_t mode);
|
||||
uint8_t xc_pwm_brake_recovery_mode_get(void);
|
||||
void xc_pwm_brake_debounce_set(uint32_t debounce, uint32_t step);
|
||||
void xc_pwm_brake_clear(void);
|
||||
void xc_pwm_capture_enable(uint8_t ch);
|
||||
void xc_pwm_capture_disable(uint8_t ch);
|
||||
void xc_pwm_capture_enable_it(uint8_t ch);
|
||||
void xc_pwm_capture_disable_it(uint8_t ch);
|
||||
void xc_pwm_capture_signal_set(uint8_t ch, uint32_t signal);
|
||||
void xc_pwm_capture_debounce_enable(uint8_t ch, uint32_t step);
|
||||
void xc_pwm_capture_debounce_disable(uint8_t ch, uint32_t step);
|
||||
void xc_pwm_capture_edge_set(uint8_t ch, uint32_t edge);
|
||||
void xc_pwm_capture_psc_set(uint8_t ch, uint32_t psc);
|
||||
void xc_pwm_capture_counter_enable(uint8_t ch);
|
||||
void xc_pwm_capture_counter_disable(uint8_t ch);
|
||||
uint16_t xc_pwm_capture_val_get(uint8_t ch);
|
||||
|
||||
void xc_pwm_timer_init(uint8_t reg_idx, PWM_Timer_InitCfg_t *init_cfg);
|
||||
void xc_pwm_timer_deinit(uint8_t reg_idx);
|
||||
void xc_pwm_timer_set_freq(uint8_t reg_idx, uint32_t freq);
|
||||
void xc_pwm_timer_set_dutycycle(uint8_t reg_idx, double dutycycle);
|
||||
void xc_pwm_timer_start(uint8_t reg_idx);
|
||||
void xc_pwm_timer_stop(uint8_t reg_idx);
|
||||
void xc_pwm_timer_set_high_cnt(uint8_t reg_idx, uint16_t high_cnt);
|
||||
void xc_pwm_timer_set_low_cnt(uint8_t reg_idx, uint16_t high_cnt);
|
||||
|
||||
uint8_t pwm_capture_ch0_callback(void *context);
|
||||
uint8_t pwm_capture_ch1_callback(void *context);
|
||||
uint8_t pwm_capture_ch2_callback(void *context);
|
||||
#endif // _XC_DRV_PWM_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,25 @@
|
||||
LOAD 0x1100E000
|
||||
{
|
||||
EXE 0x1100E000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
|
||||
RW 0x10002400
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
|
||||
}
|
||||
ScatterAssert((0x2400+ImageLength(RW)) < 1024 * 32 )
|
||||
RW2 (0x530077b0)
|
||||
{
|
||||
*(ram_em)
|
||||
}
|
||||
ScatterAssert((0x530077b0)+ImageLength(RW2) < 0x53008000)
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
LOAD 0x11011000
|
||||
{
|
||||
EXE 0x11011000
|
||||
{
|
||||
startup_xinc.o (RESET, +FIRST)
|
||||
* (+RO)
|
||||
|
||||
}
|
||||
|
||||
RW 0x10003400
|
||||
{
|
||||
startup_xinc.o(STACK)
|
||||
* (+RW,+ZI)
|
||||
*(ram_code)
|
||||
aeabi_sdiv.o(.text)
|
||||
uread4.o(.text)
|
||||
rt_memclr.o(.text)
|
||||
}
|
||||
ScatterAssert((0x3400+ImageLength(RW)) < 1024 * 32 )
|
||||
RW2 (0x530077b0)
|
||||
{
|
||||
*(ram_em)
|
||||
}
|
||||
ScatterAssert((0x530077b0)+ImageLength(RW2) < 0x53008000)
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,953 @@
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1
|
||||
|
||||
|
||||
1 00000000
|
||||
2 00000000 ;/******************************************************
|
||||
***********************
|
||||
3 00000000 ; * @file: startup_xinc.s
|
||||
4 00000000 ; * @purpose: CMSIS Cortex-M0 Core Device Startup File f
|
||||
or the
|
||||
5 00000000 ; * Device xinc.
|
||||
6 00000000 ; ******************************************************
|
||||
***********************/
|
||||
7 00000000
|
||||
8 00000000 00000800
|
||||
Stack_Size
|
||||
EQU 0x00000800
|
||||
9 00000000
|
||||
10 00000000 AREA STACK, NOINIT, READWRITE, ALIGN
|
||||
=3
|
||||
11 00000000 Stack_Mem
|
||||
SPACE Stack_Size
|
||||
12 00000800 __initial_sp
|
||||
13 00000800
|
||||
14 00000800 000000FF
|
||||
Heap_Size
|
||||
EQU 0x000000ff
|
||||
15 00000800
|
||||
16 00000800 AREA HEAP, NOINIT, READWRITE, ALIGN=
|
||||
3
|
||||
17 00000000 __heap_base
|
||||
18 00000000 Heap_Mem
|
||||
SPACE Heap_Size
|
||||
19 000000FF __heap_limit
|
||||
20 000000FF
|
||||
21 000000FF
|
||||
22 000000FF PRESERVE8
|
||||
23 000000FF THUMB
|
||||
24 00000100
|
||||
25 00000100 ; Vector Table Mapped to Address 0 at Reset
|
||||
26 00000100
|
||||
27 00000100 AREA RESET, DATA, READONLY
|
||||
28 00000000 EXPORT __Vectors
|
||||
29 00000000 EXPORT __Vectors_End
|
||||
30 00000000 EXPORT __Vectors_Size
|
||||
31 00000000
|
||||
32 00000000 00000000
|
||||
__Vectors
|
||||
DCD __initial_sp ; Top of Stack
|
||||
33 00000004 00000000 DCD Reset_Handler ; Reset Handler
|
||||
34 00000008 00000000 DCD NMI_Handler ; NMI Handler
|
||||
35 0000000C 00000000 DCD HardFault_Handler ; Hard Fault
|
||||
Handler
|
||||
36 00000010 00000000 DCD MemManage_Handler
|
||||
; MPU Fault Handler
|
||||
|
||||
37 00000014 00000000 DCD BusFault_Handler
|
||||
; Bus Fault Handler
|
||||
|
||||
38 00000018 00000000 DCD UsageFault_Handler ; Usage Faul
|
||||
t Handler
|
||||
39 0000001C 00000000 DCD 0 ; Reserved
|
||||
40 00000020 00000000 DCD 0 ; Reserved
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 2
|
||||
|
||||
|
||||
41 00000024 00000000 DCD 0 ; Reserved
|
||||
42 00000028 00000000 DCD 0 ; Reserved
|
||||
43 0000002C 00000000 DCD SVC_Handler ; SVCall Handler
|
||||
44 00000030 00000000 DCD DebugMon_Handler ; Debug Monito
|
||||
r Handler
|
||||
45 00000034 00000000 DCD 0 ; Reserved
|
||||
46 00000038 00000000 DCD PendSV_Handler ; PendSV Handler
|
||||
|
||||
47 0000003C 00000000 DCD SysTick_Handler
|
||||
; SysTick Handler
|
||||
48 00000040
|
||||
49 00000040 ; External Interrupts
|
||||
50 00000040 ; ToDo: Add here the vectors for the device specific ex
|
||||
ternal interrupts handler
|
||||
51 00000040 00000000 DCD BLE_Handler ; 0
|
||||
52 00000044 00000000 DCD DMA_Handler ; 1
|
||||
53 00000048 00000000 DCD CPR_Handler ; 2
|
||||
54 0000004C 00000000 DCD GPIO_Handler ; 3
|
||||
55 00000050 00000000 DCD RTC_Handler ; 4
|
||||
56 00000054 00000000 DCD TIMER0_Handler ; 5
|
||||
57 00000058 00000000 DCD TIMER1_Handler ; 6
|
||||
58 0000005C 00000000 DCD TIMER2_Handler ; 7
|
||||
59 00000060 00000000 DCD TIMER3_Handler ; 8
|
||||
60 00000064 00000000 DCD WDT_Handler ; 9
|
||||
61 00000068 00000000 DCD I2C_Handler ; 10
|
||||
62 0000006C 00000000 DCD UART0_Handler ; 11
|
||||
63 00000070 00000000 DCD UART1_Handler ; 12
|
||||
64 00000074 00000000 DCD SPI0_Handler ; 13
|
||||
65 00000078 00000000 DCD SPI1_Handler ; 14
|
||||
66 0000007C 00000000 DCD 0 ; 15
|
||||
67 00000080 00000000 DCD 0 ; 16
|
||||
68 00000084 00000000 DCD GADC_Handler ; 17
|
||||
69 00000088 00000000 DCD PWM_Handler ; 18
|
||||
70 0000008C 00000000 DCD AES_Handler ; 19
|
||||
71 00000090 00000000 DCD USB_Handler ; 20
|
||||
72 00000094 00000000 DCD AUDIO_Handler
|
||||
; 21
|
||||
|
||||
73 00000098 00000000 DCD RF24G_Handler ; 22
|
||||
74 0000009C 00000000 DCD SPI2_Handler ; 23
|
||||
75 000000A0 00000000 DCD 0 ; 24
|
||||
76 000000A4 00000000 DCD UART2_Handler ; 25
|
||||
77 000000A8 00000000 DCD I2S_Handler ; 26
|
||||
78 000000AC 00000000 DCD AOTIMER0_Handler ; 27
|
||||
79 000000B0 00000000 DCD AOTIMER1_Handler ; 28
|
||||
80 000000B4 00000000 DCD CMP_Handler ; 29
|
||||
81 000000B8 00000000 DCD FMC_Handler ; 30
|
||||
82 000000BC 00000000 DCD CAN_Handler ; 31
|
||||
83 000000C0
|
||||
84 000000C0 __Vectors_End
|
||||
85 000000C0
|
||||
86 000000C0 000000C0
|
||||
__Vectors_Size
|
||||
EQU __Vectors_End - __Vectors
|
||||
87 000000C0
|
||||
88 000000C0
|
||||
89 000000C0
|
||||
90 000000C0 AREA |.text|, CODE, READONLY
|
||||
91 00000000 ; Reset Handler
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 3
|
||||
|
||||
|
||||
92 00000000
|
||||
93 00000000 Reset_Handler
|
||||
PROC
|
||||
94 00000000
|
||||
95 00000000 EXPORT Reset_Handler [WEAK]
|
||||
96 00000000
|
||||
97 00000000 IMPORT SystemInit
|
||||
98 00000000 IMPORT __main
|
||||
99 00000000
|
||||
100 00000000 480A LDR r0, =0x4000013C ; remap
|
||||
101 00000002 490B LDR r1, =0x10000001
|
||||
102 00000004 6001 STR r1, [r0]
|
||||
103 00000006
|
||||
104 00000006
|
||||
105 00000006
|
||||
106 00000006 480B LDR R0, =SystemInit
|
||||
107 00000008 4780 BLX R0
|
||||
108 0000000A
|
||||
109 0000000A 480B LDR R0, =__main
|
||||
110 0000000C 4700 BX R0
|
||||
111 0000000E
|
||||
112 0000000E ENDP
|
||||
113 0000000E
|
||||
114 0000000E ; Dummy Exception Handlers (infinite loops which can be
|
||||
modified)
|
||||
115 0000000E NMI_Handler
|
||||
PROC
|
||||
116 0000000E EXPORT NMI_Handler [WEAK
|
||||
]
|
||||
117 0000000E E7FE B .
|
||||
118 00000010 ENDP
|
||||
119 00000010
|
||||
120 00000010
|
||||
122 00000010 HardFault_Handler
|
||||
PROC
|
||||
123 00000010 EXPORT HardFault_Handler [WEAK
|
||||
]
|
||||
124 00000010 E7FE B .
|
||||
125 00000012 ENDP
|
||||
127 00000012 MemManage_Handler
|
||||
PROC
|
||||
128 00000012 EXPORT MemManage_Handler [WEAK
|
||||
]
|
||||
129 00000012 E7FE B .
|
||||
130 00000014 ENDP
|
||||
132 00000014 BusFault_Handler
|
||||
PROC
|
||||
133 00000014 EXPORT BusFault_Handler [WEAK
|
||||
]
|
||||
134 00000014 E7FE B .
|
||||
135 00000016 ENDP
|
||||
137 00000016 UsageFault_Handler
|
||||
PROC
|
||||
138 00000016 EXPORT UsageFault_Handler [WEAK
|
||||
]
|
||||
139 00000016 E7FE B .
|
||||
140 00000018 ENDP
|
||||
141 00000018 SVC_Handler
|
||||
PROC
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 4
|
||||
|
||||
|
||||
142 00000018 EXPORT SVC_Handler [WEAK
|
||||
]
|
||||
143 00000018 E7FE B .
|
||||
144 0000001A ENDP
|
||||
146 0000001A DebugMon_Handler
|
||||
PROC
|
||||
147 0000001A EXPORT DebugMon_Handler [WEAK
|
||||
]
|
||||
148 0000001A E7FE B .
|
||||
149 0000001C ENDP
|
||||
150 0000001C
|
||||
151 0000001C Default_Handler
|
||||
PROC
|
||||
152 0000001C EXPORT BLE_Handler [WEAK
|
||||
]
|
||||
153 0000001C EXPORT DMA_Handler [WE
|
||||
AK]
|
||||
154 0000001C EXPORT CPR_Handler [WEAK]
|
||||
155 0000001C EXPORT GPIO_Handler [WEAK]
|
||||
156 0000001C EXPORT RTC_Handler [WEAK]
|
||||
157 0000001C EXPORT TIMER0_Handler [WEAK]
|
||||
158 0000001C EXPORT TIMER1_Handler [WEAK]
|
||||
159 0000001C EXPORT TIMER2_Handler [WEAK]
|
||||
160 0000001C EXPORT TIMER3_Handler [WEAK]
|
||||
161 0000001C EXPORT WDT_Handler [WE
|
||||
AK]
|
||||
162 0000001C EXPORT I2C_Handler [WEAK]
|
||||
163 0000001C EXPORT UART0_Handler [WEAK
|
||||
]
|
||||
164 0000001C EXPORT UART1_Handler [WE
|
||||
AK]
|
||||
165 0000001C EXPORT SPI0_Handler [WE
|
||||
AK]
|
||||
166 0000001C EXPORT SPI1_Handler [WE
|
||||
AK]
|
||||
167 0000001C ;EXPORT KBS_Handler [WEAK]
|
||||
168 0000001C ;EXPORT QDEC_Handler [WEAK]
|
||||
169 0000001C EXPORT GADC_Handler [WEAK]
|
||||
170 0000001C EXPORT PWM_Handler [WE
|
||||
AK]
|
||||
171 0000001C EXPORT AES_Handler [WE
|
||||
AK]
|
||||
172 0000001C
|
||||
173 0000001C EXPORT PendSV_Handler [WEAK]
|
||||
174 0000001C EXPORT SysTick_Handler [WE
|
||||
AK]
|
||||
175 0000001C
|
||||
176 0000001C EXPORT USB_Handler [WE
|
||||
AK]
|
||||
;20
|
||||
177 0000001C EXPORT AUDIO_Handler [WE
|
||||
AK]
|
||||
;21
|
||||
178 0000001C EXPORT RF24G_Handler [WE
|
||||
AK]
|
||||
;22
|
||||
179 0000001C EXPORT SPI2_Handler [WE
|
||||
AK]
|
||||
;23
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 5
|
||||
|
||||
|
||||
180 0000001C ;EXPORT MPU_Handler [WEAK];24
|
||||
181 0000001C EXPORT UART2_Handler [WE
|
||||
AK]
|
||||
;25
|
||||
182 0000001C EXPORT I2S_Handler [WE
|
||||
AK]
|
||||
;26
|
||||
183 0000001C EXPORT AOTIMER0_Handler [WE
|
||||
AK]
|
||||
;27
|
||||
184 0000001C EXPORT AOTIMER1_Handler [WE
|
||||
AK]
|
||||
;28
|
||||
185 0000001C EXPORT CMP_Handler [WE
|
||||
AK]
|
||||
;29
|
||||
186 0000001C EXPORT FMC_Handler [WE
|
||||
AK]
|
||||
;30
|
||||
187 0000001C EXPORT CAN_Handler [WE
|
||||
AK]
|
||||
;31
|
||||
188 0000001C
|
||||
189 0000001C PendSV_Handler
|
||||
190 0000001C SysTick_Handler
|
||||
191 0000001C BLE_Handler
|
||||
192 0000001C RF24G_Handler
|
||||
193 0000001C DMA_Handler
|
||||
194 0000001C CPR_Handler
|
||||
195 0000001C GPIO_Handler
|
||||
196 0000001C RTC_Handler
|
||||
197 0000001C TIMER0_Handler
|
||||
198 0000001C TIMER1_Handler
|
||||
199 0000001C TIMER2_Handler
|
||||
200 0000001C TIMER3_Handler
|
||||
201 0000001C WDT_Handler
|
||||
202 0000001C I2C_Handler
|
||||
203 0000001C I2S_Handler
|
||||
204 0000001C UART0_Handler
|
||||
205 0000001C UART1_Handler
|
||||
206 0000001C UART2_Handler
|
||||
207 0000001C SPI0_Handler
|
||||
208 0000001C SPI1_Handler
|
||||
209 0000001C SPI2_Handler
|
||||
210 0000001C ;KBS_Handler
|
||||
211 0000001C ;QDEC_Handler
|
||||
212 0000001C GADC_Handler
|
||||
213 0000001C PWM_Handler
|
||||
214 0000001C AUDIO_Handler
|
||||
215 0000001C ;SIM_Handler
|
||||
216 0000001C AES_Handler
|
||||
217 0000001C AOTIMER0_Handler
|
||||
218 0000001C AOTIMER1_Handler
|
||||
219 0000001C CMP_Handler
|
||||
220 0000001C FMC_Handler
|
||||
221 0000001C CAN_Handler
|
||||
222 0000001C USB_Handler
|
||||
223 0000001C
|
||||
224 0000001C E7FE B .
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 6
|
||||
|
||||
|
||||
225 0000001E ENDP
|
||||
226 0000001E
|
||||
227 0000001E
|
||||
228 0000001E 00 00 ALIGN
|
||||
229 00000020
|
||||
230 00000020 ; User Initial Stack & Heap
|
||||
231 00000020
|
||||
232 00000020 IMPORT __use_two_region_memory
|
||||
233 00000020 EXPORT __user_initial_stackheap
|
||||
234 00000020 __user_initial_stackheap
|
||||
235 00000020
|
||||
236 00000020 4806 LDR R0, = Heap_Mem
|
||||
237 00000022 4907 LDR R1, = (Stack_Mem + Stack_Size)
|
||||
238 00000024 4A07 LDR R2, = (Heap_Mem + Heap_Size)
|
||||
239 00000026 4B08 LDR R3, = Stack_Mem
|
||||
240 00000028 4770 BX LR
|
||||
241 0000002A
|
||||
242 0000002A 00 00 ALIGN
|
||||
243 0000002C
|
||||
244 0000002C END
|
||||
4000013C
|
||||
10000001
|
||||
00000000
|
||||
00000000
|
||||
00000000
|
||||
00000800
|
||||
000000FF
|
||||
00000000
|
||||
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M0 --apcs=interw
|
||||
ork --depend=.\objects\startup_xinc.d -o.\objects\startup_xinc.o -I.\RTE\_ble-s
|
||||
dk-xip_scan -ID:\Keil_v5\ARM\PACK\ARM\CMSIS\5.0.1\Device\ARM\ARMCM0\Include -ID
|
||||
:\Keil_v5\ARM\CMSIS\Include --predefine="__EVAL SETA 1" --predefine="__UVISION_
|
||||
VERSION SETA 524" --predefine="ARMCM0 SETA 1" --list=.\listings\startup_xinc.ls
|
||||
t ..\app\src\startup_xinc.s
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
STACK 00000000
|
||||
|
||||
Symbol: STACK
|
||||
Definitions
|
||||
At line 10 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: STACK unused
|
||||
Stack_Mem 00000000
|
||||
|
||||
Symbol: Stack_Mem
|
||||
Definitions
|
||||
At line 11 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 237 in file ..\app\src\startup_xinc.s
|
||||
At line 239 in file ..\app\src\startup_xinc.s
|
||||
|
||||
__initial_sp 00000800
|
||||
|
||||
Symbol: __initial_sp
|
||||
Definitions
|
||||
At line 12 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 32 in file ..\app\src\startup_xinc.s
|
||||
Comment: __initial_sp used once
|
||||
3 symbols
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
HEAP 00000000
|
||||
|
||||
Symbol: HEAP
|
||||
Definitions
|
||||
At line 16 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: HEAP unused
|
||||
Heap_Mem 00000000
|
||||
|
||||
Symbol: Heap_Mem
|
||||
Definitions
|
||||
At line 18 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 236 in file ..\app\src\startup_xinc.s
|
||||
At line 238 in file ..\app\src\startup_xinc.s
|
||||
|
||||
__heap_base 00000000
|
||||
|
||||
Symbol: __heap_base
|
||||
Definitions
|
||||
At line 17 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: __heap_base unused
|
||||
__heap_limit 000000FF
|
||||
|
||||
Symbol: __heap_limit
|
||||
Definitions
|
||||
At line 19 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: __heap_limit unused
|
||||
4 symbols
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
RESET 00000000
|
||||
|
||||
Symbol: RESET
|
||||
Definitions
|
||||
At line 27 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: RESET unused
|
||||
__Vectors 00000000
|
||||
|
||||
Symbol: __Vectors
|
||||
Definitions
|
||||
At line 32 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 28 in file ..\app\src\startup_xinc.s
|
||||
At line 86 in file ..\app\src\startup_xinc.s
|
||||
|
||||
__Vectors_End 000000C0
|
||||
|
||||
Symbol: __Vectors_End
|
||||
Definitions
|
||||
At line 84 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 29 in file ..\app\src\startup_xinc.s
|
||||
At line 86 in file ..\app\src\startup_xinc.s
|
||||
|
||||
3 symbols
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
.text 00000000
|
||||
|
||||
Symbol: .text
|
||||
Definitions
|
||||
At line 90 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: .text unused
|
||||
AES_Handler 0000001C
|
||||
|
||||
Symbol: AES_Handler
|
||||
Definitions
|
||||
At line 216 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 70 in file ..\app\src\startup_xinc.s
|
||||
At line 171 in file ..\app\src\startup_xinc.s
|
||||
|
||||
AOTIMER0_Handler 0000001C
|
||||
|
||||
Symbol: AOTIMER0_Handler
|
||||
Definitions
|
||||
At line 217 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 78 in file ..\app\src\startup_xinc.s
|
||||
At line 183 in file ..\app\src\startup_xinc.s
|
||||
|
||||
AOTIMER1_Handler 0000001C
|
||||
|
||||
Symbol: AOTIMER1_Handler
|
||||
Definitions
|
||||
At line 218 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 79 in file ..\app\src\startup_xinc.s
|
||||
At line 184 in file ..\app\src\startup_xinc.s
|
||||
|
||||
AUDIO_Handler 0000001C
|
||||
|
||||
Symbol: AUDIO_Handler
|
||||
Definitions
|
||||
At line 214 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 72 in file ..\app\src\startup_xinc.s
|
||||
At line 177 in file ..\app\src\startup_xinc.s
|
||||
|
||||
BLE_Handler 0000001C
|
||||
|
||||
Symbol: BLE_Handler
|
||||
Definitions
|
||||
At line 191 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 51 in file ..\app\src\startup_xinc.s
|
||||
At line 152 in file ..\app\src\startup_xinc.s
|
||||
|
||||
BusFault_Handler 00000014
|
||||
|
||||
Symbol: BusFault_Handler
|
||||
Definitions
|
||||
At line 132 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 2 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
At line 37 in file ..\app\src\startup_xinc.s
|
||||
At line 133 in file ..\app\src\startup_xinc.s
|
||||
|
||||
CAN_Handler 0000001C
|
||||
|
||||
Symbol: CAN_Handler
|
||||
Definitions
|
||||
At line 221 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 82 in file ..\app\src\startup_xinc.s
|
||||
At line 187 in file ..\app\src\startup_xinc.s
|
||||
|
||||
CMP_Handler 0000001C
|
||||
|
||||
Symbol: CMP_Handler
|
||||
Definitions
|
||||
At line 219 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 80 in file ..\app\src\startup_xinc.s
|
||||
At line 185 in file ..\app\src\startup_xinc.s
|
||||
|
||||
CPR_Handler 0000001C
|
||||
|
||||
Symbol: CPR_Handler
|
||||
Definitions
|
||||
At line 194 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 53 in file ..\app\src\startup_xinc.s
|
||||
At line 154 in file ..\app\src\startup_xinc.s
|
||||
|
||||
DMA_Handler 0000001C
|
||||
|
||||
Symbol: DMA_Handler
|
||||
Definitions
|
||||
At line 193 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 52 in file ..\app\src\startup_xinc.s
|
||||
At line 153 in file ..\app\src\startup_xinc.s
|
||||
|
||||
DebugMon_Handler 0000001A
|
||||
|
||||
Symbol: DebugMon_Handler
|
||||
Definitions
|
||||
At line 146 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 44 in file ..\app\src\startup_xinc.s
|
||||
At line 147 in file ..\app\src\startup_xinc.s
|
||||
|
||||
Default_Handler 0000001C
|
||||
|
||||
Symbol: Default_Handler
|
||||
Definitions
|
||||
At line 151 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: Default_Handler unused
|
||||
FMC_Handler 0000001C
|
||||
|
||||
Symbol: FMC_Handler
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 3 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
Definitions
|
||||
At line 220 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 81 in file ..\app\src\startup_xinc.s
|
||||
At line 186 in file ..\app\src\startup_xinc.s
|
||||
|
||||
GADC_Handler 0000001C
|
||||
|
||||
Symbol: GADC_Handler
|
||||
Definitions
|
||||
At line 212 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 68 in file ..\app\src\startup_xinc.s
|
||||
At line 169 in file ..\app\src\startup_xinc.s
|
||||
|
||||
GPIO_Handler 0000001C
|
||||
|
||||
Symbol: GPIO_Handler
|
||||
Definitions
|
||||
At line 195 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 54 in file ..\app\src\startup_xinc.s
|
||||
At line 155 in file ..\app\src\startup_xinc.s
|
||||
|
||||
HardFault_Handler 00000010
|
||||
|
||||
Symbol: HardFault_Handler
|
||||
Definitions
|
||||
At line 122 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 35 in file ..\app\src\startup_xinc.s
|
||||
At line 123 in file ..\app\src\startup_xinc.s
|
||||
|
||||
I2C_Handler 0000001C
|
||||
|
||||
Symbol: I2C_Handler
|
||||
Definitions
|
||||
At line 202 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 61 in file ..\app\src\startup_xinc.s
|
||||
At line 162 in file ..\app\src\startup_xinc.s
|
||||
|
||||
I2S_Handler 0000001C
|
||||
|
||||
Symbol: I2S_Handler
|
||||
Definitions
|
||||
At line 203 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 77 in file ..\app\src\startup_xinc.s
|
||||
At line 182 in file ..\app\src\startup_xinc.s
|
||||
|
||||
MemManage_Handler 00000012
|
||||
|
||||
Symbol: MemManage_Handler
|
||||
Definitions
|
||||
At line 127 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 36 in file ..\app\src\startup_xinc.s
|
||||
At line 128 in file ..\app\src\startup_xinc.s
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 4 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
|
||||
NMI_Handler 0000000E
|
||||
|
||||
Symbol: NMI_Handler
|
||||
Definitions
|
||||
At line 115 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 34 in file ..\app\src\startup_xinc.s
|
||||
At line 116 in file ..\app\src\startup_xinc.s
|
||||
|
||||
PWM_Handler 0000001C
|
||||
|
||||
Symbol: PWM_Handler
|
||||
Definitions
|
||||
At line 213 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 69 in file ..\app\src\startup_xinc.s
|
||||
At line 170 in file ..\app\src\startup_xinc.s
|
||||
|
||||
PendSV_Handler 0000001C
|
||||
|
||||
Symbol: PendSV_Handler
|
||||
Definitions
|
||||
At line 189 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 46 in file ..\app\src\startup_xinc.s
|
||||
At line 173 in file ..\app\src\startup_xinc.s
|
||||
|
||||
RF24G_Handler 0000001C
|
||||
|
||||
Symbol: RF24G_Handler
|
||||
Definitions
|
||||
At line 192 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 73 in file ..\app\src\startup_xinc.s
|
||||
At line 178 in file ..\app\src\startup_xinc.s
|
||||
|
||||
RTC_Handler 0000001C
|
||||
|
||||
Symbol: RTC_Handler
|
||||
Definitions
|
||||
At line 196 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 55 in file ..\app\src\startup_xinc.s
|
||||
At line 156 in file ..\app\src\startup_xinc.s
|
||||
|
||||
Reset_Handler 00000000
|
||||
|
||||
Symbol: Reset_Handler
|
||||
Definitions
|
||||
At line 93 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 33 in file ..\app\src\startup_xinc.s
|
||||
At line 95 in file ..\app\src\startup_xinc.s
|
||||
|
||||
SPI0_Handler 0000001C
|
||||
|
||||
Symbol: SPI0_Handler
|
||||
Definitions
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 5 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
At line 207 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 64 in file ..\app\src\startup_xinc.s
|
||||
At line 165 in file ..\app\src\startup_xinc.s
|
||||
|
||||
SPI1_Handler 0000001C
|
||||
|
||||
Symbol: SPI1_Handler
|
||||
Definitions
|
||||
At line 208 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 65 in file ..\app\src\startup_xinc.s
|
||||
At line 166 in file ..\app\src\startup_xinc.s
|
||||
|
||||
SPI2_Handler 0000001C
|
||||
|
||||
Symbol: SPI2_Handler
|
||||
Definitions
|
||||
At line 209 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 74 in file ..\app\src\startup_xinc.s
|
||||
At line 179 in file ..\app\src\startup_xinc.s
|
||||
|
||||
SVC_Handler 00000018
|
||||
|
||||
Symbol: SVC_Handler
|
||||
Definitions
|
||||
At line 141 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 43 in file ..\app\src\startup_xinc.s
|
||||
At line 142 in file ..\app\src\startup_xinc.s
|
||||
|
||||
SysTick_Handler 0000001C
|
||||
|
||||
Symbol: SysTick_Handler
|
||||
Definitions
|
||||
At line 190 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 47 in file ..\app\src\startup_xinc.s
|
||||
At line 174 in file ..\app\src\startup_xinc.s
|
||||
|
||||
TIMER0_Handler 0000001C
|
||||
|
||||
Symbol: TIMER0_Handler
|
||||
Definitions
|
||||
At line 197 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 56 in file ..\app\src\startup_xinc.s
|
||||
At line 157 in file ..\app\src\startup_xinc.s
|
||||
|
||||
TIMER1_Handler 0000001C
|
||||
|
||||
Symbol: TIMER1_Handler
|
||||
Definitions
|
||||
At line 198 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 57 in file ..\app\src\startup_xinc.s
|
||||
At line 158 in file ..\app\src\startup_xinc.s
|
||||
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 6 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
TIMER2_Handler 0000001C
|
||||
|
||||
Symbol: TIMER2_Handler
|
||||
Definitions
|
||||
At line 199 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 58 in file ..\app\src\startup_xinc.s
|
||||
At line 159 in file ..\app\src\startup_xinc.s
|
||||
|
||||
TIMER3_Handler 0000001C
|
||||
|
||||
Symbol: TIMER3_Handler
|
||||
Definitions
|
||||
At line 200 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 59 in file ..\app\src\startup_xinc.s
|
||||
At line 160 in file ..\app\src\startup_xinc.s
|
||||
|
||||
UART0_Handler 0000001C
|
||||
|
||||
Symbol: UART0_Handler
|
||||
Definitions
|
||||
At line 204 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 62 in file ..\app\src\startup_xinc.s
|
||||
At line 163 in file ..\app\src\startup_xinc.s
|
||||
|
||||
UART1_Handler 0000001C
|
||||
|
||||
Symbol: UART1_Handler
|
||||
Definitions
|
||||
At line 205 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 63 in file ..\app\src\startup_xinc.s
|
||||
At line 164 in file ..\app\src\startup_xinc.s
|
||||
|
||||
UART2_Handler 0000001C
|
||||
|
||||
Symbol: UART2_Handler
|
||||
Definitions
|
||||
At line 206 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 76 in file ..\app\src\startup_xinc.s
|
||||
At line 181 in file ..\app\src\startup_xinc.s
|
||||
|
||||
USB_Handler 0000001C
|
||||
|
||||
Symbol: USB_Handler
|
||||
Definitions
|
||||
At line 222 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 71 in file ..\app\src\startup_xinc.s
|
||||
At line 176 in file ..\app\src\startup_xinc.s
|
||||
|
||||
UsageFault_Handler 00000016
|
||||
|
||||
Symbol: UsageFault_Handler
|
||||
Definitions
|
||||
At line 137 in file ..\app\src\startup_xinc.s
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 7 Alphabetic symbol ordering
|
||||
Relocatable symbols
|
||||
|
||||
Uses
|
||||
At line 38 in file ..\app\src\startup_xinc.s
|
||||
At line 138 in file ..\app\src\startup_xinc.s
|
||||
|
||||
WDT_Handler 0000001C
|
||||
|
||||
Symbol: WDT_Handler
|
||||
Definitions
|
||||
At line 201 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 60 in file ..\app\src\startup_xinc.s
|
||||
At line 161 in file ..\app\src\startup_xinc.s
|
||||
|
||||
__user_initial_stackheap 00000020
|
||||
|
||||
Symbol: __user_initial_stackheap
|
||||
Definitions
|
||||
At line 234 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 233 in file ..\app\src\startup_xinc.s
|
||||
Comment: __user_initial_stackheap used once
|
||||
42 symbols
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
||||
Absolute symbols
|
||||
|
||||
Heap_Size 000000FF
|
||||
|
||||
Symbol: Heap_Size
|
||||
Definitions
|
||||
At line 14 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 18 in file ..\app\src\startup_xinc.s
|
||||
At line 238 in file ..\app\src\startup_xinc.s
|
||||
|
||||
Stack_Size 00000800
|
||||
|
||||
Symbol: Stack_Size
|
||||
Definitions
|
||||
At line 8 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 11 in file ..\app\src\startup_xinc.s
|
||||
At line 237 in file ..\app\src\startup_xinc.s
|
||||
|
||||
__Vectors_Size 000000C0
|
||||
|
||||
Symbol: __Vectors_Size
|
||||
Definitions
|
||||
At line 86 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 30 in file ..\app\src\startup_xinc.s
|
||||
Comment: __Vectors_Size used once
|
||||
3 symbols
|
||||
|
||||
|
||||
|
||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
||||
External symbols
|
||||
|
||||
SystemInit 00000000
|
||||
|
||||
Symbol: SystemInit
|
||||
Definitions
|
||||
At line 97 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 106 in file ..\app\src\startup_xinc.s
|
||||
Comment: SystemInit used once
|
||||
__main 00000000
|
||||
|
||||
Symbol: __main
|
||||
Definitions
|
||||
At line 98 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
At line 109 in file ..\app\src\startup_xinc.s
|
||||
Comment: __main used once
|
||||
__use_two_region_memory 00000000
|
||||
|
||||
Symbol: __use_two_region_memory
|
||||
Definitions
|
||||
At line 232 in file ..\app\src\startup_xinc.s
|
||||
Uses
|
||||
None
|
||||
Comment: __use_two_region_memory unused
|
||||
3 symbols
|
||||
393 symbols in table
|
||||
Binary file not shown.
@@ -0,0 +1,454 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>礦ision Build Log</h1>
|
||||
<h2>Tool Versions:</h2>
|
||||
IDE-Version: μVision V5.24.2.0
|
||||
Copyright (C) 2017 ARM Ltd and ARM Germany GmbH. All rights reserved.
|
||||
License Information: 1 QJM, 2, LIC=----
|
||||
|
||||
Tool Versions:
|
||||
Toolchain: MDK-Lite Version: 5.24.1
|
||||
Toolchain Path: D:\Keil_v5\ARM\ARMCC\Bin
|
||||
C Compiler: Armcc.exe V5.06 update 5 (build 528)
|
||||
Assembler: Armasm.exe V5.06 update 5 (build 528)
|
||||
Linker/Locator: ArmLink.exe V5.06 update 5 (build 528)
|
||||
Library Manager: ArmAr.exe V5.06 update 5 (build 528)
|
||||
Hex Converter: FromElf.exe V5.06 update 5 (build 528)
|
||||
CPU DLL: SARMCM3.DLL V5.24.1
|
||||
Dialog DLL: DARMCM1.DLL V1.18.0.0
|
||||
Target DLL: UL2CM3.DLL V1.160.3.0
|
||||
Dialog DLL: TARMCM1.DLL V1.13.0.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
D:\2026_4_13\hpw422_通道对码\project\example\ble\ble_peripheral\mdk\ble_peripheral.uvprojx
|
||||
Project File Date: 05/07/2026
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
|
||||
Rebuild target 'ble-sdk-xip_scan'
|
||||
assembling startup_xinc.s...
|
||||
..\app\src\startup_xinc.s(23): warning: A1581W: Added 1 bytes of padding at address 0xff
|
||||
compiling system_xinc.c...
|
||||
compiling sleep.c...
|
||||
..\app\src\sleep.h(14): warning: #1-D: last line of file ends without a newline
|
||||
#endif //_SLEEP_H_
|
||||
..\app\src\sleep.c: 1 warning, 0 errors
|
||||
compiling app_batt.c...
|
||||
compiling ota_server.c...
|
||||
compiling arch_main.c...
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\key.h(49): warning: #2532-D: support for trigraphs is disabled
|
||||
// ????/????(??:????,??10ms/?)
|
||||
..\app\src\key.h(139): warning: #1-D: last line of file ends without a newline
|
||||
#endif /* __KEY_H__ */
|
||||
..\app\src\switch_s.h(32): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\arch_main.c(163): warning: #223-D: function "xc_fmc_spi_init_oprt" declared implicitly
|
||||
xc_fmc_spi_init_oprt();
|
||||
..\app\src\arch_main.c(164): warning: #223-D: function "xc_fmc_spi_flash_wake_up" declared implicitly
|
||||
xc_fmc_spi_flash_wake_up();
|
||||
..\app\src\arch_main.c(166): warning: #223-D: function "xc_fmc_spi_flash_rdid" declared implicitly
|
||||
xc_fmc_spi_flash_rdid((uint8_t *)&mid);
|
||||
..\app\src\arch_main.c(171): warning: #223-D: function "xc_fmc_spi_flash_ruid" declared implicitly
|
||||
xc_fmc_spi_flash_ruid(ruid);
|
||||
..\app\src\arch_main.c(188): warning: #223-D: function "xc_unique_identification_read" declared implicitly
|
||||
if (
|
||||
alse == xc_unique_identification_read(co_default_bdaddr.addr)) {
|
||||
..\app\src\arch_main.c(161): warning: #177-D: variable "flash_size" was declared but never referenced
|
||||
uint32_t flash_size;
|
||||
..\app\src\arch_main.c(162): warning: #177-D: variable "flash_type" was declared but never referenced
|
||||
uint16_t flash_type;
|
||||
..\app\src\arch_main.c(217): warning: #144-D: a value of type "uint32_t *" cannot be used to initialize an entity of type "uint8_t *"
|
||||
uint8_t *ptr = (uint32_t *)(0x10000800);
|
||||
..\app\src\arch_main.c(379): warning: #188-D: enumerated type mixed with another type
|
||||
wdt_cfg.ReloadValue =
|
||||
DT_CLK_32K_RESET_MODE0_2048MS;
|
||||
..\app\src\arch_main.c(463): warning: #223-D: function "switch_init" declared implicitly
|
||||
switch_init();
|
||||
..\app\src\arch_main.c(487): warning: #223-D: function "TaskProcess" declared implicitly
|
||||
TaskProcess();
|
||||
..\app\src\arch_main.c: 22 warnings, 0 errors
|
||||
compiling app_sec.c...
|
||||
..\app\src\app_sec.c(414): warning: #177-D: variable "param" was declared but never referenced
|
||||
struct gapc_encrypt_req_ind const *param = (struct gapc_encrypt_req_ind const *)p_param;
|
||||
..\app\src\app_sec.c: 1 warning, 0 errors
|
||||
compiling app_task.c...
|
||||
..\app\src\app_task.c(448): warning: #223-D: function "ke_timer_set" declared implicitly
|
||||
ke_timer_set(APP_SECOND_ADV_START, TASK_APP, 400); // start open noconnect adv
|
||||
..\app\src\app_task.c(461): warning: #61-D: integer operation result is out of range
|
||||
value &= ~(0xff << 24);
|
||||
..\app\src\app_task.c(471): warning: #223-D: function "custom_svc_add" declared implicitly
|
||||
if (!custom_svc_add()) {
|
||||
..\app\src\app_task.c(494): warning: #223-D: function "ke_timer_set" declared implicitly
|
||||
ke_timer_set(APP_SCAN_START, TASK_APP, 10);
|
||||
..\app\src\app_task.c(638): warning: #177-D: variable "p_param" was declared but never referenced
|
||||
struct gapm_ext_adv_report_ind *p_param = (struct gapm_ext_adv_report_ind *)param;
|
||||
..\app\src\app_task.c(686): warning: #223-D: function "xc_ble_gatt_cli_mtu_exch" declared implicitly
|
||||
xc_ble_gatt_cli_mtu_exch(conidx, app_env.user_lid);
|
||||
..\app\src\app_task.c(801): warning: #223-D: function "ke_timer_set" declared implicitly
|
||||
ke_timer_set(APP_SCAN_STOP, TASK_APP, 200); // start open noconnect adv
|
||||
..\app\src\app_task.c(815): warning: #223-D: function "ke_timer_set" declared implicitly
|
||||
ke_timer_set(APP_SCAN_START, TASK_APP, 900); // start open noconnect adv
|
||||
..\app\src\app_task.c(832): warning: #223-D: function "app_switch_mode" declared implicitly
|
||||
app_switch_mode(app_mode);
|
||||
..\app\src\app_task.c(833): warning: #940-D: missing return statement at end of non-void function "app_mode_switch_handler"
|
||||
}
|
||||
..\app\src\app_task.c(834): warning: #159-D: declaration is incompatible with previous "app_switch_mode" (declared at line 832)
|
||||
void app_switch_mode(uint8_t mode)
|
||||
..\app\src\app_task.c(842): warning: #223-D: function "ke_timer_set" declared implicitly
|
||||
ke_timer_set(APP_SECOND_ADV_START, TASK_APP, 400); // start open noconnect adv
|
||||
..\app\src\app_task.c(304): warning: #177-D: function "app_get_handler" was declared but never referenced
|
||||
static uint8_t app_get_handler(const struct app_subtask_handlers *handler_list_desc, ke_msg_id_t msgid, void *p_param,
|
||||
..\app\src\app_task.c: 13 warnings, 0 errors
|
||||
compiling ota_flash_interface.c...
|
||||
..\app\src\ota_flash_interface.c(65): warning: #223-D: function "xc_fmc_spi_flash_write_page" declared implicitly
|
||||
|
||||
MC_SPI_Flash_WritePage(op_flash.op_addr, op_flash.op_buff, 256);
|
||||
..\app\src\ota_flash_interface.c(87): warning: #223-D: function "xc_fmc_spi_flash_erase_page" declared implicitly
|
||||
|
||||
MC_SPI_Flash_Erase_Page(op_flash.op_addr);
|
||||
..\app\src\ota_flash_interface.c(117): warning: #223-D: function "wright_user_data" declared implicitly
|
||||
wright_user_data();
|
||||
..\app\src\ota_flash_interface.c: 3 warnings, 0 errors
|
||||
compiling aes.c...
|
||||
compiling xc_drv_dma.c...
|
||||
compiling xc_drv_spi_dma.c...
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(230): warning: #47-D: incompatible redefinition of macro "CUR_PAGE_NUM" (declared at line 115 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_PAGE_NUM(addr) (addr / FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(231): warning: #47-D: incompatible redefinition of macro "CUR_START_PSR" (declared at line 116 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_START_PSR(addr) (addr % FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(237): warning: #47-D: incompatible redefinition of macro "FMC_IDLE_STATUS" (declared at line 78 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define FMC_IDLE_STATUS ((uint32_t)0x01 << 31)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi_dma.c: 3 warnings, 0 errors
|
||||
compiling xc_drv_spi.c...
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(230): warning: #47-D: incompatible redefinition of macro "CUR_PAGE_NUM" (declared at line 115 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_PAGE_NUM(addr) (addr / FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(231): warning: #47-D: incompatible redefinition of macro "CUR_START_PSR" (declared at line 116 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_START_PSR(addr) (addr % FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(237): warning: #47-D: incompatible redefinition of macro "FMC_IDLE_STATUS" (declared at line 78 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define FMC_IDLE_STATUS ((uint32_t)0x01 << 31)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi.c: 3 warnings, 0 errors
|
||||
compiling ota_protocol.c...
|
||||
..\app\src\ota_protocol.c(35): warning: #120-D: return value type does not match the function type
|
||||
return &fota_env;
|
||||
..\app\src\ota_protocol.c(149): warning: #550-D: variable "sw_ver" was set but never used
|
||||
uint16_t sw_ver;
|
||||
..\app\src\ota_protocol.c(150): warning: #550-D: variable "rom_ver" was set but never used
|
||||
uint16_t rom_ver;
|
||||
..\app\src\ota_protocol.c(292): warning: #177-D: label "defult" was declared but never referenced
|
||||
defult:
|
||||
..\app\src\ota_protocol.c(320): warning: #223-D: function "ble_flash_later_page_erase" declared implicitly
|
||||
ble_flash_later_page_erase(OTA_PARAM_ADDR);
|
||||
..\app\src\ota_protocol.c: 5 warnings, 0 errors
|
||||
compiling ringbuffer.c...
|
||||
compiling xc_drv_fmc_spi.c...
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(230): warning: #47-D: incompatible redefinition of macro "CUR_PAGE_NUM" (declared at line 115 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_PAGE_NUM(addr) (addr / FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(231): warning: #47-D: incompatible redefinition of macro "CUR_START_PSR" (declared at line 116 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_START_PSR(addr) (addr % FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(237): warning: #47-D: incompatible redefinition of macro "FMC_IDLE_STATUS" (declared at line 78 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define FMC_IDLE_STATUS ((uint32_t)0x01 << 31)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.c: 3 warnings, 0 errors
|
||||
compiling usr_server.c...
|
||||
..\app\src\usr_server.c(137): warning: #223-D: function "ble_callback" declared implicitly
|
||||
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]);
|
||||
..\app\src\usr_server.c: 1 warning, 0 errors
|
||||
compiling xc_drv_pwm.c...
|
||||
compiling xc_drv_gpio.c...
|
||||
compiling xc_drv_clock.c...
|
||||
compiling xc_drv_pwr.c...
|
||||
compiling xc_drv_timer.c...
|
||||
compiling xc_drv_uart.c...
|
||||
compiling xc_drv_wdt.c...
|
||||
compiling xc_drv_systick.c...
|
||||
compiling xc_drv_calib.c...
|
||||
compiling xc_drv_fmc_spi.c...
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(230): warning: #47-D: incompatible redefinition of macro "CUR_PAGE_NUM" (declared at line 115 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_PAGE_NUM(addr) (addr / FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(231): warning: #47-D: incompatible redefinition of macro "CUR_START_PSR" (declared at line 116 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_START_PSR(addr) (addr % FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(237): warning: #47-D: incompatible redefinition of macro "FMC_IDLE_STATUS" (declared at line 78 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define FMC_IDLE_STATUS ((uint32_t)0x01 << 31)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.c: 3 warnings, 0 errors
|
||||
compiling xc_drv_adc.c...
|
||||
compiling xc_drv_pga.c...
|
||||
compiling xc_gatt_client_api.c...
|
||||
..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_client_api.c(121): warning: #223-D: function "gatt_cli_mtu_exch" declared implicitly
|
||||
return gatt_cli_mtu_exch(conidx, user_lid);
|
||||
..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_client_api.c(122): warning: #1-D: last line of file ends without a newline
|
||||
}
|
||||
..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_client_api.c: 2 warnings, 0 errors
|
||||
compiling nvds.c...
|
||||
compiling xc_drv_aotimer.c...
|
||||
compiling xc_drv_rtc.c...
|
||||
compiling xc_drv_spi.c...
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(230): warning: #47-D: incompatible redefinition of macro "CUR_PAGE_NUM" (declared at line 115 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_PAGE_NUM(addr) (addr / FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(231): warning: #47-D: incompatible redefinition of macro "CUR_START_PSR" (declared at line 116 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_START_PSR(addr) (addr % FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(237): warning: #47-D: incompatible redefinition of macro "FMC_IDLE_STATUS" (declared at line 78 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define FMC_IDLE_STATUS ((uint32_t)0x01 << 31)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi.c: 3 warnings, 0 errors
|
||||
compiling rf_extrc.c...
|
||||
..\..\..\..\..\component\ble\modules\rf\src\rf_extrc.c(649): warning: #61-D: integer operation result is out of range
|
||||
|
||||
ritel(0x53020368, readl(0x53020368) | (0x01 << 31)); // EXT_CORRCODE_EN[31]
|
||||
..\..\..\..\..\component\ble\modules\rf\src\rf_extrc.c(649): warning: #68-D: integer conversion resulted in a change of sign
|
||||
|
||||
ritel(0x53020368, readl(0x53020368) | (0x01 << 31)); // EXT_CORRCODE_EN[31]
|
||||
..\..\..\..\..\component\ble\modules\rf\src\rf_extrc.c: 2 warnings, 0 errors
|
||||
compiling timer.c...
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\switch_s.h(32): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\timer.c: 9 warnings, 0 errors
|
||||
compiling xc_gatt_server_api.c...
|
||||
compiling xc_gap_api.c...
|
||||
compiling uart.c...
|
||||
compiling uart.c...
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\uart.c(86): warning: #940-D: missing return statement at end of non-void function "xc_is_data_ready"
|
||||
}
|
||||
..\app\src\uart.c(96): warning: #177-D: variable "uart_handle" was declared but never referenced
|
||||
uint8_t uart_handle = UART0_IDX;
|
||||
..\app\src\uart.c(193): warning: #1-D: last line of file ends without a newline
|
||||
|
||||
..\app\src\uart.c: 11 warnings, 0 errors
|
||||
compiling timeslice.c...
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\key.h(49): warning: #2532-D: support for trigraphs is disabled
|
||||
// ????/????(??:????,??10ms/?)
|
||||
..\app\src\key.h(139): warning: #1-D: last line of file ends without a newline
|
||||
#endif /* __KEY_H__ */
|
||||
..\app\src\switch_s.h(32): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\timeslice.c: 11 warnings, 0 errors
|
||||
compiling PWM.c...
|
||||
compiling Rf433.c...
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\key.h(49): warning: #2532-D: support for trigraphs is disabled
|
||||
// ????/????(??:????,??10ms/?)
|
||||
..\app\src\key.h(139): warning: #1-D: last line of file ends without a newline
|
||||
#endif /* __KEY_H__ */
|
||||
..\app\src\switch_s.h(32): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\Rf433.c(530): warning: #223-D: function "set_TaskComps_timer" declared implicitly
|
||||
set_TaskComps_timer(6,1000);
|
||||
..\app\src\Rf433.c(552): warning: #223-D: function "set_TaskComps_timer" declared implicitly
|
||||
set_TaskComps_timer(6,1000);
|
||||
..\app\src\Rf433.c(29): warning: #177-D: variable "POWER_flag" was declared but never referenced
|
||||
static uint8_t POWER_flag;
|
||||
..\app\src\Rf433.c(85): warning: #177-D: variable "ssse" was declared but never referenced
|
||||
static uint8_t ssse=0;
|
||||
..\app\src\Rf433.c: 15 warnings, 0 errors
|
||||
compiling fmc_spi.c...
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(230): warning: #47-D: incompatible redefinition of macro "CUR_PAGE_NUM" (declared at line 115 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_PAGE_NUM(addr) (addr / FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(231): warning: #47-D: incompatible redefinition of macro "CUR_START_PSR" (declared at line 116 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define CUR_START_PSR(addr) (addr % FLASH_PAGE_SIZE)
|
||||
..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi.h(237): warning: #47-D: incompatible redefinition of macro "FMC_IDLE_STATUS" (declared at line 78 of "..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h")
|
||||
#define FMC_IDLE_STATUS ((uint32_t)0x01 << 31)
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\fmc_spi.c(234): warning: #167-D: argument of type "uint8_t (*)[256]" is incompatible with parameter of type "uint8_t *"
|
||||
xc_fmc_spi_flash_read_page(0x1E000,&r_data,
|
||||
LASH_PAGE_SIZE);
|
||||
..\app\src\fmc_spi.c: 12 warnings, 0 errors
|
||||
compiling rgblight.c...
|
||||
compiling key.c...
|
||||
..\app\src\key.h(49): warning: #2532-D: support for trigraphs is disabled
|
||||
// ????/????(??:????,??10ms/?)
|
||||
..\app\src\key.h(139): warning: #1-D: last line of file ends without a newline
|
||||
#endif /* __KEY_H__ */
|
||||
..\app\src\key.c(431): warning: #1-D: last line of file ends without a newline
|
||||
//}
|
||||
..\app\src\key.c: 3 warnings, 0 errors
|
||||
compiling Mode.c...
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\Mode.c: 8 warnings, 0 errors
|
||||
compiling switch_s.c...
|
||||
..\app\src\switch_s.h(32): warning: #1-D: last line of file ends without a newline
|
||||
#endif
|
||||
..\app\src\RF433.h(84): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 65)
|
||||
#define Brightness_H 0xF4
|
||||
..\app\src\RF433.h(86): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 63)
|
||||
#define Brightness_L 0xF5
|
||||
..\app\src\RF433.h(92): warning: #47-D: incompatible redefinition of macro "ON" (declared at line 76)
|
||||
#define ON 0X02 //开关
|
||||
..\app\src\RF433.h(94): warning: #47-D: incompatible redefinition of macro "OFF" (declared at line 78)
|
||||
#define OFF 0X04 //七彩
|
||||
..\app\src\RF433.h(96): warning: #47-D: incompatible redefinition of macro "Mode_add" (declared at line 80)
|
||||
#define Mode_add 0X06 //
|
||||
..\app\src\RF433.h(98): warning: #47-D: incompatible redefinition of macro "Mode_dow" (declared at line 82)
|
||||
#define Mode_dow 0X0E
|
||||
..\app\src\RF433.h(100): warning: #47-D: incompatible redefinition of macro "Brightness_H" (declared at line 84)
|
||||
#define Brightness_H 0x08
|
||||
..\app\src\RF433.h(102): warning: #47-D: incompatible redefinition of macro "Brightness_L" (declared at line 86)
|
||||
#define Brightness_L 0x0D
|
||||
..\app\src\switch_s.c: 9 warnings, 0 errors
|
||||
linking...
|
||||
.\Objects\Xinc_ble_sdk.axf: Warning: L6304W: Duplicate input file .\objects\xc_drv_fmc_spi_1.o ignored.
|
||||
.\Objects\Xinc_ble_sdk.axf: Warning: L6304W: Duplicate input file .\objects\xc_drv_spi_1.o ignored.
|
||||
Program Size: Code=24884 RO-data=1396 RW-data=2572 ZI-data=3700
|
||||
Finished: 0 information, 2 warning and 0 error messages.
|
||||
FromELF: creating hex file...
|
||||
After Build - User command #1: fromelf --bin --output=app.bin .\Objects\Xinc_ble_sdk.axf
|
||||
After Build - User command #2: .\output_tool\ge_ota_scan.bat
|
||||
Size of file: 26432 bytes.
|
||||
all_size=26432
|
||||
dual_xip
|
||||
Addr:13000
|
||||
Size:0x6740
|
||||
BAddr:0x40000
|
||||
Acheck:0xdaf69d40
|
||||
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]:0
|
||||
第五个命令行参数[APP2 program]:app.bin
|
||||
第六个命令行参数[load_addr: sector align]:0x11011000
|
||||
第七个命令行参数[1:active,0:invalid]:1
|
||||
第八个命令行参数[生成的最终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=0x11011000
|
||||
status1=0
|
||||
status2=1
|
||||
需要填充0个sector
|
||||
updata file success !
|
||||
已复制 1 个文件。
|
||||
系统找不到指定的路径。
|
||||
已复制 0 个文件。
|
||||
".\Objects\Xinc_ble_sdk.axf" - 0 Error(s), 146 Warning(s).
|
||||
|
||||
<h2>Software Packages used:</h2>
|
||||
|
||||
Package Vendor: ARM
|
||||
http://www.keil.com/pack/ARM.CMSIS.5.0.1.pack
|
||||
ARM.CMSIS.5.0.1
|
||||
CMSIS (Cortex Microcontroller Software Interface Standard)
|
||||
|
||||
<h2>Collection of Component include folders:</h2>
|
||||
.\RTE\_ble-sdk-xip_scan
|
||||
D:\Keil_v5\ARM\PACK\ARM\CMSIS\5.0.1\Device\ARM\ARMCM0\Include
|
||||
|
||||
<h2>Collection of Component Files used:</h2>
|
||||
Build Time Elapsed: 00:00:12
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
--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"
|
||||
".\objects\sleep.o"
|
||||
".\objects\ota_server.o"
|
||||
".\objects\ota_flash_interface.o"
|
||||
".\objects\ota_protocol.o"
|
||||
".\objects\usr_server.o"
|
||||
".\objects\aes.o"
|
||||
"..\app\src\rom_symdefs.o"
|
||||
".\objects\xc_drv_dma.o"
|
||||
".\objects\xc_drv_spi_dma.o"
|
||||
".\objects\xc_drv_spi_1.o"
|
||||
".\objects\xc_drv_fmc_spi_1.o"
|
||||
".\objects\xc_drv_pwm.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_1.o"
|
||||
".\objects\xc_drv_calib.o"
|
||||
".\objects\xc_drv_adc.o"
|
||||
".\objects\xc_drv_pga.o"
|
||||
".\objects\xc_drv_aotimer.o"
|
||||
".\objects\xc_drv_rtc.o"
|
||||
".\objects\xc_drv_spi_1.o"
|
||||
".\objects\xc_gap_api.o"
|
||||
".\objects\xc_gatt_client_api.o"
|
||||
".\objects\xc_gatt_server_api.o"
|
||||
".\objects\nvds.o"
|
||||
".\objects\uart.o"
|
||||
".\objects\timer.o"
|
||||
".\objects\timeslice.o"
|
||||
".\objects\uart_1.o"
|
||||
".\objects\rgblight.o"
|
||||
".\objects\mode.o"
|
||||
".\objects\rf433.o"
|
||||
".\objects\pwm.o"
|
||||
".\objects\fmc_spi.o"
|
||||
".\objects\key.o"
|
||||
".\objects\switch_s.o"
|
||||
--strict --scatter ".\Linker\cpu_xip_scan.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,71 @@
|
||||
.\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:\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:\Keil_v5\ARM\ARMCC\Bin\..\include\stdbool.h
|
||||
.\objects\aes.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\stddef.h
|
||||
.\objects\aes.o: D:\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\xc60xx.h
|
||||
.\objects\aes.o: D:\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\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\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\xc6xxx.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_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\core_cm0.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\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_spi_dma.h
|
||||
.\objects\aes.o: D:\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.
Binary file not shown.
@@ -0,0 +1,131 @@
|
||||
.\objects\app_batt.o: ..\app\src\app_batt.c
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\rwip\api\rwip_config.h
|
||||
.\objects\app_batt.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\string.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\ll\api\rwble_config.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\rwip\api\rwip_config.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\inc\rwble_hl_config.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\rwble_hl_error.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\inc\rwprf_config.h
|
||||
.\objects\app_batt.o: ..\app\api\rwapp_config.h
|
||||
.\objects\app_batt.o: ..\app\src\app_batt.h
|
||||
.\objects\app_batt.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\stdint.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\ke\api\ke_task.h
|
||||
.\objects\app_batt.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\stdbool.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc6xxx.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc60xx.h
|
||||
.\objects\app_batt.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\stdio.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cm0.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cmInstr.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cmFunc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_conf.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_cpr.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_offset.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_cprao.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_rf.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_adc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_aotimer.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc6xxx.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_dma.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_fmc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_fmc_cache.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_gpio.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_i2c.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_qdec.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_pwm.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_pwm_comn.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_rtc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\core_cm0.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_spi.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_timer.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_uart.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_wdt.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\CMSIS\Device\xc_m0_register\xc_reg_pwm_timer.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_calib.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_clock.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_systick.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_pwr.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_gpio.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_aotimer.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_timer.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_rtc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_uart.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\ringbuffer.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_dma.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_spi_dma.h
|
||||
.\objects\app_batt.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\stdlib.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\flash\xc6xxx_fmc_spi.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_fmc_spi_dma.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_uart_dma.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_i2c.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_sw_i2c.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_wdt.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_adc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\xc6xx_drivers\Drivers\xc_driver\xc_drv_pwm.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\ke\api\ke_msg.h
|
||||
.\objects\app_batt.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\stddef.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\arch.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\ll\gnuarm\ll.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\arch.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\reg_intc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_intc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\driver\reg\reg_access.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_utils.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_bt.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_bt_defines.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_lmp.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_bt.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_hci.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_error.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\rwip\api\rwip.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\em\api\em_map.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_math.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_et.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\ll\api\em_map_ble.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_llcp.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_ble_cs.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_ble_tx_desc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_ble_rx_desc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_ble_rx_cte_desc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_ble_wpal.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\build\ble-full\reg\fw\_reg_em_ble_ral.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_list.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\app\api\app_task.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\dbg\api\dbg.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\dbg\api\dbg_swdiag.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\dbg\api\dbg_trc.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\src\gap\gapm\gapm_int.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\gapm.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\gapm_msg.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\rwip\api\rwip_task.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\gap.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\src\gatt\gatt_msg_int.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\gatt.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\gatt_msg.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\l2cap.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\l2cap_msg.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\common\api\co_buf.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\modules\ke\api\ke_mem.h
|
||||
.\objects\app_batt.o: ..\app\src\ota_server.h
|
||||
.\objects\app_batt.o: ..\app\api\app_task.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\api\xc_gatt_server_api.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\src\gatt\gatt_db.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\api\xc_gap_api.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\gapc_msg.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\profiles\bas\bass\api\bass_msg.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\prf_types.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\plf\refip\src\arch\compiler\gnuarm\compiler.h
|
||||
.\objects\app_batt.o: ..\..\..\..\..\component\ble\ip\ble\hl\api\prf.h
|
||||
Binary file not shown.
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