Question: Modify the C code as such that when button 0 ( BTN 0 ) is pressed only LED 0 ( LD 0 ) turns on
Modify the C code as such that when buttonBTN is pressed only LEDLD turns on if
button is pressed only LED turns on and so on for all four buttons. Include a screen shot of
the modified code.
#include "xparameters.h
#include "xparameters.h
#include "xilprintf.h
#include "xgpio.h
#include "xiltypes.h
Get device IDs from xparameters.h
#define BTNID XPARAXIGPIOBUTTONSDEVICEID
#define LEDID XPARAXIGPIOLEDDEVICEID
#define BTNCHANNEL
#define LEDCHANNEL
#define BTNMASK b
#define LEDMASK b
int main
XGpioConfig cfgptr;
XGpio leddevice, btndevice;
u data;
xilprintfEntered function mainr
;
Initialize LED Device
cfgptr XGpioLookupConfigLEDID;
XGpioCfgInitialize&leddevice, cfgptr cfgptrBaseAddress;
Initialize Button Device
cfgptr XGpioLookupConfigBTNID;
XGpioCfgInitialize&btndevice, cfgptr cfgptrBaseAddress;
Set Button Tristate
XGpioSetDataDirection&btndevice, BTNCHANNEL, BTNMASK;
Set Led Tristate
XGpioSetDataDirection&leddevice, LEDCHANNEL, ;
while
data XGpioDiscreteRead&btndevice, BTNCHANNEL;
data & BTNMASK;
if data
data LEDMASK;
else
data ;
XGpioDiscreteWrite&leddevice, LEDCHANNEL, data;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
