Extend Periphery code
This commit is contained in:
@@ -3,6 +3,39 @@
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Periphery_IO {
|
||||
__declare_io_value(JOY_STAT, uint32_t) {
|
||||
static constexpr auto TXReadyStart = Bit(0);
|
||||
static constexpr auto RXFifoNonEmpty = Bit(1);
|
||||
static constexpr auto TXReadyFinished = Bit(2);
|
||||
static constexpr auto RXParityError = Bit(3);
|
||||
static constexpr auto ACKIrqLow = Bit(7);
|
||||
|
||||
inline bool has_response() const {
|
||||
return this->is_set(RXFifoNonEmpty);
|
||||
}
|
||||
|
||||
inline bool is_ready_transfer() const {
|
||||
return this->is_set(TXReadyFinished);
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_value(JOY_CTRL, uint16_t) {
|
||||
static constexpr auto TXEnable = Bit(0);
|
||||
static constexpr auto SelectJoy = Bit(1);
|
||||
static constexpr auto ACK = Bit(4);
|
||||
static constexpr auto ACKIrqEnable = Bit(12);
|
||||
static constexpr auto PortBSelected = Bit(13);
|
||||
static constexpr auto PortASelected = !PortBSelected;
|
||||
|
||||
static constexpr JOY_CTRL create_for(uint16_t port) {
|
||||
return JOY_CTRL{static_cast<uint16_t>(port << PortBSelected)}.set(TXEnable, SelectJoy, ACKIrqEnable);
|
||||
}
|
||||
|
||||
static constexpr JOY_CTRL close() {
|
||||
return JOY_CTRL{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_value(JOY_MODE, uint16_t) {
|
||||
static constexpr JOY_MODE create() {
|
||||
return JOY_MODE{0x000D};
|
||||
@@ -15,7 +48,11 @@ namespace JabyEngine {
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_port(, JOY_MODE, 0x1F801048);
|
||||
__declare_io_port(, JOY_BAUD, 0x1F80104E);
|
||||
__declare_io_port_w_type(, uint8_t, JOY_TX_DATA, 0x1F801040);
|
||||
__declare_io_port_w_type(const, uint8_t, JOY_RX_DATA, 0x1F801040);
|
||||
__declare_io_port(const, JOY_STAT, 0x1F801044);
|
||||
__declare_io_port(, JOY_MODE, 0x1F801048);
|
||||
__declare_io_port(, JOY_CTRL, 0x1F80104A);
|
||||
__declare_io_port(, JOY_BAUD, 0x1F80104E);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user