2023-04-27 08:54:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*
|
|
|
|
|
* Change Logs:
|
|
|
|
|
* Date Author Notes
|
|
|
|
|
* 2023-04-27 RT-Thread first version
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
|
2023-04-27 09:29:44 +00:00
|
|
|
|
#define LOG_TAG "main"
|
|
|
|
|
#define LOG_LVL LOG_LVL_DBG
|
|
|
|
|
#include <ulog.h>
|
|
|
|
|
#include <board.h>
|
2023-05-25 06:58:31 +00:00
|
|
|
|
#include <ttmsg/ttmsg.h>
|
2023-04-28 03:39:00 +00:00
|
|
|
|
//#define LED_HEART GET_PIN(E,3)
|
|
|
|
|
//#ifndef ETH_RESET_PIN
|
|
|
|
|
//#define ETH_RESET_PIN GET_PIN(E, 7)//71
|
|
|
|
|
//#endif
|
|
|
|
|
////#define RESET_LB GET_PIN(E, 1)
|
|
|
|
|
////#define RESET_UB GET_PIN(E, 0)
|
|
|
|
|
////#define RESET_CE GET_PIN(G, 10)
|
2023-05-25 06:58:31 +00:00
|
|
|
|
///
|
|
|
|
|
//static rt_uint8_t d[35][200] = { };
|
|
|
|
|
//static rt_uint8_t s[35] = { };
|
|
|
|
|
static size_t leng = 0;
|
|
|
|
|
void pfdemo(void)
|
|
|
|
|
{
|
|
|
|
|
// #define cmb_println(...) rt_kprintf(__VA_ARGS__);rt_kprintf("\r\n");
|
|
|
|
|
// char *f = "1023_05_19_15_29_59_254.txt";
|
|
|
|
|
char *f = "2023_05_19_15_29_59_255.txt";
|
2023-05-29 12:49:30 +00:00
|
|
|
|
rt_uint8_t d[10][200] = { };
|
|
|
|
|
rt_uint8_t s[10] = { };
|
2023-05-25 06:58:31 +00:00
|
|
|
|
rt_uint8_t len = 0;
|
|
|
|
|
LOG_D("%p--%p",d,s);
|
|
|
|
|
LOG_I("pack %s ...",f);
|
|
|
|
|
len = pack_File(f, 0, d, s);
|
|
|
|
|
rt_kprintf("len is %d\n", len);
|
|
|
|
|
if (len)
|
|
|
|
|
{
|
2023-05-29 12:49:30 +00:00
|
|
|
|
for (size_t var = 0; var < len; ++var) {
|
|
|
|
|
LOG_HEX("d",27,d[var],s[var]);
|
|
|
|
|
}
|
|
|
|
|
// LOG_HEX("pkdata:",27,d[0],s[0]);
|
|
|
|
|
// LOG_D("%p--%p",d,s);
|
|
|
|
|
// LOG_D("%d--%d--%02X",len,s[0],d[0][0]);
|
2023-05-25 06:58:31 +00:00
|
|
|
|
LOG_I("Done.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-27 08:54:45 +00:00
|
|
|
|
int main(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
LOG_D("SYSCLK_Frequency = %d", HAL_RCC_GetSysClockFreq());
|
|
|
|
|
LOG_D("HCLK_Frequency = %d", HAL_RCC_GetHCLKFreq());
|
|
|
|
|
LOG_D("PCLK1_Frequency = %d", HAL_RCC_GetPCLK1Freq());
|
|
|
|
|
LOG_D("PCLK2_Frequency = %d", HAL_RCC_GetPCLK2Freq());
|
2023-04-27 09:29:44 +00:00
|
|
|
|
|
2023-04-28 00:15:49 +00:00
|
|
|
|
// #define LED_HEART GET_PIN(E,3)
|
2023-04-27 09:29:44 +00:00
|
|
|
|
/* 设置PIN脚模式为输出 */
|
|
|
|
|
rt_pin_mode(LED_HEART, PIN_MODE_OUTPUT);
|
2023-05-29 12:49:30 +00:00
|
|
|
|
// rt_pin_mode(LED_HEART_DEBUG, PIN_MODE_OUTPUT);
|
2023-04-28 00:15:49 +00:00
|
|
|
|
rt_pin_mode(ETH_RESET_PIN, PIN_MODE_OUTPUT);
|
|
|
|
|
|
2023-05-29 12:49:30 +00:00
|
|
|
|
rt_pin_mode(TT_EN, PIN_MODE_OUTPUT);
|
|
|
|
|
|
2023-05-04 08:35:14 +00:00
|
|
|
|
// rt_pin_write(ETH_RESET_PIN, PIN_LOW);//关闭ETH
|
2023-05-29 12:49:30 +00:00
|
|
|
|
|
|
|
|
|
rt_err_t ret = RT_EOK;
|
|
|
|
|
/* 设 置 日 期 */
|
|
|
|
|
ret = set_date(2018, 12, 3);
|
|
|
|
|
if (ret != RT_EOK)
|
2023-05-25 06:58:31 +00:00
|
|
|
|
{
|
2023-05-29 12:49:30 +00:00
|
|
|
|
rt_kprintf("set RTC date failed\n");
|
|
|
|
|
return ret;
|
2023-05-25 06:58:31 +00:00
|
|
|
|
}
|
2023-05-29 12:49:30 +00:00
|
|
|
|
/* 设 置 时 间 */
|
|
|
|
|
ret = set_time(11, 15, 50);
|
|
|
|
|
if (ret != RT_EOK)
|
|
|
|
|
{
|
|
|
|
|
rt_kprintf("set RTC time failed\n");
|
|
|
|
|
// return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-28 00:15:49 +00:00
|
|
|
|
while (1)
|
2023-04-27 09:29:44 +00:00
|
|
|
|
{
|
|
|
|
|
/* 拉低PIN脚 */
|
|
|
|
|
rt_pin_write(LED_HEART, PIN_LOW);
|
2023-05-29 12:49:30 +00:00
|
|
|
|
// rt_pin_write(LED_HEART_DEBUG, PIN_LOW);
|
2023-04-27 09:29:44 +00:00
|
|
|
|
/* 延时1ms,省电 */
|
2023-04-28 00:15:49 +00:00
|
|
|
|
rt_thread_mdelay(1); //去掉延时,共用print替换
|
2023-04-27 09:29:44 +00:00
|
|
|
|
// rt_kprintf("Heartbeat.\n");
|
|
|
|
|
|
|
|
|
|
/* 拉高PIN脚 */
|
|
|
|
|
rt_pin_write(LED_HEART, PIN_HIGH);
|
2023-05-29 12:49:30 +00:00
|
|
|
|
// rt_pin_write(LED_HEART_DEBUG, PIN_HIGH);
|
2023-04-27 09:29:44 +00:00
|
|
|
|
rt_thread_mdelay(1000);
|
|
|
|
|
}
|
2023-04-27 08:54:45 +00:00
|
|
|
|
|
|
|
|
|
return RT_EOK;
|
|
|
|
|
}
|
2023-04-27 09:10:08 +00:00
|
|
|
|
//fastlz_test -c demo.bin f.bin
|
2023-04-27 09:29:44 +00:00
|
|
|
|
|
2023-05-25 06:58:31 +00:00
|
|
|
|
void pp(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
// if (argc == 2)
|
|
|
|
|
{
|
|
|
|
|
/* 创建线程 */
|
|
|
|
|
rt_thread_t thread = rt_thread_create("pmsg2", pfdemo, RT_NULL, 1024 * 10, 25, 10);
|
|
|
|
|
/* 创建成功则启动线程 */
|
|
|
|
|
if (thread != RT_NULL)
|
|
|
|
|
{
|
|
|
|
|
rt_thread_startup(thread);
|
|
|
|
|
// rt_kprintf("done");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LOG_E("thread 'pmsg' create failure.");
|
|
|
|
|
return RT_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MSH_CMD_EXPORT(pp, 打包文件。);
|