| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- /*
- * Copyright (c) 2006-2018, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2018-11-06 SummerGift first version
- */
- #define LOG_TAG "main" // 该模块对应的标签。不定义时,默认:NO_TAG
- #define LOG_LVL ELOG_LVL_WARN // ELOG_LVL_WARN // 该模块对应的日志输出级别。不定义时,默认:调试级别
- #include <ulog.h> // 必须在 LOG_TAG 与 LOG_LVL 下面
- #include <rtthread.h>
- #include <rtdevice.h>
- #include <board.h>
- #include "sys_config.h"
- #define uart1_rx GET_PIN(A, 10)
- /*生成带日期的版本号*/
- extern char *version_with_time(uint8_t option);
- /* defined the LED0 pin: PE9 */
- // #define SIM_ENABLE GET_PIN(E, 8)
- #define A720_power_PIN GET_PIN(E, 4) // 720供电控制脚
- #define REBOOT_PIN GET_PIN(E, 15) // 系统重启按键
- #define A720_POWERON GET_PIN(E, 9) // 720开机控制脚
- #define HIM_POWER_PIN GET_PIN(C, 8)
- void reboot_f(void *args);
- void air720_poweroff(void)
- {
- rt_pin_mode(A720_power_PIN, PIN_MODE_OUTPUT);
- rt_pin_write(A720_power_PIN, PIN_LOW);
- // rt_kprintf("air720_poweroff\n");
- }
- void air720_poweron(void)
- {
- // rt_thread_mdelay(1000);
- rt_pin_mode(A720_power_PIN, PIN_MODE_OUTPUT);
- rt_pin_write(A720_power_PIN, PIN_HIGH);
- // rt_kprintf("air720_poweron\n");
- }
- extern void touch_p(void);
- int main(void)
- {
- // rt_pin_mode(uart1_rx, PIN_MODE_INPUT_PULLUP);
- // rt_pin_write(uart1_rx, PIN_HIGH);
- rt_pin_mode(A720_POWERON, PIN_MODE_OUTPUT);
- // rt_pin_mode(SIM_ENABLE, PIN_MODE_OUTPUT);
- rt_pin_write(A720_POWERON, PIN_LOW); // 上电开机
- rt_kprintf("The current version of APP firmware is %s\r\n", version_with_time(1)); // APP_VERSION);
- // rt_pin_write(SIM_ENABLE, PIN_HIGH);
- // rt_pin_write(SIM_ENABLE, PIN_LOW);
- // rt_pin_write(A720_power_PIN, PIN_HIGH);
- /* 重启引脚为输出模式 */
- rt_pin_mode(REBOOT_PIN, PIN_MODE_INPUT_PULLUP);
- /* 默认高电平 */
- rt_pin_write(REBOOT_PIN, PIN_HIGH);
- char cnt = 0;
- while (1)
- {
- if (rt_pin_read(REBOOT_PIN) == 0)
- {
- touch_p();
- for(char a = 0 ; a < 31 ; a++)
- {
- if (rt_pin_read(REBOOT_PIN) == 0)
- {
- cnt++;
- }
- rt_thread_mdelay(10);
- }
- if(cnt >= 30)
- {
- rt_kprintf("system rebooting............\n\n");
- rt_hw_cpu_reset();
- }
- else
- {
- cnt = 0;
- }
- }
- rt_thread_mdelay(30);
- }
- return RT_EOK;
- }
- INIT_BOARD_EXPORT(air720_poweroff); // 为了实现重启4G模块断电
- INIT_DEVICE_EXPORT(air720_poweron); // 系统初始化后air720立即上电
- /**
- * Function ota_app_vtor_reconfig
- * Description Set Vector Table base location to the start addr of app(RT_APP_PART_ADDR).
- */
- // 修改中断向量表的跳转及地址
- static int ota_app_vtor_reconfig(void)
- {
- #define NVIC_VTOR_MASK 0x3FFFFF80
- #define RT_APP_PART_ADDR 0x8020000
- /* Set the Vector Table base location by user application firmware definition */
- SCB->VTOR = RT_APP_PART_ADDR & NVIC_VTOR_MASK;
- return 0;
- }
- INIT_BOARD_EXPORT(ota_app_vtor_reconfig);
- extern int HIM_POWER_CNT;
- extern rt_timer_t HIM_POWER_PIN_TIMER;
- void reboot_f(void *args)
- {
- log_w("system rebooting............");
- rt_hw_cpu_reset();
- }
- static void systerm_reboot_irq(void)
- {
- /* 重启引脚为输出模式 */
- rt_pin_mode(REBOOT_PIN, PIN_MODE_INPUT_PULLUP);
- /* 默认高电平 */
- rt_pin_write(REBOOT_PIN, PIN_HIGH);
- /* 绑定中断,下降沿模式,回调函数名为reboot */
- rt_pin_attach_irq(REBOOT_PIN, PIN_IRQ_MODE_FALLING, reboot_f, RT_NULL);
- /* 使能中断 */
- rt_pin_irq_enable(REBOOT_PIN, PIN_IRQ_ENABLE);
- }
- // INIT_PREV_EXPORT(systerm_reboot_irq);
- /* 导出到 msh 命令列表中 */
- MSH_CMD_EXPORT(systerm_reboot_irq, pin beep sample);
- /*
- {"element":[
- {"num":7, "sensor_addr":6, "start_reg":0,"count":1,"d_pos":0,"factor":-10, "d_length":1,"err_cnt":0,"online_flag":0,"value":0,"cName":"日 雨 量:", "units":"mm/d", "eName":"YPRECD2", "elem_type":"PRECA", "eValue":"0", "eKey":"e8 ", "eNum":"115", "dotled_s":"%s日 雨:%s%6smm "}
- ]
- }
- {
- "config": "ch_conf",
- "ext": {
- "App_mod": "0",
- "c0": "YTEMP01",
- "c1": "YHUMI00",
- "c2": "YSM01D0",
- "c3": "YWIND01",
- "c4": "YWDIR01",
- "c5": "YPRECD2",
- "c6": "YILLU00",
- "c7": "YSTEMD0",
- "c8": "YPRES00"
- }
- }
- */
|