Fix compilation bugs; USB MSC isn't working yet

This commit is contained in:
zyphlar
2026-07-04 03:28:12 -07:00
parent 755dd02c3e
commit 181558e7aa
+19 -8
View File
@@ -76,8 +76,9 @@
#define PIN_BTN7 31
#define PIN_BTN8 12
// LED
#define PIN_LED 16
// PIN_LED is 11 (LED_R)
// LED_B is 13/12
// LED_G is 12/13
const uint8_t BTN_PINS[] = {
PIN_BTN1, PIN_BTN2, PIN_BTN3, PIN_BTN4,
@@ -631,7 +632,7 @@ void audioInit() {
// Create a FreeRTOS software timer at 8kHz
// Note: For better timing, use a hardware TIMER peripheral
// This works well enough for 8kHz audio
audioTimer.begin(1000 / 8, audioTimerHandler, true); // ~8kHz
audioTimer.begin(1000 / 8, audioTimerHandler, NULL, true); // ~8kHz
// Better approach: use nrf_drv_timer for precise 125µs intervals
}
@@ -780,8 +781,18 @@ void setup() {
digitalWrite(PIN_LED, HIGH);
Serial.begin(115200);
// Don't block on serial — may not be connected
delay(500);
Serial.println("...");
int c=0;
while(c<10) {
delay(250);
digitalWrite(PIN_LED, LOW);
// Serial.println("0");
delay(250);
digitalWrite(PIN_LED, HIGH);
// Serial.println("1");
c++;
}
Serial.println("=== Baby Mobile v2 ===");
Serial.println("nRF52840 + IS25LP128F + PAM8302A");
@@ -824,9 +835,9 @@ void setup() {
// USB Mass Storage
usb_msc.setID("BabyMobile", "Audio Drive", "2.0");
usb_msc.setReadWriteCallback(msc_read_cb, msc_write_cb, msc_flush_cb);
usb_msc.setStartStopCallback(msc_start_stop_cb);
//usb_msc.setStartStopCallback(msc_start_stop_cb); // unused in nrf?
usb_msc.setCapacity(MSC_BLOCK_COUNT, MSC_BLOCK_SIZE);
usb_msc.setReadOnly(false);
//usb_msc.setReadOnly(false);
usb_msc.setUnitReady(true);
usb_msc.begin();
@@ -835,7 +846,7 @@ void setup() {
g_lastActivity = millis();
digitalWrite(PIN_LED, LOW);
digitalWrite(PIN_LED, HIGH);
Serial.println("Ready! Plug in USB to upload audio, or press a button.");
}