std1.0.0-beta-7 SafeC docs

std :: hal::spi

Struct std::SpiDevice

#include <std/hal/spi.h> source

generic<C: SpiChip> struct SpiDevice {
    &volatile unsigned int base;
    int mode;
    C chip;
}

Fields

§&volatile unsigned int basesource

MMIO base address

§int modesource

SPI mode (0-3)

§C chipsource

Methods

§static struct SpiDevice<C> new(&volatile unsigned int base, int mode)source · definition

Initialize an SPI master at base with the given mode; the chip type comes from the target.

§unsigned char transfer(unsigned char tx)source · definition

Transfer one byte (full-duplex). Returns the received byte.

§void cs_assert()source · definition

Assert chip select (drive low).

§void cs_deassert()source · definition

Deassert chip select (drive high).

§void write([]const unsigned char tx, ?[]unsigned char rx)source · definition

Transfer tx (full-duplex); rx, when given, receives the incoming bytes (up to rx.len of them).

§void read([]unsigned char rx)source · definition

Fill rx (sends 0xFF as dummy TX).