C/C++ API Reference
Loading...
Searching...
No Matches
pw::i2c::ResponderEvents Class Reference

Overview

Application handler for i2c events.

Note: these functions will be called on an interrupt context.

Inheritance diagram for pw::i2c::ResponderEvents:
pw::i2c::test::ResponderEventsForTest

Public Member Functions

virtual bool OnStartRead ()
 
virtual bool OnStartWrite ()
 
virtual bool OnWrite (ConstByteSpan data)
 
virtual Result< ConstByteSpanOnRead ()
 
virtual bool OnStop ()
 

Member Function Documentation

◆ OnRead()

virtual Result< ConstByteSpan > pw::i2c::ResponderEvents::OnRead ( )
inlinevirtual

Called when data is needed from the bus.

The responder implementation is responsible for handling hardware that doesn't support a hardware cache. In those cases follow-up interrupts for reading the next byte should consume the next byte from the original span until all the bytes have been consumed. At which point this function will be called again.

Returns
A Result containing ConstByteSpan on success or one of the following error codes on failure:
  • OK along with a byte span used to send to the initiator. An ACK will be sent for each valid byte.
  • Any error status to NACK.

Reimplemented in pw::i2c::test::ResponderEventsForTest.

◆ OnStartRead()

virtual bool pw::i2c::ResponderEvents::OnStartRead ( )
inlinevirtual

Called when a read start condition is seen.

Returns
  • true to send an ACK
  • false to NACK

Reimplemented in pw::i2c::test::ResponderEventsForTest.

◆ OnStartWrite()

virtual bool pw::i2c::ResponderEvents::OnStartWrite ( )
inlinevirtual

Called when a write start condition is seen.

Returns
  • true to send an ACK
  • false to NACK

Reimplemented in pw::i2c::test::ResponderEventsForTest.

◆ OnStop()

virtual bool pw::i2c::ResponderEvents::OnStop ( )
inlinevirtual

Called when the stop condition is received.

Returns
  • true to send an ACK
  • false to NACK

Reimplemented in pw::i2c::test::ResponderEventsForTest.

◆ OnWrite()

virtual bool pw::i2c::ResponderEvents::OnWrite ( ConstByteSpan  data)
inlinevirtual

Called when data is available on the bus.

Depending on the IC, some buses have hardware caches so they will call this function once with a few bytes while others will call this once per byte. Either way, the write is not considered complete until the stop condition is called.

  • data The data written to the responder
    Returns
    • true to send an ACK
    • false to NACK

Reimplemented in pw::i2c::test::ResponderEventsForTest.


The documentation for this class was generated from the following file: