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

Convert GPIO users to new GPIO API #20017

Closed
carlescufi opened this issue Oct 22, 2019 · 16 comments
Closed

Convert GPIO users to new GPIO API #20017

carlescufi opened this issue Oct 22, 2019 · 16 comments
Assignees
Labels
area: GPIO Enhancement Changes/Updates/Additions to existing features

Comments

@carlescufi
Copy link
Member

carlescufi commented Oct 22, 2019

List of users to convert:

Boards (DONE)

Module Assignee PR Done
boards/arm/actinius_icarus @anangl #20798
boards/arm/degu_evk @anangl #20798
boards/arm/hexiwear_k64 @MaureenHelm #21346
boards/arm/mimxrt1020_evk @MaureenHelm N/A - uses hal driver directly
boards/arm/mimxrt1050_evk @MaureenHelm N/A - uses hal driver directly
boards/arm/mimxrt1060_evk @MaureenHelm N/A - uses hal driver directly
boards/arm/mimxrt1064_evk @MaureenHelm N/A - uses hal driver directly
boards/arm/nrf52840_pca10090 @anangl #20184
boards/arm/particle_* @pabigot #21249
boards/arm/nrf52_pca20020 @pabigot
boards/arm/nrf9160_pca10090 @anangl

Drivers

Module Assignee PR Done
drivers/audio/tlv320dac310x @carlescufi #22172
drivers/bluetooth/hci @erwango #21062
drivers/can @karstenkoenig #20944
drivers/display/ssd1306 @jfischer-phytec-iot #21687
drivers/display/ssd16xx @jfischer-phytec-iot #21686
drivers/display/st7789v @jfischer-phytec-iot #22146
drivers/display/ili9340 @jfischer-phytec-iot #22146
drivers/display/mb_display.c @carlescufi #22157
drivers/eeprom/eeprom_at2x @pabigot #22219
drivers/ethernet/enc424j600-enc28j60 @jfischer-phytec-iot #22130
drivers/i2c/i2c_esp32 @ExtremeGTX #20194
drivers/ieee802154/ieee802154_cc1200 @tbursztyka, @pabigot #22323
drivers/ieee802154/ieee802154_cc2520 @tbursztyka, @pabigot #22323
drivers/ieee802154/ieee802154_mcr20a @jfischer-phytec-iot #22186
drivers/ieee802154/ieee802154_rf2xx*.c @mnkp #22214
drivers/led
drivers/led_strip @mbolivar #20393
drivers/lora @pabigot #22218
drivers/modem @carlescufi #22168
drivers/pwm/pwm_led_esp32 @ExtremeGTX #19753
drivers/spi/spi_context.h @erwango #21062
drivers/wifi/eswifi @erwango #21066
drivers/wifi/winc1500 @tbursztyka, @pabigot #22324

Samples

Module Assignee PR Done
samples/basic/blinky
samples/basic/button
samples/basic/threads @mnkp #21116
samples/bluetooth/hci_spi @erwango #22134
samples/bluetooth/mesh @mnkp #22122
samples/bluetooth/mesh_demo @mnkp #22122
samples/boards/96b_argonkey/microphone @avisconti #21203
samples/boards/96b_argonkey/sensors @avisconti #21203
samples/boards/bbc_microbit/ line_follower_robot @carlescufi #22068
samples/boards/bbc_microbit/pong @carlescufi #22068
samples/boards/bbc_microbit/sound @carlescufi #22068
samples/boards/nrf52/mesh/* @carlescufi #22129
samples/boards/reel_board/mesh_badge @carlescufi #22137
samples/boards/sensortile_box @avisconti #20941
samples/boards/up_squared/gpio_counter @dcpleung #21503
samples/drivers/CAN @karstenkoenig #20944
samples/drivers/espi @albertofloyd @franciscomunoz #22154 #22298
samples/drivers/gpio @mnkp #21117 ✓ Removed
samples/drivers/lcd_hd44780 @carlescufi #22098
samples/drivers/led_apa102c_bitbang @carlescufi #22099
samples/net/lwm2m_client @carlescufi #22092
samples/net/nats @nashif Removed in master ✓removed
samples/net/wifi/src/wifi_test.c @pabigot #22324
samples/sensor/fxos8700-hid @jfischer-phytec-iot #22139
samples/subsys/usb/hid-cdc @jfischer-phytec-iot #22139
samples/subsys/usb/hid-mouse @anangl #20237

Other (DONE)

Module Assignee PR Done
subsys/disk/disk_access_usdhc.c @JunYangNXP #21349
subsys/disk/disk_access_spi_sdhc.c @MaureenHelm #21918
subsys/usb/usb_device.c @jfischer-phytec-iot #22102
tests/bluetooth/mesh @carlescufi #22162
tests/boards/intel_s1000_crb @dcpleung #21471 #21983
tests/drivers/gpio/gpio_basic_api @pabigot @mnkp
tests/drivers/pinmux/pinmux_basic_api @mnkp #21619

Sensors (DONE)

Module Assignee PR Done
drivers/sensor/adt7420 @pabigot #21559
drivers/sensor/adxl362 @pabigot #21561
drivers/sensor/adxl372 @pabigot #21562
drivers/sensor/amg88xx @jfischer-phytec-iot #21579
drivers/sensor/apds9960 @jfischer-phytec-iot #21267 ✓ [ on reelboard ]
drivers/sensor/bma280 @pabigot #22104 no hw
drivers/sensor/bmc150_magn @pabigot #22110 no hw [EOL, not documented on BMI site]
drivers/sensor/bmg160 @pabigot #22111 no hw [EOL, not documented on BMI site]
drivers/sensor/bmi160 @pabigot #21582
drivers/sensor/ccs811 @pabigot #22072
drivers/sensor/dht @pabigot #21527
drivers/sensor/fxas21002 @MaureenHelm #21343
drivers/sensor/fxos8700 @MaureenHelm #21311
drivers/sensor/hmc5883l @microbuilder #21718
drivers/sensor/hts221 @pabigot #19834
drivers/sensor/iis3dhhc @avisconti #20941
drivers/sensor/isl29035 @pabigot #21523
drivers/sensor/lis2dh @pabigot #22113
drivers/sensor/lis2ds12 @avisconti #22040
drivers/sensor/lis2dw12 @avisconti #20941
drivers/sensor/lis2mdl @avisconti #21958
drivers/sensor/lis3mdl @avisconti #21972
drivers/sensor/lps22hh @avisconti #20941
drivers/sensor/lsm6dsl @pabigot #19839
drivers/sensor/lsm6dso @avisconti #20941
drivers/sensor/lsm9ds0_gyro @pabigot #22114
drivers/sensor/mcp9808 @pabigot #21427
drivers/sensor/mpu6050 @pabigot #21566
drivers/sensor/sht3xd @pabigot #20295
drivers/sensor/stts751 @avisconti #21828
drivers/sensor/sx9500 @pabigot #22115
drivers/sensor/ti_hdc @jfischer-phytec-iot #21543
drivers/sensor/tmp007 @pabigot #22135 ✓ [EOL, not documented on TI site]
drivers/sensor/vl53l0x @erwango #21063 ✓ [on several boards]
@carlescufi carlescufi added the Enhancement Changes/Updates/Additions to existing features label Oct 22, 2019
@vikrant8052
Copy link
Contributor

@carlescufi
Is that mean I have to update said Apps (via submitting new PRs) with latest GPIO APIs ?

@carlescufi
Copy link
Member Author

@carlescufi
Is that mean I have to update said Apps (via submitting new PRs) with latest GPIO APIs ?

Yes, please. Send a Pull Request against the topic-gpio branch, since that is the branch we are targeting, not master.

@vikrant8052
Copy link
Contributor

@carlescufi

ff873b8 & we have to take reference from this link for modifications (for nrfx). right ?

@carlescufi
Copy link
Member Author

@carlescufi

ff873b8 & we have to take reference from this link for modifications (for nrfx). right ?

That is modifying an actual GPIO driver, not a user of it. Take a look at the one of the PRs listed in the table in the main description of the issue to get a better feeling.

@pabigot
Copy link
Collaborator

pabigot commented Oct 23, 2019

@Vikrant8051 Specifically you should look at the commits with these subjects:

  • 2c6af1f [Mon Jun 3 12:29:18 2019 +0200] samples: button: update to use new GPIO API
  • 254e332 [Tue Jan 29 00:33:10 2019 +0100] samples: blinky: update to use new GPIO API

since the only GPIO use in the samples you're responsible for are toggling LEDs and responding to button presses. The only significant change in API will be in button handling.

(Note: The SHA1s above will change when the topic-branch is updated, so look for the commit message if you can't find them.)

@pabigot
Copy link
Collaborator

pabigot commented Nov 4, 2019

Some notes on converting GPIO users. If this is useful it may be edited for clarifications/extensions.

  • If you capture devicetree GPIOS_PIN information in a configuration structure, you should now also capture devicetree GPIOS_FLAGS information so it can be passed to gpio_pin_configure along with any direction/pull/other flags. Pin values should be stored as type gpio_pin_t, and flag values recorded from GPIOS_FLAGS as gpio_devicetree_flags_t (soon to be gpio_dt_flags_t). Note that gpio_dt_flags_t will not record flags that are not provided through devicetree, e.g. direction. If you are augmenting the flags from devicetree with other flags, use gpio_flags_t.

  • Don't make people search out the datasheet to figure out what the active level for a signal should be. Document in the device bindings the active level of each signal as produced/consumed by the device, and add a note that the flags value in the devicetree node should reflect any inversion performed between the device and the GPIO line.

  • Ensure that all devicetree nodes include GPIO_ACTIVE_HIGH or GPIO_ACTIVE_LOW as appropriate for the GPIO signal path.

  • sensors/drivers/hts221 (merged) provides a basic example of how to handle data-ready interrupts in the new infrastructure. Several platforms don't support level triggers, so the best practice is to use edge triggers. Some sensors produce level signals which require an operation (like reading the data) to clear the signal.

    Be aware that on board reset a level ready signal may already be asserted and if so no observation reports will be triggered. Thus it's important to check the signal state and trigger a handle operation if already signalled.

  • sensors/drivers/sht3xd ([TOPIC-GPIO] drivers: sensor: sht3xd: convert to new GPIO APIO #20295) shows an example of configuring triggers. It's mostly the same as for data-ready, but isn't enabled until the trigger is configured. Be aware that just as with data-ready device reset may have left the signal asserted so handling it when enabling is required here too.

A working idiom to handle interrupts is exemplified in the converted driver for st,hts221 (PENDING: See also #21548):

  • Provide a setup_signal(dev, enable) function that invokes gpio_pin_interrupt_configure() with GPIO_INT_DISABLE or (usually) GPIO_INT_EDGE_TO_ACTIVE based on the value of the passed enable flag.
  • Provide a handle_signal(dev) function that invokes setup_signal() to disable the interrupt, then processes the interrupt (signals a semaphore, queues a work item)
  • Provide a process_signal(dev) function that's run from the thread or work callback to retrieve the sample and do whatever is appropriate.
  • Use gpio_pin_configure() and gpio_add_callback() for the signal initializing the trigger infrastructure.
  • On trigger changes first disable the interrupt with setup_signal(dev, false)
  • When enabling the trigger use setup_signal(dev, true) then read the signal and if it's asserted invoke handle_signal(dev). This ensures that we don't miss a transition that occured before the interrupt was enabled.

NOTE Some drivers may use gpio_pin_write(..., ACTIVE) where the driver currently defines ACTIVE as zero or non-zero. A complete conversion solution would update the driver to use gpio_pin_set(..., 0) (or 1) and specify the active level in the devicetree flags. A minimal conversion may be achieved by using gpio_pin_set_raw(..., ACTIVE).

jenmwms added a commit to jenmwms/zephyr that referenced this issue Dec 18, 2019
This commit removes the tests for intel_s1000_crb based on
the discussion in zephyrproject-rtos#20017 to convert to new GPIO API.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
@jenmwms
Copy link
Collaborator

jenmwms commented Dec 18, 2019

Can someone please explain the reasoning to remove tests/boards/intel_s1000_crb? I need to include rationale in the commit for #21471 . Any thoughts, @dcpleung, @carlescufi?

@avisconti
Copy link
Collaborator

@carlescufi
I am still owner of the following 3 items: lis2dh, lis2ds12, lsm9ds0_gyro.
I am not sure I'll be able to complete them in the timeframe, as I have other urgencies till end of
January. Is there anyone who can volunteer on those tasks?

@avisconti
Copy link
Collaborator

@carlescufi
I am still owner of the following 3 items: lis2dh, lis2ds12, lsm9ds0_gyro.
I am not sure I'll be able to complete them in the timeframe, as I have other urgencies till end of
January. Is there anyone who can volunteer on those tasks?

OK, I changed also lis2ds12 (see #22040).
I think I'll not be able to proceed with the remaining two (lis2dh and lsm9ds0_gyro).

tbursztyka pushed a commit to tbursztyka/zephyr that referenced this issue Jan 28, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
tbursztyka pushed a commit to tbursztyka/zephyr that referenced this issue Jan 28, 2020
Also making cc1200's gpio int DTS based.

Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 28, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 28, 2020
Also making cc1200's gpio int DTS based.

Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 29, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 29, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 29, 2020
Also making cc1200's gpio int DTS based.

Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 29, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 29, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot pushed a commit to pabigot/zephyr that referenced this issue Jan 29, 2020
Also making cc1200's gpio int DTS based.

Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
tbursztyka pushed a commit to tbursztyka/zephyr that referenced this issue Jan 30, 2020
Fixes zephyrproject-rtos#20017

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
@pabigot
Copy link
Collaborator

pabigot commented Feb 3, 2020

All identified conversions have been completed. Any more that are discovered will be addressed when topic-gpio merges to master, or in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: GPIO Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

9 participants