ST25R100.SPI (st25r100 v0.1.0)

Copy Markdown View Source

SPI communication functions for the ST25R100. Separates pure binary payload construction from side-effecting hardware execution.

Summary

Functions

Builds the SPI packet to execute the direct command cmd. Uses write format (Bit 7 = 0) with command ID.

Builds the SPI packet to read length bytes from the FIFO buffer. Uses pseudo-register 0x5F read format.

Builds the SPI packet to read length bytes starting from register reg. Address format: Bit 7 = 1 (read), Bits 6:0 = register address.

Builds the SPI packet to write data into the FIFO buffer. Uses pseudo-register 0x5F write format.

Builds the SPI packet to write val to register reg. Address format: Bit 7 = 0 (write), Bits 6:0 = register address.

Modifies specific bits in register reg using a mask and value. new_value = (current_value & ~mask) | (value & mask)

Clears the specified bit flags in register reg.

Executes a direct command on the chip.

Reads length bytes from the chip's FIFO.

Reads length multiple registers sequentially (auto-increment read).

Reads a single byte from register reg.

Sets the specified bit flags in register reg.

Writes raw binary payload data into the chip's FIFO.

Writes a single byte val to register reg.

Functions

build_execute_command(cmd)

@spec build_execute_command(byte()) :: binary()

Builds the SPI packet to execute the direct command cmd. Uses write format (Bit 7 = 0) with command ID.

build_read_fifo(length)

@spec build_read_fifo(pos_integer()) :: binary()

Builds the SPI packet to read length bytes from the FIFO buffer. Uses pseudo-register 0x5F read format.

build_read_register(reg, length \\ 1)

@spec build_read_register(byte(), pos_integer()) :: binary()

Builds the SPI packet to read length bytes starting from register reg. Address format: Bit 7 = 1 (read), Bits 6:0 = register address.

build_write_fifo(data)

@spec build_write_fifo(binary()) :: binary()

Builds the SPI packet to write data into the FIFO buffer. Uses pseudo-register 0x5F write format.

build_write_register(reg, val)

@spec build_write_register(byte(), byte()) :: binary()

Builds the SPI packet to write val to register reg. Address format: Bit 7 = 0 (write), Bits 6:0 = register address.

change_register_bits(spi, reg, mask, value)

Modifies specific bits in register reg using a mask and value. new_value = (current_value & ~mask) | (value & mask)

clear_register_bits(spi, reg, bits)

Clears the specified bit flags in register reg.

execute_command(spi, cmd)

Executes a direct command on the chip.

read_fifo(spi, length)

Reads length bytes from the chip's FIFO.

read_multiple_registers(spi, start_reg, length)

Reads length multiple registers sequentially (auto-increment read).

read_register(spi, reg)

Reads a single byte from register reg.

set_register_bits(spi, reg, bits)

Sets the specified bit flags in register reg.

write_fifo(spi, data)

Writes raw binary payload data into the chip's FIFO.

write_register(spi, reg, val)

Writes a single byte val to register reg.