新手上路
- 积分
- 28
- 金钱
- 28
- 注册时间
- 2022-10-11
- 在线时间
- 5 小时
|

楼主 |
发表于 2022-10-31 14:39:06
|
显示全部楼层
- void USART1_IRQHandler(void)
- {
- HAL_UART_IRQHandler(&usart1_hand1er);
- HAL_UART_Receive_IT(&usart1_hand1er,rdata,sizeof(rdata)); //使能接收中断
- }
- void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
- {
- u8 rec;
- if(huart->Instance==USART1)//如果是串口1
- rec=*((huart->pRxBuffPtr)-1);
- // rec=rdata[0];
- HAL_UART_Transmit(&usart1_hand1er,&rec,1,1000);
- }
- int main(void)
- {
-
- HAL_Init(); //初始化HAL库
- Stm32_Clock_Init(360,25,2,8); //设置时钟,180Mhz
- delay_init(180);
-
- uart1_init();
-
- HAL_UART_Receive_IT(&usart1_hand1er,rdata,sizeof(rdata)); //使能接收中断
-
- while(1)
- {
-
- //HAL_UART_Transmit(&usart1_hand1er,buff,sizeof(buff),1000);
- //delay_ms(300);
复制代码 |
|