1
/***************************************************************************
2
* Copyright (C) 2012 by santiago González *
3
* santigoro@gmail.com *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 3 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, see <http://www.gnu.org/licenses/>. *
18
***************************************************************************/
23
#include "piccomponentpin.h"
24
#include "piccomponent.h"
25
#include "simulator.h"
26
#include "pic-processor.h"
28
PICComponentPin::PICComponentPin( McuComponent* mcu, QString id, QString type, QString label, int pos, int xpos, int ypos, int angle )
29
: McuComponentPin( mcu, id, type, label, pos, xpos, ypos, angle )
34
PICComponentPin::~PICComponentPin(){}
36
void PICComponentPin::attachPin( pic_processor* PicProcessor )
38
if( m_PicProcessor ) return;
40
m_PicProcessor = PicProcessor;
42
IOPIN* iopin = m_PicProcessor->get_pin( m_pos );
44
if( m_id.startsWith("R") || m_id.startsWith("GP") )
48
m_port = m_id.at(1).toLatin1();
49
m_pinN = m_id.mid(2,1).toInt();
53
qDebug() << "PICComponentPin::attach : iopin is NULL: "<< m_id << endl;
58
qDebug() << "PICComponentPin::attach :Already have an iopin" << endl;
62
m_pIOPIN->setPicPin( this );
64
if( m_pIOPIN->getType() == OPEN_COLLECTOR )
67
//eSource::setVoltHigh( 0 );
70
else if( m_id.startsWith("MCLR") )
77
void PICComponentPin::voltChanged()
79
if( !m_isInput ) return; // Nothing to do if pin is output
81
double volt = m_ePin[0]->getVolt();
82
//qDebug() << "PICComponentPin::setVChanged "<< m_id <<volt;
84
if( m_pinType == 1 ) // Is an IO Pin
86
m_pIOPIN->set_nodeVoltage(volt);
88
else if( m_pinType == 21 ) // reset
90
if( volt < 3 ) m_processor->hardReset( true );
91
else m_processor->hardReset( false );
95
void PICComponentPin::pullupNotConnected( bool up )
97
m_pIOPIN->set_nodeVoltage( up? 5:0);
101
#include "moc_piccomponentpin.cpp"