Commit 91b58540 authored by lcgamboa's avatar lcgamboa

new: Initial support to STM32 Blue Pill board

parent 762f23b3
...@@ -16,5 +16,6 @@ OBJS = ppicsimlab.o picsimlab1.o picsimlab2.o picsimlab3.o picsimlab4.o picsimla ...@@ -16,5 +16,6 @@ OBJS = ppicsimlab.o picsimlab1.o picsimlab2.o picsimlab3.o picsimlab4.o picsimla
parts/part_LED_matrix.o parts/part_7s_Display.o parts/part_TempSys.o parts/part_keypad.o \ parts/part_LED_matrix.o parts/part_7s_Display.o parts/part_TempSys.o parts/part_keypad.o \
parts/part_MI2C_24CXXX.o parts/part_RTC_ds1307.o parts/part_RTC_pfc8563.o parts/part_IO_74xx595.o \ parts/part_MI2C_24CXXX.o parts/part_RTC_ds1307.o parts/part_RTC_pfc8563.o parts/part_IO_74xx595.o \
parts/part_VCD_Dump.o parts/part_IO_PCF8574.o parts/part_Buzzer.o parts/part_SignalGenerator.o \ parts/part_VCD_Dump.o parts/part_IO_PCF8574.o parts/part_Buzzer.o parts/part_SignalGenerator.o \
parts/part_push_buttons_an.o parts/part_VCD_Dump_an.o parts/part_IO_MCP23S17.o parts/part_push_buttons_an.o parts/part_VCD_Dump_an.o parts/part_IO_MCP23S17.o\
boards/board_Blue_Pill.o boards/board_stm32.o
/* ########################################################################
PICsimLab - PIC laboratory simulator
########################################################################
Copyright (c) : 2015-2020 Luis Claudio Gambôa Lopes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
For e-mail suggestions : lcgamboa@yahoo.com
######################################################################## */
//include files
#include"../picsimlab1.h"
#include"../picsimlab4.h" //Oscilloscope
#include"../picsimlab5.h" //Spare Parts
#include"board_Blue_Pill.h"
/* ids of inputs of input map*/
enum
{
I_ICSP, //ICSP connector
I_PWR, //Power button
I_RST, //Reset button
};
/* ids of outputs of output map*/
enum
{
O_LPWR, //Power LED
O_LED, //LED on PC13 output
};
//return the input ids numbers of names used in input map
unsigned short
cboard_Blue_Pill::get_in_id(char * name)
{
if (strcmp (name, "I_ICSP") == 0)return I_ICSP;
if (strcmp (name, "I_PWR") == 0)return I_PWR;
if (strcmp (name, "I_RST") == 0)return I_RST;
printf ("Error input '%s' don't have a valid id! \n", name);
return -1;
}
//return the output ids numbers of names used in output map
unsigned short
cboard_Blue_Pill::get_out_id(char * name)
{
if (strcmp (name, "LED") == 0)return O_LED;
if (strcmp (name, "LPWR") == 0)return O_LPWR;
printf ("Error output '%s' don't have a valid id! \n", name);
return 1;
}
//Constructor called once on board creation
cboard_Blue_Pill::cboard_Blue_Pill(void)
{
Proc = "stm32f103c8t6"; //default microcontroller if none defined in preferences
ReadMaps (); //Read input and output board maps
}
//Destructor called once on board destruction
cboard_Blue_Pill::~cboard_Blue_Pill(void)
{
}
//Reset board status
void
cboard_Blue_Pill::Reset(void)
{
MReset(1);
//verify serial port state and refresh status bar
#ifndef _WIN_
if (serialfd[0] > 0)
#else
if (serial[0].serialfd != INVALID_HANDLE_VALUE)
#endif
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (":") + itoa (serialbaud) + lxT ("(") +
String ().Format ("%4.1f", fabs ((100.0 * serialexbaud - 100.0 *
serialbaud) / serialexbaud)) + lxT ("%)"));
else
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (" (ERROR)"));
if (use_spare)Window5.Reset ();
}
//Called ever 1s to refresh status
void
cboard_Blue_Pill::RefreshStatus(void)
{
//verify serial port state and refresh status bar
#ifndef _WIN_
if (serialfd[0] > 0)
#else
if (pic.serial[0].serialfd != INVALID_HANDLE_VALUE)
#endif
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (":") + itoa (serialbaud) + lxT ("(") +
String ().Format ("%4.1f", fabs ((100.0 * serialexbaud - 100.0 *
serialbaud) / serialexbaud)) + lxT ("%)"));
else
Window1.statusbar1.SetField (2, lxT ("Serial: ") +
String::FromAscii (SERIALDEVICE) + lxT (" (ERROR)"));
}
//Called to save board preferences in configuration file
void
cboard_Blue_Pill::WritePreferences(void)
{
//write selected microcontroller of board_x to preferences
Window1.saveprefs (lxT ("Blue_Pill_proc"), Proc);
//write microcontroller clock to preferences
Window1.saveprefs (lxT ("Blue_Pill_clock"), String ().Format ("%2.1f", Window1.GetClock()));
}
//Called whe configuration file load preferences
void
cboard_Blue_Pill::ReadPreferences(char *name, char *value)
{
//read microcontroller of preferences
if (!strcmp (name, "Blue_Pill_proc"))
{
Proc = value;
}
//read microcontroller clock
if (!strcmp (name, "Blue_Pill_clock"))
{
Window1.SetClock (atof(value));
}
}
//Event on the board
void
cboard_Blue_Pill::EvKeyPress(uint key, uint mask)
{
}
//Event on the board
void
cboard_Blue_Pill::EvKeyRelease(uint key, uint mask)
{
}
//Event on the board
void
cboard_Blue_Pill::EvMouseButtonPress(uint button, uint x, uint y, uint state)
{
int i;
//search for the input area which owner the event
for (i = 0; i < inputc; i++)
{
if (((input[i].x1 <= x)&&(input[i].x2 >= x))&&((input[i].y1 <= y)&&
(input[i].y2 >= y)))
{
switch (input[i].id)
{
//if event is over I_ISCP area then load hex file
case I_ICSP:
Window1.menu1_File_LoadHex_EvMenuActive (NULL);
break;
//if event is over I_PWR area then toggle board on/off
case I_PWR:
if (Window1.Get_mcupwr ()) //if on turn off
{
Window1.Set_mcurun (0);
Window1.Set_mcupwr (0);
Reset ();
Window1.statusbar1.SetField (0, lxT ("Stoped"));
}
else //if off turn on
{
Window1.Set_mcupwr (1);
Window1.Set_mcurun (1);
Reset ();
Window1.statusbar1.SetField (0, lxT ("Running..."));
}
break;
//if event is over I_RST area then turn off and reset
case I_RST:
/*
if (Window1.Get_mcupwr () && reset (-1))//if powered
{
Window1.Set_mcupwr (0);
Window1.Set_mcurst (1);
}
*/
MReset(-1);
p_MCLR = 0;
break;
}
}
}
}
//Event on the board
void
cboard_Blue_Pill::EvMouseButtonRelease(uint button, uint x, uint y, uint state)
{
int i;
//search for the input area which owner the event
for (i = 0; i < inputc; i++)
{
if (((input[i].x1 <= x)&&(input[i].x2 >= x))&&((input[i].y1 <= y)&&
(input[i].y2 >= y)))
{
switch (input[i].id)
{
//if event is over I_RST area then turn on
case I_RST:
if (Window1.Get_mcurst ())//if powered
{
Window1.Set_mcupwr (1);
Window1.Set_mcurst (0);
/*
if (reset (-1))
{
Reset ();
}
*/
}
p_MCLR = 1;
break;
}
}
}
}
//Called ever 100ms to draw board
//This is the critical code for simulator running speed
void
cboard_Blue_Pill::Draw(CDraw *draw, double scale)
{
int i;
draw->Canvas.Init (scale, scale); //initialize draw context
//board_x draw
for (i = 0; i < outputc; i++) //run over all outputs
{
if (!output[i].r)//if output shape is a rectangle
{
draw->Canvas.SetFgColor (0, 0, 0); //black
switch (output[i].id)//search for color of output
{
case O_LED: //White using pc13 mean value
draw->Canvas.SetColor (pins[1].oavalue, 0 , 0);
break;
case O_LPWR: //Blue using mcupwr value
draw->Canvas.SetColor (225 * Window1.Get_mcupwr () + 30, 0 ,0 );
break;
}
draw->Canvas.Rectangle (1, output[i].x1, output[i].y1, output[i].x2 - output[i].x1, output[i].y2 - output[i].y1);
}
}
//end draw
draw->Canvas.End ();
draw->Update ();
}
void
cboard_Blue_Pill::Run_CPU(void)
{
int i;
int j;
unsigned char pi;
unsigned int alm[64];
int JUMPSTEPS = Window1.GetJUMPSTEPS (); //number of steps skipped
long int NSTEPJ = Window1.GetNSTEPJ (); //number of steps in 100ms
//reset pins mean value
memset (alm, 0, 64* sizeof (unsigned int));
//Spare parts window pre process
if (use_spare)Window5.PreProcess ();
j = JUMPSTEPS; //step counter
if (Window1.Get_mcupwr ()) //if powered
for (i = 0; i < Window1.GetNSTEP (); i++) //repeat for number of steps in 100ms
{
/*
if (j >= JUMPSTEPS)//if number of step is bigger than steps to skip
{
}
*/
//verify if a breakpoint is reached if not run one instruction
MStep ();
//Oscilloscope window process
if (use_oscope)Window4.SetSample ();
//Spare parts window process
if (use_spare)Window5.Process ();
//increment mean value counter if pin is high
if (j < MGetPinCount ())
alm[j] += pins[j].value;
if (j >= JUMPSTEPS)//if number of step is bigger than steps to skip
{
j = -1; //reset counter
}
j++; //counter increment
}
//calculate mean value
for (pi = 0; pi < MGetPinCount (); pi++)
{
pins[pi].oavalue = (int) (((225.0 * alm[pi]) / NSTEPJ) + 30);
}
//Spare parts window pre post process
if (use_spare)Window5.PostProcess ();
}
#ifdef _EXPERIMENTAL_
//Register the board in PICSimLab
board_init("Blue Pill", cboard_Blue_Pill);
#endif
/* ########################################################################
PICsimLab - PIC laboratory simulator
########################################################################
Copyright (c) : 2015-2020 Luis Claudio Gambôa Lopes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
For e-mail suggestions : lcgamboa@yahoo.com
######################################################################## */
#ifndef BOARD_Blue_Pill_H
#define BOARD_Blue_Pill_H
#include<lxrad.h>
#include "board_stm32.h"
//new board class must be derived from board class defined in board.h
class cboard_Blue_Pill:public board_stm32
{
private:
public:
//Constructor called once on board creation
cboard_Blue_Pill(void);
//Destructor called once on board destruction
~cboard_Blue_Pill(void);
//Called ever 100ms to draw board
void Draw(CDraw *draw,double scale);
void Run_CPU(void);
//Return a list of board supported microcontrollers
String GetSupportedDevices(void){return lxT("stm32f103c8t6,");};
//Return the filename of board picture
String GetPictureFileName(void){return lxT("picsimlab8.png");};
//Return the filename of board picture input map
String GetInputMapFile(void){return lxT("input8.map");};
//Return the filename of board picture output map
String GetOutputMapFile(void){return lxT("output8.map");};
//Reset board status
void Reset(void);
//Event on the board
void EvMouseButtonPress(uint button, uint x, uint y,uint state);
//Event on the board
void EvMouseButtonRelease(uint button, uint x, uint y,uint state);
//Event on the board
void EvKeyPress(uint key,uint mask);
//Event on the board
void EvKeyRelease(uint key,uint mask);
void EvOnShow(void){};
//Called ever 1s to refresh status
void RefreshStatus(void);
//Called to save board preferences in configuration file
void WritePreferences(void);
//Called whe configuration file load preferences
void ReadPreferences(char *name,char *value);
//return the input ids numbers of names used in input map
unsigned short get_in_id(char * name);
//return the output ids numbers of names used in output map
unsigned short get_out_id(char * name);
};
#endif /* BOARD_Blue_Pill_H */
/* ########################################################################
PICsimLab - PIC laboratory simulator
########################################################################
Copyright (c) : 2010-2020 Luis Claudio Gambôa Lopes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
For e-mail suggestions : lcgamboa@yahoo.com
######################################################################## */
#include "board_stm32.h"
#include"../picsimlab1.h"
void setblock(int sock_descriptor);
void setnblock(int sock_descriptor);
#ifndef _WIN_
#include<sys/types.h>
#include<sys/socket.h>
#include<sys/un.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#else
#include<winsock2.h>
#include<ws2tcpip.h>
WORD wVersionRequested = 2;
WSADATA wsaData;
#define SHUT_RDWR SD_BOTH
#endif
board_stm32::board_stm32(void)
{
connected = 0;
}
void
board_stm32::MSetSerial(const char * port) {
/*
set_serial (&pic,0, port, 0, 0, 0);
set_serial (&pic,1, "", 0, 0, 0);
*/ }
int
board_stm32::MInit(const char * processor, const char * fname, float freq)
{
struct sockaddr_in serv, cli;
char buff[100];
int n;
#ifdef _WIN_
int clilen;
#else
unsigned int clilen;
#endif
sockfd = -1;
sockmon = -1;
pins_reset ();
serialfd[0] = -1;
serialfd[1] = -1;
serialfd[2] = -1;
serialfd[3] = -1;
if ((listenfd = socket (PF_INET, SOCK_STREAM, 0)) < 0)
{
printf ("socket error : %s \n", strerror (errno));
exit (1);
}
int reuse = 1;
if (setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, (const char*) &reuse, sizeof (reuse)) < 0)
perror ("setsockopt(SO_REUSEADDR) failed");
memset (&serv, 0, sizeof (serv));
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = htonl (INADDR_ANY);
serv.sin_port = htons (2200);
if (bind (listenfd, (sockaddr *) & serv, sizeof (serv)) < 0)
{
printf ("bind error : %s \n", strerror (errno));
exit (1);
}
if (listen (listenfd, SOMAXCONN) < 0)
{
printf ("listen error : %s \n", strerror (errno));
exit (1);
}
char fname_[300];
//change .hex to .bin
strncpy (fname_, fname, 299);
strncpy (fname_ + (strlen (fname_) - 3), "bin", 299);
if (!lxFileExists (fname_))
{
//create a empty memory
FILE *fout;
fout = fopen (fname_, "w");
if (fout)
{
unsigned int val[4] = {0, 0, 0, 0};
fwrite (&val, 4, sizeof (int), fout);
fclose (fout);
}
else
{
printf ("Erro creating file %s \n", fname_);
exit (-1);
}
}
char cmd[500];
snprintf (cmd, 499, "cd %s; ./qemu-system-arm -M stm32-f103c8-picsimlab -pflash %s -serial %s -qmp tcp:localhost:2500,server,nowait &",
"/home/gamboa/projetos/qemu_stm32/arm-softmmu/",
fname_,
"/dev/tnt2"
);
printf ("%s", (const char *)cmd);
system (cmd);
clilen = sizeof (cli);
if (
(sockfd =
accept (listenfd, (sockaddr *) & cli, & clilen)) < 0)
{
printf ("accept error : %s \n", strerror (errno));
exit (1);
}
close (listenfd);
printf ("Qemu connected!\n");
setnblock (sockfd);
//monitor
if ((sockmon = socket (PF_INET, SOCK_STREAM, 0)) < 0)
{
printf ("socket error : %s \n", strerror (errno));
exit (1);
}
memset (&serv, 0, sizeof (serv));
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = inet_addr ("127.0.0.1");
serv.sin_port = htons (2500);
if (connect (sockmon, (sockaddr *) & serv, sizeof (serv)) < 0)
{
printf ("connect error : %s \n", strerror (errno));
exit (1);
}
//read monitor qemu first mensage
if ((n = recv (sockmon, buff, 99, 0)) < 0)
{
printf ("connect error : %s \n", strerror (errno));
exit (1);
}
buff[n] = 0;
printf ("%s", buff);
qemu_cmd ("qmp_capabilities");
connected = 1;
Window1.menu1_File_LoadHex.SetText ("Load Bin");
Window1.menu1_File_SaveHex.SetEnable (0);
Window1.filedialog1.SetFileName(lxT("untitled.bin"));
Window1.filedialog1.SetFilter(lxT("Bin Files (*.bin)|*.bin;*.BIN"));
return 0; //ret;
}
void
board_stm32::MEnd(void)
{
if (connected)
{
qemu_cmd ("quit");
}
close (sockfd);
connected = 0;
Window1.menu1_File_LoadHex.SetText ("Load Hex");
Window1.menu1_File_SaveHex.SetEnable (1);
Window1.filedialog1.SetFileName(lxT("untitled.hex"));
Window1.filedialog1.SetFilter(lxT("Hex Files (*.hex)|*.hex;*.HEX"));
sleep(1);
}
void
board_stm32::MEraseFlash(void) {
//erase_flash ();
}
void
board_stm32::MSetFreq(float freq_)
{
freq = freq_;
}
float
board_stm32::MGetFreq(void)
{
return freq;
}
float
board_stm32::MGetInstClock(void)
{
return freq;
}
int
board_stm32::CpuInitialized(void)
{
return 1;
}
void
board_stm32::DebugLoop(void) {
}
String
board_stm32::MGetPinName(int pin)
{
String pinname = "error";
switch (pin)
{
case 1:
pinname = "VBAT";
break;
case 2:
pinname = "PC13";
break;
case 3:
pinname = "PC14";
break;
case 4:
pinname = "PC15";
break;
case 5:
pinname = "PD0";
break;
case 6:
pinname = "PD1";
break;
case 7:
pinname = "NRST";
break;
case 8:
pinname = "VSSA";
break;
case 9:
pinname = "VDDA";
break;
case 10:
pinname = "PA0";
break;
case 11:
pinname = "PA1";
break;
case 12:
pinname = "PA2";
break;
case 13:
pinname = "PA3";
break;
case 14:
pinname = "PA4";
break;
case 15:
pinname = "PA5";
break;
case 16:
pinname = "PA6";
break;
case 17:
pinname = "PA7";
break;
case 18:
pinname = "PB0";
break;
case 19:
pinname = "PB1";
break;
case 20:
pinname = "PB2";
break;
case 21:
pinname = "PB10";
break;
case 22:
pinname = "PB11";
break;
case 23:
pinname = "VSS";
break;
case 24:
pinname = "VDD";
break;
case 25:
pinname = "PB12";
break;
case 26:
pinname = "PB13";
break;
case 27:
pinname = "PB14";
break;
case 28:
pinname = "PB15";
break;
case 29:
pinname = "PA8";
break;
case 30:
pinname = "PA9";
break;
case 31:
pinname = "PA10";
break;
case 32:
pinname = "PA11";
break;
case 33:
pinname = "PA12";
break;
case 34:
pinname = "PA13";
break;
case 35:
pinname = "VSS";
break;
case 36:
pinname = "VDD";
break;
case 37:
pinname = "PA14";
break;
case 38:
pinname = "PA15";
break;
case 39:
pinname = "PB3";
break;
case 40:
pinname = "PB4";
break;
case 41:
pinname = "PB5";
break;
case 42:
pinname = "PB6";
break;
case 43:
pinname = "PB7";
break;
case 44:
pinname = "BOOT0";
break;
case 45:
pinname = "PB8";
break;
case 46:
pinname = "PB9";
break;
case 47:
pinname = "VSS";
break;
case 48:
pinname = "VDD";
break;
}
return pinname;
}
void
board_stm32::MDumpMemory(const char * fname)
{
char cmd[500];
char fname_[300];
//change .hex to .bin
strncpy (fname_, fname, 299);
strncpy (fname_ + (strlen (fname_) - 3), "bin", 299);
qemu_cmd ("stop");
snprintf (cmd, 500, "{ \"execute\": \"pmemsave\",\"arguments\": { \"val\": 134217728, \"size\": 65536, \"filename\": \"%s\" } }\n", fname_);
qemu_cmd (cmd, 1);
qemu_cmd ("cont");
}
int
board_stm32::DebugInit(int dtyppe) //argument not used in picm only mplabx
{
return 0; //!mplabxd_init (this, Window1.Get_debug_port ()) - 1;
}
int
board_stm32::MGetPinCount(void)
{
return 48;
}
void
board_stm32::pins_reset(void)
{
for (int p = 0; p < MGetPinCount (); p++)
{
pins[p].avalue = 0;
pins[p].lvalue = 0;
pins[p].value = 0;
pins[p].ptype = PT_CMOS;
pins[p].dir = PD_IN;
pins[p].ovalue = 0;
pins[p].oavalue = 0;
}
//TODO
//VCC pins
//pins[6].value = 1;
//pins[19].value = 1;
}
void
board_stm32::MSetPin(int pin, unsigned char value)
{
if ((connected)&&(pins[pin - 1].value != value))
{
unsigned char val = (0x7F & pin);
if(value)
val|=0x80;
if (send (sockfd, &val, 1, 0) != 1)
{
printf ("send error : %s \n", strerror (errno));
exit (1);
}
pins[pin - 1].value = value;
}
}
void
board_stm32::MSetPinDOV(int pin, unsigned char ovalue) {
//set_pin_DOV (pin, ovalue);
}
void
board_stm32::MSetAPin(int pin, float value) {
//set_apin (pin, value);
}
unsigned char
board_stm32::MGetPin(int pin)
{
return 0; //get_pin (pin);
}
void
board_stm32::MReset(int flags)
{
if (connected)
{
qemu_cmd ("system_reset");
}
}
const picpin *
board_stm32::MGetPinsValues(void)
{
return pins;
}
void
board_stm32::MStep(void)
{
char buff;
int n;
if (connected)
{
if ((n = recv (sockfd, &buff, 1, 0)) < 0)
{
//printf ("receive error : %s \n", strerror (errno));
//exit (1);
return;
}
pins[(0x7F & buff) - 1].value = ((0x80 & buff) > 0);
}
}
void
board_stm32::MStepResume(void) {
//if (pic.s2 == 1)step ();
}
int
board_stm32::qemu_cmd(const char * cmd, int raw)
{
int n;
char buffin[400];
char buffout[400];
unsigned int size;
/*
//clear messages
if ((n = recv (sockmon, buffout, 399, 0)) < 0)
{
return 1;
}
buffout[n] = 0;
printf ("(%s)=(%s) \n", buffin, buffout);
*/
if (raw)
{
strcpy (buffin, cmd);
}
else
{
sprintf (buffin, "{ \"execute\": \"%s\" }\n", cmd);
}
size = strlen (buffin);
if (send (sockmon, buffin, size, 0) != size)
{
printf ("mon send error : %s \n", strerror (errno));
exit (1);
}
usleep (1000);
if ((n = recv (sockmon, buffout, 399, 0)) < 0)
{
return 1;
}
buffout[n] = 0;
printf ("(%s)=(%s) \n", buffin, buffout);
return 0;
}
/* ########################################################################
PICsimLab - PIC laboratory simulator
########################################################################
Copyright (c) : 2010-2020 Luis Claudio Gambôa Lopes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
For e-mail suggestions : lcgamboa@yahoo.com
######################################################################## */
#ifndef BOARD_STM32_H
#define BOARD_STM32_H
#include "board.h"
class board_stm32: virtual public board
{
public:
board_stm32(void);
int DebugInit(int dtyppe);
void DebugLoop(void);
int CpuInitialized(void);
void MSetSerial(const char * port);
int MInit(const char * processor, const char * fname, float freq);
void MEnd(void);
void MDumpMemory(const char * fname);
void MEraseFlash(void);
void MSetFreq(float freq);
float MGetFreq(void);
float MGetInstClock(void);
int MGetPinCount(void);
String MGetPinName(int pin);
void MSetPin(int pin, unsigned char value);
void MSetPinDOV(int pin, unsigned char ovalue);
void MSetAPin(int pin, float value);
unsigned char MGetPin(int pin);
const picpin * MGetPinsValues(void);
void MStep(void);
void MStepResume(void);
void MReset(int flags);
void pins_reset(void);
protected:
int qemu_cmd(const char * cmd, int raw =0);
int serialfd[4];
picpin pins[256];
unsigned int serialbaud;
float serialexbaud;
float freq;
int listenfd, sockfd;
int sockmon;
int connected;
};
#endif /* BOARD_STM32_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment