forked from ccsens_hardware/stc_ttss_868
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.
119 lines
3.4 KiB
119 lines
3.4 KiB
#include "bsp_config.h"
|
|
#include "../tpc/tpc_modbus.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
|
///-------------------------------------------------------------------------
|
|
/// @file bsp_func.c
|
|
/// @brief bsp @ fuctiong ; io复用选择等,和cpu型号息息相关
|
|
///-------------------------------------------------------------------------
|
|
/// @version 1.0
|
|
/// @author CC
|
|
/// @date 20180308
|
|
/// @note cc_AS_stc02
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//struct _s_sysclk s_sysclk;
|
|
|
|
GlobalRegister R;
|
|
|
|
void L0_reg_reset()
|
|
{
|
|
U8 i = 0;
|
|
//R.p.reset = 0;
|
|
R.p.adc_ch_status = ADC_status_ch2_Ready | ADC_status_ch3_Ready | ADC_status_ch4_Ready; //修改采集通道
|
|
R.p.slaver_id = D_UART0_485_SLAVER_ID;
|
|
//R.p.zero = 0;
|
|
R.p.weight_max = 500; //500kg
|
|
R.p.lmd = 2; //2mv/v
|
|
|
|
R.p.cc_blur_ch_avg = 6;
|
|
R.p.cc_blur_ch_shift = 2;
|
|
R.p.cc_blur_all_shift0 = 2;
|
|
R.p.cc_blur_all_shift1 = 4;
|
|
R.p.cc_blur_all_out_d_threshold = 200; //0.2kg
|
|
R.p.cc_blur_all_out_dd_threshold = 200; //0.2kg
|
|
|
|
for(i=0;i<D_weight_show_limit_num;i++)
|
|
{
|
|
R.p.weight_show_limit[i].weight = 0;
|
|
R.p.weight_show_limit[i].times = 0;
|
|
}
|
|
R.p.weight_show_limit[0].weight = 300; //0.3kg
|
|
R.p.weight_show_limit[0].times = 1;
|
|
R.p.weight_show_limit[1].weight = 200; //0.2kg
|
|
R.p.weight_show_limit[1].times = 9;
|
|
R.p.weight_show_limit[2].weight = 100; //0.1kg
|
|
R.p.weight_show_limit[2].times = 18;
|
|
R.p.weight_show_limit[3].weight = 50; //0.05kg
|
|
R.p.weight_show_limit[3].times = 18;
|
|
R.p.weight_show_limit[4].weight = 20; //0.02kg
|
|
R.p.weight_show_limit[4].times = 30;
|
|
|
|
//for(i=0;i<D_weight_std_num;i++)
|
|
//{
|
|
// R.p.weight_std[i].weight_range = 0;
|
|
// R.p.weight_std[i].ratio = 0;
|
|
//}
|
|
|
|
R.p.baud_rate = 19200;
|
|
R.p.stop_bits = 1;
|
|
}
|
|
|
|
void L0_reg_init(void)
|
|
{
|
|
R.reserved1 = R.reserved2 = R.reserved3 = 0x55;
|
|
//R.total_weight = R.total_zweight = 0;
|
|
L0_reg_reset();
|
|
}
|
|
|
|
//==========================================================
|
|
//系统定时器回调
|
|
//初始化为NULL,timer0_isr中判断为NULL则不调用
|
|
//==========================================================
|
|
|
|
|
|
void L0_board_config(void)
|
|
{
|
|
#if (PIN_UART0_Rxd_30_Txd_31 == D_PIN_UART0)
|
|
BITN_0(P_SW1 ,BITN7);//
|
|
BITN_0(P_SW1 ,BITN6);// rxd p3.0 txd p3.1
|
|
#elif (PIN_UART0_Rxd_36_Txd_37 == D_PIN_UART0)
|
|
BITN_0(P_SW1 ,BITN7);//
|
|
BITN_1(P_SW1 ,BITN6);// rxd p3.6 txd p3.7
|
|
#elif (PIN_UART0_Rxd_16_Txd_17 == D_PIN_UART0)
|
|
BITN_1(P_SW1 ,BITN7);//
|
|
BITN_0(P_SW1 ,BITN6);// rxd p1.6 txd p1.7
|
|
#elif (PIN_UART0_Rxd_43_Txd_44 == D_PIN_UART0)
|
|
BITN_1(P_SW1 ,BITN7);//
|
|
BITN_1(P_SW1 ,BITN6);// rxd p4.3 txd p4.4
|
|
#else
|
|
BITN_0(P_SW1 ,BITN7);//
|
|
BITN_0(P_SW1 ,BITN6);// rxd p3.0 txd p3.1
|
|
#endif
|
|
|
|
//uart2
|
|
BITN_0(P_SW2 ,BITN0);// rxd2 p1.0 txd2 p1.1
|
|
//BITN_1(P_SW2 ,BITN0);// rxd2 p4.0 txd2 p4.2
|
|
|
|
//uart3
|
|
//P_SW2 = 0x02; // RXD3_2/P5.0, TXD3_2/P5.1
|
|
|
|
//uart4
|
|
//BITN_1(P_SW2 ,BITN2);// rxd4 p5.2 txd4 p5.3
|
|
//BITN_0(P_SW2 ,BITN2);// rxd4 p0.2 txd4 p0.3
|
|
|
|
//485 RE/DE 配置推完输出 P32
|
|
BITN_0(P3M1,BITN2);BITN_1(P3M0,BITN2);
|
|
|
|
#if (TYPE_WDT_ENABLE == D_WDT_STATUS)
|
|
WDT_CONTR = 0x27; //使能看门狗,22M时钟下溢出时间约为5s,请注意添加喂狗程序
|
|
#else
|
|
WDT_CONTR = 0x00;
|
|
#endif
|
|
|
|
//Lp0_Sys_timer_extern_handler被timer0中断调用
|
|
//Lp0_Sys_timer_extern_handler = L1_Sys_timer_extern_handler;
|
|
}
|
|
|
|
|
|
|