Alexander Shabarshin
06/28/2023, 6:27 AMTim Edwards
06/28/2023, 12:52 PMAlexander Shabarshin
06/28/2023, 2:37 PMTim Edwards
06/28/2023, 2:39 PMAlexander Shabarshin
06/28/2023, 2:45 PM`define USER_CONFIG_GPIO_5_INIT `GPIO_MODE_USER_STD_INPUT_PULLDOWN
`define USER_CONFIG_GPIO_6_INIT `GPIO_MODE_USER_STD_INPUT_PULLDOWN
`define USER_CONFIG_GPIO_7_INIT `GPIO_MODE_USER_STD_INPUT_PULLDOWN
`define USER_CONFIG_GPIO_8_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_9_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_10_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_11_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_12_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_13_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_14_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_15_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_16_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_17_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_18_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_19_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_20_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_21_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_22_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_23_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
`define USER_CONFIG_GPIO_24_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_25_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_26_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_27_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_28_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_29_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_30_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_31_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_32_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_33_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_34_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_35_INIT `GPIO_MODE_USER_STD_OUTPUT
`define USER_CONFIG_GPIO_36_INIT `GPIO_MODE_USER_STD_INPUT_PULLDOWN
`define USER_CONFIG_GPIO_37_INIT `GPIO_MODE_USER_STD_INPUT_PULLDOWN
So IOs 8 to 23 are inputs and IOs 24 to 35 are outputs - I want to be able to write values to inputs and read outputs programmaticallyTim Edwards
06/30/2023, 1:37 AMreg_mprj_datal
and reg_mprj_datah
. GPIO 0 is the low bit of reg_mprj_datal
up to GPIO 31, which is the high bit of the (32-bit) register. Then GPIO 32 is the low bit of reg_mprj_datah
up to GPIO 37, which is the 6th bit. You can read or write GPIOs simply by doing
reg_mprj_datal = value
or
value = reg_mprj_datal
Reading a single GPIO is just a matter of bit-masking the value:
gpio8_value = (reg_mprj_datal >> 8) & 1;
Just be aware that every time you access the register, you get the values at the time of the access. There are some restrictions on simultaneous access, such as that GPIOs 32 to 37 cannot be read (or written) at the exact same time as GPIOs 0 to 31 because you can only do 32-bit register accesses.Alexander Shabarshin
06/30/2023, 7:21 AMTim Edwards
06/30/2023, 5:41 PMAlexander Shabarshin
06/30/2023, 7:19 PMTim Edwards
06/30/2023, 8:59 PMAlexander Shabarshin
06/30/2023, 9:01 PMTim Edwards
06/30/2023, 9:06 PMAlexander Shabarshin
06/30/2023, 9:12 PMAlexander Shabarshin
06/30/2023, 9:17 PMTim Edwards
06/30/2023, 9:22 PMAlexander Shabarshin
06/30/2023, 9:27 PMTim Edwards
06/30/2023, 9:37 PMreg_mprj_xfer = 1
is how you do it from C code). The configuration values near the GPIO are how the GPIO gets its own configuration. The values in housekeeping are what the management SoC think the GPIOs are configured to. So the trick here is to get the management SoC to think that the GPIOs are different from what they actually are.
Although one thing I said was wrong; if you want the management SoC to drive a pin and the user project to read that pin, then the GPIO needs to be configured as a management-controlled output, not a user-controlled input.Tim Edwards
06/30/2023, 9:38 PMAlexander Shabarshin
06/30/2023, 9:40 PMAlexander Shabarshin
07/01/2023, 10:39 PMAlexander Shabarshin
07/01/2023, 10:56 PMAlexander Shabarshin
07/01/2023, 10:56 PMAlexander Shabarshin
07/01/2023, 11:05 PMAlexander Shabarshin
07/01/2023, 11:06 PMAnish
07/02/2023, 4:30 AMAnish
07/02/2023, 4:30 AM// mgmt_en = 1, oe_ovr = 1, ie = 1, oe = 1
// all other cfg bits = 0
#define MPRJ_INPUT_CFG 0x00F
// mgmt_en = 0, oe_ovr = 1, ie = 1, oe = 1
// all other cfg bits = 0
#define MPRJ_OUTPUT_CFG 0x00E
Anish
07/02/2023, 4:35 AMAnish
07/02/2023, 4:37 AMAlexander Shabarshin
07/02/2023, 4:44 AMAnish
07/02/2023, 4:45 AMAnish
07/02/2023, 4:46 AMAlexander Shabarshin
07/02/2023, 4:49 AMAnish
07/02/2023, 4:51 AMAnish
07/02/2023, 4:51 AMAnish
07/02/2023, 4:52 AMAnish
07/02/2023, 4:52 AMAnish
07/02/2023, 4:52 AMAnish
07/02/2023, 4:54 AMAnish
07/02/2023, 4:54 AMAnish
07/02/2023, 4:55 AMAnish
07/02/2023, 4:55 AMAlexander Shabarshin
07/02/2023, 5:01 AMAlexander Shabarshin
07/02/2023, 5:01 AMAlexander Shabarshin
07/02/2023, 5:10 AM