forked from ccsens_hardware/ttss_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.
311 lines
11 KiB
311 lines
11 KiB
////////////////////////////////////////////////////////////////////////////
|
|
///@copyright Copyright (c) 2017, 传控科技 All rights reserved.
|
|
///-------------------------------------------------------------------------
|
|
/// @file hard_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
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
#ifndef _BSP_CONFIG_H
|
|
#define _BSP_CONFIG_H
|
|
|
|
#include <INTRINS.H>
|
|
#include "../clib/type.h"
|
|
#include "../clib/bit.h"
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>.BORAD TYPE
|
|
#define TYPE_BOARD_hhnew 1
|
|
#define TYPE_BOARD_st_sleep04_01 4
|
|
#define TYPE_BOARD_st_sleep03 5
|
|
#define TYPE_BOARD_SMMM_MB_VH032_0E 6
|
|
#define TYPE_BOARD_LPC17xx_ 8
|
|
#define TYPE_BOARD_STM32F_103ZET6_READBULL 1036
|
|
#define TYPE_BOARD_hh_CC_MD_VH05_anyriny_simple_m51 0x0551
|
|
#define TYPE_BOARD_hh_CC_MD_VH06_asMain_m6a7 0x6a7
|
|
#define TYPE_BOARD_TI26_MT01_M178 0x178 //会议计时器版v TI26_MT01-M178
|
|
#define TYPE_BOARD_stc5as32_WIFIBV01 532
|
|
#define TYPE_BOARD_SHC16LAXXQN32 1632 //SHC16LAXXQN32
|
|
#define TYPE_BOARD_PAPER6133_M0A6 0xa6 //打印机纸张传感
|
|
#define TYPE_BOARD_GSM_MAIN_V07 0xa7 //打印机运维板
|
|
#define TYPE_BOARD_ADDA_MAIN_V02 0xa8 //ADDA
|
|
#define TYPE_BOARD_433_0A 0xa9 //433
|
|
#define TYPE_BOARD_WEIGH_0B 0xaa //称重
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<.BORAD TYPE end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>MCU TYPE
|
|
#define TYPE_MCU_STC_8A 51
|
|
#define TYPE_MCU_STC_8F 52
|
|
#define TYPE_MCU_STC_8G 53
|
|
#define TYPE_MCU_SHC6601 66
|
|
#define TYPE_MCU_LPC17xx 3217
|
|
#define TYPE_MCU_STM32 3232
|
|
|
|
#define D_CPUfamily_8bits 8
|
|
#define D_CPUfamily_16bits 16
|
|
#define D_CPUfamily_32bits 32
|
|
//<<<<<<<<<<<<<<<<<<<<<<mcu TYPE end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>IDE TYPE
|
|
#define TYPE_IDE_KEIL 1
|
|
#define TYPE_IDE_MDK 2
|
|
#define TYPE_IDE_IAR 3
|
|
//<<<<<<<<<<<<<<<<<<<<<<IDE TYPE end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>.SysTimer TYPE
|
|
#define TYPE_JIFFIES_5MS 1
|
|
#define TYPE_JIFFIES_10MS 2
|
|
#define TYPE_JIFFIES_25MS 3
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<.SysTimer TYPE end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>.WDT TYPE
|
|
#define TYPE_WDT_DISABLE 1
|
|
#define TYPE_WDT_ENABLE 2
|
|
#define WDT_FEED() WDT_CONTR |= 0x10
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<.SysTimer TYPE end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>.ByteOrder TYPE
|
|
#define TYPE_MCU_BIGENDIAN 1
|
|
#define TYPE_MCU_LITENDIAN 2
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<.ByteOrder TYPE end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>BUADRATE & StopBit
|
|
#define SBIT_1 1 //1 stop bit
|
|
#define SBIT_2 2 //2 stop bit
|
|
#define BRT_115200 115200
|
|
#define BRT_19200 19200
|
|
#define BRT_9600 9600
|
|
#define BRT_4800 4800
|
|
//<<<<<<<<<<<<<<<<<<<<<<BUADRATE & StopBit end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>MainFre
|
|
#define MainFre_5M 5529600L
|
|
#define MainFre_11M 11059200L
|
|
#define MainFre_22M 22118400L
|
|
#define MainFre_24M 24000000L
|
|
#define MainFre_27M 27000000L
|
|
//<<<<<<<<<<<<<<<<<<<<<<MainFre end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>UART0 PIN
|
|
#define PIN_UART0_Rxd_30_Txd_31 1
|
|
#define PIN_UART0_Rxd_36_Txd_37 2
|
|
#define PIN_UART0_Rxd_16_Txd_17 3
|
|
#define PIN_UART0_Rxd_43_Txd_44 4
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<.UART0 PIN
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>485 Type
|
|
#define TYPE_485_NONE 0
|
|
#define TYPE_485_MASTER 1
|
|
#define TYPE_485_SLAVER 2
|
|
//<<<<<<<<<<<<<<<<<<<<<<485 Type end
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>G-SENSOR TYPE
|
|
#define TYPE_ASENSOR_ADXL362 362
|
|
#define TYPE_ASENSOR_MSA300 300
|
|
#define TYPE_ASENSOR TYPE_ASENSOR_MSA300
|
|
//<<<<<<<<<<<<<<<<<<<<<<G-SENSOR TYPE end
|
|
|
|
//STEP 1 TYPE_UASER_BOARD SELECT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
#define TYPE_UASER_BOARD TYPE_BOARD_WEIGH_0B
|
|
|
|
//STEP 2 TYPE_UASER_BOARD CONFIG >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
#if(TYPE_UASER_BOARD == TYPE_BOARD_WEIGH_0B)
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <intrins.h>
|
|
#include "../cpu/stc_stc8f.h"
|
|
#include "../cpu/stc_macro.h"
|
|
|
|
//基本配置(工作频率、时钟、看门狗、字节序)
|
|
#define TYPE_MCU TYPE_MCU_STC_8F
|
|
#define TYPE_IDE TYPE_IDE_KEIL
|
|
#define D_CPUfamily_type D_CPUfamily_8bits
|
|
#define D_sys_MainFre MainFre_11M
|
|
#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_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_uart3_BRT BRT_115200
|
|
#define D_uart4_BRT BRT_115200
|
|
|
|
//485配置
|
|
#define D_UART0_485_TYPE TYPE_485_SLAVER //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 LED0 P10 //D4
|
|
#define LED1 P35 //D4
|
|
|
|
//EEP存储地址定义
|
|
#define D_EEP_SECTOR_SIZE 0x200
|
|
#define D_EEP_PARAM_ADDR (D_EEP_SECTOR_SIZE * 0) //eeprom参数区扇区地址
|
|
|
|
#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)
|
|
|
|
#elif(TYPE_UASER_BOARD == TYPE_BOARD_433_0A)
|
|
xxx
|
|
#endif
|
|
|
|
|
|
//STEP 3 Register CONFIG >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
|
#if 0
|
|
序号 量程 系数
|
|
1 100kg 100%
|
|
2 200kg 100%
|
|
3 300kg 100%
|
|
4 400kg 100%
|
|
5 500kg 100%
|
|
6 600kg 100%
|
|
7 700kg 100%
|
|
8 800kg 100%
|
|
9 900kg 100%
|
|
10 1000kg 100%
|
|
#endif
|
|
|
|
#define ADC_status_chx_Ready_BASE 0x01
|
|
#define ADC_status_ch1_Ready 0x01
|
|
#define ADC_status_ch2_Ready 0x02
|
|
#define ADC_status_ch3_Ready 0x04
|
|
#define ADC_status_ch4_Ready 0x08
|
|
|
|
#define D_weight_show_limit_num 5
|
|
#define D_weight_std_num 10
|
|
typedef struct global_register
|
|
{
|
|
//RO Register
|
|
S16 reserved1;
|
|
S32 total_weight; //净重(显示重量)*100
|
|
S32 total_zweight; //皮重*100
|
|
//RW Register
|
|
S16 reserved2;
|
|
struct { //需要持久化的参数,不能超过72字节,否则会导致eeprom溢出
|
|
U16 reset; //reset标志,写入任何值,所有参数恢复初始值
|
|
U16 adc_ch_status;
|
|
S16 slaver_id;
|
|
S16 zero; //清0标志,写入任何值清0(去皮)
|
|
S16 weight_max; //量程
|
|
S16 lmd; //2mv/v
|
|
S16 cc_blur_ch_avg; //均值滤波点数
|
|
S16 cc_blur_ch_shift; //移位滤波点数
|
|
S16 cc_blur_all_shift0; //和值移位滤波点数1
|
|
S16 cc_blur_all_shift1; //和值移位滤波点数2
|
|
S16 cc_blur_all_out_d_threshold; //移位阈值1
|
|
S16 cc_blur_all_out_dd_threshold;//移位阈值2
|
|
struct{
|
|
S16 weight;
|
|
S16 times;
|
|
} weight_show_limit[D_weight_show_limit_num];
|
|
struct {
|
|
S16 weight_range; //量程 x 100
|
|
S16 ratio; //重量计算系数,默认100,保留两位小数,相当于x1
|
|
} weight_std[D_weight_std_num];
|
|
U16 baud_rate; //波特率
|
|
U16 stop_bits; //停止位
|
|
}p;
|
|
S16 reserved3;
|
|
}GlobalRegister;
|
|
|
|
//寄存器内存基地址
|
|
#define REG_MEM_BASE ((U16*)(&R)) //寄存器基础地址(本文件外部不应该使用该宏定义)
|
|
//变量地址转寄存器
|
|
#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE) + 1)
|
|
//寄存器转变量地址
|
|
#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg) - 1))
|
|
|
|
extern GlobalRegister R;
|
|
|
|
//Step4: IRQ Config
|
|
#if (TYPE_MCU == TYPE_MCU_STC_8A || TYPE_MCU == TYPE_MCU_STC_8F)
|
|
#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
|
|
|
|
//======================================================== 以下为协议配置 ====================================================
|
|
#define D_CMD_Filter1_ff 0xFF
|
|
#define D_CMD_Filter2_fe 0xFE
|
|
#define D_HETU_FX_fi 0xF0
|
|
#define D_HETU_FX_MASK 0x0F
|
|
#define D_tp_handle_x_len 64
|
|
|
|
extern void L0_board_config(void);
|
|
extern void L0_reg_init(void);
|
|
|
|
#endif//_BSP_CONFIG_H
|
|
/*********************************end file*********************************************/
|
|
|
|
|
|
|
|
|
|
|