-
Notifications
You must be signed in to change notification settings - Fork 1
/
a_uart.cpp
50 lines (39 loc) · 953 Bytes
/
a_uart.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <Arduino.h>
#include "app.h"
#include "a_uart.h"
uint8_t UART_Buff[4096];
void UART_Init(void)
{
}
void UART_Task(void *pvParameters)
{
uint16_t idx;
uint16_t len;
UBaseType_t uxHighWaterMark;
ESP_LOGI("UART", "Task Started");
uxHighWaterMark = uxTaskGetStackHighWaterMark(NULL);
ESP_LOGI("UART", "uxHighWaterMark = %d", uxHighWaterMark);
while (1)
{
idx = 0;
len = 0;
while (len != Serial.available())
{
len = Serial.available();
vTaskDelay(5 / portTICK_PERIOD_MS);
}
if (len && (len < sizeof(UART_Buff)))
{
while (len--)
{
UART_Buff[idx++] = Serial.read();
}
APP_ProcessData(UART_Buff, idx, APP_CHANNEL_UART);
}
vTaskDelay(5 / portTICK_PERIOD_MS);
}
}
void UART_Write(uint8_t *payLoad, uint16_t len)
{
Serial.write(payLoad, len);
}