/* Calculate baudrate for LEUART given reference frequency and clock division. 
This function returns the baudrate that a LEUART module will use if configured with the given frequency and clock divisor. Notice that this function will not use actual HW configuration. It can be used to determinate if a given configuration is sufficiently accurate for the application. */
uint32_t LEUART_BaudrateCalc(uint32_t refFreq, uint32_t clkdiv)
/* Calculate baudrate for LEUART given reference frequency and clock division. 
This function returns the baudrate that a LEUART module will use if configured with the given frequency and clock divisor. Notice that this function will not use actual HW configuration. It can be used to determinate if a given configuration is sufficiently accurate for the application. */
uint32_t LEUART_BaudrateCalc(uint32_t refFreq, uint32_t clkdiv)
{
  uint32_t divisor;
  uint32_t remainder;
  uint32_t quotient;
  uint32_t br;
  clkdiv &= _LEUART_CLKDIV_MASK;
  divisor = 256 + clkdiv;
  quotient  = refFreq / divisor;
  remainder = refFreq % divisor;
  br = 256 * quotient;
  br += (256 * remainder) / divisor;
  return br;
}