W7500 UART Setting
/*******************************************************************************
* Function Name :
* Parameters :
* Return :
* Description :
*******************************************************************************/
void UART_Config(uint8_t uart, uint32_t baud)
{
UART_InitTypeDef UART_InitStructure;
if(uart == USART_0){
/* UART Configuration for UART1*/
UART_StructInit(&UART_InitStructure, baud);
UART_Init(UART0,&UART_InitStructure);
/* Configure Uart1 Interrupt Enable*/
UART_ITConfig(UART0,(UART_IT_FLAG_RXI),ENABLE);
/* NVIC configuration */
NVIC_ClearPendingIRQ(UART0_IRQn);
NVIC_EnableIRQ(UART0_IRQn);
}
else if(uart == USART_1){
/* UART Configuration for UART1*/
UART_StructInit(&UART_InitStructure, baud);
UART_Init(UART1,&UART_InitStructure);
/* Configure Uart1 Interrupt Enable*/
UART_ITConfig(UART1,(UART_IT_FLAG_RXI),ENABLE);
/* NVIC configuration */
NVIC_ClearPendingIRQ(UART1_IRQn);
NVIC_EnableIRQ(UART1_IRQn);
}
else if(uart == USART_2){
S_UART_Init(baud);
S_UART_ITConfig((S_UART_CTRL_RXI),ENABLE);
/* NVIC configuration */
NVIC_ClearPendingIRQ(UART2_IRQn);
NVIC_EnableIRQ(UART2_IRQn);
}
}
/**
* @brief This function handles UART0 Handler.
* @param None
* @retval None
*/
uint8_t ch0, ch1, ch2;
void UART0_Handler(void)
{
if(UART_GetITStatus(UART0,UART_IT_FLAG_RXI))
{
UART_ClearITPendingBit(UART0,UART_IT_FLAG_RXI);
ch0 = UART_ReceiveData(UART0);
}
else if(UART_GetITStatus(UART0,UART_IT_FLAG_TXI))
{
UART_ClearITPendingBit(UART0,UART_IT_FLAG_TXI);
}
}
/**
* @brief This function handles UART1 Handler.
* @param None
* @retval None
*/
void UART1_Handler(void)
{
if(UART_GetITStatus(UART1,UART_IT_FLAG_RXI)){
UART_ClearITPendingBit(UART1,UART_IT_FLAG_RXI);
ch1 = UART_ReceiveData(UART1);
}
else if(UART_GetITStatus(UART1,UART_IT_FLAG_TXI)){
UART_ClearITPendingBit(UART1,UART_IT_FLAG_TXI);
}
}
/**
* @brief This function handles UART2 Handler.
* @param None
* @retval None
*/
void UART2_Handler(void)
{
if(S_UART_GetFlagStatus(S_UART_INTSTATUS_RXI)){
S_UART_ClearITPendingBit(S_UART_INTSTATUS_RXI);
ch2 = S_UART_ReceiveData();
}
else if(S_UART_GetFlagStatus(S_UART_INTSTATUS_TXI)){
S_UART_ClearITPendingBit(S_UART_INTSTATUS_TXI);
}
}
'초보의 아웅다웅 설계하기 > W7500P' 카테고리의 다른 글
W7500P - 리셋타이밍 (0) | 2019.04.16 |
---|---|
W7500P Soft I2C Setting (0) | 2019.04.16 |
W7500P - SWD와 PA3, PA4 (0) | 2019.04.12 |
Wiznet W7500P Keil에서 J-link(or ST-Link) 사용하여 디버깅 (0) | 2018.12.18 |
Wiznet W7500P의 추가 메모리 사용 (0) | 2018.11.12 |