pindef.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* pindef.h — 由 pindef.json 生成 (html_tools/pindef 编辑器)。勿手改, 改 pindef.json 后重新生成。
  2. * 引脚定义为 hal_pin_t 单值 (PA()/PB(), 见 hal_gpio_port.h)。 */
  3. #ifndef INCLUDE_PINDEF_H_
  4. #define INCLUDE_PINDEF_H_
  5. #include "CH58x_common.h"
  6. #include "hal_gpio_port.h" /* PA()/PB()/hal_pin_t */
  7. /* GPIOB 辅助宏 (SDK 只提供 GPIOB_PinOutput/Input) */
  8. #define GPIOB_PinOutput(pin) (R32_PB_DIR |= pin)
  9. #define GPIOB_PinInput(pin) (R32_PB_DIR &= ~pin)
  10. /* 引脚定义 (hal_pin_t) */
  11. #define LED_PIN PB(GPIO_Pin_14) // PB14
  12. #define LED_SW PB(GPIO_Pin_11) // PB11 (LED开关 - 备用)
  13. #define SOUND_PIN PB(GPIO_Pin_9) // PB9
  14. #define SOUND_SW PA(GPIO_Pin_10) // PA10
  15. #define SW_KEY PA(GPIO_Pin_4) // PA4
  16. #define ZZZ PB(GPIO_Pin_12)
  17. /* PWM 通道 */
  18. #define PWM_LED_CHANNEL CH_PWM10
  19. /* 按键检测位 (从 SW_KEY 派生, 原始寄存器快速读, 不走 hal_gpio 抽象) */
  20. #define KEY10_BV BV(4)
  21. #define KEY10_IN (ACTIVE_LOW(R32_PA_PIN & KEY10_BV))
  22. /* ==================== RF 构建变体 ====================
  23. * SI24R1 5字节通信地址 + 信道。build 脚本按设备重写 (通过 -D 覆盖, #ifndef 守卫)。
  24. * 【重要】中控与从机两端必须完全一致, 否则无法通信。修改后两端同步重新编译部署。 */
  25. #ifndef INIT_ADDR
  26. #define INIT_ADDR 0x34,0x43,0x10,0x10,0x02 /* SI24R1 5字节地址 */
  27. #endif
  28. #ifndef SI24R1_CH
  29. #define SI24R1_CH 16 /* SI24R1 信道 (0-127, 1MHz步进) */
  30. #endif
  31. /* ==================== 跳频信道池 ====================
  32. * 跳频信道池: 避开 WiFi ch1/6/11/13。
  33. * 用法: static const uint8_t pool[HOP_POOL_SIZE] = HOP_POOL;
  34. * HOP_POOL_SIZE 自动 = 元素数 (生成器计算, 无需手工同步)。 */
  35. #ifndef HOP_POOL
  36. #define HOP_POOL {16,84,98,112}
  37. #endif
  38. #ifndef HOP_POOL_SIZE
  39. #define HOP_POOL_SIZE 4 /* 自动 = HOP_POOL 元素数 */
  40. #endif
  41. /* LED 节能亮度曲线数据 (struct eco_s 聚合初始化值, 见 hw_config.h)。
  42. * 字段顺序: { pwm_start, sec, pwm_end, is_loop, loop_max_sec }
  43. * pwm 单位 1/100 (10000=满亮度), sec 单位秒。
  44. * 展开为 hw_config.c: struct eco_s eco_plan[] = { MLED_ECO_PLAN_DATA };
  45. * 阶段数由 hw_config.c 用 sizeof 自动计算, 无需手动维护 ECO_PLAN_LEN。 */
  46. #define MLED_ECO_PLAN_DATA \
  47. { 6500, 300, 6000, 0, 0 }, \
  48. { 6000, 1200, 6000, 0, 0 }, \
  49. { 6000, 300, 5500, 0, 0 }, \
  50. { 5500, 600, 5500, 0, 0 }, \
  51. { 5500, 600, 5000, 0, 0 }, \
  52. { 5000, 60, 5000, 0, 0 }
  53. #endif /* INCLUDE_PINDEF_H_ */