|
@@ -0,0 +1,511 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ * ===================================================
|
|
|
|
|
+ * project_config.h — 全局可调配置集中管理
|
|
|
|
|
+ * ===================================================
|
|
|
|
|
+ *
|
|
|
|
|
+ * 本文件汇集 APP 内所有可修改的硬件、时序、阈值参数。
|
|
|
|
|
+ * 修改任何参数后重新编译即可生效,无需逐文件查找。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 使用 #ifndef 守卫允许编译选项(-D)或上游头文件覆盖。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 本文件不包含:
|
|
|
|
|
+ * - 内存/缓冲大小 (memory_pool_c.h 自行管理)
|
|
|
|
|
+ * - BLE 连接参数 (peripheral.c 自行管理)
|
|
|
|
|
+ * - NRF 寄存器地址/位定义 (sir24drv.h 芯片手册常量)
|
|
|
|
|
+ * - GATT UUID (gattprofile.h Profile 定义)
|
|
|
|
|
+ * - GPIO 引脚映射 (pindef.h 硬件绑定)
|
|
|
|
|
+ *
|
|
|
|
|
+ * 编码: GBK (与项目保持一致)
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef PROJECT_CONFIG_H
|
|
|
|
|
+#define PROJECT_CONFIG_H
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 1. RF 构建变体 ==================== */
|
|
|
|
|
+/* 由 build 脚本通过 -d 选项重写,每台设备编译时生成不同 .hex。
|
|
|
|
|
+ * 也可直接修改此处手工构建。 */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef INIT_ADDR
|
|
|
|
|
+#define INIT_ADDR 0x34,0x43,0x10,0x10,0x02 /* SI24R1 5字节地址 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef SI24R1_CH
|
|
|
|
|
+#define SI24R1_CH 16 /* SI24R1 信道 (0-127, 1MHz步进) */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 2. 跳频参数 ==================== */
|
|
|
|
|
+/* 【重要】中控与从机两端必须完全一致,否则无法通信。
|
|
|
|
|
+ * 修改后两端同步重新编译部署。 */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef HOP_POOL
|
|
|
|
|
+/* 跳频信道池:避开 WiFi ch1/6/11/13。
|
|
|
|
|
+ * 4 信道:16(低端夹缝),84(中段),98(中高),112(高端) */
|
|
|
|
|
+#define HOP_POOL {16,84,98,112}
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef HOP_POOL_SIZE
|
|
|
|
|
+#define HOP_POOL_SIZE 4 /* 信道池大小 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef HOP_SLOT_MS
|
|
|
|
|
+#define HOP_SLOT_MS 32 /* 跳频时隙 (ms),与中控 MODE_TICK_MS 对齐 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef HOP_RX_TIMEOUT_MS
|
|
|
|
|
+#define HOP_RX_TIMEOUT_MS 320 /* 失步阈值 (ms),作为 HOP_CREDIT_MAX 导出基准 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#define HOP_CREDIT_MAX (HOP_RX_TIMEOUT_MS / HOP_SLOT_MS) /* 信用桶满额 (=10) */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef HOP_CREDIT_RX_GAIN
|
|
|
|
|
+#define HOP_CREDIT_RX_GAIN 2 /* 每 slot 收包信用增益 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef HOP_RX_SELF_HEAL_MS
|
|
|
|
|
+#define HOP_RX_SELF_HEAL_MS 10000 /* 硬件自愈超时 (ms): 连续无包此时间后软复位 SI24R1 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* SipHash-2-4 共享密钥 (16 字节)
|
|
|
|
|
+ * 两端必须完全一致,否则 MAC 校验失败→灯光包全部丢弃。
|
|
|
|
|
+ * 当前为占位测试密钥,正式部署前替换。 */
|
|
|
|
|
+#ifndef HOP_KEY_BYTE_0
|
|
|
|
|
+#define HOP_KEY_INIT { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, \
|
|
|
|
|
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 3. 灯光相位同步 ==================== */
|
|
|
|
|
+/* 丢包兜底:从机 RTC 外推 phase 保持动画连续,直到重新收包或 RF 超时。 */
|
|
|
|
|
+
|
|
|
|
|
+/* 相位模式值:与中控 MODE_VALUE_* 一致 */
|
|
|
|
|
+#ifndef RF_PHASE_MODE_CONST
|
|
|
|
|
+#define RF_PHASE_MODE_CONST 0u
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef RF_PHASE_MODE_BLINK
|
|
|
|
|
+#define RF_PHASE_MODE_BLINK 2u
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef RF_PHASE_MODE_GRADIENT
|
|
|
|
|
+#define RF_PHASE_MODE_GRADIENT 3u
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef RF_PHASE_FALLBACK_MS
|
|
|
|
|
+#define RF_PHASE_FALLBACK_MS 80u /* 丢包超过此毫秒数后才启用相位外推 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 相位软同步参数 */
|
|
|
|
|
+#ifndef PHASE_SOFT_ALPHA_N
|
|
|
|
|
+#define PHASE_SOFT_ALPHA_N 77 /* alpha 分子, α≈0.3 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PHASE_SOFT_ALPHA_D
|
|
|
|
|
+#define PHASE_SOFT_ALPHA_D 256 /* alpha 分母 (>>8 免除法) */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PHASE_SOFT_LIMIT
|
|
|
|
|
+#define PHASE_SOFT_LIMIT 8192 /* 单次校正限幅,防丢包大跳 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 相位外推启用延迟:距上次收包超过此毫秒数才从每包亮度切换到 RTC 外推 */
|
|
|
|
|
+#ifndef RF_PHASE_EXTRAPOLATE_DT_MS
|
|
|
|
|
+#define RF_PHASE_EXTRAPOLATE_DT_MS 100u
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 默认 blink_period_units:老固件不发该字节时的兜底值,退化为慢闪速率 */
|
|
|
|
|
+#ifndef DEFAULT_BLINK_PERIOD_UNITS
|
|
|
|
|
+#define DEFAULT_BLINK_PERIOD_UNITS 20
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 4. TMOS / 时序任务间隔 ==================== */
|
|
|
|
|
+/* TMOS 时基: 1 tick = 1/32768 s ≈ 0.0305 ms. 以下为 tick 数。 */
|
|
|
|
|
+
|
|
|
|
|
+/* PERIODIC 渲染任务重排间隔: 16*1 = 16 ticks ≈ 10ms */
|
|
|
|
|
+#ifndef RF_PERIODIC_RETICK
|
|
|
|
|
+#define RF_PERIODIC_RETICK (16*1)
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 渲染采样间隔:16ms, <= BURST 半周期 32ms/2 (奈奎斯特) */
|
|
|
|
|
+#ifndef RENDER_SAMPLE_TICK
|
|
|
|
|
+#define RENDER_SAMPLE_TICK MS_TO_RTC(16)
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* RF 超时计数上限: 16ms×3000≈48s 无中控包 → isRFOn=false */
|
|
|
|
|
+#ifndef RF_TIMEOUT_COUNT
|
|
|
|
|
+#define RF_TIMEOUT_COUNT 3000
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 按键轮询 */
|
|
|
|
|
+#ifndef KEY_POLL_INIT_TICK
|
|
|
|
|
+#define KEY_POLL_INIT_TICK (16*50) /* 按键事件后加速轮询 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef KEY_POLL_CONT_TICK
|
|
|
|
|
+#define KEY_POLL_CONT_TICK (16*10) /* 常规轮询间隔 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 近距离感应/群控状态检查 (SELF_LIGHT_EVT) */
|
|
|
|
|
+#ifndef SELF_LIGHT_PERIOD_TICK
|
|
|
|
|
+#define SELF_LIGHT_PERIOD_TICK 1600 /* ≈50ms */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 节能 (ECO) 任务 */
|
|
|
|
|
+#ifndef OPENVOICE_SHORT_TICK
|
|
|
|
|
+#define OPENVOICE_SHORT_TICK (1600*2) /* ≈100ms, 过渡阶段 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef OPENVOICE_NORMAL_TICK
|
|
|
|
|
+#define OPENVOICE_NORMAL_TICK 1600 /* ≈50ms, 正常阶段 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef OPENVOICE_LONG_TICK
|
|
|
|
|
+#define OPENVOICE_LONG_TICK (1600*3600) /* ≈180s, 长间隔阶段 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 系统定时器 */
|
|
|
|
|
+#ifndef SYSTICK_INTERVAL
|
|
|
|
|
+#define SYSTICK_INTERVAL 1000
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 看门狗周期: FREQ_SYS / WDT_PERIOD_DIV */
|
|
|
|
|
+#ifndef WDT_PERIOD_DIV
|
|
|
|
|
+#define WDT_PERIOD_DIV 10 /* 100ms */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 5. LED PWM / 亮度控制 ==================== */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef PWM_CLOCK_DIVX
|
|
|
|
|
+#define PWM_CLOCK_DIVX 2 /* PWM 时钟分频 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef PWM_LED_ECHO_INIT
|
|
|
|
|
+#define PWM_LED_ECHO_INIT 9500 /* 初始 PWM 回显 (95.00%) */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef BRIGHTNESS_SCALE_DEN
|
|
|
|
|
+#define BRIGHTNESS_SCALE_DEN 10000 /* 亮度缩放分母 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef BRIGHTNESS_MIN_THRESHOLD
|
|
|
|
|
+#define BRIGHTNESS_MIN_THRESHOLD 10 /* 低于此值直接关断 LED */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef BRIGHTNESS_FULL_THRESHOLD
|
|
|
|
|
+#define BRIGHTNESS_FULL_THRESHOLD 0xf0 /* 高于此值视为满亮 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* LED 各模式最大计数值 */
|
|
|
|
|
+#ifndef MAX_SLOW
|
|
|
|
|
+#define MAX_SLOW 8
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef MAX_FAST
|
|
|
|
|
+#define MAX_FAST 4
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef MAX_FLASH
|
|
|
|
|
+#define MAX_FLASH 2
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef MAX_GLOW
|
|
|
|
|
+#define MAX_GLOW 160
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef MAX_PARIR
|
|
|
|
|
+#define MAX_PARIR 300
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 呼吸灯间隔 (RTC tick) */
|
|
|
|
|
+#ifndef GLOW_INTERVAL_TICK
|
|
|
|
|
+#define GLOW_INTERVAL_TICK 100
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 闪烁模式分频: flashMode() 每 N 次 tick 执行一次 */
|
|
|
|
|
+#ifndef FLASH_MODE_DIVIDER
|
|
|
|
|
+#define FLASH_MODE_DIVIDER 6
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 6. 声音检测 ==================== */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef SOUND_DEBOUNCE_COUNT
|
|
|
|
|
+#define SOUND_DEBOUNCE_COUNT 2 /* 去抖动连续采样次数 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef SOUND_ACTIVE_DURATION
|
|
|
|
|
+#define SOUND_ACTIVE_DURATION 10 /* 检测到声音后 LED 保持亮起的轮次 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#ifndef SOUND_CHECK_INTERVAL_MS
|
|
|
|
|
+#define SOUND_CHECK_INTERVAL_MS 2 /* 声音检测间隔 (ms) */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 7. 按键 / 电源管理 ==================== */
|
|
|
|
|
+
|
|
|
|
|
+/* 操作模式 */
|
|
|
|
|
+#ifndef OPMODE_UNKNOWN
|
|
|
|
|
+#define OPMODE_UNKNOWN 0
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef OPMODE_NORMAL
|
|
|
|
|
+#define OPMODE_NORMAL 1
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef OPMODE_BLE
|
|
|
|
|
+#define OPMODE_BLE 7
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef OPMODE_PAIRE
|
|
|
|
|
+#define OPMODE_PAIRE 8
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef OPMODE_SHUTDOWN
|
|
|
|
|
+#define OPMODE_SHUTDOWN 9
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 模式存储 Flash 地址 */
|
|
|
|
|
+#ifndef MODE_ADDR
|
|
|
|
|
+#define MODE_ADDR 0x1000
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 长按阈值: poll 周期计数, ~3s */
|
|
|
|
|
+#ifndef KEY_LONG_PRESS_THRESHOLD
|
|
|
|
|
+#define KEY_LONG_PRESS_THRESHOLD 25
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 按键序列超时: RTC 周期, 释放后此时间内再次按下视为连续 */
|
|
|
|
|
+#ifndef KEY_SEQUENCE_TIMEOUT
|
|
|
|
|
+#define KEY_SEQUENCE_TIMEOUT 12000
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 自动关机空闲计数 */
|
|
|
|
|
+#ifndef AUTO_SHUTDOWN_COUNT
|
|
|
|
|
+#define AUTO_SHUTDOWN_COUNT 150
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 开机防抖: 上电后此时长内长按不触发关机 */
|
|
|
|
|
+#ifndef STARTUP_GUARD_MS
|
|
|
|
|
+#define STARTUP_GUARD_MS 10
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 8. SI24R1 模式/配置值 ==================== */
|
|
|
|
|
+
|
|
|
|
|
+/* CONFIG 寄存器 (详见 sir24drv.h 位定义) */
|
|
|
|
|
+#ifndef CONFIG_TX_MODE
|
|
|
|
|
+#define CONFIG_TX_MODE 0x0e /* TX 模式 CONFIG 值 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef CONFIG_RX_MODE
|
|
|
|
|
+#define CONFIG_RX_MODE 0x0f /* RX 模式 CONFIG 值 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* RF_SETUP 寄存器初始化值 (250K_1Mbps + LNA_HCURR + PWR_0DB) */
|
|
|
|
|
+#ifndef RF_SETUP_INIT_VALUE
|
|
|
|
|
+#define RF_SETUP_INIT_VALUE 0x26
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* TX 重试超时 */
|
|
|
|
|
+#ifndef TX_RETRY_TIMEOUT_MS
|
|
|
|
|
+#define TX_RETRY_TIMEOUT_MS 500
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 自动重传 */
|
|
|
|
|
+#ifndef AUTO_RETRANSMIT_COUNT
|
|
|
|
|
+#define AUTO_RETRANSMIT_COUNT 15
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef AUTO_RETRANSMIT_DELAY
|
|
|
|
|
+#define AUTO_RETRANSMIT_DELAY ARD_4000US
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 固定包长 (动态包关闭时) */
|
|
|
|
|
+#ifndef FIXED_PACKET_LEN
|
|
|
|
|
+#define FIXED_PACKET_LEN 32
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* SI24R1 默认模式 (init 后) */
|
|
|
|
|
+#ifndef SI24_DEFAULT_MODE
|
|
|
|
|
+#define SI24_DEFAULT_MODE 8
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 9. SI24R1 位bang SPI 引脚 ==================== */
|
|
|
|
|
+/* SI24R1 使用 GPIO 模拟 SPI 时序 (非硬件 SPI0 外设)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * SI24R1_SPI_USE_PORTB = 0: PA12(CSN) PA13(SCK) PA14(MOSI) PA15(MISO)
|
|
|
|
|
+ * PA11(CE) PA5(IRQ) — 默认,无需 remap
|
|
|
|
|
+ * SI24R1_SPI_USE_PORTB = 1: 开启 SPI0 引脚重映射到 PB12-PB15,
|
|
|
|
|
+ * CE/IRQ 也切到 PB 对应引脚。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 注意: CE 和 IRQ 是普通 GPIO,不随 SPI0 remap 自动切换,需手动指定 PB 引脚。
|
|
|
|
|
+ * 切换端口后需调用 SI24R1_SPI_REMAP_INIT() 执行 GPIOPinRemap。 */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef SI24R1_SPI_USE_PORTB
|
|
|
|
|
+#define SI24R1_SPI_USE_PORTB 0 /* 0=Port A (默认), 1=Port B (开 remap) */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#if SI24R1_SPI_USE_PORTB
|
|
|
|
|
+ /* ---- Port B (开启 GPIOPinRemap ENABLE, RB_PIN_SPI0 后) ---- */
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_CLK_GPIO_PIN
|
|
|
|
|
+ #define SPI_CLK_GPIO_PIN GPIO_Pin_13
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_CLK_PORT B
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_MISO_GPIO_PIN
|
|
|
|
|
+ #define SPI_MISO_GPIO_PIN GPIO_Pin_15
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_MISO_PORT B
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_MOSI_GPIO_PIN
|
|
|
|
|
+ #define SPI_MOSI_GPIO_PIN GPIO_Pin_14
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_MOSI_PORT B
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_NSS_GPIO_PIN
|
|
|
|
|
+ #define SPI_NSS_GPIO_PIN GPIO_Pin_12
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_NSS_PORT B
|
|
|
|
|
+
|
|
|
|
|
+ /* CE 和 IRQ 是普通 GPIO,不在 SPI0 remap 范围内,按需改引脚 */
|
|
|
|
|
+ #ifndef RF24L01_CE_GPIO_PIN
|
|
|
|
|
+ #define RF24L01_CE_GPIO_PIN GPIO_Pin_11
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define RF24L01_CE_PORT B
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef RF24L01_IRQ_GPIO_PIN
|
|
|
|
|
+ #define RF24L01_IRQ_GPIO_PIN GPIO_Pin_5
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define RF24L01_IRQ_PORT B
|
|
|
|
|
+
|
|
|
|
|
+ /* 初始化时调用此宏执行硬件重映射 */
|
|
|
|
|
+ #define SI24R1_SPI_REMAP_INIT() GPIOPinRemap(ENABLE, RB_PIN_SPI0)
|
|
|
|
|
+
|
|
|
|
|
+#else
|
|
|
|
|
+ /* ---- Port A (默认, 无需 remap) ---- */
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_CLK_GPIO_PIN
|
|
|
|
|
+ #define SPI_CLK_GPIO_PIN GPIO_Pin_13
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_CLK_PORT A
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_MISO_GPIO_PIN
|
|
|
|
|
+ #define SPI_MISO_GPIO_PIN GPIO_Pin_15
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_MISO_PORT A
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_MOSI_GPIO_PIN
|
|
|
|
|
+ #define SPI_MOSI_GPIO_PIN GPIO_Pin_14
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_MOSI_PORT A
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef SPI_NSS_GPIO_PIN
|
|
|
|
|
+ #define SPI_NSS_GPIO_PIN GPIO_Pin_12
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define SPI_NSS_PORT A
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef RF24L01_CE_GPIO_PIN
|
|
|
|
|
+ #define RF24L01_CE_GPIO_PIN GPIO_Pin_11
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define RF24L01_CE_PORT A
|
|
|
|
|
+
|
|
|
|
|
+ #ifndef RF24L01_IRQ_GPIO_PIN
|
|
|
|
|
+ #define RF24L01_IRQ_GPIO_PIN GPIO_Pin_5
|
|
|
|
|
+ #endif
|
|
|
|
|
+ #define RF24L01_IRQ_PORT A
|
|
|
|
|
+
|
|
|
|
|
+ #define SI24R1_SPI_REMAP_INIT() /* 无需操作 */
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 10. 通用 GPIO 操作宏 ==================== */
|
|
|
|
|
+/* 将 port + pin 自动派发到 GPIOA_xxx / GPIOB_xxx 函数。
|
|
|
|
|
+ * 与 pindef.h 的 xxx_PORT / xxx_PIN 配合使用。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 用法:
|
|
|
|
|
+ * GPIO_PIN_ModeCfg(SW_KEY_PORT, SW_KEY, GPIO_ModeIN_PU);
|
|
|
|
|
+ * GPIO_PIN_SetBits(SOUND_SW_PORT, SOUND_SW);
|
|
|
|
|
+ * GPIO_PIN_ClearITFlagBit(SW_KEY_PORT, SW_KEY);
|
|
|
|
|
+ *
|
|
|
|
|
+ * 端口用单字母 A/B, pin 用 GPIO_Pin_* 宏。零运行时开销。 */
|
|
|
|
|
+
|
|
|
|
|
+/* 内层宏: 接收已展开的端口字母 (A/B), 用 ## 拼出 GPIOx_xxx 函数名 */
|
|
|
|
|
+#define _GPIO_PIN_ModeCfg(port, pin, mode) GPIO##port##_ModeCfg(pin, mode)
|
|
|
|
|
+#define _GPIO_PIN_SetBits(port, pin) GPIO##port##_SetBits(pin)
|
|
|
|
|
+#define _GPIO_PIN_ResetBits(port, pin) GPIO##port##_ResetBits(pin)
|
|
|
|
|
+#define _GPIO_PIN_ITModeCfg(port, pin, mode) GPIO##port##_ITModeCfg(pin, mode)
|
|
|
|
|
+#define _GPIO_PIN_ClearITFlagBit(port, pin) GPIO##port##_ClearITFlagBit(pin)
|
|
|
|
|
+#define _GPIO_PIN_ReadPortPin(port, pin) GPIO##port##_ReadPortPin(pin)
|
|
|
|
|
+
|
|
|
|
|
+/* 外层宏: 先展开 xxx_PORT 为 A/B, 再交给内层粘贴 */
|
|
|
|
|
+#define GPIO_PIN_ModeCfg(port, pin, mode) _GPIO_PIN_ModeCfg(port, pin, mode)
|
|
|
|
|
+#define GPIO_PIN_SetBits(port, pin) _GPIO_PIN_SetBits(port, pin)
|
|
|
|
|
+#define GPIO_PIN_ResetBits(port, pin) _GPIO_PIN_ResetBits(port, pin)
|
|
|
|
|
+#define GPIO_PIN_ITModeCfg(port, pin, mode) _GPIO_PIN_ITModeCfg(port, pin, mode)
|
|
|
|
|
+#define GPIO_PIN_ClearITFlagBit(port, pin) _GPIO_PIN_ClearITFlagBit(port, pin)
|
|
|
|
|
+#define GPIO_PIN_ReadPortPin(port, pin) _GPIO_PIN_ReadPortPin(port, pin)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 11. 协议封包类型标识 ==================== */
|
|
|
|
|
+/* 无线/蓝牙包首字节 */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef PKT_TYPE_CENTRAL_CTRL
|
|
|
|
|
+#define PKT_TYPE_CENTRAL_CTRL 0xaa /* 中控广播包 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_PAIR_DATA
|
|
|
|
|
+#define PKT_TYPE_PAIR_DATA 0x56 /* 配对/群控数据包 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_FLASH_WRITE
|
|
|
|
|
+#define PKT_TYPE_FLASH_WRITE 0x57 /* 闪存写入 (BLE) */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_RESET
|
|
|
|
|
+#define PKT_TYPE_RESET 0x58 /* 复位 (BLE) */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_BLE_LIGHT_CTRL
|
|
|
|
|
+#define PKT_TYPE_BLE_LIGHT_CTRL 0x60 /* BLE 灯光控制 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_INFO_RESP
|
|
|
|
|
+#define PKT_TYPE_INFO_RESP 0x61 /* 信息响应 (BLE) */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_OTA
|
|
|
|
|
+#define PKT_TYPE_OTA 0x62 /* OTA 跳转 (BLE, +magic) */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_RELOAD_COLORDB
|
|
|
|
|
+#define PKT_TYPE_RELOAD_COLORDB 0x63 /* 重载颜色数据库 (BLE) */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef PKT_TYPE_SET_COLOR_MODE
|
|
|
|
|
+#define PKT_TYPE_SET_COLOR_MODE 0x64 /* 设置颜色模式 (BLE) */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 12. 颜色数据库 ==================== */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef COLORDB_FILE_MAGIC
|
|
|
|
|
+#define COLORDB_FILE_MAGIC 0x59 /* 颜色数据库文件头魔数 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef COLORDB_MAX_FRAMES_NOINDEX
|
|
|
|
|
+#define COLORDB_MAX_FRAMES_NOINDEX 1024 /* 无索引时最大帧数 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef COLORDB_CACHE_SIZE
|
|
|
|
|
+#define COLORDB_CACHE_SIZE 8 /* 颜色数据库缓存条目数 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef COLORDB_REPEAT_MARKER
|
|
|
|
|
+#define COLORDB_REPEAT_MARKER 0xEF /* 颜色数据库重复标记 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 13. 命令/协议通用 ==================== */
|
|
|
|
|
+
|
|
|
|
|
+#ifndef CMDLEN
|
|
|
|
|
+#define CMDLEN 240 /* 单条命令最大长度 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 命令行表/跟随路径初始容量 */
|
|
|
|
|
+#ifndef CMD_LIST_INIT_CAPACITY
|
|
|
|
|
+#define CMD_LIST_INIT_CAPACITY 8
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef FOLLOW_PATH_INIT_CAPACITY
|
|
|
|
|
+#define FOLLOW_PATH_INIT_CAPACITY 4
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* 模式值 (亮度/颜色模式,与 ledx COLORMODE 对齐) */
|
|
|
|
|
+#ifndef MODE_CONST
|
|
|
|
|
+#define MODE_CONST 0 /* 常亮 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef MODE_BREATH
|
|
|
|
|
+#define MODE_BREATH 1 /* 呼吸 */
|
|
|
|
|
+#endif
|
|
|
|
|
+#ifndef MODE_BLINK_VAL
|
|
|
|
|
+#define MODE_BLINK_VAL 2 /* 闪烁 */
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#endif /* PROJECT_CONFIG_H */
|