FlashProgramming Class Reference

Provides the programming engine for flash self programming. More...

#include <flashprog.h>

Inheritance diagram for FlashProgramming:
Inheritance graph
[legend]
Collaboration diagram for FlashProgramming:
Collaboration graph
[legend]

List of all members.

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< FlashProgrammingspmcr_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
AvrDevicecore
 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.

Detailed Description

Provides the programming engine for flash self programming.

Todo:
not implemented yet: SPM interrupt. Support of LPM operation. Setting boot lock bits. Read-While-Write, if run code in NRWW section.

Definition at line 38 of file flashprog.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
SPM_TINY_MODE 
SPM_MEGA_MODE 
SPM_SIG_OPR 
SPM_TIMEOUT 

Definition at line 76 of file flashprog.h.

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.

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.


Constructor & Destructor Documentation

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.

Here is the call graph for this function:

FlashProgramming::~FlashProgramming (  ) 

Definition at line 86 of file flashprog.cpp.

References avr_free(), and tempBuffer.

Here is the call graph for this function:


Member Function Documentation

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().

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void FlashProgramming::SetSpmcr ( unsigned char  v  ) 
int FlashProgramming::SPM_action ( unsigned int  data,
unsigned int  xaddr,
unsigned int  addr 
)

Member Data Documentation

state of the processing engine

Definition at line 65 of file flashprog.h.

Referenced by ClearOperationBits(), CpuCycle(), Reset(), SetSpmcr(), and SPM_action().

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().

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().

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().

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().

system time till operation run

Definition at line 68 of file flashprog.h.

Referenced by CpuCycle(), Reset(), and SPM_action().


The documentation for this class was generated from the following files:
Generated on Sun Feb 12 16:51:08 2012 for Simulavr by  doxygen 1.6.3