Peripheral Class Reference
|
yasimavr
|
Abstract class defining a framework for MCU peripherals. More...
#include <sim_peripheral.h>
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 | |
| Peripheral & | operator= (const Peripheral &)=delete |
Public Member Functions inherited from IORegHandler | |
| virtual | ~IORegHandler ()=default |
Protected Member Functions | |
| Device * | device () const |
| Access to the device. It is null before init() is called. | |
| Logger & | logger () |
| Logging object associated with this peripheral. | |
| bool | register_interrupt (int_vect_t vector, InterruptHandler &handler) const |
| Signal * | get_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]
|
explicit |
◆ ~Peripheral()
|
virtual |
◆ Peripheral() [2/2]
|
delete |
Member Function Documentation
◆ add_ioreg() [1/4]
|
protected |
◆ add_ioreg() [2/4]
|
inlineprotected |
◆ add_ioreg() [3/4]
|
protected |
◆ add_ioreg() [4/4]
|
inlineprotected |
◆ clear_ioreg() [1/4]
|
protected |
◆ clear_ioreg() [2/4]
|
inlineprotected |
◆ clear_ioreg() [3/4]
|
inlineprotected |
◆ clear_ioreg() [4/4]
|
inlineprotected |
◆ ctlreq()
|
virtual |
Virtual method called for a CTL request. The method must return true if the request has been processed.
Reimplemented in ArchAVR_ACP, ArchAVR_ADC, ArchAVR_ExtInt, ArchAVR_NVM, ArchAVR_Fuses, ArchAVR_SPI, ArchAVR_Timer, ArchAVR_TWI, ArchAVR_USART, ArchAVR_WDT, ArchXT_ACP, ArchXT_ADC, ArchXT_MiscRegCtrl, ArchXT_NVM, ArchXT_SPI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_TWI, ArchXT_USART, ArchXT_WDT, InterruptController, SleepController, Port, and VREF.
◆ device()
|
inlineprotected |
Access to the device. It is null before init() is called.
◆ get_signal()
Helper function to obtain a pointer to a signal from another peripheral.
◆ id()
|
inline |
Unique identifier of the peripheral.
◆ init()
|
virtual |
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.
Reimplemented in ArchXT_VREF, ArchAVR_ACP, ArchAVR_ADC, ArchAVR_ExtInt, ArchAVR_IntCtrl, ArchAVR_MiscRegCtrl, 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_IntCtrl, ArchXT_ResetCtrl, ArchXT_MiscRegCtrl, ArchXT_PortMuxCtrl, ArchXT_USERROW, ArchXT_Fuses, ArchXT_NVM, ArchXT_Port, ArchXT_RTC, ArchXT_SPI, ArchXT_TimerA, ArchXT_TimerB, ArchXT_TWI, ArchXT_USART, ArchXT_WDT, DummyController, SleepController, and Port.
◆ ioreg_peek_handler()
|
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
-
addr the register address in I/O space value current 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()
|
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
-
addr the register address in I/O space value current 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()
|
overridevirtual |
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
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()
|
inlineprotected |
Logging object associated with this peripheral.
◆ name()
| std::string Peripheral::name | ( | ) | const |
The name of the peripheral.
◆ operator=()
|
delete |
◆ read_ioreg() [1/4]
|
protected |
◆ read_ioreg() [2/4]
|
inlineprotected |
◆ read_ioreg() [3/4]
|
protected |
◆ read_ioreg() [4/4]
|
inlineprotected |
◆ register_interrupt()
|
protected |
Helper function to register an interrupt vector.
◆ reset()
|
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
-
flags Reset 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]
|
protected |
◆ set_ioreg() [2/4]
|
inlineprotected |
◆ set_ioreg() [3/4]
|
inlineprotected |
◆ set_ioreg() [4/4]
|
inlineprotected |
◆ sleep()
|
virtual |
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
Reimplemented in ArchAVR_ADC, ArchXT_ACP, ArchXT_ADC, ArchXT_RTC, ArchXT_TimerA, ArchXT_TimerB, ArchXT_USART, and InterruptController.
◆ test_ioreg() [1/4]
|
inlineprotected |
◆ test_ioreg() [2/4]
|
inlineprotected |
◆ test_ioreg() [3/4]
|
inlineprotected |
◆ test_ioreg() [4/4]
|
inlineprotected |
◆ write_ioreg() [1/5]
|
protected |
◆ write_ioreg() [2/5]
|
inlineprotected |
◆ write_ioreg() [3/5]
|
protected |
◆ write_ioreg() [4/5]
|
inlineprotected |
◆ write_ioreg() [5/5]
|
inlineprotected |
The documentation for this class was generated from the following files:
Generated by
Public Member Functions inherited from