23
23
#define GPIO_DEVICE_ID XPAR_XGPIOPS_0_DEVICE_ID
24
24
#define GPIO_AXI0_DEVICE_ID XPAR_GPIO_0_DEVICE_ID
25
25
26
- #define GPIO_PS_BUTTON_OFFSET 0 //MIO#0
27
- #define GPIO_PS_LED_R_OFFSET 52 //MIO#52 (906+52=958)
28
- #define GPIO_PS_LED_G_OFFSET 53 //MIO#53 (906+53=959)
26
+ #define GPIO_PS_BUTTON_OFFSET 0 //MIO#0
27
+ #define GPIO_PS_LED_R_OFFSET 52 //MIO#52 (906+52=958)
28
+ #define GPIO_PS_LED_G_OFFSET 53 //MIO#53 (906+53=959)
29
29
30
30
// ----------------------------------------------
31
31
// PRIVATE VARIABLES
32
- static const u32 PSRedLedPin = 52 ; /* MIO_52 = Red LED */
33
- static const u32 PSGreenLedPin = 53 ; /* MIO53 = Green LED */
32
+ static const u32 PsButtonPin = 0 ; /* MIO_0 = PS Pushbutton */
33
+ static const u32 PSRedLedPin = 52 ; /* MIO_52 = Red LED */
34
+ static const u32 PSGreenLedPin = 53 ; /* MIO53 = Green LED */
34
35
35
36
// GPIO Instances
36
37
static XGpioPs PS_Gpio ; /* The driver instance for PS GPIO Device. */
@@ -90,6 +91,13 @@ void GPIO_Set_PL_Color(unsigned char led_color)
90
91
}
91
92
}
92
93
94
+ bool GPIO_Get_PS_Button (void )
95
+ {
96
+ unsigned char PsButtonStatus ;
97
+ PsButtonStatus = XGpioPs_ReadPin (& PS_Gpio , PsButtonPin );
98
+ return (PsButtonStatus == 0 ? false : true);
99
+ }
100
+
93
101
int GPIO_Init ()
94
102
{
95
103
XGpioPs_Config * ConfigPtr ;
@@ -103,6 +111,9 @@ int GPIO_Init()
103
111
return XST_FAILURE ;
104
112
}
105
113
114
+ /* Set the direction for the PS button pin to be input. */
115
+ XGpioPs_SetDirectionPin (& PS_Gpio , PsButtonPin , 0x0 );
116
+
106
117
/* Set the direction for the LED pins to be outputs */
107
118
XGpioPs_SetDirectionPin (& PS_Gpio , PSRedLedPin , 1 );
108
119
XGpioPs_SetDirectionPin (& PS_Gpio , PSGreenLedPin , 1 );
@@ -120,4 +131,4 @@ int GPIO_Init()
120
131
/* Set the direction for all LED signals as outputs */
121
132
XGpio_SetDataDirection (& PL_Gpio0 , 1 , 0x00 ); //All outputs
122
133
return 0 ;
123
- }
134
+ }
0 commit comments