Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging/max32670 #2238

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions drivers/platform/maxim/max32670/maxim_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment on lines +65 to +90
Copy link
Contributor

@CiprianRegus CiprianRegus Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth mentioning in the commit message that MAX32670 only has 1 CS per SPI instance (which is already included in the gpio_cfg_spi pin config structs), so we don't need to configure it independently, as for the other Maxim drivers.


static int _max_spi_config(struct no_os_spi_desc *desc)
{
int32_t ret;
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions drivers/platform/maxim/max32670/maxim_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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