Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| ctboard:peripherals:gpio_cpld [2016/02/25 11:38] – created feur | ctboard:peripherals:gpio_cpld [2026/06/25 14:52] (current) – [Programming Example] scbj | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| > {{ctboard: | > {{ctboard: | ||
| > Supported [[ctboard: | > Supported [[ctboard: | ||
| - | \\ | ||
| - | |||
| - | ===== Programming Example ===== | ||
| - | |||
| - | The code snippet bellow shows how to use the GPIO. | ||
| - | |||
| - | <code c> | ||
| - | #include " | ||
| - | |||
| - | uint8_t data_byte = CT_GPIO-> | ||
| - | uint16_t data_hword = CT_GPIO-> | ||
| - | uint32_t data_word = CT_GPIO-> | ||
| - | |||
| - | CT_GPIO-> | ||
| - | CT_GPIO-> | ||
| - | CT_GPIO-> | ||
| - | </ | ||
| \\ | \\ | ||
| Line 33: | Line 16: | ||
| ==== Output ==== | ==== Output ==== | ||
| - | The Registers | + | The registers |
| \\ {{ctboard_gpio_output_reg.svg}} \\ \\ | \\ {{ctboard_gpio_output_reg.svg}} \\ \\ | ||
| Line 40: | Line 23: | ||
| \\ {{ctboard_gpio_cpld.svg}} \\ \\ | \\ {{ctboard_gpio_cpld.svg}} \\ \\ | ||
| + | |||
| + | ===== Programming Example ===== | ||
| + | |||
| + | The code snippets below show how to use the GPIO. | ||
| + | |||
| + | <code c> | ||
| + | #include " | ||
| + | |||
| + | uint8_t data_byte = CT_GPIO-> | ||
| + | uint16_t data_hword = CT_GPIO-> | ||
| + | uint32_t data_word = CT_GPIO-> | ||
| + | |||
| + | CT_GPIO-> | ||
| + | CT_GPIO-> | ||
| + | CT_GPIO-> | ||
| + | </ | ||
| + | \\ | ||
| + | |||
| + | <code text> | ||
| + | .equ ADDR_GPIO_IN, | ||
| + | .equ ADDR_GPIO_OUT, | ||
| + | | ||
| + | ldr | ||
| + | ldrb r1, [r0, #0] // Read byte from P1. | ||
| + | ldrw r1, [r0, #0] // Read half word from P1 and P2. | ||
| + | ldr | ||
| + | | ||
| + | ldr | ||
| + | strb r1, [r0, #2] // Write byte of data to P3. | ||
| + | strh r1, [r0, #2] // Write halfword of data to P3..4. | ||
| + | str | ||
| + | </ | ||
| + | \\ | ||