Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / Spi.h
blob6e6a1965eb4a9784b62410adca8dbebd4d6b7caa
1 #ifndef AVR_SPI_H
2 #define AVR_SPI_H
4 #include "Hardware.h"
6 namespace avr {
8 class Spi : public avr::Hardware {
9 public:
10 Spi(Bus & bus, unsigned int stcVec);
11 ~Spi();
13 public:
14 /**
15 * Attach a register with name \e name to the hardware.
17 bool attachReg(const char *name, IORegister *reg);
19 /**
20 * Finishes the construction of the hardware.
21 * This should verify the registers and parameters
22 * @returns true if build was successful.
24 bool finishBuild();
26 /**
27 * An attached register changed state.
29 void regChanged( IORegister *reg );
31 /**
32 * Perform a single step.
34 void step();
36 /**
37 * Reset the internal hardware.
39 void reset();
41 /**
42 * Called just before an interrupt handler is invoked.
44 void beforeInvokeInterrupt(unsigned int vector);
46 private:
47 void setSpcr(unsigned char val);
48 void setSpdr(unsigned char val);
49 void setClkDiv();
51 private:
52 IORegister *spcr;
53 IORegister *spsr;
54 IORegister *spdr;
56 private:
57 unsigned int stcVec;
59 int clkDiv;
60 int bitCnt;
61 unsigned char spdrWrite;
62 unsigned char spdrRead;
63 unsigned spsr_old;
65 enum {
66 READY,
67 SLAVE,
68 START_MASTER,
69 MASTER
70 } state;
75 #endif /*AVR_SPI_H*/