解决了一些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

View file

@ -1,58 +1,40 @@
/* key.h - 监测并采集按键的输入
*
* 使10ms采集一次io状态来实现的
*/
#ifndef KEY_H
#define KEY_H
typedef enum key_mean_
{
N_KEY = 0, S_KEY, D_KEY, L_KEY
} key_mean;
/*
* key_type -
*/
typedef enum key_type_
{
UP_KEY = 0, DOWN_KEY, OK_KEY, RET_KEY, AMS_KEY, WIFI_KEY, MR_KEY, MB_KEY, MUVB_KEY
} key_type;
/*
* key_init() -
*
*/
void key_init(void);
/*
* key_detect() -
*
* 10ms调用一次
*/
void key_detect(void);
/*
* get_key_mean() -
*
* N_KEY
*/
key_mean get_key_mean(key_type key_t);
void clear_key_m(void);
#endif // KEY_H
/* key.h - 监测并采集按键的输入
*
* 使10ms采集一次io状态来实现的
*/
#ifndef KEY_H
#define KEY_H
/*
* key_mean -
* N_KEY表示无键按下状态S_KEY表示单击D_KEY表示双击L_KEY表示长按
*/
typedef enum key_mean_
{
N_KEY = 0, S_KEY, D_KEY, L_KEY
} key_mean;
/*
* key_type -
*/
typedef enum key_type_
{
UP_KEY = 0, DOWN_KEY, OK_KEY, RET_KEY, AMS_KEY, WIFI_KEY, MR_KEY, MB_KEY, MUVB_KEY
} key_type;
void key_init(void);
void key_detect(void);
key_mean get_key_mean(key_type key_t);
void clear_key_m(void);
#endif // KEY_H

View file

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

View file

@ -1,38 +1,34 @@
/*
* time.h -
*/
#include <stdint.h>
typedef struct calendar_info_
{
uint8_t sec;
uint8_t min;
uint8_t hour;
uint8_t mday;
uint8_t month;
uint16_t year;
uint8_t wday;
uint16_t yday;
} calendar_info;
enum { START_YEAR = 2000, SEC_IN_DAY = 24 * 60 * 60};
uint8_t is_leapyear(uint16_t year);
uint8_t get_month_days(uint16_t year, uint8_t month);
void ds1302_init(void);
void ds1302_set_time(calendar_info *cal);
void ds1302_read_time(calendar_info *cal);
void maintain_system_time(void);
calendar_info get_system_time(void);
uint32_t calendar_to_sec(calendar_info *cal);
calendar_info sec_to_calendar(uint32_t sec);
/*
* time.h -
*/
#include <stdint.h>
/*
* calendar_info -
*/
typedef struct calendar_info_
{
uint8_t sec;
uint8_t min;
uint8_t hour;
uint8_t mday;
uint8_t month;
uint16_t year;
uint8_t wday;
uint16_t yday;
} calendar_info;
// START_YEAR为计算日历时间时的起始时间
enum { START_YEAR = 2000, SEC_IN_DAY = 24 * 60 * 60};
uint8_t is_leapyear(uint16_t year);
uint8_t get_month_days(uint16_t year, uint8_t month);
void ds1302_init(void);
void ds1302_set_time(calendar_info *cal);
void ds1302_read_time(calendar_info *cal);
void maintain_system_time(void);
calendar_info get_system_time(void);
uint32_t calendar_to_sec(calendar_info *cal);
calendar_info sec_to_calendar(uint32_t sec);

View file

@ -1,107 +1,52 @@
/*
* simulat_timer.h -
*/
#ifndef SIMULAT_TIMER_H
#define SIMULAT_TIMER_H
#include <stdint.h>
/*
*
*/
#define SIMULAT_TIMER_NUM 5
typedef struct st_register_
{
uint32_t count; // 定时器计数
uint32_t cmr; // 比较寄存器
struct
{
uint8_t ten : 1; // 使能标志
uint8_t tov : 1; // 溢出标志
uint8_t tfc : 1; // 自由运行标志
uint8_t tcf : 1; // 比较标志
} flag;
} st_register;
typedef enum st_mode_
{
COMPARE = 0,
NO_COMPARE
} st_mode;
/*
* st_init() - pit定时器
*
* 1ms
*/
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);
/*
* st_close() -
* @n:
*/
void st_close(uint8_t n);
/*
* st_tcf() - tcf位返回
* @n:
*
* 01
*/
uint8_t st_tcf(uint8_t n);
/*
* st_tov() - tov位返回
* @n:
*
* 01
*/
uint8_t st_tov(uint8_t n);
/*
* st_count() -
* @n:
*
*
*/
uint32_t st_count(uint8_t n);
/********************ISR******************/
/*
* st_base() -N路定时器
*
*
*/
void st_base(void);
#endif /* SIMULAT_TIMER_H */
/*
* simulat_timer.h -
*/
#ifndef SIMULAT_TIMER_H
#define SIMULAT_TIMER_H
#include <stdint.h>
/*
*
*/
#define SIMULAT_TIMER_NUM 5
typedef struct st_register_
{
uint32_t count; // 定时器计数
uint32_t cmr; // 比较寄存器
struct
{
uint8_t ten : 1; // 使能标志
uint8_t tov : 1; // 溢出标志
uint8_t tfc : 1; // 自由运行标志
uint8_t tcf : 1; // 比较标志
} flag;
} st_register;
typedef enum st_mode_
{
COMPARE = 0,
NO_COMPARE
} st_mode;
void st_base_init(void);
uint8_t st_init(uint8_t n, st_mode st_m, uint32_t cmr_v);
void st_close(uint8_t n);
uint8_t st_tcf(uint8_t n);
uint8_t st_tov(uint8_t n);
uint32_t st_count(uint8_t n);
void st_base(void);
#endif /* SIMULAT_TIMER_H */

View file

@ -1,43 +1,42 @@
/*
* tft.h - tft½Ó¿Ú
*/
#ifndef TFT_H
#define TFT_H
typedef struct input_limit_
{
int16_t max;
int16_t min;
} input_limit;
void tft_init(void);
void tft_send_cmd(const char *cmd);
void tft_left(void);
void tft_right(void);
void tft_up(void);
void tft_down(void);
void tft_ok(void);
void tft_ret(void);
void tft_page_refresh(void);
int16_t *get_value_of_kvp(char *name, uint8_t objn);
input_limit tft_input_limit(char *name);
//const kv_pair *get_plan_data(uint8_t objn)[][PLAN_DATA_NUM];
#endif /* TFT_H */
/*
* tft.h - tft½Ó¿Ú
*/
#ifndef TFT_H
#define TFT_H
typedef struct input_limit_
{
int16_t max;
int16_t min;
} input_limit;
void tft_init(void);
void tft_send_cmd(const char *cmd);
void tft_left(void);
void tft_right(void);
void tft_up(void);
void tft_down(void);
void tft_ok(void);
void tft_ret(void);
void tft_page_refresh(void);
int16_t *get_value_of_kvp(char *name, uint8_t objn);
input_limit tft_input_limit(char *name);
#endif /* TFT_H */

View file

@ -1,41 +1,48 @@
/*
* tft_handle_internal.h - tft和plan_handle模块共同使用部分的内部声明
*
* tft和plan_handle模块
*/
#include "include/pm_time.h"
typedef struct plan_input_
{
calendar_info bg_t;
calendar_info ed_t;
calendar_info pd_t;
uint8_t x_orient;
uint8_t y_orient;
uint8_t lg_r : 1;
uint8_t lg_b : 1;
uint8_t lg_uvb : 1;
uint8_t water : 1;
uint8_t sw : 1;
uint8_t cnt;
} plan_input;
typedef struct kv_pair_
{
char *key;
int16_t value;
int8_t attr;
} kv_pair;
enum { PLAN_DATA_NUM = 19 };
extern plan_input plan_in[PLAN_DATA_NUM];
extern kv_pair kvp_obj_set[][PLAN_DATA_NUM];
void tft_to_plan_input(uint8_t objn);
/*
* tft_handle_internal.h - tft和plan_handle模块共同使用部分的内部声明
*
* tft和plan_handle模块
*/
#include "include/pm_time.h"
/*
* plan_input -
*
*/
typedef struct plan_input_
{
calendar_info bg_t; // 开始时间
calendar_info ed_t; // 结束时间
calendar_info pd_t; // 周期时长
uint8_t x_orient; // x方向值未使用
uint8_t y_orient; // y方向值未使用
uint8_t lg_r : 1; // 红灯
uint8_t lg_b : 1; // 蓝灯
uint8_t lg_uvb : 1; // uvb
uint8_t water : 1; // 浇水,未使用
uint8_t sw : 1; // 是否加入计划
uint8_t cnt; // 完成次数
} plan_input;
/*
* kv_pair -
* key为存储元素ID的字符串value为一个整形值attr为元素属性
*/
typedef struct kv_pair_
{
char *key;
int16_t value;
int8_t attr;
} kv_pair;
enum { PLAN_DATA_NUM = 19, OBJ_NUM = 8 };
extern plan_input plan_in[OBJ_NUM];
extern kv_pair kvp_obj_set[][PLAN_DATA_NUM];
void tft_to_plan_input(uint8_t objn);

View file

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