在线时间177 小时
UID2086045
ST金币0
蝴蝶豆0
注册时间2014-4-15
金牌会员
- 最后登录
- 2020-7-23
|
a0a.1 0b0c
部分关键源代码预览如下,原理图及手板样片随后。
/*******************************************************************************
* Function Name : USART2_IRQHandler
* Description : This function handles USART2 global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void USART2_IRQHandler(void)
{
if (USART_GetITStatus(USART2, USART_IT_TC) != RESET) {
/* Set DE to low level pin(PA.8) */
GPIOA->BRR = GPIO_Pin_8;
/* Disable the USART2 Transmit Complete interrupt */
USART_ITConfig(USART2, USART_IT_TC, DISABLE);
/* Clear USART2 TC pending bit */
USART_ClearFlag(USART2, USART_FLAG_TC);
}
if (USART_GetITStatus(USART2, USART_IT_TXE) != RESET) {
if(USART2_Tx_length){
if (USART2_Tx_length==1) {
/* Set DE pin to high level pin(PA.8) */
GPIOA->BSRR = GPIO_Pin_8;
USART2->DR = USART2_Tx_Buffer[USART2_Tx_ptr_out++];
/* Enable USART TC interrupt */
USART_ITConfig(USART2, USART_IT_TC, ENABLE);
/* Disable USART TXE interrupt */
USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
} else {
if(USART2_Tx_ptr_out == USART2_Tx_Start){
/* Set DE pin to high level pin(PA.8) */
GPIOA->BSRR = GPIO_Pin_8;
USART2->DR = USART2_Tx_Buffer[USART2_Tx_ptr_out++];
} else {
if (USART2_Tx_ptr_out < USART2_Tx_End) {
USART2->DR = USART2_Tx_Buffer[USART2_Tx_ptr_out++];
} else {
/* Disable USART TXE interrupt */
USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
/* Enable USART TC interrupt */
USART_ITConfig(USART2, USART_IT_TC , ENABLE);
}
}
}
}else{
/* Set DE to low level pin(PA.8) */
GPIOA->BRR = GPIO_Pin_8;
/* Disable USART2 TXE interrupt */
USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
/* Disable USART2 TC interrupt */
USART_ITConfig(USART2, USART_IT_TC , DISABLE);
}
}
if(USART_GetITStatus(USART2,USART_IT_RXNE)==SET)
{
/* Send the received data to the PC Host*/
USART2_To_USB_Send_Data();
}
if(USART_GetFlagStatus(USART2,USART_FLAG_ORE)==SET)
{
(void)USART_ReceiveData(USART2);
}
}
工程源代码下载地址:
STM32_USB-FS-Device_Lib_V5.0.0.2.rar
(5.45 MB, 下载次数: 125)
|
|