drivers/serial/uart_nrfx_uart.c
static int baudrate_set(struct device *dev, u32_t baudrate)
{
	nrf_uart_baudrate_t nrf_baudrate; /* calculated baudrate divisor */

	switch (baudrate) {
	case 300:
		/* value not supported by Nordic HAL */
		nrf_baudrate = 0x00014000;
		break;
	case 600:
		/* value not supported by Nordic HAL */
		nrf_baudrate = 0x00027000;
		break;
	case 1200:
		nrf_baudrate = NRF_UART_BAUDRATE_1200;
		break;
	case 2400:
		nrf_baudrate = NRF_UART_BAUDRATE_2400;
		break;
	case 4800:
		nrf_baudrate = NRF_UART_BAUDRATE_4800;
		break;
	case 9600:
		nrf_baudrate = NRF_UART_BAUDRATE_9600;
		break;
	case 14400:
		nrf_baudrate = NRF_UART_BAUDRATE_14400;
		break;
	case 19200:
		nrf_baudrate = NRF_UART_BAUDRATE_19200;
		break;
	case 28800:
		nrf_baudrate = NRF_UART_BAUDRATE_28800;
		break;
	case 38400:
		nrf_baudrate = NRF_UART_BAUDRATE_38400;
		break;
	case 57600:
		nrf_baudrate = NRF_UART_BAUDRATE_57600;
		break;
	case 76800:
		nrf_baudrate = NRF_UART_BAUDRATE_76800;
		break;
	case 115200:
		nrf_baudrate = NRF_UART_BAUDRATE_115200;
		break;
	case 230400:
		nrf_baudrate = NRF_UART_BAUDRATE_230400;
		break;
	case 250000:
		nrf_baudrate = NRF_UART_BAUDRATE_250000;
		break;
	case 460800:
		nrf_baudrate = NRF_UART_BAUDRATE_460800;
		break;
	case 921600:
		nrf_baudrate = NRF_UART_BAUDRATE_921600;
		break;
	case 1000000:
		nrf_baudrate = NRF_UART_BAUDRATE_1000000;
		break;
	default:
		return -EINVAL;
	}

	nrf_uart_baudrate_set(NRF_UART0, nrf_baudrate);

	return 0;
}
/**
 * @brief Set the baud rate
 *
 * This routine set the given baud rate for the UART.
 *
 * @param dev UART device struct
 * @param baudrate Baud rate
 *
 * @return N/A
 */
@brief Set the baud rate
This routine set the given baud rate for the UART.

@param dev UART device struct
@param baudrate Baud rate

@return N/A
@brief Set the baud rate This routine set the given baud rate for the UART . @param dev UART device struct @param baudrate Baud rate @return N / A
static int baudrate_set(struct device *dev, u32_t baudrate)
{
	nrf_uart_baudrate_t nrf_baudrate; 
	switch (baudrate) {
	case 300:
		nrf_baudrate = 0x00014000;
		break;
	case 600:
		nrf_baudrate = 0x00027000;
		break;
	case 1200:
		nrf_baudrate = NRF_UART_BAUDRATE_1200;
		break;
	case 2400:
		nrf_baudrate = NRF_UART_BAUDRATE_2400;
		break;
	case 4800:
		nrf_baudrate = NRF_UART_BAUDRATE_4800;
		break;
	case 9600:
		nrf_baudrate = NRF_UART_BAUDRATE_9600;
		break;
	case 14400:
		nrf_baudrate = NRF_UART_BAUDRATE_14400;
		break;
	case 19200:
		nrf_baudrate = NRF_UART_BAUDRATE_19200;
		break;
	case 28800:
		nrf_baudrate = NRF_UART_BAUDRATE_28800;
		break;
	case 38400:
		nrf_baudrate = NRF_UART_BAUDRATE_38400;
		break;
	case 57600:
		nrf_baudrate = NRF_UART_BAUDRATE_57600;
		break;
	case 76800:
		nrf_baudrate = NRF_UART_BAUDRATE_76800;
		break;
	case 115200:
		nrf_baudrate = NRF_UART_BAUDRATE_115200;
		break;
	case 230400:
		nrf_baudrate = NRF_UART_BAUDRATE_230400;
		break;
	case 250000:
		nrf_baudrate = NRF_UART_BAUDRATE_250000;
		break;
	case 460800:
		nrf_baudrate = NRF_UART_BAUDRATE_460800;
		break;
	case 921600:
		nrf_baudrate = NRF_UART_BAUDRATE_921600;
		break;
	case 1000000:
		nrf_baudrate = NRF_UART_BAUDRATE_1000000;
		break;
	default:
		return -EINVAL;
	}
	nrf_uart_baudrate_set(NRF_UART0, nrf_baudrate);
	return 0;
}
static int baudrate_set ( struct device * dev , u32_t baudrate ) { nrf_uart_baudrate_t nrf_baudrate ; switch ( baudrate ) { case 300 : nrf_baudrate = 0x00014000 ; break ; case 600 : nrf_baudrate = 0x00027000 ; break ; case 1200 : nrf_baudrate = NRF_UART_BAUDRATE_1200 ; break ; case 2400 : nrf_baudrate = NRF_UART_BAUDRATE_2400 ; break ; case 4800 : nrf_baudrate = NRF_UART_BAUDRATE_4800 ; break ; case 9600 : nrf_baudrate = NRF_UART_BAUDRATE_9600 ; break ; case 14400 : nrf_baudrate = NRF_UART_BAUDRATE_14400 ; break ; case 19200 : nrf_baudrate = NRF_UART_BAUDRATE_19200 ; break ; case 28800 : nrf_baudrate = NRF_UART_BAUDRATE_28800 ; break ; case 38400 : nrf_baudrate = NRF_UART_BAUDRATE_38400 ; break ; case 57600 : nrf_baudrate = NRF_UART_BAUDRATE_57600 ; break ; case 76800 : nrf_baudrate = NRF_UART_BAUDRATE_76800 ; break ; case 115200 : nrf_baudrate = NRF_UART_BAUDRATE_115200 ; break ; case 230400 : nrf_baudrate = NRF_UART_BAUDRATE_230400 ; break ; case 250000 : nrf_baudrate = NRF_UART_BAUDRATE_250000 ; break ; case 460800 : nrf_baudrate = NRF_UART_BAUDRATE_460800 ; break ; case 921600 : nrf_baudrate = NRF_UART_BAUDRATE_921600 ; break ; case 1000000 : nrf_baudrate = NRF_UART_BAUDRATE_1000000 ; break ; default : return - EINVAL ; } nrf_uart_baudrate_set ( NRF_UART0 , nrf_baudrate ) ; return 0 ; }
@brief Set the baud rate
 This routine set the given baud rate for the UART.
@brief Set the baud rate This routine set the given baud rate for the UART .
/* calculated baudrate divisor */ /* value not supported by Nordic HAL */ /* value not supported by Nordic HAL */