LatticeMico32 Microprocessor Software Support
LatticeMico GPIO
19
intr_enable
unsigned int
This value is set to 0 if the GPIO is not configured to generate
interrupts. Otherwise, the value is 1.
wb_data_size
unsigned int
This value determines the width of the WISHBONE data bus.
Allowed values are 8 or 32.
lookupReg
DeviceReg_t
Used by the device driver to register the GPIO component instance
with the LatticeMico32 lookup service. Refer to the
LatticeMico32
Software Developer User Guide
for a description of the DeviceReg_t
data type.
prev
void *
Used internally by the lookup service
next
void *
Used internally by the lookup service
Table 9: GPIO Device Context Structure Parameters (Continued)
Parameter
Data Type
Description
Note
Y
ou may need to access the GPIO device registers directly, but some of these
registers are write-only. Implementing shadow registers in RAM can be an effective
way to replace this missing capability. Figure 14 provides an example of “shadow”
register code for handling write-only registers in LatticeMico System.
Figure 14: Example Shadow Register Code Fragment
MicoGPIOCtx_t *pGPIO_context;
MicoGPIO_t gpioState, *pGPIO;
// The GPIO is an OUTPUT only instance
pGPIO = (pMicoGPIO_t *)(pGPIO_context->base);
// initialize the "shadow" copy in RAM
gpioState.gpioData = 0x1ff;
// write the "shadow" values out to the I/O pins
pGPIO->gpioData = gpioState.gpioData;
// do a read of the "shadow" value and then clear the lsb
gpioState->gpioData &= 0xFE;
// write the new value to the I/O pins
pGPIO->gpioData = pGpioState->gpioData;
// ...