我使用了官方给的BLE Serial Port例程和LL drivers里的ADC例程 在把ADC例程主函数中的一些初始化的函数放到SERIAL port例程的主函数后,将循环部分做成了一个函数 - unsigned long adc[CMD_BUFF_SIZE];
- #if CLIENT
- void adcadcadc(void)
- {
- uint32_t nVBattRawVal = 0;
- uint8_t ret;
- /* Check the ADC flag End Of Down Sampler conversion */
- if( LL_ADC_IsActiveFlag_EODS(ADC) == 1) {
- /* Get the battery raw value from the Down Sampler */
- nVBattRawVal = LL_ADC_DSGetOutputData(ADC);
- adc[0] = LL_ADC_GetADCConvertedValueBatt(ADC, nVBattRawVal, USER_DATAWIDTH);
- /* Printout the output value */
- //printf("Battery voltage %d mV\r\n", LL_ADC_GetADCConvertedValueBatt(ADC, nVBattRawVal, USER_DATAWIDTH));
- ret = aci_gatt_clt_write_without_resp(connection_handle, rx_handle + 1,USER_DATAWIDTH ,
- (uint8_t *)adc[0]);
- if (ret != BLE_STATUS_SUCCESS)
- {
- printf("Error to send ");
- }
- /* Clear the ADC flag End Of Down Sampler conversion */
- LL_ADC_ClearFlag_EODS(ADC);
- /* Toggle the conversion/activity LED */
- BSP_LED_Toggle(BSP_LED1);
- /* Add 100 ms of delay between each measure */
- LL_mDelay(100);
- /* Restart ADC conversion */
- LL_ADC_StartConversion(ADC);
- }
- /* Check the ADC flag overrun of Down Sampler */
- if( LL_ADC_IsActiveFlag_OVRDS(ADC) == 1) {
- /* Clear the ADC flag overrun of Down Sampler */
- LL_ADC_ClearFlag_OVRDS(ADC);
- /* Turn on the LED2 is overrun occurs */
- BSP_LED_On(BSP_LED2);
- }
- }
- #endif
然后把这个函数放到了APP_Tick()中,结果并没有实现 是我aci_gatt_clt_write_without_resp()应用的不对吗?还是思路有问题? |
|