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.
167 lines
5.2 KiB
167 lines
5.2 KiB
/*****************************************************************************
|
|
* uart.h: Header file for NXP LPC17xx Family Microprocessors
|
|
*
|
|
* Copyright (c) 2023 CCSENS
|
|
* All rights reserved.
|
|
*
|
|
* History
|
|
* 2009.05.27 ver 1.00 Prelimnary version, first Release
|
|
*2017.01.10 ver 1.10 rename TTSS_tick.h tick.c
|
|
2019.03.11 ver 1.30 定时时间更改为25ms 解决串口接收受干扰的情况
|
|
*2021.12.12 ver 2.10 detail
|
|
****************************************************************************************/
|
|
/*****************************************************
|
|
*============================================================================
|
|
* HISTORY
|
|
* Below this line, this part is controlled by TSTS. DO NOT MODIFY!!
|
|
伪时间片嵌入式平台(Task Step by Step Turn by Turn Structure,简称TSTS)
|
|
*============================================================================
|
|
****************************************************************************/
|
|
|
|
#include "TTSS_tick.h"
|
|
|
|
#include "msp_uart1.h"
|
|
///#include "msp_uart2.h"
|
|
///#include "msp_uart3.h"
|
|
///#include "msp_uart4.h"
|
|
|
|
TS_nos_tick_ s_nos_tick;
|
|
#ifdef D_use_tick_fum
|
|
void L1_task_tick_init(void)
|
|
{
|
|
s_nos_tick.uart1_overtime_callback = L2_uart1_overtime_callback;
|
|
s_nos_tick.uart2_overtime_callback = L2_uart1_overtime_callback;
|
|
s_nos_tick.uart2_overtime_callback = L2_uart1_overtime_callback;///保护使用防止误删 容易崩溃
|
|
|
|
s_nos_tick.t_1s = 0;
|
|
s_nos_tick.jiffies = 0;
|
|
s_nos_tick.t1s_heartbeat= 0;
|
|
|
|
s_nos_tick.uart1_overtime_callback = L2_uart1_overtime_callback;///必备步骤1(method step 3)
|
|
//// s_nos_tick.uart2_overtime_callback = L2_uart2_overtime_callback;///必备步骤1(method step 3)
|
|
//// s_nos_tick.uart3_overtime_callback = L2_uart3_overtime_callback;///必备步骤1(method step 3)
|
|
// s_nos_tick.uart4_overtime_callback = L2_uart4_overtime_callback;///必备步骤1(method step 3)
|
|
///s_nos_tick.uart3_overtime_fun = NULL;///必备步骤1(method step 3)
|
|
///s_nos_tick.uart4_overtime_fun = NULL;///必备步骤1(method step 3)
|
|
/*****
|
|
s_nos_tick.t1s_flag[0] = 0;
|
|
s_nos_tick.t1s_flag[1] = 0;
|
|
s_nos_tick.t1s_flag[2] = 0;
|
|
s_nos_tick.t1s_flag[3] = 0;
|
|
s_nos_tick.t1s_flag[4] = 0;
|
|
s_nos_tick.t1s_flag[5] = 0;
|
|
if(L2_tick_time_interval(n_stamp,7*D_Tdelay_1s))
|
|
{// 时间溢出
|
|
L2_tick_time_stamp(s->t_stamp);
|
|
s_nos_tick.t_10ms = 0;
|
|
s_nos_tick.tp_count = 0;
|
|
s_nos_tick.n_stamp = 0;
|
|
s_nos_tick.t1s_heartbeat= 0;
|
|
********/
|
|
|
|
/// s_nos_tick.flag_1s = 0;
|
|
/// s_nos_tick.t_n = 0;
|
|
//s_nos_tick.tmp = 0;
|
|
//L0_timer0_ONF(1);
|
|
}
|
|
//JIFFIES回绕问题没有解决 参见 linux time_after宏定义
|
|
void L1_task_tick_callback (void)
|
|
{
|
|
///65535*65535/3600/24/365=139nian/s=1.39nian/10ms
|
|
///相当于1.39年后t_10ms 溢出,对于电池供电的系统而言 完全可以满足
|
|
// 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000秒/年
|
|
//s_nos_tick.t_50ms ++;//D_led_D1_REV(); 20160522验证
|
|
s_nos_tick.jiffies++;
|
|
if(s_nos_tick.jiffies % HZ == 0)
|
|
{
|
|
// 65535*65535/24/60/60/356/10 =12.7年
|
|
s_nos_tick.t_1s ++;
|
|
s_nos_tick.t1s_heartbeat = 1;
|
|
}
|
|
s_nos_tick.uart1_overtime_callback();////必备步骤1(method step 1)
|
|
// s_nos_tick.uart2_overtime_callback();////必备步骤1(method step 2)//
|
|
// s_nos_tick.uart3_overtime_callback();////必备步骤1(method step 1)
|
|
// s_nos_tick.uart4_overtime_callback();////必备步骤1(method step 1)
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
/// 定时器调用 10ms 一个中断
|
|
/// 定时器调用 25ms 一个中断
|
|
void L1_tick_tick (void)
|
|
{ /// 65535*65535 /3600/24/365=139nian/s=1.39nian/10ms
|
|
///相当于1.39年后t_10ms 溢出,对于电池供电的系统而言 完全可以满足
|
|
// 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000秒/年
|
|
s_nos_tick.tp_count++;
|
|
s_nos_tick.t_10ms ++;//D_led_D1_REV(); 20160522 验证
|
|
if(s_nos_tick.t_10ms%D_TIMER0_1S_COUNT == 0)
|
|
{// 65535*65535/24/60/60/356/10 =12.7年
|
|
s_nos_tick.t_1s ++;//// 65535*65535/24/60/60/356/10 =12.7年
|
|
/// s_nos_tick.flag_1s2 = 1;
|
|
s_nos_tick.t1s_heartbeat = 1;
|
|
/// LED1 = !LED1;
|
|
}
|
|
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<
|
|
}
|
|
|
|
|
|
void L1_tick_tick (void)
|
|
{
|
|
s_nos_tick.t_n++;
|
|
if (s_nos_tick.t_n >= D_TIMER0_10MS_COUNT)// 5500--- 100 10s--556
|
|
/// s 5ms 65535*65535 /3600/24/365=139nian/s
|
|
// 4,294,836,225 = 65535*65535 ;3600*24*60*60 = 31,536,000秒/年
|
|
// fixme:此处 保留了一个百年bug:)
|
|
{
|
|
s_nos_tick.t_10ms ++;//D_led_D1_REV(); 20160522 验证
|
|
if(s_nos_tick.t_10ms%D_TIMER0_1S_COUNT == 0)
|
|
{// 65535*65535/24/60/60/356/10 =12.7年
|
|
s_nos_tick.t_1s ++;//
|
|
|
|
// led_red =~led_red;
|
|
//s_nos_tick.t1s_flag[0] = 1;
|
|
//s_nos_tick.t1s_flag[1] = 1;
|
|
//s_nos_tick.t1s_flag[2] = 1;
|
|
//s_nos_tick.t1s_flag[3] = 1;
|
|
//s_nos_tick.t1s_flag[4] = 1;
|
|
//s_nos_tick.t1s_flag[5] = 1;
|
|
s_nos_tick.flag_1s = 1;
|
|
s_nos_tick.t1s_heatbeart = 1;
|
|
}
|
|
s_nos_tick.t_n = 0;
|
|
}
|
|
/*******************
|
|
// 0.2mm 4/0.2 = 20 20/60s = 333ms/maicong
|
|
// 0.2mm 60s 60 100 ms
|
|
// 0.2 6000ms
|
|
// 平时为1 水满一次为0
|
|
// rain = 1;必须要做的初始化
|
|
if(0 == rain)
|
|
{
|
|
if(1 == s_rain.temp)
|
|
{// ````\___
|
|
s_rain.pool = s_rain.t;
|
|
s_rain.all ++;
|
|
s_rain.t = 0;
|
|
}
|
|
s_rain.temp = 0;
|
|
}else
|
|
{
|
|
s_rain.temp = 1;
|
|
}
|
|
s_rain.t ++;
|
|
|
|
******/
|
|
//<<<<<<<<<<<<<<<<<<<<<<
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|