For GPIO pins configured as outputs, there are two options to program the desired
value.
- Option 1
- Read, modify, and update the GPIO pin using the gpio.DATA_0 register.
- Example
- Set GPIO output pin 10 using the DATA_0 register.
- Read the gpio.DATA_0 register: Read gpio.DATA_0 register to the reg_val variable.
- Modify the value: Set reg_val [10] =1.
- Write updated value to output pin: Write reg_val to the gpio.DATA_0 register.
- Option 2
- Use the MASK_DATA_x_MSW/LSW registers to update one or more GPIO pins.
- Example
- Set output pins 20, 25, and 30 to 1 using the MASK_DATA_0_MSW register.
-
Generate the mask value for pins 20, 25, and 30: To drive pins 20, 25
and 30,
0xBDEFis the mask value for gpio.MASK_DATA_0_MSW [MASK_0_MSW]. -
Generate the data value for pins 20, 25, 30: To drive 1 on pins 20,
25, and 30,
0x4210is the data value for gpio.MASK_DATA_0_MSW [DATA_0_MSW]. -
Write the mask and data to the MASK_DATA_x_MSW register: Write
0xBDEF_4210to the gpio.MASK_DATA_0_MSW register.