simulavr
1.1.0
|
#include <hwspi.h>
Public Member Functions | |
HWSpi (AvrDevice *core, HWIrqSystem *, PinAtPort mosi, PinAtPort miso, PinAtPort sck, PinAtPort ss, unsigned int irq_vec, bool mega_mode=true) | |
unsigned int | CpuCycle () |
void | Reset () |
void | SetSPDR (unsigned char val) |
void | SetSPSR (unsigned char val) |
void | SetSPCR (unsigned char val) |
unsigned char | GetSPDR () |
unsigned char | GetSPSR () |
unsigned char | GetSPCR () |
void | ClearIrqFlag (unsigned int) |
![]() | |
Hardware (AvrDevice *core) | |
virtual | ~Hardware () |
virtual bool | IsLevelInterrupt (unsigned int vector) |
virtual bool | LevelInterruptPending (unsigned int vector) |
![]() | |
TraceValueRegister (TraceValueRegister *parent, const std::string &name) | |
Create a TraceValueRegister, with a scope prefix built on parent scope + name. More... | |
TraceValueRegister () | |
Create a TraceValueRegister, with a empty scope name, single device application. More... | |
virtual | ~TraceValueRegister () |
const std::string | GetTraceValuePrefix (void) |
Returns the scope prefix. More... | |
const std::string | GetScopeName (void) |
Returns the scope name. More... | |
void | RegisterTraceValue (TraceValue *t) |
Registers a TraceValue for this register. More... | |
void | UnregisterTraceValue (TraceValue *t) |
Unregisters a TraceValue, remove it from register. More... | |
TraceValueRegister * | GetScopeGroupByName (const std::string &name) |
Get a here registered TraceValueRegister by it's name. More... | |
virtual TraceValue * | GetTraceValueByName (const std::string &name) |
Get a here registered TraceValue by it's name. More... | |
TraceValueRegister * | FindScopeGroupByName (const std::string &name) |
Seek for a TraceValueRegister by it's name. More... | |
TraceValue * | FindTraceValueByName (const std::string &name) |
Seek for a TraceValue by it's name. More... | |
TraceSet * | GetAllTraceValues (void) |
Get all here registered TraceValue's only (not with descending values) More... | |
TraceSet * | GetAllTraceValuesRecursive (void) |
Get all here registered TraceValue's with descending values. More... | |
Public Attributes | |
IOReg< HWSpi > | spdr_reg |
IOReg< HWSpi > | spsr_reg |
IOReg< HWSpi > | spcr_reg |
Private Member Functions | |
void | updatePrescaler () |
Takes info from registers and updates clkdiv. More... | |
void | txbit (const int bitpos) |
Send/receive one bit. More... | |
void | rxbit (const int bitpos) |
void | trxend () |
Handle end of transmission if necessary. More... | |
void | spdr_access () |
Called for all SPDR access to clear the WCOL and SPIF flags if needed. More... | |
Private Attributes | |
unsigned char | shift_in |
unsigned char | data_read |
unsigned char | data_write |
unsigned char | spsr |
unsigned char | spcr |
AvrDevice * | core |
HWIrqSystem * | irq |
PinAtPort | MOSI |
PinAtPort | MISO |
PinAtPort | SCK |
PinAtPort | SS |
unsigned int | irq_vector |
int | clkdiv |
bool | spsr_read |
bool | oldsck |
int | bitcnt |
unsigned | clkcnt |
bool | mega_mode |
bool | finished |
finished transmission? More... | |
Additional Inherited Members | |
![]() | |
virtual size_t | _tvr_getValuesCount (void) |
Get the count of all TraceValues, that are registered here and descending. More... | |
virtual void | _tvr_insertTraceValuesToSet (TraceSet &t) |
Insert all TraceValues into TraceSet, that registered here and descending. More... | |
HWSpi::HWSpi | ( | AvrDevice * | core, |
HWIrqSystem * | _irq, | ||
PinAtPort | mosi, | ||
PinAtPort | miso, | ||
PinAtPort | sck, | ||
PinAtPort | ss, | ||
unsigned int | irq_vec, | ||
bool | mega_mode = true |
||
) |
Definition at line 166 of file hwspi.cpp.
References bitcnt, data_read, data_write, HWIrqSystem::DebugVerifyInterruptVector(), finished, irq, Reset(), shift_in, spcr, spsr, and trace_direct().
|
virtual |
This signals the hardware that the given IRQ vector has been handled by the AVR core.
Reimplemented from Hardware.
Definition at line 200 of file hwspi.cpp.
References HWIrqSystem::ClearIrqFlag(), irq, irq_vector, SPIF, and spsr.
|
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 239 of file hwspi.cpp.
References bitcnt, clkcnt, clkdiv, core, CPHA, CPOL, DORD, finished, PinAtPort::GetDdr(), irq, irq_vector, MOSI, MSTR, oldsck, rxbit(), SCK, PinAtPort::SetAlternatePort(), HWIrqSystem::SetIrqFlag(), SetSPCR(), shift_in, spcr, SPE, SPI_VERBOSE, SPIE, SPIF, spsr, SS, AvrDevice::trace_on, traceOut, trxend(), and txbit().
|
virtual |
|
private |
void HWSpi::SetSPCR | ( | unsigned char | val | ) |
void HWSpi::SetSPDR | ( | unsigned char | val | ) |
void HWSpi::SetSPSR | ( | unsigned char | val | ) |
|
private |
|
private |
Handle end of transmission if necessary.
Definition at line 222 of file hwspi.cpp.
References core, data_read, data_write, finished, irq, irq_vector, HWIrqSystem::SetIrqFlag(), shift_in, spcr, SPI_VERBOSE, SPIE, SPIF, spsr, spsr_read, AvrDevice::trace_on, and traceOut.
Referenced by CpuCycle().
|
private |
Send/receive one bit.
Definition at line 209 of file hwspi.cpp.
References data_write, MISO, MOSI, MSTR, PinAtPort::SetAlternatePort(), and spcr.
Referenced by CpuCycle().
|
private |
|
private |
Bit counter counting from zero (start bit) to eight (idle).
Definition at line 75 of file hwspi.h.
Referenced by CpuCycle(), and HWSpi().
|
private |
Main clock cycles (will be divided to yield SPI clock cycles)
Definition at line 78 of file hwspi.h.
Referenced by CpuCycle().
|
private |
Clock divider for SPI transfers; the system clock is divided by this amount before being fed to the state logic.
Definition at line 62 of file hwspi.h.
Referenced by CpuCycle().
|
private |
Definition at line 51 of file hwspi.h.
Referenced by CpuCycle(), and trxend().
|
private |
|
private |
|
private |
finished transmission?
Definition at line 86 of file hwspi.h.
Referenced by CpuCycle(), HWSpi(), and trxend().
|
private |
Definition at line 52 of file hwspi.h.
Referenced by ClearIrqFlag(), CpuCycle(), HWSpi(), and trxend().
|
private |
Definition at line 58 of file hwspi.h.
Referenced by ClearIrqFlag(), CpuCycle(), and trxend().
|
private |
|
private |
|
private |
Definition at line 54 of file hwspi.h.
Referenced by CpuCycle(), rxbit(), and txbit().
|
private |
Definition at line 72 of file hwspi.h.
Referenced by CpuCycle().
|
private |
Definition at line 56 of file hwspi.h.
Referenced by CpuCycle().
|
private |
|
private |
Definition at line 121 of file hwspi.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(), and AvrDevice_atmega668base::AvrDevice_atmega668base().
Definition at line 121 of file hwspi.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(), and AvrDevice_atmega668base::AvrDevice_atmega668base().
|
private |
Definition at line 48 of file hwspi.h.
Referenced by ClearIrqFlag(), CpuCycle(), HWSpi(), Reset(), and trxend().
|
private |
Definition at line 121 of file hwspi.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(), and AvrDevice_atmega668base::AvrDevice_atmega668base().
|
private |
Definition at line 57 of file hwspi.h.
Referenced by CpuCycle().