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 [2022/12/23 11:05] (current) – [Output] ruan | ||
|---|---|---|---|
| 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 asm> | ||
| + | ADDR_GPIO_IN | ||
| + | ADDR_GPIO_OUT | ||
| + | | ||
| + | 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). | ||
| + | </ | ||
| + | \\ | ||