29#include "../lib/board.h"
31#include "../devices/bitbang_uart.h"
32#include "../devices/mplabxd.h"
33#include "../lib/serial_port.h"
35#include <simavr/avr_adc.h>
36#include <simavr/avr_ioport.h>
37#include <simavr/avr_twi.h>
38#include <simavr/avr_uart.h>
39#include <simavr/sim_avr.h>
40#include <simavr/sim_elf.h>
41#include <simavr/sim_gdb.h>
42#include <simavr/sim_hex.h>
44#define MAX_UART_COUNT 4
64 int MInit(
const char* processor,
const char* fname,
float freq)
override;
65 void MEnd(
void)
override;
71 void MSetVCC(
float vcc)
override;
76 void MSetPin(
int pin,
unsigned char value)
override;
77 void MSetPinDOV(
int pin,
unsigned char ovalue)
override;
78 void MSetAPin(
int pin,
float value)
override;
79 unsigned char MGetPin(
int pin)
override;
81 void MStep(
void)
override;
83 void MReset(
int flags)
override;
85 unsigned int DBGGetPC(
void)
override;
86 void DBGSetPC(
unsigned int pc)
override;
99 int GetUARTRX(
const int uart_num)
override;
100 int GetUARTTX(
const int uart_num)
override;
101 virtual void UpdateHardware(
void);
103 static void out_hook(
struct avr_irq_t* irq, uint32_t value,
void* param) {
104 picpin* p = (picpin*)param;
109 static void ddr_hook(
struct avr_irq_t* irq, uint32_t value,
void* param) {
110 picpin* p = (picpin*)param;
111 p->dir = !(value & (1 << p->pord));
115 void SerialSend(
bitbang_uart_t* _bb_uart,
const unsigned char value);
121 avr_irq_t* serial_irq[MAX_UART_COUNT];
123 avr_irq_t* Write_stat_irq[100];
124 unsigned int serialbaud[MAX_UART_COUNT];
125 float serialexbaud[MAX_UART_COUNT];
126 void pins_reset(
void);
130 unsigned char* eeprom;
131 unsigned char uart_config[MAX_UART_COUNT];
132 unsigned char usart_count;
133 unsigned int UCSR_base[MAX_UART_COUNT];
136 int parse_hex(
const char* line,
int bytes);
137 unsigned char checksum(
char* str);
138 int read_ihx_avr(
const char* fname,
int leeprom);
139 int write_ihx_avr(
const char* fname);
Board class.
Definition board.h:111
Definition bsim_simavr.h:56
float MGetVCC(void) override
board microcontroller get vcc
Definition bsim_simavr.cc:545
int DebugInit(int dtyppe) override
Start debug support.
Definition bsim_simavr.cc:591
void MReset(int flags) override
board microcontroller reset
Definition bsim_simavr.cc:1535
unsigned int DBGGetEEPROM_Size(void) override
board microcontroller get data EEPROM memory size
Definition bsim_simavr.cc:1610
unsigned char * DBGGetCONFIG_p(void) override
board microcontroller get CONFIG memory pointer
Definition bsim_simavr.cc:1579
void MSetPin(int pin, unsigned char value) override
board microcontroller set digital pin
Definition bsim_simavr.cc:1187
float MGetFreq(void) override
board microcontroller get frequency
Definition bsim_simavr.cc:537
void MSetAPin(int pin, float value) override
board microcontroller set analog pin
Definition bsim_simavr.cc:1215
const picpin * MGetPinsValues(void) override
board microcontroller get all pins list struct
Definition bsim_simavr.cc:1388
unsigned int DBGGetRAMSize(void) override
board microcontroller get RAM memory size
Definition bsim_simavr.cc:1592
void MStep(void) override
board microcontroller run one step
Definition bsim_simavr.cc:1529
unsigned char * DBGGetID_p(void) override
board microcontroller get internal IDS memory pointer
Definition bsim_simavr.cc:1583
void EndServers(void) override
board servers shutdown
Definition bsim_simavr.cc:1614
unsigned int DBGGetIDSize(void) override
board microcontroller get internal IDS memory size
Definition bsim_simavr.cc:1605
unsigned int DBGGetROMSize(void) override
board microcontroller get ROM (FLASH) memory size
Definition bsim_simavr.cc:1596
int MGetArchitecture(void) override
Return board microcontroller architecture.
Definition bsim_simavr.cc:521
int MInit(const char *processor, const char *fname, float freq) override
board microcontroller init
Definition bsim_simavr.cc:282
int GetUARTRX(const int uart_num) override
Return the UART N RX pin number.
Definition bsim_simavr.cc:1618
unsigned char MGetPin(int pin) override
board microcontroller get digital pin value
Definition bsim_simavr.cc:1381
void MSetFreq(float freq) override
board microcontroller set frequency
Definition bsim_simavr.cc:530
int MGetPinCount(void) override
board microcontroller pin count
Definition bsim_simavr.cc:637
void MSetPinDOV(int pin, unsigned char ovalue) override
board microcontroller set Default Open Value (external pull)
Definition bsim_simavr.cc:1202
void MSetVCC(float vcc) override
board microcontroller set vcc
Definition bsim_simavr.cc:541
int GetUARTTX(const int uart_num) override
Return the UART N TX pin number.
Definition bsim_simavr.cc:1624
int CpuInitialized(void) override
return true if microcontroller is initialized
Definition bsim_simavr.cc:633
void MSetSerial(const char *port) override
Set serial port name to use.
Definition bsim_simavr.cc:82
unsigned int DBGGetCONFIGSize(void) override
board microcontroller get CONFIG memory size
Definition bsim_simavr.cc:1600
unsigned int DBGGetPC(void) override
board microcontroller get PC
Definition bsim_simavr.cc:1563
void DebugLoop(void) override
debug step (pooling)
Definition bsim_simavr.cc:622
int GetDefaultClock(void) override
Get board default clock in MHz.
Definition bsim_simavr.h:98
unsigned char * DBGGetRAM_p(void) override
board microcontroller get RAM memory pointer
Definition bsim_simavr.cc:1571
void MEraseFlash(void) override
board microcontroller erase flash memory (program)
Definition bsim_simavr.cc:525
float MGetInstClockFreq(void) override
board microcontroller get cpu internal clock (in PIC frequency/4)
Definition bsim_simavr.cc:552
unsigned char * DBGGetROM_p(void) override
board microcontroller get ROM (FLASH) memory pointer
Definition bsim_simavr.cc:1575
std::string GetDebugName(void) override
Get debug interface name.
Definition bsim_simavr.cc:614
void MStepResume(void) override
board microcontroller run one or two steps to resume instruction
Definition bsim_simavr.cc:1533
int MDumpMemory(const char *fname) override
board microcontroller save non volatile memory to hex file
Definition bsim_simavr.cc:556
unsigned char * DBGGetEEPROM_p(void) override
board microcontroller get data EEPROM memory pointer
Definition bsim_simavr.cc:1588
void MEnd(void) override
board microcontroller end
Definition bsim_simavr.cc:469
std::string MGetPinName(int pin) override
board microcontroller pin name
Definition bsim_simavr.cc:661
void DBGSetPC(unsigned int pc) override
board microcontroller set PC
Definition bsim_simavr.cc:1567
unsigned short * DBGGetProcID_p(void) override
board microcontroller get pointer to processor ID
Definition bsim_simavr.cc:1559
Definition bitbang_uart.h:35
Definition bsim_simavr.h:46