arch_avr_acp.h Source File

yasimavr: arch_avr_acp.h Source File
yasimavr
Loading...
Searching...
No Matches
arch_avr_acp.h
Go to the documentation of this file.
1/*
2 * arch_avr_acp.h
3 *
4 * Copyright 2022-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_ACOMP_H__
25#define __YASIMAVR_AVR_ACOMP_H__
26
27#include "arch_avr_globals.h"
28#include "core/sim_pin.h"
29#include "core/sim_interrupt.h"
30
32
33
34//=======================================================================================
35
72
73
86
87public:
88
89 ArchAVR_ACP(int num, const ArchAVR_ACPConfig& config);
90
91 virtual bool init(Device& device) override;
92 virtual void reset(int flags) override;
93 virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t* data) override;
94 virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t& data) override;
95
96private:
97
98 const ArchAVR_ACPConfig& m_config;
99 InterruptFlag m_intflag;
100 DataSignalMux m_pos_mux;
101 DataSignalMux m_neg_mux;
103 Signal m_out_signal;
104 double m_pos_value;
105 double m_neg_value;
106
107 void change_pos_channel();
108 void change_neg_channel();
109 void input_raised(const signal_data_t& sigdata, int hooktag);
110 void update_state();
111
112};
113
114
116
117#endif //__YASIMAVR_AVR_ACOMP_H__
#define AVR_ARCHAVR_PUBLIC_API
Definition arch_avr_globals.h:46
Implementation of an Analog Comparator for AVR series.
Definition arch_avr_acp.h:85
Definition sim_signal.h:227
Definition sim_signal.h:169
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 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
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_acp.h:41
pin_id_t pin
Definition arch_avr_acp.h:42
Configuration structure for ArchAVR_ACP.
Definition arch_avr_acp.h:39
regbit_t rb_int_enable
Regbit for the interrupt enable bit (ACIE)
Definition arch_avr_acp.h:66
regbit_t rb_output
Regbit for the output bit (ACO)
Definition arch_avr_acp.h:64
int_vect_t iv_cmp
Vector index for the interrupt.
Definition arch_avr_acp.h:70
regbit_t rb_mux
Regbit for the mux select field (ADMUX)
Definition arch_avr_acp.h:58
regbit_t rb_mux_enable
Regbit for the mux enable bit (ACME)
Definition arch_avr_acp.h:54
regbit_t rb_int_mode
Regbit for the interrupt mode select field (ACIS)
Definition arch_avr_acp.h:62
std::vector< mux_config_t > mux_pins
List of the mux options for the negative input.
Definition arch_avr_acp.h:46
regbit_t rb_int_flag
Regbit for the interrupt flag (ACI)
Definition arch_avr_acp.h:68
pin_id_t neg_pin
Negative input pin ID.
Definition arch_avr_acp.h:50
pin_id_t pos_pin
Positive input pin ID.
Definition arch_avr_acp.h:48
regbit_t rb_disable
Regbit for the disable bit (ACD)
Definition arch_avr_acp.h:52
regbit_t rb_bandgap_select
Regbit for the bandgap select bit (ACBG)
Definition arch_avr_acp.h:60
regbit_t rb_adc_enable
Regbit for the ADC enable bit (ADEN)
Definition arch_avr_acp.h:56
Definition sim_peripheral.h:252
Definition sim_peripheral.h:237
Definition sim_ioreg.h:39
Definition sim_signal.h:39