PCA9641.Registers (pca9641 v2.0.1)

This module provides a wrapper around the PCA9641 registers described in NXP's datasheet.

Link to this section Summary

Functions

Read the contents of the control register.

Read the contents of the id register.

Read the contents of the interrupt_mask register.

Read the contents of the interrupt_status register.

Read the contents of the mailbox_lsb register.

Read the contents of the mailbox_msb register.

Read the contents of the reserve_time register.

Read the contents of the status register.

Swap the contents of the control register.

Swap the contents of the interrupt_mask register.

Swap the contents of the interrupt_status register.

Swap the contents of the mailbox_lsb register.

Swap the contents of the mailbox_msb register.

Swap the contents of the reserve_time register.

Swap the contents of the status register.

Update the contents of the control register using a transformation function.

Update the contents of the interrupt_mask register using a transformation function.

Update the contents of the interrupt_status register using a transformation function.

Update the contents of the mailbox_lsb register using a transformation function.

Update the contents of the mailbox_msb register using a transformation function.

Update the contents of the reserve_time register using a transformation function.

Update the contents of the status register using a transformation function.

Write new contents to the control register.

Write new contents to the interrupt_mask register.

Write new contents to the interrupt_status register.

Write new contents to the mailbox_lsb register.

Write new contents to the mailbox_msb register.

Write new contents to the reserve_time register.

Write new contents to the status register.

Link to this section Functions

Link to this function

read_control(conn)

@spec read_control(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}

Read the contents of the control register.

Example

iex> read_control(conn)
{:ok, <<0>>}
@spec read_id(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}

Read the contents of the id register.

Example

iex> read_id(conn)
{:ok, <<0>>}
Link to this function

read_interrupt_mask(conn)

@spec read_interrupt_mask(Wafer.Conn.t()) ::
  {:ok, binary()} | {:error, reason :: any()}

Read the contents of the interrupt_mask register.

Example

iex> read_interrupt_mask(conn)
{:ok, <<0>>}
Link to this function

read_interrupt_status(conn)

@spec read_interrupt_status(Wafer.Conn.t()) ::
  {:ok, binary()} | {:error, reason :: any()}

Read the contents of the interrupt_status register.

Example

iex> read_interrupt_status(conn)
{:ok, <<0>>}
Link to this function

read_mailbox_lsb(conn)

@spec read_mailbox_lsb(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}

Read the contents of the mailbox_lsb register.

Example

iex> read_mailbox_lsb(conn)
{:ok, <<0>>}
Link to this function

read_mailbox_msb(conn)

@spec read_mailbox_msb(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}

Read the contents of the mailbox_msb register.

Example

iex> read_mailbox_msb(conn)
{:ok, <<0>>}
Link to this function

read_reserve_time(conn)

@spec read_reserve_time(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}

Read the contents of the reserve_time register.

Example

iex> read_reserve_time(conn)
{:ok, <<0>>}
Link to this function

read_status(conn)

@spec read_status(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}

Read the contents of the status register.

Example

iex> read_status(conn)
{:ok, <<0>>}
Link to this function

swap_control(conn, data)

@spec swap_control(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the control register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_control(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

swap_interrupt_mask(conn, data)

@spec swap_interrupt_mask(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the interrupt_mask register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_interrupt_mask(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

swap_interrupt_status(conn, data)

@spec swap_interrupt_status(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the interrupt_status register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_interrupt_status(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

swap_mailbox_lsb(conn, data)

@spec swap_mailbox_lsb(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the mailbox_lsb register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_mailbox_lsb(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

swap_mailbox_msb(conn, data)

@spec swap_mailbox_msb(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the mailbox_msb register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_mailbox_msb(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

swap_reserve_time(conn, data)

@spec swap_reserve_time(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the reserve_time register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_reserve_time(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

swap_status(conn, data)

@spec swap_status(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Swap the contents of the status register.

Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.

Example

iex> swap_status(conn, <<0>>)
{:ok, <<0>>, _conn}
Link to this function

update_control(conn, callback)

@spec update_control(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the control register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_control(conn, transform)
{:ok, _conn}
Link to this function

update_interrupt_mask(conn, callback)

@spec update_interrupt_mask(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the interrupt_mask register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_interrupt_mask(conn, transform)
{:ok, _conn}
Link to this function

update_interrupt_status(conn, callback)

@spec update_interrupt_status(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the interrupt_status register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_interrupt_status(conn, transform)
{:ok, _conn}
Link to this function

update_mailbox_lsb(conn, callback)

@spec update_mailbox_lsb(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the mailbox_lsb register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_mailbox_lsb(conn, transform)
{:ok, _conn}
Link to this function

update_mailbox_msb(conn, callback)

@spec update_mailbox_msb(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the mailbox_msb register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_mailbox_msb(conn, transform)
{:ok, _conn}
Link to this function

update_reserve_time(conn, callback)

@spec update_reserve_time(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the reserve_time register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_reserve_time(conn, transform)
{:ok, _conn}
Link to this function

update_status(conn, callback)

@spec update_status(Wafer.Conn.t(), (<<_::_*8>> -> <<_::_*8>>)) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Update the contents of the status register using a transformation function.

Example

iex> transform = fn <<data::size(8)>> -> <<(data * 2)::size(8)>> end
...> update_status(conn, transform)
{:ok, _conn}
Link to this function

write_control(conn, data)

@spec write_control(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the control register.

Example

iex> write_control(conn, <<0>>)
{:ok, _conn}
Link to this function

write_interrupt_mask(conn, data)

@spec write_interrupt_mask(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the interrupt_mask register.

Example

iex> write_interrupt_mask(conn, <<0>>)
{:ok, _conn}
Link to this function

write_interrupt_status(conn, data)

@spec write_interrupt_status(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the interrupt_status register.

Example

iex> write_interrupt_status(conn, <<0>>)
{:ok, _conn}
Link to this function

write_mailbox_lsb(conn, data)

@spec write_mailbox_lsb(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the mailbox_lsb register.

Example

iex> write_mailbox_lsb(conn, <<0>>)
{:ok, _conn}
Link to this function

write_mailbox_msb(conn, data)

@spec write_mailbox_msb(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the mailbox_msb register.

Example

iex> write_mailbox_msb(conn, <<0>>)
{:ok, _conn}
Link to this function

write_reserve_time(conn, data)

@spec write_reserve_time(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the reserve_time register.

Example

iex> write_reserve_time(conn, <<0>>)
{:ok, _conn}
Link to this function

write_status(conn, data)

@spec write_status(Wafer.Conn.t(), data :: binary()) ::
  {:ok, Wafer.Conn.t()} | {:error, reason :: any()}

Write new contents to the status register.

Example

iex> write_status(conn, <<0>>)
{:ok, _conn}