示例#1
0
static int mcux_lpsci_init(struct device *dev)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	lpsci_config_t uart_config;
	struct device *clock_dev;
	u32_t clock_freq;

	clock_dev = device_get_binding(config->clock_name);
	if (clock_dev == NULL) {
		return -EINVAL;
	}

	if (clock_control_get_rate(clock_dev, config->clock_subsys,
				   &clock_freq)) {
		return -EINVAL;
	}

	LPSCI_GetDefaultConfig(&uart_config);
	uart_config.enableTx = true;
	uart_config.enableRx = true;
	uart_config.baudRate_Bps = config->baud_rate;

	LPSCI_Init(config->base, &uart_config, clock_freq);

#ifdef CONFIG_UART_INTERRUPT_DRIVEN
	config->irq_config_func(dev);
#endif

	return 0;
}
/*!
 * @brief Main function
 */
int main(void)
{
    uint8_t ch;
    lpsci_config_t config;

    BOARD_InitPins();
    BOARD_BootClockRUN();
    CLOCK_SetLpsci0Clock(0x1U);

    /*
     * config.parityMode = kLPSCI_ParityDisabled;
     * config.stopBitCount = kLPSCI_OneStopBit;
     * config.enableTx = false;
     * config.enableRx = false;
     */
    LPSCI_GetDefaultConfig(&config);
    config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;

    LPSCI_Init(DEMO_LPSCI, &config, CLOCK_GetFreq(DEMO_LPSCI_CLKSRC));
    LPSCI_EnableTx(DEMO_LPSCI, true);
    LPSCI_EnableRx(DEMO_LPSCI, true);

    LPSCI_WriteBlocking(DEMO_LPSCI, txbuff, sizeof(txbuff) - 1);

    while (1)
    {
        LPSCI_ReadBlocking(DEMO_LPSCI, &ch, 1);
        LPSCI_WriteBlocking(DEMO_LPSCI, &ch, 1);
    }
}
示例#3
0
static int mcux_lpsci_init(struct device *dev)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	lpsci_config_t uart_config;
	u32_t clock_freq;

	clock_freq = CLOCK_GetFreq(config->clock_source);

	LPSCI_GetDefaultConfig(&uart_config);
	uart_config.enableTx = true;
	uart_config.enableRx = true;
	uart_config.baudRate_Bps = config->baud_rate;

	LPSCI_Init(config->base, &uart_config, clock_freq);

#ifdef CONFIG_UART_INTERRUPT_DRIVEN
	config->irq_config_func(dev);
#endif

	return 0;
}