|
Hi,
Here you have some code to interact with the board.
UART.txt have some functions to work with a second UART
if you have one (the first UART works with printf(),
getc()...)
GPIO.c is a full app that reads from the switches and
ligths the corresponding LEDs.
You can also take a look at the apps that come with
petalinux like gpio-test.
On the other hand, if you want to interact with
hardware inside the FPGA designed by yourself, you can use the functions/macros
that the EDK creates after using the wizard "Create or Import
Peripheral" in
microblaze_0/include/youripname.h.
Tell me if you have any
problem.
Raúl.
De: owner-microblaze-uclinux@xxxxxxxxxxxxxx [mailto:owner-microblaze-uclinux@xxxxxxxxxxxxxx] En nombre de Brian Estrada Enviado el: martes, 08 de abril de 2008 14:17 Para: microblaze-uclinux@xxxxxxxxxxxxxx Asunto: [microblaze-uclinux] uclinux and interfacing with hardware on the Spartan 3E starter board Hello, I?m currently a Computer Engineering student working
on project using the Spartan 3E Rev D Starter Board and Petalinux. I currently
have the board running uclinux and have been very satisfied with it.
Unfortunately, my professor wants me to take it a step further. He wants me to
somehow integrate uclinux with some of the hardware aspects of the board itself.
He gave me an example such as running a user app called ?lights? through the
uclinux terminal which will then blink the leds of the Spartan 3e starter board.
I?ve read through the petalinux guides and know that I can write apps for
uclinux that run exclusively inside of it, but I haven?t seen any programs that
can be run in uclinux that can interact with the board itself, like with the
leds or lcd display. Has anyone had any experience with this kind of program?
Thanks for any help you can give me. Brian Estrada |
typedef struct _SerialPort_XUartLite {
bool portOpen;
} SerialPort_XUartLite;
#define NUM_XUARTLITE 1
SerialPort_XUartLite s_xuartLite[NUM_XUARTLITE];
/*----------------------------------------------------------------------------*/
int io_serial_xuartlite_openPort(unsigned char portNo)
{
if (portNo >= NUM_XUARTLITE) {
return 0;
}
s_xuartLite[portNo].portOpen = true;
return 1;
}
/*----------------------------------------------------------------------------*/
void io_serial_xuartlite_closePort(unsigned char portNo)
{
s_xuartLite[portNo].portOpen = false;
}
/*----------------------------------------------------------------------------*/
int io_serial_xuartlite_readBlock(unsigned char portNo, char *data, int maxlen)
{
int recvBytes = 0;
if (s_xuartLite[portNo].portOpen) {
while (recvBytes < maxlen) {
if (XUartLite_mIsReceiveEmpty(STDIN_BASEADDRESS)) {
return recvBytes;
}
*data = (Xuint8)XIo_In32(STDIN_BASEADDRESS + XUL_RX_FIFO_OFFSET);
data++;
recvBytes++;
}
}
return recvBytes;
}
/*----------------------------------------------------------------------------*/
int io_serial_xuartlite_writeBlock(unsigned char portNo, const char *data, int len)
{
int retVal = 0;
if (s_xuartLite[portNo].portOpen) {
int i;
char* p = (char*)data;
for (i = 0; i < len; i++) {
while (XUartLite_mIsTransmitFull(STDOUT_BASEADDRESS));
XIo_Out32(STDOUT_BASEADDRESS + XUL_TX_FIFO_OFFSET, *p);
p++;
}
retVal = len;
}
return retVal;
}
/*----------------------------------------------------------------------------*/
bool io_serial_xuartlite_byteAvailable(unsigned char portNo)
{
if (s_xuartLite[portNo].portOpen) {
return XUartLite_mIsReceiveEmpty(STDIN_BASEADDRESS) ? false : true;
}
return false;
}Attachment:
GPIO.c
Description: GPIO.c