MANU AATITYA
MANU AATITYA

Reputation: 1

ZEPHYR RTOS Configuring GPIO Pins

Hi I would like to configure a custom GPIO pin as output to control a motor on a STM32 H743Zi board running Zephyr RTOS.

The dts file of the board can be found in the folder or a separate file nucleo h743zi.dts code.

I would like to us the arduino pin mapping provided by the board ardunio r3 connector.dtsi code

The overlay file that I've developed so far is as follows code. I would like to configure the D0 pin (as per the arduino connector dtsi file) as a GPIO pin to control the motors.

However, I've not been able to configure the pin and I don't receive a high signal if the pin is turned on.

Any help to resolve this issue is appreciated.

Upvotes: 0

Views: 5039

Answers (1)

Long Nguyen
Long Nguyen

Reputation: 11

You can refer to the answer in this link: https://github.com/zephyrproject-rtos/zephyr/discussions/35932

In my case, I use Thunderboard Sensor 2 and my solution as below:

  1. Move to the <board.dsti> in folder /zephyr/dts/arm/silabs/efr32mg.dtsi insert your define GPIO to use:

     ...
     / {
     zephyr,user {
         signal-gpios = <&gpioa 8 GPIO_ACTIVE_HIGH>;
     };
     ...
    

Here, I use my board portA and pin 8 as schematic

  1. After you save the file, open the main file of your project and insert something as below:

     #define ZEPHYR_USER_NODE DT_PATH(zephyr_user)
     ...
     void main(void)
    {
     const struct gpio_dt_spec signal = 
     GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, signal_gpios);
     /* Configure the pin */
     gpio_pin_configure_dt(&signal, GPIO_OUTPUT_INACTIVE);
     ...
        while(1){
         /* Toggle the pin PA8*/
         gpio_pin_toggle(signal.port, signal.pin);
         k_msleep(SLEEP_TIME_MS);
        }
    ...
    

Upvotes: 1

Related Questions