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
|
extern UART_HandleTypeDef huart1;
void test_task_fun(void *arg){
const char t_data[]={"-----------\n"};
char tbuf[128];
char rbuf[128];
memset(tbuf,0,sizeof(tbuf));
memset(rbuf,0,sizeof(rbuf));
__HAL_UART_ENABLE_IT(&huart1,UART_IT_IDLE);
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)t_data, strlen(t_data));
/* Infinite loop */
for(;;)
{
if(HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t*)rbuf, sizeof(rbuf)-1)==HAL_OK)
{
memcpy(tbuf,rbuf,sizeof(rbuf));
HAL_UART_Transmit_DMA(&huart1, (uint8_t*)tbuf, strlen(tbuf));
}
osDelay(1);
}
}
|