Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ctboard:peripherals:gpio_cpld [2016/02/25 11:38] – created feurctboard:peripherals:gpio_cpld [2022/12/23 11:05] (current) – [Output] ruan
Line 5: Line 5:
 > {{ctboard:ctboard_mode_1.svg?48px }} Please make sure the CT Board is in the correct mode. > {{ctboard:ctboard_mode_1.svg?48px }} Please make sure the CT Board is in the correct mode.
 > Supported [[ctboard:mode_switch|mode]]: **1** > Supported [[ctboard:mode_switch|mode]]: **1**
-\\ 
- 
-===== Programming Example ===== 
- 
-The code snippet bellow shows how to use the GPIO. 
- 
-<code c> 
-#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 data to all ports (P1..4). */ 
-</code> 
 \\ \\
  
Line 33: Line 16:
 ==== Output ==== ==== Output ====
  
-The Registers are read / write.+The registers are read / write.
  
 \\ {{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 "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). */
 +</code>
 +\\
 +
 +<code asm>
 +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).
 +</code>
 +\\
  
  • ctboard/peripherals/gpio_cpld.1456400323.txt.gz
  • Last modified: 2016/02/25 11:38
  • by feur