Compare commits
No commits in common. "cd851cf044284263c2ad591d389292e0147e6db7" and "fe879e300a02fc64b1611370c91d9300e7f74e53" have entirely different histories.
cd851cf044
...
fe879e300a
@ -1,6 +1,5 @@
|
|||||||
#include "app_utils.h"
|
#include "app_utils.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "utils.h"
|
|
||||||
#include "wm_crypto_hard.h"
|
#include "wm_crypto_hard.h"
|
||||||
|
|
||||||
static uint32_t millis_cnt = 0;
|
static uint32_t millis_cnt = 0;
|
||||||
@ -74,37 +73,4 @@ uint32_t random_gen_6_digit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return output_num;
|
return output_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
void time_date_to_tm(const char *time_date, struct tm *time)
|
|
||||||
{
|
|
||||||
if(!time_date) return;
|
|
||||||
|
|
||||||
/* Months are on three letters :
|
|
||||||
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
|
|
||||||
*/
|
|
||||||
const char *MONTHS[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
|
||||||
const unsigned long int MONTHS_CNT = sizeof(MONTHS)/sizeof(*MONTHS);
|
|
||||||
char month[4];
|
|
||||||
time->tm_mon = 0;
|
|
||||||
|
|
||||||
sscanf(time_date, "%d:%d:%d %s %d %d",
|
|
||||||
&time->tm_hour,
|
|
||||||
&time->tm_min,
|
|
||||||
&time->tm_sec,
|
|
||||||
month,
|
|
||||||
&time->tm_mday,
|
|
||||||
&time->tm_year);
|
|
||||||
|
|
||||||
for(unsigned long int i = 0; i < MONTHS_CNT; i++)
|
|
||||||
{
|
|
||||||
if(strcasecmp(MONTHS[i], month) == 0)
|
|
||||||
{
|
|
||||||
time->tm_mon = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust year value
|
|
||||||
time->tm_year -= 1900;
|
|
||||||
}
|
|
@ -13,13 +13,4 @@ void ms_delay(uint32_t ms);
|
|||||||
|
|
||||||
uint32_t random_gen_6_digit(void);
|
uint32_t random_gen_6_digit(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Function parsing a string having format : __TIME__" "__DATE__
|
|
||||||
* and filling the given struct tm accordingly.
|
|
||||||
*
|
|
||||||
* @param time_date a string having the proper time and date format
|
|
||||||
* @param time a pointer to the struct tm to fill
|
|
||||||
*/
|
|
||||||
void time_date_to_tm(const char *time_date, struct tm *time);
|
|
||||||
|
|
||||||
#endif //APP_UTILS_H
|
#endif //APP_UTILS_H
|
@ -696,7 +696,6 @@ static int ble_gap_event_cb(struct ble_gap_event *event, void *arg)
|
|||||||
if((status = ble_gap_conn_find(event->connect.conn_handle, &desc)) == BLE_HS_ENOERR)
|
if((status = ble_gap_conn_find(event->connect.conn_handle, &desc)) == BLE_HS_ENOERR)
|
||||||
{
|
{
|
||||||
print_conn_desc(&desc);
|
print_conn_desc(&desc);
|
||||||
TLS_BT_APPL_TRACE_VERBOSE("ble_gap_security_initiate %s"NEW_LINE, tls_bt_rc_2_str(ble_gap_security_initiate(ble_device_conn_handle)));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -165,15 +165,6 @@ void user_main(void *param)
|
|||||||
u8 tmr_millis_id = tls_timer_create(&tmr_millis);
|
u8 tmr_millis_id = tls_timer_create(&tmr_millis);
|
||||||
tls_timer_start(tmr_millis_id);
|
tls_timer_start(tmr_millis_id);
|
||||||
|
|
||||||
//Let's start the RTC if not already running
|
|
||||||
if(!tls_is_rtc_running())
|
|
||||||
{
|
|
||||||
shell_printf("Starting RTC"NEW_LINE);
|
|
||||||
struct tm curr_time;
|
|
||||||
time_date_to_tm(__TIME__" "__DATE__, &curr_time);
|
|
||||||
tls_set_rtc(&curr_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
//We create a task for the nano_shell process
|
//We create a task for the nano_shell process
|
||||||
u8 *nano_shell_task_stack = NULL, *nano_shell_server_task_stack = NULL;
|
u8 *nano_shell_task_stack = NULL, *nano_shell_server_task_stack = NULL;
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ static void tls_rtc_irq_cb(void *arg)
|
|||||||
rtc_time.tm_sec,
|
rtc_time.tm_sec,
|
||||||
rtc_time.tm_mday,
|
rtc_time.tm_mday,
|
||||||
rtc_time.tm_mon,
|
rtc_time.tm_mon,
|
||||||
rtc_time.tm_year + 1900);
|
rtc_time.tm_year);
|
||||||
|
|
||||||
tls_rtc_timer_stop();
|
tls_rtc_timer_stop();
|
||||||
}
|
}
|
||||||
@ -582,8 +582,6 @@ int _pmu(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
|
|
||||||
int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
bool cmd_found = true;
|
|
||||||
|
|
||||||
if(argc > 1)
|
if(argc > 1)
|
||||||
{
|
{
|
||||||
if(strcmp(argv[1], "get") == 0)
|
if(strcmp(argv[1], "get") == 0)
|
||||||
@ -597,7 +595,7 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
rtc_time.tm_sec,
|
rtc_time.tm_sec,
|
||||||
rtc_time.tm_mday,
|
rtc_time.tm_mday,
|
||||||
rtc_time.tm_mon,
|
rtc_time.tm_mon,
|
||||||
rtc_time.tm_year + 1900);
|
rtc_time.tm_year);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[1], "set") == 0)
|
else if(strcmp(argv[1], "set") == 0)
|
||||||
{
|
{
|
||||||
@ -618,8 +616,6 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
rtc_time.tm_mon,
|
rtc_time.tm_mon,
|
||||||
rtc_time.tm_year);
|
rtc_time.tm_year);
|
||||||
|
|
||||||
rtc_time.tm_year -= 1900;
|
|
||||||
|
|
||||||
tls_set_rtc(&rtc_time);
|
tls_set_rtc(&rtc_time);
|
||||||
tls_rtc_isr_register(&(tls_rtc_irq_cb), NULL);
|
tls_rtc_isr_register(&(tls_rtc_irq_cb), NULL);
|
||||||
}
|
}
|
||||||
@ -642,26 +638,17 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
rtc_time.tm_mon,
|
rtc_time.tm_mon,
|
||||||
rtc_time.tm_year);
|
rtc_time.tm_year);
|
||||||
|
|
||||||
rtc_time.tm_year -= 1900;
|
|
||||||
|
|
||||||
tls_rtc_timer_start(&(rtc_time));
|
tls_rtc_timer_start(&(rtc_time));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shell_printf("Unknown %s action"NEW_LINE, argv[0]);
|
shell_printf("Unknown %s action"NEW_LINE, argv[0]);
|
||||||
cmd_found = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
cmd_found = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!cmd_found)
|
|
||||||
{
|
{
|
||||||
shell_printf("List of rtc actions :"NEW_LINE"get"NEW_LINE"set <h> <m> <s> <d> <m> <y>"NEW_LINE"alarm <h> <m> <s> <d> <m> <y>"NEW_LINE);
|
shell_printf("List of rtc actions :"NEW_LINE"get"NEW_LINE"set <h> <m> <s> <d> <m> <y>"NEW_LINE"alarm <h> <m> <s> <d> <m> <y>"NEW_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -986,136 +973,6 @@ int _utils(const shell_cmd_t *pcmd, int argc, char *const argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tls_os_task_t task_handle = NULL;
|
|
||||||
u8 *task_stack = NULL;
|
|
||||||
#define TASK_STK_SIZE (256)
|
|
||||||
void task_function(void *param)
|
|
||||||
{
|
|
||||||
(void)param;
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
char *notification_data = (char *)ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
|
||||||
shell_printf("%s got notification : #%s#"NEW_LINE, __func__, notification_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void task_free_function(void)
|
|
||||||
{
|
|
||||||
task_handle = NULL;
|
|
||||||
tls_mem_free(task_stack);
|
|
||||||
task_stack = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _freertos(const shell_cmd_t *pcmd, int argc, char * const argv[])
|
|
||||||
{
|
|
||||||
bool cmd_found = true;
|
|
||||||
|
|
||||||
if(argc > 1)
|
|
||||||
{
|
|
||||||
if(strcmp(argv[1], "task") == 0)
|
|
||||||
{
|
|
||||||
if(argc > 2)
|
|
||||||
{
|
|
||||||
if(strcmp(argv[2], "create") == 0)
|
|
||||||
{
|
|
||||||
if(task_handle == NULL)
|
|
||||||
{
|
|
||||||
task_stack = tls_mem_alloc(TASK_STK_SIZE * sizeof(StackType_t));
|
|
||||||
if(task_stack)
|
|
||||||
{
|
|
||||||
if(tls_os_task_create(&task_handle, "demo_task", &(task_function), NULL, task_stack, TASK_STK_SIZE * sizeof(StackType_t), 62, 0) == TLS_OS_SUCCESS)
|
|
||||||
{
|
|
||||||
shell_printf("Task created"NEW_LINE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell_printf("Failed to create task"NEW_LINE);
|
|
||||||
tls_mem_free(task_stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell_printf("Failed to allocate task stack"NEW_LINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell_printf("Task already created"NEW_LINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(strcmp(argv[2], "destroy") == 0)
|
|
||||||
{
|
|
||||||
if(task_handle)
|
|
||||||
{
|
|
||||||
if(tls_os_task_del_by_task_handle(task_handle, &(task_free_function)) == TLS_OS_SUCCESS)
|
|
||||||
{
|
|
||||||
shell_printf("Task deleted"NEW_LINE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell_printf("Failed to delete task"NEW_LINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("No task to destroy"NEW_LINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(strcmp(argv[2], "notify") == 0)
|
|
||||||
{
|
|
||||||
if(argc > 3)
|
|
||||||
{
|
|
||||||
if(task_handle)
|
|
||||||
{
|
|
||||||
if(xTaskNotify(task_handle, (uint32_t)argv[3], eSetValueWithoutOverwrite) == pdFAIL)
|
|
||||||
{
|
|
||||||
shell_printf("Failed to notify task"NEW_LINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell_printf("No task to notify"NEW_LINE
|
|
||||||
"Use: freertos task create, to start the task"NEW_LINE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd_found = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd_found = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd_found = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd_found = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shell_printf("Unknown %s action"NEW_LINE, argv[0]);
|
|
||||||
cmd_found = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!cmd_found)
|
|
||||||
{
|
|
||||||
shell_printf("List of %s actions :"NEW_LINE
|
|
||||||
"task create"NEW_LINE
|
|
||||||
"task destroy"NEW_LINE
|
|
||||||
"task notify \"msg\""NEW_LINE, argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
NANO_SHELL_ADD_CMD(bus,
|
NANO_SHELL_ADD_CMD(bus,
|
||||||
_bus,
|
_bus,
|
||||||
"Command to interact with the SPI bus",
|
"Command to interact with the SPI bus",
|
||||||
@ -1172,8 +1029,3 @@ NANO_SHELL_ADD_CMD(utils,
|
|||||||
_utils,
|
_utils,
|
||||||
"Command used to test various utils functions",
|
"Command used to test various utils functions",
|
||||||
" Use this command to try various utility functions out lilke random and more"NEW_LINE);
|
" Use this command to try various utility functions out lilke random and more"NEW_LINE);
|
||||||
|
|
||||||
NANO_SHELL_ADD_CMD(freertos,
|
|
||||||
_freertos,
|
|
||||||
"Command to test various FreeRTOS concepts",
|
|
||||||
" Use this command to interact with various FreeRTOS concepts (tasks, queues, notifications...)"NEW_LINE);
|
|
||||||
|
@ -58,16 +58,6 @@ void tls_set_rtc(struct tm *tblock);
|
|||||||
*/
|
*/
|
||||||
void tls_get_rtc(struct tm *tblock);
|
void tls_get_rtc(struct tm *tblock);
|
||||||
|
|
||||||
/** NOT PART OF THE OFFICIAL SDK **/
|
|
||||||
/**
|
|
||||||
* @brief Checks if the RTC peripheral is running or not
|
|
||||||
*
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool tls_is_rtc_running(void);
|
|
||||||
/**********************************/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is used to register pmu rtc interrupt
|
* @brief This function is used to register pmu rtc interrupt
|
||||||
*
|
*
|
||||||
|
@ -772,8 +772,6 @@ tls_os_status_t tls_os_queue_flush(tls_os_queue_t *queue);
|
|||||||
*/
|
*/
|
||||||
void tls_os_time_delay(u32 ticks);
|
void tls_os_time_delay(u32 ticks);
|
||||||
|
|
||||||
void tls_os_time_delay_until(u32 * const previous_wake_time, const u32 duration_in_ticks);
|
|
||||||
|
|
||||||
u8 tls_os_timer_active(tls_os_timer_t *timer);
|
u8 tls_os_timer_active(tls_os_timer_t *timer);
|
||||||
|
|
||||||
u32 tls_os_timer_expirytime(tls_os_timer_t *timer);
|
u32 tls_os_timer_expirytime(tls_os_timer_t *timer);
|
||||||
|
@ -82,15 +82,6 @@ void tls_get_rtc(struct tm *tblock)
|
|||||||
tblock->tm_sec = ctrl1 & 0x0000003f;
|
tblock->tm_sec = ctrl1 & 0x0000003f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** NOT PART OF THE OFFICIAL SDK **/
|
|
||||||
bool tls_is_rtc_running(void)
|
|
||||||
{
|
|
||||||
int ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2);
|
|
||||||
|
|
||||||
return ctrl2 & (1 << 16) ? true : false;
|
|
||||||
}
|
|
||||||
/**********************************/
|
|
||||||
|
|
||||||
void PMU_RTC_IRQHandler(void)
|
void PMU_RTC_IRQHandler(void)
|
||||||
{
|
{
|
||||||
tls_reg_write32(HR_PMU_INTERRUPT_SRC, BIT(4)); /* clear rtc interrupt */
|
tls_reg_write32(HR_PMU_INTERRUPT_SRC, BIT(4)); /* clear rtc interrupt */
|
||||||
|
@ -1173,6 +1173,7 @@ int tls_uart_tx_length(u16 uart_no)
|
|||||||
int tls_uart_write(u16 uart_no, char *buf, u16 writesize)
|
int tls_uart_write(u16 uart_no, char *buf, u16 writesize)
|
||||||
{
|
{
|
||||||
return tls_uart_write_async(uart_no, buf, writesize);
|
return tls_uart_write_async(uart_no, buf, writesize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1419,11 +1419,6 @@ u32 tls_os_timer_expirytime(tls_os_timer_t *timer)
|
|||||||
vTaskDelay(ticks);
|
vTaskDelay(ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tls_os_time_delay_until(u32 * const previous_wake_time, const u32 duration_in_ticks)
|
|
||||||
{
|
|
||||||
vTaskDelayUntil(previous_wake_time, duration_in_ticks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*********************************************************************************************************
|
*********************************************************************************************************
|
||||||
* task stat info
|
* task stat info
|
||||||
|
Loading…
Reference in New Issue
Block a user