Skip to content

Commit d4fb5c3

Browse files
committed
ADDS UART IDLE LINE
1 parent 219db57 commit d4fb5c3

File tree

104 files changed

+19643
-4893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+19643
-4893
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
66BE74F758C12D739921AEA421D593D3=1
2+
8DF89ED150041C4CBC7CB9A9CAA90856=0C2D9101539AAC194A0CD1278D4AEC9A
23
DC22A860405A8BF2F2C095E5B6529F12=0C2D9101539AAC194A0CD1278D4AEC9A
34
eclipse.preferences.version=1

playground/stm32/stm32f401ccu6-UART-DMA-circular/Core/Src/main.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
/* Private includes ----------------------------------------------------------*/
2323
/* USER CODE BEGIN Includes */
24+
#include "stdio.h"
25+
#include "string.h"
2426

2527
/* USER CODE END Includes */
2628

@@ -32,6 +34,13 @@
3234
/* Private define ------------------------------------------------------------*/
3335
/* USER CODE BEGIN PD */
3436

37+
#define UART_RX_BUFFER_SIZE 50 // maximum data we expect
38+
39+
uint8_t UART1_rx_buffer[UART_RX_BUFFER_SIZE] = {0}; // to hold the received message
40+
uint16_t rx_data_len = 0; // length of the received data
41+
42+
43+
3544
/* USER CODE END PD */
3645

3746
/* Private macro -------------------------------------------------------------*/
@@ -94,6 +103,7 @@ int main(void)
94103
MX_USART1_UART_Init();
95104
/* USER CODE BEGIN 2 */
96105

106+
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, UART1_rx_buffer, UART_RX_BUFFER_SIZE);
97107
/* USER CODE END 2 */
98108

99109
/* Infinite loop */
@@ -103,6 +113,8 @@ int main(void)
103113
/* USER CODE END WHILE */
104114

105115
/* USER CODE BEGIN 3 */
116+
117+
// nothing to do here
106118
}
107119
/* USER CODE END 3 */
108120
}
@@ -219,10 +231,23 @@ static void MX_GPIO_Init(void)
219231

220232
/* USER CODE BEGIN 4 */
221233

222-
void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) {
223-
dma_recv_complete = 1;
224-
// HAL_UART_Transmit(&huart1, (uint8_t*)"DMA_BUFF: ", strlen("DMA_BUFF: "), 10);
225-
// HAL_UART_Transmit(&huart1, rx_data, 12, 100);
234+
/**
235+
* called when idle event is received OR we receive the full data length
236+
* we can receive variable length of data
237+
*/
238+
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
239+
// check the size of the received stream
240+
rx_data_len = Size;
241+
static char buffer[UART_RX_BUFFER_SIZE] = {0};
242+
243+
sprintf(buffer, "Size: %d\r\n", rx_data_len);
244+
HAL_UART_Transmit(&huart1, (uint8_t*) buffer, strlen(buffer), 500);
245+
246+
// process it
247+
HAL_UART_Transmit(&huart1, UART1_rx_buffer, rx_data_len, 500);
248+
249+
// restart the idle event check
250+
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, UART1_rx_buffer, UART_RX_BUFFER_SIZE);
226251

227252
}
228253

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
../Core/Src/main.c:77:5:main 1
2+
../Core/Src/main.c:126:6:SystemClock_Config 3
3+
../Core/Src/main.c:168:13:MX_USART1_UART_Init 2
4+
../Core/Src/main.c:199:13:MX_DMA_Init 1
5+
../Core/Src/main.c:217:13:MX_GPIO_Init 1
6+
../Core/Src/main.c:238:6:HAL_UARTEx_RxEventCallback 1
7+
../Core/Src/main.c:260:6:Error_Handler 1
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Core/Src/main.o: ../Core/Src/main.c ../Core/Inc/main.h \
2+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h \
3+
../Core/Inc/stm32f4xx_hal_conf.h \
4+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h \
5+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h \
6+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h \
7+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h \
8+
../Drivers/CMSIS/Include/core_cm4.h \
9+
../Drivers/CMSIS/Include/cmsis_version.h \
10+
../Drivers/CMSIS/Include/cmsis_compiler.h \
11+
../Drivers/CMSIS/Include/cmsis_gcc.h \
12+
../Drivers/CMSIS/Include/mpu_armv7.h \
13+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h \
14+
../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h \
15+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h \
16+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h \
17+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h \
18+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h \
19+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h \
20+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h \
21+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h \
22+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h \
23+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h \
24+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h \
25+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h \
26+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h \
27+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h
28+
../Core/Inc/main.h:
29+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:
30+
../Core/Inc/stm32f4xx_hal_conf.h:
31+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:
32+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:
33+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:
34+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h:
35+
../Drivers/CMSIS/Include/core_cm4.h:
36+
../Drivers/CMSIS/Include/cmsis_version.h:
37+
../Drivers/CMSIS/Include/cmsis_compiler.h:
38+
../Drivers/CMSIS/Include/cmsis_gcc.h:
39+
../Drivers/CMSIS/Include/mpu_armv7.h:
40+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h:
41+
../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:
42+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:
43+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:
44+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h:
45+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h:
46+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:
47+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h:
48+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h:
49+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h:
50+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h:
51+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h:
52+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:
53+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h:
54+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h:
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
../Core/Src/main.c:77:5:main 8 static
2+
../Core/Src/main.c:126:6:SystemClock_Config 88 static
3+
../Core/Src/main.c:168:13:MX_USART1_UART_Init 8 static
4+
../Core/Src/main.c:199:13:MX_DMA_Init 16 static
5+
../Core/Src/main.c:217:13:MX_GPIO_Init 16 static
6+
../Core/Src/main.c:238:6:HAL_UARTEx_RxEventCallback 16 static
7+
../Core/Src/main.c:260:6:Error_Handler 4 static,ignoring_inline_asm
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
../Core/Src/stm32f4xx_hal_msp.c:64:6:HAL_MspInit 1
2+
../Core/Src/stm32f4xx_hal_msp.c:87:6:HAL_UART_MspInit 3
3+
../Core/Src/stm32f4xx_hal_msp.c:143:6:HAL_UART_MspDeInit 2
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Core/Src/stm32f4xx_hal_msp.o: ../Core/Src/stm32f4xx_hal_msp.c \
2+
../Core/Inc/main.h ../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h \
3+
../Core/Inc/stm32f4xx_hal_conf.h \
4+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h \
5+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h \
6+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h \
7+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h \
8+
../Drivers/CMSIS/Include/core_cm4.h \
9+
../Drivers/CMSIS/Include/cmsis_version.h \
10+
../Drivers/CMSIS/Include/cmsis_compiler.h \
11+
../Drivers/CMSIS/Include/cmsis_gcc.h \
12+
../Drivers/CMSIS/Include/mpu_armv7.h \
13+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h \
14+
../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h \
15+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h \
16+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h \
17+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h \
18+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h \
19+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h \
20+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h \
21+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h \
22+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h \
23+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h \
24+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h \
25+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h \
26+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h \
27+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h
28+
../Core/Inc/main.h:
29+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:
30+
../Core/Inc/stm32f4xx_hal_conf.h:
31+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:
32+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:
33+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:
34+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h:
35+
../Drivers/CMSIS/Include/core_cm4.h:
36+
../Drivers/CMSIS/Include/cmsis_version.h:
37+
../Drivers/CMSIS/Include/cmsis_compiler.h:
38+
../Drivers/CMSIS/Include/cmsis_gcc.h:
39+
../Drivers/CMSIS/Include/mpu_armv7.h:
40+
../Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h:
41+
../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:
42+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h:
43+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h:
44+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h:
45+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h:
46+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h:
47+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h:
48+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h:
49+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h:
50+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h:
51+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h:
52+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:
53+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h:
54+
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h:
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
../Core/Src/stm32f4xx_hal_msp.c:64:6:HAL_MspInit 16 static
2+
../Core/Src/stm32f4xx_hal_msp.c:87:6:HAL_UART_MspInit 48 static
3+
../Core/Src/stm32f4xx_hal_msp.c:143:6:HAL_UART_MspDeInit 16 static

0 commit comments

Comments
 (0)