PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
bsim_remote.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_REMOTETCP_H
27#define BOARD_REMOTETCP_H
28
29#include <stdint.h>
30#include "../devices/bitbang_i2c.h"
31#include "../devices/bitbang_spi.h"
32#include "../devices/bitbang_uart.h"
33#include "../lib/board.h"
34
35//===================== Ripes protocol =========================================
36typedef struct {
37 uint32_t msg_type;
38 uint32_t payload_size;
39 uint64_t time;
41
42enum { VB_PINFO = 1, VB_PWRITE, VB_PREAD, VB_PSTATUS, VB_QUIT, VB_SYNC, VB_LAST };
43//==============================================================================
44
45#define TTIMEOUT (BASETIMER * 1000000L)
46
47class bsim_remote : virtual public board {
48public:
49 bsim_remote(void);
50 ~bsim_remote(void);
51 int DebugInit(int dtyppe) override;
52 std::string GetDebugName(void) override { return "NONE"; };
53 void DebugLoop(void) override;
54 int CpuInitialized(void) override;
55 void MSetSerial(const char* port) override;
56 int MInit(const char* processor, const char* fname, float freq) override;
57 void MEnd(void) override;
58 int MGetArchitecture(void) override;
59 int MDumpMemory(const char* fname) override;
60 void MEraseFlash(void) override;
61 void MSetFreq(float freq) override;
62 float MGetFreq(void) override;
63 void MSetVCC(float vcc) override;
64 float MGetVCC(void) override;
65 float MGetInstClockFreq(void) override;
66 int MGetPinCount(void) override;
67 std::string MGetPinName(int pin) override;
68 void MSetPin(int pin, unsigned char value) override;
69 void MSetPinDOV(int pin, unsigned char ovalue) override;
70 void MSetAPin(int pin, float value) override;
71 unsigned char MGetPin(int pin) override;
72 const picpin* MGetPinsValues(void) override;
73 void MStep(void) override;
74 void MStepResume(void) override{};
75 void MReset(int flags) override;
76 void EndServers(void) override;
77 virtual void Run_CPU_ns(uint64_t time) = 0;
78 int GetInc_ns(void) { return inc_ns; };
79 int GetUARTRX(const int uart_num) override;
80 int GetUARTTX(const int uart_num) override;
81 virtual std::string GetClkLabel(void) override { return "IO (Mhz)"; };
82
83protected:
84 const int TestConnection(void);
85 const int DataAvaliable(void);
86 void ConnectionError(const char* s_error);
87 void Disconnect(void);
88 void pins_reset(void);
89 //===================== Ripes protocol =========================================
90 int32_t recv_cmd(cmd_header_t* cmd_header);
91 int32_t recv_payload(char* buff, const uint32_t payload_size);
92 int32_t send_cmd(const uint32_t cmd, const char* payload = NULL, const uint32_t payload_size = 0);
93//==============================================================================
94#ifdef _WIN_
95 HANDLE serialfd[4];
96#else
97 int serialfd[4];
98#endif
99 int procid;
100 picpin pins[256];
101 unsigned int serialbaud;
102 float serialexbaud;
103 float freq;
104 int sockfd;
105 int connected;
106 char fname_[300];
107 char fname_bak[300];
108 unsigned short ADCvalues[16];
109
110 unsigned short Dirs[2] = {0xFF, 0xFF};
111 unsigned short Ports[2] = {0x00, 0x00};
112 unsigned short t0CNT = 0;
113 unsigned short t0STA = 0;
114 unsigned short t0CON = 0x7FFF;
115 unsigned short t0PR = 0xFFFF;
116 unsigned short t0iclk = 0;
117
118 int64_t timerlast = 0;
119 unsigned int inc_ns = 0;
120 unsigned int ns_count = 0;
121
122 bitbang_i2c_t master_i2c[2];
123 bitbang_spi_t master_spi[2];
124 bitbang_uart_t master_uart[2];
125};
126
127#endif /* BOARD_REMOTETCP_H */
Board class.
Definition board.h:111
Definition bsim_remote.h:47
int GetUARTRX(const int uart_num) override
Return the UART N RX pin number.
Definition bsim_remote.cc:772
int GetUARTTX(const int uart_num) override
Return the UART N TX pin number.
Definition bsim_remote.cc:779
int CpuInitialized(void) override
return true if microcontroller is initialized
Definition bsim_remote.cc:290
const picpin * MGetPinsValues(void) override
board microcontroller get all pins list struct
Definition bsim_remote.cc:709
void MEnd(void) override
board microcontroller end
Definition bsim_remote.cc:240
void MReset(int flags) override
board microcontroller reset
Definition bsim_remote.cc:689
void MSetVCC(float vcc) override
board microcontroller set vcc
Definition bsim_remote.cc:278
std::string MGetPinName(int pin) override
board microcontroller pin name
Definition bsim_remote.cc:296
void EndServers(void) override
board servers shutdown
Definition bsim_remote.cc:254
int DebugInit(int dtyppe) override
Start debug support.
Definition bsim_remote.cc:520
void MStep(void) override
board microcontroller run one step
Definition bsim_remote.cc:713
void MSetFreq(float freq) override
board microcontroller set frequency
Definition bsim_remote.cc:268
float MGetInstClockFreq(void) override
board microcontroller get cpu internal clock (in PIC frequency/4)
Definition bsim_remote.cc:286
float MGetFreq(void) override
board microcontroller get frequency
Definition bsim_remote.cc:274
void MSetSerial(const char *port) override
Set serial port name to use.
Definition bsim_remote.cc:96
virtual std::string GetClkLabel(void) override
Return the description of clk label.
Definition bsim_remote.h:81
void MSetAPin(int pin, float value) override
board microcontroller set analog pin
Definition bsim_remote.cc:598
int MInit(const char *processor, const char *fname, float freq) override
board microcontroller init
Definition bsim_remote.cc:103
void DebugLoop(void) override
debug step (pooling)
Definition bsim_remote.cc:294
int MDumpMemory(const char *fname) override
board microcontroller save non volatile memory to hex file
Definition bsim_remote.cc:508
void MSetPinDOV(int pin, unsigned char ovalue) override
board microcontroller set Default Open Value (external pull)
Definition bsim_remote.cc:594
unsigned char MGetPin(int pin) override
board microcontroller get digital pin value
Definition bsim_remote.cc:682
int MGetPinCount(void) override
board microcontroller pin count
Definition bsim_remote.cc:525
void MStepResume(void) override
board microcontroller run one or two steps to resume instruction
Definition bsim_remote.h:74
std::string GetDebugName(void) override
Get debug interface name.
Definition bsim_remote.h:52
float MGetVCC(void) override
board microcontroller get vcc
Definition bsim_remote.cc:282
int MGetArchitecture(void) override
Return board microcontroller architecture.
Definition bsim_remote.cc:250
void MSetPin(int pin, unsigned char value) override
board microcontroller set digital pin
Definition bsim_remote.cc:577
void MEraseFlash(void) override
board microcontroller erase flash memory (program)
Definition bsim_remote.cc:264
Definition bitbang_i2c.h:39
Definition bitbang_spi.h:35
Definition bitbang_uart.h:35
Definition bsim_remote.h:36