Peripheral Class Reference

yasimavr: Peripheral Class Reference
yasimavr
Loading...
Searching...
No Matches

Abstract class defining a framework for MCU peripherals. More...

#include <sim_peripheral.h>

Inheritance diagram for Peripheral:
IORegHandler 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 ArchXT_WDT DummyController InterruptController Port SleepController VREF

Public Member Functions

 Peripheral (ctl_id_t id)
 
virtual ~Peripheral ()
 
ctl_id_t id () const
 Unique identifier of the peripheral.
 
std::string name () const
 The name of the peripheral.
 
virtual bool init (Device &device)
 
virtual void reset (int flags)
 
virtual bool ctlreq (ctlreq_id_t req, ctlreq_data_t *data)
 
virtual uint8_t ioreg_read_handler (reg_addr_t addr, uint8_t value) override
 
virtual uint8_t ioreg_peek_handler (reg_addr_t addr, uint8_t value) override
 
virtual void ioreg_write_handler (reg_addr_t addr, const ioreg_write_t &data) override
 
virtual void sleep (bool on, SleepMode mode)
 
 Peripheral (const Peripheral &)=delete
 
Peripheraloperator= (const Peripheral &)=delete
 
- Public Member Functions inherited from IORegHandler
virtual ~IORegHandler ()=default
 

Protected Member Functions

Devicedevice () const
 Access to the device. It is null before init() is called.
 
Loggerlogger ()
 Logging object associated with this peripheral.
 
bool register_interrupt (int_vect_t vector, InterruptHandler &handler) const
 
Signalget_signal (ctl_id_t ctl_id) const
 
IO Register creation

Functions to create an IO Register and add this as a handler

void add_ioreg (const regmask_t &rm, IORegister::BitMode bitmode=IORegister::RW)
 
void add_ioreg (const regbit_compound_t &rbc, IORegister::BitMode bitmode=IORegister::RW)
 
void add_ioreg (reg_addr_t addr, IORegister::BitMode bitmode=IORegister::RW)
 
void add_ioreg (reg_addr_t addr, bitmask_t mask, IORegister::BitMode bitmode=IORegister::RW)
 
IO Register value manipulation

Functions to read/write/set/clear the value of an IO Register

uint8_t read_ioreg (const regbit_t &rb) const
 
uint64_t read_ioreg (const regbit_compound_t &rbc) const
 
uint8_t read_ioreg (reg_addr_t addr) const
 
uint8_t read_ioreg (reg_addr_t addr, const bitspec_t &bs) const
 
bool test_ioreg (const regbit_t &rb) const
 
bool test_ioreg (const regbit_compound_t &rbc) const
 
bool test_ioreg (reg_addr_t addr, const bitspec_t &bs) const
 
bool test_ioreg (reg_addr_t addr, bitmask_t bm=0xFF) const
 
void write_ioreg (reg_addr_t addr, bitmask_t bm, uint8_t value)
 
void write_ioreg (const regbit_t &rb, uint8_t value)
 
void write_ioreg (const regbit_compound_t &rbc, uint64_t value)
 
void write_ioreg (reg_addr_t addr, uint8_t value)
 
void write_ioreg (reg_addr_t addr, const bitspec_t &bs, uint8_t value)
 
void set_ioreg (reg_addr_t addr, bitmask_t bm=0xFF)
 
void set_ioreg (const regbit_t &rb)
 
void set_ioreg (const regbit_compound_t &rbc)
 
void set_ioreg (reg_addr_t addr, const bitspec_t &bs)
 
void clear_ioreg (reg_addr_t addr, bitmask_t bm=0xFF)
 
void clear_ioreg (const regbit_t &rb)
 
void clear_ioreg (const regbit_compound_t &rbc)
 
void clear_ioreg (reg_addr_t addr, const bitspec_t &bs)
 

Detailed Description

Abstract class defining a framework for MCU peripherals.

Constructor & Destructor Documentation

◆ Peripheral() [1/2]

YASIMAVR_USING_NAMESPACE Peripheral::Peripheral ( ctl_id_t  id)
explicit

◆ ~Peripheral()

Peripheral::~Peripheral ( )
virtual

◆ Peripheral() [2/2]

Peripheral::Peripheral ( const Peripheral )
delete

Member Function Documentation

◆ add_ioreg() [1/4]

void Peripheral::add_ioreg ( const regbit_compound_t rbc,
IORegister::BitMode  bitmode = IORegister::RW 
)
protected

◆ add_ioreg() [2/4]

void Peripheral::add_ioreg ( const regmask_t rm,
IORegister::BitMode  bitmode = IORegister::RW 
)
inlineprotected

◆ add_ioreg() [3/4]

void Peripheral::add_ioreg ( reg_addr_t  addr,
bitmask_t  mask,
IORegister::BitMode  bitmode = IORegister::RW 
)
protected

◆ add_ioreg() [4/4]

void Peripheral::add_ioreg ( reg_addr_t  addr,
IORegister::BitMode  bitmode = IORegister::RW 
)
inlineprotected

◆ clear_ioreg() [1/4]

void Peripheral::clear_ioreg ( const regbit_compound_t rbc)
protected

◆ clear_ioreg() [2/4]

void Peripheral::clear_ioreg ( const regbit_t rb)
inlineprotected

◆ clear_ioreg() [3/4]

void Peripheral::clear_ioreg ( reg_addr_t  addr,
bitmask_t  bm = 0xFF 
)
inlineprotected

◆ clear_ioreg() [4/4]

void Peripheral::clear_ioreg ( reg_addr_t  addr,
const bitspec_t bs 
)
inlineprotected

◆ ctlreq()

bool Peripheral::ctlreq ( ctlreq_id_t  req,
ctlreq_data_t data 
)
virtual

◆ device()

Device * Peripheral::device ( ) const
inlineprotected

Access to the device. It is null before init() is called.

◆ get_signal()

Signal * Peripheral::get_signal ( ctl_id_t  ctl_id) const
protected

Helper function to obtain a pointer to a signal from another peripheral.

◆ id()

ctl_id_t Peripheral::id ( ) const
inline

Unique identifier of the peripheral.

◆ init()

bool Peripheral::init ( Device device)
virtual

◆ ioreg_peek_handler()

uint8_t Peripheral::ioreg_peek_handler ( reg_addr_t  addr,
uint8_t  value 
)
overridevirtual

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
addrthe register address in I/O space
valuecurrent cached value of the register
Returns
actual value of the register

Implements IORegHandler.

Reimplemented in ArchAVR_SPI, ArchAVR_Timer, ArchXT_RTC, ArchXT_SPI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_TWI, and ArchXT_USART.

◆ ioreg_read_handler()

uint8_t Peripheral::ioreg_read_handler ( reg_addr_t  addr,
uint8_t  value 
)
overridevirtual

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
addrthe register address in I/O space
valuecurrent cached value of the register
Returns
actual value of the register

Implements IORegHandler.

Reimplemented in ArchAVR_ADC, ArchAVR_SPI, ArchAVR_Timer, ArchAVR_USART, ArchXT_ADC, ArchXT_MiscRegCtrl, ArchXT_Port, ArchXT_RTC, ArchXT_SPI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_TWI, and ArchXT_USART.

◆ ioreg_write_handler()

void Peripheral::ioreg_write_handler ( reg_addr_t  addr,
const ioreg_write_t value 
)
overridevirtual

Virtual method called when the CPU is writing a I/O register allocated by this peripheral. The value has already been written.

Parameters
addrthe register address in I/O space
valuethe new register content

Implements IORegHandler.

Reimplemented in ArchAVR_IntCtrl, ArchAVR_ACP, ArchAVR_ADC, ArchAVR_ExtInt, ArchAVR_ResetCtrl, ArchAVR_NVM, ArchAVR_Port, ArchAVR_SPI, ArchAVR_Timer, ArchAVR_TWI, ArchAVR_USART, ArchAVR_USI, ArchAVR_WDT, ArchXT_ACP, ArchXT_ADC, ArchXT_VREF, ArchXT_IntCtrl, ArchXT_ResetCtrl, ArchXT_MiscRegCtrl, ArchXT_PortMuxCtrl, ArchXT_USERROW, ArchXT_NVM, ArchXT_Port, ArchXT_RTC, ArchXT_SPI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_TWI, ArchXT_USART, and ArchXT_WDT.

◆ logger()

Logger & Peripheral::logger ( )
inlineprotected

Logging object associated with this peripheral.

◆ name()

std::string Peripheral::name ( ) const

The name of the peripheral.

◆ operator=()

Peripheral & Peripheral::operator= ( const Peripheral )
delete

◆ read_ioreg() [1/4]

uint64_t Peripheral::read_ioreg ( const regbit_compound_t rbc) const
protected

◆ read_ioreg() [2/4]

uint8_t Peripheral::read_ioreg ( const regbit_t rb) const
inlineprotected

◆ read_ioreg() [3/4]

uint8_t Peripheral::read_ioreg ( reg_addr_t  addr) const
protected

◆ read_ioreg() [4/4]

uint8_t Peripheral::read_ioreg ( reg_addr_t  addr,
const bitspec_t bs 
) const
inlineprotected

◆ register_interrupt()

bool Peripheral::register_interrupt ( int_vect_t  vector,
InterruptHandler handler 
) const
protected

Helper function to register an interrupt vector.

◆ reset()

void Peripheral::reset ( int  flags)
virtual

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.

Parameters
flagsReset flags (OR'ed combination of Device::ResetFlag enumeration values)

Reimplemented in ArchAVR_ACP, ArchAVR_ADC, ArchAVR_ExtInt, ArchAVR_ResetCtrl, ArchAVR_NVM, ArchAVR_Fuses, ArchAVR_Port, ArchAVR_SPI, ArchAVR_Timer, ArchAVR_TWI, ArchAVR_USART, ArchAVR_USI, ArchAVR_WDT, ArchXT_ACP, ArchXT_ADC, ArchXT_VREF, ArchXT_ResetCtrl, ArchXT_MiscRegCtrl, ArchXT_PortMuxCtrl, ArchXT_Fuses, ArchXT_NVM, ArchXT_RTC, ArchXT_SPI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_TWI, ArchXT_USART, ArchXT_WDT, InterruptController, DummyController, and Port.

◆ set_ioreg() [1/4]

void Peripheral::set_ioreg ( const regbit_compound_t rbc)
protected

◆ set_ioreg() [2/4]

void Peripheral::set_ioreg ( const regbit_t rb)
inlineprotected

◆ set_ioreg() [3/4]

void Peripheral::set_ioreg ( reg_addr_t  addr,
bitmask_t  bm = 0xFF 
)
inlineprotected

◆ set_ioreg() [4/4]

void Peripheral::set_ioreg ( reg_addr_t  addr,
const bitspec_t bs 
)
inlineprotected

◆ sleep()

void Peripheral::sleep ( bool  on,
SleepMode  mode 
)
virtual

Virtual method called when the device enters or exits a sleep mode.

Parameters
ontrue when entering a sleep mode, false when exiting it.
modeone of the enum SleepMode values

Reimplemented in ArchAVR_ADC, ArchXT_ACP, ArchXT_ADC, ArchXT_RTC, ArchXT_TimerA, ArchXT_TimerB, ArchXT_USART, and InterruptController.

◆ test_ioreg() [1/4]

bool Peripheral::test_ioreg ( const regbit_compound_t rbc) const
inlineprotected

◆ test_ioreg() [2/4]

bool Peripheral::test_ioreg ( const regbit_t rb) const
inlineprotected

◆ test_ioreg() [3/4]

bool Peripheral::test_ioreg ( reg_addr_t  addr,
bitmask_t  bm = 0xFF 
) const
inlineprotected

◆ test_ioreg() [4/4]

bool Peripheral::test_ioreg ( reg_addr_t  addr,
const bitspec_t bs 
) const
inlineprotected

◆ write_ioreg() [1/5]

void Peripheral::write_ioreg ( const regbit_compound_t rbc,
uint64_t  value 
)
protected

◆ write_ioreg() [2/5]

void Peripheral::write_ioreg ( const regbit_t rb,
uint8_t  value 
)
inlineprotected

◆ write_ioreg() [3/5]

void Peripheral::write_ioreg ( reg_addr_t  addr,
bitmask_t  bm,
uint8_t  value 
)
protected

◆ write_ioreg() [4/5]

void Peripheral::write_ioreg ( reg_addr_t  addr,
const bitspec_t bs,
uint8_t  value 
)
inlineprotected

◆ write_ioreg() [5/5]

void Peripheral::write_ioreg ( reg_addr_t  addr,
uint8_t  value 
)
inlineprotected

The documentation for this class was generated from the following files: