/*
* pwm_key_read.c
*
* Created on: 2023Äê7ÔÂ10ÈÕ
* Author: luo
*/
#include "pwm_key_read.h"
#include "all.h"
#include "MyPrintf.h"
#define T_100us_CNT 19230 //100000ns/5.2ns=19230.7
#define T_10us_CNT 1923 //10000ns/5.2ns=1923.07
#define T_12us_CNT 2307 //12000ns/5.2ns=2307
#define T_500us_CNT 96154
PWM_KEY_t Pwm_Key;
uint32_t pwm_frc_cnt_buf[MAX_PWM_BUF_LEN];
uint32_t over_time_cnt_time_buf[MAX_PWM_BUF_LEN];
//============================add by luo 23-0719 test input pwm frequany========================================
//excute in gpio intruupt
static uint8_t pwm_get_step;
void pwmGpioIsr()
{
static uint32_t pre_time_systik_10us=0;
static uint16_t i;
static uint32_t pwm_cnt=0;
static uint8_t pwm_H_cnt,pwm_L_cnt;
static uint32_t pre_systik_cnt,diff_cnt,diff_cnt1;
static uint32_t systik_cnt_start=0,over_time_cnt=0;
uint32_t cur_time;
static bool led_flg;
if(PWM_INTR_CHECK)
{
PWM_INTR_CLEAR1;
PWM_INTR_CLEAR0;
//----------test speed------------
#if 1
led_flg^=1;
if(led_flg)
//if(PWM_H_L_CHECK)
{
GPIO_Init_way1(GPIO_P1

该代码实现了PWM键的读取功能,通过GPIO中断来捕获信号。在中断服务程序中,使用计数器检测PWM脉冲的周期,从而判断PWM的频率。当接收到信号开始和结束的标志时,记录脉冲数并计算时间间隔。此外,还包含了一个测试函数用于打印计数值。
最低0.47元/天 解锁文章
2989

被折叠的 条评论
为什么被折叠?



