29 lines
1.6 KiB
C
29 lines
1.6 KiB
C
// /* Includes ----------------------------------------------------------------- */
|
|
// #include "task/user_task.h"
|
|
// #include "device/ads8864.h"
|
|
// /* Private typedef ---------------------------------------------------------- */
|
|
// /* Private define ----------------------------------------------------------- */
|
|
|
|
// /* Private macro ------------------------------------------------------------ */
|
|
// /* Private variables --------------------------------------------------------- */
|
|
// Ads8864_t ads8864;
|
|
// /* Private function --------------------------------------------------------- */
|
|
|
|
// /* Exported functions ------------------------------------------------------- */
|
|
// void Task_Adc(void *argument) {
|
|
// (void)argument; // 消除未使用参数的警告
|
|
|
|
// /* 计算任务运行到指定频率需要等待的tick数 */
|
|
// const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_ADC; // 200Hz
|
|
// uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
|
// ads8864_Init(&ads8864); // 初始化 ADC
|
|
// while (1) {
|
|
// tick += delay_tick; /* 计算下一个唤醒时刻 */
|
|
// Ads8864_Read(&ads8864);
|
|
// osMessageQueueReset(task_runtime.msgq.adc); // 重置消息队列
|
|
// osMessageQueuePut(task_runtime.msgq.adc, &ads8864.filtered, 0, 0); // 将数据放入消息队列
|
|
// osMessageQueueReset(task_runtime.msgq.pc); // 重置消息队列
|
|
// osMessageQueuePut(task_runtime.msgq.pc, &ads8864.filtered.distance,0, 0); // 将数据放入消息队列
|
|
// osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
|
// }
|
|
// }
|