Created
May 7, 2016 13:06
-
-
Save monpetit/1a2a5664138fefab9be7a6fd60abc3f5 to your computer and use it in GitHub Desktop.
STM32 HAL Driver Receive with Interrupt example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stm32f1xx_hal.h" | |
UART_HandleTypeDef UartHandle; /* UART 핸들러 */ | |
__IO ITStatus UartReady = RESET; /* UART 상태 지시자 */ | |
#define RXBUFFERSIZE 10 | |
uint8_t aRxBuffer[RXBUFFERSIZE]; /* UART 수신 버퍼 */ | |
int main(void) | |
{ | |
/* ... */ | |
/*## UART 수신 모드 시작 ###########################*/ | |
if (HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK) { | |
Error_Handler(); | |
} | |
/*## 전송이 완료될 때까지의 처리 ###################################*/ | |
while (UartReady != SET) { | |
/* ... */ | |
} | |
/* UART 상태 리셋 */ | |
UartReady = RESET; | |
/* ... */ | |
} | |
/** | |
* @brief Rx Transfer completed callback | |
* @param UartHandle: UART handle | |
* @retval None | |
*/ | |
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) | |
{ | |
/* 전송(수신)이 완료되면 상태 변경 */ | |
UartReady = SET; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment