반응형
0. 파일
1. STM32CubeMx
2. main.c
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f4xx_hal.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private variables ---------------------------------------------------------*/ UART_HandleTypeDef huart1; /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_USART1_UART_Init(void); /* USER CODE BEGIN PFP */ /* Private function prototypes -----------------------------------------------*/ uint8_t Usar1_val[1]; /* USER CODE END PFP */ /* USER CODE BEGIN 0 */ int fputc(int ch, FILE *f) { uint8_t temp[1]={ch}; HAL_UART_Transmit(&huart1, temp, 1, 2); return(ch); } /* USER CODE END 0 */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Receive_IT(&huart1,Usar1_val,1); printf("http://hnydiy.tistory.com *** USART1_IT_TEST\r\n"); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } | cs |
3. user_callback.c
1 2 3 4 5 6 7 8 9 10 11 12 | #include "stm32f4xx_hal.h" extern UART_HandleTypeDef huart1; extern uint8_t Usar1_val[1]; void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if(huart->Instance == USART1){ HAL_UART_Transmit(&huart1, (uint8_t*)Usar1_val, 1, 1000); } HAL_UART_Receive_IT(&huart1,(uint8_t*)Usar1_val,1); } | cs |
반응형
'공부 > STM32F4' 카테고리의 다른 글
5.[stm32f429] HID USB Host - Mouse (1) | 2018.06.08 |
---|---|
4.[stm32f429][hal] DAC 로 삼각파 만들기 (2) | 2018.03.08 |
2.[stm32f429][hal] USART1_Polling (0) | 2018.03.05 |
1.[stm32f429][hal] GPIO 인터럽트 (2) | 2018.03.02 |
STM32F429I 로 시작하기 (0) | 2017.12.18 |