|
SatCat5
|
Interace driver for "cfgbus_i2c_controller".
This driver is designed for high-throughput, for example writing large blocks of data to I2C-controlled OLED displays. As such, it has a relatively large transmit queue, to ensure throughput can be maintained without buffer underruns.
Definition at line 33 of file cfgbus_i2c.h.
#include <cfgbus_i2c.h>
Public Member Functions | |
| I2c (satcat5::cfg::ConfigBus *cfg, unsigned devaddr) | |
| Constructor links to specified ConfigBus address. | |
| void | configure (unsigned refclk_hz, unsigned baud_hz, bool clock_stretch=true) |
| Configure the I2C controller. | |
| bool | busy () override |
| Is the I2C controller currently busy? | |
| bool | read (const satcat5::util::I2cAddr &devaddr, u8 regbytes, u32 regaddr, u8 nread, satcat5::cfg::I2cEventListener *callback=0) override |
| Add a read operation to the queue. More... | |
| bool | write (const satcat5::util::I2cAddr &devaddr, u8 regbytes, u32 regaddr, u8 nwrite, const u8 *data, satcat5::cfg::I2cEventListener *callback=0) override |
| Add a write operation to the queue. More... | |
| 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 | |
| bool | enqueue_cmd (const satcat5::util::I2cAddr &devaddr, u8 regbytes, u32 regaddr, u8 nwrite, const u8 *data, u8 nread, satcat5::cfg::I2cEventListener *callback=0) |
| void | read_done (unsigned idx) |
| Callback when each transaction is finished. 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 | 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::I2cEventListener * | m_callback [SATCAT5_I2C_MAXCMD] |
| u16 | m_devaddr [SATCAT5_I2C_MAXCMD] |
| u32 | m_regaddr [SATCAT5_I2C_MAXCMD] |
| u8 | m_txbuff [SATCAT5_I2C_TXBUFF] |
| u8 | m_rxbuff [SATCAT5_I2C_RXBUFF] |
| 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 |
|
overrideprivatevirtualinherited |
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.
|
privatevirtualinherited |
Interrupt service routine.
(Child class must override this method.)
Implements satcat5::cfg::Interrupt.
Definition at line 108 of file cfgbus_multiserial.cc.
|
privatevirtualinherited |
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.
|
overridevirtual |
Add a read operation to the queue.
Implements satcat5::cfg::I2cGeneric.
Definition at line 53 of file cfgbus_i2c.cc.
|
protectedvirtual |
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.) |
Implements satcat5::cfg::MultiSerial.
Definition at line 146 of file cfgbus_i2c.cc.
|
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.
|
overridevirtual |
Add a write operation to the queue.
Implements satcat5::cfg::I2cGeneric.
Definition at line 66 of file cfgbus_i2c.cc.
|
protectedinherited |
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.