skl-tunnel/radio/include/radio_hw_instance.hpp
2022-07-12 18:04:40 +03:00

59 lines
1.1 KiB
C++

//
// Created by erki on 4.06.22.
//
#ifndef SKL_TUNNEL_RADIO_HW_INSTANCE_HPP
#define SKL_TUNNEL_RADIO_HW_INSTANCE_HPP
#include <hal_spi_m_sync.h>
#include "radio_hw_registers.hpp"
namespace radio
{
struct HwInstance
{
enum class States : std::uint8_t
{
P_ON = 0,
BUSY_RX,
BUSY_TX,
RX_ON,
TRX_OFF,
PLL_ON,
SLEEP,
PREP_DEEP_SLEEP,
BUSY_RX_AACK,
BUSY_TX_ARET,
RX_AACK_ON,
TX_ARET_ON
};
static HwInstance* instance();
HwInstance();
HwInstance(const HwInstance&) = delete;
HwInstance(HwInstance&&) = delete;
HwInstance& operator=(const HwInstance&) = delete;
HwInstance& operator=(HwInstance&&) = delete;
void irq_handler();
uint8_t register_read(const Registers& address);
void register_write(const Registers& address, const uint8_t value);
States current_state() const;
bool set_current_state(const States& new_state);
private:
spi_m_sync_descriptor* m_spi = nullptr;
io_descriptor* m_spi_io = nullptr;
States m_current_state = States::P_ON;
void m_wait_transition_complete();
};
}
#endif //SKL_TUNNEL_RADIO_HW_INSTANCE_HPP