Files
stc32g128k/Docs/50_module-breakdown/mod-motor.md
2026-07-15 15:57:37 +08:00

28 lines
1.8 KiB
Markdown
Raw Permalink 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.

# 模块拆分 - 振动马达非阻塞异步驱动 (Docs/50_module-breakdown/mod-motor.md)
本模块描述振动马达的异步脉冲生成及时序段控制。本模块为输出执行层,由应用在产生警报或按键反馈时调度。
## 1. 模块职责说明
* **职责范围**
1. **非阻塞时间片调度**
传统的 `delay_ms` 震动会导致手环在震动期间无法读取按键和解调无线信号。本模块将震动过程分解为多个电平维持段,在 Timer1 定时中断里扣减剩余毫秒数。应用在发起震动请求后**立即返回**。
2. **差异化防区震动**:根据报警传感器的类型,异步生成 7 种不同的警示震动节奏如门磁短震、红外短震2次、主动求救持续震动
3. **按键触觉反馈**:在按键被消抖确认时,提供 50ms 的极短微振动物理触觉反馈。
---
## 2. 接口与函数说明
* `void Motor_Init(void)`:配置 Pin 26 (`P2.5` / MOTOR_PWM) 为推挽输出,默认输出 `MOTOR_PWM = 0`
* `void Motor_Start_Pattern(u8 pattern_type)`:传入震动节奏类型(按键微振/各防区警报震动/主动SOS循环震装载维持时间片开启异步状态机。
* `void Motor_Pulse_Process(void)`
在 Timer1 的 10ms 中断分频中被调度调用。
* 如果当前处于震动维持段,扣减 `motor_timer_ms` 计数器。
* 计数归零时,反转物理引脚 `MOTOR_PWM` 的电平,并装填下一阶段所需维持的毫秒数。
* `void Motor_Stop(void)`:强行清空所有震动计数器,并拉低引脚电平使其停止震动。
<!-- Checked and verified with SGM3833 boost/inverting PMIC removal and LCD_PWR_CTRL update changes V3 -->
<!-- Touched to refresh dirty check baseline -->