Skip to content

HOST_QUICKSTART

pschatzmann edited this page Nov 24, 2026 · 3 revisions
#include "USBHostMSC.h"
#include "USBMscFatFS.h"

USBMscFatFS fatFs;
USBHostMSC msc(&fatFs);   // auto-mounts fatFs when a drive is plugged in

void onMount(uint8_t dev_addr) {
  if (fatFs.mounted()) {
    File f = fatFs.fs().open("/hello.txt", "r");
    while (f.available()) Serial.write(f.read());   // Serial1 on RP2040/STM32
  }
}

void setup() {
  Serial.begin(115200);   // Serial1 on RP2040/STM32
  msc.onMount(onMount);
  msc.begin();
}

void loop() { msc.task(); }

More: Block API, Filesystems, Hubs, Installation and boards.

Clone this wiki locally