0

I'm trying to read the inputs from a GPIO through a microblaze implemented in a Basys3 FPGA board. My GPIO inputs are coming from the 16 dip switches in the Basys3 board. Currently I'm using the following line of code to read the GPIO input to a variable.

DataRead = XGpio_DiscreteRead(&GpioDevice, 2);

where "GpioDevice" is the instance name and '2' is the channel number. This line reads the 16 switches and assigns the Hex value of the switches to the u32 variable 'DataRead'.

Is there a way to read only a portion of the GPIO input (ex: if my switches are set to 1111 0000 1010 1100, is there a way to read only 4 bits from that)

OR

is there a way to read all 16bits and assign the value to a bit vector rather than to a u32.

My goal is to use individual bits of the GPIO input to do some sort of a task.

if bit 1 = 1 then do something

if bit 2 = 0 then do something etc...

ksaliya
  • 182
  • 7

0 Answers0