Revert C++ libnx bindings and call-site conversion
This commit is contained in:
1 parent
fb46ac4199
commit
5f973f60b2
44 files changed
+246
-34097
No files matched your search
@@ -24,10 +24,7 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "i2c.hpp"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
#include "i2c.h"
|
||||
|
||||
#define I2C_CMD_SND 0
|
||||
#define I2C_CMD_RCV 1
|
||||
@@ -37,5 +34,5 @@ Result i2csessionExtRegReceive(I2cSession *s, u8 in, void *out, u8 out_size) {
|
||||
|
||||
I2C_CMD_RCV | (I2cTransactionOption_All << 6), out_size };
|
||||
|
||||
return i2csession::ExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist));
|
||||
return i2csessionExecuteCommandList(s, out, out_size, cmdlist, sizeof(cmdlist));
|
||||
}
|
||||
@@ -25,7 +25,15 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <switch.hpp>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
Result i2csessionExtRegReceive(I2cSession *s, u8 in, void *out, u8 out_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -15,9 +15,6 @@
|
||||
*
|
||||
*/
|
||||
#include "i2cDrv.h"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
|
||||
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
|
||||
// ams::fatal::srv::StopSoundTask::StopSound()
|
||||
@@ -28,14 +25,14 @@ Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val) {
|
||||
} __attribute__((packed)) cmd;
|
||||
|
||||
I2cSession _session;
|
||||
Result res = i2c::OpenSession(&_session, dev);
|
||||
Result res = i2cOpenSession(&_session, dev);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
cmd.reg = reg;
|
||||
cmd.val = val;
|
||||
res = i2csession::SendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
i2csession::Close(&_session);
|
||||
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
i2csessionClose(&_session);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -48,19 +45,19 @@ Result I2cRead_OutU8(I2cDevice dev, u8 reg, u8 *out) {
|
||||
} __attribute__((packed)) rec;
|
||||
|
||||
I2cSession _session;
|
||||
Result res = i2c::OpenSession(&_session, dev);
|
||||
Result res = i2cOpenSession(&_session, dev);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
cmd.reg = reg;
|
||||
res = i2csession::SendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
if (res) {
|
||||
i2csession::Close(&_session);
|
||||
i2csessionClose(&_session);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = i2csession::ReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
|
||||
i2csession::Close(&_session);
|
||||
res = i2csessionReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
|
||||
i2csessionClose(&_session);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
@@ -78,19 +75,19 @@ Result I2cRead_OutU16(I2cDevice dev, u8 reg, u16 *out) {
|
||||
} __attribute__((packed)) rec;
|
||||
|
||||
I2cSession _session;
|
||||
Result res = i2c::OpenSession(&_session, dev);
|
||||
Result res = i2cOpenSession(&_session, dev);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
cmd.reg = reg;
|
||||
res = i2csession::SendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
if (res) {
|
||||
i2csession::Close(&_session);
|
||||
i2csessionClose(&_session);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = i2csession::ReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
|
||||
i2csession::Close(&_session);
|
||||
res = i2csessionReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
|
||||
i2csessionClose(&_session);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
@@ -136,7 +133,7 @@ u32 I2c_BuckConverter_GetMvOut(const I2c_BuckConverter_Domain *domain) {
|
||||
return 0u;
|
||||
|
||||
// Wait 1us
|
||||
svc::SleepThread(1E3);
|
||||
svcSleepThread(1E3);
|
||||
|
||||
if (!domain->por_val || val != domain->por_val)
|
||||
break;
|
||||
@@ -152,7 +149,7 @@ u32 I2c_BuckConverter_GetUvOut(const I2c_BuckConverter_Domain *domain) {
|
||||
return 0u;
|
||||
|
||||
// Wait 1us
|
||||
svc::SleepThread(1E3);
|
||||
svcSleepThread(1E3);
|
||||
|
||||
if (!domain->por_val || val != domain->por_val)
|
||||
break;
|
||||
@@ -175,7 +172,7 @@ Result I2c_BuckConverter_SetMvOut(const I2c_BuckConverter_Domain *domain, u32 mv
|
||||
return res;
|
||||
|
||||
// 5ms Ramp delay
|
||||
svc::SleepThread(5E6);
|
||||
svcSleepThread(5E6);
|
||||
u8 new_val;
|
||||
res = I2cRead_OutU8(domain->device, domain->reg, &new_val);
|
||||
if (R_FAILED(res))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <hocclk.h>
|
||||
|
||||
// To use i2c service, sm and i2c should be intialized via smInitialize() and i2cInitialize().
|
||||
|
||||
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val);
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "i2c.hpp"
|
||||
#include "max17050.hpp"
|
||||
#include "i2c.h"
|
||||
#include "max17050.h"
|
||||
|
||||
#define MAX17050_WAIT_NS 1000000000UL
|
||||
|
||||
File renamed without changes.
@@ -47,7 +47,7 @@
|
||||
|
||||
/* Is this a watchdog or a watchcat, that is the question */
|
||||
|
||||
namespace HocI2c::wdt {
|
||||
namespace i2c::wdt {
|
||||
|
||||
static bool isWdtEnabled = false;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace HocI2c::wdt {
|
||||
const bool watchdogEnabled = file::config::GetConfigValue(HocClkConfigValue_Watchdog);
|
||||
|
||||
if (watchdogEnabled) {
|
||||
Arm(HocI2c::wdt::MAX77620_WDT_2S);
|
||||
Arm(i2c::wdt::MAX77620_WDT_2S);
|
||||
Result rc = update_bits(MAX77620_REG_CNFGGLBL3, MAX77620_WDTC_MASK, MAX77620_WDTC_KICK);
|
||||
ASSERT_RESULT_OK(rc, "update_bits");
|
||||
} else {
|
||||
@@ -136,4 +136,4 @@ namespace HocI2c::wdt {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace HocI2c::wdt
|
||||
} // namespace i2c::wdt
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "i2cDrv.h"
|
||||
#include "../file/errors.hpp"
|
||||
|
||||
namespace HocI2c::wdt {
|
||||
namespace i2c::wdt {
|
||||
|
||||
typedef enum {
|
||||
MAX77620_WDT_2S = 0, /* ~2 seconds */
|
||||
@@ -38,4 +38,4 @@ namespace HocI2c::wdt {
|
||||
|
||||
void ResetWdtEnableState();
|
||||
bool IsWdtEnabled();
|
||||
} // namespace HocI2c::wdt
|
||||
} // namespace i2c::wdt
|
||||
+9
-12
@@ -17,11 +17,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "i2c.hpp"
|
||||
#include "tmp451.hpp"
|
||||
#include <switch.hpp>
|
||||
|
||||
using namespace nx;
|
||||
#include "i2c.h"
|
||||
#include "tmp451.h"
|
||||
|
||||
#define TMP451_WAIT_NS 1000000000UL
|
||||
|
||||
@@ -53,14 +50,14 @@ static Result _tmp451_get_temp(u8 reg, u8 dec_reg, s32 *out) {
|
||||
}
|
||||
|
||||
static void _tmp451_update() {
|
||||
u64 ticks = arm::GetSystemTick();
|
||||
if (arm::TicksToNs(ticks - g_update_ticks) <= TMP451_WAIT_NS) {
|
||||
u64 ticks = armGetSystemTick();
|
||||
if (armTicksToNs(ticks - g_update_ticks) <= TMP451_WAIT_NS) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_update_ticks = ticks;
|
||||
|
||||
if (!service::IsActive(&g_i2c_session.s)) {
|
||||
if (!serviceIsActive(&g_i2c_session.s)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,18 +66,18 @@ static void _tmp451_update() {
|
||||
}
|
||||
|
||||
Result tmp451Initialize(void) {
|
||||
Result rc = i2c::Initialize();
|
||||
Result rc = i2cInitialize();
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
rc = i2c::OpenSession(&g_i2c_session, I2cDevice_Tmp451);
|
||||
rc = i2cOpenSession(&g_i2c_session, I2cDevice_Tmp451);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void tmp451Exit(void) {
|
||||
i2csession::Close(&g_i2c_session);
|
||||
i2c::Exit();
|
||||
i2csessionClose(&g_i2c_session);
|
||||
i2cExit();
|
||||
}
|
||||
|
||||
s32 tmp451TempPcb(void) {
|
||||
+10
-2
@@ -26,9 +26,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch.hpp>
|
||||
using namespace nx;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
Result tmp451Initialize(void);
|
||||
void tmp451Exit(void);
|
||||
s32 tmp451TempPcb(void);
|
||||
s32 tmp451TempSoc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user