gpio: add (most of) driver framework for boot sysmodule usage
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/gpio/gpio_types.hpp>
|
||||
#include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp>
|
||||
|
||||
namespace ams::gpio::driver::board::nintendo_nx {
|
||||
|
||||
void Initialize(bool enable_interrupt_handlers);
|
||||
|
||||
void SetInitialGpioConfig();
|
||||
void SetInitialWakePinConfig();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/gpio/gpio_types.hpp>
|
||||
#include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp>
|
||||
|
||||
namespace ams::gpio::driver {
|
||||
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/gpio/gpio_types.hpp>
|
||||
#include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp>
|
||||
|
||||
namespace ams::gpio::driver {
|
||||
|
||||
void RegisterDriver(IGpioDriver *driver);
|
||||
void UnregisterDriver(IGpioDriver *driver);
|
||||
|
||||
Result RegisterDeviceCode(DeviceCode device_code, Pad *pad);
|
||||
bool UnregisterDeviceCode(DeviceCode device_code);
|
||||
|
||||
void RegisterInterruptHandler(ddsf::IEventHandler *handler);
|
||||
void UnregisterInterruptHandler(ddsf::IEventHandler *handler);
|
||||
|
||||
void SetInitialGpioConfig();
|
||||
void SetInitialWakePinConfig();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/gpio/gpio_types.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::gpio::driver {
|
||||
|
||||
class Pad;
|
||||
|
||||
class IGpioDriver : public ::ams::ddsf::IDriver {
|
||||
NON_COPYABLE(IGpioDriver);
|
||||
NON_MOVEABLE(IGpioDriver);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::IGpioDriver, ::ams::ddsf::IDriver);
|
||||
public:
|
||||
IGpioDriver() : IDriver() { /* ... */ }
|
||||
virtual ~IGpioDriver() { /* ... */ }
|
||||
|
||||
virtual void InitializeDriver() = 0;
|
||||
virtual void FinalizeDriver() = 0;
|
||||
|
||||
virtual Result InitializePad(Pad *pad) = 0;
|
||||
virtual void FinalizePad(Pad *pad) = 0;
|
||||
|
||||
virtual Result GetDirection(Direction *out, Pad *pad) const = 0;
|
||||
virtual Result SetDirection(Pad *pad, Direction direction) = 0;
|
||||
|
||||
virtual Result GetValue(GpioValue *out, Pad *pad) const = 0;
|
||||
virtual Result SetValue(Pad *pad, GpioValue value) = 0;
|
||||
|
||||
virtual Result GetInterruptMode(InterruptMode *out, Pad *pad) const = 0;
|
||||
virtual Result SetInterruptMode(Pad *pad, InterruptMode mode) = 0;
|
||||
|
||||
virtual Result SetInterruptEnabled(Pad *pad, bool en) = 0;
|
||||
|
||||
virtual Result GetInterruptStatus(InterruptStatus *out, Pad *pad) = 0;
|
||||
virtual Result ClearInterruptStatus(Pad *pad) = 0;
|
||||
|
||||
virtual os::SdkMutex &GetInterruptControlMutex(const Pad &pad) const = 0;
|
||||
|
||||
virtual Result GetDebounceEnabled(bool *out, Pad *pad) const = 0;
|
||||
virtual Result SetDebounceEnabled(Pad *pad, bool en) = 0;
|
||||
|
||||
virtual Result GetDebounceTime(s32 *out_ms, Pad *pad) const = 0;
|
||||
virtual Result SetDebounceTime(Pad *pad, s32 ms) = 0;
|
||||
|
||||
virtual Result GetUnknown22(u32 *out) = 0;
|
||||
virtual void Unknown23();
|
||||
|
||||
virtual Result SetValueForSleepState(Pad *pad, GpioValue value) = 0;
|
||||
virtual Result IsWakeEventActive(bool *out, Pad *pad) const = 0;
|
||||
virtual Result SetWakeEventActiveFlagSetForDebug(Pad *pad, bool en) = 0;
|
||||
virtual Result SetWakePinDebugMode(WakePinDebugMode mode) = 0;
|
||||
|
||||
virtual Result Suspend() = 0;
|
||||
virtual Result SuspendLow() = 0;
|
||||
virtual Result Resume() = 0;
|
||||
virtual Result ResumeLow() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/gpio/gpio_types.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::gpio::driver {
|
||||
|
||||
class Pad : public ::ams::ddsf::IDevice {
|
||||
NON_COPYABLE(Pad);
|
||||
NON_MOVEABLE(Pad);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::Pad, ::ams::ddsf::IDevice);
|
||||
private:
|
||||
int pad_number;
|
||||
bool is_interrupt_enabled;
|
||||
public:
|
||||
explicit Pad(int pad) : IDevice(true), pad_number(pad), is_interrupt_enabled(false) { /* ... */ }
|
||||
|
||||
Pad() : Pad(0) { /* ... */ }
|
||||
|
||||
virtual ~Pad() { /* ... */ }
|
||||
|
||||
int GetPadNumber() const {
|
||||
return this->pad_number;
|
||||
}
|
||||
|
||||
void SetPadNumber(int p) {
|
||||
this->pad_number = p;
|
||||
}
|
||||
|
||||
bool IsInterruptEnabled() const {
|
||||
return this->is_interrupt_enabled;
|
||||
}
|
||||
|
||||
void SetInterruptEnabled(bool en) {
|
||||
this->is_interrupt_enabled = en;
|
||||
}
|
||||
|
||||
bool IsInterruptRequiredForDriver() const {
|
||||
return this->IsInterruptEnabled() && this->IsAnySessionBoundToInterrupt();
|
||||
}
|
||||
|
||||
bool IsAnySessionBoundToInterrupt() const;
|
||||
void SignalInterruptBoundEvent();
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/gpio/gpio_types.hpp>
|
||||
#include <stratosphere/gpio/driver/gpio_i_gpio_driver.hpp>
|
||||
#include <stratosphere/gpio/driver/gpio_driver_service_api.hpp>
|
||||
#include <stratosphere/gpio/driver/gpio_driver_client_api.hpp>
|
||||
|
||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
|
||||
|
||||
#include <stratosphere/gpio/driver/board/nintendo_nx/gpio_driver_api.hpp>
|
||||
|
||||
namespace ams::gpio::driver::board {
|
||||
|
||||
using namespace ams::gpio::driver::board::nintendo_nx;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error "Unknown board for ams::gpio::driver::"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user