33 #ifdef __BUILD_WITH_EXAMPLE__
34 #include "lpc17xx_libcfg.h"
64 uint32_t calcBaudrate = 0;
67 uint32_t mulFracDiv, dividerAddFracDiv;
68 uint32_t diviser = 0 ;
69 uint32_t mulFracDivOptimal = 1;
70 uint32_t dividerAddOptimal = 0;
71 uint32_t diviserOptimal = 0;
73 uint32_t relativeError = 0;
74 uint32_t relativeOptimalError = 100000;
103 for (mulFracDiv = 1 ; mulFracDiv <= 15 ;mulFracDiv++)
105 for (dividerAddFracDiv = 0 ; dividerAddFracDiv <= 15 ;dividerAddFracDiv++)
107 temp = (mulFracDiv * uClk) / ((mulFracDiv + dividerAddFracDiv));
109 diviser = temp / baudrate;
110 if ((temp % baudrate) > (baudrate / 2))
113 if (diviser > 2 && diviser < 65536)
115 calcBaudrate = temp / diviser;
117 if (calcBaudrate <= baudrate)
118 relativeError = baudrate - calcBaudrate;
120 relativeError = calcBaudrate - baudrate;
122 if ((relativeError < relativeOptimalError))
124 mulFracDivOptimal = mulFracDiv ;
125 dividerAddOptimal = dividerAddFracDiv;
126 diviserOptimal = diviser;
127 relativeOptimalError = relativeError;
128 if (relativeError == 0)
133 if (relativeError == 0)
274 while (UARTx->LSR & UART_LSR_RDR)
303 uart_set_divisors(UARTx, (UART_ConfigStruct->
Baud_rate));
315 switch (UART_ConfigStruct->
Databits){
338 switch (UART_ConfigStruct->
Parity)
360 switch (UART_ConfigStruct->
Stopbits){
519 uint32_t bToSend, bSent, timeOut, fifo_cnt;
520 uint8_t *pChar = txbuf;
531 if (timeOut == 0)
break;
535 if(timeOut == 0)
break;
537 while (fifo_cnt && bToSend){
553 while (fifo_cnt && bToSend) {
584 uint32_t bToRecv, bRecv, timeOut;
585 uint8_t *pChar = rxbuf;
594 while (!(UARTx->
LSR & UART_LSR_RDR)){
595 if (timeOut == 0)
break;
599 if(timeOut == 0)
break;
610 if (!(UARTx->
LSR & UART_LSR_RDR)) {
776 return (UARTx->
IIR & 0x03CF);
972 UARTx->
ACR |= ABIntType;
975 UARTx->
ACR |= ABIntType;
1312 uint32_t size, uint8_t ParityStick)
1339 UART_RS485Send(UARTx, &SlvAddr, 1, 1);
1351 return (UART_RS485Send(UARTx, pData, size, 0));