Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
picsimlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
picsimlab
Commits
e7965fd5
Commit
e7965fd5
authored
Jan 06, 2024
by
lcgamboa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new: Add support to use analog values in gpboard (gpsim backend)
parent
bb6ef5ff
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
22 deletions
+63
-22
VERSION
VERSION
+1
-1
src/boards/bridge_gpsim.cc
src/boards/bridge_gpsim.cc
+19
-2
src/boards/bridge_gpsim.h
src/boards/bridge_gpsim.h
+2
-0
src/boards/bsim_gpsim.cc
src/boards/bsim_gpsim.cc
+34
-17
tests/in_out/in_out_pic18gp.pzw
tests/in_out/in_out_pic18gp.pzw
+0
-0
tests/spi/esp32c3_bmp280_spi.pzw
tests/spi/esp32c3_bmp280_spi.pzw
+0
-0
tests/test_in_out.cc
tests/test_in_out.cc
+7
-2
No files found.
VERSION
View file @
e7965fd5
...
@@ -2,5 +2,5 @@ PACKAGE=picsimlab
...
@@ -2,5 +2,5 @@ PACKAGE=picsimlab
MAINVER=0
MAINVER=0
MINORVER=9
MINORVER=9
VERSION=0.9.1
VERSION=0.9.1
DATE=2
31224
DATE=2
40106
VERSION_STABLE=0.9.1
VERSION_STABLE=0.9.1
src/boards/bridge_gpsim.cc
View file @
e7965fd5
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
void
simulation_cleanup
(
void
);
void
simulation_cleanup
(
void
);
static
pic_processor
*
gpic
;
static
pic_processor
*
gpic
=
NULL
;
int
bridge_gpsim_init
(
const
char
*
processor
,
const
char
*
fileName
,
float
freq
)
{
int
bridge_gpsim_init
(
const
char
*
processor
,
const
char
*
fileName
,
float
freq
)
{
// initialize_gpsim_core ();
// initialize_gpsim_core ();
...
@@ -24,11 +24,17 @@ int bridge_gpsim_init(const char* processor, const char* fileName, float freq) {
...
@@ -24,11 +24,17 @@ int bridge_gpsim_init(const char* processor, const char* fileName, float freq) {
CSimulationContext
::
GetContext
()
->
LoadProgram
(
fileName
,
processor
,
&
tempProc
,
NULL
);
CSimulationContext
::
GetContext
()
->
LoadProgram
(
fileName
,
processor
,
&
tempProc
,
NULL
);
gpic
=
dynamic_cast
<
pic_processor
*>
(
tempProc
);
gpic
=
dynamic_cast
<
pic_processor
*>
(
tempProc
);
gpic
->
set_frequency
(
freq
);
bridge_gpsim_
set_frequency
(
freq
);
return
(
gpic
!=
NULL
)
-
1
;
return
(
gpic
!=
NULL
)
-
1
;
}
}
void
bridge_gpsim_set_frequency
(
double
freq
)
{
if
(
gpic
)
{
gpic
->
set_frequency
(
freq
);
}
}
void
bridge_gpsim_reset
(
void
)
{
void
bridge_gpsim_reset
(
void
)
{
if
(
gpic
->
is_sleeping
())
if
(
gpic
->
is_sleeping
())
gpic
->
exit_sleep
();
gpic
->
exit_sleep
();
...
@@ -89,8 +95,19 @@ void bridge_gpsim_set_pin_value(int pin, unsigned char value) {
...
@@ -89,8 +95,19 @@ void bridge_gpsim_set_pin_value(int pin, unsigned char value) {
}
}
}
}
void
bridge_gpsim_set_apin_value
(
int
pin
,
float
value
)
{
IOPIN
*
iopin
=
gpic
->
get_pin
(
pin
);
iopin
->
set_is_analog
(
true
);
iopin
->
set_Cth
(
5e-12
);
iopin
->
set_nodeVoltage
(
value
);
}
void
bridge_gpsim_step
(
void
)
{
void
bridge_gpsim_step
(
void
)
{
gpic
->
step_cycle
();
gpic
->
step_cycle
();
if
(
gpic
->
mCurrentPhase
==
((
ClockPhase
*
)
gpic
->
mExecute2ndHalf
))
{
gpic
->
step_cycle
();
}
}
}
void
bridge_gpsim_end
(
void
)
{
void
bridge_gpsim_end
(
void
)
{
...
...
src/boards/bridge_gpsim.h
View file @
e7965fd5
...
@@ -25,6 +25,8 @@ const char* bridge_gpsim_get_pin_name(int pin);
...
@@ -25,6 +25,8 @@ const char* bridge_gpsim_get_pin_name(int pin);
unsigned
char
bridge_gpsim_get_pin_value
(
int
pin
);
unsigned
char
bridge_gpsim_get_pin_value
(
int
pin
);
unsigned
char
bridge_gpsim_get_pin_dir
(
int
pin
);
unsigned
char
bridge_gpsim_get_pin_dir
(
int
pin
);
void
bridge_gpsim_set_pin_value
(
int
pin
,
unsigned
char
value
);
void
bridge_gpsim_set_pin_value
(
int
pin
,
unsigned
char
value
);
void
bridge_gpsim_set_apin_value
(
int
pin
,
float
value
);
void
bridge_gpsim_set_frequency
(
double
freq
);
void
bridge_gpsim_step
(
void
);
void
bridge_gpsim_step
(
void
);
void
bridge_gpsim_end
(
void
);
void
bridge_gpsim_end
(
void
);
int
bridge_gpsim_dump_memory
(
const
char
*
fname
);
int
bridge_gpsim_dump_memory
(
const
char
*
fname
);
...
...
src/boards/bsim_gpsim.cc
View file @
e7965fd5
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "../lib/picsimlab.h"
#include "../lib/picsimlab.h"
#include "bsim_gpsim.h"
#include "bsim_gpsim.h"
static
const
unsigned
char
GPSIM_PORTS
[
5
]
=
{
0
,
1
,
2
,
3
,
0xFF
};
static
const
unsigned
char
GPSIM_PORTS
[
7
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
0xFF
};
bsim_gpsim
::
bsim_gpsim
(
void
)
{
bsim_gpsim
::
bsim_gpsim
(
void
)
{
char
list
[
2000
];
char
list
[
2000
];
...
@@ -61,13 +61,14 @@ void bsim_gpsim::MSetSerial(const char* port) {
...
@@ -61,13 +61,14 @@ void bsim_gpsim::MSetSerial(const char* port) {
}
}
}
}
ret
=
bridge_gpsim_init
(
processor
,
fname
,
freq
);
ret
=
bridge_gpsim_init
(
processor
,
fname
,
freq
);
pins_reset
();
}
}
return
ret
;
return
ret
;
}
}
void
bsim_gpsim
::
MEnd
(
void
)
{
void
bsim_gpsim
::
MEnd
(
void
)
{
bridge_gpsim_end
();
// bridge_gpsim_end(); //Not needed when SetNeedReboot is used
}
}
int
bsim_gpsim
::
MGetArchitecture
(
void
)
{
int
bsim_gpsim
::
MGetArchitecture
(
void
)
{
...
@@ -80,6 +81,7 @@ void bsim_gpsim::MSetSerial(const char* port) {
...
@@ -80,6 +81,7 @@ void bsim_gpsim::MSetSerial(const char* port) {
void
bsim_gpsim
::
MSetFreq
(
float
freq_
)
{
void
bsim_gpsim
::
MSetFreq
(
float
freq_
)
{
freq
=
freq_
;
freq
=
freq_
;
bridge_gpsim_set_frequency
(
freq
);
TimerUpdateFrequency
(
freq
);
TimerUpdateFrequency
(
freq
);
}
}
...
@@ -115,6 +117,9 @@ void bsim_gpsim::MSetSerial(const char* port) {
...
@@ -115,6 +117,9 @@ void bsim_gpsim::MSetSerial(const char* port) {
pinname
=
"R"
+
pinname
.
substr
(
4
,
2
);
pinname
=
"R"
+
pinname
.
substr
(
4
,
2
);
pinname
=
uppercase
(
pinname
);
pinname
=
uppercase
(
pinname
);
}
}
if
(
pinname
.
length
()
==
0
)
{
pinname
=
"nd"
;
}
}
}
return
pinname
;
return
pinname
;
}
}
...
@@ -125,7 +130,7 @@ void bsim_gpsim::MSetSerial(const char* port) {
...
@@ -125,7 +130,7 @@ void bsim_gpsim::MSetSerial(const char* port) {
int
bsim_gpsim
::
DebugInit
(
int
dtyppe
)
// argument not used in picm only mplabx
int
bsim_gpsim
::
DebugInit
(
int
dtyppe
)
// argument not used in picm only mplabx
{
{
return
0
;
//! mplabxd_init (this, Window1.Get_debug_port ()) - 1;
return
0
;
//! mplabxd_init (this, Window1.Get_debug_port ()) - 1;
}
}
int
bsim_gpsim
::
MGetPinCount
(
void
)
{
int
bsim_gpsim
::
MGetPinCount
(
void
)
{
...
@@ -135,27 +140,35 @@ void bsim_gpsim::MSetSerial(const char* port) {
...
@@ -135,27 +140,35 @@ void bsim_gpsim::MSetSerial(const char* port) {
void
bsim_gpsim
::
pins_reset
(
void
)
{
void
bsim_gpsim
::
pins_reset
(
void
)
{
for
(
int
p
=
0
;
p
<
MGetPinCount
();
p
++
)
{
for
(
int
p
=
0
;
p
<
MGetPinCount
();
p
++
)
{
lxString
pname
=
MGetPinName
(
p
+
1
);
lxString
pname
=
MGetPinName
(
p
+
1
);
if
(
pname
[
0
]
==
'p'
)
{
if
(
pname
[
0
]
==
'R'
)
{
pins
[
p
].
port
=
(
unsigned
char
*
)
&
GPSIM_PORTS
[
pname
[
4
]
-
'a'
];
pins
[
p
].
port
=
(
unsigned
char
*
)
&
GPSIM_PORTS
[
pname
[
1
]
-
'A'
];
pins
[
p
].
pord
=
pname
[
5
]
-
'0'
;
pins
[
p
].
pord
=
pname
[
2
]
-
'0'
;
pins
[
p
].
ptype
=
PT_DIGITAL
;
pins
[
p
].
dir
=
PD_IN
;
pins
[
p
].
value
=
0
;
}
else
if
(
pname
[
0
]
==
'M'
)
{
// MCLR
pins
[
p
].
port
=
(
unsigned
char
*
)
&
GPSIM_PORTS
[
6
];
pins
[
p
].
pord
=
-
1
;
pins
[
p
].
ptype
=
PT_DIGITAL
;
pins
[
p
].
dir
=
PD_IN
;
pins
[
p
].
value
=
1
;
}
else
{
}
else
{
pins
[
p
].
port
=
(
unsigned
char
*
)
&
GPSIM_PORTS
[
4
];
pins
[
p
].
port
=
(
unsigned
char
*
)
&
GPSIM_PORTS
[
6
];
pins
[
p
].
pord
=
-
1
;
pins
[
p
].
pord
=
-
1
;
pins
[
p
].
ptype
=
PT_POWER
;
pins
[
p
].
dir
=
PD_OUT
;
pins
[
p
].
value
=
0
;
}
}
pins
[
p
].
avalue
=
0
;
pins
[
p
].
avalue
=
0
;
pins
[
p
].
lvalue
=
0
;
pins
[
p
].
lvalue
=
0
;
pins
[
p
].
value
=
0
;
pins
[
p
].
ptype
=
PT_DIGITAL
;
pins
[
p
].
dir
=
PD_IN
;
pins
[
p
].
ovalue
=
0
;
pins
[
p
].
ovalue
=
0
;
pins
[
p
].
oavalue
=
55
;
pins
[
p
].
oavalue
=
55
;
}
}
/*TODO add VCC and GND pins
// TODO add VCC and GND pins
pins[7 - 1].value = 0;
// pins[7 - 1].value = 0;
pins[7 - 1].dir = PD_OUT;
// pins[7 - 1].dir = PD_OUT;
pins[9 - 1].value = 1;
// pins[9 - 1].value = 1;
pins[9 - 1].dir = PD_OUT;
// pins[9 - 1].dir = PD_OUT;
*/
}
}
void
bsim_gpsim
::
MSetPin
(
int
pin
,
unsigned
char
value
)
{
void
bsim_gpsim
::
MSetPin
(
int
pin
,
unsigned
char
value
)
{
...
@@ -167,7 +180,11 @@ void bsim_gpsim::MSetSerial(const char* port) {
...
@@ -167,7 +180,11 @@ void bsim_gpsim::MSetSerial(const char* port) {
}
}
void
bsim_gpsim
::
MSetAPin
(
int
pin
,
float
value
)
{
void
bsim_gpsim
::
MSetAPin
(
int
pin
,
float
value
)
{
// set_apin (pin, value);
if
(
pins
[
pin
-
1
].
dir
==
PD_IN
)
{
pins
[
pin
-
1
].
ptype
=
PT_ANALOG
;
pins
[
pin
-
1
].
avalue
=
value
;
bridge_gpsim_set_apin_value
(
pin
,
value
);
}
}
}
unsigned
char
bsim_gpsim
::
MGetPin
(
int
pin
)
{
unsigned
char
bsim_gpsim
::
MGetPin
(
int
pin
)
{
...
...
tests/in_out/in_out_pic18gp.pzw
0 → 100644
View file @
e7965fd5
File added
tests/spi/esp32c3_bmp280_spi.pzw
0 → 100644
View file @
e7965fd5
File added
tests/test_in_out.cc
View file @
e7965fd5
...
@@ -154,7 +154,7 @@ static int test_IN_OUT_ESP32(void* arg) {
...
@@ -154,7 +154,7 @@ static int test_IN_OUT_ESP32(void* arg) {
register_test
(
"IN/OUT ESP32"
,
test_IN_OUT_ESP32
,
NULL
);
register_test
(
"IN/OUT ESP32"
,
test_IN_OUT_ESP32
,
NULL
);
static
int
test_IN_OUT_ESP32C3
(
void
*
arg
)
{
static
int
test_IN_OUT_ESP32C3
(
void
*
arg
)
{
return
in_out_test
(
"SPI ESP32C3"
,
"in_out/in_out_esp32c3.pzw"
,
1
,
20
00000L
);
return
in_out_test
(
"SPI ESP32C3"
,
"in_out/in_out_esp32c3.pzw"
,
1
,
35
00000L
);
}
}
register_test
(
"IN/OUT ESP32C3"
,
test_IN_OUT_ESP32C3
,
NULL
);
register_test
(
"IN/OUT ESP32C3"
,
test_IN_OUT_ESP32C3
,
NULL
);
...
@@ -169,6 +169,11 @@ static int test_IN_OUT_STM32(void* arg) {
...
@@ -169,6 +169,11 @@ static int test_IN_OUT_STM32(void* arg) {
register_test
(
"IN/OUT STM32"
,
test_IN_OUT_STM32
,
NULL
);
register_test
(
"IN/OUT STM32"
,
test_IN_OUT_STM32
,
NULL
);
static
int
test_IN_OUT_PIC18F
(
void
*
arg
)
{
static
int
test_IN_OUT_PIC18F
(
void
*
arg
)
{
return
in_out_test
(
"SPI PIC18F"
,
"in_out/in_out_pic18.pzw"
);
return
in_out_test
(
"SPI PIC18F"
,
"in_out/in_out_pic18.pzw"
,
2
);
}
}
register_test
(
"IN/OUT PIC18F"
,
test_IN_OUT_PIC18F
,
NULL
);
register_test
(
"IN/OUT PIC18F"
,
test_IN_OUT_PIC18F
,
NULL
);
static
int
test_IN_OUT_PIC18FGP
(
void
*
arg
)
{
return
in_out_test
(
"SPI PIC18FGP"
,
"in_out/in_out_pic18gp.pzw"
,
2
);
}
register_test
(
"IN/OUT PIC18F GP"
,
test_IN_OUT_PIC18FGP
,
NULL
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment