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. | |
| ~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 () |
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 | |
| unsigned int | nrww_addr |
| start address of non RWW area of flash (word address) | |
| unsigned char | spmcr_val |
| holds the register value | |
| unsigned char | spmcr_opr_bits |
| mask for operation bits, including SPMEN bit | |
| unsigned char | spmcr_valid_bits |
| mask for valid bits | |
| int | opr_enable_count |
| enable counter for SPM operation | |
| SPM_ACTIONtype | action |
| state of the processing engine | |
| SPM_OPStype | spm_opr |
| selected SPM operation | |
| AvrDevice * | core |
| link to AvrDevice | |
| SystemClockOffset | timeout |
| system time till operation run | |
| unsigned char * | tempBuffer |
| hidden buffer for flash page operations | |
| bool | isATMega |
| Flag: true, if in ATMega mode, if false, it's ATTiny mode. | |
Provides the programming engine for flash self programming.
Definition at line 38 of file flashprog.h.
| anonymous enum |
Definition at line 76 of file flashprog.h.
enum FlashProgramming::SPM_ACTIONtype [protected] |
states of processing engine
Definition at line 42 of file flashprog.h.
enum FlashProgramming::SPM_OPStype [protected] |
SPM operations.
| 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.

| void FlashProgramming::ClearOperationBits | ( | void | ) | [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().

| unsigned int FlashProgramming::CpuCycle | ( | void | ) | [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.

| unsigned char FlashProgramming::GetSpmcr | ( | ) | [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.
| void FlashProgramming::Reset | ( | void | ) | [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().

| void FlashProgramming::SetRWWLock | ( | unsigned int | addr | ) | [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_SPM::operator()(), and avr_op_ESPM::operator()().


SPM_ACTIONtype FlashProgramming::action [protected] |
state of the processing engine
Definition at line 65 of file flashprog.h.
Referenced by ClearOperationBits(), CpuCycle(), Reset(), SetSpmcr(), and SPM_action().
AvrDevice* FlashProgramming::core [protected] |
link to AvrDevice
Definition at line 67 of file flashprog.h.
Referenced by FlashProgramming(), SetRWWLock(), and SPM_action().
bool FlashProgramming::isATMega [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().
unsigned int FlashProgramming::nrww_addr [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().
int FlashProgramming::opr_enable_count [protected] |
enable counter for SPM operation
Definition at line 64 of file flashprog.h.
Referenced by CpuCycle(), Reset(), SetSpmcr(), and SPM_action().
unsigned int FlashProgramming::pageSize [protected] |
page size in words
Definition at line 59 of file flashprog.h.
Referenced by FlashProgramming(), and SPM_action().
SPM_OPStype FlashProgramming::spm_opr [protected] |
selected SPM operation
Definition at line 66 of file flashprog.h.
Referenced by ClearOperationBits(), Reset(), SetSpmcr(), and SPM_action().
unsigned char FlashProgramming::spmcr_opr_bits [protected] |
mask for operation bits, including SPMEN bit
Definition at line 62 of file flashprog.h.
Referenced by ClearOperationBits(), FlashProgramming(), and SetSpmcr().
Definition at line 95 of file flashprog.h.
Referenced by AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega8::AvrDevice_atmega8(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
unsigned char FlashProgramming::spmcr_val [protected] |
holds the register value
Definition at line 61 of file flashprog.h.
Referenced by ClearOperationBits(), GetSpmcr(), Reset(), SetRWWLock(), SetSpmcr(), and SPM_action().
unsigned char FlashProgramming::spmcr_valid_bits [protected] |
mask for valid bits
Definition at line 63 of file flashprog.h.
Referenced by FlashProgramming(), and SetSpmcr().
unsigned char* FlashProgramming::tempBuffer [protected] |
hidden buffer for flash page operations
Definition at line 69 of file flashprog.h.
Referenced by FlashProgramming(), SPM_action(), and ~FlashProgramming().
SystemClockOffset FlashProgramming::timeout [protected] |
system time till operation run
Definition at line 68 of file flashprog.h.
Referenced by CpuCycle(), Reset(), and SPM_action().
1.6.3