78 denominator = 16 * baudrate * 2;
79 bdr = numerator / denominator;
87 fd = numerator - bdr * denominator;
88 bfr = ( fd * 256 ) / denominator;
89 UARTx->BDR = ( uint16_t )( bdr & 0xffff );
90 UARTx->BFR = ( uint8_t )( bfr & 0xff );
113 #if 0 // not supported 114 if( UARTx == ( UARTn_Type* )UART0 )
122 if( UARTx == ( UARTn_Type* )UART1 )
130 while( UARTx->LSR & UARTn_LSR_RDR )
135 while( !( UARTx->LSR & UARTn_LSR_THRE ) );
154 tmp = ( UARTx->LCR & UARTn_LCR_BREAK_EN ) & UARTn_LCR_BITMASK;
159 tmp |= UARTn_LCR_WLEN5;
162 tmp |= UARTn_LCR_WLEN6;
165 tmp |= UARTn_LCR_WLEN7;
169 tmp |= UARTn_LCR_WLEN8;
179 tmp |= UARTn_LCR_PARITY_EN;
180 switch( UARTn_Config->
Parity )
183 tmp |= UARTn_LCR_PARITY_ODD;
187 tmp |= UARTn_LCR_PARITY_EVEN;
191 tmp |= UARTn_LCR_PARITY_F_1;
195 tmp |= UARTn_LCR_PARITY_F_0;
205 tmp |= UARTn_LCR_STOPBIT_SEL;
213 UARTx->LCR = ( uint8_t )( tmp & UARTn_LCR_BITMASK );
233 #if 0 // not supported 234 if( UARTx == ( UARTn_Type* )UART0 )
243 if( UARTx == ( UARTn_Type* )UART1 )
267 if( UARTn_Config == NULL )
307 switch( UARTn_IntCfg )
310 tmp = UARTn_IER_RBRINT_EN;
313 tmp = UARTn_IER_THREINT_EN;
316 tmp = UARTn_IER_RLSINT_EN;
319 tmp = UARTn_IER_TXE_EN;
329 UARTx->IER &= ( ~tmp ) & UARTn_IER_BITMASK;
363 tmp = UARTn_DCR_LBON;
366 tmp = UARTn_DCR_RXINV;
369 tmp = UARTn_DCR_TXINV;
372 tmp = UARTn_DCR_RXINV | UARTn_DCR_TXINV;
384 UARTx->DCR &= ( ~tmp ) & UARTn_DCR_BITMASK;
408 UARTx->IDTR = waitval;
430 UARTx->LCR |= UARTn_LCR_BREAK_EN;
451 return ( ( UARTx->LSR ) & UARTn_LSR_BITMASK );
463 if( UARTx->LSR & UARTn_LSR_TEMT )
526 uint32_t bToSend, bSent, timeOut;
527 uint8_t* pChar = txbuf;
539 timeOut = UARTn_BLOCKING_TIMEOUT;
540 while( !( UARTx->LSR & UARTn_LSR_THRE ) )
564 while( UARTx->LSR_b.TEMT == 0 );
573 if( !( UARTx->LSR & UARTn_LSR_THRE ) )
610 uint32_t bToRecv, bRecv, timeOut;
611 uint8_t* pChar = rxbuf;
623 timeOut = UARTn_BLOCKING_TIMEOUT;
624 while( !( UARTx->LSR & UARTn_LSR_RDR ) )
654 if( !( UARTx->LSR & UARTn_LSR_RDR ) )
HAL_Status_Type HAL_UART_DeInit(UARTn_Type *UARTx)
Deinitialize the UARTn peripheral registers to their default reset values.
HAL_Status_Type HAL_UART_ConfigStructInit(UARTn_CFG_Type *UARTn_Config)
Fills each UARTn_Config member with its default value:
uint8_t HAL_UART_ReceiveByte(UARTn_Type *UARTx)
Receive a single data from UART peripheral.
uint32_t HAL_UART_Receive(UARTn_Type *UARTx, uint8_t *rxbuf, uint32_t buflen, TRANSFER_BLOCK_Type flag)
Receive a block of data via UART peripheral.
HAL_Status_Type HAL_UART_ForceBreak(UARTn_Type *UARTx)
Force BREAK character on UART line, output pin UARTn TXD is forced to logic 0.
Contains all macro definitions and function prototypes support for uartn firmware library on A31R71x.
static uint32_t UARTn_BaseClock
static void uart_set_divisors(UARTn_Type *UARTx, uint32_t baudrate)
Determines best dividers to get a target clock rate.
Contains all macro definitions and function prototypes support for scu firmware library on A31R71x.
uint32_t HAL_UART_Transmit(UARTn_Type *UARTx, uint8_t *txbuf, uint32_t buflen, TRANSFER_BLOCK_Type flag)
Send a block of data via UART peripheral.
UARTn_DATA_BIT_Type Databits
HAL_Status_Type HAL_UART_DataControlConfig(UARTn_Type *UARTx, UARTn_DATA_CONTROL_Type Mode, FunctionalState NewState)
Configure Data Control mode for UART peripheral.
HAL_Status_Type HAL_UART_IFDelayConfig(UARTn_Type *UARTx, uint8_t waitval)
Configure inter-frame delay time for UART peripheral.
UARTn_PARITY_BIT_Type Parity
HAL_Status_Type HAL_UART_TransmitByte(UARTn_Type *UARTx, uint8_t Data)
Transmit a single data through UART peripheral.
FlagStatus HAL_UART_CheckBusy(UARTn_Type *UARTx)
Check whether if UART is busy or not.
UARTn_STOP_BIT_Type Stopbits
void HAL_SCU_Peripheral_SetReset2(uint32_t u32EachPeri2)
Set/Reset Each Peripheral Block Reset of PPRST2 Register.
HAL_Status_Type HAL_UART_Init(UARTn_Type *UARTx, UARTn_CFG_Type *UARTn_Config)
Initialize the UARTn peripheral with the specified parameters.
void HAL_SCU_Peripheral_EnableClock2(uint32_t u32PeriClk2, uint32_t u32Ind)
Set Each Peripheral Clock.
HAL_Status_Type HAL_UART_ConfigInterrupt(UARTn_Type *UARTx, UARTn_INT_Type UARTn_IntCfg, FunctionalState NewState)
Configure the peripheral interrupt.
uint8_t HAL_UART_GetLineStatus(UARTn_Type *UARTx)
This function returns the current value of Line Status Register.