52 lines
2.0 KiB
C++
52 lines
2.0 KiB
C++
#ifndef __JABYENGINE_CD_INTERNAL_HPP__
|
|
#define __JABYENGINE_CD_INTERNAL_HPP__
|
|
#include "cd_types.hpp"
|
|
|
|
namespace JabyEngine {
|
|
namespace CD {
|
|
namespace internal {
|
|
extern State current_state;
|
|
extern CD_IO::Interrupt::Type last_interrupt;
|
|
extern uint8_t cmd_interrupt_bit;
|
|
|
|
struct Command {
|
|
static void wait_completed() {
|
|
while(const_cast<volatile uint8_t&>(cmd_interrupt_bit) > 0);
|
|
}
|
|
|
|
template<typename...ARGS>
|
|
static void send(CD_IO::CommandFifo_v& cmd_fifo, CD_IO::ParameterFifo_v& parameter_fifo, CD_IO::Command::Desc cmd, ARGS...args) {
|
|
while(CD_IO::IndexStatus.is_set(CD_IO::IndexStatus_t::IsTransmissionBusy));
|
|
|
|
((parameter_fifo = args),...);
|
|
cmd_fifo = cmd.id;
|
|
cmd_interrupt_bit = bit::set(0, cmd.complete_irq);
|
|
}
|
|
|
|
template<typename T, typename...ARGS>
|
|
static void send(CD_IO::Command::Desc cmd, ARGS...args) {
|
|
send(T::CommandFifo, T::ParameterFifo, cmd, args...);
|
|
}
|
|
|
|
template<typename...ARGS>
|
|
static void send_wait(CD_IO::CommandFifo_v& cmd_fifo, CD_IO::ParameterFifo_v& parameter_fifo, CD_IO::Command::Desc cmd, ARGS...args) {
|
|
send(cmd_fifo, parameter_fifo, cmd, args...);
|
|
wait_completed();
|
|
}
|
|
|
|
template<typename T, typename...ARGS>
|
|
static void send_wait(CD_IO::Command::Desc cmd, ARGS...args) {
|
|
send_wait(T::CommandFifo, T::ParameterFifo, cmd, args...);
|
|
}
|
|
};
|
|
|
|
static State read_current_state() {
|
|
return const_cast<volatile State&>(current_state);
|
|
}
|
|
|
|
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
|
|
void continue_reading();
|
|
}
|
|
}
|
|
}
|
|
#endif //!__JABYENGINE_CD_INTERNAL_HPP__
|