728x90
반응형
1. 소스
#include "main.h"
#include "stm32f1xx_hal.h"
UART_HandleTypeDef huart1;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
int fputc(int ch, FILE *f)
{
uint8_t temp[1]={ch};
HAL_UART_Transmit(&huart1, temp, 1, 2);
return(ch);
}
int main(void)
{
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
HAL_StatusTypeDef R_stat;
uint8_t UsartData[1];
printf("Hello hny diy\r\n");
while (1)
{
R_stat = HAL_UART_Receive(&huart1,UsartData,1,1000);
if(R_stat == HAL_OK) HAL_UART_Transmit(&huart1,UsartData,1,1000);
}
}
728x90
반응형
'공부 > STM32F1' 카테고리의 다른 글
9.[stm32f103][hal] RCC_MCO 로 Clock 확인하기 (0) | 2017.09.20 |
---|---|
8.[stm32f103][hal] 외부 인터럽트 (0) | 2017.09.19 |
5.[stm32f103][hal]usart1 polling (0) | 2017.09.12 |
4.[stm32f103][hal] Fatal error: ST-LINK, No MCU device found (0) | 2017.09.11 |
3.[stm32f103][hal] GPIO 입출력 (0) | 2017.08.23 |