libnx v4.9.0
Loading...
Searching...
No Matches
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
12typedef enum {
13 GpioPadName_AudioCodec = 1,
14 GpioPadName_ButtonVolUp = 25,
15 GpioPadName_ButtonVolDown = 26,
16 GpioPadName_SdCd = 56,
17} GpioPadName;
18
19typedef struct {
20 Service s;
22
23typedef enum {
24 GpioDirection_Input = 0,
25 GpioDirection_Output = 1,
26} GpioDirection;
27
28typedef enum {
29 GpioValue_Low = 0,
30 GpioValue_High = 1,
31} GpioValue;
32
33typedef enum {
34 GpioInterruptMode_LowLevel = 0,
35 GpioInterruptMode_HighLevel = 1,
36 GpioInterruptMode_RisingEdge = 2,
37 GpioInterruptMode_FallingEdge = 3,
38 GpioInterruptMode_AnyEdge = 4,
39} GpioInterruptMode;
40
41typedef enum {
42 GpioInterruptStatus_Inactive = 0,
43 GpioInterruptStatus_Active = 1,
44} GpioInterruptStatus;
45
46/// Initialize gpio.
48
49/// Exit gpio.
50void gpioExit(void);
51
52/// Gets the Service object for the actual gpio service session.
54
55Result gpioOpenSession(GpioPadSession *out, GpioPadName name);
56Result gpioOpenSession2(GpioPadSession *out, u32 device_code, u32 access_mode);
57
58Result gpioIsWakeEventActive(bool *out, GpioPadName name);
59Result gpioIsWakeEventActive2(bool *out, u32 device_code);
60
61Result gpioPadSetDirection(GpioPadSession *p, GpioDirection dir);
62Result gpioPadGetDirection(GpioPadSession *p, GpioDirection *out);
63Result gpioPadSetInterruptMode(GpioPadSession *p, GpioInterruptMode mode);
64Result gpioPadGetInterruptMode(GpioPadSession *p, GpioInterruptMode *out);
65Result gpioPadSetInterruptEnable(GpioPadSession *p, bool en);
66Result gpioPadGetInterruptEnable(GpioPadSession *p, bool *out);
67Result gpioPadGetInterruptStatus(GpioPadSession *p, GpioInterruptStatus *out); ///< [1.0.0-16.1.0]
69Result gpioPadSetValue(GpioPadSession *p, GpioValue val);
70Result gpioPadGetValue(GpioPadSession *p, GpioValue *out);
71Result gpioPadBindInterrupt(GpioPadSession *p, Event *out);
72Result gpioPadUnbindInterrupt(GpioPadSession *p);
73Result gpioPadSetDebounceEnabled(GpioPadSession *p, bool en);
74Result gpioPadGetDebounceEnabled(GpioPadSession *p, bool *out);
75Result gpioPadSetDebounceTime(GpioPadSession *p, s32 ms);
76Result gpioPadGetDebounceTime(GpioPadSession *p, s32 *out);
77void gpioPadClose(GpioPadSession *p);
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.
Service * gpioGetServiceSession(void)
Gets the Service object for the actual gpio service session.
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