PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
board_PQDB.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2010-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#ifndef BOARD_PQDB_H
27#define BOARD_PQDB_H
28
29#include "bsim_picsim.h"
30
31#include "../devices/io_74xx595.h"
32#include "../devices/lcd_hd44780.h"
33#include "../devices/rtc_ds1307.h"
34
35#define BOARD_PQDB_Name "PQDB"
36
37// Pin definitions
38// Arduino style
39/*
40#define SDA_PIN 18
41#define SCL_PIN 19
42#define KEYPAD_1_PIN 13
43#define KEYPAD_2_PIN 12
44#define SO_CLK_PIN 11
45#define SO_EN_PIN 10
46#define PWM_PIN 9
47#define SO_DATA_PIN 8
48#define LCD_RS_PIN 7
49#define LCD_EN_PIN 6
50#define DISP_4_PIN 5
51#define LED_BLUE_PIN 4
52#define DISP_3_PIN 4
53#define LED_GREEN_PIN 3
54#define DISP_2_PIN 3
55#define LED_RED_PIN 2
56#define DISP_1_PIN 2
57#define TX_PIN 1
58#define RX_PIN 0
59 */
60
61// PIC18f4550 style
62// zero index, pin 1 ->0; pin 18 -> 17
63
64#define RA0 1
65#define RA1 2
66#define RA2 3
67
68#define RB0 32
69#define RB1 33
70#define RB2 34
71#define RB3 35
72#define RB4 36
73#define RB5 37
74#define RB6 38
75#define RB7 39
76
77#define RC1 15
78
79#define RD0 18
80#define RD1 19
81#define RD2 20
82#define RD3 21
83#define RD4 26
84#define RD5 27
85#define RD6 28
86#define RD7 29
87
88#define PSRD0 40
89#define PSRD1 41
90#define PSRD2 42
91#define PSRD3 43
92#define PSRD4 44
93#define PSRD5 45
94#define PSRD6 46
95#define PSRD7 47
96
97#define SRD0 0x01
98#define SRD1 0x02
99#define SRD2 0x04
100#define SRD3 0x08
101#define SRD4 0x10
102#define SRD5 0x20
103#define SRD6 0x40
104#define SRD7 0x80
105
106#define SDA_PIN RB4
107#define SCL_PIN RB3
108#define KEYPAD_1_PIN RB2
109#define KEYPAD_2_PIN RB1
110#define SO_CLK_PIN RB0
111#define SO_EN_PIN RD7
112#define PWM_PIN RC1
113#define SO_DATA_PIN RD6
114#define LCD_RS_PIN RD5
115#define LCD_EN_PIN RD4
116#define DISP_4_PIN RD3
117#define DISP_3_PIN RD2
118#define DISP_2_PIN RD1
119#define DISP_1_PIN RD0
120#define TX_PIN 1
121#define RX_PIN 0
122
123#define LED_BLUE_PIN DISP_3_PIN
124#define LED_GREEN_PIN DISP_2_PIN
125#define LED_RED_PIN DISP_1_PIN
126
127#define AN2_PIN RA2
128#define AN1_PIN RA1
129#define AN0_PIN RA0
130
131#define LM_PIN AN2_PIN
132#define LDR_PIN AN1_PIN
133#define POT_PIN AN0_PIN
134
135class cboard_PQDB : public bsim_picsim {
136private:
137 unsigned char p_KEY[10];
138
139 unsigned char pot;
140 unsigned char active;
141
142 int vtc;
143 int vt;
144
145 // external peripherals
146 lcd_t lcd;
147 unsigned char d;
148
149 rtc_ds1307_t rtc2;
150 unsigned char sda, sck;
151
152 io_74xx595_t shiftReg;
153 unsigned char srDATA, srCLK, srLAT;
154 unsigned long shiftReg_alm[8];
155 unsigned short _srret;
156
157 int lcde;
158
159 int sound_on;
160
161 float vPOT;
162 float vLDR;
163 float vLM;
164
165 float vp2[2];
166 float temp[2];
167 float ref;
168
169 int rpmstp;
170 int rpmc;
171
172 int lm7seg[32]; // luminosidade media display
173
174 int buzzerId;
175
176 void RegisterRemoteControl(void) override;
177
178 unsigned char scroll1_old;
179 unsigned char scroll2_old;
180
181public:
182 // Return the board name
183 std::string GetName(void) override { return BOARD_PQDB_Name; };
184 std::string GetAboutInfo(void) override { return "R.M.A. Almeida \n <rodrigomax@unifei.edu.br>"; };
185 cboard_PQDB(void);
186 ~cboard_PQDB(void);
187 void Draw(void) override;
188 void Run_CPU(void) override;
189
190 std::string GetSupportedDevices(void) override { return "PIC18F4520,PIC18F4550,PIC18F4620,"; };
191
192 void Reset(void) override;
193 void EvMouseMove(unsigned int button, unsigned int x, unsigned int y, unsigned int state) override;
194 void EvMouseButtonPress(unsigned int button, unsigned int x, unsigned int y, unsigned int state) override;
195 void EvMouseButtonRelease(unsigned int button, unsigned int x, unsigned int y, unsigned int state) override;
196 void EvKeyPress(unsigned int key, unsigned int mask) override;
197 void EvKeyRelease(unsigned int key, unsigned int mask) override;
198 void EvOnShow(void) override;
199 void RefreshStatus(void) override;
200 void WritePreferences(void) override;
201 void ReadPreferences(char* name, char* value) override;
202 unsigned short GetInputId(char* name) override;
203 unsigned short GetOutputId(char* name) override;
204 std::string MGetPinName(int pin) override;
205 int MGetPinCount(void) override;
206};
207
208#endif /* BOARD_4_H */
Definition bsim_picsim.h:34
Definition board_PQDB.h:135
void ReadPreferences(char *name, char *value) override
Called whe configuration file load preferences.
Definition board_PQDB.cc:1795
void WritePreferences(void) override
Called to save board preferences in configuration file.
Definition board_PQDB.cc:1763
std::string MGetPinName(int pin) override
board microcontroller pin name
Definition board_PQDB.cc:1846
std::string GetSupportedDevices(void) override
Return a list of supported microcontrollers.
Definition board_PQDB.h:190
void EvMouseButtonRelease(unsigned int button, unsigned int x, unsigned int y, unsigned int state) override
Event on the board.
Definition board_PQDB.cc:1064
unsigned short GetInputId(char *name) override
return the input ids numbers of names used in input map
Definition board_PQDB.cc:1226
void RefreshStatus(void) override
Called ever 1s to refresh status.
Definition board_PQDB.cc:1751
void EvKeyRelease(unsigned int key, unsigned int mask) override
Event on the board.
Definition board_PQDB.cc:1178
void EvMouseMove(unsigned int button, unsigned int x, unsigned int y, unsigned int state) override
Event on the board.
Definition board_PQDB.cc:964
void RegisterRemoteControl(void) override
Register remote control variables.
Definition board_PQDB.cc:905
unsigned short GetOutputId(char *name) override
return the output ids numbers of names used in output map
Definition board_PQDB.cc:1321
void EvOnShow(void) override
Event on the board.
Definition board_PQDB.cc:1221
void Run_CPU(void) override
Paralle thread called ever 100ms to run cpu code.
Definition board_PQDB.cc:526
int MGetPinCount(void) override
board microcontroller pin count
Definition board_PQDB.cc:1914
void EvMouseButtonPress(unsigned int button, unsigned int x, unsigned int y, unsigned int state) override
Event on the board.
Definition board_PQDB.cc:983
void Draw(void) override
Called ever 100ms to draw board.
Definition board_PQDB.cc:208
void Reset(void) override
Reset board status.
Definition board_PQDB.cc:863
std::string GetName(void) override
Get board name registered in PICSimLab.
Definition board_PQDB.h:183
void EvKeyPress(unsigned int key, unsigned int mask) override
Event on the board.
Definition board_PQDB.cc:1135
std::string GetAboutInfo(void) override
Return the about information of part.
Definition board_PQDB.h:184
Definition io_74xx595.h:49
Definition lcd_hd44780.h:67
Definition rtc_ds1307.h:29