|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/// COPYRIGHT NOTICE
|
|
|
|
/// Copyright (c) 2023 CCSENS
|
|
|
|
/// All rights reserved.
|
|
|
|
///
|
|
|
|
/// @file main.c
|
|
|
|
/// @brief main app
|
|
|
|
///
|
|
|
|
|
|
|
|
/// 下面是一个含有两个参数的函数的注释说明(简述)
|
|
|
|
///
|
|
|
|
/// 这里写该函数的详述信息
|
|
|
|
/// @param a 被测试的变量(param描述参数)
|
|
|
|
/// @param s 指向描述测试信息的字符串
|
|
|
|
/// @return 测试结果(return描述返回值)
|
|
|
|
/// @see Test() (本函数参考其它的相关的函数,这里作一个链接)
|
|
|
|
/// @note (note描述需要注意的问题)
|
|
|
|
|
|
|
|
//===============================================
|
|
|
|
//寄存器头文件
|
|
|
|
//===============================================
|
|
|
|
|
|
|
|
/// 20221023_175541 CCmodify
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
#include "asp_lowpower.h"
|
|
|
|
|
|
|
|
|
|
|
|
void L0_RTC_init(void)
|
|
|
|
{
|
|
|
|
P_SW2 = 0x80;
|
|
|
|
// XOSCCR =0;
|
|
|
|
///HIRCCR = 0;
|
|
|
|
IRC32KCR = 0x80; //启动内部32K IRC
|
|
|
|
while (!(IRC32KCR & 1)); //等待时钟稳定
|
|
|
|
CLKDIV = 0x00; //时钟不分频
|
|
|
|
/// CLKSEL = 0x03; //选择内部32K
|
|
|
|
|
|
|
|
RTCCFG = 3;
|
|
|
|
///RTCCFG |= 0x02; //选择内部 32K 作为 RTC 时钟源 RTCCFG | = 0x02; / / Select internal 32K as RTC, clock source
|
|
|
|
RTCCR = 1;
|
|
|
|
printf3("\r\n %X %X:%X",(int)(DAY), (int)(MIN), (int)(SEC));
|
|
|
|
|
|
|
|
D_stdIO_P2(BITN4);D_P24_REV();
|
|
|
|
Lc_delay_ms(500);
|
|
|
|
|
|
|
|
printf3("\r\n %X %X:%X",(int)(DAY), (int)(MIN), (int)(SEC));
|
|
|
|
Lc_delay_ms(200);D_stdIO_P2(BITN4);D_P24_REV();
|
|
|
|
Lc_delay_ms(500);
|
|
|
|
printf3("\r\n %X %X:%X",(int)(DAY), (int)(MIN), (int)(SEC));
|
|
|
|
Lc_delay_ms(200);D_stdIO_P2(BITN4);D_P24_REV();
|
|
|
|
Lc_delay_ms(500);
|
|
|
|
printf3("\r\n %X %X:%X",(int)(DAY), (int)(MIN), (int)(SEC));
|
|
|
|
Lc_delay_ms(200);
|
|
|
|
}
|
|
|
|
|
|
|
|
void L0_main_initled(void)
|
|
|
|
{
|
|
|
|
D_LED1_OFF();
|
|
|
|
//D_LED2_ON();
|
|
|
|
|
|
|
|
L3_reg_init();
|
|
|
|
|
|
|
|
TTSS_run_times(6)
|
|
|
|
{
|
|
|
|
D_LED1_REV();
|
|
|
|
//D_LED2_REV();
|
|
|
|
Lc_delay_ms(300);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void L0_main_init(void)
|
|
|
|
{
|
|
|
|
// A5 5A 05 80 02 32 F0 9D 0.5s
|
|
|
|
// A5 5A 05 80 02 14 71 47 0.2s
|
|
|
|
SCRControlPkg scrBeepPowOnPkg = {
|
|
|
|
0xA5, 0x5A,
|
|
|
|
0x05, //长度
|
|
|
|
0x80, //指令
|
|
|
|
0x02, 0x14, //数据
|
|
|
|
0x71, 0x47, // CRC
|
|
|
|
};
|
|
|
|
|
|
|
|
int r = 0;
|
|
|
|
Lc_delay_ms(200);
|
|
|
|
L0_main_initled();
|
|
|
|
CLKDIV = 0;////不分频,使用focs
|
|
|
|
|
|
|
|
L0_uart1_open();
|
|
|
|
|
|
|
|
L3_debug_drv_init();
|
|
|
|
L1_task_tick_init();
|
|
|
|
L0_timer0_Init();
|
|
|
|
ET0 = 1;
|
|
|
|
|
|
|
|
printf1("\r\nD_sys_MainFre %ld",D_sys_MainFre);
|
|
|
|
|
|
|
|
//上电时控制蜂鸣器响一声
|
|
|
|
// L1_uart1_Array((U8 *)&scrBeepPowOnPkg, sizeof(scrBeepPowOnPkg));
|
|
|
|
|
|
|
|
r = L3_S_init();
|
|
|
|
printf1("\r\nL3_S_init %d",r);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//===============================================
|
|
|
|
//主函数
|
|
|
|
//===============================================
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
int tpc_flag = 0;
|
|
|
|
u16 a= 0;
|
|
|
|
char d[9]={0xab};
|
|
|
|
|
|
|
|
L0_main_init();
|
|
|
|
L3_task_weight_init();
|
|
|
|
L3_task_screen_init();
|
|
|
|
L3_task_bed_alarm_init();
|
|
|
|
L3_task_weight_keep_init();
|
|
|
|
|
|
|
|
TTSS_run_every_init(s_nos_tick.stamp,10);
|
|
|
|
|
|
|
|
printfs("\r\3 main while13\r\n");
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
if(1 == s_nos_tick.t1s_heartbeat)///
|
|
|
|
{
|
|
|
|
s_nos_tick.t1s_heartbeat = 0;
|
|
|
|
// L1_uartD_uc('.');
|
|
|
|
D_LED1_REV();
|
|
|
|
}
|
|
|
|
|
|
|
|
if((tpc_flag = L2_debug_ONcomand()))
|
|
|
|
{
|
|
|
|
if(tpc_flag == 1)
|
|
|
|
{
|
|
|
|
L3_weight_ONdebug(D_cmd_filter_weight);///fe xx xx///
|
|
|
|
}
|
|
|
|
else if(tpc_flag == 2)
|
|
|
|
{
|
|
|
|
parse_screen_pkg();///fe xx xx///
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
L3_task_weight_handler(&tst_weight);
|
|
|
|
|
|
|
|
L3_task_screen_handler(&_s_task_screen);
|
|
|
|
|
|
|
|
L3_task_bed_alarm_handler(&_s_task_bed_alarm);
|
|
|
|
|
|
|
|
L3_task_weight_keep_handler(&_s_task_weight_keep);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|