解决了一些bug,添加完善了程序注释

This commit is contained in:
forbelief 2016-06-04 16:18:10 +08:00
parent fe11958be3
commit bd1902939a
23 changed files with 7250 additions and 7073 deletions

File diff suppressed because it is too large Load diff

View file

@ -93,7 +93,7 @@
</option> </option>
<option> <option>
<name>OCDownloadAttachToProgram</name> <name>OCDownloadAttachToProgram</name>
<state>0</state> <state>1</state>
</option> </option>
<option> <option>
<name>UseFlashLoader</name> <name>UseFlashLoader</name>

View file

@ -19,6 +19,6 @@
@REM @REM
"D:\work_soft\iar\arm\common\bin\cspybat" "D:\work_soft\iar\arm\arm\bin\armproc.dll" "D:\work_soft\iar\arm\arm\bin\armjlink.dll" %1 --plugin "D:\work_soft\iar\arm\arm\bin\armbat.dll" --device_macro "D:\work_soft\iar\arm\arm\config\debugger\Freescale\Kinetis.dmac" --backend -B "--endian=little" "--cpu=Cortex-M0+" "--fpu=None" "-p" "D:\work_soft\iar\arm\arm\CONFIG\debugger\Freescale\MKL25Z128xxx4.ddf" "--semihosting" "--device=MKL25Z128xxx4" "--drv_mtb_regbase=0xF0000000" "--drv_mtb_dwtregbase=0xF0001000" "--drv_mtb_minramaddr=0x20000000" "--drv_mtb_maxramaddr=0x20002FFF" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=1000" "--jlink_reset_strategy=0,0" "--jlink_interface=SWD" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000" "D:\work_soft\iar\arm\common\bin\cspybat" "D:\work_soft\iar\arm\arm\bin\armproc.dll" "D:\work_soft\iar\arm\arm\bin\armjlink.dll" %1 --plugin "D:\work_soft\iar\arm\arm\bin\armbat.dll" --device_macro "D:\work_soft\iar\arm\arm\config\debugger\Freescale\Kinetis.dmac" --backend -B "--endian=little" "--cpu=Cortex-M0+" "--fpu=None" "-p" "D:\work_soft\iar\arm\arm\CONFIG\debugger\Freescale\MKL25Z128xxx4.ddf" "--drv_attach_to_program" "--semihosting" "--device=MKL25Z128xxx4" "--drv_mtb_regbase=0xF0000000" "--drv_mtb_dwtregbase=0xF0001000" "--drv_mtb_minramaddr=0x20000000" "--drv_mtb_maxramaddr=0x20002FFF" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=1000" "--jlink_reset_strategy=0,0" "--jlink_interface=SWD" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000"

View file

@ -9,7 +9,7 @@ TriggerName=main
LimitSize=0 LimitSize=0
ByteLimit=50 ByteLimit=50
[DebugChecksum] [DebugChecksum]
Checksum=231404021 Checksum=2097835749
[CodeCoverage] [CodeCoverage]
Enabled=_ 0 Enabled=_ 0
[Exceptions] [Exceptions]

Binary file not shown.

View file

@ -7,6 +7,10 @@
#define KEY_H #define KEY_H
/*
* key_mean -
* N_KEY表示无键按下状态S_KEY表示单击D_KEY表示双击L_KEY表示长按
*/
typedef enum key_mean_ typedef enum key_mean_
{ {
N_KEY = 0, S_KEY, D_KEY, L_KEY N_KEY = 0, S_KEY, D_KEY, L_KEY
@ -24,32 +28,10 @@ typedef enum key_type_
/*
* key_init() -
*
*/
void key_init(void); void key_init(void);
/*
* key_detect() -
*
* 10ms调用一次
*/
void key_detect(void); void key_detect(void);
/*
* get_key_mean() -
*
* N_KEY
*/
key_mean get_key_mean(key_type key_t); key_mean get_key_mean(key_type key_t);
void clear_key_m(void); void clear_key_m(void);

View file

@ -7,49 +7,22 @@
#ifndef KNOB_H #ifndef KNOB_H
#define KNOB_H #define KNOB_H
#include "arm_cm0.h"
#include "vectors.h"
/*
* knob_init() -
*
*
*/
void knob_init(void); void knob_init(void);
/*
* knob_enable() - 使
*/
void knob_enable(void); void knob_enable(void);
/*
* knob_disable() -
*/
void knob_disable(void); void knob_disable(void);
/*
* knob_clear() -
*/
void knob_clear(void); void knob_clear(void);
/*
* get_knob_val() -
*/
int32_t get_knob_val(void); int32_t get_knob_val(void);
/*
* knob_detect() -
*
* A相输出发生沿跳变时调用沿
*/
void knob_detect(void); void knob_detect(void);

View file

@ -5,6 +5,9 @@
#include <stdint.h> #include <stdint.h>
/*
* calendar_info -
*/
typedef struct calendar_info_ typedef struct calendar_info_
{ {
uint8_t sec; uint8_t sec;
@ -17,22 +20,15 @@ typedef struct calendar_info_
uint16_t yday; uint16_t yday;
} calendar_info; } calendar_info;
// START_YEAR为计算日历时间时的起始时间
enum { START_YEAR = 2000, SEC_IN_DAY = 24 * 60 * 60}; enum { START_YEAR = 2000, SEC_IN_DAY = 24 * 60 * 60};
uint8_t is_leapyear(uint16_t year); uint8_t is_leapyear(uint16_t year);
uint8_t get_month_days(uint16_t year, uint8_t month); uint8_t get_month_days(uint16_t year, uint8_t month);
void ds1302_init(void); void ds1302_init(void);
void ds1302_set_time(calendar_info *cal); void ds1302_set_time(calendar_info *cal);
void ds1302_read_time(calendar_info *cal); void ds1302_read_time(calendar_info *cal);
void maintain_system_time(void); void maintain_system_time(void);
calendar_info get_system_time(void); calendar_info get_system_time(void);
uint32_t calendar_to_sec(calendar_info *cal); uint32_t calendar_to_sec(calendar_info *cal);
calendar_info sec_to_calendar(uint32_t sec); calendar_info sec_to_calendar(uint32_t sec);

View file

@ -34,68 +34,13 @@ typedef enum st_mode_
NO_COMPARE NO_COMPARE
} st_mode; } st_mode;
/*
* st_init() - pit定时器
*
* 1ms
*/
void st_base_init(void); void st_base_init(void);
/*
* st_init() -
* @n:
* @st_m:
* @cmr_v:
*
* 0~0
*/
uint8_t st_init(uint8_t n, st_mode st_m, uint32_t cmr_v); uint8_t st_init(uint8_t n, st_mode st_m, uint32_t cmr_v);
/*
* st_close() -
* @n:
*/
void st_close(uint8_t n); void st_close(uint8_t n);
/*
* st_tcf() - tcf位返回
* @n:
*
* 01
*/
uint8_t st_tcf(uint8_t n); uint8_t st_tcf(uint8_t n);
/*
* st_tov() - tov位返回
* @n:
*
* 01
*/
uint8_t st_tov(uint8_t n); uint8_t st_tov(uint8_t n);
/*
* st_count() -
* @n:
*
*
*/
uint32_t st_count(uint8_t n); uint32_t st_count(uint8_t n);
/********************ISR******************/
/*
* st_base() -N路定时器
*
*
*/
void st_base(void); void st_base(void);

View file

@ -35,7 +35,6 @@ int16_t *get_value_of_kvp(char *name, uint8_t objn);
input_limit tft_input_limit(char *name); input_limit tft_input_limit(char *name);
//const kv_pair *get_plan_data(uint8_t objn)[][PLAN_DATA_NUM];

View file

@ -6,23 +6,30 @@
#include "include/pm_time.h" #include "include/pm_time.h"
/*
* plan_input -
*
*/
typedef struct plan_input_ typedef struct plan_input_
{ {
calendar_info bg_t; calendar_info bg_t; // 开始时间
calendar_info ed_t; calendar_info ed_t; // 结束时间
calendar_info pd_t; calendar_info pd_t; // 周期时长
uint8_t x_orient; uint8_t x_orient; // x方向值未使用
uint8_t y_orient; uint8_t y_orient; // y方向值未使用
uint8_t lg_r : 1; uint8_t lg_r : 1; // 红灯
uint8_t lg_b : 1; uint8_t lg_b : 1; // 蓝灯
uint8_t lg_uvb : 1; uint8_t lg_uvb : 1; // uvb
uint8_t water : 1; uint8_t water : 1; // 浇水,未使用
uint8_t sw : 1; uint8_t sw : 1; // 是否加入计划
uint8_t cnt; uint8_t cnt; // 完成次数
} plan_input; } plan_input;
/*
* kv_pair -
* key为存储元素ID的字符串value为一个整形值attr为元素属性
*/
typedef struct kv_pair_ typedef struct kv_pair_
{ {
char *key; char *key;
@ -30,9 +37,9 @@ typedef struct kv_pair_
int8_t attr; int8_t attr;
} kv_pair; } kv_pair;
enum { PLAN_DATA_NUM = 19 }; enum { PLAN_DATA_NUM = 19, OBJ_NUM = 8 };
extern plan_input plan_in[PLAN_DATA_NUM]; extern plan_input plan_in[OBJ_NUM];
extern kv_pair kvp_obj_set[][PLAN_DATA_NUM]; extern kv_pair kvp_obj_set[][PLAN_DATA_NUM];

View file

@ -14,11 +14,7 @@
void water_init(void); void water_init(void);
uint16_t get_moisture(void); uint16_t get_moisture(void);
void water_ctr(uint16_t sv_moist); void water_ctr(uint16_t sv_moist);

View file

@ -44,6 +44,13 @@ typedef enum state_sign_
} state_sign; } state_sign;
/*
* key_infomation -
* state_base和time_base在key_read_base函数中使用的状态变量
* state和time在key_read函数中使用的状态变量
* key_m保存当前按键读取的结果
* get_state_io变量指向获取按键对应输入io状态的函数
*/
typedef struct key_infomation_ typedef struct key_infomation_
{ {
key_state state_base; key_state state_base;
@ -59,6 +66,9 @@ typedef struct key_infomation_
/*
* io状态的函数
*/
state_sign get_state_up_key_io(void) state_sign get_state_up_key_io(void)
{ return !gpio_get(UP_KEY_PINX) ? VALID : INVALID; } { return !gpio_get(UP_KEY_PINX) ? VALID : INVALID; }
@ -87,6 +97,7 @@ state_sign get_state_muvb_key_io(void)
{ return !gpio_get(MUVB_KEY_PINX) ? VALID : INVALID; } { return !gpio_get(MUVB_KEY_PINX) ? VALID : INVALID; }
// 定义按键变量并初始化
static volatile key_infomation static volatile key_infomation
up_key_info = { key_state_0, 0, key_state_0, 0, N_KEY, get_state_up_key_io }, up_key_info = { key_state_0, 0, key_state_0, 0, N_KEY, get_state_up_key_io },
down_key_info = { key_state_0, 0, key_state_0, 0, N_KEY, get_state_down_key_io }, down_key_info = { key_state_0, 0, key_state_0, 0, N_KEY, get_state_down_key_io },
@ -100,7 +111,7 @@ static volatile key_infomation
/* /**
* key_init() - * key_init() -
* *
*/ */
@ -116,17 +127,11 @@ void key_init(void)
gpio_Interrupt_init(MB_KEY_PINX, GPI_UP_PF, GPI_DISAB); gpio_Interrupt_init(MB_KEY_PINX, GPI_UP_PF, GPI_DISAB);
gpio_Interrupt_init(MUVB_KEY_PINX, GPI_UP_PF, GPI_DISAB); gpio_Interrupt_init(MUVB_KEY_PINX, GPI_UP_PF, GPI_DISAB);
/*
* 10ms定时中断
*/
return; return;
} }
/* /**
* key_read_base - * key_read_base -
* @key_info: , * @key_info: ,
* *
@ -137,45 +142,50 @@ key_mean key_read_base(volatile key_infomation *key_info)
state_sign key_state_io; state_sign key_state_io;
key_mean key_m = N_KEY; key_mean key_m = N_KEY;
key_state_io = (*((*key_info).get_state_io))(); // 获取io状态 // 获取io状态
switch((*key_info).state_base) key_state_io = (*(key_info->get_state_io))();
switch(key_info->state_base)
{ {
case key_state_0: case key_state_0:
if (key_state_io == VALID) if (key_state_io == VALID)
{ {
(*key_info).state_base = key_state_1; // 按键按下后首先进入消抖和按键确 // 按键按下后首先进入消抖和按键确认状态
// 认状态 key_info->state_base = key_state_1;
} }
break; break;
case key_state_1: case key_state_1:
if (key_state_io == VALID) if (key_state_io == VALID)
{ {
(*key_info).time_base = 0; // 按键如果仍然按下,则消抖完成
(*key_info).state_base = key_state_2; // 按键如果仍然按下,则消抖完成, // 进行状态转换,并且返回无按键事件
// 状态转换,此时返回无按键事件 key_info->time_base = 0;
key_info->state_base = key_state_2;
} }
else else
{ {
(*key_info).state_base = key_state_0; key_info->state_base = key_state_0;
} }
break; break;
case key_state_2: case key_state_2:
if (key_state_io == INVALID) if (key_state_io == INVALID)
{ {
key_m = S_KEY; // 此时按键释放说明为一次短操作 // 此时按键释放说明为一次短操作
(*key_info).state_base = key_state_0; key_m = S_KEY;
key_info->state_base = key_state_0;
} }
else if (++(*key_info).time_base > 100) // 继续按下计时加10ms即本函 // 继续按下计时加10ms即本函数调用周期
// 数调用周期 else if (++key_info->time_base > 100)
{ {
key_m = L_KEY; // 按下时间大于1s返回 长按键 // 按下时间大于1s返回长按键并且转换为等待按键释放状态
(*key_info).state_base = key_state_3; // 转换为等待按键释放状态 key_m = L_KEY;
key_info->state_base = key_state_3;
} }
break; break;
case key_state_3: case key_state_3:
if (key_state_io == INVALID) if (key_state_io == INVALID)
{ {
(*key_info).state_base = key_state_0; // 按键此时已释放,转换为初始状态 // 按键此时已释放,转换为初始状态
key_info->state_base = key_state_0;
} }
break; break;
default: default:
@ -184,7 +194,7 @@ key_mean key_read_base(volatile key_infomation *key_info)
return key_m; return key_m;
} }
/* /**
* key_read - * key_read -
* @key_info: * @key_info:
* *
@ -196,33 +206,35 @@ key_mean key_read(volatile key_infomation *key_info)
key_m_temp; key_m_temp;
key_m_temp = key_read_base(key_info); key_m_temp = key_read_base(key_info);
switch((*key_info).state) switch(key_info->state)
{ {
case key_state_0: case key_state_0:
if (key_m_temp == S_KEY) if (key_m_temp == S_KEY)
{ {
(*key_info).time = 0; // 第一次单击状态,仍然返回无键,到下个周期 // 第一次单击状态,仍然返回无键,到下个周期判断是否出现双击
// 判断是否出现双击 key_info->time = 0;
(*key_info).state = key_state_1; key_info->state = key_state_1;
} }
else else
{ {
key_m = key_m_temp; // 对于非单击,返回原事件 // 对于非单击,返回原事件
key_m = key_m_temp;
} }
break; break;
case key_state_1: case key_state_1:
if (key_m_temp == S_KEY) // 又一次单击,间隔 < 300ms // 又一次单击,间隔 < 300ms
if (key_m_temp == S_KEY)
{ {
key_m = D_KEY; key_m = D_KEY;
(*key_info).state = key_state_0; key_info->state = key_state_0;
} }
else else
{ {
if (++(*key_info).time > 30) if (++key_info->time > 30)
{ {
key_m = S_KEY; // 300ms内没有再出现单击事件则返回上一次单 // 300ms内没有再出现单击事件则返回上一次单击事件
// 击事件 key_m = S_KEY;
(*key_info).state = key_state_0; key_info->state = key_state_0;
} }
} }
break; break;
@ -233,11 +245,11 @@ key_mean key_read(volatile key_infomation *key_info)
} }
/* /**
* key_detect() - * key_detect() -
* *
* N_KEY状态时记录按键信息N_KEY是在应用程序获取按键信息的时候同时被设 * N_KEY状态时记录按键信息N_KEY是在应用程序获取按键信息的时候同时
* *
* 10ms调用一次 * 10ms调用一次
*/ */
void key_detect(void) void key_detect(void)
@ -284,7 +296,7 @@ void key_detect(void)
} }
/* /**
* get_key_mean() - * get_key_mean() -
* *
* N_KEY * N_KEY

View file

@ -7,10 +7,11 @@
#include <stdint.h> #include <stdint.h>
#include "include.h" #include "include.h"
#include "arm_cm0.h"
#include "vectors.h"
#include "include/knob.h"
#include "include/config.h" #include "include/config.h"
#include "include/knob.h"
@ -48,7 +49,7 @@ void knob_enable(void)
*/ */
void knob_disable(void) void knob_disable(void)
{ {
disable_irq(PortA_irq_no); disable_irq(PortD_irq_no);
return; return;
} }
@ -87,7 +88,8 @@ void knob_detect(void)
{ {
knob_val++; knob_val++;
} }
else // ¼´if ((knob_A == 0 && knob_B == 0) || (knob_A == 1 && knob_B == 1)) // ¼´if ((knob_A == 0 && knob_B == 0) || (knob_A == 1 && knob_B == 1))
else
{ {
knob_val--; knob_val--;
} }

View file

@ -24,8 +24,10 @@ void main(void)
enter_critical(); enter_critical();
pm_init(); pm_init();
exit_critical(); exit_critical();
/*
st_init(0, COMPARE, 10); // 作为按键扫描函数的定时使用在simulat_timer.c的底层中使用 * 使simulat_timer.c的底层中使用
*/
st_init(0, COMPARE, 10);
st_init(1, COMPARE, 100); st_init(1, COMPARE, 100);
#ifdef PM_DEBUG #ifdef PM_DEBUG

View file

@ -53,7 +53,7 @@ void orient_setspeed(uint8_t addr, orient ori, uint8_t spd)
{ {
spd = 100; spd = 100;
} }
cmd[4] = 0x3f * spd / 100; cmd[4] = (uint16_t)0x3f * spd / 100;
cmd[6] = cmd[1] + cmd[2] + cmd[3] + cmd[4] + cmd[5]; cmd[6] = cmd[1] + cmd[2] + cmd[3] + cmd[4] + cmd[5];
uart_sendN(ORIENT_UARTX, cmd, 7); uart_sendN(ORIENT_UARTX, cmd, 7);

View file

@ -1,16 +1,17 @@
/* /*
* plan_handle.c - * plan_handle.c -
* *
* *
* *
* *
* *
* *
* *
* 访 * 访
* tft.c模块访 * tft.c模块访
* 访 * 访
* *
*
*/ */
#include <stdint.h> #include <stdint.h>
@ -26,6 +27,11 @@
#include "include/orient.h" #include "include/orient.h"
#include "include/key.h" #include "include/key.h"
/*
*
* is_reach表示是否到达计划执行时间
* note是一个字符串
*/
typedef struct plan_output_ typedef struct plan_output_
{ {
uint8_t is_reach; uint8_t is_reach;
@ -38,6 +44,9 @@ typedef enum lg_state_
} lg_state; } lg_state;
/*
*
*/
static void indata_to_outdata(plan_input *ind, plan_output *outd); static void indata_to_outdata(plan_input *ind, plan_output *outd);
static void plan_ctr_exe(uint8_t activity); static void plan_ctr_exe(uint8_t activity);
static void plan_inpu_to_tft(void); static void plan_inpu_to_tft(void);
@ -46,11 +55,19 @@ static void manul_key_func(void);
static void manul_ctr(void); static void manul_ctr(void);
static void plan_ctr(void); static void plan_ctr(void);
static plan_output plan_out[PLAN_DATA_NUM] = { 0 }; /*
plan_input plan_in[PLAN_DATA_NUM] = { 0 }; * 0
*/
static plan_output plan_out[OBJ_NUM] = { 0 };
plan_input plan_in[OBJ_NUM] = { 0 };
/**
* plan_handle_init() -
*
* IO初始化和计划数据的上电恢复工作
*/
void plan_handle_init(void) void plan_handle_init(void)
{ {
gpio_init(LGRED_PINX, 1, NO_LIGHT); gpio_init(LGRED_PINX, 1, NO_LIGHT);
@ -61,7 +78,6 @@ void plan_handle_init(void)
gpio_init(LG1_PINX, 1, 1); gpio_init(LG1_PINX, 1, 1);
gpio_init(LG2_PINX, 1, 1); gpio_init(LG2_PINX, 1, 1);
gpio_init(LG3_PINX, 1, 1); gpio_init(LG3_PINX, 1, 1);
// 还有设置方向的初始化
/* /*
* flash到plan_handle模块plan_handle模块到tft模块 * flash到plan_handle模块plan_handle模块到tft模块
@ -74,20 +90,37 @@ void plan_handle_init(void)
/**
* indata_to_outdata() -
* @ind:
* @outd:
*
*
*/
static void indata_to_outdata(plan_input *ind, plan_output *outd) static void indata_to_outdata(plan_input *ind, plan_output *outd)
{ {
// 首先得到系统时间并转换为日历时间格式
calendar_info st = get_system_time(); calendar_info st = get_system_time();
uint32_t sys_sec = calendar_to_sec(&st); uint32_t sys_sec = calendar_to_sec(&st);
/*
*
* 便
*/
ind->pd_t.year = START_YEAR; ind->pd_t.year = START_YEAR;
ind->pd_t.month = 1; ind->pd_t.month = 1;
ind->pd_t.mday = 1;
ind->pd_t.sec = 0; ind->pd_t.sec = 0;
uint32_t pd_sec = calendar_to_sec(&ind->pd_t); uint32_t pd_sec = calendar_to_sec(&ind->pd_t);
/*
*
*
*
*/
uint32_t ctr_bg_sec = calendar_to_sec(&ind->bg_t) + pd_sec * ind->cnt; uint32_t ctr_bg_sec = calendar_to_sec(&ind->bg_t) + pd_sec * ind->cnt;
uint32_t ctr_ed_sec = calendar_to_sec(&ind->ed_t) + pd_sec * ind->cnt; uint32_t ctr_ed_sec = calendar_to_sec(&ind->ed_t) + pd_sec * ind->cnt;
// 比较系统时间是否在执行计划的区间
if (ctr_bg_sec < sys_sec && ctr_ed_sec > sys_sec) if (ctr_bg_sec < sys_sec && ctr_ed_sec > sys_sec)
{ {
outd->is_reach = 1; outd->is_reach = 1;
@ -96,6 +129,10 @@ static void indata_to_outdata(plan_input *ind, plan_output *outd)
{ {
if (outd->is_reach == 1) if (outd->is_reach == 1)
{ {
/*
*
*
*/
ind->cnt++; ind->cnt++;
} }
outd->is_reach = 0; outd->is_reach = 0;
@ -105,16 +142,36 @@ static void indata_to_outdata(plan_input *ind, plan_output *outd)
} }
/**
* plan_ctr_exe() -
* @activity: activity大于
*
*
* IO输出控制以及云台预置位控制
*/
static void plan_ctr_exe(uint8_t activity) static void plan_ctr_exe(uint8_t activity)
{ {
if (activity >= PLAN_DATA_NUM) /*
* isnt_first数组是为了标记每一个活动在一次计划区间内是不是第一次执行
*
*/
static uint8_t isnt_first[OBJ_NUM] = { 0 };
if (activity >= OBJ_NUM)
{ {
// activity大于植物的编号的话代表没有计划任务需要执行
for (uint8_t i = 0; i < OBJ_NUM; i++)
{
isnt_first[i] = 0;
}
gpio_set(LGRED_PINX, NO_LIGHT); gpio_set(LGRED_PINX, NO_LIGHT);
gpio_set(LGBLUE_PINX, NO_LIGHT); gpio_set(LGBLUE_PINX, NO_LIGHT);
gpio_set(LGUVB_PINX, NO_LIGHT); gpio_set(LGUVB_PINX, NO_LIGHT);
gpio_set(WATER_PINX, NO_LIGHT); gpio_set(WATER_PINX, NO_LIGHT);
} }
else else
{
// 当activity对应于一个植物编号并且是第一次执行的时候就执行计划
if (isnt_first[activity] == 0)
{ {
orient_presetop(0, PRESET_CALL, activity + 1); orient_presetop(0, PRESET_CALL, activity + 1);
orient_presetop(1, PRESET_CALL, activity + 1); orient_presetop(1, PRESET_CALL, activity + 1);
@ -122,16 +179,26 @@ static void plan_ctr_exe(uint8_t activity)
gpio_set(LGBLUE_PINX, plan_in[activity].lg_b == 1 ? LIGHT : NO_LIGHT); gpio_set(LGBLUE_PINX, plan_in[activity].lg_b == 1 ? LIGHT : NO_LIGHT);
gpio_set(LGUVB_PINX, plan_in[activity].lg_uvb == 1 ? LIGHT : NO_LIGHT); gpio_set(LGUVB_PINX, plan_in[activity].lg_uvb == 1 ? LIGHT : NO_LIGHT);
gpio_set(WATER_PINX, plan_in[activity].water == 1 ? LIGHT : NO_LIGHT); gpio_set(WATER_PINX, plan_in[activity].water == 1 ? LIGHT : NO_LIGHT);
isnt_first[activity] = 1;
}
} }
return; return;
} }
/**
* plan_ctr() -
*
*
*/
void plan_ctr(void) void plan_ctr(void)
{ {
uint8_t activity = PLAN_DATA_NUM; // 首先初始化活动不为任意一个植物编号
uint8_t activity = OBJ_NUM;
for (uint8_t i = 0; i < PLAN_DATA_NUM; i++) // 依次遍历每一个植物,得到需要执行的活动号,即对应的植物编号
for (uint8_t i = 0; i < OBJ_NUM; i++)
{ {
indata_to_outdata(&plan_in[i], &plan_out[i]); indata_to_outdata(&plan_in[i], &plan_out[i]);
if (plan_in[i].sw == 1) if (plan_in[i].sw == 1)
@ -148,6 +215,12 @@ void plan_ctr(void)
} }
/**
* plan_handle() -
*
*
*
*/
void plan_handle(void) void plan_handle(void)
{ {
if (gpio_get(AMS_KEY_PINX)) if (gpio_get(AMS_KEY_PINX))
@ -161,6 +234,11 @@ void plan_handle(void)
return; return;
} }
/**
* key_func() -
*
*
*/
void key_func(void) void key_func(void)
{ {
if (gpio_get(AMS_KEY_PINX)) if (gpio_get(AMS_KEY_PINX))
@ -175,12 +253,17 @@ void key_func(void)
} }
/**
* manul_ctr() -
*
*
*/
void manul_ctr(void) void manul_ctr(void)
{ {
return; return;
} }
/* /**
* tft_to_plan_input() - tft显示的数据提取到计划处理的输入数据结构中 * tft_to_plan_input() - tft显示的数据提取到计划处理的输入数据结构中
* @objn: 0~7 * @objn: 0~7
* *
@ -196,7 +279,7 @@ void tft_to_plan_input(uint8_t objn)
plan_in[objn].bg_t.sec = 0; plan_in[objn].bg_t.sec = 0;
/* /*
* tft条目没有年 * tft条目没有年
*/ */
plan_in[objn].ed_t.year = plan_in[objn].bg_t.year; plan_in[objn].ed_t.year = plan_in[objn].bg_t.year;
plan_in[objn].ed_t.month = plan_in[objn].bg_t.month; plan_in[objn].ed_t.month = plan_in[objn].bg_t.month;
@ -261,6 +344,11 @@ static void plan_inpu_to_tft(void)
} }
/**
* plan_key_func() -
*
* tft显示屏关
*/
static void plan_key_func(void) static void plan_key_func(void)
{ {
/* /*
@ -272,15 +360,21 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("UP_KEY 单击\n"); printf("UP_KEY 单击\n");
#endif /* PM_DEBUG */
tft_left(); tft_left();
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("UP_KEY 双击\n"); printf("UP_KEY 双击\n");
#endif /* PM_DEBUG */
tft_up(); tft_up();
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("UP_KEY 长按\n"); printf("UP_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -291,15 +385,21 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("DOWN_KEY 单击\n"); printf("DOWN_KEY 单击\n");
#endif /* PM_DEBUG */
tft_right(); tft_right();
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("DOWN_KEY 双击\n"); printf("DOWN_KEY 双击\n");
#endif /* PM_DEBUG */
tft_down(); tft_down();
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("DOWN_KEY 长按\n"); printf("DOWN_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -310,14 +410,20 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("OK_KEY 单击\n"); printf("OK_KEY 单击\n");
tft_ok(); tft_ok();
#endif /* PM_DEBUG */
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("OK_KEY 双击\n"); printf("OK_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("OK_KEY 长按\n"); printf("OK_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -328,14 +434,20 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("RET_KEY 单击\n"); printf("RET_KEY 单击\n");
#endif /* PM_DEBUG */
tft_ret(); tft_ret();
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("RET_KEY 双击\n"); printf("RET_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("RET_KEY 长按\n"); printf("RET_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -346,13 +458,19 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("MR_KEY 单击\n"); printf("MR_KEY 单击\n");
#endif /* PM_DEBUG */
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("MR_KEY 双击\n"); printf("MR_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("MR_KEY 长按\n"); printf("MR_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -363,13 +481,19 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("MB_KEY 单击\n"); printf("MB_KEY 单击\n");
#endif /* PM_DEBUG */
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("MB_KEY 双击\n"); printf("MB_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("MB_KEY 长按\n"); printf("MB_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -380,13 +504,19 @@ static void plan_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("MUVB_KEY 单击\n"); printf("MUVB_KEY 单击\n");
#endif /* PM_DEBUG */
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("MUVB_KEY 双击\n"); printf("MUVB_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("MUVB_KEY 长按\n"); printf("MUVB_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -395,6 +525,11 @@ static void plan_key_func(void)
} }
/**
* manul_key_func() -
*
*
*/
static void manul_key_func(void) static void manul_key_func(void)
{ {
/* /*
@ -408,15 +543,21 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("UP_KEY 单击\n"); printf("UP_KEY 单击\n");
#endif /* PM_DEBUG */
orient_setspeed(0, ORIENT_LEFT, 100); orient_setspeed(0, ORIENT_LEFT, 100);
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("UP_KEY 双击\n"); printf("UP_KEY 双击\n");
#endif /* PM_DEBUG */
orient_setspeed(0, ORIENT_RIGHT, 100); orient_setspeed(0, ORIENT_RIGHT, 100);
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("UP_KEY 长按\n"); printf("UP_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -427,15 +568,21 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("DOWN_KEY 单击\n"); printf("DOWN_KEY 单击\n");
#endif /* PM_DEBUG */
orient_setspeed(1, ORIENT_LEFT, 100); orient_setspeed(1, ORIENT_LEFT, 100);
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("DOWN_KEY 双击\n"); printf("DOWN_KEY 双击\n");
#endif /* PM_DEBUG */
orient_setspeed(1, ORIENT_RIGHT, 100); orient_setspeed(1, ORIENT_RIGHT, 100);
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("DOWN_KEY 长按\n"); printf("DOWN_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -446,13 +593,19 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("OK_KEY 单击\n"); printf("OK_KEY 单击\n");
#endif /* PM_DEBUG */
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("OK_KEY 双击\n"); printf("OK_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("OK_KEY 长按\n"); printf("OK_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -463,15 +616,21 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("RET_KEY 单击\n"); printf("RET_KEY 单击\n");
#endif /* PM_DEBUG */
orient_setmode(0, MODE_MANUL); orient_setmode(0, MODE_MANUL);
orient_setmode(1, MODE_MANUL); orient_setmode(1, MODE_MANUL);
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("RET_KEY 双击\n"); printf("RET_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("RET_KEY 长按\n"); printf("RET_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -482,15 +641,21 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("MR_KEY 单击\n"); printf("MR_KEY 单击\n");
#endif /* PM_DEBUG */
mlgr = !mlgr; mlgr = !mlgr;
gpio_set(LGRED_PINX, mlgr == 1 ? LIGHT : NO_LIGHT); gpio_set(LGRED_PINX, mlgr == 1 ? LIGHT : NO_LIGHT);
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("MR_KEY 双击\n"); printf("MR_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("MR_KEY 长按\n"); printf("MR_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -501,15 +666,21 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("MB_KEY 单击\n"); printf("MB_KEY 单击\n");
#endif /* PM_DEBUG */
mlgb = !mlgb; mlgb = !mlgb;
gpio_set(LGBLUE_PINX, mlgb == 1 ? LIGHT : NO_LIGHT); gpio_set(LGBLUE_PINX, mlgb == 1 ? LIGHT : NO_LIGHT);
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("MB_KEY 双击\n"); printf("MB_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("MB_KEY 长按\n"); printf("MB_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;
@ -520,15 +691,21 @@ static void manul_key_func(void)
//printf("无键\n"); //printf("无键\n");
break; break;
case S_KEY: case S_KEY:
#ifdef PM_DEBUG
printf("MUVB_KEY 单击\n"); printf("MUVB_KEY 单击\n");
#endif /* PM_DEBUG */
mlguvb = !mlguvb; mlguvb = !mlguvb;
gpio_set(LGUVB_PINX, mlguvb == 1 ? LIGHT : NO_LIGHT); gpio_set(LGUVB_PINX, mlguvb == 1 ? LIGHT : NO_LIGHT);
break; break;
case D_KEY: case D_KEY:
#ifdef PM_DEBUG
printf("MUVB_KEY 双击\n"); printf("MUVB_KEY 双击\n");
#endif /* PM_DEBUG */
break; break;
case L_KEY: case L_KEY:
#ifdef PM_DEBUG
printf("MUVB_KEY 长按\n"); printf("MUVB_KEY 长按\n");
#endif /* PM_DEBUG */
break; break;
default: default:
break; break;

View file

@ -26,7 +26,8 @@ FLASH_SSD_CONFIG flashSSDConfig =
pFLASHCOMMANDSEQUENCE g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)0xFFFFFFFF; pFLASHCOMMANDSEQUENCE g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)0xFFFFFFFF;
uint16_t __ram_func[LAUNCH_CMD_SIZE/2]; /* array to copy __Launch_Command func to RAM */ /* array to copy __Launch_Command func to RAM */
uint16_t __ram_func[LAUNCH_CMD_SIZE/2];
void pm_flash_init(void) void pm_flash_init(void)
{ {
@ -64,13 +65,16 @@ void flash_write(uint8_t *saddr, uint16_t nbyte)
/* /*
* ²Á³ýÉÈÇø * ²Á³ýÉÈÇø
*/ */
dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(
flashSSDConfig.PFlashBlockSize
- USED_SECTOR_NUM * FTFx_PSECTOR_SIZE); - USED_SECTOR_NUM * FTFx_PSECTOR_SIZE);
while ((dest + BYTE2WORD(FTFx_PSECTOR_SIZE)) <= (flashSSDConfig.PFlashBlockBase while ((dest + BYTE2WORD(FTFx_PSECTOR_SIZE)) <=
(flashSSDConfig.PFlashBlockBase
+ BYTE2WORD(flashSSDConfig.PFlashBlockSize))) + BYTE2WORD(flashSSDConfig.PFlashBlockSize)))
{ {
size = FTFx_PSECTOR_SIZE; size = FTFx_PSECTOR_SIZE;
ret = FlashEraseSector(&flashSSDConfig, dest, size, g_FlashLaunchCommand); ret = FlashEraseSector(&flashSSDConfig, dest, size,
g_FlashLaunchCommand);
if (FTFx_OK != ret) if (FTFx_OK != ret)
{ {
ErrorTrap(ret); ErrorTrap(ret);
@ -80,7 +84,8 @@ void flash_write(uint8_t *saddr, uint16_t nbyte)
number = FTFx_PSECTOR_SIZE / PRD1SEC_ALIGN_SIZE; number = FTFx_PSECTOR_SIZE / PRD1SEC_ALIGN_SIZE;
for(uint8_t i = 0x0U; i < 0x2U; i++) for(uint8_t i = 0x0U; i < 0x2U; i++)
{ {
ret = FlashVerifySection(&flashSSDConfig, dest, number, i, g_FlashLaunchCommand); ret = FlashVerifySection(&flashSSDConfig, dest, number, i,
g_FlashLaunchCommand);
if (FTFx_OK != ret) if (FTFx_OK != ret)
{ {
ErrorTrap(ret); ErrorTrap(ret);
@ -92,7 +97,8 @@ void flash_write(uint8_t *saddr, uint16_t nbyte)
/* /*
* дÈëÊý¾Ý * дÈëÊý¾Ý
*/ */
dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(
flashSSDConfig.PFlashBlockSize
- (uint32_t)(USED_SECTOR_NUM * FTFx_PSECTOR_SIZE)); - (uint32_t)(USED_SECTOR_NUM * FTFx_PSECTOR_SIZE));
if ((dest + BYTE2WORD(size)) <= (flashSSDConfig.PFlashBlockBase if ((dest + BYTE2WORD(size)) <= (flashSSDConfig.PFlashBlockBase
@ -141,7 +147,8 @@ void flash_write(uint8_t *saddr, uint16_t nbyte)
*/ */
void flash_read(uint8_t *daddr, uint16_t nbyte) void flash_read(uint8_t *daddr, uint16_t nbyte)
{ {
uint8_t *saddr = (uint8_t *)(flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize uint8_t *saddr = (uint8_t *)(flashSSDConfig.PFlashBlockBase
+ BYTE2WORD(flashSSDConfig.PFlashBlockSize
- (uint32_t)(USED_SECTOR_NUM * FTFx_PSECTOR_SIZE))); - (uint32_t)(USED_SECTOR_NUM * FTFx_PSECTOR_SIZE)));
for (uint16_t i = 0; i < nbyte; i++) for (uint16_t i = 0; i < nbyte; i++)

View file

@ -8,7 +8,7 @@
#include "include/config.h" #include "include/config.h"
// 被维护的系统时间
static calendar_info system_time; static calendar_info system_time;
#define DAY_IN_YEAR(nyear) (is_leapyear(nyear) ? 366 : 365) #define DAY_IN_YEAR(nyear) (is_leapyear(nyear) ? 366 : 365)
@ -23,22 +23,59 @@ static const uint8_t day_noleap[] = {
/*
*
*/
static void ds1302_byte_write(uint8_t data); static void ds1302_byte_write(uint8_t data);
static uint8_t ds1302_byte_read(void); static uint8_t ds1302_byte_read(void);
static uint8_t ds1302_single_read(uint8_t addr); static uint8_t ds1302_single_read(uint8_t addr);
static uint8_t ds1302_single_read(uint8_t addr); void ds1302_single_write(uint8_t addr, uint8_t data);
static int16_t ymd_to_wday(int16_t year, int16_t month, int16_t mday); static int16_t ymd_to_wday(int16_t year, int16_t month, int16_t mday);
/**
* ds1302_init() - ds1302的初始化
*
* io的初始化以及当ds1302掉电时对其时间值设置初始值
*/
void ds1302_init(void)
{
//gpio_Interrupt_init(DS1302_CE_PINX, GPO, GPI_DISAB);
//gpio_Interrupt_init(DS1302_CLK_PINX, GPO, GPI_DISAB);
gpio_init(DS1302_CE_PINX, 1, 0);
gpio_init(DS1302_CLK_PINX, 1, 0);
gpio_Interrupt_init(DS1302_IO_PINX, GPI_UP_PF, GPI_DISAB);
// 使能写
ds1302_single_write(7, 0x00);
// 当ds1302掉电时设置时间初始值
if ((ds1302_single_read(0) & 0x80) == 1)
{
calendar_info sys_cal = { 0, 1, 2, 3, 4, 2012, 0, 1 };
ds1302_set_time(&sys_cal);
}
return;
}
/**
* is_leapyear() -
* @year:
*
* 10
*/
uint8_t is_leapyear(uint16_t year) uint8_t is_leapyear(uint16_t year)
{ {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
} }
/**
* get_month_days() -
* @year:
* @month:
*
*
*/
uint8_t get_month_days(uint16_t year, uint8_t month) uint8_t get_month_days(uint16_t year, uint8_t month)
{ {
switch (month) switch (month)
@ -58,6 +95,10 @@ uint8_t get_month_days(uint16_t year, uint8_t month)
} }
} }
/**
* ds1302_byte_write() - ds1302写入一个字节
* @data:
*/
static void ds1302_byte_write(uint8_t data) static void ds1302_byte_write(uint8_t data)
{ {
gpio_init(DS1302_IO_PINX, 1, 0); gpio_init(DS1302_IO_PINX, 1, 0);
@ -81,6 +122,11 @@ static void ds1302_byte_write(uint8_t data)
return; return;
} }
/**
* ds1302_byte_read() - ds1302读取一个字节
*
*
*/
static uint8_t ds1302_byte_read(void) static uint8_t ds1302_byte_read(void)
{ {
uint8_t data = 0; uint8_t data = 0;
@ -109,7 +155,12 @@ static uint8_t ds1302_byte_read(void)
/**
* ds1302_single_read() - ds1302在单字节模式下读取一个地址上的数据
* @addr:
*
*
*/
static uint8_t ds1302_single_read(uint8_t addr) static uint8_t ds1302_single_read(uint8_t addr)
{ {
uint8_t cmd = 0, uint8_t cmd = 0,
@ -135,6 +186,11 @@ static uint8_t ds1302_single_read(uint8_t addr)
return data; return data;
} }
/**
* ds1302_single_write() - ds1302的一个地址上写入一个字节的数据
* @addr:
* @data:
*/
void ds1302_single_write(uint8_t addr, uint8_t data) void ds1302_single_write(uint8_t addr, uint8_t data)
{ {
uint8_t cmd = 0; uint8_t cmd = 0;
@ -157,6 +213,10 @@ void ds1302_single_write(uint8_t addr, uint8_t data)
return; return;
} }
/**
* ds1302_set_time() - ds1302中写入时间
* @cal:
*/
void ds1302_set_time(calendar_info *cal) void ds1302_set_time(calendar_info *cal)
{ {
ds1302_single_write(7, 0x00); ds1302_single_write(7, 0x00);
@ -170,6 +230,10 @@ void ds1302_set_time(calendar_info *cal)
return; return;
} }
/**
* ds1302_read_time() - ds1302中读取时间
* @cal:
*/
void ds1302_read_time(calendar_info *cal) void ds1302_read_time(calendar_info *cal)
{ {
uint8_t rval; uint8_t rval;
@ -192,25 +256,9 @@ void ds1302_read_time(calendar_info *cal)
return; return;
} }
void ds1302_init(void) /**
{ * maintain_system_time() -
//gpio_Interrupt_init(DS1302_CE_PINX, GPO, GPI_DISAB); *
//gpio_Interrupt_init(DS1302_CLK_PINX, GPO, GPI_DISAB);
gpio_init(DS1302_CE_PINX, 1, 0);
gpio_init(DS1302_CLK_PINX, 1, 0);
gpio_Interrupt_init(DS1302_IO_PINX, GPI_UP_PF, GPI_DISAB);
ds1302_single_write(7, 0x00);
if ((ds1302_single_read(0) & 0x80) == 1)
{
calendar_info sys_cal = { 0, 1, 2, 3, 4, 2012, 0, 1 };
ds1302_set_time(&sys_cal);
}
return;
}
/*
* *
*/ */
void maintain_system_time(void) void maintain_system_time(void)
@ -221,6 +269,9 @@ void maintain_system_time(void)
return; return;
} }
/**
* get_system_time() -
*/
calendar_info get_system_time(void) calendar_info get_system_time(void)
{ {
return system_time; return system_time;
@ -228,9 +279,13 @@ calendar_info get_system_time(void)
/*************************************************************/
/**
* calendar_to_sec() -
* @cal:
*
*
*/
uint32_t calendar_to_sec(calendar_info *cal) uint32_t calendar_to_sec(calendar_info *cal)
{ {
uint32_t sec = cal->sec; uint32_t sec = cal->sec;
@ -264,6 +319,12 @@ uint32_t calendar_to_sec(calendar_info *cal)
return sec; return sec;
} }
/**
* sec_to_calendar() -
* @cal:
*
*
*/
calendar_info sec_to_calendar(uint32_t sec) calendar_info sec_to_calendar(uint32_t sec)
{ {
calendar_info cal; calendar_info cal;
@ -309,7 +370,14 @@ calendar_info sec_to_calendar(uint32_t sec)
return cal; return cal;
} }
/**
* ymd_to_wday() -
* @year:
* @month:
* @mday:
*
*
*/
static int16_t ymd_to_wday(int16_t year, int16_t month, int16_t mday) static int16_t ymd_to_wday(int16_t year, int16_t month, int16_t mday)
{ {
if (is_leapyear(year)) if (is_leapyear(year))

View file

@ -4,15 +4,16 @@
#include "include.h" #include "include.h"
#include "include/simulat_timer.h"
#include "include/config.h" #include "include/config.h"
#include "include/key.h" #include "include/key.h"
#include "include/simulat_timer.h"
static volatile st_register st_r[SIMULAT_TIMER_NUM]; static volatile st_register st_r[SIMULAT_TIMER_NUM];
/* /**
* st_init() - pit定时器 * st_init() - pit定时器
* *
* 1ms * 1ms
@ -27,7 +28,7 @@ void st_base_init(void)
} }
/* /**
* st_init() - * st_init() -
* @n: * @n:
* @st_m: * @st_m:
@ -58,7 +59,7 @@ uint8_t st_init(uint8_t n, st_mode st_m, uint32_t cmr_v)
} }
/* /**
* st_close() - * st_close() -
* @n: * @n:
*/ */
@ -68,7 +69,7 @@ void st_close(uint8_t n)
return; return;
} }
/* /**
* st_tcf() - tcf位返回 * st_tcf() - tcf位返回
* @n: * @n:
* *
@ -90,7 +91,7 @@ uint8_t st_tcf(uint8_t n)
return temp; return temp;
} }
/* /**
* st_tov() - tov位返回 * st_tov() - tov位返回
* @n: * @n:
* *
@ -111,7 +112,7 @@ uint8_t st_tov(uint8_t n)
return temp; return temp;
} }
/* /**
* st_count() - * st_count() -
* @n: * @n:
* *
@ -123,7 +124,7 @@ uint32_t st_count(uint8_t n)
} }
/* /**
* st_base() -N路定时器 * st_base() -N路定时器
* *
* *

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
[MainWindow] [MainWindow]
WindowPlacement=_ 125 87 1150 613 2 WindowPlacement=_ 139 121 1164 647 3