| 
									
										
										
										
											2023-10-06 18:47:05 +08:00
										 |  |  |  | #ifndef DEFINE_H_
 | 
					
						
							|  |  |  |  | #define DEFINE_H_
 | 
					
						
							|  |  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  |  | #include <string.h>
 | 
					
						
							|  |  |  |  | #include <rthw.h>
 | 
					
						
							|  |  |  |  | #include <rtthread.h>
 | 
					
						
							|  |  |  |  | #include "stm32f10x.h"
 | 
					
						
							|  |  |  |  | #include "misc.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_adc.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_dma.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_gpio.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_usart.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_rcc.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_tim.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_dac.h"
 | 
					
						
							|  |  |  |  | #include "stm32f10x_i2c.h"
 | 
					
						
							| 
									
										
										
										
											2023-10-27 18:47:02 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // 设置硬件版本
 | 
					
						
							|  |  |  |  | #define HARD_VERSION  2
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #if HARD_VERSION==1
 | 
					
						
							|  |  |  |  | // 电压倍数,旧板子21 新板子11
 | 
					
						
							|  |  |  |  | #define V_PARAM_1  21
 | 
					
						
							|  |  |  |  | // 参数2 旧板子143 新板子178
 | 
					
						
							|  |  |  |  | #define V_PARAM_2  143
 | 
					
						
							|  |  |  |  | // 电阻放大倍数 旧板子16 新板子79.7
 | 
					
						
							|  |  |  |  | #define RES_MULTIPLE  16
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #elif HARD_VERSION==2
 | 
					
						
							|  |  |  |  | // 电压倍数,旧板子21 新板子11
 | 
					
						
							|  |  |  |  | #define V_PARAM_1  11
 | 
					
						
							|  |  |  |  | // 参数2 旧板子143 新板子178
 | 
					
						
							|  |  |  |  | #define V_PARAM_2  178
 | 
					
						
							|  |  |  |  | // 电阻放大倍数 旧板子16 新板子79.7
 | 
					
						
							|  |  |  |  | #define RES_MULTIPLE  79.7
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-06 18:47:05 +08:00
										 |  |  |  | #define UNUSED(X) (void)X   
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #define SoftVersion 0x000D
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #if __IF_PORT_UART
 | 
					
						
							|  |  |  |  | //是否使用通信缓存
 | 
					
						
							|  |  |  |  | #define APP_COMM_USE_FIFO   0
 | 
					
						
							|  |  |  |  | //命令通信接口
 | 
					
						
							|  |  |  |  | #define APP_COMD_CAN       0
 | 
					
						
							|  |  |  |  | #define APP_COMD_USART     1
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #else
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | //是否使用通信缓存
 | 
					
						
							|  |  |  |  | #define APP_COMM_USE_FIFO   1
 | 
					
						
							|  |  |  |  | //命令通信接口
 | 
					
						
							|  |  |  |  | #define APP_COMD_CAN       1
 | 
					
						
							|  |  |  |  | #define APP_COMD_USART     1
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | typedef enum{ | 
					
						
							|  |  |  |  |         FUN_E     = ((uint8_t)0),//使能
 | 
					
						
							|  |  |  |  |         FUN_D     = ((uint8_t)1) //失能
 | 
					
						
							|  |  |  |  | }FUNState_e; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | typedef union{ | 
					
						
							|  |  |  |  | uint32_t ul_data; | 
					
						
							|  |  |  |  | uint16_t us_data; | 
					
						
							|  |  |  |  | uint8_t  uc_data; | 
					
						
							|  |  |  |  | uint16_t us_buf[2]; | 
					
						
							|  |  |  |  | uint8_t  uc_buf[4]; | 
					
						
							|  |  |  |  | }Seq_Buf_En; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-07 18:15:52 +08:00
										 |  |  |  | // 模块程序地址
 | 
					
						
							|  |  |  |  | // 这个地址要和 dev_flash.c 中定义的地址相对应
 | 
					
						
							|  |  |  |  | #define MC_CODE_ADDR \
 | 
					
						
							| 
									
										
										
										
											2023-10-09 18:12:00 +08:00
										 |  |  |  |   (FLASH_BASE+2048*109+128) | 
					
						
							| 
									
										
										
										
											2023-10-06 18:47:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-07 18:15:52 +08:00
										 |  |  |  | // 方案地址
 | 
					
						
							|  |  |  |  | // 这个地址要和 dev_flash.c 中定义的地址相对应
 | 
					
						
							|  |  |  |  | #define APP_TEST_PLAN_ADDR \
 | 
					
						
							| 
									
										
										
										
											2023-10-09 18:12:00 +08:00
										 |  |  |  |   (FLASH_BASE+2048*118+128) | 
					
						
							| 
									
										
										
										
											2023-10-06 18:47:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-07 18:15:52 +08:00
										 |  |  |  | // 方案大小
 | 
					
						
							| 
									
										
										
										
											2023-10-06 18:47:05 +08:00
										 |  |  |  | #define APP_TEST_PLANINFO_SIZE  2048
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | //系统事件定义
 | 
					
						
							|  |  |  |  | #define U1_RX_FRAME_EVENT     0x01 
 | 
					
						
							|  |  |  |  | #define UART_MC_FRAME_EVENT   0x02
 | 
					
						
							|  |  |  |  | #define CAN_MC_FRAME_EVENT  	0x04
 | 
					
						
							|  |  |  |  | #define TRANS_FRAME_EVENT 		0x08
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #define UART_TX_END_EVENT     1
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #define EP1_CMD_FRAME_EVENT   1
 | 
					
						
							|  |  |  |  | #define EPJ_CMD_FRAME_EVENT   1
 | 
					
						
							|  |  |  |  | #define EP2_CMD_FRAME_EVENT   1
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #define USART_APP_EXCE_EVENT  1
 | 
					
						
							|  |  |  |  | #define EP_HEARTBEAD_EVENT    5
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /******************总线电压倍率*****/ | 
					
						
							|  |  |  |  | #define VH_Mutli             21
 | 
					
						
							|  |  |  |  | #define VM_Mutli						 21
 | 
					
						
							|  |  |  |  | #define BOAED_SEQ_NUM_SIZE  20
 | 
					
						
							|  |  |  |  | extern struct rt_event usart1_rx_event; | 
					
						
							|  |  |  |  | #pragma pack(1)
 | 
					
						
							|  |  |  |  | typedef struct { | 
					
						
							|  |  |  |  | uint32_t bootflag; //更新标志
 | 
					
						
							|  |  |  |  | uint16_t resistor_diff;//
 | 
					
						
							|  |  |  |  | uint16_t hard_v; | 
					
						
							|  |  |  |  | uint32_t mc_ICodeCrc32; | 
					
						
							|  |  |  |  | uint8_t  sqNum[BOAED_SEQ_NUM_SIZE]; | 
					
						
							|  |  |  |  | }BoardInfo_st; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | typedef union{ | 
					
						
							|  |  |  |  | BoardInfo_st boardinfo; | 
					
						
							|  |  |  |  | uint32_t ul_buf[32]; | 
					
						
							|  |  |  |  | }BoardInfo_un; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | typedef struct { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	uint8_t app_run_flag; | 
					
						
							|  |  |  |  | 	uint8_t device_id; | 
					
						
							|  |  |  |  | 	uint16_t chip_temp; | 
					
						
							|  |  |  |  | 	uint16_t v2p5_adc; | 
					
						
							|  |  |  |  | 	uint16_t v1p25_adc; | 
					
						
							|  |  |  |  | 	uint16_t adc_shake; | 
					
						
							|  |  |  |  | 	uint16_t bus_5p5v; | 
					
						
							|  |  |  |  | 	uint16_t bus_26v; | 
					
						
							|  |  |  |  | 	uint16_t hard_v; | 
					
						
							|  |  |  |  | 	uint16_t soft_v; | 
					
						
							|  |  |  |  | 	uint16_t resistor_diff; | 
					
						
							|  |  |  |  | 	uint32_t plan_id; | 
					
						
							|  |  |  |  | 	 | 
					
						
							|  |  |  |  | }BoartCheck_st; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #pragma pack()
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-16 18:53:12 +08:00
										 |  |  |  | extern volatile BoartCheck_st board_st; | 
					
						
							|  |  |  |  | extern volatile BoardInfo_un  boardinfo_un; | 
					
						
							| 
									
										
										
										
											2023-10-06 18:47:05 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | //检测小板初始化
 | 
					
						
							|  |  |  |  | void Ye_BoardInit(void); | 
					
						
							|  |  |  |  | /*
 | 
					
						
							|  |  |  |  |  测试小板上电自检 | 
					
						
							|  |  |  |  | */ | 
					
						
							|  |  |  |  | void Ye_BoardCheck(void); | 
					
						
							|  |  |  |  | //
 | 
					
						
							|  |  |  |  | uint8_t UidCode_YM2JQ(uint8_t* pstJQUID, uint8_t* pstYMUID); | 
					
						
							|  |  |  |  |  uint32_t GetPasswordByUidCode(uint8_t* uidcode); | 
					
						
							|  |  |  |  | #endif
 |