arch_avr_extint.h Source File

yasimavr: arch_avr_extint.h Source File
yasimavr
Loading...
Searching...
No Matches
arch_avr_extint.h
Go to the documentation of this file.
1/*
2 * arch_avr_extint.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_EXTINT_H__
25#define __YASIMAVR_AVR_EXTINT_H__
26
27#include "arch_avr_globals.h"
28#include "core/sim_peripheral.h"
29#include "core/sim_interrupt.h"
30#include "core/sim_pin.h"
31#include "core/sim_types.h"
32
34
35
36//=======================================================================================
37
38#define EXTINT_PIN_COUNT 2
39#define PCINT_PIN_COUNT 24
40#define PCINT_BANK_COUNT (PCINT_PIN_COUNT / 8)
41
42
43//=======================================================================================
76
81 public InterruptHandler {
82
83public:
84
85 enum SignalId {
87 Signal_PinChange
88 };
89
90 explicit ArchAVR_ExtInt(const ArchAVR_ExtIntConfig& config);
91
92 virtual bool init(Device& device) override;
93 virtual void reset(int flags) override;
94 virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t* data) override;
95 virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t& data) override;
96 virtual bool interrupt_ack_handler(int_vect_t vector) override;
97
98private:
99
100 const ArchAVR_ExtIntConfig& m_config;
101 //Signals that get raised when an external interrupt condition is detected
102 Signal m_signal;
103 //Backup copies of pin states to detect edges
104 uint8_t m_extint_pin_value;
105 std::vector<uint8_t> m_pcint_pin_value;
107
108 void pin_signal_raised(const signal_data_t& sigdata, int hooktag);
109
110 uint8_t get_extint_mode(uint8_t pin) const;
111
112};
113
114
116
117#endif //__YASIMAVR_AVR_EXTINT_H__
#define AVR_ARCHAVR_PUBLIC_API
Definition arch_avr_globals.h:46
Implementation of a model for a External Interrupts peripheral for AVR series.
Definition arch_avr_extint.h:81
SignalId
Definition arch_avr_extint.h:85
@ Signal_ExtInt
Definition arch_avr_extint.h:86
Definition sim_signal.h:227
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
Signalling framework class.
Definition sim_signal.h:97
Representation of a I/O register address, with validity state.
Definition sim_types.h:60
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
#define AVR_INTERRUPT_NONE
Definition sim_interrupt.h:59
YASIMAVR_BEGIN_NAMESPACE typedef sim_id_t pin_id_t
Definition sim_pin.h:34
short int_vect_t
Definition sim_types.h:43
Definition arch_avr_extint.h:49
pin_id_t pin
Definition arch_avr_extint.h:51
int_vect_t vector
Definition arch_avr_extint.h:50
Definition arch_avr_extint.h:54
int_vect_t vector
Definition arch_avr_extint.h:55
reg_addr_t reg_mask
Definition arch_avr_extint.h:56
pin_id_t pins[8]
Definition arch_avr_extint.h:57
Configuration structure for ArchAVR_ExtInt.
Definition arch_avr_extint.h:47
regbit_t rb_extint_flag
Regbit for the external interrupt flags.
Definition arch_avr_extint.h:69
regbit_t rb_pcint_ctrl
Regbit for Pin Change interrupt control.
Definition arch_avr_extint.h:71
regbit_t rb_pcint_flag
Regbit for Pin Change interrupt flags.
Definition arch_avr_extint.h:73
std::vector< pc_int_t > pc_ints
Array of pins for Pin Change interrupts.
Definition arch_avr_extint.h:63
regbit_t rb_extint_mask
Regbit for the external interrupt mask.
Definition arch_avr_extint.h:67
std::vector< ext_int_t > ext_ints
Array of pins for external interrupts.
Definition arch_avr_extint.h:61
regbit_t rb_extint_ctrl
Regbit for external interrupt control.
Definition arch_avr_extint.h:65
Definition sim_peripheral.h:237
Definition sim_ioreg.h:39
Definition sim_signal.h:39