File indexing completed on 2024-05-05 05:46:30
0001 /*************************************************************************** 0002 * Copyright (C) 2003-2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef PICPACKAGES_H 0012 #define PICPACKAGES_H 0013 0014 #include <QString> 0015 #include <QStringList> 0016 0017 #include <QMap> 0018 0019 /** 0020 @author David Saxton 0021 */ 0022 class PicPin 0023 { 0024 public: 0025 enum pin_type { 0026 type_input = 0x1, // Input only pin 0027 type_bidir = 0x2, // Bi-directional (input/output) 0028 type_open = 0x4, // Open collector 0029 type_vss = 0x8, // Voltage source 0030 type_vdd = 0x10, // Voltage drain 0031 type_mclr = 0x20, // Memory clear 0032 type_osc = 0x40 // Oscillator 0033 }; 0034 0035 PicPin(); 0036 PicPin(const QString &_pinID, PicPin::pin_type _type, const QString &_portName = "", int _portPosition = -1); 0037 0038 PicPin::pin_type type; 0039 0040 QString pinID; // Id of pin, eg 'MCLR' 0041 0042 // For bidir (io) pins 0043 QString portName; // Name of port, eg 'PORTA' 0044 int portPosition; // Position in port 0045 }; 0046 0047 typedef QMap<int, PicPin> PicPinMap; 0048 0049 /** 0050 @short Describes the PIC package (i.e. pins) 0051 @author David Saxton 0052 */ 0053 class MicroPackage 0054 { 0055 public: 0056 MicroPackage(const int pinCount); 0057 virtual ~MicroPackage(); 0058 0059 /** 0060 * Assigns a pin to a position in the package. 0061 */ 0062 void assignPin(int pinPosition, PicPin::pin_type type, const QString &pinID, const QString &portName = "", int portPosition = -1); 0063 void assignPin(int pinPosition, PicPin::pin_type type, const char *pinID, const char *portName = "", int portPosition = -1) 0064 { 0065 assignPin(pinPosition, type, QString::fromLatin1(pinID), QString::fromLatin1(portName), portPosition); 0066 } 0067 0068 /** 0069 * Returns the pins of the given type(s). If portName is not specified, all pins will be returned; 0070 * not just those belonging to a given port. pin_type's can be OR'ed together 0071 * e.g. pins( PicPin::type_input | PicPin::type_bidir, "PORTA" ) will return all bidirectional or 0072 * input pins belonging to PORTA. If pinType is 0, then this will return all pins 0073 */ 0074 PicPinMap pins(uint pinType = 0, const QString &portName = ""); 0075 /** 0076 * Returns just a QStringList of the pin ids. 0077 * @see pins( uint pinType, const QString& portName ) 0078 */ 0079 QStringList pinIDs(uint pinType = 0, const QString &portName = ""); 0080 /** 0081 * Returns the number of pins of the given type(s) (which can be OR'ed together), with the given 0082 * port name if specified, while avoiding the construction of a new PicPinMap. if pinType is 0, 0083 * then all pin types are considered 0084 * @see pins 0085 */ 0086 int pinCount(uint pinType = 0, const QString &portName = ""); 0087 /** 0088 * Returns a list of port names, eg 'PORTA', 'PORTB' for the package 0089 */ 0090 QStringList portNames() const 0091 { 0092 return m_portNames; 0093 } 0094 /** 0095 * Returns the number of ports 0096 */ 0097 uint portCount() const 0098 { 0099 return m_portNames.size(); 0100 } 0101 0102 private: 0103 PicPinMap m_picPinMap; 0104 QStringList m_portNames; 0105 int m_numPins; 0106 }; 0107 0108 #endif