Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不穿格子衫的农民
TencentOS Tiny
提交
3aaafde7
T
TencentOS Tiny
项目概览
不穿格子衫的农民
/
TencentOS Tiny
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TencentOS Tiny
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3aaafde7
编写于
6月 24, 2021
作者:
M
mculover666
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add frame input type of at,update version to 2.4.0
上级
a1cdea57
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
2346 addition
and
2221 deletion
+2346
-2221
board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c
board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c
+327
-307
board/BearPi_STM32L431RC/BSP/Src/usart.c
board/BearPi_STM32L431RC/BSP/Src/usart.c
+317
-313
board/BearPi_STM32L431RC/TOS-CONFIG/tos_config.h
board/BearPi_STM32L431RC/TOS-CONFIG/tos_config.h
+47
-45
kernel/core/include/tos_version.h
kernel/core/include/tos_version.h
+3
-3
net/at/Makefile
net/at/Makefile
+34
-34
net/at/include/tos_at.h
net/at/include/tos_at.h
+521
-493
net/at/src/tos_at.c
net/at/src/tos_at.c
+1097
-1026
未找到文件。
board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c
浏览文件 @
3aaafde7
...
...
@@ -44,7 +44,11 @@
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
#if AT_INPUT_TYPE_FRAME_EN
#define UART_FRAME_BUFFER_MAX 1024
uint8_t
uart_frame_buffer
[
UART_FRAME_BUFFER_MAX
];
uint16_t
uart_frame_buffer_index
;
#endif
/* AT_INPUT_TYPE_FRAME_EN */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
...
...
@@ -290,6 +294,18 @@ void LPUART1_IRQHandler(void)
HAL_UART_IRQHandler
(
&
hlpuart1
);
tos_knl_irq_leave
();
/* USER CODE BEGIN LPUART1_IRQn 1 */
#if AT_INPUT_TYPE_FRAME_EN
if
(
__HAL_UART_GET_FLAG
(
&
hlpuart1
,
UART_FLAG_IDLE
)){
__HAL_UART_CLEAR_IDLEFLAG
(
&
hlpuart1
);
if
(
uart_frame_buffer_index
!=
0
)
{
tos_at_uart_input_frame
(
uart_frame_buffer
,
uart_frame_buffer_index
);
uart_frame_buffer_index
=
0
;
memset
(
uart_frame_buffer
,
0
,
sizeof
(
uart_frame_buffer
));
}
}
#endif
/* AT_INPUT_TYPE_FRAME_EN */
/* USER CODE END LPUART1_IRQn 1 */
}
...
...
@@ -300,7 +316,11 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
extern
uint8_t
data
;
if
(
huart
->
Instance
==
LPUART1
)
{
HAL_UART_Receive_IT
(
&
hlpuart1
,
&
data
,
1
);
#if AT_INPUT_TYPE_FRAME_EN
uart_frame_buffer
[
uart_frame_buffer_index
++
]
=
data
;
#else
tos_at_uart_input_byte
(
data
);
#endif
/* AT_INPUT_TYPE_FRAME_EN */
}
}
/* USER CODE END 1 */
...
...
board/BearPi_STM32L431RC/BSP/Src/usart.c
浏览文件 @
3aaafde7
...
...
@@ -19,6 +19,7 @@
/* Includes ------------------------------------------------------------------*/
#include "usart.h"
#include "tos_at.h"
/* USER CODE BEGIN 0 */
uint8_t
data
;
...
...
@@ -48,6 +49,9 @@ void MX_LPUART1_UART_Init(void)
Error_Handler
();
}
HAL_UART_Receive_IT
(
&
hlpuart1
,
&
data
,
1
);
#if AT_INPUT_TYPE_FRAME_EN
__HAL_UART_ENABLE_IT
(
&
hlpuart1
,
UART_IT_IDLE
);
#endif
}
/* USART1 init function */
...
...
board/BearPi_STM32L431RC/TOS-CONFIG/tos_config.h
浏览文件 @
3aaafde7
...
...
@@ -41,5 +41,7 @@
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_MAIL_QUEUE_EN 1u
#endif
kernel/core/include/tos_version.h
浏览文件 @
3aaafde7
...
...
@@ -24,9 +24,9 @@
// patch is updated for patch changes/bug fixes that should not need user code changes
#define TOS_VERSION_MAJOR 0x02
#define TOS_VERSION_MINOR 0x0
3
#define TOS_VERSION_PATCH 0x0
1
#define TOS_VERSION "2.
3.1
"
#define TOS_VERSION_MINOR 0x0
4
#define TOS_VERSION_PATCH 0x0
0
#define TOS_VERSION "2.
4.0
"
#endif
/* _TOS_VERSION_H_ */
net/at/Makefile
浏览文件 @
3aaafde7
net/at/include/tos_at.h
浏览文件 @
3aaafde7
...
...
@@ -32,6 +32,9 @@
#define AT_PARSER_TASK_STACK_SIZE 2048
#define AT_PARSER_TASK_PRIO 2
#define AT_INPUT_TYPE_FRAME_EN 0
#define AT_FRAME_LEN_MAIL_MAX 5
typedef
enum
at_status_en
{
AT_STATUS_OK
,
AT_STATUS_ERROR
,
...
...
@@ -97,6 +100,10 @@ typedef struct at_echo_st {
int
__is_fuzzy_match
;
}
at_echo_t
;
typedef
struct
at_frame_len_mail_st
{
uint16_t
frame_len
;
}
at_frame_len_mail_t
;
typedef
void
(
*
at_event_callback_t
)(
void
);
typedef
struct
at_event_st
{
...
...
@@ -123,7 +130,14 @@ typedef struct at_agent_st {
hal_uart_t
uart
;
k_mutex_t
uart_tx_lock
;
// k_mutex_t uart_rx_lock;
#if AT_INPUT_TYPE_FRAME_EN
k_mail_q_t
uart_rx_frame_mail
;
uint8_t
*
uart_rx_frame_mail_buffer
;
uint16_t
fifo_available_len
;
#else
k_sem_t
uart_rx_sem
;
#endif
/* AT_INPUT_TYPE_FRAME_EN */
k_chr_fifo_t
uart_rx_fifo
;
uint8_t
*
uart_rx_fifo_buffer
;
}
at_agent_t
;
...
...
@@ -386,6 +400,20 @@ __API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_
*/
__API__
int
tos_at_raw_data_send_until
(
at_echo_t
*
echo
,
uint32_t
timeout
,
const
uint8_t
*
buf
,
size_t
size
);
#if AT_INPUT_TYPE_FRAME_EN
/**
* @brief Write amount bytes to the at uart.
* The function called by the uart interrupt, to put the data from the uart to the at framework.
*
* @attention None
*
* @param[in] pdata pointer of the uart received data.
* @param[in] len length of the uart received data.
*
* @return None
*/
__API__
void
tos_at_uart_input_frame
(
uint8_t
*
pdata
,
uint16_t
len
);
#else
/**
* @brief Write byte to the at uart.
* The function called by the uart interrupt, to put the data from the uart to the at framework.
...
...
@@ -397,7 +425,7 @@ __API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const
* @return None
*/
__API__
void
tos_at_uart_input_byte
(
uint8_t
data
);
#endif
/**
* @brief A global lock provided by at framework.
* The lock usually used to make a atomic function.
...
...
net/at/src/tos_at.c
浏览文件 @
3aaafde7
...
...
@@ -46,11 +46,38 @@ __API__ int tos_at_global_lock_post(void)
return
0
;
}
__STATIC__
int
at_uart_getchar
(
uint8_t
*
data
,
k_tick_t
timeout
)
__STATIC__
int
at_uart_getchar
_from_fifo
(
uint8_t
*
data
)
{
TOS_CPU_CPSR_ALLOC
();
k_err_t
err
;
TOS_CPU_INT_DISABLE
();
err
=
tos_chr_fifo_pop
(
&
AT_AGENT
->
uart_rx_fifo
,
data
);
TOS_CPU_INT_ENABLE
();
return
err
;
}
__STATIC__
int
at_uart_getchar
(
uint8_t
*
data
,
k_tick_t
timeout
)
{
#if AT_INPUT_TYPE_FRAME_EN
at_frame_len_mail_t
frame_len_mail
;
size_t
mail_size
;
if
(
AT_AGENT
->
fifo_available_len
==
0
)
{
if
(
tos_mail_q_pend
(
&
AT_AGENT
->
uart_rx_frame_mail
,
&
frame_len_mail
,
&
mail_size
,
timeout
)
!=
K_ERR_NONE
)
{
return
-
1
;
}
AT_AGENT
->
fifo_available_len
=
frame_len_mail
.
frame_len
;
}
if
(
at_uart_getchar_from_fifo
(
data
)
!=
K_ERR_NONE
)
{
return
-
1
;
}
AT_AGENT
->
fifo_available_len
-=
1
;
return
0
;
#else
tos_stopwatch_delay
(
1
);
if
(
tos_sem_pend
(
&
AT_AGENT
->
uart_rx_sem
,
timeout
)
!=
K_ERR_NONE
)
{
...
...
@@ -67,15 +94,14 @@ __STATIC__ int at_uart_getchar(uint8_t *data, k_tick_t timeout)
// return -1;
// }
TOS_CPU_INT_DISABLE
();
err
=
tos_chr_fifo_pop
(
&
AT_AGENT
->
uart_rx_fifo
,
data
);
TOS_CPU_INT_ENABLE
();
if
(
at_uart_getchar_from_fifo
(
data
)
!=
K_ERR_NONE
)
{
return
-
1
;
}
// tos_mutex_post(&AT_AGENT->uart_rx_lock);
return
err
==
K_ERR_NONE
?
0
:
-
1
;
return
0
;
#endif
/* AT_INPUT_TYPE_FRAME_EN */
}
__STATIC__
at_event_t
*
at_event_do_get
(
char
*
buffer
,
size_t
buffer_len
)
...
...
@@ -228,9 +254,9 @@ __STATIC__ at_parse_status_t at_uart_line_parse(void)
continue
;
}
if
(
data
==
'\0'
)
{
continue
;
}
// if (data == '\0') {
// continue;
// }
if
(
curr_len
<
recv_cache
->
buffer_size
)
{
recv_cache
->
buffer
[
curr_len
++
]
=
data
;
...
...
@@ -257,11 +283,11 @@ __STATIC__ at_parse_status_t at_uart_line_parse(void)
}
if
(
data
==
'\n'
&&
last_data
==
'\r'
)
{
// 0xd 0xa
curr_len
-=
1
;
recv_cache
->
buffer
[
curr_len
-
1
]
=
'\n'
;
recv_cache
->
recv_len
=
curr_len
;
// curr_len -= 1;
// recv_cache->buffer[curr_len - 1] = '\n';
// recv_cache->recv_len = curr_len;
if
(
curr_len
==
1
)
{
// only a blank newline, ignore
if
(
curr_len
==
2
)
{
// only a blank newline, ignore
last_data
=
0
;
curr_len
=
0
;
recv_cache
->
recv_len
=
0
;
...
...
@@ -475,7 +501,7 @@ __STATIC__ int at_cmd_do_exec(const char *format, va_list args)
cmd_len
=
vsnprintf
(
AT_AGENT
->
cmd_buf
,
AT_CMD_BUFFER_SIZE
,
format
,
args
);
printf
(
"AT CMD:
\n
%s
\n
"
,
AT_AGENT
->
cmd_buf
);
tos_kprintln
(
"AT CMD:
\n
%s
\n
"
,
AT_AGENT
->
cmd_buf
);
at_uart_send
((
uint8_t
*
)
AT_AGENT
->
cmd_buf
,
cmd_len
,
0xFFFF
);
...
...
@@ -927,48 +953,70 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size
goto
errout2
;
}
#if AT_INPUT_TYPE_FRAME_EN
buffer
=
tos_mmheap_alloc
(
AT_FRAME_LEN_MAIL_MAX
*
sizeof
(
at_frame_len_mail_t
));
if
(
!
buffer
)
{
goto
errout3
;
}
AT_AGENT
->
uart_rx_frame_mail_buffer
=
(
uint8_t
*
)
buffer
;
if
(
tos_mail_q_create
(
&
AT_AGENT
->
uart_rx_frame_mail
,
buffer
,
AT_FRAME_LEN_MAIL_MAX
,
sizeof
(
at_frame_len_mail_t
))
!=
K_ERR_NONE
)
{
goto
errout4
;
}
#else
if
(
tos_sem_create
(
&
AT_AGENT
->
uart_rx_sem
,
(
k_sem_cnt_t
)
0u
)
!=
K_ERR_NONE
)
{
goto
errout3
;
}
#endif
/* AT_INPUT_TYPE_FRAME_EN */
// if (tos_mutex_create(&AT_AGENT->uart_rx_lock) != K_ERR_NONE) {
// goto errout
4;
// goto errout
5;
// }
if
(
tos_mutex_create
(
&
AT_AGENT
->
uart_tx_lock
)
!=
K_ERR_NONE
)
{
goto
errout5
;
}
if
(
tos_task_create
(
&
AT_AGENT
->
parser
,
"at_parser"
,
at_parser
,
K_NULL
,
AT_PARSER_TASK_PRIO
,
at_parser_task_stack
,
AT_PARSER_TASK_STACK_SIZE
,
0
)
!=
K_ERR_NONE
)
{
goto
errout6
;
}
if
(
tos_
hal_uart_init
(
&
AT_AGENT
->
uart
,
uart_port
)
!=
0
)
{
if
(
tos_
mutex_create
(
&
AT_AGENT
->
global_lock
)
!=
K_ERR_NONE
)
{
goto
errout7
;
}
if
(
tos_
mutex_create
(
&
AT_AGENT
->
global_lock
)
!=
K_ERR_NONE
)
{
if
(
tos_
hal_uart_init
(
&
AT_AGENT
->
uart
,
uart_port
)
!=
0
)
{
goto
errout8
;
}
if
(
tos_task_create
(
&
AT_AGENT
->
parser
,
"at_parser"
,
at_parser
,
K_NULL
,
AT_PARSER_TASK_PRIO
,
at_parser_task_stack
,
AT_PARSER_TASK_STACK_SIZE
,
0
)
!=
K_ERR_NONE
)
{
goto
errout9
;
}
return
0
;
errout9:
tos_hal_uart_deinit
(
&
AT_AGENT
->
uart
);
errout8:
tos_
hal_uart_deinit
(
&
AT_AGENT
->
uart
);
tos_
mutex_destroy
(
&
AT_AGENT
->
global_lock
);
errout7:
tos_task_destroy
(
&
AT_AGENT
->
parser
);
errout6:
tos_mutex_destroy
(
&
AT_AGENT
->
uart_tx_lock
);
errout
5:
errout
6:
// tos_mutex_destroy(&AT_AGENT->uart_rx_lock);
//errout4:
//errout5:
#if AT_INPUT_TYPE_FRAME_EN
tos_mail_q_destroy
(
&
AT_AGENT
->
uart_rx_frame_mail
);
#else
tos_sem_destroy
(
&
AT_AGENT
->
uart_rx_sem
);
#endif
/* AT_INPUT_TYPE_FRAME_EN */
#if AT_INPUT_TYPE_FRAME_EN
errout4:
tos_mmheap_free
(
AT_AGENT
->
uart_rx_frame_mail_buffer
);
AT_AGENT
->
uart_rx_frame_mail_buffer
=
K_NULL
;
#endif
/* AT_INPUT_TYPE_FRAME_EN */
errout3:
at_recv_cache_deinit
();
...
...
@@ -990,15 +1038,23 @@ errout0:
__API__
void
tos_at_deinit
(
void
)
{
tos_
mutex_destroy
(
&
AT_AGENT
->
global_lock
);
tos_
task_destroy
(
&
AT_AGENT
->
parser
);
tos_hal_uart_deinit
(
&
AT_AGENT
->
uart
);
tos_
task_destroy
(
&
AT_AGENT
->
parser
);
tos_
mutex_destroy
(
&
AT_AGENT
->
global_lock
);
tos_mutex_destroy
(
&
AT_AGENT
->
uart_tx_lock
);
//tos_mutex_destroy(&AT_AGENT->uart_tx_lock);
#if AT_INPUT_TYPE_FRAME_EN
tos_mail_q_destroy
(
&
AT_AGENT
->
uart_rx_frame_mail
);
tos_mmheap_free
(
AT_AGENT
->
uart_rx_frame_mail_buffer
);
AT_AGENT
->
uart_rx_frame_mail_buffer
=
K_NULL
;
#else
tos_sem_destroy
(
&
AT_AGENT
->
uart_rx_sem
);
#endif
/* AT_INPUT_TYPE_FRAME_EN */
at_recv_cache_deinit
();
...
...
@@ -1017,10 +1073,25 @@ __API__ void tos_at_deinit(void)
/* To completely decouple the uart intterupt and at agent, we need a more powerful
hal(driver framework), that would be a huge work, we place it in future plans. */
#if AT_INPUT_TYPE_FRAME_EN
__API__
void
tos_at_uart_input_frame
(
uint8_t
*
pdata
,
uint16_t
len
)
{
int
ret
;
at_frame_len_mail_t
at_frame_len_mail
;
ret
=
tos_chr_fifo_push_stream
(
&
AT_AGENT
->
uart_rx_fifo
,
pdata
,
len
);
if
(
ret
!=
len
)
{
return
;
}
at_frame_len_mail
.
frame_len
=
len
;
tos_mail_q_post
(
&
AT_AGENT
->
uart_rx_frame_mail
,
&
at_frame_len_mail
,
sizeof
(
at_frame_len_mail_t
));
}
#else
__API__
void
tos_at_uart_input_byte
(
uint8_t
data
)
{
if
(
tos_chr_fifo_push
(
&
AT_AGENT
->
uart_rx_fifo
,
data
)
==
K_ERR_NONE
)
{
tos_sem_post
(
&
AT_AGENT
->
uart_rx_sem
);
}
}
#endif
/* AT_INPUT_TYPE_FRAME_EN */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录