SleepController Class Reference

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

Generic sleep mode controller. More...

#include <sim_sleep.h>

Inheritance diagram for SleepController:
Peripheral SignalHook IORegHandler

Public Member Functions

 SleepController (const SleepConfig &config)
 
virtual bool init (Device &device) override
 
virtual bool ctlreq (ctlreq_id_t req, ctlreq_data_t *data) override
 
virtual void raised (const signal_data_t &sigdata, int hooktag) override
 
- Public Member Functions inherited from Peripheral
 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 void reset (int flags)
 
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
 
- Public Member Functions inherited from SignalHook
 SignalHook ()=default
 
 SignalHook (const SignalHook &)
 
 SignalHook (const SignalHook &&)=delete
 
virtual ~SignalHook ()
 
SignalHookoperator= (const SignalHook &)
 
SignalHookoperator= (const SignalHook &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from Peripheral
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
 
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)
 
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

Generic sleep mode controller.

It listens for the sleep instruction notification from the CPU and, using the register configuration, determines which sleep mode the MCU should enter. It then sends a CTL request to the device to enter sleep.

It is also connected to the interrupt controller to listen to any interrupt raise, and determines if the interrupt is able to wake the MCU up. If so, it sends a CTL request to the device to exit sleep.

This controller also manages the "pseudo-sleep" mode, which is treated as any other sleep mode, and which can be exited by any interrupt.

All the configuration is done at construction by mean of a AVR_SleepConfig object.

Constructor & Destructor Documentation

◆ SleepController()

SleepController::SleepController ( const SleepConfig config)
explicit

Member Function Documentation

◆ ctlreq()

bool SleepController::ctlreq ( ctlreq_id_t  req,
ctlreq_data_t data 
)
overridevirtual

Virtual method called for a CTL request. The method must return true if the request has been processed.

Reimplemented from Peripheral.

◆ init()

bool SleepController::init ( Device device)
overridevirtual

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 from Peripheral.

◆ raised()

void SleepController::raised ( const signal_data_t sigdata,
int  hooktag 
)
overridevirtual

Pure virtual callback called during signal raises.

Parameters
sigdataData structure passed on when raising a signal
hooktaginteger passed on when connecting a hook to a signal. For hooks connected to several signals, it provides a mean to identify the caller.

Implements SignalHook.


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