fd767d1dcd
74HC165 开入 + 光耦继电器开出的完整硬件抽象层,接进 defaultTask 的 50ms 节拍。开入 8 路(第二块 165 数据线板上未接,故只有 8 位), 开出 4 路(高电平吸合)。 驱动 BSP drivers: - IOBOARD/ioboard.c 装载与移位时序,每步注明数据手册依据; SH/LD 拉高前先拉低 CLK,否则装载瞬间多移一位; 单次读取上界 26us(延时按最慢列 VCC 2V 全温区取值)。 - IOBOARD/ioboard_bits.c 位序组装纯函数,只依赖 stdint.h, 主机侧可直接 include 做单测:读 8 次为 H,G,F,E,D,C,B,A, A 放 bit0(bit(7-i) = reads[i])。 - 极性集中在 IOBOARD_DO_LEVEL_ACTIVE 一处,接口语义统一为 mask 的 1 = 吸合。 业务接线: - App/util/ioboard_di.c 通道去抖与双区快照,纯逻辑; 刻意不 include ioboard.h(其引脚宏会牵入 main.h), 两处路数常量由测试的编译期静态断言钉住。 - default_task.c 的 default_task_di_poll():读失败不喂去抖、 不写发布值,只把上一有效值加 valid=0 发布出去, 避免"全 0"被现场读成开入全部复归。 - 去抖实际粒度 50ms(每个轮询周期喂一拍),最坏上报约 100ms; 想要真 20ms 需另建定时器,本次不做。 - Src/main.c 在 app_main_init 之前调 ioboard_init(), 上电即把 4 路出口钉在全释放并确认 165 静止态。 测试: - test/host/ioboard/ 100 条断言。位序主判据为单比特两端 (只有 A 得 0x01、只有 H 得 0x80)加八点双射穷举; 混合图样降级为辅助,因该图样曾先后被算成 0xA5、0x5A、0xAA。 - 去抖覆盖 20ms 边界、抖动不翻、跨 49.7 天回绕。 - 失败语义覆盖"失败保留上次有效值"与"失败窗口内的真实变位不丢"。 文档: - 新增 docs/硬件平台/开入开出实施说明.md。 - 硬件规格与能力边界 §5 的能力边界现状改写:出口继电器与 开入回路已具备、业务层未接入;4 路开出只可台架验证, 不得用于真实跳闸。 - 修正 docs/文档规范.md §3.1:原文要求所有互链用仓库根相对, 与 check_doc_links.py 的实际解析基准矛盾(markdown 链接按 当前文档目录解析,反引号路径才按仓库根)。改为区分两类, 并补 §3.1b 写明对应校验器。 - 清理 docs/任务规划/登记簿.md 改名为硬件改版登记.md 后 遗留的 9 处旧名引用。 门禁: keil-build 0 Error 0 Warning;主机侧单测 ioboard 100/100、 sb_proto 45/45;pre-commit 48 根钩子全通过。
209 lines
6.1 KiB
C
209 lines
6.1 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : main.h
|
|
* @brief : Header for main.c file.
|
|
* This file contains the common defines of the application.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2026 STMicroelectronics.
|
|
* All rights reserved.
|
|
*
|
|
* This software is licensed under terms that can be found in the LICENSE file
|
|
* in the root directory of this software component.
|
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef __MAIN_H
|
|
#define __MAIN_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "stm32f4xx_hal.h"
|
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN ET */
|
|
|
|
/* USER CODE END ET */
|
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
/* USER CODE BEGIN EC */
|
|
|
|
/* USER CODE END EC */
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN EM */
|
|
|
|
/* USER CODE END EM */
|
|
|
|
/* Exported functions prototypes ---------------------------------------------*/
|
|
void Error_Handler(void);
|
|
|
|
/* USER CODE BEGIN EFP */
|
|
|
|
/* USER CODE END EFP */
|
|
|
|
/* Private defines -----------------------------------------------------------*/
|
|
#define IN_D4_Pin GPIO_PIN_2
|
|
#define IN_D4_GPIO_Port GPIOE
|
|
#define HC165_IN2_Pin GPIO_PIN_3
|
|
#define HC165_IN2_GPIO_Port GPIOE
|
|
#define IN_E4_Pin GPIO_PIN_4
|
|
#define IN_E4_GPIO_Port GPIOE
|
|
#define CH395_INT_Pin GPIO_PIN_5
|
|
#define CH395_INT_GPIO_Port GPIOE
|
|
#define KO6_Pin GPIO_PIN_14
|
|
#define KO6_GPIO_Port GPIOC
|
|
#define TRIP_LED_Pin GPIO_PIN_0
|
|
#define TRIP_LED_GPIO_Port GPIOF
|
|
#define ERT_LED_Pin GPIO_PIN_1
|
|
#define ERT_LED_GPIO_Port GPIOF
|
|
#define CLZ_LED_Pin GPIO_PIN_6
|
|
#define CLZ_LED_GPIO_Port GPIOF
|
|
#define HC165_LD_Pin GPIO_PIN_2
|
|
#define HC165_LD_GPIO_Port GPIOC
|
|
#define HC165_CLK_Pin GPIO_PIN_3
|
|
#define HC165_CLK_GPIO_Port GPIOC
|
|
#define ADC9_RES_Pin GPIO_PIN_0
|
|
#define ADC9_RES_GPIO_Port GPIOA
|
|
#define ADC10_IC_Pin GPIO_PIN_1
|
|
#define ADC10_IC_GPIO_Port GPIOA
|
|
#define ADC11_IN_Pin GPIO_PIN_2
|
|
#define ADC11_IN_GPIO_Port GPIOA
|
|
#define ADC12_UC_Pin GPIO_PIN_3
|
|
#define ADC12_UC_GPIO_Port GPIOA
|
|
#define ADC13_RES_Pin GPIO_PIN_4
|
|
#define ADC13_RES_GPIO_Port GPIOA
|
|
#define ADC14_TEMP_Pin GPIO_PIN_5
|
|
#define ADC14_TEMP_GPIO_Port GPIOA
|
|
#define ADC15_IB_Pin GPIO_PIN_6
|
|
#define ADC15_IB_GPIO_Port GPIOA
|
|
#define ADC16_RES_Pin GPIO_PIN_7
|
|
#define ADC16_RES_GPIO_Port GPIOA
|
|
#define ADC17_UB_Pin GPIO_PIN_4
|
|
#define ADC17_UB_GPIO_Port GPIOC
|
|
#define LED1_Pin GPIO_PIN_5
|
|
#define LED1_GPIO_Port GPIOC
|
|
#define LED2_Pin GPIO_PIN_0
|
|
#define LED2_GPIO_Port GPIOB
|
|
#define LED3_Pin GPIO_PIN_1
|
|
#define LED3_GPIO_Port GPIOB
|
|
#define LED4_Pin GPIO_PIN_2
|
|
#define LED4_GPIO_Port GPIOB
|
|
#define LED5_Pin GPIO_PIN_11
|
|
#define LED5_GPIO_Port GPIOF
|
|
#define LED6_Pin GPIO_PIN_12
|
|
#define LED6_GPIO_Port GPIOF
|
|
#define DB0_Pin GPIO_PIN_0
|
|
#define DB0_GPIO_Port GPIOG
|
|
#define DB1_Pin GPIO_PIN_1
|
|
#define DB1_GPIO_Port GPIOG
|
|
#define ST_TX2_Pin GPIO_PIN_10
|
|
#define ST_TX2_GPIO_Port GPIOB
|
|
#define ST_RX2_Pin GPIO_PIN_11
|
|
#define ST_RX2_GPIO_Port GPIOB
|
|
#define CH395_SCS_Pin GPIO_PIN_12
|
|
#define CH395_SCS_GPIO_Port GPIOB
|
|
#define CH395F_SCK_Pin GPIO_PIN_13
|
|
#define CH395F_SCK_GPIO_Port GPIOB
|
|
#define CH395F_SDO_Pin GPIO_PIN_14
|
|
#define CH395F_SDO_GPIO_Port GPIOB
|
|
#define CH395F_SDOB15_Pin GPIO_PIN_15
|
|
#define CH395F_SDOB15_GPIO_Port GPIOB
|
|
#define DB2_Pin GPIO_PIN_2
|
|
#define DB2_GPIO_Port GPIOG
|
|
#define DB3_Pin GPIO_PIN_3
|
|
#define DB3_GPIO_Port GPIOG
|
|
#define DB4_Pin GPIO_PIN_4
|
|
#define DB4_GPIO_Port GPIOG
|
|
#define DB5_Pin GPIO_PIN_5
|
|
#define DB5_GPIO_Port GPIOG
|
|
#define DB6_Pin GPIO_PIN_6
|
|
#define DB6_GPIO_Port GPIOG
|
|
#define DB7_Pin GPIO_PIN_7
|
|
#define DB7_GPIO_Port GPIOG
|
|
#define DB8_Pin GPIO_PIN_8
|
|
#define DB8_GPIO_Port GPIOG
|
|
#define TP_FRSTDATA_Pin GPIO_PIN_6
|
|
#define TP_FRSTDATA_GPIO_Port GPIOC
|
|
#define TP_BUSY_Pin GPIO_PIN_7
|
|
#define TP_BUSY_GPIO_Port GPIOC
|
|
#define TP_BUSY_EXTI_IRQn EXTI9_5_IRQn
|
|
#define TP_RD_Pin GPIO_PIN_8
|
|
#define TP_RD_GPIO_Port GPIOC
|
|
#define TP_CONVST_Pin GPIO_PIN_9
|
|
#define TP_CONVST_GPIO_Port GPIOC
|
|
#define TP_OS2_Pin GPIO_PIN_8
|
|
#define TP_OS2_GPIO_Port GPIOA
|
|
#define TP_OS1_Pin GPIO_PIN_11
|
|
#define TP_OS1_GPIO_Port GPIOA
|
|
#define TP_OS0_Pin GPIO_PIN_12
|
|
#define TP_OS0_GPIO_Port GPIOA
|
|
#define ST_DIR4_Pin GPIO_PIN_15
|
|
#define ST_DIR4_GPIO_Port GPIOA
|
|
#define ST_TX4_Pin GPIO_PIN_10
|
|
#define ST_TX4_GPIO_Port GPIOC
|
|
#define ST_RX4_Pin GPIO_PIN_11
|
|
#define ST_RX4_GPIO_Port GPIOC
|
|
#define ST_TX1_Pin GPIO_PIN_12
|
|
#define ST_TX1_GPIO_Port GPIOC
|
|
#define ST_RX1_Pin GPIO_PIN_2
|
|
#define ST_RX1_GPIO_Port GPIOD
|
|
#define ST_TX3_Pin GPIO_PIN_5
|
|
#define ST_TX3_GPIO_Port GPIOD
|
|
#define ST_RX3_Pin GPIO_PIN_6
|
|
#define ST_RX3_GPIO_Port GPIOD
|
|
#define DB9_Pin GPIO_PIN_9
|
|
#define DB9_GPIO_Port GPIOG
|
|
#define DB10_Pin GPIO_PIN_10
|
|
#define DB10_GPIO_Port GPIOG
|
|
#define DB11_Pin GPIO_PIN_11
|
|
#define DB11_GPIO_Port GPIOG
|
|
#define DB12_Pin GPIO_PIN_12
|
|
#define DB12_GPIO_Port GPIOG
|
|
#define DB13_Pin GPIO_PIN_13
|
|
#define DB13_GPIO_Port GPIOG
|
|
#define DB14_Pin GPIO_PIN_14
|
|
#define DB14_GPIO_Port GPIOG
|
|
#define DB15_Pin GPIO_PIN_15
|
|
#define DB15_GPIO_Port GPIOG
|
|
#define GD_SCLK_Pin GPIO_PIN_3
|
|
#define GD_SCLK_GPIO_Port GPIOB
|
|
#define GD_SO_Pin GPIO_PIN_4
|
|
#define GD_SO_GPIO_Port GPIOB
|
|
#define GD_SI_Pin GPIO_PIN_5
|
|
#define GD_SI_GPIO_Port GPIOB
|
|
#define SD_SCL_Pin GPIO_PIN_6
|
|
#define SD_SCL_GPIO_Port GPIOB
|
|
#define SD_SDA_Pin GPIO_PIN_7
|
|
#define SD_SDA_GPIO_Port GPIOB
|
|
#define GD_WP_Pin GPIO_PIN_8
|
|
#define GD_WP_GPIO_Port GPIOB
|
|
#define GD_CS_Pin GPIO_PIN_0
|
|
#define GD_CS_GPIO_Port GPIOE
|
|
#define GD_HOLD_Pin GPIO_PIN_1
|
|
#define GD_HOLD_GPIO_Port GPIOE
|
|
|
|
/* USER CODE BEGIN Private defines */
|
|
|
|
/* USER CODE END Private defines */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __MAIN_H */
|