ESP32学习笔记:FreeRTOS中的消息队列

实战派 ESP32-S3,双模无线开发板

ESP32-S3 原生支持 ESP-IDF,WiFi + 蓝牙一次搞定

#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "esp_log.h"
#include "driver/timer.h"

#define TIMER_DIVIDER         16  
#define TIMER_SCALE           (TIMER_BASE_CLK / TIMER_DIVIDER/ 1000)  //分频
#define TIMER_INTERVAL0_SEC   (1) //计数值,如果为1,则1ms进入中断;如果为10,则10ms进入中断
#define TEST_WITH_RELOAD      1  

typedef struct {
    uint64_t timer_minute_count;
    uint64_t timer_second_count;
} timer_event_t;

timer_event_t g_timer_event;

xQueueHandle timer_queue;


unsigned int timer_counter = 0;

void IRAM_ATTR timer_group0_isr(void *para) //中断函数
{
    timer_spinlock_take(TIMER_GROUP_0);
    int timer_idx = (int) para;

    // /* Prepare basic event data
    //    that will be then sent back to the main program task */
    timer_counter++;
    timer_event_t evt;
    xQueueSendFromISR(timer_queue, &evt, NULL); //每次进入中断都会向设置

实战派 ESP32-S3,双模无线开发板

ESP32-S3 原生支持 ESP-IDF,WiFi + 蓝牙一次搞定

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

moon2shine

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值