完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我有一个示例代码,用于在PSoC4 4200 BLE(CY8CKIT-042-BLU-A)中使用环境感知配置文件。它干扰了风速和其他东西的模拟,但没有显示如何建立一个具有多个传感器输入到ADC的真实系统。我需要从ADC到BLE寄存器中写入新数据?我如何创建一个主循环,读取所有传感器数据,将其写入BLE,然后在唤醒和启动之前关闭芯片一两秒钟?什么是ELS.C中的句柄指示(标志)过程,以及如何与HeleLoTrimeCuffic()进行比较?我如何在所有的特征和描述指针数据类型周围找到我的方法?
我真的很感激这里的任何帮助。谢谢! 史蒂夫 以上来自于百度翻译 以下为原文 I have the example code for using the Environmental Sensing profile in PSoC4 4200 BLE (CY8CKit-042-BLE-A). It messes with simulation of windspeed and other stuff, but doesn't show how to set up a real system with multiple sensor inputs to the ADC. What calls to I make to write new data from ADC into BLE registers? How do I create a main loop that reads all the sensor data, writes it to BLE, then shuts the chip down for a second or two before waking up and starting over? What is the HandleIndication(flags) procedure in ess.c for, and how does it compare with HandleNotification()? How do I find my way around all the CHARACTERISTIC and DESCRIPTION pointer data types? I would really appreciate any help here. Thanks! Steve |
|
相关推荐
5个回答
|
|
|
你将取代“例假”数据读数/加工从你想使用ADC传感器数据。
大多数的BLE实例主循环不断的奔跑,只有调用函数来处理事件/旗帜单独。 handleindication()听起来就像是处理来自远程设备的合理指示的事件,handlenotification()相似,但它是一个不同的稳定运行。和描述的指针数据类型的特性指的是不同的结构,用于发送/读取的值。 这听起来像你有一个清单在各方面的应用问题,我建议把它分解成其组成部分: ADC读取多个传感器。 BLE深睡眠(睡觉和起床后一段时间,等) BLE通信(通知、指示、发送数据) 我会找一个例子,每个人,从最简单的(在顶部)。 处理多个模拟输入/投票率通过模拟多路复用器/ SAR ADC http://www.cypress.com/video-library/psoc/psoc-101-lesson-17-deep-sleep/387641 psoc-4-ble / 100_projects_in_100_days大师·cypresssemiconductorco / psoc-4-ble·GitHub 以上来自于百度翻译 以下为原文 You would replace the "fake" data in the example with the readings/processed data from the ADC sensors you want to use. Most of the BLE examples have the main loop constantly running, and only call the functions to handle events/flags individually. HandleIndication() sounds like it is handling the BLE indication events from the remote device, similar to HandleNotification(), but it is a different BLE operation. The CHARACTERISTIC and DESCRIPTION pointer data types are referring to different BLE structures used to send/read BLE values. It sounds like you have a list of questions on various aspects of the application, I would suggest breaking it into its constituent parts: ADC reading multiple sensors. BLE deep sleep (going to sleep and waking up after a period of time, etc) BLE communication (notifications, indications, sending the data) I would look for an example for each one, starting with the least complicated (at the top). Handling multiple analog inputs/polling rates using an Analog Mux/SAR ADC http://www.cypress.com/video-library/PSoC/psoc-101-lesson-17-deep-sleep/387641 PSoC-4-BLE/100_Projects_in_100_Days at master · cypresssemiconductorco/PSoC-4-BLE · GitHub |
|
|
|
|
yuhe82 发表于 2018-9-26 08:10 E.PrATT, 答案可能是正确的,但没有给出很多细节。 现在,我只想以相同的轮询速率运行所有的传感器,让系统一直保持清醒。让我们通过一些数据。 我用示例的调用替换了SalePrimePrIrror()调用。调用有指向特征数据结构的指针,其中填充了ADCJGETRESULT16.()数据,但在CyScript读取的数据中,我得到零。我真的无法确定ADC是否正在正确地生成数据,或者软件数据通路还没有完全连接好。至少ADC和BLE似乎正在运行。下面是一些代码片段…我错过什么了吗? 六、************************************************************************************************************************* 定义AcCl热敏电阻1Cu(0U) 定义AdcHyHydIDyShanChan-1Cu(1U) CysLeX特性的数据温度1; 湿度特性; / ***************************************************************************************************** *函数Hoad Lead() *** 无效HandleADC(空){ ADCI SeaChanValm(0x00 03);/ /使用两个通道 ADCL(); ADCYSTART转换(); CRGGI BeaSoCuxLoad(1U);//启动时启动ADC ADCI ISEN转换(ADCJAWITITHOFURY结果);/ /等待转换完成 AdcTestCurror(); 温度1值=ADCl GETRESULT16(ADCX热敏电阻1); 湿度=ADCJGETRESULT16(ADCH HyMID); } / ***************************************************************************************************** *函数名:主体() ***************************************************************************************************************************************************************************************** int() { 聚伞花序; 囊状的; *设置初始更改索引值*/ CysLysEsSeaStchange指数(EsSchange指数); /*启动Cyle组件并注册通用事件处理程序*/ CyBLY启动(AppCalBead); *配置按钮中断*/ WakuPiBufftT.StEXTEX(&ButtoPress); UARTHOBDEBASESTATE(); ADCGIN(); EsIn(); /*全局资源初始化*/ ADCJSTART(); OpAMP1*START(); WDTTSTART(); (1) { /*CyByLoPraceSeXScript()允许BLE堆栈处理未决事件*/ 聚伞花序; *实现低功耗的设备*/ 低功耗实现(); /运行传感器数据的ADC HooLead(); *检查是否有更新的数据-用实际数据代替模拟 *模拟轮廓(和;温度1); *模拟轮廓(和湿度); */ 手提电话(温度计1); 手感(湿度); … 如果(连接和CT){ *检查是否有热敏电阻1的通知并发送给*/ CKNTFTANDSEDATA(和;温度1); *检查是否有湿度通知并发送给*/ CHKNTFANDSANDEDATA(和;湿度); *检查是否有指示需要发送到远程客户端并发送它们*/ If((ISActuiabd==是))和(; { 手指(指示器值); 指示不成立; 聚伞花序; } } 主定时器=主定时器; } } / ***************************************************************************************************** *函数名: *环境敏感实例中ESS.C的未改变 ******************************************************************************** * *摘要: *发送一个描述符的变化对客户通知。 * *参数: * sensorptr:一个指向传感器的结构特点。 * ******************************************************************************* / 无效handlenotificaion(cyble_ess_characteristic_data_t * sensorptr) { 聚伞花序; UITN8 TMPBuff[ CyBythiSe2BytheStLe]; *将数据打包为BLE兼容格式…*/ CyBlySt1616BYTR(TMPBUFF,SysRoPTR & gt;值); …并发送它*/ AppRealth= CyByraseSSeNoDebug(连接句柄, 传感器 传感器 大小为2字节, TMPBUFF; 如果(APIREST)!CyelyyeloRosiok { dbg_printf(“发送通知失败:%d rn”,apiresult); }其他 { dbg_printf(“通知# %d %s发送成功。”,CharIndexToText(sensorptr - >;esschrindex),sensorptr - >;chrinstance + 1U); dbg_printf(“通知值:%d.%d m/s rn”,sensorptr - >;价值/ 100U,sensorptr - >;价值% 100u); Syror Pro & Gt;Syror NeXDATAARADY=NO; 传感装置& NTFTIMEN=StRelpPTR & GT;NTFTimeOutValf; } } 以上来自于百度翻译 以下为原文 e.pratt, The answer may be correct as far as it goes, but doesn't give many details. For now, I just want to run all the sensors at the same polling rate and leave the system awake all the time. Let's just get some data through. I replaced the SimulateProfile() calls with HandleNotificaion() /*******************************************************************************/ #define ADC_THERMISTOR1_CHAN (0u) #define ADC_HUMIDITY_CHAN (1u) CYBLE_ESS_CHARACTERISTIC_DATA_T temperature1; CYBLE_ESS_CHARACTERISTIC_DATA_T humidity; /******************************************************************************* * Function HandleADC() ********************************************************************************/ void HandleADC(void) { ADC_SetChanMask(0x0003); // using two channels for now ADC_Enable(); ADC_StartConvert(); CReg_BegSoc_Write(1u); // Start the ADC when ready ADC_IsEndConversion(ADC_WAIT_FOR_RESULT); // Wait for conversions to finish ADC_StopConvert(); temperature1.value = ADC_GetResult16(ADC_THERMISTOR1_CHAN); humidity.value = ADC_GetResult16(ADC_HUMIDITY_CHAN); } /******************************************************************************* * Function Name: main() ******************************************************************************** int main() { CYBLE_API_RESULT_T apiResult; CyGlobalIntEnable; /* Set initial Change Index value */ CyBle_EsssSetChangeIndex(essChangeIndex); /* Start CYBLE component and register generic event handler */ CyBle_Start(AppCallBack); /* Configure button interrupt */ Wakeup_Interrupt_StartEx(&ButtonPressInt); UART_DEB_Start(); ADC_Init(); EssInit(); /* Global Resources initialization */ ADC_Start(); Opamp1_Start(); WDT_Start(); while(1) { /* CyBle_ProcessEvents() allows BLE stack to process pending events */ CyBle_ProcessEvents(); /* To achieve low power in the device */ LowPowerImplementation(); // Run the ADC for sensor data HandleADC(); /* Check if there is updated data -- replace simulation with actual data * SimulateProfile(&temperature1); * SimulateProfile(&humidity); */ HandleNotificaion(&temperature1); HandleNotificaion(&humidity); ... if(connected &ct.) { /* Check if there are notifications for Thermistor1 and send them */ ChkNtfAndSendData(&temperature1); /* Check if there are notifications for Humidity and send them */ ChkNtfAndSendData(&humidity); /* Check if there are indications need to send to remote Client and send them */ if((isIndicationEnabled == YES) && (isIndicationPending == YES)) { HandleIndication(indicationValue); isIndicationPending = NO; CyBle_ProcessEvents(); } } prevMainTimer = mainTimer; } } /******************************************************************************* * Function Name: HandleNotificaion() * -- unaltered from ess.c in the Environmental Sensing example ******************************************************************************** * * Summary: * Sends a notification about a descriptor change to the Client. * * Parameters: * *sensorPtr: A pointer to the sensor characteristic structure. * *******************************************************************************/ void HandleNotificaion(CYBLE_ESS_CHARACTERISTIC_DATA_T *sensorPtr) { CYBLE_API_RESULT_T apiResult; uint8 tmpBuff[CYBLE_ESS_2BYTES_LENGTH]; /* Pack data to BLE compatible format ... */ CyBle_Set16ByPtr(tmpBuff, sensorPtr->value); /* ... and send it */ apiResult = CyBle_EsssSendNotification(connectionHandle, sensorPtr->EssChrIndex, sensorPtr->chrInstance, SIZE_2_BYTES, tmpBuff); if(apiResult != CYBLE_ERROR_OK) { DBG_PRINTF("Send notification is failed: %d rn", apiResult); } else { DBG_PRINTF("Notification for %s #%d was sent successfully. ", CharIndexToText(sensorPtr->EssChrIndex), sensorPtr->chrInstance + 1u); DBG_PRINTF("Notified value is: %d.%d m/s.rn", sensorPtr->value/100u, sensorPtr->value%100u); sensorPtr->sensorNewDataReady = NO; sensorPtr->ntfTimer = sensorPtr->ntfTimeoutVal; } } |
|
|
|
|
该怎么起名字呢 发表于 2018-9-26 08:27 你好, API可能是清除ADC数据寄存器。您可以在读取寄存器值之后注释这个API或放进去。 “”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”,“”,“”,“”,“”,“” ADCI ISEN转换(ADCJAWITITHOFURY结果);/ /等待转换完成 在读取ADC数据寄存器后,将该行或注释放在该行上。 温度1值=ADCl GETRESULT16(ADCX热敏电阻1); 湿度=ADCJGETRESULT16(ADCH HyMID); “”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”,“”,“”,“”,“”,“” -吉安 以上来自于百度翻译 以下为原文 Hello, Probably ADC_StopConvert(); API is clearing the ADC Data Register. Could you comment out this API or put after reading the register value. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ADC_IsEndConversion(ADC_WAIT_FOR_RESULT); // Wait for conversions to finish ADC_StopConvert(); // Comment Out this Line or Put after reading the ADC Data Register. temperature1.value = ADC_GetResult16(ADC_THERMISTOR1_CHAN); humidity.value = ADC_GetResult16(ADC_HUMIDITY_CHAN); """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -Gyan |
|
|
|
|
YHYDZ 发表于 2018-9-26 08:45 我不这么认为。这是StopConvert的密码…它只不过改变了SAMPLE。 空穴停止转换(空隙) { γIF(AdcDebug)SAMPLE AdcSalySAMPrPycTrLyReg和=(UIT32)(~AdcIX连续); { NeNFF/*ADCY-DeFultTySpRaySuffely= } 相反,我摆弄了“通知”复选框上的BLe/Env感测/配置文件和VoILA!开始使用CyScript获取数据。 我希望立即关闭转换以允许低功耗模式接管,而不必进行下一组的自由运行转换。但我猜测这是正确的顺序…还有更好的主意吗?我试图与ADC硬件触发从用户控制寄存器,但最终结束了关闭ADC完全。 史蒂夫 以上来自于百度翻译 以下为原文 I don't think so. Here's the code for StopConvert... It does nothing but change the sample_ctrl_reg continuous_en bit. void ADC_StopConvert(void) { #if(ADC_DEFAULT_SAMPLE_MODE_SEL == ADC__FREERUNNING) ADC_SAR_SAMPLE_CTRL_REG &= (uint32)(~ADC_CONTINUOUS_EN); #endif /* ADC_DEFAULT_SAMPLE_MODE == ADC__FREERUNNING */ } Instead I fiddled with the 'Notifications' checkboxes on the BLE/Env Sensing/Profiles and voila! started getting data with CySmart. I want to shut down conversions right away to allow low-power mode to take over, and not have the next set of free-running conversions already in progress. But I am guessing about the proper sequence for doing this... any better ideas out there? I tried messing with ADC Hardware Triggering from a user control register, but only ended up shutting down the ADC completely. Steve |
|
|
|
|
|
你好,史提夫, 你是对的。很抱歉弄乱了。ADC输出值仍将存在于ADC数据寄存器中,直到下一个转换或功率周期/复位重写为止。 要用Low Power实现前进,可以引用可用的代码示例作为PSoC Creator代码示例的一部分。只要转到PSoC Creator -GT文件-GT;代码示例-gt;搜索“BLYBATTYY-YORE”。 -吉安 以上来自于百度翻译 以下为原文 Hello Steve, You are correct. Sorry for the confusion. The ADC output value will still be there in the ADC data register until overwritten by the next conversion or power cycle/reset. To move forward with Low Power implementation you can refer the code example available as a part of PSoC Creator code examples. Just Go to PSoC Creator-> File-> Code Example-> Search for 'BLE_Battery_Level'. -Gyan |
|
|
|
|
只有小组成员才能发言,加入小组>>
786个成员聚集在这个小组
加入小组cyUSB3014一直显示2.1,不能到3.0情况,谁遇到过
7088 浏览 0 评论
2474 浏览 1 评论
2166 浏览 1 评论
4031 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
2073 浏览 6 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
7566浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
6114浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
742浏览 2评论
710浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
7962浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 00:33 , Processed in 1.676719 second(s), Total 80, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1805