| Nano100BN Series BSP V3.03.002 The Board Support Package for Nano100BN Series

NuEdu-Basic01_Button.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include <stdio.h>
13 #include "Nano100Series.h"
25 /*---------------------------------------------------------------------------------------------------------*/
26 /* GPIO for Button Definitions */
27 /*---------------------------------------------------------------------------------------------------------*/
28 #define KEY1_INPUT PD12
29 #define KEY2_INPUT PE12
30 #define KEY3_INPUT PD0
31 #define KEY4_INPUT PD1
37 void Initial_KEY_INPUT(void)
38 {
39 GPIO_SetMode(PD, BIT12, GPIO_PMD_INPUT);
40 GPIO_SetMode(PE, BIT12, GPIO_PMD_INPUT);
41 GPIO_SetMode(PD, BIT0, GPIO_PMD_INPUT);
42 GPIO_SetMode(PD, BIT1, GPIO_PMD_INPUT);
43 }
48 unsigned char Get_KEY_INPUT(void)
49 {
50 unsigned char temp=0;
51 if (KEY1_INPUT == 1)
52 temp|=0x1;
53
54 if (KEY2_INPUT == 1)
55 temp|=0x2;
56
57 if (KEY3_INPUT == 1)
58 temp|=0x4;
59
60 if (KEY4_INPUT == 1)
61 temp|=0x8;
62 return temp;
63 } /* end of group Nano130_Basic01_FUNCTIONS */
65 /* end of group NuEdu-SDK-Nano130_Basic01 */
67 /* end of group NANO100_Library */
69
70 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
KEY4_INPUT
#define KEY4_INPUT
Definition: NuEdu-Basic01_Button.c:31
PD
#define PD
Pointer to GPIO port D register structure.
Definition: Nano100Series.h:11698
KEY1_INPUT
#define KEY1_INPUT
Definition: NuEdu-Basic01_Button.c:28
KEY3_INPUT
#define KEY3_INPUT
Definition: NuEdu-Basic01_Button.c:30
BIT12
#define BIT12
Bit 12 mask of an 32 bit integer.
Definition: Nano100Series.h:11881
GPIO_PMD_INPUT
#define GPIO_PMD_INPUT
Definition: gpio.h:37
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
BIT0
#define BIT0
Bit 0 mask of an 32 bit integer.
Definition: Nano100Series.h:11869
BIT1
#define BIT1
Bit 1 mask of an 32 bit integer.
Definition: Nano100Series.h:11870
KEY2_INPUT
#define KEY2_INPUT
Definition: NuEdu-Basic01_Button.c:29
PE
#define PE
Pointer to GPIO port E register structure.
Definition: Nano100Series.h:11699
GPIO_SetMode
void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO operation mode.
Definition: gpio.c:40
Get_KEY_INPUT
unsigned char Get_KEY_INPUT(void)
This function get button status.
Definition: NuEdu-Basic01_Button.c:48