示例#1
0
static int mcux_lpsci_irq_rx_full(struct device *dev)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	u32_t flags = LPSCI_GetStatusFlags(config->base);

	return (flags & kLPSCI_RxDataRegFullFlag) != 0;
}
示例#2
0
static int mcux_lpsci_irq_tx_complete(struct device *dev)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	u32_t flags = LPSCI_GetStatusFlags(config->base);

	return (flags & kLPSCI_TxDataRegEmptyFlag) != 0;
}
示例#3
0
static void mcux_lpsci_poll_out(struct device *dev, unsigned char c)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;

	while (!(LPSCI_GetStatusFlags(config->base)
		& kLPSCI_TxDataRegEmptyFlag))
		;

	LPSCI_WriteByte(config->base, c);
}
示例#4
0
static int mcux_lpsci_poll_in(struct device *dev, unsigned char *c)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	u32_t flags = LPSCI_GetStatusFlags(config->base);
	int ret = -1;

	if (flags & kLPSCI_RxDataRegFullFlag) {
		*c = LPSCI_ReadByte(config->base);
		ret = 0;
	}

	return ret;
}
示例#5
0
static int mcux_lpsci_fifo_read(struct device *dev, u8_t *rx_data,
				const int len)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	u8_t num_rx = 0;

	while ((len - num_rx > 0) &&
	       (LPSCI_GetStatusFlags(config->base)
		& kLPSCI_RxDataRegFullFlag)) {

		rx_data[num_rx++] = LPSCI_ReadByte(config->base);
	}

	return num_rx;
}
示例#6
0
static int mcux_lpsci_fifo_fill(struct device *dev, const u8_t *tx_data,
				int len)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	u8_t num_tx = 0;

	while ((len - num_tx > 0) &&
	       (LPSCI_GetStatusFlags(config->base)
		& kLPSCI_TxDataRegEmptyFlag)) {

		LPSCI_WriteByte(config->base, tx_data[num_tx++]);
	}

	return num_tx;
}
示例#7
0
static int mcux_lpsci_err_check(struct device *dev)
{
	const struct mcux_lpsci_config *config = dev->config->config_info;
	u32_t flags = LPSCI_GetStatusFlags(config->base);
	int err = 0;

	if (flags & kLPSCI_RxOverrunFlag) {
		err |= UART_ERROR_OVERRUN;
	}

	if (flags & kLPSCI_ParityErrorFlag) {
		err |= UART_ERROR_PARITY;
	}

	if (flags & kLPSCI_FramingErrorFlag) {
		err |= UART_ERROR_FRAMING;
	}

	LPSCI_ClearStatusFlags(config->base, kLPSCI_RxOverrunFlag |
					      kLPSCI_ParityErrorFlag |
					      kLPSCI_FramingErrorFlag);

	return err;
}