-
Notifications
You must be signed in to change notification settings - Fork 185
Add "pwm" service #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
masagrator
wants to merge
9
commits into
switchbrew:master
Choose a base branch
from
masagrator:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+84
−0
Open
Add "pwm" service #710
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
640304e
Add files via upload
masagrator 0404309
Add files via upload
masagrator ef6a0ef
Update pwm.c
masagrator ce98046
Update pwm.c
masagrator ea97c98
Update pwm.h
masagrator 5995852
Update pwm.h
masagrator 17374cd
Update pwm.c
masagrator 26f4021
Update pwm.h
masagrator 452d847
Update pwm.c
masagrator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * @file pwm.h | ||
| * @author MasaGratoR | ||
| * @copyright libnx Authors | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "../types.h" | ||
| #include "../sf/service.h" | ||
|
|
||
| typedef struct { | ||
| Service s; | ||
| } PwmChannelSession; | ||
|
|
||
| typedef enum { | ||
| PwmChannelDeviceCode_CpuFan = 0x3D000001, | ||
| PwmChannelDeviceCode_LcdBacklight = 0x3400003D, | ||
| PwmChannelDeviceCode_Led = 0x35000065 | ||
| } PwmChannelDeviceCode; | ||
|
|
||
| /// Initialize pwm. | ||
| Result pwmInitialize(void); | ||
|
|
||
| /// Exit pwm. | ||
| void pwmExit(void); | ||
|
|
||
| /// Gets the Service for pwm. | ||
| Service* pwmGetServiceSession(void); | ||
|
|
||
| /// Takes a PwmChannelDeviceCode and returns a PwmChannelSession. Only available on [6.0.0+]. | ||
| Result pwmOpenSession2(PwmChannelSession *out, PwmChannelDeviceCode device_code); | ||
|
|
||
| /// Closes a PwmChannelSession. | ||
| void pwmChannelSessionClose(PwmChannelSession *c); | ||
|
|
||
| /// Takes a PwmChannelSession, returns an output double. Only available on [6.0.0+]. | ||
| Result pwmChannelSessionGetDutyCycle(PwmChannelSession *c, double* out); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #define NX_SERVICE_ASSUME_NON_DOMAIN | ||
| #include "service_guard.h" | ||
| #include "services/pwm.h" | ||
| #include "runtime/hosversion.h" | ||
|
|
||
| static Service g_pwmSrv; | ||
|
|
||
| NX_GENERATE_SERVICE_GUARD(pwm); | ||
|
|
||
| Result _pwmInitialize(void) { | ||
| return smGetService(&g_pwmSrv, "pwm"); | ||
| } | ||
|
|
||
| void _pwmCleanup(void) { | ||
| serviceClose(&g_pwmSrv); | ||
| } | ||
|
|
||
| Service* pwmGetServiceSession(void) { | ||
| return &g_pwmSrv; | ||
| } | ||
|
|
||
| Result pwmOpenSession2(PwmChannelSession *out, PwmChannelDeviceCode device_code) { | ||
| if (hosversionBefore(6,0,0)) | ||
| return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
|
||
| u32 tmp = device_code; | ||
|
|
||
| return serviceDispatchIn(&g_pwmSrv, 2, tmp, | ||
| .out_num_objects = 1, | ||
| .out_objects = &out->s, | ||
| ); | ||
| } | ||
|
|
||
| void pwmChannelSessionClose(PwmChannelSession *c) { | ||
| serviceClose(&c->s); | ||
| } | ||
|
|
||
| Result pwmChannelSessionGetDutyCycle(PwmChannelSession *c, double* out) { | ||
| if (hosversionBefore(6,0,0)) | ||
| return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
|
||
| if (!serviceIsActive(&c->s)) | ||
| return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); | ||
|
|
||
| return serviceDispatchOut(&c->s, 7, *out); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.