Class Peripheral
Defined in File sim_peripheral.h
Inheritance Relationships
Base Type
public IO_RegHandler(Class IO_RegHandler)
Derived Types
public ArchAVR_ACP(Class ArchAVR_ACP)public ArchAVR_ADC(Class ArchAVR_ADC)public ArchAVR_ExtInt(Class ArchAVR_ExtInt)public ArchAVR_Fuses(Class ArchAVR_Fuses)public ArchAVR_MiscRegCtrl(Class ArchAVR_MiscRegCtrl)public ArchAVR_NVM(Class ArchAVR_NVM)public ArchAVR_ResetCtrl(Class ArchAVR_ResetCtrl)public ArchAVR_SPI(Class ArchAVR_SPI)public ArchAVR_TWI(Class ArchAVR_TWI)public ArchAVR_Timer(Class ArchAVR_Timer)public ArchAVR_USART(Class ArchAVR_USART)public ArchAVR_USI(Class ArchAVR_USI)public ArchAVR_WDT(Class ArchAVR_WDT)public ArchXT_ACP(Class ArchXT_ACP)public ArchXT_ADC(Class ArchXT_ADC)public ArchXT_Fuses(Class ArchXT_Fuses)public ArchXT_MiscRegCtrl(Class ArchXT_MiscRegCtrl)public ArchXT_NVM(Class ArchXT_NVM)public ArchXT_PortMuxCtrl(Class ArchXT_PortMuxCtrl)public ArchXT_RTC(Class ArchXT_RTC)public ArchXT_ResetCtrl(Class ArchXT_ResetCtrl)public ArchXT_SPI(Class ArchXT_SPI)public ArchXT_TWI(Class ArchXT_TWI)public ArchXT_TimerA(Class ArchXT_TimerA)public ArchXT_TimerB(Class ArchXT_TimerB)public ArchXT_USART(Class ArchXT_USART)public ArchXT_USERROW(Class ArchXT_USERROW)public DummyController(Class DummyController)public InterruptController(Class InterruptController)public Port(Class Port)public SleepController(Class SleepController)public VREF(Class VREF)public WatchdogTimer(Class WatchdogTimer)
Class Documentation
-
class Peripheral : public IO_RegHandler
Abstract class defining a framework for MCU peripherals.
Subclassed by ArchAVR_ACP, ArchAVR_ADC, ArchAVR_ExtInt, ArchAVR_Fuses, ArchAVR_MiscRegCtrl, ArchAVR_NVM, ArchAVR_ResetCtrl, ArchAVR_SPI, ArchAVR_TWI, ArchAVR_Timer, ArchAVR_USART, ArchAVR_USI, ArchAVR_WDT, ArchXT_ACP, ArchXT_ADC, ArchXT_Fuses, ArchXT_MiscRegCtrl, ArchXT_NVM, ArchXT_PortMuxCtrl, ArchXT_RTC, ArchXT_ResetCtrl, ArchXT_SPI, ArchXT_TWI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_USART, ArchXT_USERROW, DummyController, InterruptController, Port, SleepController, VREF, WatchdogTimer
Public Functions
-
virtual ~Peripheral()
-
std::string name() const
- Returns:
the name of the peripheral (the id converted to 4 ASCII characters)
-
virtual bool init(Device &device)
Virtual method called when the device is initialised. This is where the peripheral can allocate its I/O registers, interrupts or connect signals.
- Returns:
boolean indicates the success of all allocations.
-
virtual void reset()
Virtual method called when the device is reset. Note that resetting I/O registers is only necessary here if their reset value is not zero.
-
virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t *data)
Virtual method called for a CTL request. The method must return true if the request has been processed.
-
virtual uint8_t ioreg_read_handler(reg_addr_t addr, uint8_t value) override
Virtual method called when the CPU is reading a I/O register allocated by this peripheral. The value has not been read yet so the module can modify it before the CPU gets it.
- Parameters:
addr – the register address in I/O space
value – current cached value of the register
- Returns:
actual value of the register
-
virtual uint8_t ioreg_peek_handler(reg_addr_t addr, uint8_t value) override
Virtual method called when a debug probe is peeking the value of a register. The value has not been read yet so the module can modify it before the CPU gets it. The difference between a peek and a read is that a peek should not modify the state of the peripheral. By default, ioreg_read_handler is called to obtain the value.
- Parameters:
addr – the register address in I/O space
value – current cached value of the register
- Returns:
actual value of the register
-
virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t &data) override
Virtual method called when the CPU is writing a I/O register allocated by this peripheral. The value has already been written.
- Parameters:
addr – the register address in I/O space
value – the new register content
-
virtual void sleep(bool on, SleepMode mode)
Virtual method called when the device enters or exits a sleep mode.
- Parameters:
on – true when entering a sleep mode, false when exiting it.
mode – one of the enum SleepMode values
-
Peripheral(const Peripheral&) = delete
-
Peripheral &operator=(const Peripheral&) = delete
Protected Functions
-
void add_ioreg(const regbit_compound_t &rbc, bool readonly = false)
-
void add_ioreg(reg_addr_t addr, uint8_t mask = 0xFF, bool readonly = false)
-
uint8_t read_ioreg(reg_addr_t reg) const
-
uint64_t read_ioreg(const regbit_compound_t &rbc) const
-
inline uint8_t read_ioreg(reg_addr_t reg, const bitmask_t &bm) const
-
inline bool test_ioreg(reg_addr_t reg, uint8_t bit) const
-
inline bool test_ioreg(reg_addr_t reg, const bitmask_t &bm) const
-
void write_ioreg(const regbit_compound_t &rbc, uint64_t value)
-
inline void write_ioreg(reg_addr_t reg, uint8_t value)
-
inline void write_ioreg(reg_addr_t reg, uint8_t bit, uint8_t value)
-
inline void write_ioreg(reg_addr_t reg, const bitmask_t &bm, uint8_t value)
-
void set_ioreg(const regbit_compound_t &rbc)
-
inline void set_ioreg(reg_addr_t reg, uint8_t bit)
-
inline void set_ioreg(reg_addr_t reg, const bitmask_t &bm)
-
void clear_ioreg(const regbit_compound_t &rbc)
-
inline void clear_ioreg(reg_addr_t reg)
-
inline void clear_ioreg(reg_addr_t reg, uint8_t bit)
-
inline void clear_ioreg(reg_addr_t reg, const bitmask_t &bm)
-
bool register_interrupt(int_vect_t vector, InterruptHandler &handler) const
Helper function to register an interrupt vector.
-
virtual ~Peripheral()