//////////////////////////////////////////////////////////////////////////// ///@copyright Copyright (c) 2017, 传控科技 All rights reserved. ///------------------------------------------------------------------------- /// @file bsp_config.h /// @brief hard config include /// @info FILE FOR HARDWARE SETUP AND SOFTWARE SETUP///FOR EXAMPLE: BAORD ,MCU,IDE /// @info YOU CAN CHANGE OR ADD THE DEFINE IF YOU NEED /// @info 整个嵌入式项目的入口 首先是确认电路板 然后确认cpu 芯片型号 然后确认编译器 之后是软件框架 最后是应用程序 /// @info bsp_CONFIG 为其他头文件的始祖 TYPE_BOARD_xx ///------------------------------------------------------------------------- /// @version 1.1 /// @author CC /// @date 20180308 /// @note ////////////////////////////////////////////////////////////////////////////// /// @version 5.1 /// @author CC /// @date 20200301 /// @note ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ///存储器中的特殊参数 ///全球唯一ID号 7FF9H~7FFFH BFF9H~BFFFH EFF9H~EFFFH FDF9H~FDFFH 7字节 ///内部1.19V参考信号源 7FF7H~7FF8H BFF7H~BFF8H EFF7H~EFF8H FDF7H~FDF8H 毫伏(高字节在前) ///32K掉电唤醒定时器的频率 7FF5H~7FF6H BFF5H~BFF6H EFF5H~EFF6H FDF5H~FDF6H Hz (高字节在前) ///22.1184MHz的IRC参数(20M频段) 7FF4H BFF4H EFF4H FDF4H - ///24MHz的IRC参数(20M频段) 7FF3H BFF3H EFF3H FDF3H - ///20MHz的IRC参数(20M频段) 7FF2H BFF2H EFF2H FDF2H ///固件版本为7.3.12U ///以及后续版本有效 ///27MHz的IRC参数(35M频段) 7FF1H BFF1H EFF1H FDF1H ///30MHz的IRC参数(35M频段) 7FF0H BFF0H EFF0H FDF0H ///33.1776MHz的IRC参数(35M频段) 7FEFH BFEFH EFEFH FDEFH ///35MHz的IRC参数(35M频段) 7FEEH BFEEH EFEEH FDEEH ///36.864MHz的IRC参数(35M频段) 7FEDH BFEDH EFEDH FDEDH ///保留 7FECH BFECH EFECH FDECH ///保留 7FEBH BFEBH EFEBH FDEBH ///20M频段的VRTRIM参数 7FEAH BFEAH EFEAH FDEAH ///35M频段的VRTRIM参数 7FE9H BFE9H EFE9H FDE9H ////////////////////////////////////////////////////////////////////////// #ifndef _BSP_CONFIG_H #define _BSP_CONFIG_H #include #include "../bsp/bsp_config_const.h" #include "../clib/type.h" #include "../clib/bit.h" //STEP 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD SELECT #define TYPE_UASER_BOARD TYPE_BOARD_TOUCH_PEN_0B //STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD CONFIG #if(TYPE_UASER_BOARD == TYPE_BOARD_TOUCH_PEN_0B) #include #include "../cpu/stc_stc8hxx.h" #include "../cpu/stc_macro.h" //基本配置(工作频率、时钟、看门狗、字节序) #define TYPE_MCU TYPE_MCU_STC_8H #define TYPE_IDE TYPE_IDE_KEIL #define D_CPUfamily_type D_CPUfamily_8bits #define D_sys_MainFre MainFre_22M #define D_sys_Jiffies TYPE_JIFFIES_10MS #define D_WDT_STATUS TYPE_WDT_DISABLE //如果配置为enable,请在bsp_config.c中设置wdt溢出时间 #define D_MCU_ENDIAN TYPE_MCU_BIGENDIAN #define D_CODE_ENCRYPTION_TYPE TYPE_ENCRYPTION_ENABLE //是否代码加密 #define D_MCU_NAME "STC8H3K64S4" //存储器特殊参数地址配置 #define D_MCU_SPEC_PARAM_CHIPID 0xBFF9 //...其他参数 //串口配置 #define D_uart0_BRT BRT_115200 #define D_uart0_SBIT SBIT_1 #define D_PIN_UART0 PIN_UART0_Rxd_30_Txd_31 #define D_uart2_BRT BRT_115200 #define D_uart2_SBIT SBIT_1 #define D_PIN_UART2 PIN_UART2_Rxd_10_Txd_11 //wifi模块 #define D_uart3_BRT BRT_115200 #define D_PIN_UART3 PIN_UART3_Rxd_43_Txd_44 //声音模块 #define D_uart4_BRT BRT_115200 //485配置 #define D_UART0_485_TYPE TYPE_485_NONE //UART0启用485 #define D_UART0_485_SLAVER_ID_BROADCAST 0xFF //485从机总是响应0xFF消息 #define D_UART0_485_SLAVER_ID 0x01 //板卡作为485从机 slaverId #define D_UART0_485_TX() P32 = 1; #define D_UART0_485_RX() P32 = 0; #define D_UART2_485_TYPE TYPE_485_NONE //UART2不启用485 #define D_UART3_485_TYPE TYPE_485_NONE //UART2不启用485 #define D_UART4_485_TYPE TYPE_485_NONE //UART2不启用485 //MODBUS协议配置 #define D_MODBUS_ENABLE //MODBS启用开关,如果不使用modbus,可以注释掉本行 #define D_MODBUS_SPLIT_ENTRY L1_modbus_split //modbus切割函数,在tpc_modbus.c中实现,依据实际情况修改 #define D_MODBUS_REG_MAX_NUM 32 //每次最多读取/写入的寄存器数量,此处的数量要注意和 D_tp_handle_x_len 对应 //外设定义 #define LED1 P27 //D4 #define LED2 P26 //D4 #define LED3 P2 //D4 #define LED4 P55 //D4 //笔头 #define SCK P34 #define SDIO P50 //EEP存储地址定义 #define D_EEP_SECTOR_SIZE 0x200 //每个扇区0x200==512bytes #define D_EEP_SECTOR_BLOCK_SIZE 0x40 //扇区中每个数据块0x40==64bytes,可选值[32,64,128]等 #define D_EEP_SECTOR_BLOCK_NUM (D_EEP_SECTOR_SIZE / D_EEP_PARAM_BLOCK_SIZE) //每个扇区数据块的数量 #define D_EEP_BLOCK_FILTER0 0xAA //扇区中每个数据块的Filter字段值 #define D_EEP_BLOCK_FILTER1 0x55 //EEP User Defined 参数区存储配置 #define D_EEP_PARAM_IN_SECTOR 1 //eeprom参数区扇区地址,从0开始 #define D_EEP_PARAM_IN_BLOCK 0 //eeprom参数区数据块地址,从0开始 //#define D_EEP_PARAM_BLOCK_SIZE (D_EEP_SECTOR_BLOCK_SIZE) //参数区每个块大小,必须:D_EEP_PARAM_BLOCK_SIZE<=D_EEP_SECTOR_BLOCK_SIZE!!!,因为eeprom.h中是按照D_EEP_SECTOR_BLOCK_SIZE分配的buf //#define D_EEP_PARAM_BLOCK_NUM (D_EEP_SECTOR_SIZE / D_EEP_PARAM_BLOCK_SIZE) //每个扇区数据块的数量 //EEP 加密区存储配置 #if(D_CODE_ENCRYPTION_TYPE == TYPE_ENCRYPTION_ENABLE) #define D_EEP_ENC_IN_SECTOR 0 //eeprom加密区扇区地址,从0开始 #define D_EEP_ENC_IN_BLOCK 0 //eeprom加密区数据块地址,从0开始 //#define D_EEP_ENC_BLOCK_SIZE 0x20 //ENC_BLOCK_SIZE必须与加密程序中的ENC_BLOCK_SIZE匹配,此处不建议修改,如需修改,请同时修改加密程序 #endif #elif xxx #endif //STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>IRQ Config #if ((TYPE_MCU & TYPE_MCU_VENDOR_MSK) == TYPE_MCU_VENDOR_STC) #define D_SERVE_INT0 interrupt 0 #define D_SERVE_TIMER0 interrupt 1 #define D_SERVE_INT1 interrupt 2 #define D_SERVE_TIMER1 interrupt 3 #define D_SERVE_UART interrupt 4 #define D_SERVE_ADC interrupt 5 #define D_SERVE_LVD interrupt 6 #define D_SERVE_PCA interrupt 7 #define D_SERVE_UART2 interrupt 8 #define D_SERVE_SPI interrupt 9 #define D_SERVE_INT2 interrupt 10 #define D_SERVE_INT3 interrupt 11 #define D_SERVE_TIMER2 interrupt 12 #define D_SERVE_INT4 interrupt 16 #define D_SERVE_UART3 interrupt 17 #define D_SERVE_UART4 interrupt 18 #define D_SERVE_TIMER3 interrupt 19 #define D_SERVE_TIMER4 interrupt 20 #define D_SERVE_CMP interrupt 21 #define D_SERVE_PWM interrupt 22 #define D_SERVE_PWMFD interrupt 23 #define D_SERVE_I2C interrupt 24 #endif //STEP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Cdelay CONFIG #if(MainFre_5M == D_sys_MainFre) #define D_Cdelay_200us 20 #define D_Cdelay_1us 1 ////while p21翻转时测定 500k 2us 一个指令 #elif(MainFre_22M == D_sys_MainFre) #define D_Cdelay_200us 20 #define D_Cdelay_1us 1 ////while p21翻转时测定 500k 2us 一个指令 #define D_Cdelay_1us 1 ////while p21翻转时测定 500k 2us 一个指令 #define L0_delay_1us() Lc_delay_nop(0) // 5个nop() 100ns 50个nop() 1us (20)=10us (2)1.5us #define L0_delay_10us() Lc_delay_nop(4) // 5个nop() 100ns 50个nop() 1us (20)=10us (2)1.5us #define L0_delay_40us() Lc_delay_nop(18) // 5个nop() 100ns 50个nop() 1us (20)=10us (2)1.5us #elif(MainFre_27M == D_sys_MainFre) #define D_Cdelay_200us 20 #define D_Cdelay_1us 1 ////while p21翻转时测定 500k 2us 一个指令 #else ///MainFre_11M #define D_Cdelay_200us 20 #define D_Cdelay_1us 1 ////while p21翻转时测定 500k 2us 一个指令 #define L0_delay_1us() Lc_delay_nop(0) // 5个nop() 100ns 50个nop() 1us (20)=10us (2)1.5us #define L0_delay_10us() Lc_delay_nop(4) // 5个nop() 100ns 50个nop() 1us (20)=10us (2)1.5us #define L0_delay_40us() Lc_delay_nop(18) // 5个nop() 100ns 50个nop() 1us (20)=10us (2)1.5us //xx #endif//D_sys_MainFre) //STEP 4 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<