sim_sleep.h Source File

yasimavr: sim_sleep.h Source File
yasimavr
Loading...
Searching...
No Matches
sim_sleep.h
Go to the documentation of this file.
1/*
2 * sim_sleep.h
3 *
4 * Copyright 2021 Clement Savergne <csavergne@yahoo.com>
5
6 This file is part of yasim-avr.
7
8 yasim-avr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 yasim-avr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with yasim-avr. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22//=======================================================================================
23
24#ifndef __YASIMAVR_SLEEP_H__
25#define __YASIMAVR_SLEEP_H__
26
27#include "sim_peripheral.h"
28#include "sim_signal.h"
29#include "sim_types.h"
30
32
33//=======================================================================================
34/*
35 * CTLREQ definitions
36*/
37
38//AVR_CTLREQ_SLEEP_CALL (defined in sim_peripheral.h) :
39//Request sent by the CPU when executing a SLEEP instruction.
40//No data is required
41
42//AVR_CTLREQ_SLEEP_PSEUDO (defined in sim_peripheral.h) :
43//Request sent by the CPU when executing a infinite loop (RJMP .-2) with GIE flag set
44//No data is required
45
49enum class SleepMode {
50 Invalid,
51 Active,
52 Pseudo,
53 Idle,
54 ADC,
55 Standby,
59};
60
62
63
64//=======================================================================================
65
71
83
85 std::vector<mode_config_t> modes;
90};
91
92
110
111public:
112
113 explicit SleepController(const SleepConfig& config);
114
115 virtual bool init(Device& device) override;
116 virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t* data) override;
117 virtual void raised(const signal_data_t& sigdata, int hooktag) override;
118
119private:
120
121 const SleepConfig& m_config;
122 //Index of the current sleep mode in the configuration mode map
123 unsigned int m_mode_index;
124
125};
126
127
129
130#endif //__YASIMAVR_SLEEP_H__
Basic AVR device model.
Definition sim_device.h:61
Abstract class defining a framework for MCU peripherals.
Definition sim_peripheral.h:286
virtual bool init(Device &device)
Definition sim_peripheral.cpp:60
virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t *data)
Definition sim_peripheral.cpp:79
Definition sim_signal.h:55
virtual void raised(const signal_data_t &sigdata, int hooktag)=0
Generic sleep mode controller.
Definition sim_sleep.h:109
Represents a field in a I/O register with address.
Definition sim_types.h:348
int ctlreq_id_t
Definition sim_peripheral.h:111
#define YASIMAVR_BEGIN_NAMESPACE
Definition sim_globals.h:58
#define AVR_CORE_PUBLIC_API
Definition sim_globals.h:46
#define YASIMAVR_END_NAMESPACE
Definition sim_globals.h:59
SleepMode
Definition sim_sleep.h:49
const char * SleepModeName(SleepMode mode) AVR_CORE_PUBLIC_API
Definition sim_sleep.cpp:45
Configuration structure for each supported sleep mode.
Definition sim_sleep.h:79
uint8_t int_mask[16]
Definition sim_sleep.h:81
SleepMode mode
Definition sim_sleep.h:80
Configuration structure for a generic sleep mode controller.
Definition sim_sleep.h:70
regbit_t rb_enable
Register location for the sleep enable bit.
Definition sim_sleep.h:89
std::vector< mode_config_t > modes
The supported sleep modes.
Definition sim_sleep.h:85
regbit_t rb_mode
Register location for the sleep mode selection.
Definition sim_sleep.h:87
Definition sim_peripheral.h:252
Definition sim_peripheral.h:237
Definition sim_signal.h:39