config

Configures a serial (uart) interface on pins PA2 (TX) and PA3 (RX), using the SerialDriver API.
Author: Johannes Taelman
License: BSD
Github: gpio/serial/config.axo

Inlets

None

Outlets

None

Attributes

combo baudrate

Init
// setup the pins
// PA2 : TX
// PA3 : RX

palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7) | PAL_MODE_INPUT); // RX
palSetPadMode(GPIOA, 2, PAL_MODE_OUTPUT_PUSHPULL);               // TX
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));                  // TX
// 9600 baud
static const SerialConfig sd2Cfg = {attr_baudrate, // baud
                                    0, 0, 0};
sdStart(&SD2, &sd2Cfg);
Dispose
sdStop(&SD2);
palSetPadMode(GPIOA, 2, PAL_MODE_INPUT_ANALOG);
palSetPadMode(GPIOA, 3, PAL_MODE_INPUT_ANALOG);

Privacy

© 2024 Zrna Research