====== GPIO over CPLD ====== Each of the 4 GPIO ports contains 8 ouput and 8 input pins. The ports are not as fast as the integrated [[stm32:peripherals:gpio|GPIO ports]] of the microcontroller. \\ \\ > {{ctboard:ctboard_mode_1.svg?48px }} Please make sure the CT Board is in the correct mode. > Supported [[ctboard:mode_switch|mode]]: **1** \\ ===== Registers ===== ==== Input ==== \\ {{ ctboard_gpio_pinout.svg?300em}} {{ctboard_gpio_input_reg.svg}} \\ \\ ==== Output ==== The registers are read / write. \\ {{ctboard_gpio_output_reg.svg}} \\ \\ ===== Diagram ===== \\ {{ctboard_gpio_cpld.svg}} \\ \\ ===== Programming Example ===== The code snippets below show how to use the GPIO. #include "reg_ctboard.h" uint8_t data_byte = CT_GPIO->IN.BYTE.P1; /* Read byte from P1. */ uint16_t data_hword = CT_GPIO->IN.HWORD.P2_1; /* Read half word from P1 and P2. */ uint32_t data_word = CT_GPIO->IN.WORD; /* Read word from all ports (P1..4). */ CT_GPIO->OUT.BYTE.P3 = (uint8_t) data_byte; /* Write byte of data to P3. */ CT_GPIO->OUT.HWORD.P4_3 = (uint16_t) data_halfword; /* Write halfword of data to P3..4 */ CT_GPIO->OUT.WORD = (uint32_t) data_word; /* Write word of data to all ports (P1..4). */ \\ ADDR_GPIO_IN EQU 0x60000410 ADDR_GPIO_OUT EQU 0x60000400 LDR r0, =ADDR_GPIO_IN LDRB r1, [r0, #0] ; Read byte from P1. LDRH r1, [r0, #0] ; Read half word from P1 and P2. LDR r1, [r0, #0] ; Read word from all ports (P1..4). LDR r0, =ADDR_GPIO_OUT STRB r1, [r0, #2] ; Write byte of data to P3. STRH r1, [r0, #2] ; Write halfword of data to P3..4. STR r1, [r0, #0] ; Write word of data to all ports (P1..4). \\