Class I2CSim


  • public class I2CSim
    extends Object
    A class to control a simulated I2C device.
    • Constructor Detail

      • I2CSim

        public I2CSim​(int index)
        Construct a new I2C simulation object.
        Parameters:
        index - the HAL index of the I2C object
    • Method Detail

      • registerInitializedCallback

        public CallbackStore registerInitializedCallback​(NotifyCallback callback,
                                                         boolean initialNotify)
        Register a callback to be run when this I2C device is initialized.
        Parameters:
        callback - the callback
        initialNotify - whether to run the callback with the initial state
        Returns:
        the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
      • getInitialized

        public boolean getInitialized()
        Check whether this I2C device has been initialized.
        Returns:
        true if initialized
      • setInitialized

        public void setInitialized​(boolean initialized)
        Define whether this I2C device has been initialized.
        Parameters:
        initialized - whether this device is initialized
      • registerReadCallback

        public CallbackStore registerReadCallback​(BufferCallback callback)
        Register a callback to be run whenever a `read` operation is done.
        Parameters:
        callback - the callback that is run on `read` operations
        Returns:
        the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
      • registerWriteCallback

        public CallbackStore registerWriteCallback​(ConstBufferCallback callback)
        Register a callback to be run whenever a `write` operation is done.
        Parameters:
        callback - the callback that is run on `write` operations
        Returns:
        the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
      • resetData

        public void resetData()
        Reset all I2C simulation data.