|
SatCat5
|
Partial driver for the multipurpose serial peripheral.
This incomplete driver controls the "cfgbus_multiserial" block in transaction-based protocols, such as I2C and SPI. It handles core functions such as interrupt servicing, and is designed to maintain good throughput, but requires additional logic to implement specific protocols.
This driver should not be used for when "cfgbus_multiserial" is used in streaming mode.
Definition at line 24 of file cfgbus_multiserial.h.
#include <cfgbus_multiserial.h>
Public Member Functions | |
| u8 | get_percent_full () const |
| How full is the transmit queue? (0-100%) | |
| bool | idle () const |
| Is the queue empty and the bus idle? | |
| void | irq_check () |
| Check if this interrupt may need service. More... | |
| void | irq_enable () |
| Enable this interrupt. More... | |
| void | irq_disable () |
| Temporarily disable this interrupt. More... | |
| void | request_poll () |
| Call this method to request polling at a later time. More... | |
| void | request_cancel () |
| Call this method to cancel a previous request_poll(). | |
Static Public Member Functions | |
| static unsigned | count_ondemand () |
| Count queued objects of this type (i.e., non-idle). | |
Protected Member Functions | |
| MultiSerial (satcat5::cfg::ConfigBus *cfg, unsigned devaddr, unsigned maxpkt, u8 *txbuff, unsigned txsize, u8 *rxbuff, unsigned rxsize) | |
| Set all parameters for this Multiserial instance. More... | |
| bool | write_check (unsigned ncmd, unsigned nread) |
| Is there enough space in the software queue? If it returns true, write each opcode and then call write_finish(). | |
| unsigned | write_finish () |
| Enqueue transaction after calling write_check(). More... | |
| virtual void | read_done (unsigned cidx)=0 |
| Callback when each transaction is finished. More... | |
| virtual void | data_unlink (satcat5::io::Readable *src) |
| Unlink this EventListener from the designated source, because the designated Readable object is being destroyed. More... | |
Protected Attributes | |
| satcat5::cfg::Register | m_ctrl |
| satcat5::io::PacketBuffer | m_tx |
| Buffer for hardware commands. | |
| satcat5::io::PacketBuffer | m_rx |
| Buffer for reply data. | |
Static Protected Attributes | |
| static const unsigned | REGADDR_IRQ = 0 |
| static const unsigned | REGADDR_CFG = 1 |
| static const unsigned | REGADDR_STATUS = 2 |
| static const unsigned | REGADDR_DATA = 3 |
Private Member Functions | |
| void | data_rcvd (satcat5::io::Readable *src) override |
| The data_rcvd() callback is polled whenever data is available. More... | |
| void | irq_event () |
| Interrupt service routine. More... | |
| void | poll_demand () |
| Deferred event handler, called after request(). More... | |
Private Attributes | |
| unsigned const | m_cmd_max |
| unsigned | m_cmd_cbidx |
| unsigned | m_cmd_queued |
| unsigned | m_new_wralloc |
| unsigned | m_new_rdalloc |
| unsigned | m_rdalloc |
| unsigned | m_irq_wrrem |
| unsigned | m_irq_rdrem |
| satcat5::cfg::ConfigBus *const | m_cfg |
| satcat5::cfg::Interrupt * | m_next |
| bool | m_idle |
|
protected |
Set all parameters for this Multiserial instance.
(Only children should create or destroy base class.)
Definition at line 32 of file cfgbus_multiserial.cc.
|
overrideprivatevirtual |
The data_rcvd() callback is polled whenever data is available.
A pointer is provided to assist handlers with multiple sources. Child objects of io::EventListener MUST override this method.
Implements satcat5::io::EventListener.
Definition at line 94 of file cfgbus_multiserial.cc.
|
inlinevirtualinherited |
Unlink this EventListener from the designated source, because the designated Readable object is being destroyed.
Child objects of io::EventListener MAY override this method if action is required.
Reimplemented in satcat5::io::Override, satcat5::io::MuxUp, satcat5::io::MuxDown, satcat5::io::BufferedPackets, satcat5::io::BufferedStream, satcat5::io::BufferedCopy, satcat5::eth::SwitchLogReader, satcat5::eth::Dispatch, satcat5::ccsds_spp::Dispatch, satcat5::ccsds_aos::Dispatch, satcat5::ccsds_aos::Channel, satcat5::test::MockOffload::Port, and satcat5::freertos::MessageCopy.
Definition at line 54 of file io_readable.h.
|
inherited |
Check if this interrupt may need service.
If the interrupt needs service, this calls irq_event.
Definition at line 46 of file cfgbus_interrupt.cc.
|
inherited |
Temporarily disable this interrupt.
Interrupts are enabled by default, but some peripherals may wish to temporary toggle this setting. For use with standard "cfgbus_interrupt" only.
Definition at line 63 of file cfgbus_interrupt.cc.
|
inherited |
Enable this interrupt.
Interrupts are enabled by default, but some peripherals may wish to temporary toggle this setting. For use with standard "cfgbus_interrupt" only.
Definition at line 58 of file cfgbus_interrupt.cc.
|
privatevirtual |
Interrupt service routine.
(Child class must override this method.)
Implements satcat5::cfg::Interrupt.
Definition at line 108 of file cfgbus_multiserial.cc.
|
privatevirtual |
Deferred event handler, called after request().
Child class MUST override this method. (Call "request_poll" to enqueue a callback to this method.)
Implements satcat5::poll::OnDemand.
Definition at line 113 of file cfgbus_multiserial.cc.
|
protectedpure virtual |
Callback when each transaction is finished.
The child object must reads N+1 bytes m_rx, where the first N bytes are reply data and the last byte is an error flag.
| cidx | Command index (for child class to retrieve metadata). (Child MUST override this method.) |
Implemented in satcat5::cfg::I2c, and satcat5::cfg::Spi.
|
inherited |
Call this method to request polling at a later time.
Safe to stack requests, but only one call to poll().
Definition at line 208 of file polling.cc.
|
protected |
Enqueue transaction after calling write_check().
The child object must call write_check, then write each opcode to the queue (m_tx), then call write_finish.
Definition at line 74 of file cfgbus_multiserial.cc.