diff --git a/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25/sensor_parser.c b/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25/sensor_parser.c
new file mode 100644
index 00000000..675b690c
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25/sensor_parser.c
@@ -0,0 +1,337 @@
+/*----------------------------------------------------------------------------
+ * Tencent is pleased to support the open source community by making TencentOS
+ * available.
+ *
+ * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * If you have downloaded a copy of the TencentOS binary from Tencent, please
+ * note that the TencentOS binary is licensed under the BSD 3-Clause License.
+ *
+ * If you have downloaded a copy of the TencentOS source code from Tencent,
+ * please note that TencentOS source code is licensed under the BSD 3-Clause
+ * License, except for the third-party components listed below which are
+ * subject to different license terms. Your integration of TencentOS into your
+ * own projects may require compliance with the BSD 3-Clause License, as well
+ * as the other licenses applicable to the third-party components included
+ * within TencentOS.
+ *---------------------------------------------------------------------------*/
+
+#include "sensor_parser.h"
+
+__STATIC__ shell_ctl_t shell_ctl;
+
+__STATIC__ k_stack_t shell_parser_task_stack[SHELL_PARSER_TASK_STACK_SIZE];
+
+__STATIC__ int shell_getchar(void)
+{
+ uint8_t chr;
+ k_err_t err;
+
+ if (tos_sem_pend(&SHELL_CTL->shell_rx_sem, TOS_TIME_FOREVER) != K_ERR_NONE) {
+ return -1;
+ }
+
+ err = tos_chr_fifo_pop(&SHELL_CTL->shell_rx_fifo, &chr);
+
+ return err == K_ERR_NONE ? chr : -1;
+}
+
+typedef struct sensor_frame_st {
+ uint16_t len;
+ uint16_t data1;
+ uint16_t data2;
+ uint16_t data3;
+ uint16_t data4;
+ uint16_t data5;
+ uint16_t data6;
+ uint16_t data7;
+ uint16_t data8;
+ uint16_t data9;
+ uint16_t data10;
+ uint16_t data11;
+ uint16_t data12;
+ uint16_t data13;
+ uint16_t chk_sum;
+
+ uint8_t len_h;
+ uint8_t len_l;
+
+ uint8_t data1_h;
+ uint8_t data1_l;
+
+ uint8_t data2_h;
+ uint8_t data2_l;
+
+ uint8_t data3_h;
+ uint8_t data3_l;
+
+ uint8_t data4_h;
+ uint8_t data4_l;
+
+ uint8_t data5_h;
+ uint8_t data5_l;
+
+ uint8_t data6_h;
+ uint8_t data6_l;
+
+ uint8_t data7_h;
+ uint8_t data7_l;
+
+ uint8_t data8_h;
+ uint8_t data8_l;
+
+ uint8_t data9_h;
+ uint8_t data9_l;
+
+ uint8_t data10_h;
+ uint8_t data10_l;
+
+ uint8_t data11_h;
+ uint8_t data11_l;
+
+ uint8_t data12_h;
+ uint8_t data12_l;
+
+ uint8_t data13_h;
+ uint8_t data13_l;
+
+ uint8_t chk_sum_h;
+ uint8_t chk_sum_l;
+} __PACKED__ sensor_frame_t;
+
+extern k_mail_q_t mail_q;
+
+k_tick_t last_report = 0;
+
+int read_frame(sensor_frame_t *frame)
+{
+ frame->len_h = shell_getchar();
+ frame->len_l = shell_getchar();
+
+ frame->data1_h = shell_getchar();
+ frame->data1_l = shell_getchar();
+
+ frame->data2_h = shell_getchar();
+ frame->data2_l = shell_getchar();
+
+ frame->data3_h = shell_getchar();
+ frame->data3_l = shell_getchar();
+
+ frame->data4_h = shell_getchar();
+ frame->data4_l = shell_getchar();
+
+ frame->data5_h = shell_getchar();
+ frame->data5_l = shell_getchar();
+
+ frame->data6_h = shell_getchar();
+ frame->data6_l = shell_getchar();
+
+ frame->data7_h = shell_getchar();
+ frame->data7_l = shell_getchar();
+
+ frame->data8_h = shell_getchar();
+ frame->data8_l = shell_getchar();
+
+ frame->data9_h = shell_getchar();
+ frame->data9_l = shell_getchar();
+
+ frame->data10_h = shell_getchar();
+ frame->data10_l = shell_getchar();
+
+ frame->data11_h = shell_getchar();
+ frame->data11_l = shell_getchar();
+
+ frame->data12_h = shell_getchar();
+ frame->data12_l = shell_getchar();
+
+ frame->data13_h = shell_getchar();
+ frame->data13_l = shell_getchar();
+
+ frame->chk_sum_h = shell_getchar();
+ frame->chk_sum_l = shell_getchar();
+
+
+ frame->len = (frame->len_h << 8) | frame->len_l;
+ frame->data1 = (frame->data1_h << 8) | frame->data1_l;
+ frame->data2 = (frame->data2_h << 8) | frame->data2_l;
+ frame->data3 = (frame->data3_h << 8) | frame->data3_l;
+ frame->data4 = (frame->data4_h << 8) | frame->data4_l;
+ frame->data5 = (frame->data5_h << 8) | frame->data5_l;
+ frame->data6 = (frame->data6_h << 8) | frame->data6_l;
+ frame->data7 = (frame->data7_h << 8) | frame->data7_l;
+ frame->data8 = (frame->data8_h << 8) | frame->data8_l;
+ frame->data9 = (frame->data9_h << 8) | frame->data9_l;
+ frame->data10 = (frame->data10_h << 8) | frame->data10_l;
+ frame->data11 = (frame->data11_h << 8) | frame->data11_l;
+ frame->data12 = (frame->data12_h << 8) | frame->data12_l;
+ frame->data13 = (frame->data13_h << 8) | frame->data13_l;
+ frame->chk_sum = (frame->chk_sum_h << 8) | frame->chk_sum_l;
+
+
+ uint16_t chsum;
+ chsum = frame->len_h +
+ frame->len_l +
+ frame->data1_h +
+ frame->data1_l +
+ frame->data2_h +
+ frame->data2_l +
+ frame->data3_h +
+ frame->data3_l +
+ frame->data4_h +
+ frame->data4_l +
+ frame->data5_h +
+ frame->data5_l +
+ frame->data6_h +
+ frame->data6_l +
+ frame->data7_h +
+ frame->data7_l +
+ frame->data8_h +
+ frame->data8_l +
+ frame->data9_h +
+ frame->data9_l +
+ frame->data10_h +
+ frame->data10_l +
+ frame->data11_h +
+ frame->data11_l +
+ frame->data12_h +
+ frame->data12_l +
+ frame->data13_h +
+ frame->data13_l;
+
+ if (chsum + 0x42 + 0x4d != frame->chk_sum) {
+ return -1;
+ }
+
+ k_tick_t now = tos_systick_get();
+ if (last_report == 0 || now - last_report >= 15000) {
+ last_report = now;
+
+ printf("data1: %d\n", frame->data1);
+ printf("data2: %d\n", frame->data2);
+ printf("data3: %d\n", frame->data3);
+ printf("data4: %d\n", frame->data4);
+ printf("data5: %d\n", frame->data5);
+ printf("data6: %d\n", frame->data6);
+ printf("data7: %d\n", frame->data7);
+ printf("data8: %d\n", frame->data8);
+ printf("data9: %d\n", frame->data9);
+ printf("data10: %d\n", frame->data10);
+ printf("data11: %d\n", frame->data11);
+ printf("data12: %d\n", frame->data12);
+ printf("data13: %d\n", frame->data13);
+ printf("\n\n");
+
+ return 0;
+ }
+
+ return -1;
+}
+
+sensor_frame_t frame;
+
+__STATIC__ int shell_readline(void)
+{
+ int chr, last_chr = 0;
+ char *buf = SHELL_CTL->cmd_buffer;
+
+ while (K_TRUE) {
+ if (buf - SHELL_CTL->cmd_buffer >= (SHELL_CTL->cmd_buffer_size - 1)) {
+ return -1;
+ }
+
+ chr = shell_getchar();
+ if (chr < 0) {
+ return -1;
+ }
+
+ if (chr == 0x4d && last_chr == 0x42) {
+ if (read_frame(&frame) == 0) {
+ tos_mail_q_post(&mail_q, &frame.data1_h, 13 * 2);
+ }
+ }
+
+ *buf++ = chr;
+ last_chr = chr;
+ }
+}
+
+
+__STATIC__ void shell_parser(void *arg)
+{
+ while (K_TRUE) {
+ shell_readline();
+ }
+}
+
+__API__ int tos_shell_init(char *cmd_buf, int cmd_buf_size, shell_output_t output)
+{
+ void *buffer = K_NULL;
+
+ TOS_PTR_SANITY_CHECK_RC(cmd_buf, -1);
+ TOS_PTR_SANITY_CHECK_RC(output, -1);
+
+ memset(SHELL_CTL, 0, sizeof(shell_ctl_t));
+
+ SHELL_CTL->cmd_buffer = cmd_buf;
+ SHELL_CTL->cmd_buffer_size = cmd_buf_size;
+ SHELL_CTL->output = output;
+
+ buffer = tos_mmheap_alloc(cmd_buf_size * 2);
+ if (!buffer) {
+ return -1;
+ }
+
+ SHELL_CTL->shell_rx_fifo_buffer = (uint8_t *)buffer;
+ tos_chr_fifo_create(&SHELL_CTL->shell_rx_fifo, buffer, cmd_buf_size * 2);
+
+ if (tos_sem_create(&SHELL_CTL->shell_rx_sem, (k_sem_cnt_t)0u) != K_ERR_NONE) {
+ goto errout0;
+ }
+
+ if (tos_task_create(&SHELL_CTL->parser, "shell_parser", shell_parser,
+ K_NULL, SHELL_PARSER_TASK_PRIO, shell_parser_task_stack,
+ SHELL_PARSER_TASK_STACK_SIZE, 0) != K_ERR_NONE) {
+ goto errout1;
+ }
+
+ return 0;
+
+errout1:
+ tos_sem_destroy(&SHELL_CTL->shell_rx_sem);
+
+errout0:
+ tos_mmheap_free(SHELL_CTL->shell_rx_fifo_buffer);
+ SHELL_CTL->shell_rx_fifo_buffer = K_NULL;
+ tos_chr_fifo_destroy(&SHELL_CTL->shell_rx_fifo);
+
+ return -1;
+}
+
+__API__ void tos_shell_deinit(void)
+{
+ tos_task_destroy(&SHELL_CTL->parser);
+ tos_sem_destroy(&SHELL_CTL->shell_rx_sem);
+
+ tos_mmheap_free(SHELL_CTL->shell_rx_fifo_buffer);
+ SHELL_CTL->shell_rx_fifo_buffer = K_NULL;
+ tos_chr_fifo_destroy(&SHELL_CTL->shell_rx_fifo);
+}
+
+__API__ void tos_shell_printf(const char *format, ...)
+{
+ va_list args;
+ static char buffer[SHELL_OUTPUT_MAX];
+
+ va_start(args, format);
+ vsnprintf(buffer, sizeof(buffer), format, args);
+ va_end(args);
+
+ (SHELL_CTL->output)(buffer);
+}
+
+__API__ void tos_shell_input_byte(uint8_t data)
+{
+ if (tos_chr_fifo_push(&SHELL_CTL->shell_rx_fifo, data) == K_ERR_NONE) {
+ tos_sem_post(&SHELL_CTL->shell_rx_sem);
+ }
+}
+
diff --git a/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25/sensor_parser.h b/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25/sensor_parser.h
new file mode 100644
index 00000000..b69c8169
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25/sensor_parser.h
@@ -0,0 +1,54 @@
+/*----------------------------------------------------------------------------
+ * Tencent is pleased to support the open source community by making TencentOS
+ * available.
+ *
+ * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * If you have downloaded a copy of the TencentOS binary from Tencent, please
+ * note that the TencentOS binary is licensed under the BSD 3-Clause License.
+ *
+ * If you have downloaded a copy of the TencentOS source code from Tencent,
+ * please note that TencentOS source code is licensed under the BSD 3-Clause
+ * License, except for the third-party components listed below which are
+ * subject to different license terms. Your integration of TencentOS into your
+ * own projects may require compliance with the BSD 3-Clause License, as well
+ * as the other licenses applicable to the third-party components included
+ * within TencentOS.
+ *---------------------------------------------------------------------------*/
+
+#ifndef _TOS_SHELL_H_
+#define _TOS_SHELL_H_
+
+#include "tos_k.h"
+
+#define SHELL_CMD_ARGV_MAX 16
+#define SHELL_OUTPUT_MAX 256
+#define SHELL_PARSER_TASK_STACK_SIZE 1024
+#define SHELL_PARSER_TASK_PRIO 5
+
+typedef void (*shell_output_t)(const char *str);
+
+typedef struct shell_control_st {
+ k_task_t parser;
+
+ shell_output_t output;
+
+ char *cmd_buffer;
+ int cmd_buffer_size;
+
+ k_sem_t shell_rx_sem;
+ k_chr_fifo_t shell_rx_fifo;
+ uint8_t *shell_rx_fifo_buffer;
+} shell_ctl_t;
+
+#define SHELL_CTL ((shell_ctl_t *)(&shell_ctl))
+
+__API__ int tos_shell_init(char *cmd_buf, int cmd_buf_size, shell_output_t output);
+
+__API__ void tos_shell_deinit(void);
+
+__API__ void tos_shell_printf(const char *format, ...);
+
+__API__ void tos_shell_input_byte(uint8_t data);
+
+#endif /* _TOS_SHELL_H_ */
+
diff --git a/board/TencentOS_tiny_EVB_LX/BSP/Inc/usart.h b/board/TencentOS_tiny_EVB_LX/BSP/Inc/usart.h
index 8e2cf040..df77bc34 100644
--- a/board/TencentOS_tiny_EVB_LX/BSP/Inc/usart.h
+++ b/board/TencentOS_tiny_EVB_LX/BSP/Inc/usart.h
@@ -13,8 +13,13 @@
#define USART2_GPIO_RX_PIN GPIO_PIN_11
#define USART2_GPIO_PORT GPIOB
+#define UART3_GPIO_TX_PIN GPIO_PIN_10
+#define UART3_GPIO_RX_PIN GPIO_PIN_11
+#define UART3_GPIO_PORT GPIOC
+
void usart0_init(int baud);
void usart1_init(int baud);
void usart2_init(int baud);
+void uart3_init(int baud);
#endif // __USART_H
diff --git a/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c b/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c
new file mode 100644
index 00000000..6a5edd66
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.c
@@ -0,0 +1,119 @@
+#include "lora_demo.h"
+#include "RHF76.h"
+#include "sensor_parser.h"
+
+/*
+ ==================================================================================
+ data template:
+
+ Type Name Token DataType RW Attribute
+ property temperature temperature integer readonly range: [-100, 155]
+ initial: 0
+ step: 1
+ unit: centigrade
+
+ property humidity humidity integer readonly range: [-0, 100]
+ initial: 0
+ step: 1
+ unit: %
+
+ property report_period period integer read-write range: [0, 3600]
+ initial: 0
+ step: 1
+ unit: second
+
+ ==================================================================================
+ up-link parser javascript:
+
+ function RawToProtocol(fPort, bytes) {
+ var data = {
+ "method": "report",
+ "clientToken" : new Date(),
+ "params" : {}
+ };
+ data.params.temperature = bytes[0];
+ data.params.humidity = bytes[1];
+ data.params.period = bytes[2] | (bytes[3] << 8);
+ return data;
+ }
+
+ ==================================================================================
+ down-link parser javascript:
+
+ function ProtocolToRaw(obj) {
+ var data = new Array();
+ data[0] = 5;// fport=5
+ data[1] = 0;// unconfirmed mode
+ data[2] = obj.params.period & 0x00FF;
+ data[3] = (obj.params.period >> 8) & 0x00FF;
+ return data;
+ }
+
+ */
+
+uint16_t report_period = 10;
+
+k_mail_q_t mail_q;
+#define DATA_CNT 26
+uint8_t mail_buf[DATA_CNT];
+
+typedef struct device_data_st {
+ uint8_t data[DATA_CNT];
+} __PACKED__ dev_data_t;
+
+void recv_callback(uint8_t *data, uint8_t len)
+{
+ int i = 0;
+
+ printf("len: %d\n", len);
+
+ for (i = 0; i < len; ++i) {
+ printf("data[%d]: %d\n", i, data[i]);
+ }
+
+ if (len == 1) {
+ report_period = data[0];
+ } else if (len >= 2) {
+ report_period = data[0] | (data[1] << 8);
+ }
+ printf("report_period: %d\n", report_period);
+}
+
+
+#define CMD_LEN_MAX 1024
+char cmd_buf[CMD_LEN_MAX];
+
+void uart_output(const char *str)
+{
+ /* if using c lib printf through uart, a simpler one is: */
+ printf(str);
+}
+
+dev_data_t dev_data;
+uint8_t pool[DATA_CNT];
+
+void application_entry(void *arg)
+{
+ int i = 0;
+
+ rhf76_lora_init(HAL_UART_PORT_1);
+ tos_lora_module_recvcb_register(recv_callback);
+
+ tos_lora_module_join_otaa("8cf957200000025a", "8cf957200000025a1e29aaaaad204a72");
+
+ tos_mail_q_create(&mail_q, pool, DATA_CNT, sizeof(uint8_t));
+ tos_shell_init(cmd_buf, sizeof(cmd_buf), uart_output);
+
+ while (1) {
+ size_t mail_size;
+ tos_mail_q_pend(&mail_q, &dev_data.data, &mail_size, TOS_TIME_FOREVER);
+
+ for (i = 0; i < mail_size; ++i) {
+ printf("[%d] %x\n", i, dev_data.data[i]);
+ }
+ printf("\n\n");
+
+ tos_lora_module_send(&dev_data.data, mail_size);
+ }
+}
+
diff --git a/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.h b/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.h
new file mode 100644
index 00000000..ccc30179
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN/lora_demo.h
@@ -0,0 +1,24 @@
+#ifndef __APP_DEMO_H__
+#define __APP_DEMO_H__
+
+#include "mcu_init.h"
+#include "tos_at.h"
+#include "string.h"
+#include "tos_k.h"
+#include "lora_module_wrapper.h"
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+typedef struct
+{
+ char data[32];
+}ReportData_TypeDef;
+
+void application_entry(void *arg);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __APP_DEMO_H__ */
+
diff --git a/board/TencentOS_tiny_EVB_LX/BSP/Src/mcu_init.c b/board/TencentOS_tiny_EVB_LX/BSP/Src/mcu_init.c
index c2bbf9f3..f301d763 100644
--- a/board/TencentOS_tiny_EVB_LX/BSP/Src/mcu_init.c
+++ b/board/TencentOS_tiny_EVB_LX/BSP/Src/mcu_init.c
@@ -19,6 +19,7 @@ void board_init()
usart0_init(115200);
usart1_init(115200);
usart2_init(115200);
+ uart3_init(9600);
OLED_Init();
OLED_Clear();
OLED_ShowChinese(36,0,0);
diff --git a/board/TencentOS_tiny_EVB_LX/BSP/Src/usart.c b/board/TencentOS_tiny_EVB_LX/BSP/Src/usart.c
index c36810e9..9a18f0c0 100644
--- a/board/TencentOS_tiny_EVB_LX/BSP/Src/usart.c
+++ b/board/TencentOS_tiny_EVB_LX/BSP/Src/usart.c
@@ -65,8 +65,6 @@ void usart1_init(int baud)
}
-
-
void usart2_init(int baud)
{
//eclic_irq_enable(USART2_IRQn, 1, 0);
@@ -101,6 +99,40 @@ void usart2_init(int baud)
//usart_interrupt_enable(USART2, USART_INT_RBNE);
}
+void uart3_init(int baud)
+{
+ eclic_irq_enable(UART3_IRQn, 1, 0);
+
+ /* enable GPIO clock */
+ rcu_periph_clock_enable(RCU_GPIOC);
+
+ /* enable USART2 clock */
+ rcu_periph_clock_enable(RCU_UART3);
+
+ /* connect port to USART0_Tx */
+ gpio_init(UART3_GPIO_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, UART3_GPIO_TX_PIN);
+
+ /* connect port to USART0_Rx */
+ gpio_init(UART3_GPIO_PORT, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, UART3_GPIO_RX_PIN);
+
+ //gpio_pin_remap_config(GPIO_USART2_FULL_REMAP,ENABLE);
+
+ /* USART1 configure */
+ usart_deinit(UART3);
+ usart_baudrate_set(UART3, baud);
+ usart_word_length_set(UART3, USART_WL_8BIT);
+ usart_stop_bit_set(UART3, USART_STB_1BIT);
+ usart_parity_config(UART3, USART_PM_NONE);
+ usart_hardware_flow_rts_config(UART3, USART_RTS_DISABLE);
+ usart_hardware_flow_cts_config(UART3, USART_CTS_DISABLE);
+ usart_receive_config(UART3, USART_RECEIVE_ENABLE);
+ usart_transmit_config(UART3, USART_TRANSMIT_ENABLE);
+ usart_enable(UART3);
+
+
+ usart_interrupt_enable(UART3, USART_INT_RBNE);
+}
+
int _put_char(int ch)
{
diff --git a/board/TencentOS_tiny_EVB_LX/TOS_CONFIG/tos_config.h b/board/TencentOS_tiny_EVB_LX/TOS_CONFIG/tos_config.h
index 4bba2d58..ef40f451 100644
--- a/board/TencentOS_tiny_EVB_LX/TOS_CONFIG/tos_config.h
+++ b/board/TencentOS_tiny_EVB_LX/TOS_CONFIG/tos_config.h
@@ -4,34 +4,33 @@
#include "gd32vf103.h"
#include "stddef.h"
-// 配置TencentOS tiny默认支持的最大优先级数量
+
#define TOS_CFG_TASK_PRIO_MAX 10u
-// 配置TencentOS tiny的内核是否开启时间片轮转
+
#define TOS_CFG_ROUND_ROBIN_EN 0u
-// 配置TencentOS tiny是否校验指针合法
+
#define TOS_CFG_OBJECT_VERIFY 0u
-// TencentOS tiny 事件模块功能宏
+#define TOS_CFG_TASK_DYNAMIC_CREATE_EN 0u
+
+
#define TOS_CFG_EVENT_EN 1u
-// 配置TencentOS tiny是否开启动态内存模块
+#define TOS_CFG_MMBLK_EN 1u
+
#define TOS_CFG_MMHEAP_EN 1u
-// 配置TencentOS tiny动态内存池大小
-#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 16384
-// 配置TencentOS tiny是否开启互斥锁模块
+#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x3000
+
+#define TOS_CFG_MAIL_QUEUE_EN 1u
+
#define TOS_CFG_MUTEX_EN 1u
-// 配置TencentOS tiny是否开启队列模块
-#define TOS_CFG_QUEUE_EN 1u
+#define TOS_CFG_TIMER_EN 0u
-// 配置TencentOS tiny是否开启软件定时器模块
-#define TOS_CFG_TIMER_EN 0u
-
-// 配置TencentOS tiny是否开启信号量模块
#define TOS_CFG_SEM_EN 1u
#define TOS_CFG_CPU_SYSTICK_PRIO 0xF
@@ -42,29 +41,24 @@
#define TOS_CFG_MSG_EN 0u
#endif
-// 配置TencentOS tiny消息队列大小
+
#define TOS_CFG_MSG_POOL_SIZE 10u
-// 配置TencentOS tiny空闲任务栈大小
+
#define TOS_CFG_IDLE_TASK_STK_SIZE 512u
-// 配置TencentOS tiny中断栈大小
+
#define TOS_CFG_IRQ_STK_SIZE 128u
-// 配置TencentOS tiny的tick频率
+
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u
-// 配置TencentOS tiny CPU频率
-// 除4的原因是,Bumblebee内核通过core_clk_aon四分频来更新mtime寄存器
-// 具体信息参见《Bumblebee内核简明数据手册》
+
#define TOS_CFG_CPU_CLOCK (SystemCoreClock/4)
-// 配置是否将TIMER配置成函数模式
+
#define TOS_CFG_TIMER_AS_PROC 1u
-#define TOS_CFG_VFS_EN 1u
-
-#define TOS_CFG_MMBLK_EN 1u
#endif /* INC_TOS_CONFIG_H_ */
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.cproject b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.cproject
new file mode 100644
index 00000000..e9fb6d48
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.cproject
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.gitignore b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.gitignore
new file mode 100644
index 00000000..3df573fe
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.gitignore
@@ -0,0 +1 @@
+/Debug/
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.project b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.project
new file mode 100644
index 00000000..bf822c41
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/.project
@@ -0,0 +1,144 @@
+
+
+ lorawan
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
+
+ Application
+ 2
+ virtual:/virtual
+
+
+ GD32VF103_Firmware_Library
+ 2
+ $%7BPARENT-4-PROJECT_LOC%7D/platform/vendor_bsp/gd/GD32VF103_Firmware_Library
+
+
+ TencentOS_tiny
+ 2
+ virtual:/virtual
+
+
+ Application/Inc
+ 2
+ $%7BPARENT-2-PROJECT_LOC%7D/BSP/Inc
+
+
+ Application/LoRaWAN
+ 2
+ C:/Users/supowang/Desktop/TencentOS-tiny/board/TencentOS_tiny_EVB_LX/BSP/LoRaWAN
+
+
+ Application/PM25
+ 2
+ C:/Users/supowang/Desktop/TencentOS-tiny/board/TencentOS_tiny_EVB_LX/BSP/Hardware/PM25
+
+
+ Application/Src
+ 2
+ $%7BPARENT-2-PROJECT_LOC%7D/BSP/Src
+
+
+ Application/tos_config.h
+ 1
+ $%7BPARENT-2-PROJECT_LOC%7D/TOS_CONFIG/tos_config.h
+
+
+ TencentOS_tiny/arch
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/devices
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/kernel
+ 2
+ $%7BPARENT-4-PROJECT_LOC%7D/kernel
+
+
+ TencentOS_tiny/net
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/platform
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/arch/risc-v
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/devices/rhf76_lora
+ 2
+ C:/Users/Supowang/Desktop/TencentOS-tiny/devices/rhf76_lora
+
+
+ TencentOS_tiny/net/at
+ 2
+ TOP_DIR/net/at
+
+
+ TencentOS_tiny/net/lora_module_wrapper
+ 2
+ C:/Users/Supowang/Desktop/TencentOS-tiny/net/lora_module_wrapper
+
+
+ TencentOS_tiny/platform/hal
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/arch/risc-v/bumblebee
+ 2
+ TOP_DIR/arch/risc-v/bumblebee/gcc
+
+
+ TencentOS_tiny/arch/risc-v/common
+ 2
+ $%7BPARENT-4-PROJECT_LOC%7D/arch/risc-v/common
+
+
+ TencentOS_tiny/arch/risc-v/rv32i
+ 2
+ TOP_DIR/arch/risc-v/rv32i/gcc
+
+
+ TencentOS_tiny/platform/hal/gd
+ 2
+ TOP_DIR/platform/hal/gd
+
+
+
+
+ TOP_DIR
+ $%7BPARENT-4-PROJECT_LOC%7D
+
+
+
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/gd32vf103_libopt.h b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/gd32vf103_libopt.h
new file mode 100644
index 00000000..875ff748
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/gd32vf103_libopt.h
@@ -0,0 +1,61 @@
+/*!
+ \file gd32vf103_libopt.h
+ \brief library optional for gd32vf103
+
+ \version 2019-6-5, V1.0.0, demo for GD32VF103
+*/
+
+/*
+ Copyright (c) 2019, GigaDevice Semiconductor Inc.
+
+ Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#ifndef GD32VF103_LIBOPT_H
+#define GD32VF103_LIBOPT_H
+
+#include "gd32vf103_adc.h"
+#include "gd32vf103_bkp.h"
+#include "gd32vf103_can.h"
+#include "gd32vf103_crc.h"
+#include "gd32vf103_dac.h"
+#include "gd32vf103_dma.h"
+#include "gd32vf103_eclic.h"
+#include "gd32vf103_exmc.h"
+#include "gd32vf103_exti.h"
+#include "gd32vf103_fmc.h"
+#include "gd32vf103_gpio.h"
+#include "gd32vf103_i2c.h"
+#include "gd32vf103_fwdgt.h"
+#include "gd32vf103_dbg.h"
+#include "gd32vf103_pmu.h"
+#include "gd32vf103_rcu.h"
+#include "gd32vf103_rtc.h"
+#include "gd32vf103_spi.h"
+#include "gd32vf103_timer.h"
+#include "gd32vf103_usart.h"
+#include "gd32vf103_wwdgt.h"
+#include "n200_func.h"
+
+#endif /* GD32VF103_LIBOPT_H */
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/link.lds b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/link.lds
new file mode 100644
index 00000000..1c32e640
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/link.lds
@@ -0,0 +1,175 @@
+OUTPUT_ARCH( "riscv" )
+
+ENTRY( _start )
+
+MEMORY
+{
+ /* Run in FLASH */
+ flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 128k
+ ram (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 32K
+
+ /* Run in RAM */
+/* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 24k
+ ram (wxa!ri) : ORIGIN = 0x20006000, LENGTH = 8K
+*/
+}
+
+
+SECTIONS
+{
+ __stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
+
+
+ .init :
+ {
+ KEEP (*(SORT_NONE(.init)))
+ } >flash AT>flash
+
+ .ilalign :
+ {
+ . = ALIGN(4);
+ PROVIDE( _ilm_lma = . );
+ } >flash AT>flash
+
+ .ialign :
+ {
+ PROVIDE( _ilm = . );
+ } >flash AT>flash
+
+ .text :
+ {
+ *(.rodata .rodata.*)
+ *(.text.unlikely .text.unlikely.*)
+ *(.text.startup .text.startup.*)
+ *(.text .text.*)
+ *(.gnu.linkonce.t.*)
+ } >flash AT>flash
+
+ .fini :
+ {
+ KEEP (*(SORT_NONE(.fini)))
+ } >flash AT>flash
+
+ . = ALIGN(4);
+
+ PROVIDE (__etext = .);
+ PROVIDE (_etext = .);/*0x80022c8*/
+ PROVIDE (etext = .);/*0x80022c8*/
+ PROVIDE( _eilm = . );
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >flash AT>flash
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
+ KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >flash AT>flash
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
+ KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >flash AT>flash
+
+ .ctors :
+ {
+ /* gcc uses crtbegin.o to find the start of
+ the constructors, so we make sure it is
+ first. Because this is a wildcard, it
+ doesn't matter if the user does not
+ actually link against crtbegin.o; the
+ linker won't look for a file to match a
+ wildcard. The wildcard also means that it
+ doesn't matter which directory crtbegin.o
+ is in. */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*crtbegin?.o(.ctors))
+ /* We don't want to include the .ctor section from
+ the crtend.o file until after the sorted ctors.
+ The .ctor section from the crtend file contains the
+ end of ctors marker and it must be last */
+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ } >flash AT>flash
+
+ .dtors :
+ {
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*crtbegin?.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ } >flash AT>flash
+
+ . = ALIGN(4);
+ PROVIDE( _eilm = . );
+
+ .lalign :
+ {
+ . = ALIGN(4);
+ PROVIDE( _data_lma = . );
+ } >flash AT>flash
+
+ .dalign :
+ {
+ . = ALIGN(4);
+ PROVIDE( _data = . );
+ } >ram AT>flash
+
+
+ .data :
+ {
+ *(.rdata)
+
+ *(.gnu.linkonce.r.*)
+ *(.data .data.*)
+ *(.gnu.linkonce.d.*)
+ . = ALIGN(8);
+ PROVIDE( __global_pointer$ = . + 0x800);
+ *(.sdata .sdata.*)
+ *(.gnu.linkonce.s.*)
+ . = ALIGN(8);
+ *(.srodata.cst16)
+ *(.srodata.cst8)
+ *(.srodata.cst4)
+ *(.srodata.cst2)
+ *(.srodata .srodata.*)
+ } >ram AT>flash
+
+ . = ALIGN(4);
+ PROVIDE( _edata = . );
+ PROVIDE( edata = . );
+
+ PROVIDE( _fbss = . ); /*0X200052A0 0X200002A0*/
+ PROVIDE( __bss_start = . );
+ .bss :
+ {
+ *(.sbss*)
+ *(.gnu.linkonce.sb.*)
+ *(.bss .bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ . = ALIGN(4);
+ } >ram AT>ram
+
+ . = ALIGN(8);
+ PROVIDE( _end = . ); /*0X2000,0340*/
+ PROVIDE( end = . );
+
+ .stack ORIGIN(ram) + LENGTH(ram) - __stack_size :
+ {
+ PROVIDE( _heap_end = . );
+ . = __stack_size;
+ PROVIDE( _sp = . );
+ } >ram AT>ram
+}
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/main.c b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/main.c
new file mode 100644
index 00000000..28adf09b
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/main.c
@@ -0,0 +1,72 @@
+#include "mcu_init.h"
+#include "tos_k.h"
+#include "tos_hal.h"
+
+#define LORA_TASK_SIZE 4096
+
+k_task_t k_task_lora;
+uint8_t k_lora_stk[LORA_TASK_SIZE];
+
+
+void USART0_IRQHandler() {
+ tos_knl_irq_enter();
+ if(RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)){
+ uint8_t data = usart_data_receive(USART0);
+ printf("%c\n", data);
+ }
+ tos_knl_irq_leave();
+}
+
+void USART1_IRQHandler() {
+ tos_knl_irq_enter();
+ if(RESET != usart_interrupt_flag_get(USART1, USART_INT_FLAG_RBNE)){
+ uint8_t data = usart_data_receive(USART1);
+ tos_at_uart_input_byte(data);
+ }
+ tos_knl_irq_leave();
+}
+
+void USART2_IRQHandler() {
+ tos_knl_irq_enter();
+ if(RESET != usart_interrupt_flag_get(USART2, USART_INT_FLAG_RBNE)){
+ uint8_t data = usart_data_receive(USART2);
+ }
+ tos_knl_irq_leave();
+}
+
+void UART3_IRQHandler() {
+ tos_knl_irq_enter();
+ if(RESET != usart_interrupt_flag_get(UART3, USART_INT_FLAG_RBNE)){
+ uint8_t data = usart_data_receive(UART3);
+ tos_shell_input_byte(data);
+ }
+ tos_knl_irq_leave();
+}
+
+void task_bled(void *pdata)
+{
+ int cnt = 0;
+ while (1) {
+ printf("blink led task cnt: %d\n", cnt++);
+ gpio_bit_write(LED_GPIO_PORT, LED_PIN,cnt % 2 ? SET : RESET);
+ tos_task_delay(1000);
+ }
+}
+
+extern void application_entry(void);
+void task_lora(void *pdata)
+{
+ application_entry();
+}
+
+
+void main(void) {
+ board_init();
+
+ tos_knl_init();
+
+ tos_task_create(&k_task_lora, "lora", task_lora, NULL, 4, k_lora_stk, LORA_TASK_SIZE, 0);
+
+ tos_knl_start();
+
+}
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/openocd_gdlink.cfg b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/openocd_gdlink.cfg
new file mode 100644
index 00000000..3ec85d42
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/lorawan/openocd_gdlink.cfg
@@ -0,0 +1,45 @@
+adapter_khz 1000
+reset_config srst_only
+adapter_nsrst_assert_width 100
+
+
+
+interface cmsis-dap
+
+transport select jtag
+
+#autoexit true
+
+set _CHIPNAME riscv
+jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
+
+set _TARGETNAME $_CHIPNAME.cpu
+target create $_TARGETNAME riscv -chain-position $_TARGETNAME
+$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0
+
+
+# Work-area is a space in RAM used for flash programming
+if { [info exists WORKAREASIZE] } {
+ set _WORKAREASIZE $WORKAREASIZE
+} else {
+ set _WORKAREASIZE 0x5000
+}
+
+# Allow overriding the Flash bank size
+if { [info exists FLASH_SIZE] } {
+ set _FLASH_SIZE $FLASH_SIZE
+} else {
+ # autodetect size
+ set _FLASH_SIZE 0
+}
+
+# flash size will be probed
+set _FLASHNAME $_CHIPNAME.flash
+
+flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
+riscv set_reset_timeout_sec 1
+init
+
+halt
+
+
diff --git a/devices/rhf76_lora/RHF76.h b/devices/rhf76_lora/RHF76.h
index 7b713366..fa87321d 100644
--- a/devices/rhf76_lora/RHF76.h
+++ b/devices/rhf76_lora/RHF76.h
@@ -19,7 +19,6 @@
#define __RHF76_H__
#include
-#include
#include
#include "usart.h"
#include "tos_at.h"