Class ArchAVR_SPI
Defined in File arch_avr_spi.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public Peripheral(Class Peripheral)
Class Documentation
-
class ArchAVR_SPI : public Peripheral
Implementation of a SPI interface for AVR series Features:
Host/client mode
data order, phase and polarity settings have no effect
write collision flag not supported
See also
sim_spi.h
Public Functions
-
ArchAVR_SPI(uint8_t num, const ArchAVR_SPIConfig &config)
-
virtual ~ArchAVR_SPI()
-
virtual bool init(Device &device) override
Virtual method called when the device is initialised. This is where the peripheral can allocate its I/O registers, interrupts or connect signals.
- Returns:
boolean indicates the success of all allocations.
-
virtual void reset() override
Virtual method called when the device is reset. Note that resetting I/O registers is only necessary here if their reset value is not zero.
-
virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t *data) override
Virtual method called for a CTL request. The method must return true if the request has been processed.
-
virtual uint8_t ioreg_read_handler(reg_addr_t addr, uint8_t value) override
Virtual method called when the CPU is reading a I/O register allocated by this peripheral. The value has not been read yet so the module can modify it before the CPU gets it.
- Parameters:
addr – the register address in I/O space
value – current cached value of the register
- Returns:
actual value of the register
-
virtual uint8_t ioreg_peek_handler(reg_addr_t addr, uint8_t value) override
Virtual method called when a debug probe is peeking the value of a register. The value has not been read yet so the module can modify it before the CPU gets it. The difference between a peek and a read is that a peek should not modify the state of the peripheral. By default, ioreg_read_handler is called to obtain the value.
- Parameters:
addr – the register address in I/O space
value – current cached value of the register
- Returns:
actual value of the register
-
virtual void ioreg_write_handler(reg_addr_t addr, const ioreg_write_t &data) override
Virtual method called when the CPU is writing a I/O register allocated by this peripheral. The value has already been written.
- Parameters:
addr – the register address in I/O space
value – the new register content
-
class _Controller : public SPI::EndPoint, public CycleTimer
Public Functions
-
explicit _Controller(ArchAVR_SPI &peripheral)
-
inline virtual ~_Controller()
-
void init(CycleManager &cycle_manager, Logger &logger)
-
void reset()
-
void set_bit_delay(cycle_count_t delay)
-
void set_mode(ControllerMode mode)
-
inline ControllerMode mode() const
-
void set_serial_mode(SerialMode mode)
-
void push_tx(uint8_t data)
-
uint8_t pop_rx()
-
uint8_t peek_rx() const
-
inline bool rx_available() const
-
uint8_t mock_transfer(uint8_t rx_frame)
-
inline void input_clock(bool state)
-
void set_selected(bool selected)
-
inline bool selected() const
-
virtual cycle_count_t next(cycle_count_t when) override
Callback from the cycle loop.
Note
there’s no guarantee the method will be called exactly on the required ‘when’ cycle. The only guarantee is “called ‘when’ <= ‘current cycle’”, the implementations must account for this.
Note
The next ‘when’ can be in the ‘past’ (i.e. <= ‘current cycle’). In this case, the timer will be called again within the same cycle with the given next ‘when’. The only constraint is that it must be greater than the previous ‘when’. If it’s negative or zero, the timer is removed from the queue.
- Parameters:
when – current ‘when’ cycle, at which the timer was scheduled
- Returns:
the next ‘when’ the timer requires to be called at.
-
explicit _Controller(ArchAVR_SPI &peripheral)
-
class _PinDriver : public PinDriver
Public Functions
-
_PinDriver(_Controller &ctrl, ctl_id_t id)
-
void set_mode(ControllerMode mode)
-
void set_line_state(Line line, bool state)
-
virtual Pin::controls_t override_gpio(pin_index_t pin_index, const Pin::controls_t &gpio_controls) override
Stub called when a state resolution is taking place on a pin that the driver is controlling. The reimplementation should make a copy of the controls structure in argument, change its members according to the override state and return the result.
- Parameters:
pin_index – index of the pin
controls – pin controls as configured by the GPIO port controller
- Returns:
the controls to apply to the pin
-
virtual void digital_state_changed(pin_index_t pin_index, bool state) override
Stub called when the digital state of a pin has changed after a state resolution.
- Parameters:
pin_index – Index of the pin
state – New digital state of the pin
-
_PinDriver(_Controller &ctrl, ctl_id_t id)