请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC2650STK 工具/软件:Code Composer Studio
大家好、
我正在 sensortag 的 simple_peripheral 项目中实施 sensortag 加速计、因此我将一些所需的文件复制到 simple_peripheral_cc2650stk_app 项目的根目录中。
我已修改 sensortag_mov.c 并创建了 cadera.c 文件、以便它可以满足我的需求。
问题是、现在总是开始调试工程、它会在 exit.c 文件的 void abort(void)函数中崩溃、它说是(abort -异常程序终止。 目前只是暂停执行 。)
请有人知道发生了什么? 发生这种情况的原因可能是什么?
sensortag_mov.c 文件
/*********
@file sensortag_mov.c
@brief 此文件包含移动处理器子应用程序。 它使用
MPU-9250移动唤醒功能可实现
MPU 可在无活动时关闭陀螺仪和磁力计
检测到。
小组成员:WCS、BTS
目标设备:CC2650、CC2640、CC1350
版权所有(c) 2015-2016、德州仪器(TI)公司
保留所有权利。
只要
满足以下条件、就允许以源代码和二进制形式重新分发和使用(无论是否修改):
*源代码的重新分发必须保留上述版权
声明、此条件列表和以下免责声明。
*二进制形式的再发行必须复制上述版权
注意、本条件列表和中的以下免责声明
分发时提供的文档和/或其他材料。
*德州仪器公司的名称和名称均不相同
其贡献者可用于认可或推广衍生产品
未经特定的事先书面许可。
本软件由版权所有者和贡献者"按原样"提供
、
不承认任何明示或暗示的保证、包括但不限于对适销性和特定用途适用性的暗示保证。 在任何情况下、版权所有者或
贡献者都不对任何直接、间接、偶然、特殊、
模范、 或相应的损害(包括但不限于
采购替代产品或服务;丧失使用、数据或利润;
或业务中断)、但出于任何责任理论、
无论是在合同中、严格责任还是在使用
本软件时以任何方式产生的侵权行为(包括疏忽或其他原因)、
即使被告知存在此类损坏的可能性。
秘书长的报告
发布名称:BLE_SDK_2_02_01_18
发布日期:2016年10月26日15:20:04
/
#ifndef exclude_MOV
/*********
*包括
*/
#include
#include
#include "GATT.h"
#include "gattservapp.h"
#include "board.h"
#include "sensortag_mov.h"
#include "SensorMpu925.h"
#include "SensorTagTest.h"
#include "SensorUtil.h"
#include "string.h";include "external void #include "string.h";#include "exSimplease.n"
*宏
*/
#define MOVINACT_CYCLES (MOVINACT_INACT_TIMEOUT *\
(10000/sensorPeriod)/ 10)
/*********
*常量和宏
*/
//执行传感器读取的频率(毫秒)
#define SENSOR_DEFAULT_PERIOD 1000
//此传感器的数据长度
#define SENSOR_DATA_LEN MOVACT_DATA_LEN
//此传感器的事件标志
#define SENSOR_EVT ST_gyroscope_sensor_EVT
//移动任务状态
#define APP_State_error 0xFF
#define APP_State_off 0
#define APP_State_IDLE 1
#define APP_State_active 2
//移动任务配置
#define MOVINACT_INACT_TIMEOUT 10. // 10秒
#define GYR_Shake_THR 10.0
#define WOM_THR 50
//配置位掩码(sensor_mpu925.h 中定义的0-6位)
#define MOV_WOM_ENABLE 0x0080
#define MOV_MASK_WOM_THRESHOLD 0x3C00 // TBD
#define MOV_MASK_INACT_TIMEOUT 0xC000 // TBD
/*********
* typedef
*/
/*********
*全局变量
*/
/*********
*外部变量
*/
/*********
*外部功能
*/
*局部变量
*/
static Clock_Structurt periodicClock;
static uint16_t sensorPeriod;
static volatile bool sensorReadScheduled;
//static uint8_t sensorData[sensor_data_LEN];
static volatile uint8_t mpuWom = 0;
//应用程序状态变量
// MPU config:
// x
bit 2、6://启用 x、y、x 2:/x 位:/x (x)
磁力计使能
//位7: WOM 使能
//位8-9:加速计范围(2、4、8、16)
静态 uint16_t mpuConfig;
//static uint8_t appState;
//静态易失性 bool mpuDataRdy;
//bool mpuDataRdy;
volatile bint8_t
muvThreshold;
static volatile uint8_mut int8/
static t/ntuintt/static tuint8t 检测;static uintt/static uintt/static uintt/static uinttuintt/static uint8_intt/t 检测;static uintt/static uintt/static uint
/*********
*本地函数
*/
static void sensorChangeCB (uint8_t paramID);
static void initCharacteristicValue (uint8_t paramID、uint8_t value、
uint8_t paramLen);
静态空 SensorTag_clockHandler (UArg arg);
静态空 appStateSet (uint8_t newState);
静态空 SensorTag_processInterrupt (void);
/
*系统配置回调
*//static
sensorCBs_t sensorCallback =
//{
// sensorChangeCB、//特征值更改回调
//;
/*********
*公共职能
*/
*@fn SensorTag_init
*
*@SensorTag 移动子应用的简要初始化函数
*
@param none
*
@return none
*/
void SensorTagprofile /init (void)
{
/添加服务
// Movement_addService ();
//使用
Config 注册回调// Movement_registerAppCBs (&sensorCallback);//默认 sensor_state= 0x00/禁用 sensor_charge/sensor_pert = 0x00/ statelt;//
sensorReadScheduled = false;
mpuConfig = 0x01;// ST_CFG_SENSOR_ENABLE
appStateSet (app_State_active);
// appState = app_State_off;
// nModions = 0;
if (SensorMpu9250_init ()
){
// SensorTag_reset();
SensorMpu9250_registerCallback (SensorTag_processInterrupt);
}
SensorMpu9250_enableWom (movThreshold);
//初始化特性
// initCharacteristic Value (sensor_peri、
// sensor_default_period / sensor_period_resolution、
// sizeof (uint8_t));
//
为内部周期性事件创建连续时钟。
Util_constructClock (周期时钟、SensorTag_clockHandler、
10000、0、false、0);
}
/*********
*@fn SensorTagAG_processSensorEvent
*
*@SensorTag 运动传感器事件处理器简介。
*
*@param none
*
*@return none
*/
void SensorTag_processSensorEvent (void)
{
#if 0
if (sensorReadScheduled)
{
uint8_t 轴;
Axes = mpuConfig & MPU_AX_ALL;
如果(轴!= ST_CFG_SENSOR_DISABLE)&&(轴!= ST_CFG_ERROR)
{
//获取中断状态(清除中断)
mpuIntStatus = SensorMpu9250_irqStatus ();//检查动作唤醒是否有过流
//过程陀螺仪和加速计
if (mpuDataRdy || appState == APP_State_active)
{
IF (mpuIntStatus 和 MPU_MOVement)
{
//检测到运动(小滤波器)
nMods++;
TEST = SensorMpu9250_accRead ((uint16_t*)&sensorData[6]);
如果(nModions == 2)
{
nActivity = MOVITY_INACT_CYCLES;
}
}
如果(mpuIntStatus 和 MPU_DATA_READY)
{
//读取陀螺仪数据
SensorMpu9250_gyroRead ((uint16_t*) sensorData);
//读取加速计数据
SensorMpu9250_accRead ((uint16_t*) sensorData[6]);
IF (晃动分离)
{
//陀螺仪检测到运动
nActivity = MOVITY_INACT_CYCLES;
ShakeDetected = false;
}
}
mpuDataRdy = false;
if (appState = app_State_active &&!!(mpuConfig & MPU_AX_MAG))
{
uint8_t status;
状态= SensorMpu9250_magRead ((int16_t*)&sensorData[12]);
//始终测量磁力计(非中断驱动)
如果(status =mag_bype_fail)
{
//出错时空闲
nActivity = 0;
appState = app_State_error;
}
否则(状态!= mag_status_OK)
{
SensorMpu9250_magReset();
}
}
如果(nActivity >0)
{
if (appState!= app_State_active)
{
//转换到活动状态
appState = app_State_active;
nModions = 0;
if (SensorMpu9250_reset ())
{
SensorMpu9250_enable (轴);
//SensorMpu9250_enable (0b0001110100000000);
}
}
IF (mpuConfig 和 MOV_WOM_ENABLE)
{
n 活动--;
}
//发送数据
Moving_SetParameter (sensor_data、sensor_data_LEN、sensorData);
}
其他
{
if (appState!= app_State_idle)
{
//从活动状态转换到空闲状态
nModions = 0;
appState = app_State_Idle;
if (SensorMpu9250_reset ())
{
SensorMpu9250_enableWom (movThreshold);
}
}
}
sensorReadScheduled = false;
}
#endif
1
if (mpuWom){
mpuWom = 0;
mpuIntStatus = SensorMpu9250_irqStatus ();
// Liga o LED
// arma (ou reseta) o timer de 10s (MovementTimeout)
IF (mpuIntStatus 和 MPU_MOVement)
{
}
}
#endif
}
/*********
*@fn SensorTag_processCharChangeEvt
*
*@SensorTag 移动事件处理的简短
说明*
@param paramID -识别已更改的特征
*
*@return tag*
/
void SensorTagId_SENSOR ChangeCharEvt (uint8_t Tag)
{
#if 0
uint16_t newparamuint8_newValuue8
;
{
CONF_case:}
if ((SensorTag_testResult ()& sensor_MOV_TEST_BM)=0)
{
mpuConfig = ST_CFG_ERROR;
}
if (mpuConfig!= ST_CFG_ERROR)
{
move_getParameter (sensor_CONF、newCfg);
if ((newCfg & MPU_AX_ALL)== ST_CFG_SENSOR_DISABLE)
{
//关闭所有轴,关闭设备电源
mpuConfig = newCfg;
appStateSet (app_State_off);
}
其他
{
//某些轴打开;打开电源并激活 MPU
mpuConfig = newCfg;
appStateSet (app_State_active);
IF (SensorMpu9250_powerIsOn ())
{
DELAY_MS (5);
mpuConfig = newCfg |(SensorMpu9250_accReadRange()<<8);
}
}
Moving_SetParameter (sensor_CONF、sizeof (mpuConfig)、(uint8_t*)&mpuConfig);
}
其他
{
//确保恢复先前的特性值
initCharacteristicValue (sensor_CONF、mpuConfig、sizeof (mpuConfig));
}
//数据最初为零
initCharacteristicValue (sensor_data、0、sensor_data_LEN);
break;
case sensor_peri:
Moving_getParameter (sensor_peri、newValue8);
sensorPeriod = newValue8 * sensor_period_resolution;
Util_eliteduleClock (周期时钟、sensorPeriod);
中断;
默认:
//不应该出现在这里
中断;
}
#endif
}
/*********
*@fn SensorTag_reset
*
*@简要重置特性并禁用传感器
*
@param none
*
@return none
*/
void SensorTag_sensor_reset (void)
{
// initistorValue(sensor_data、0、icensor_data_LEN);
mpuConfig = 0x00 |(acc_range_8G << 8);// initistor_statement (g_disable_statement
)
*(param_transport)/eConfig)*(parature_off)*(parature_statement from the status_ap_off)
*私人职能
*/
*@fn SensorTagAG_processInterrupt
*
*@MPU 的简短中断处理程序
*
@param_none
*
@return none
*/
static void SensorTagAG_processInterrupt (void)
{
//唤醒应用程序线程
Util_stopClock (周期时钟);
Util_startClock (周期时钟);
mpuWom = 1;
PIN_setOutputValue (hGpioPin、Board_LED1、Board_LED_ON);
PIN_setOutputValue (hGpioPin、Board_LED2、Board_LED_ON);
SimpleBLEPeripheral_mexeu ();
// mpuDataRdy = true;
// sensorReadScheduled = true;
Semaphore_post (SEM);
}
/*********
*@fn SensorTag451_clockHandler
*
*@时钟超时的简单处理程序函数。
*
*@param arg -未使用
*
*@return none
*/
static void SensorTagHandler (UArg 时钟处理程序)
{
//计划定期读取
//apaga o led
PIN_setOutputValue (hGpioPin、Board_LED1、Board_LED_OFF);
PIN_setOutputValue (hGpioPin、Board_LED2、Board_LED_OFF);
//mpuDataRdy = false;
// uint8_t TempAddertEnable = false;
// GAPRole_TerminateConnection();
// GAPRole_SetParameter (GAPROLE_Advertise_enabled、sizeof (uint8_t)、&TempAddertEnable);
// sensorReadScheduled = true;
semaphore_post (sem);
}
/*********
*@fn sensorChangeCB
*
*@Movement Service 的简短回调指示值更改
*
*@param paramID -已更改值的参数 ID。
*
**@返回无*
/
static void sensorChangeCB (uint8_t paramID)
{
//唤醒应用程序线程
// SensorTag_charValueChangeCB (0x04、paramID);
}
/*******
*@fn initCharacteristic Value
*
*@
@brief 初始化一个特征值*@param paramID -要清除该值的参数 ID **@param value -要使用**@param paramLen 进行初始化的值-参数长度* return none
Value */ static void initCharacteristic (uint8_t paramID、 uint8_t 值、
uint8_t paramLen)
{
// memset (sensorData、value、paramLen);
// Movement_SetParameter (paramID、paramLen、sensorData);
}
/*********
*@fn appStateSet
*
*@brief 设置应用程序状态
*
*/
static void appStateSet (uint8_t newState)
{
#if 0
if (newState == app_State_off)
{
appState = app_State_off;
SensorMpu9250_enable (0);
SensorMpu9250_poweroff();
//停止计划的数据测量
Util_stopClock (&periodicClock);
}
if (newState == APP_State_active || newState == APP_State_Idle)
{
appState = app_State_active;
nActivity = MOVITY_INACT_CYCLES;
movThreshold = WOM_THR;
mpuIntStatus = 0;
ShakeDetected = false;
mpuDataRdy = false;
SensorMpu9250_powerOn ();
// SensorMpu9250_enable (mpuConfig & 0xFF);
SensorMpu9250_enable (0b0001110100000000);
if (newState == APP_State_active)
{
//开始计划的数据测量
Util_startClock (周期时钟);
}
其他
{
//停止计划的数据测量
Util_stopClock (周期时钟);
}
}
#endif
}
#endif // exclude_MOV
/*********
(三 /
cadeira.c 文件
/* * cadeira.c * *创建日期:26 de jun de 2017 * 作者:Nicholas * /********* *包括 */ #include #include #include #include #include #include #include #include #include #include "gatt.h" #include "hci.h" #include "gapgattserver.h" #include "gattservapp.h" #include "gapbondmgr.h" #include "osal_sdv.h" #include "util.h" #include "task_apimsg.h" #include "sensortask" /Middleware/sensors/SensorI2C.h #include "#include "/sensor.h"#include #include #define task"#include "/sensorch.h"#include #include #include "#include #.org.h"#include #include #include #.org.h 1 #ifndef ST_TASK_STACK_SIZE //堆栈大小可被项目设置 #define ST_TASK_STACK_SIZE 覆盖 700 #endif static void Cadeira_taskFxn (UArg a0、UArg A1); //用于应用程序消息 的队列对象 static Queue_Structd appMsg; static Queue_handle appMsgQueue; /********* *全局变量 */ /配置文件状态和参数 gaprole_states_t gapProfileState = GAPROLE_init; //全局信号量用于将事件发布到应用程序线程 iCall_Semaphore SEM; //全局实体 ID 用于检查消息的源和/或目标 iCall_EntityID Entityself; *** gpinoState;/ gpinoPIN 全局处理 *局部变量 * / * typedef */ //从配置文件传递的应用程序事件。 tytagf 结构 { uint8_t event;//哪个配置文件的事件 uint8_t serviceID;//新状态 uint8_t paramID; }stEvt_t; //任务配置 静态 Task_sedef cadeiraTask; 静态特性 cadeiraTaskStack[ST_TASK_STACK_SIZE]; // 应用程序正在使用的静态配置 PIN_AppConfig = {// Pintagpinring] Board_LED1 | PIN_GPIO_OUTP_EN | PIN_GPIO_LOW | PIN_PushPull | PIN_DRVSTR_MAX、 /* LED 最初关闭 * Board_LED2 | PIN_GPIO_OUTP_EN | PIN_GPIO_LOW | PIN_PushPull | PIN_DRVSTR_MAX、 /* LED 最初关闭 * BOARD_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_迟滞、 /*按钮为低电平有效 * BOARD_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_迟滞、 /*按钮为低电平有效 * Board_relay | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_BOTHEDGES | PIN_迟滞、 /*继电器高电平有效 * Board_蜂 鸣器 | PIN_GPIO_OUTP_EN | PIN_GPIO_LOW | PIN_PushPull | PIN_DRVSTR_MAX、 /*蜂鸣器最初关闭 * PIN_Terminate }; void Cadeira_createTask (void) { Task_Params taskParams; //配置任务 Task_Params_init (&taskParams); 任务 Params.stack = cadeiraTaskStack; 任务 Params.STACKSIZE = ST_TASK_STACK_SIZE;任务 Params.priority = ST_TASK_TASK_PRIORITY;任务 params.stepal = ST_TASK_TASK_TASK_TASK_TASK_TASK_TASK( Cadeira_taskFxn、&taskParams、NULL); } /《*********》 *@fn SensorTag_taskFxn * *@SensorTag 的简短应用任务入口点 * *@param a0、A1 (未使用) * *@返回无 */ 静态空 Cadeira_taskFxn (UArg a0、UArg A1) { //为传感器设置 I2C SensorI2C_open (); //处理按钮、LED、继电器 hGpioPin = PIN_OPEN (&pinGpioState、SensorTagAppPinTable); //PIN_registerIntCb (hGpioPin、SensorTag_callback); 秘书长的报告 //在调用 iCall_registerApp 之前可能会发生 N0栈 API 调用 秘书长的报告 //将当前线程注册为 iCall 调度应用程序 //以便应用程序可以发送和接收消息。 iCall_registerApp (self EntityMain、&sem); //为要发送到应用程序的配置文件中的消息创建 RTOS 队列。 appMsgQueue = Util_constructQueue (&appMsg); //初始化应用程序 SensorTagita_itaginit(); //移动处理器 //应用程序主循环 对于(;) { //等待与调用线程关联的信号量。 //请注意、当发出信号时、与线程关联的信号量会发出信号 //消息在线程的消息接收队列中排队,或在何时排队 // iCall_signal ()函数被调用到信号量上。 iCall_errno errno = iCall_Wait (ICALL_TIMEOUT_FOREVAL); if (errno =ICALL_errno_Success) { iCall_EntityID dest; iCall_ServiceEnum src; iCall_HciExtEvt *pMsg =空; if (iCall_fetchServiceMsg (&src、&dest、 (void **)&pMsg)=ICALL_errno_Success) { IF (((src=ICALL_SERVICE_CLASS_BLE)&&(dest =self EntityMain)) { // //处理任务间消息 // SensorTag_processStackMsg ((iCall_HDR *) pMsg); } if (pMsg) { iCall_freeMsg (pMsg); } } //如果 RTOS 队列不为空,则处理应用程序消息。 while (!Queue_empty (appMsgQueue)) { stEvt_t *pMsg =(stEvt_t *) Util_dequeueMsg (appMsgQueue); if (pMsg) { // //处理消息。 // SensorTag_processAppMsg (pMsg); //从消息中释放空间。 iCall_free (pMsg); } } SensorTagait_processSensorEvent(); } }