-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[TOPIC GPIO] Adapt winc1500 wifi driver to new API #22156
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,6 @@ | |
| #include <drivers/gpio.h> | ||
| #include <drivers/spi.h> | ||
|
|
||
| #include <drivers/wifi/winc1500.h> | ||
|
|
||
| #include "wifi_winc1500_config.h" | ||
| #include <bus_wrapper/include/nm_bus_wrapper.h> | ||
|
|
||
|
|
@@ -23,6 +21,19 @@ extern tstrNmBusCapabilities egstrNmBusCapabilities; | |
| #define NM_DEBUG CONF_WINC_DEBUG | ||
| #define NM_BSP_PRINTF CONF_WINC_PRINTF | ||
|
|
||
| enum winc1500_gpio_index { | ||
| WINC1500_GPIO_IDX_CHIP_EN = 0, | ||
| WINC1500_GPIO_IDX_IRQN, | ||
| WINC1500_GPIO_IDX_RESET_N, | ||
|
|
||
| WINC1500_GPIO_IDX_MAX | ||
| }; | ||
|
|
||
| struct winc1500_gpio_configuration { | ||
| struct device *dev; | ||
| u32_t pin; | ||
|
||
| }; | ||
|
|
||
| struct winc1500_device { | ||
| struct winc1500_gpio_configuration *gpios; | ||
| struct gpio_callback gpio_cb; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,13 @@ LOG_MODULE_REGISTER(winc1500); | |
|
|
||
| #include "wifi_winc1500_config.h" | ||
|
|
||
| static | ||
| struct winc1500_gpio_configuration winc1500_gpios[WINC1500_GPIO_IDX_MAX] = { | ||
| { .dev = NULL, .pin = DT_INST_0_ATMEL_WINC1500_ENABLE_GPIOS_PIN }, | ||
| { .dev = NULL, .pin = DT_INST_0_ATMEL_WINC1500_IRQ_GPIOS_PIN }, | ||
| { .dev = NULL, .pin = DT_INST_0_ATMEL_WINC1500_RESET_GPIOS_PIN }, | ||
| }; | ||
|
|
||
| #define NM_BUS_MAX_TRX_SZ 256 | ||
|
|
||
| tstrNmBusCapabilities egstrNmBusCapabilities = { | ||
|
|
@@ -87,6 +94,37 @@ static s8_t spi_rw(u8_t *mosi, u8_t *miso, u16_t size) | |
|
|
||
| #endif | ||
|
|
||
| struct winc1500_gpio_configuration *winc1500_configure_gpios(void) | ||
| { | ||
| struct device *gpio_en, *gpio_irq, *gpio_reset; | ||
|
|
||
| gpio_en = device_get_binding( | ||
| DT_INST_0_ATMEL_WINC1500_ENABLE_GPIOS_CONTROLLER); | ||
| gpio_irq = device_get_binding( | ||
| DT_INST_0_ATMEL_WINC1500_IRQ_GPIOS_CONTROLLER); | ||
| gpio_reset = device_get_binding( | ||
| DT_INST_0_ATMEL_WINC1500_RESET_GPIOS_CONTROLLER); | ||
|
|
||
| gpio_pin_configure(gpio_en, | ||
| winc1500_gpios[WINC1500_GPIO_IDX_CHIP_EN].pin, | ||
| GPIO_OUTPUT | | ||
|
||
| DT_INST_0_ATMEL_WINC1500_ENABLE_GPIOS_FLAGS); | ||
| gpio_pin_configure(gpio_irq, | ||
| winc1500_gpios[WINC1500_GPIO_IDX_IRQN].pin, | ||
| GPIO_INPUT | | ||
| DT_INST_0_ATMEL_WINC1500_IRQ_GPIOS_FLAGS); | ||
| gpio_pin_configure(gpio_reset, | ||
| winc1500_gpios[WINC1500_GPIO_IDX_RESET_N].pin, | ||
| GPIO_OUTPUT | | ||
| DT_INST_0_ATMEL_WINC1500_RESET_GPIOS_FLAGS); | ||
|
|
||
| winc1500_gpios[WINC1500_GPIO_IDX_CHIP_EN].dev = gpio_en; | ||
| winc1500_gpios[WINC1500_GPIO_IDX_IRQN].dev = gpio_irq; | ||
| winc1500_gpios[WINC1500_GPIO_IDX_RESET_N].dev = gpio_reset; | ||
|
|
||
| return winc1500_gpios; | ||
| } | ||
|
|
||
| s8_t nm_bus_init(void *pvinit) | ||
| { | ||
| /* configure GPIOs */ | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of the reset pin we generally let the user configure its active level in DTS. I propose to follow the convention. In this case the name of the pin should reflect signal logical value. I.e. it should be
WINC1500_GPIO_IDX_RESET. Then in the code we would callgpio_pin_set(..., 1)to assert the reset (e.g. pull reset pin low) andgpio_pin_set(..., 0)to de-assert the reset.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change that. Here the point of that PR is just to switch to new API, not to do more work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this rework is not necessary given the scope of this work. We have not enforced the convert-to-logic-API in every driver that's already been accepted as converted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we prefer to stick to the old implementation - do not use logical levels - then we should use the
gpio_pin_set_rawfunctions. Otherwise the implementation is inconsistent, also quite confusing to the users reading/using the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this like #22241 should be using the raw API if it's not going to be updated to use the logical values.