[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[microblaze-uclinux] Program able to write on LEDs successfully
Hello everybody,
My struggle to write on LEDs has come to an end. Now I dont think there
is a need to write any separate device driver for GPIO as a xilinx gpio
driver already exists. An issue I was missing on was setting the I/O
direction for the pins. '0' configures the pins as output and '1' as
output. I am giving "myapp.c" .
myapp.c:
#include "stdio.h"
#include "xgpio_l.h"
#define LED_BaseAddress 0x40020000
int main (void)
{
unsigned int j;
void Write_on_LEDs(int, int);
printf("-- Application Program By KUNAL to Write on LEDs --\r\n");
printf("Size of int on this platform = %d Bytes\n",sizeof(int)); /* Checking "int" size */
printf("Enter 8 Bit Hex Data to Write on 8 LEDs :\n");
scanf("%x",&j);
printf("Press CTRL C to exit\n");
while(1)
{
Write_on_LEDs(LED_BaseAddress,j);
};
return 0;
}
void Write_on_LEDs(int BaseAddress,int j)
{
XGpio_mSetDataDirection(BaseAddress, 1, 0x00000000); /* Set as Output */
XGpio_mSetDataReg(BaseAddress, 1, j); /* Write on LEDs */
}