arch_avr_wdt.h Source File

yasimavr: arch_avr_wdt.h Source File
yasimavr
Loading...
Searching...
No Matches
arch_avr_wdt.h
Go to the documentation of this file.
1/*
2 * arch_avr_wdt.h
3 *
4 * Copyright 2021-2026 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_AVR_WDT_H__
25#define __YASIMAVR_AVR_WDT_H__
26
27#include "arch_avr_globals.h"
29#include "core/sim_interrupt.h"
30
32
33//=======================================================================================
34
60
61
66
67public:
68
69 explicit ArchAVR_WDT(const ArchAVR_WDTConfig& config);
70
71 virtual bool init(Device& device) override;
72 virtual void reset(int flags) override;
73 virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t* data) override;
74 virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t& data) override;
75 virtual bool interrupt_ack_handler(int_vect_t vector) override;
76
77private:
78
79 const ArchAVR_WDTConfig& m_config;
82
83 cycle_count_t calculate_delay();
84 void reschedule_timer();
85 cycle_count_t wdt_timeout(cycle_count_t when);
86 void lock_timeout();
87
88};
89
90
92
93#endif //__YASIMAVR_AVR_WDT_H__
#define AVR_ARCHAVR_PUBLIC_API
Definition arch_avr_globals.h:46
Implementation of a Watchdog Timer for AVR series.
Definition arch_avr_wdt.h:65
Definition sim_cycle_timer.h:85
Basic AVR device model.
Definition sim_device.h:61
Abstract interface to a interrupt controller.
Definition sim_interrupt.h:221
virtual bool interrupt_ack_handler(int_vect_t vector)=0
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
virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t &data) override
Definition sim_peripheral.cpp:117
virtual void reset(int flags)
Definition sim_peripheral.cpp:72
bit spec structure. Represent a field in a I/O register. It works the same as bitmask_t except used b...
Definition sim_types.h:287
Representation of a I/O register address, with validity state.
Definition sim_types.h:60
Definition sim_types.h:431
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 YASIMAVR_END_NAMESPACE
Definition sim_globals.h:59
short int_vect_t
Definition sim_types.h:43
YASIMAVR_BEGIN_NAMESPACE typedef long long cycle_count_t
Definition sim_types.h:40
Configuration structure for ArchAVR_WDT.
Definition arch_avr_wdt.h:38
regbit_compound_t rbc_delay
Regbit the delay select.
Definition arch_avr_wdt.h:45
reg_addr_t reg_wdt
WDT configuration register address.
Definition arch_avr_wdt.h:43
unsigned long clock_frequency
Clock frequency used by the watchdog timer.
Definition arch_avr_wdt.h:41
bitspec_t bs_int_flag
Bitspec for the Interrupt Flag bit.
Definition arch_avr_wdt.h:53
bitspec_t bs_int_enable
Bitspec for the Interrupt Enable bit.
Definition arch_avr_wdt.h:51
bitspec_t bs_reset_enable
Bitspec for the Reset Enable bit.
Definition arch_avr_wdt.h:49
bitspec_t bs_chg_enable
Bitspec for the Change Enable bit.
Definition arch_avr_wdt.h:47
regbit_t rb_reset_flag
Regbit for the reset flag.
Definition arch_avr_wdt.h:55
int_vect_t iv_wdt
Interrupt vector index.
Definition arch_avr_wdt.h:57
Definition sim_peripheral.h:237
Definition sim_ioreg.h:39