Skip to content

MicroCS 1.12.0 — Peripheral configuration and DMA (HAL API v3)

Choose a tag to compare

@github-actions github-actions released this 11 Oct 12:06
82789c9

Try it without installing anything: MicroCS Studio in Chrome or Edge, connected to a board flashed with one of the files below.

Board File How to flash
Raspberry Pi Pico / Pico 2 / RP2040-Zero microcs-1.12.0-<board>.uf2 hold BOOTSEL, plug in, copy the file to the RPI-RP2 drive
ESP32 / ESP32-S3 / ESP32-C2 / ESP32-C3 / ESP32-C6 microcs-1.12.0-<chip>.bin esptool.py --chip <chip> write_flash 0 microcs-1.12.0-<chip>.bin
STM32 Nucleo-F401RE / F411RE / F446RE / G474RE / L476RG / H743ZI microcs-1.12.0-nucleo_<board>.bin copy the file to the NOD_xxx drive of the Nucleo's ST-LINK (or STM32CubeProgrammer, .hex keeps your files); the console is the ST-LINK virtual COM port
STM32 Black Pill (F411CE) microcs-1.12.0-blackpill_f411ce.bin USB DFU (hold BOOT0, reset): dfu-util -a 0 -s 0x08000000:leave -D microcs-1.12.0-blackpill_f411ce.bin, or ST-LINK; console = USART1 (PA9 TX, PA10 RX) via a USB-serial adapter
Linux x64 mcs-1.12.0-<os>.tar.gz compiler, REPL and simulator: ./mcs --repl --sim
Threads Pico / Pico 2 / RP2040-Zero and ESP32 files run FreeRTOS (SMP on dual cores): Thread.RunOn(1, …) and jobs.cfg jobs use real threads; STM32 files are bare-metal
ESP32-C2 note built for a 40 MHz crystal (ESP-IDF default); boards with a 26 MHz ESP8684 need a rebuild with CONFIG_XTAL_FREQ_26=y
Arduino IDE MicroCS-1.12.0.zip Sketch → Include Library → Add .ZIP Library
  • Configuration objects for every peripheral. GpioConfig, UartConfig, I2cConfig,
    SpiConfig, QspiConfig, PwmConfig and AdcConfig carry the settings a vendor SDK takes in
    its init struct — pins, pulls, slew rate / speed, drive strength, Schmitt trigger, pad hold,
    hardware inversion, glitch filters, initial output level, alternate functions, buffer sizes,
    RS-485, three-wire SPI, sampling delay, ADC attenuation / oversampling, PWM resolution /
    polarity / centre alignment, DMA on / off. New overloads: GPIO.Configure, new Pin(pin, cfg),
    pin.Configure, UART.Open(port, cfg), I2C.Open(bus, cfg), SPI.Open(bus, cfg),
    new SpiDevice(bus, cs, cfg), QSPI.Open(bus, cfg), PWM.Configure, ADC.Configure.
    Unset properties stay at the board default; values are range-checked on assignment; a board
    that cannot honour a setting throws NotSupportedException / ArgumentException with the
    reason (DriveMa: 2, 4, 8 or 12 mA). Nothing is silently ignored.
  • Board options: chip-specific settings by name (cfg.Set("queue_size", 8)), listed with
    their range and help by Hal.Options([peripheral]).
  • DMA and asynchronous transfers. DmaBuffer (DMA-capable memory), SPI.TransferAsync / WriteAsync / ReadAsync, I2C.WriteAsync / ReadAsync / WriteReadAsync, UART.WriteAsync / ReadAsync, QSPI.ReadAsync / WriteAsync, device-object variants, and Dma.Copy / Fill / CopyAsync / FillAsync / WaitAll. Each returns a DmaTransfer (Wait, OnComplete,
    Cancel, Result, Error). Transfers stay in order per bus, keep their buffers alive and
    complete through the event queue, never in an interrupt. Synchronous SPI.Write / Read and
    QSPI.Read accept DmaBuffers of any size. Boards without DMA run the same calls
    synchronously, so scripts are portable. Hal.Has("DMA.SPI") & co. tell what really runs in
    the background.
  • ESP32 port: everything — runtime pins for UART / I²C / SPI / QSPI / PWM (no more C pin
    tables needed), GPIO filters (pin and flex glitch filters), hold, invert, drive; UART buffers,
    inversion, RS-485 half duplex, RX timeout; I²C pull-ups and filter; SPI three-wire, input delay,
    max transfer; LEDC resolution / invert; ADC attenuation / resolution / oversampling; SPI and
    QSPI transfers on DMA, async memcpy on GDMA chips, DmaBuffer in internal DMA-capable RAM.
  • RP2040 / RP2350 port: GPIO pulls, drive, slew, Schmitt, alternate function, invert (pad
    overrides or software), glitch-free initial level; runtime UART / I²C / SPI pins, UART
    inversion and RTS / CTS, I²C spike filter, pull-ups and timeout; PWM resolution, polarity and
    phase-correct mode; ADC oversampling; SPI transfers and memory copy / fill on DMA.
  • STM32 port: GpioConfig (pull, speed, open drain, alternate function) and PwmConfig
    (polarity, centre-aligned). Zephyr, Arduino and Cortex-M keep the basic settings.
  • Simulator implements and validates every setting and runs DMA transfers through the event
    queue, so scripts can be tested on a PC (mcs --sim --sim-virtual).
  • C API: MCS_HAL_API_VERSION 3. New optional mcs_hal_t members (*_configure, options,
    dma_alloc / dma_free / dma_align / dma_channels, dma_copy, dma_abort,
    spi_transfer_async, i2c_transfer_async, uart_write_async, uart_read_async,
    qspi_command_async), mcs_*_config_init(), mcs_hal_opt(), mcs_hal_error(),
    MCS_HAL_EV_DMA; MCS_HAL_MAX_DMA, MCS_HAL_MAX_OPTS and MCS_ENABLE_HAL_DMA (leave the DMA
    classes out, ~11 KB; off in the 256 KB Cortex-M0 reference build) in mcs_user_config.h;
    mcs_userdata_of(). A port can return MCS_HAL_ENOTSUP from an async call to get the
    synchronous fallback. Board tables written for v1 / v2 compile and work unchanged.
  • Docs: Peripheral configuration, DMA, step-by-step
    guides for peripheral settings and DMA,
    example 17_config_dma.cs, Studio completions for every new class.