config

Configures a SPI interface. Pin mapping: PA4=NSS PA5=SCK PA6=MISO PA7=MOSI
Author: Johannes Taelman
License: BSD
Github: gpio/spi/config.axo

Inlets

None

Outlets

None

Attributes

combo clock_polarity

combo clock_phase

combo baudrate

combo format

Init
// setup the pins
palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL); // NSS
palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL); // SCK
palSetPadMode(GPIOA, 7, PAL_MODE_OUTPUT_PUSHPULL); // MOSI
// palSetPadMode(GPIOA, 4, PAL_MODE_ALTERNATE(5));// NSS
palSetPadMode(GPIOA, 5, PAL_MODE_ALTERNATE(5)); // SCK
palSetPadMode(GPIOA, 6, PAL_MODE_ALTERNATE(5)); // MISO
palSetPadMode(GPIOA, 7, PAL_MODE_ALTERNATE(5)); // MOSI
static const SPIConfig spicfg = {
    NULL, GPIOA, 4,
    0 attr_clock__polarity attr_clock__phase attr_baudrate attr_format};
spiStart(&SPID1, &spicfg);
Dispose
spiStop(&SPID1);
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
palSetPadMode(GPIOA, 6, PAL_MODE_INPUT_ANALOG);
palSetPadMode(GPIOA, 7, PAL_MODE_INPUT_ANALOG);

Privacy

© 2024 Zrna Research