Hi! I have a question regarding the mprj_ios. When...
# caravel
k
Hi! I have a question regarding the mprj_ios. When writing c code to program them, how do we know which mprj_io we output the data through or what mprj_io we're reading the data for? For example this blink.c file has a reg_mprj_datah = x_value but it doesn't specify for which mprj_io it is for.
t
"datal" is a 32-bit register holding the values to or from GPIO 0 to 31. "datah" is only valid on the low 6 bits, which correspond to GPIO 32 to 37.
k
I see, but how do we know if the datal data is for which GPIO?
For example, if I have an LED tied to GPIO 0, and want to have it blink, how do I let it know that I want to output to that GPIO using the management SoC/Processor
t
@Kevin Lin: You would configure the GPIO in the C program to be management output mode (
reg_mprj_io_0 = GPIO_MODE_MGMT_STD_OUTPUT;
) (followed by setting
reg_mprj_xfer
low bit and waiting for it to self-reset to zero) and then apply data through, e.g.,
reg_mprj_datal = 0x00000001;
and
reg_mprj_datal = 0x00000000;
.
k
I see. One more question, would we just wait until reg_mprj_xfer self-reset to 0 if we want to use more than one GPIO? e.g. GPIO0 to blink LED, GPIO1 to output for something else , and GPIO2 to take in an input.
t
Toggling
reg_mprj_xfer
initiates the full configuration of the GPIO. There are defaults that get used if you don't set a value for any GPIO, which should be "sane" values, but it's best just to make sure you've set all the GPIOs the way you want them before you toggle
reg_mprj_xfer
(FYI, if you don't set GPIO 1 to 4 within your program, then the defaults are correct for using the housekeeping SPI).
k
I see, so we configure each of the GPIO and then set reg_mprj_xfer to be low and wait for it to self reset. Just to double check the GPIO0 to 31 are they 1-bit or 32-bits?
Oh wait, nvm I see
I see how it works now, apologies and thanks!
t
Progress, one enlightened user at a time. . . : )