libnx  v4.7.0
gpio.h
Go to the documentation of this file.
1 /**
2  * @file gpio.h
3  * @brief GPIO service IPC wrapper.
4  * @author SciresM
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../kernel/event.h"
10 #include "../sf/service.h"
11 
12 typedef enum {
13  GpioPadName_AudioCodec = 1,
14  GpioPadName_ButtonVolUp = 25,
15  GpioPadName_ButtonVolDown = 26,
16  GpioPadName_SdCd = 56,
17 } GpioPadName;
18 
19 typedef struct {
20  Service s;
22 
23 typedef enum {
24  GpioDirection_Input = 0,
25  GpioDirection_Output = 1,
26 } GpioDirection;
27 
28 typedef enum {
29  GpioValue_Low = 0,
30  GpioValue_High = 1,
31 } GpioValue;
32 
33 typedef enum {
34  GpioInterruptMode_LowLevel = 0,
35  GpioInterruptMode_HighLevel = 1,
36  GpioInterruptMode_RisingEdge = 2,
37  GpioInterruptMode_FallingEdge = 3,
38  GpioInterruptMode_AnyEdge = 4,
39 } GpioInterruptMode;
40 
41 typedef enum {
42  GpioInterruptStatus_Inactive = 0,
43  GpioInterruptStatus_Active = 1,
44 } GpioInterruptStatus;
45 
46 /// Initialize gpio.
48 
49 /// Exit gpio.
50 void gpioExit(void);
51 
52 /// Gets the Service object for the actual gpio service session.
54 
55 Result gpioOpenSession(GpioPadSession *out, GpioPadName name);
56 Result gpioOpenSession2(GpioPadSession *out, u32 device_code, u32 access_mode);
57 
58 Result gpioIsWakeEventActive(bool *out, GpioPadName name);
59 Result gpioIsWakeEventActive2(bool *out, u32 device_code);
60 
61 Result gpioPadSetDirection(GpioPadSession *p, GpioDirection dir);
62 Result gpioPadGetDirection(GpioPadSession *p, GpioDirection *out);
63 Result gpioPadSetInterruptMode(GpioPadSession *p, GpioInterruptMode mode);
64 Result gpioPadGetInterruptMode(GpioPadSession *p, GpioInterruptMode *out);
65 Result gpioPadSetInterruptEnable(GpioPadSession *p, bool en);
66 Result gpioPadGetInterruptEnable(GpioPadSession *p, bool *out);
67 Result gpioPadGetInterruptStatus(GpioPadSession *p, GpioInterruptStatus *out); ///< [1.0.0-16.1.0]
69 Result gpioPadSetValue(GpioPadSession *p, GpioValue val);
70 Result gpioPadGetValue(GpioPadSession *p, GpioValue *out);
71 Result gpioPadBindInterrupt(GpioPadSession *p, Event *out);
72 Result gpioPadUnbindInterrupt(GpioPadSession *p);
73 Result gpioPadSetDebounceEnabled(GpioPadSession *p, bool en);
74 Result gpioPadGetDebounceEnabled(GpioPadSession *p, bool *out);
75 Result gpioPadSetDebounceTime(GpioPadSession *p, s32 ms);
76 Result gpioPadGetDebounceTime(GpioPadSession *p, s32 *out);
77 void gpioPadClose(GpioPadSession *p);
Service * gpioGetServiceSession(void)
Gets the Service object for the actual gpio service session.
Result gpioPadGetInterruptStatus(GpioPadSession *p, GpioInterruptStatus *out)
[1.0.0-16.1.0]
Result gpioInitialize(void)
Initialize gpio.
Result gpioPadClearInterruptStatus(GpioPadSession *p)
[1.0.0-16.1.0]
void gpioExit(void)
Exit gpio.
Kernel-mode event structure.
Definition: event.h:13
Definition: gpio.h:19
Service object structure.
Definition: service.h:14
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21