feat(Puya-PY32F040): add OTA dual-project codegen template

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 18:56:19 +08:00
co-authored by Cursor
commit 62eb0199ed
498 changed files with 329164 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
/******************************************************************************
* @file jb_timer.h
* @brief TIM6 1ms 基础定时器硬件驱动(ms 计数由协议层 jbTimerIrq 维护)
* @author cyWu <1917507415@qq.com>
* @date 2026.08.10
* @version V1.0.1
* @history
* - V1.0.1, 2026.08.10, cyWu, 软件 ms 计数交还协议层,本模块仅负责 TIM6 硬件
* - V1.0.0, 2026.08.10, cyWu, 首次发布
******************************************************************************/
#ifndef __JB_TIMER_H__
#define __JB_TIMER_H__
#include <stdint.h>
#include "py32f0xx_hal.h"
/*============================================================================*/
/* 宏定义 */
/*============================================================================*/
#ifndef JB_TIMER_PERIOD_MS
#define JB_TIMER_PERIOD_MS (1U) /**< 定时周期 ms */
#endif
#define JB_TIMER TIM6
#define JB_TIMER_IRQn TIM6_LPTIM1_IRQn
#define JB_TIMER_CLK_ENABLE() __HAL_RCC_TIM6_CLK_ENABLE()
/*============================================================================*/
/* 错误码 */
/*============================================================================*/
typedef enum {
JB_TIMER_OK = 0,
JB_TIMER_ERR_PARAM,
JB_TIMER_ERR_BUSY,
JB_TIMER_ERR_TIMEOUT,
JB_TIMER_ERR_NOT_INIT,
JB_TIMER_ERR_HAL,
JB_TIMER_ERR_UNKNOWN
} JbTimer_Ret_t;
/*============================================================================*/
/* 句柄(供 MSP / IRQ */
/*============================================================================*/
extern TIM_HandleTypeDef g_jb_tim_handle;
#define TimHandle g_jb_tim_handle
/*============================================================================*/
/* 外部接口 */
/*============================================================================*/
/**
* @brief 初始化 TIM6 为 1ms 周期中断
* @note 更新回调中应调用协议层 jbTimerIrq(),由协议维护 timerMs
* @return JbTimer_Ret_t
*/
JbTimer_Ret_t jb_timer_init(void);
/**
* @brief 获取初始化状态
* @return JbTimer_Ret_t
*/
JbTimer_Ret_t jb_timer_get_status(void);
#endif /* __JB_TIMER_H__ */