arch_xt_rtc.h Source File

yasimavr: arch_xt_rtc.h Source File
yasimavr
Loading...
Searching...
No Matches
arch_xt_rtc.h
Go to the documentation of this file.
1/*
2 * arch_xt_rtc.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_XT_RTC_H__
25#define __YASIMAVR_XT_RTC_H__
26
27#include "arch_xt_globals.h"
28#include "core/sim_peripheral.h"
29#include "core/sim_interrupt.h"
31
33
34
35//=======================================================================================
36
66
79
80public:
81
82 explicit ArchXT_RTC(const ArchXT_RTCConfig& config);
83 virtual ~ArchXT_RTC();
84
85 virtual bool init(Device& device) override;
86 virtual void reset(int flags) override;
87 virtual uint8_t ioreg_read_handler(reg_addr_t addr, uint8_t value) override;
88 virtual uint8_t ioreg_peek_handler(reg_addr_t addr, uint8_t value) override;
89 virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t& data) override;
90 virtual void sleep(bool on, SleepMode mode) override;
91
92private:
93
94 const ArchXT_RTCConfig& m_config;
95
96 int m_clk_mode;
97
98 //***** prescaled timer, one for each counter *****
99 TimerCounter m_rtc_counter;
100 TimerCounter m_pit_counter;
101
102 //***** Interrupt flags *****
103 InterruptFlag m_rtc_intflag;
104 InterruptFlag m_pit_intflag;
105
106 //***** Timer signal hook implementation *****
107 class TimerHook;
108 friend class TimerHook;
109 TimerHook* m_timer_hook;
110
111 void rtc_hook_raised(const signal_data_t& sigdata);
112 void pit_hook_raised(const signal_data_t& sigdata);
113
114 void configure_timers();
115
116};
117
118
120
121#endif //__YASIMAVR_XT_RTC_H__
#define AVR_ARCHXT_PUBLIC_API
Definition arch_xt_globals.h:46
Definition arch_xt_rtc.cpp:56
Implementation of a RTC controller for XT core series.
Definition arch_xt_rtc.h:78
Basic AVR device model.
Definition sim_device.h:61
Generic helper to manage a typical Interrupt Flag/Enable in a I/O register.
Definition sim_interrupt.h:324
Abstract class defining a framework for MCU peripherals.
Definition sim_peripheral.h:286
virtual bool init(Device &device)
Definition sim_peripheral.cpp:60
virtual void sleep(bool on, SleepMode mode)
Definition sim_peripheral.cpp:125
virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t &data) override
Definition sim_peripheral.cpp:117
virtual uint8_t ioreg_read_handler(reg_addr_t addr, uint8_t value) override
Definition sim_peripheral.cpp:91
virtual uint8_t ioreg_peek_handler(reg_addr_t addr, uint8_t value) override
Definition sim_peripheral.cpp:106
virtual void reset(int flags)
Definition sim_peripheral.cpp:72
Generic model of a Counter.
Definition sim_timer.h:164
Representation of a I/O register address, with validity state.
Definition sim_types.h:60
#define YASIMAVR_BEGIN_NAMESPACE
Definition sim_globals.h:58
#define YASIMAVR_END_NAMESPACE
Definition sim_globals.h:59
SleepMode
Definition sim_sleep.h:49
short int_vect_t
Definition sim_types.h:43
Configuration structure for each supported source clock.
Definition arch_xt_rtc.h:52
RTC_ClockSource source
Definition arch_xt_rtc.h:53
Configuration structure for ArchXT_RTC.
Definition arch_xt_rtc.h:40
reg_addr_t reg_base
Base address for the peripheral I/O registers.
Definition arch_xt_rtc.h:59
int_vect_t iv_rtc
Interrupt vector index for RTC.
Definition arch_xt_rtc.h:61
RTC_ClockSource
Definition arch_xt_rtc.h:42
@ Clock_1kHz
Definition arch_xt_rtc.h:44
@ Clock_32kHz
Definition arch_xt_rtc.h:43
std::vector< clksel_config_t > clocks
Clock source configurations.
Definition arch_xt_rtc.h:57
int_vect_t iv_pit
Interrupt vector index for PIT.
Definition arch_xt_rtc.h:63
Definition sim_peripheral.h:252
Definition sim_ioreg.h:39
Definition sim_signal.h:39