diff --git a/drivers/platform/maxim/max32670/maxim_spi.c b/drivers/platform/maxim/max32670/maxim_spi.c index a49ca3d5056..654ce7bb5ff 100644 --- a/drivers/platform/maxim/max32670/maxim_spi.c +++ b/drivers/platform/maxim/max32670/maxim_spi.c @@ -57,6 +57,38 @@ /************************ Functions Definitions *******************************/ /******************************************************************************/ +/** + * @brief Configure the VDDIO level for a SPI interface + * @param desc - the SPI descriptor + * @return 0 in case of success, -EINVAL otherwise + */ +static int32_t _max_spi_config_pins(struct no_os_spi_desc *desc) +{ + struct max_spi_init_param *eparam; + mxc_gpio_cfg_t spi_pins; + + eparam = desc->extra; + + switch(desc->device_id) { + case 0: + spi_pins = gpio_cfg_spi0; + break; + case 1: + spi_pins = gpio_cfg_spi1; + break; + case 2: + spi_pins = gpio_cfg_spi2; + break; + default: + return -EINVAL; + } + + spi_pins.vssel = eparam->vssel; + MXC_GPIO_Config(&spi_pins); + + return 0; +} + static int _max_spi_config(struct no_os_spi_desc *desc) { int32_t ret; @@ -72,6 +104,10 @@ static int _max_spi_config(struct no_os_spi_desc *desc) goto err_init; } + ret = _max_spi_config_pins(desc); + if (ret) + return ret; + ret = MXC_SPI_SetMode(MXC_SPI_GET_SPI(desc->device_id), (mxc_spi_mode_t)desc->mode); if (ret) { diff --git a/drivers/platform/maxim/max32670/maxim_spi.h b/drivers/platform/maxim/max32670/maxim_spi.h index 456512355c2..9558e5fcea8 100644 --- a/drivers/platform/maxim/max32670/maxim_spi.h +++ b/drivers/platform/maxim/max32670/maxim_spi.h @@ -62,6 +62,7 @@ enum spi_ss_polarity { struct max_spi_init_param { uint32_t num_slaves; enum spi_ss_polarity polarity; + mxc_gpio_vssel_t vssel; }; #endif diff --git a/drivers/platform/maxim/max32670/maxim_uart.c b/drivers/platform/maxim/max32670/maxim_uart.c index b673dd9d33d..3b64355a81f 100644 --- a/drivers/platform/maxim/max32670/maxim_uart.c +++ b/drivers/platform/maxim/max32670/maxim_uart.c @@ -221,6 +221,39 @@ void uart_rx_callback(void *context) max_uart_read_nonblocking(d, &c, 1); } +/** + * @brief Configure the VDDIO for the UART pins. + * @param device_id - the interface number. + * @param vssel - the voltage level of the interface. + * @return 0 in case of success, -EINVAL otherwise. + */ +static int32_t _max_uart_pins_config(uint32_t device_id, mxc_gpio_vssel_t vssel) +{ + mxc_gpio_cfg_t uart_pins; + + switch (device_id) { + case 0: + uart_pins = gpio_cfg_uart0; + break; + case 1: + uart_pins = gpio_cfg_uart1; + break; + case 2: + uart_pins = gpio_cfg_uart2; + break; + case 3: + uart_pins = gpio_cfg_uart3; + break; + default: + return -EINVAL; + } + + uart_pins.vssel = vssel; + MXC_GPIO_Config(&uart_pins); + + return 0; +} + /** * @brief Initialize the UART communication peripheral. * @param desc - The UART descriptor. @@ -302,10 +335,10 @@ static int32_t max_uart_init(struct no_os_uart_desc **desc, } switch (eparam->flow) { - case MAX_UART_FLOW_DIS: + case UART_FLOW_DIS: flow = MXC_UART_FLOW_DIS; break; - case MAX_UART_FLOW_EN: + case UART_FLOW_EN: flow = MXC_UART_FLOW_EN; break; default: @@ -319,6 +352,10 @@ static int32_t max_uart_init(struct no_os_uart_desc **desc, goto error; } + ret = _max_uart_pins_config(descriptor->device_id, eparam->vssel); + if (ret) + goto error; + ret = MXC_UART_SetDataSize(uart_regs, size); if (ret != E_NO_ERROR) { ret = -EINVAL; diff --git a/drivers/platform/maxim/max32670/maxim_uart.h b/drivers/platform/maxim/max32670/maxim_uart.h index 935f0820a77..56c971d1778 100644 --- a/drivers/platform/maxim/max32670/maxim_uart.h +++ b/drivers/platform/maxim/max32670/maxim_uart.h @@ -49,8 +49,8 @@ * @brief UART flow control */ enum max_uart_flow_ctrl { - MAX_UART_FLOW_DIS, - MAX_UART_FLOW_EN + UART_FLOW_DIS, + UART_FLOW_EN }; /** @@ -58,6 +58,7 @@ enum max_uart_flow_ctrl { */ struct max_uart_init_param { enum max_uart_flow_ctrl flow; + mxc_gpio_vssel_t vssel; }; /**