simulavr
1.1.0
|
Provides the programming engine for flash self programming. More...
#include <flashprog.h>
Public Types | |
enum | { SPM_TINY_MODE = 0, SPM_MEGA_MODE = 1, SPM_SIG_OPR = 2, SPM_TIMEOUT = 4000000 } |
Public Member Functions | |
FlashProgramming (AvrDevice *c, unsigned int pgsz, unsigned int nrww, int mode) | |
Create a instance of FlashProgramming class. More... | |
~FlashProgramming () | |
unsigned int | CpuCycle () |
void | Reset () |
unsigned char | LPM_action (unsigned int xaddr, unsigned int addr) |
int | SPM_action (unsigned int data, unsigned int xaddr, unsigned int addr) |
void | SetSpmcr (unsigned char v) |
unsigned char | GetSpmcr () |
![]() | |
Hardware (AvrDevice *core) | |
virtual | ~Hardware () |
virtual void | ClearIrqFlag (unsigned int vector) |
virtual bool | IsLevelInterrupt (unsigned int vector) |
virtual bool | LevelInterruptPending (unsigned int vector) |
Public Attributes | |
IOReg< FlashProgramming > | spmcr_reg |
Protected Types | |
enum | SPM_ACTIONtype { SPM_ACTION_NOOP = 0, SPM_ACTION_PREPARE, SPM_ACTION_LOCKCPU, SPM_ACTION_WAIT } |
states of processing engine More... | |
enum | SPM_OPStype { SPM_OPS_NOOP = 0, SPM_OPS_STOREBUFFER, SPM_OPS_WRITEBUFFER, SPM_OPS_ERASE, SPM_OPS_LOCKBITS, SPM_OPS_UNLOCKRWW, SPM_OPS_CLEARBUFFER, SPM_OPS_READSIG } |
SPM operations. More... | |
Protected Member Functions | |
void | ClearOperationBits (void) |
void | SetRWWLock (unsigned int addr) |
Protected Attributes | |
unsigned int | pageSize |
page size in words More... | |
unsigned int | nrww_addr |
start address of non RWW area of flash (word address) More... | |
unsigned char | spmcr_val |
holds the register value More... | |
unsigned char | spmcr_opr_bits |
mask for operation bits, including SPMEN bit More... | |
unsigned char | spmcr_valid_bits |
mask for valid bits More... | |
int | opr_enable_count |
enable counter for SPM operation More... | |
SPM_ACTIONtype | action |
state of the processing engine More... | |
SPM_OPStype | spm_opr |
selected SPM operation More... | |
AvrDevice * | core |
link to AvrDevice More... | |
SystemClockOffset | timeout |
system time till operation run More... | |
unsigned char * | tempBuffer |
hidden buffer for flash page operations More... | |
bool | isATMega |
Flag: true, if in ATMega mode, if false, it's ATTiny mode. More... | |
Provides the programming engine for flash self programming.
Definition at line 38 of file flashprog.h.
anonymous enum |
Enumerator | |
---|---|
SPM_TINY_MODE | |
SPM_MEGA_MODE | |
SPM_SIG_OPR | |
SPM_TIMEOUT |
Definition at line 76 of file flashprog.h.
|
protected |
states of processing engine
Enumerator | |
---|---|
SPM_ACTION_NOOP | |
SPM_ACTION_PREPARE | |
SPM_ACTION_LOCKCPU | |
SPM_ACTION_WAIT |
Definition at line 42 of file flashprog.h.
|
protected |
SPM operations.
Enumerator | |
---|---|
SPM_OPS_NOOP | |
SPM_OPS_STOREBUFFER | |
SPM_OPS_WRITEBUFFER | |
SPM_OPS_ERASE | |
SPM_OPS_LOCKBITS | |
SPM_OPS_UNLOCKRWW | |
SPM_OPS_CLEARBUFFER | |
SPM_OPS_READSIG |
Definition at line 49 of file flashprog.h.
FlashProgramming::FlashProgramming | ( | AvrDevice * | c, |
unsigned int | pgsz, | ||
unsigned int | nrww, | ||
int | mode | ||
) |
Create a instance of FlashProgramming class.
Definition at line 52 of file flashprog.cpp.
References AvrDevice::AddToCycleList(), avr_new, core, isATMega, pageSize, Reset(), SPM_MEGA_MODE, SPM_SIG_OPR, spmcr_opr_bits, spmcr_valid_bits, and tempBuffer.
FlashProgramming::~FlashProgramming | ( | ) |
Definition at line 86 of file flashprog.cpp.
References avr_free(), and tempBuffer.
|
protected |
Definition at line 35 of file flashprog.cpp.
References action, SPM_ACTION_NOOP, spm_opr, SPM_OPS_NOOP, spmcr_opr_bits, and spmcr_val.
Referenced by CpuCycle(), and SPM_action().
|
virtual |
Called for each AVR cycle when this hardware has registered itself as a receiver for AVR clocks. Returns nonzero if instructions should not be executed (e.g. a Flash write is in progress).
Reimplemented from Hardware.
Definition at line 90 of file flashprog.cpp.
References action, ClearOperationBits(), SystemClock::Instance(), opr_enable_count, SPM_ACTION_LOCKCPU, and timeout.
|
inline |
Definition at line 93 of file flashprog.h.
References spmcr_val.
unsigned char FlashProgramming::LPM_action | ( | unsigned int | xaddr, |
unsigned int | addr | ||
) |
Definition at line 114 of file flashprog.cpp.
|
virtual |
Implement the hardware's reset functionality here. The default is no action on reset.
Reimplemented from Hardware.
Definition at line 106 of file flashprog.cpp.
References action, opr_enable_count, SPM_ACTION_NOOP, spm_opr, SPM_OPS_NOOP, spmcr_val, and timeout.
Referenced by FlashProgramming().
|
protected |
Definition at line 41 of file flashprog.cpp.
References core, AvrDevice::Flash, isATMega, nrww_addr, AvrFlash::SetRWWLock(), and spmcr_val.
Referenced by SPM_action().
void FlashProgramming::SetSpmcr | ( | unsigned char | v | ) |
Definition at line 186 of file flashprog.cpp.
References action, isATMega, opr_enable_count, SPM_ACTION_NOOP, SPM_ACTION_PREPARE, spm_opr, SPM_OPS_CLEARBUFFER, SPM_OPS_ERASE, SPM_OPS_LOCKBITS, SPM_OPS_NOOP, SPM_OPS_READSIG, SPM_OPS_STOREBUFFER, SPM_OPS_UNLOCKRWW, SPM_OPS_WRITEBUFFER, spmcr_opr_bits, spmcr_val, and spmcr_valid_bits.
int FlashProgramming::SPM_action | ( | unsigned int | data, |
unsigned int | xaddr, | ||
unsigned int | addr | ||
) |
Definition at line 118 of file flashprog.cpp.
References action, ClearOperationBits(), core, AvrDevice::Flash, SystemClock::GetCurrentTime(), SystemClock::Instance(), nrww_addr, opr_enable_count, pageSize, AvrDevice::PC, SetRWWLock(), AvrFlash::SetRWWLock(), SPM_ACTION_LOCKCPU, SPM_ACTION_PREPARE, spm_opr, SPM_OPS_ERASE, SPM_OPS_STOREBUFFER, SPM_OPS_UNLOCKRWW, SPM_OPS_WRITEBUFFER, SPM_TIMEOUT, spmcr_val, tempBuffer, timeout, and AvrFlash::WriteMem().
Referenced by avr_op_ESPM::operator()(), and avr_op_SPM::operator()().
|
protected |
state of the processing engine
Definition at line 65 of file flashprog.h.
Referenced by ClearOperationBits(), CpuCycle(), Reset(), SetSpmcr(), and SPM_action().
|
protected |
link to AvrDevice
Definition at line 67 of file flashprog.h.
Referenced by FlashProgramming(), SetRWWLock(), and SPM_action().
|
protected |
Flag: true, if in ATMega mode, if false, it's ATTiny mode.
Definition at line 70 of file flashprog.h.
Referenced by FlashProgramming(), SetRWWLock(), and SetSpmcr().
|
protected |
start address of non RWW area of flash (word address)
Definition at line 60 of file flashprog.h.
Referenced by SetRWWLock(), and SPM_action().
|
protected |
enable counter for SPM operation
Definition at line 64 of file flashprog.h.
Referenced by CpuCycle(), Reset(), SetSpmcr(), and SPM_action().
|
protected |
page size in words
Definition at line 59 of file flashprog.h.
Referenced by FlashProgramming(), and SPM_action().
|
protected |
selected SPM operation
Definition at line 66 of file flashprog.h.
Referenced by ClearOperationBits(), Reset(), SetSpmcr(), and SPM_action().
|
protected |
mask for operation bits, including SPMEN bit
Definition at line 62 of file flashprog.h.
Referenced by ClearOperationBits(), FlashProgramming(), and SetSpmcr().
IOReg<FlashProgramming> FlashProgramming::spmcr_reg |
Definition at line 95 of file flashprog.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega128base::AvrDevice_atmega128base(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), AvrDevice_atmega668base::AvrDevice_atmega668base(), AvrDevice_attiny2313::AvrDevice_attiny2313(), and AvrDevice_attinyX5::AvrDevice_attinyX5().
|
protected |
holds the register value
Definition at line 61 of file flashprog.h.
Referenced by ClearOperationBits(), GetSpmcr(), Reset(), SetRWWLock(), SetSpmcr(), and SPM_action().
|
protected |
mask for valid bits
Definition at line 63 of file flashprog.h.
Referenced by FlashProgramming(), and SetSpmcr().
|
protected |
hidden buffer for flash page operations
Definition at line 69 of file flashprog.h.
Referenced by FlashProgramming(), SPM_action(), and ~FlashProgramming().
|
protected |
system time till operation run
Definition at line 68 of file flashprog.h.
Referenced by CpuCycle(), Reset(), and SPM_action().