forked from ccsens_hardware/stc_touch_pen
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.
185 lines
5.0 KiB
185 lines
5.0 KiB
//////////////////////////////////////////////////////////////////////////
|
|
/// COPYRIGHT NOTICE
|
|
/// Copyright (c) 2015, 传控科技
|
|
/// All rights reserved.
|
|
///
|
|
/// @file main.c
|
|
/// @brief main app
|
|
///
|
|
///(本文件实现的功能的详述)
|
|
///
|
|
/// @version 1.1 CCsens technology
|
|
/// @author CC
|
|
/// @date 20150102
|
|
///
|
|
/// 修订说明:最初版本
|
|
/// Modified by:
|
|
/// Modified date:
|
|
/// Version:
|
|
/// Descriptions: CC-PWR-VH01-m02.sch
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//20160413 CC-ACC-VH02
|
|
//20170111 CC-ls_02
|
|
//
|
|
//20170608 cc_as_stc01_main
|
|
//
|
|
//
|
|
//
|
|
//
|
|
|
|
/// 下面是一个含有两个参数的函数的注释说明(简述)
|
|
///
|
|
/// 这里写该函数的详述信息
|
|
/// @param a 被测试的变量(param描述参数)
|
|
/// @param s 指向描述测试信息的字符串
|
|
/// @return 测试结果(return描述返回值)
|
|
/// @see Test() (本函数参考其它的相关的函数,这里作一个链接)
|
|
/// @note (note描述需要注意的问题)
|
|
/************************************************
|
|
stc5ac32s
|
|
************************************************/
|
|
//===============================================
|
|
//寄存器头文件
|
|
//===============================================
|
|
|
|
#include "main.h"
|
|
|
|
/// main init
|
|
/// @param a 被测试的变量(param描述参数)
|
|
/// @param s 指向描述测试信息的字符串
|
|
/// @return 测试结果(return描述返回值)
|
|
/// @see Test() (本函数参考其它的相关的函数,这里作一个链接)
|
|
/// @note (note描述需要注意的问题)
|
|
|
|
void L0_main_init(void)
|
|
{
|
|
#if 0
|
|
//flash
|
|
L3_flash_init();
|
|
L3_flash_read_param();
|
|
|
|
L2_task_relay_init(); //继电器初始化
|
|
#endif
|
|
L2_relay_init();
|
|
|
|
///step : 1>>>>>>>>>>时钟初始化-------------------------------------
|
|
// L0_cpu_init();
|
|
// L1_led_init();
|
|
L0_timer0_Init();
|
|
L1_tick_init();
|
|
Lc_delay_ms(700);// 2000--7s
|
|
|
|
///step : 2>>>>>>>>>引脚选择相关>>>>>>>>>
|
|
L0_uart0_change(P3130); //调试(心跳)
|
|
L0_uart2_change(P1110); //串口2 射频m
|
|
L0_uart4_change(P5352); //串口4 gsm通讯
|
|
Lc_delay_ms(700);// 2000--7s
|
|
|
|
///step : 3>>>>>>>>>中断控制相关>>>>>>>>>
|
|
EA = 1; //打开总中断-------------------------------------
|
|
Lc_delay_ms(700);// 2000--7s
|
|
|
|
///step : 4>>>>>>>>>串口等debug相关>>>>>>>>>
|
|
L1_bsp_uart_config(); //配置串口对应的操作协议
|
|
L1_uart0_buf_init();
|
|
L1_uart2_buf_init();
|
|
L1_uart4_buf_init();
|
|
L2_485_init();
|
|
Lc_delay_ms(700);// 2000--7s
|
|
|
|
///step: 5>>>>>>>>>看门狗>>>>>>>>>>>>>
|
|
L0_wdt_init();
|
|
L2_gm35_init();
|
|
|
|
///step: 7>>>>>>>>>寄存器默认初始化>>>>>>>>>>>>>
|
|
L2_register_init();
|
|
//L3_flash_write_page0();
|
|
|
|
///step: 6>>>>>>>>>Flash>>>>>>>>>>>>>
|
|
L3_flash_init();
|
|
L3_flash_read_param();
|
|
|
|
///step : 7>>>>>>>>>任务相关>>>>>>>>>
|
|
L3_task_report_init(); //与上位机通信
|
|
L3_task_relay_init(); //继电器
|
|
L3_task_gm35_core_init();
|
|
L3_task_wdt_init(); //看门狗任务初始化
|
|
L3_task_485_init(); //485轮询任务初始化
|
|
Lc_delay_ms(700);// 2000--7s
|
|
}
|
|
|
|
//===============================================
|
|
//主函数
|
|
//===============================================
|
|
|
|
|
|
void main(void)
|
|
{
|
|
P35 = 0;
|
|
P07 = 0;
|
|
//-----------------------------------------------
|
|
//系统初始化
|
|
//----------------------------------------------
|
|
L0_main_init();
|
|
Lc_delay_ms(700);// 2000--7s
|
|
|
|
Lc_print_buf("Init complete...\r\n");
|
|
Lc_delay_ms(700);// 2000--7s
|
|
Lc_print_buf("Version:");
|
|
L0_uart0_uc((APP_VERSION_HEX >> 4 & 0xF) + '0');
|
|
L0_uart0_uc('.');
|
|
L0_uart0_uc((APP_VERSION_HEX >> 0 & 0xF) + '0');
|
|
L0_uart0_0d0a();
|
|
Lc_delay_ms(700);// 2000--7s
|
|
//-----------------------------------------------
|
|
//系统主循环
|
|
//-----------------------------------------------
|
|
while(9)
|
|
{
|
|
if(30 == s_nos_tick.t1s_heatbeart)
|
|
{
|
|
s_nos_tick.t1s_heatbeart = 0;
|
|
// L0_uart0_uc('.');
|
|
//L2_gprs_send_signin_pkg();
|
|
//L0_uart4_sendArray(AT_INS_ATEQV,2);
|
|
//L3_gm35_send_str(AT_INS_CCID);
|
|
//L3_gm35_send_str(AT_INS_CREG);
|
|
//L3_gm35_send_str(AT_INS_CSQ);
|
|
//L2_ph3_common_send(ADDR_SERVER,gprsTcpPkg_SigninAscii,46 * 2);
|
|
//L0_uart4_0d0a();
|
|
//L0_uart0_uc(' ');
|
|
//L0_uart0_sendArray(G.ccid_passwd, 22);
|
|
|
|
//getPwd(G.ccid, G.ccid_passwd);
|
|
//hexBytes2AsciiBytes(NULL,NULL,46);
|
|
}
|
|
//看门狗
|
|
L3_task_wdt_handle(&s_task_wdt);
|
|
#if 1
|
|
//每隔n秒,主动向上位机发送心跳包
|
|
L3_task_report_handle(&s_task_report);
|
|
|
|
//解析串口0协议(上位机发送的控制消息)
|
|
L3_UARTcom0_exp_protocol(&s_uart0_rec);
|
|
|
|
//gsm模块初始化+tcp发送消息
|
|
L3_task_gm35_core_handle();
|
|
|
|
//解析串口4协议(gsm模块收到的at响应消息+服务器发送消息)
|
|
L3_UARTcom4_exp_protocol(&s_uart4_at_rec);
|
|
|
|
//解析串口4+CIPRCV协议
|
|
L3_task_a9_rcv_handle(&s_uart4_tcp_rec);
|
|
|
|
//继电器PC按键弹起
|
|
L3_task_relay_handle(&s_task_relay);
|
|
#endif
|
|
|
|
//485轮询
|
|
L3_task_485_handle(&ts_485);
|
|
}
|
|
}//end main
|
|
|
|
|
|
|
|
|
|
|