Initial import of NFC GNSS SDK project
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configure variable
|
||||
#-------------------------------------------------------------------------------
|
||||
TOP_DIR:=$(TOP_DIR)
|
||||
ROOT_DIR:=$(TOP_DIR)/../..
|
||||
MAKEFILE_PATH :=$(subst $(strip \),/,$(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configure source code files
|
||||
#-------------------------------------------------------------------------------
|
||||
SRC_FILES+= \
|
||||
example_rtc.c \
|
||||
example_time.c \
|
||||
example_timer.c \
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# the include directories
|
||||
#-------------------------------------------------------------------------------
|
||||
INC_DIRS+= \
|
||||
-I${TOP_DIR}/ \
|
||||
-I${TOP_DIR}/common/include \
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configure compile flag for C
|
||||
#-------------------------------------------------------------------------------
|
||||
U_FLAGS:=
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configure compile flag for C++
|
||||
#-------------------------------------------------------------------------------
|
||||
U_CPPFLAGS:=
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configure default macro define
|
||||
#-------------------------------------------------------------------------------
|
||||
DFLAGS+= \
|
||||
-D__TM_ZONE=tm_zone \
|
||||
-D__TM_GMTOFF=tm_gmtoff \
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Configure link library
|
||||
#-------------------------------------------------------------------------------
|
||||
U_LIBS:=
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# include mk file
|
||||
#-------------------------------------------------------------------------------
|
||||
include ${TOP_DIR}/config/common/makefile.mk
|
||||
@@ -0,0 +1,134 @@
|
||||
/*================================================================
|
||||
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
||||
Quectel Wireless Solutions Proprietary and Confidential.
|
||||
=================================================================*/
|
||||
/* example_rtc: we just use APP_OFFSET, and SYS_OFFSET is not used, but we can set it in quec_rtc.c*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ql_rtos.h"
|
||||
#include "ql_type.h"
|
||||
#include "ql_application.h"
|
||||
#include "ql_rtc.h"
|
||||
|
||||
|
||||
const char * week_days[] =
|
||||
{
|
||||
"SUN","MON","TUS","WED","THU","FRI","SAT"
|
||||
};
|
||||
|
||||
#define weekday_to_string(a) (week_days[(a)])
|
||||
void ql_rtc_print_time(ql_rtc_time_t *tmp)
|
||||
{
|
||||
if(tmp->tm_wday > 6 || tmp->tm_wday < 0)
|
||||
{
|
||||
tmp->tm_wday = 0;
|
||||
}
|
||||
|
||||
printf("%d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d [%s]\r\n",
|
||||
tmp->tm_year,
|
||||
tmp->tm_mon,
|
||||
tmp->tm_mday,
|
||||
tmp->tm_hour,
|
||||
tmp->tm_min,
|
||||
tmp->tm_sec,
|
||||
weekday_to_string(tmp->tm_wday));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 当开机注网后,NITZ会自动将时间更新到RTC
|
||||
static void ql_rtc_sync_test(void * argv)
|
||||
{
|
||||
unsigned int t1 = 0, t2 = 0;
|
||||
ql_rtc_time_t tm = {0};
|
||||
ql_rtc_get_time(&tm);
|
||||
ql_rtos_task_sleep_s(8);
|
||||
printf("enter rtc api test!! \n");
|
||||
|
||||
|
||||
/* test rtc ticks */
|
||||
t1 = ql_rtc_get_ticks();
|
||||
ql_rtos_task_sleep_ms(100);
|
||||
t2 = ql_rtc_get_ticks();
|
||||
printf("ql_rtc_get_ticks, t1:%d, t2:%d, t2-t1:%d! time=%d ms \r\n", t1, t2, t2-t1,1000*(t2-t1)/32768);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ql_rtc_get_time(&tm);
|
||||
printf("=========print current net time===========\r\n");
|
||||
ql_rtc_print_time(&tm);
|
||||
ql_rtos_task_sleep_s(2);
|
||||
}
|
||||
}
|
||||
|
||||
//application_init(ql_rtc_sync_test, "ql_rtc_sync_test", 2, 10);
|
||||
|
||||
|
||||
void ql_rtc_test_callback(void)
|
||||
{
|
||||
ql_rtc_time_t test_tm = {0};
|
||||
|
||||
//test alarm expired
|
||||
printf("[%s] \r\n",__func__);
|
||||
//disable RTC alarm
|
||||
ql_rtc_enable_alarm(0);
|
||||
//get alarm time
|
||||
printf("=========print alarm time===========\r\n");
|
||||
ql_rtc_get_alarm(&test_tm);
|
||||
ql_rtc_print_time(&test_tm);
|
||||
|
||||
test_tm.tm_min += 1;
|
||||
ql_rtc_set_alarm(&test_tm);
|
||||
printf("=========print open system alarm time===========\r\n");
|
||||
ql_rtc_print_time(&test_tm);
|
||||
ql_rtc_enable_alarm(1);
|
||||
ql_powerdown_rtc_in_work(1); //增加此接口,关机后,LDO5给rtc供电,解决关机后,开不了机
|
||||
ql_power_down(1); //power off system //manual plug-out usb , to avoid EXTON_WU
|
||||
//wait for RTC_ALARM_WU after 3min
|
||||
|
||||
}
|
||||
|
||||
/*The test for set time */
|
||||
static void ql_rtc_set_test(void * argv)
|
||||
{
|
||||
unsigned int t1 = 0, t2 = 0;
|
||||
ql_rtc_time_t tm = {0};
|
||||
// ql_rtc_get_time(&tm);
|
||||
ql_rtos_task_sleep_s(4);
|
||||
printf("enter rtc api set test!! \n");
|
||||
|
||||
//2058-2-2 02:02:02 []
|
||||
tm.tm_sec = 2;
|
||||
tm.tm_min = 2;
|
||||
tm.tm_hour = 2;
|
||||
tm.tm_mday = 2;
|
||||
tm.tm_mon = 2;
|
||||
tm.tm_year = 2018;
|
||||
tm.tm_wday = 5;
|
||||
ql_rtc_set_time(&tm);
|
||||
|
||||
//set alarm
|
||||
tm.tm_sec += 20;
|
||||
ql_rtc_set_alarm(&tm);
|
||||
|
||||
ql_rtc_get_alarm(&tm);
|
||||
ql_rtc_print_time(&tm);
|
||||
|
||||
//init callback , once alarm expire callback would be invoke
|
||||
ql_rtc_register_cb(ql_rtc_test_callback);
|
||||
|
||||
//enable RTC alarm
|
||||
ql_rtc_enable_alarm(1);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ql_rtc_get_time(&tm);
|
||||
printf("=========print current time===========\r\n");
|
||||
ql_rtc_print_time(&tm);
|
||||
ql_rtos_task_sleep_s(2);
|
||||
}
|
||||
}
|
||||
|
||||
// application_init(ql_rtc_set_test, "ql_rtc_set_test", 2, 10);
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*================================================================
|
||||
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
||||
Quectel Wireless Solutions Proprietary and Confidential.
|
||||
=================================================================*/
|
||||
|
||||
#include "ql_application.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void time_test(void * argv)
|
||||
{
|
||||
struct tm *tm_ptr = NULL;
|
||||
time_t _time = 0x00000001;
|
||||
struct timeval tv = {0};
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
printf("tv_sec: %d\r\n", tv.tv_sec);
|
||||
printf("tv_usec: %d\r\n", tv.tv_usec);
|
||||
|
||||
_time = time(NULL);
|
||||
printf("seconds: %d\r\n", _time);
|
||||
|
||||
tm_ptr =ql_localtime(&_time);
|
||||
printf("year: %d\r\n", tm_ptr->tm_year);
|
||||
printf("mont: %d\r\n", tm_ptr->tm_mon);
|
||||
printf("mday: %d\r\n", tm_ptr->tm_mday);
|
||||
printf("wday: %d\r\n", tm_ptr->tm_wday);
|
||||
printf("hour: %d\r\n", tm_ptr->tm_hour);
|
||||
printf("minu: %d\r\n", tm_ptr->tm_min);
|
||||
printf("seco: %d\r\n", tm_ptr->tm_sec);
|
||||
|
||||
struct tm now_time;
|
||||
ql_localtime_r(&_time,&now_time);
|
||||
printf("year: %d\r\n", now_time.tm_year);
|
||||
printf("mont: %d\r\n", now_time.tm_mon);
|
||||
printf("mday: %d\r\n", now_time.tm_mday);
|
||||
printf("wday: %d\r\n", now_time.tm_wday);
|
||||
printf("hour: %d\r\n", now_time.tm_hour);
|
||||
printf("minu: %d\r\n", now_time.tm_min);
|
||||
printf("seco: %d\r\n", now_time.tm_sec);
|
||||
|
||||
tm_ptr = gmtime(&_time);
|
||||
printf("year: %d\r\n", tm_ptr->tm_year);
|
||||
printf("mont: %d\r\n", tm_ptr->tm_mon);
|
||||
printf("mday: %d\r\n", tm_ptr->tm_mday);
|
||||
printf("wday: %d\r\n", tm_ptr->tm_wday);
|
||||
printf("hour: %d\r\n", tm_ptr->tm_hour);
|
||||
printf("minu: %d\r\n", tm_ptr->tm_min);
|
||||
printf("seco: %d\r\n", tm_ptr->tm_sec);
|
||||
}
|
||||
|
||||
//application_init(time_test, "time_test", 1, 1);
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*================================================================
|
||||
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
||||
Quectel Wireless Solutions Proprietary and Confidential.
|
||||
=================================================================*/
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file example_timer.c
|
||||
* @author Juson.zhang
|
||||
* @version V1.0.0
|
||||
* @date 2020/04/02
|
||||
* @brief This file tests timer's APIs
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ql_rtos.h"
|
||||
#include "ql_type.h"
|
||||
#include "ql_application.h"
|
||||
#include "ql_timer.h"
|
||||
#include "ql_log.h"
|
||||
#include "ql_uart.h"
|
||||
|
||||
|
||||
#define test_log(fmt, args...) printf(fmt, ##args)
|
||||
static ql_timer_t quec_task_timer = NULL;
|
||||
void ql_task_test_cb(unsigned int param)
|
||||
{
|
||||
test_log("quectel,%s\n",param);
|
||||
ql_norflash_do_erase("fota_param",0x00801A4000,0x6000);
|
||||
}
|
||||
|
||||
|
||||
static void quec_task_timer_test(void * argv)
|
||||
{
|
||||
ql_debug_log_enable();
|
||||
ql_task_timer_create(&quec_task_timer);
|
||||
ql_task_timer_start(quec_task_timer, 1000,1, ql_task_test_cb,"quec_task_timer");
|
||||
while (1) {
|
||||
ql_rtos_task_sleep_s(3);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int g_timer_cnt = 0;
|
||||
void ql_Acctimer_test_cb(unsigned int param)
|
||||
{
|
||||
g_timer_cnt++;
|
||||
}
|
||||
|
||||
static void quec_timer_test(void * argv)
|
||||
{
|
||||
int timer_id = 0;
|
||||
timer_id = ql_start_Acctimer(QL_TIMER_PERIOD, 1000, ql_Acctimer_test_cb, 0);
|
||||
test_log("timer_id=%d \n", timer_id);
|
||||
|
||||
while (1) {
|
||||
test_log("test 1ms timer, g_timer_cnt=%d \n", g_timer_cnt);
|
||||
ql_rtos_task_sleep_s(1);
|
||||
}
|
||||
}
|
||||
|
||||
static ql_timer_t quec_rtos_timer = NULL;
|
||||
static unsigned int rtos_timer_cnt = 0;
|
||||
void ql_rtos_timer_test_cb(unsigned int param)
|
||||
{
|
||||
rtos_timer_cnt++;
|
||||
}
|
||||
|
||||
static void quec_rtos_timer_test(void * argv)
|
||||
{
|
||||
ql_debug_log_enable();
|
||||
ql_rtos_timer_create(&quec_rtos_timer);
|
||||
ql_rtos_timer_start(quec_rtos_timer, 1000,1, ql_rtos_timer_test_cb,NULL);
|
||||
while (1) {
|
||||
test_log("test 1ms timer, rtos_timer_cnt=%d \n", rtos_timer_cnt);
|
||||
ql_rtos_task_sleep_s(1);
|
||||
}
|
||||
}
|
||||
|
||||
//application_init(quec_timer_test, "quec_timer_test", 2, 0);//硬件定时器
|
||||
//application_init(quec_rtos_timer_test, "quec_rtos_timer_test", 2, 0);//软件定时器,回调内不能执行延迟操作
|
||||
//application_init(quec_task_timer_test, "quec_task_timer_test", 2, 0);//task_timer软件定时器,回调内可执行延迟操作
|
||||
|
||||
|
||||
Reference in New Issue
Block a user