drivers: serial: msp432p4xx: drop usage of uart_device_config
Create a driver specific configuration structure, containing the required fields only. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
14dda3af08
commit
dbdaf8ddba
1 changed files with 43 additions and 46 deletions
|
@ -19,6 +19,10 @@
|
|||
#include <driverlib/rom_map.h>
|
||||
#include <driverlib/uart.h>
|
||||
|
||||
struct uart_msp432p4xx_config {
|
||||
unsigned long base;
|
||||
};
|
||||
|
||||
struct uart_msp432p4xx_dev_data_t {
|
||||
/* UART config structure */
|
||||
eUSCI_UART_Config uartConfig;
|
||||
|
@ -32,8 +36,8 @@ struct uart_msp432p4xx_dev_data_t {
|
|||
static void uart_msp432p4xx_isr(const struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_device_config uart_msp432p4xx_dev_cfg_0 = {
|
||||
.base = (void *)DT_INST_REG_ADDR(0),
|
||||
static const struct uart_msp432p4xx_config uart_msp432p4xx_dev_cfg_0 = {
|
||||
.base = DT_INST_REG_ADDR(0),
|
||||
};
|
||||
|
||||
static struct uart_msp432p4xx_dev_data_t uart_msp432p4xx_dev_data_0 = {
|
||||
|
@ -112,7 +116,7 @@ static int baudrate_set(eUSCI_UART_Config *config, uint32_t baudrate)
|
|||
static int uart_msp432p4xx_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
eUSCI_UART_Config UartConfig;
|
||||
|
||||
/* Select P1.2 and P1.3 in UART mode */
|
||||
|
@ -132,10 +136,10 @@ static int uart_msp432p4xx_init(const struct device *dev)
|
|||
return err;
|
||||
}
|
||||
/* Configure UART Module */
|
||||
MAP_UART_initModule((unsigned long)config->base, &UartConfig);
|
||||
MAP_UART_initModule(config->base, &UartConfig);
|
||||
|
||||
/* Enable UART module */
|
||||
MAP_UART_enableModule((unsigned long)config->base);
|
||||
MAP_UART_enableModule(config->base);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
IRQ_CONNECT(DT_INST_IRQN(0),
|
||||
|
@ -150,9 +154,9 @@ static int uart_msp432p4xx_init(const struct device *dev)
|
|||
|
||||
static int uart_msp432p4xx_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
*c = MAP_UART_receiveData((unsigned long)config->base);
|
||||
*c = MAP_UART_receiveData(config->base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -160,22 +164,21 @@ static int uart_msp432p4xx_poll_in(const struct device *dev, unsigned char *c)
|
|||
static void uart_msp432p4xx_poll_out(const struct device *dev,
|
||||
unsigned char c)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
MAP_UART_transmitData((unsigned long)config->base, c);
|
||||
MAP_UART_transmitData(config->base, c);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static int uart_msp432p4xx_fifo_fill(const struct device *dev,
|
||||
const uint8_t *tx_data, int size)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
unsigned int num_tx = 0U;
|
||||
|
||||
while ((size - num_tx) > 0) {
|
||||
MAP_UART_transmitData((unsigned long)config->base,
|
||||
tx_data[num_tx]);
|
||||
if (MAP_UART_getInterruptStatus((unsigned long)config->base,
|
||||
MAP_UART_transmitData(config->base, tx_data[num_tx]);
|
||||
if (MAP_UART_getInterruptStatus(config->base,
|
||||
EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG)) {
|
||||
num_tx++;
|
||||
} else {
|
||||
|
@ -190,15 +193,14 @@ static int uart_msp432p4xx_fifo_read(const struct device *dev,
|
|||
uint8_t *rx_data,
|
||||
const int size)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
unsigned int num_rx = 0U;
|
||||
|
||||
while (((size - num_rx) > 0) &&
|
||||
MAP_UART_getInterruptStatus((unsigned long)config->base,
|
||||
EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG)) {
|
||||
MAP_UART_getInterruptStatus(
|
||||
config->base, EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG)) {
|
||||
|
||||
rx_data[num_rx++] =
|
||||
MAP_UART_receiveData((unsigned long)config->base);
|
||||
rx_data[num_rx++] = MAP_UART_receiveData(config->base);
|
||||
}
|
||||
|
||||
return num_rx;
|
||||
|
@ -206,62 +208,59 @@ static int uart_msp432p4xx_fifo_read(const struct device *dev,
|
|||
|
||||
static void uart_msp432p4xx_irq_tx_enable(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
MAP_UART_enableInterrupt((unsigned long)config->base,
|
||||
EUSCI_A_UART_TRANSMIT_INTERRUPT);
|
||||
MAP_UART_enableInterrupt(config->base, EUSCI_A_UART_TRANSMIT_INTERRUPT);
|
||||
}
|
||||
|
||||
static void uart_msp432p4xx_irq_tx_disable(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
MAP_UART_disableInterrupt((unsigned long)config->base,
|
||||
EUSCI_A_UART_TRANSMIT_INTERRUPT);
|
||||
MAP_UART_disableInterrupt(config->base,
|
||||
EUSCI_A_UART_TRANSMIT_INTERRUPT);
|
||||
}
|
||||
|
||||
static int uart_msp432p4xx_irq_tx_ready(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
unsigned int int_status;
|
||||
|
||||
int_status = MAP_UART_getInterruptStatus((unsigned long)config->base,
|
||||
EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG);
|
||||
int_status = MAP_UART_getInterruptStatus(
|
||||
config->base, EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG);
|
||||
|
||||
return (int_status & EUSCI_A_IE_TXIE);
|
||||
}
|
||||
|
||||
static void uart_msp432p4xx_irq_rx_enable(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
MAP_UART_enableInterrupt((unsigned long)config->base,
|
||||
EUSCI_A_UART_RECEIVE_INTERRUPT);
|
||||
MAP_UART_enableInterrupt(config->base, EUSCI_A_UART_RECEIVE_INTERRUPT);
|
||||
}
|
||||
|
||||
static void uart_msp432p4xx_irq_rx_disable(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
MAP_UART_disableInterrupt((unsigned long)config->base,
|
||||
EUSCI_A_UART_RECEIVE_INTERRUPT);
|
||||
MAP_UART_disableInterrupt(config->base, EUSCI_A_UART_RECEIVE_INTERRUPT);
|
||||
}
|
||||
|
||||
static int uart_msp432p4xx_irq_tx_complete(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
|
||||
return MAP_UART_getInterruptStatus((unsigned long)config->base,
|
||||
EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG);
|
||||
return MAP_UART_getInterruptStatus(
|
||||
config->base, EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG);
|
||||
}
|
||||
|
||||
static int uart_msp432p4xx_irq_rx_ready(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
unsigned int int_status;
|
||||
|
||||
int_status = MAP_UART_getInterruptStatus((unsigned long)config->base,
|
||||
EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG);
|
||||
int_status = MAP_UART_getInterruptStatus(
|
||||
config->base, EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG);
|
||||
|
||||
return (int_status & EUSCI_A_IE_RXIE);
|
||||
}
|
||||
|
@ -278,11 +277,10 @@ static void uart_msp432p4xx_irq_err_disable(const struct device *dev)
|
|||
|
||||
static int uart_msp432p4xx_irq_is_pending(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
unsigned int int_status;
|
||||
|
||||
int_status = MAP_UART_getEnabledInterruptStatus(
|
||||
(unsigned long)config->base);
|
||||
int_status = MAP_UART_getEnabledInterruptStatus(config->base);
|
||||
|
||||
return (int_status & (EUSCI_A_IE_TXIE | EUSCI_A_IE_RXIE));
|
||||
}
|
||||
|
@ -311,12 +309,11 @@ static void uart_msp432p4xx_irq_callback_set(const struct device *dev,
|
|||
*/
|
||||
static void uart_msp432p4xx_isr(const struct device *dev)
|
||||
{
|
||||
const struct uart_device_config *config = dev->config;
|
||||
const struct uart_msp432p4xx_config *config = dev->config;
|
||||
struct uart_msp432p4xx_dev_data_t * const dev_data = dev->data;
|
||||
unsigned int int_status;
|
||||
|
||||
int_status = MAP_UART_getEnabledInterruptStatus(
|
||||
(unsigned long)config->base);
|
||||
int_status = MAP_UART_getEnabledInterruptStatus(config->base);
|
||||
|
||||
if (dev_data->cb) {
|
||||
dev_data->cb(dev, dev_data->cb_data);
|
||||
|
@ -325,7 +322,7 @@ static void uart_msp432p4xx_isr(const struct device *dev)
|
|||
* Clear interrupts only after cb called, as Zephyr UART clients expect
|
||||
* to check interrupt status during the callback.
|
||||
*/
|
||||
MAP_UART_disableInterrupt((unsigned long)config->base, int_status);
|
||||
MAP_UART_disableInterrupt(config->base, int_status);
|
||||
}
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue