Skip to content

Commit

Permalink
fix uart2 interupt.
Browse files Browse the repository at this point in the history
  • Loading branch information
coregiu committed Dec 1, 2023
1 parent 9dd7def commit afabf80
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions software/main_control/src/src/audio_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,34 @@ char *receive_audio_command()
return "1C";
}


extern char usart2Buf[64];
extern char usart2Len;
/*
************************************************************
* 函数名称: USART2_IRQHandler
*
* 函数功能: 串口2收发中断
*
* 入口参数: 无
*
* 返回参数: 无
*
* 说明:
************************************************************
*/
void USART2_IRQHandler(void)
{

if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) //接收中断
{
LED = 0;
// if(usart2Len >= 64) //防止数据过多,导致内存溢出
// usart2Len = 0;
// usart2Buf[usart2Len++] = USART2->DR;

USART_ClearFlag(USART2, USART_FLAG_RXNE);
}
}

const struct module_command_receiver audio_receiver = {init_audio_state, receive_audio_command};
4 changes: 2 additions & 2 deletions software/main_control/src/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(void)

while (1)
{
char *commands = audio_receiver.receive_commands();
execute_commands(commands);
// char *commands = audio_receiver.receive_commands();
// execute_commands(commands);
}
}

0 comments on commit afabf80

Please sign in to comment.