Reputation: 21
My question is, what this function XGpio_SetDataDirection does, en C. For example XGpio_SetDataDirection (&gp_out, 1, 0x00) ?
Upvotes: 2
Views: 9499
Reputation: 354
It's a library function. This can be viewed in xgpio.c file. Here is a definition of this guy:
void XGpio_SetDataDirection(XGpio *InstancePtr, unsigned Channel,
u32 DirectionMask)
{
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Xil_AssertVoid((Channel == 1) ||
((Channel == 2) && (InstancePtr->IsDual == TRUE)));
XGpio_WriteReg(InstancePtr->BaseAddress,
((Channel - 1) * XGPIO_CHAN_OFFSET) + XGPIO_TRI_OFFSET,
DirectionMask);
}
Upvotes: 0
Reputation: 971
You can find/generate Microblaze drivers' API documentation right from your design. E.g. in Xilinx Platform Studio right clicking on Microblaze core should bring you menu item Driver / View API Documentation. From there you can navigate to xgpio
driver and for XGpio_SetDataDirection
you should see something like this:
void XGpio_SetDataDirection (XGpio * InstancePtr, unsigned Channel, u32 DirectionMask )
Set the input/output direction of all discrete signals for the specified GPIO channel.
Parameters:
InstancePtr
is a pointer to an XGpio instance to be worked on.Channel
contains the channel of the GPIO (1 or 2) to operate on.DirectionMask
is a bitmask specifying which discretes are input and which are output. Bits set to 0 are output and bits set to 1 are input.Returns: None.
Note: The hardware must be built for dual channels if this function is used with any channel other than 1. If it is not, this function will assert.
So in your case XGpio_SetDataDirection (&gp_out, 1, 0x00)
will set GPIO ports (with your LEDs) as output for your Microblaze CPU core.
Upvotes: 2