Hi Stewart, Take this with a grain of salt. I have never used the ioexpander ... took a quick look after seeing your email. You need to populate ioexpander_ops_s within your board specific files. IOEXP_WRITEPIN is the "virtual function" that calls your board specific write_pin function (which calls stm32l4_gpiowrite?). Take a look at ioexpander.h and one of the following files to see how ioexpander_ops_s is initialized. Your board calls relay_gpio_register passing a pointer to the initialized ioexpander_dev_s.
(ioexpander_ops_s is part of ioexpander_dev_s) /drivers/analog/lmp92001.c ./drivers/ioexpander/skeleton.c ./drivers/ioexpander/mcp23x17.c ./drivers/ioexpander/ioe_rpmsg.c ./drivers/ioexpander/pcf8575.c ./drivers/ioexpander/pca9555.c ./drivers/ioexpander/iso1h812g.c ./drivers/ioexpander/pca9538.c ./drivers/ioexpander/sx1509.c ./drivers/ioexpander/iso1i813t.c ./drivers/ioexpander/pcf8574.c ./drivers/ioexpander/tca64xx.c ./drivers/ioexpander/ioe_dummy.c ./drivers/ioexpander/mcp23x08.c On Wed, 17 Jan 2024 at 07:50, Stewart Charnell <nu...@charnell.plus.com> wrote: > Hello Bowen, > > Thank you for you help. I am not sure if this question is for you or is > more architecture specific? > > I am looking at implementing the the relay ops (set()/get()) functions > within the drivers/power/relay/relay.c file. I can see how to implement > this based on the drivers/power/relay/relay_gpio.c file. However I think > that for control of a processor GPIO (rather than a GPIO controlled by > an IO expander) I will need to use the gpiowrite & gpioread functions > (rather than the IOEXP_WRITEPIN & IOEXP_READPIN functions used by the > relay_gpio.c file). Do you think this is correct, or am I missing > something? > > If the relay.c file is modified to implement the relay ops (set()/get()) > functions and uses the gpiowrite & gpioread functions then it becomes > board/processor specific (e.g. will need the stm32l4_gpiowrite & > stm32l4_gpioread functions for the nucleo-l432kc board I am working > with). For my relay driver that doesn't matter (if I don't export it > back to github as a patch), but to make the relay driver more generic > does this mean the relay.c file should be within the > arch/arm/src/<processor> directory? > > Kind regards > > Stewart > >