sop板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
11 KiB

4 years ago
////////////////////////////////////////////////////////////////////////////
///@copyright Copyright (c) 2017, 传控科技 All rights reserved.
///-------------------------------------------------------------------------
/// @file bsp_config.h
4 years ago
/// @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 5.1
/// @author CC
4 years ago
/// @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
//////////////////////////////////////////////////////////////////////////
4 years ago
#ifndef _BSP_CONFIG_H
#define _BSP_CONFIG_H
1 year ago
#include <intrins.h>
#include "../bsp/bsp_config_const.h"
4 years ago
#include "../clib/type.h"
#include "../clib/bit.h"
//STEP 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD SELECT
1 year ago
#define TYPE_UASER_BOARD TYPE_BOARD_BFY_V4_SOP
//STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<YPE_UASER_BOARD SELECT End
4 years ago
//STEP 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TYPE_UASER_BOARD CONFIG
1 year ago
#if(TYPE_UASER_BOARD == TYPE_BOARD_BFY_V4_SOP)
#include "../cpu/stc_stc8h.h"
4 years ago
#include "../cpu/stc_macro.h"
//基本配置(工作频率、时钟、看门狗、字节序)
#define TYPE_MCU TYPE_MCU_STC_8H
4 years ago
#define TYPE_IDE TYPE_IDE_KEIL
#define D_CPUfamily_type D_CPUfamily_8bits
#define D_sys_MainFre MainFre_22M
4 years ago
#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
1 year ago
#define D_CODE_ENCRYPTION_TYPE TYPE_ENCRYPTION_DISABLE //是否代码加密
#define D_MCU_NAME "STC8H8K64U"
//存储器特殊参数地址配置
1 year ago
#define MSP_ID_LEN 7
#define D_MCU_SPEC_PARAM_ID_IN_RAM 0x00F1
#define D_MCU_SPEC_PARAM_ID_IN_ROM 0xFDF9
#define D_MCU_SPEC_PARAM_ID_IN_CHIPID 0xFDE0
#define ID_ADDR_IN_RAM ((char idata*)(D_MCU_SPEC_PARAM_ID_IN_RAM + 0x00))
#define ID_ADDR_IN_ROM ((char code*)(D_MCU_SPEC_PARAM_ID_IN_ROM + 0x00))
#define ID_ADDR_IN_CHIPID ((unsigned char volatile xdata*)(D_MCU_SPEC_PARAM_ID_IN_CHIPID + 0x00))
//...其他参数
4 years ago
//串口配置
#define D_uart0_BRT BRT_115200
#define D_uart0_SBIT SBIT_1
1 year ago
#define D_PIN_UART0 PIN_UART0_Rxd_30_Txd_31 //RXD, TXD
4 years ago
#define D_uart2_BRT BRT_115200
1 year ago
#define D_PIN_UART2 PIN_UART2_Rxd_46_Txd_47 //RXD2_2, TXD2_2
4 years ago
#define D_uart3_BRT BRT_115200
1 year ago
#define D_PIN_UART3 PIN_UART3_Rxd_50_Txd_51 //RXD3_2, TXD3_2
4 years ago
#define D_uart4_BRT BRT_115200
1 year ago
#define D_PIN_UART4 PIN_UART4_Rxd_02_Txd_03 //RXD4, TXD4
4 years ago
//485配置
1 year ago
#define D_UART4_485_TYPE TYPE_485_SLAVER //UART4启用485
#define D_UART4_485_SLAVER_ID_BROADCAST 0xFF //485从机总是响应0xFF消息
#define D_UART4_485_SLAVER_ID 0x01 //板卡作为485从机 slaverId
#define D_UART4_485_TX() P01 = 1; P00=1;
#define D_UART4_485_RX() P01 = 0; P00=0;
#define D_UART0_485_TYPE TYPE_485_NONE //UART0不启用485
4 years ago
#define D_UART2_485_TYPE TYPE_485_NONE //UART2不启用485
1 year ago
#define D_UART3_485_TYPE TYPE_485_NONE //UART3不启用485
4 years ago
//MODBUS协议配置
1 year ago
//#define D_MODBUS_ENABLE //MODBS启用开关,如果不使用modbus,可以注释掉本行
4 years ago
#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 LED0_ON 1
#define LED0_OFF 0
1 year ago
#define LED0 P23 //LED5
1 year ago
//Button LED
#define BLED0_ON 0
#define BLED0_OFF 1
1 year ago
//0 1 2 3 4 5 6
//13 12 11 10 9 8 7
#define BLED0 P42 //NET9
#define BLED1 P41 //NET10
#define BLED2 P37 //NET11
#define BLED3 P35 //NET12
#define BLED4 P16 //NET13
#define BLED5 P15 //NET14
#define BLED6 P14 //NET15
#define BLED7 P47 //NET16
#define BLED8 P11 //NET17
#define BLED9 P26 //NET18
#define BLED10 P25 //NET19
#define BLED11 P21 //NET20
#define BLED12 P44 //NET21
#define BLED13 P22 //NET22
//K->Key, R->ROW, C->COL
#define KR1 P36 //NET1
#define KR2 P17 //NET2
#define KR3 P06 //NET3
#define KR4 P43 //NET4
#define KC1 P10 //NET5
#define KC2 P07 //NET6
#define KC3 P13 //NET7
#define KC4 P20 //NET8
//RFID EN -- 暂未定义
#define RFID_ENABLE 1
#define RFID_DISABLE 0
#define RFID_EN_PIN P32 //RFID-EN >1.1v使能
4 years ago
//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
4 years ago
xxx
#endif
//STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<TYPE_UASER_BOARD CONFIG End
4 years ago
//Step3: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>IRQ Config
#if ((TYPE_MCU & TYPE_MCU_VENDOR_MSK) == TYPE_MCU_VENDOR_STC)
4 years ago
#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
1 year ago
// #define D_SERVE_PWM interrupt 22
// #define D_SERVE_PWMFD interrupt 23
4 years ago
#define D_SERVE_I2C interrupt 24
#endif
//STEP 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<IRQ Config End
4 years ago
//STEP 4 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Cdelay CONFIG End
//STEP 5 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Uart CONFIG
1 year ago
#define SERIAL_MAX_NUM 4
////fixme:和cpu的程序容量息息相关
#define D_UART_send_buf_max 16 /// 9600bps = 10000bps = 1000 Bps = 1Byte/ms
/// 19200bps = 20000bps = 2000Bps = 2Byte/ms = 1Byte/0.5ms
/// 128Bytes = 128*0.5ms = 64ms
1 year ago
#define D_UART_send_buf2_max 8 //此处改动会影响L0_uartN_ulhex函数
//STEP 5 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Uart CONFIG End
//STEP 6 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Transmission Protocol Config
#define D_TPC_CCMODBUS_Filter0 0xFF
#define D_TPC_CCMODBUS_Filter1 0xFE
#define D_TPC_DEBUG_FX_fi 0xF0
#define D_TPC_DEBUG_FX_MASK 0x0F
#define D_TPC_HANDLER_X_LEN 32
//STEP 6 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Transmission Protocol Config End
extern void L0_board_config(void);
#endif//_BSP_CONFIG_H
/*********************************end file*********************************************/
4 years ago