Files
JBao_Heat_Lamp_FW/apps/usr_periph/bsp_zc.h
T

56 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/******************************************************************************
* @file bsp_zc.h
* @brief PA1 过零检测(MCPWM FPIN 双沿中断)
* @author cyWu <1917507415@qq.com>
* @date 2026.09.04
* @version V3.1.0
* @history
* - V3.1.0, 2026.09.04, cyWu, 精简注释
* - V3.0.0, 2026.09.04, cyWu, FPIN 硬件边沿中断
*
* @note BR28 无通用 GPIO 中断,沿检测复用 MCPWM FPIN(例程 usr_hw_gpio_int.c)。
* PA1 占两个通道实现双沿。ISR 只准清 pending、计数、回调切 GPIO。
* 软件兜底必须用真实 1ms 定时器,禁止在 20ms 节拍里空循环采样。
******************************************************************************/
#ifndef __BSP_ZC_H__
#define __BSP_ZC_H__
#include <stdint.h>
typedef void (*BspZcEdgeCb_t)(void);
/**
* @brief 初始化 PA1 并挂 FPIN 双沿中断
* @param cb 沿回调(app_relay 提供),NULL 则只计数
* @return 无
*/
void bsp_zc_init(BspZcEdgeCb_t cb);
/**
* @brief 1ms 软件采样兜底
* @note 须由真实 1ms 定时器调用
* @return 无
*/
void bsp_zc_scan_1ms(void);
/**
* @brief 累计过零沿次数
* @return 沿计数
*/
uint32_t bsp_zc_edge_count(void);
/**
* @brief 最近一次沿的时间戳
* @return timer_get_ms()0=从未检测到
*/
uint32_t bsp_zc_last_edge_ms(void);
/**
* @brief 当前 PA1 电平
* @return 0 或 1
*/
uint8_t bsp_zc_level(void);
#endif /* __BSP_ZC_H__ */