View Source ATECC508A.Configuration (atecc508a v1.2.0)

This module handles operations on the configuration zone.

Link to this section Summary

Functions

Convert a raw configuration to a nice map.

Lock the configuration zone.

Read the configuration

Read the entire contents of the configuration zone and don't interpret them

Read the current slot configuration

Read the current slot configuration

Convert a nice config map back to a raw configuration

Write the configuration.

Write the key configuration.

Write a slot configuration.

Link to this section Types

@type t() :: %ATECC508A.Configuration{
  chip_mode: non_neg_integer(),
  counter0: non_neg_integer(),
  counter1: non_neg_integer(),
  i2c_address: Circuits.I2C.address(),
  i2c_enable: byte(),
  key_config: <<_::256>>,
  last_key_use: binary(),
  lock_config: non_neg_integer(),
  lock_value: non_neg_integer(),
  otp_mode: non_neg_integer(),
  reserved0: byte(),
  reserved1: byte(),
  reserved2: byte(),
  rev_num: atom() | binary(),
  rfu: <<_::16>>,
  selector: non_neg_integer(),
  serial_number: binary(),
  slot_config: <<_::256>>,
  slot_locked: non_neg_integer(),
  user_extra: non_neg_integer(),
  x509_format: <<_::32>>
}

Link to this section Functions

@spec from_raw(<<_::1024>>) :: t()

Convert a raw configuration to a nice map.

Link to this function

lock(transport, expected_contents)

View Source
@spec lock(ATECC508A.Transport.t(), t()) :: :ok | {:error, atom()}

Lock the configuration zone.

The expected contents need to be passed for a CRC calculation. They are not written by design. The logic is that this is a final chance before it's too late to check that the device is programmed correctly.

@spec read(ATECC508A.Transport.t()) :: {:ok, t()} | {:error, atom()}

Read the configuration

@spec read_all_raw(ATECC508A.Transport.t()) :: {:ok, <<_::1024>>} | {:error, atom()}

Read the entire contents of the configuration zone and don't interpret them

Link to this function

read_key_config(transport)

View Source
@spec read_key_config(ATECC508A.Transport.t()) :: {:ok, <<_::256>>} | {:error, atom()}

Read the current slot configuration

Link to this function

read_slot_config(transport)

View Source
@spec read_slot_config(ATECC508A.Transport.t()) ::
  {:ok, <<_::256>>} | {:error, atom()}

Read the current slot configuration

@spec to_raw(t()) :: <<_::1024>>

Convert a nice config map back to a raw configuration

@spec write(ATECC508A.Transport.t(), t()) :: :ok | {:error, atom()}

Write the configuration.

This only works when the ATECC508A is unlocked and only bytes not all bytes can be changed. This only writes the ones that can.

Link to this function

write_key_config(transport, data)

View Source
@spec write_key_config(ATECC508A.Transport.t(), <<_::256>>) :: :ok | {:error, atom()}

Write the key configuration.

Link to this function

write_slot_config(transport, data)

View Source
@spec write_slot_config(ATECC508A.Transport.t(), <<_::256>>) :: :ok | {:error, atom()}

Write a slot configuration.