| M480 BSP V3.05.001 The Board Support Package for M480 Series

gpio.c
Go to the documentation of this file.
1 /**************************************************************************/
10 #include "NuMicro.h"
11
39 void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
40 {
41 uint32_t i;
42
43 for(i = 0ul; i < GPIO_PIN_MAX; i++)
44 {
45 if((u32PinMask & (1ul << i))==(1ul << i))
46 {
47 port->MODE = (port->MODE & ~(0x3ul << (i << 1))) | (u32Mode << (i << 1));
48 }
49 }
50 }
51
67 void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
68 {
69 port->INTTYPE = (port->INTTYPE&~(1ul<<u32Pin)) | (((u32IntAttribs >> 24) & 0xFFUL) << u32Pin);
70 port->INTEN = (port->INTEN&~(0x00010001ul<<u32Pin)) | ((u32IntAttribs & 0xFFFFFFUL) << u32Pin);
71 }
72
73
87 void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin)
88 {
89 port->INTTYPE &= ~(1UL << u32Pin);
90 port->INTEN &= ~((0x00010001UL) << u32Pin);
91 }
92
106 void GPIO_SetSlewCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
107 {
108 uint32_t i;
109
110 for(i = 0ul; i < GPIO_PIN_MAX; i++)
111 {
112 if(u32PinMask & (1ul << i))
113 {
114 port->SLEWCTL = (port->SLEWCTL & ~(0x3ul << (i << 1))) | (u32Mode << (i << 1));
115 }
116 }
117 }
118
133 void GPIO_SetPullCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
134 {
135 uint32_t i;
136
137 for(i = 0ul; i < GPIO_PIN_MAX; i++)
138 {
139 if(u32PinMask & (1ul << i))
140 {
141 port->PUSEL = (port->PUSEL & ~(0x3ul << (i << 1))) | (u32Mode << (i << 1));
142 }
143 }
144 }
145
146 /* end of group GPIO_EXPORTED_FUNCTIONS */
148 /* end of group GPIO_Driver */
150 /* end of group Standard_Driver */
152
153 /*** (C) COPYRIGHT 2011~2016 Nuvoton Technology Corp. ***/
GPIO_SetPullCtl
void GPIO_SetPullCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO Pull-up and Pull-down control.
Definition: gpio.c:133
GPIO_T
Definition: gpio_reg.h:27
GPIO_EnableInt
void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
Enable GPIO interrupt.
Definition: gpio.c:67
GPIO_T::INTTYPE
__IO uint32_t INTTYPE
Definition: gpio_reg.h:489
NuMicro.h
NuMicro peripheral access layer header file.
GPIO_SetSlewCtl
void GPIO_SetSlewCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO slew rate control.
Definition: gpio.c:106
GPIO_T::SLEWCTL
__IO uint32_t SLEWCTL
Definition: gpio_reg.h:493
GPIO_DisableInt
void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin)
Disable GPIO interrupt.
Definition: gpio.c:87
GPIO_T::PUSEL
__IO uint32_t PUSEL
Definition: gpio_reg.h:497
GPIO_T::MODE
__IO uint32_t MODE
Definition: gpio_reg.h:483
GPIO_PIN_MAX
#define GPIO_PIN_MAX
Definition: gpio.h:31
GPIO_SetMode
void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO operation mode.
Definition: gpio.c:39
GPIO_T::INTEN
__IO uint32_t INTEN
Definition: gpio_reg.h:490