How to Control GPIO Using Registers in Zephyr?

Hi,

As the title suggests, I need to simulate I2C-like functionality using software. Therefore, I want to control GPIO using registers. I attempted the following approach, but the GPIO did not respond at all.

My hardware is nRF5340, and the project example is Matter Lock.

gpio_pin_configure_dt(&comm_data, GPIO_OUTPUT_INACTIVE);  // output low
volatile NRF_GPIO_Type *gpio = NRF_P1;
  
if ((udata & 0x01) == 0) gpio->OUTSET &= ~BIT(BCOMM_DATA_PIN);//gpio_pin_set_dt(&comm_data, 0);
else                     gpio->OUTSET |= BIT(BCOMM_DATA_PIN);//gpio_pin_set_dt(&comm_data, 1);

Parents
  • Hi,

    My hardware is nRF5340, and the project example is Matter Lock.

    First and foremost: To test this new feature, add it to a simple project first, such as hello worlds. Then integrate it into more complex projects when it works standalone.

    As the title suggests, I need to simulate I2C-like functionality using software.

    Cant you just use the I2C peripheral? That is usually a better idea than bit-banging.

    Regards,
    Sigurd Hellesvik

Reply
  • Hi,

    My hardware is nRF5340, and the project example is Matter Lock.

    First and foremost: To test this new feature, add it to a simple project first, such as hello worlds. Then integrate it into more complex projects when it works standalone.

    As the title suggests, I need to simulate I2C-like functionality using software.

    Cant you just use the I2C peripheral? That is usually a better idea than bit-banging.

    Regards,
    Sigurd Hellesvik

Children
Related