/* * Event processing function */ EXPORT INT sdEventFn(INT evttyp, void *evtinf, GDI gdi) { ER er; DrvTab *drv; drv = CheckDrvTab(GDI_exinf(gdi), GDI_devid(gdi)); if (! drv) return E_NOEXS; switch (evttyp) { case TDV_SUSPEND: er = SuspendReq(drv); break; case TDV_RESUME: er = ResumeReq(drv); break; case TDV_CARDEVT: Lock(&drv->ProcLock); drv->CurSUnit = 0; er = sdCardEvent(evttyp, evtinf, gdi); Unlock(&drv->ProcLock); break; case TDV_USBEVT: er = E_NOSPT; break; default: /* Undefined event */ er = E_PAR; } return er; }
int main(void) { // Initialize ChibiOS halInit(); chSysInit(); // Initialize uGFX gfxInit(); // Initialize our own stuff startupInit(); // Get the command prompt (via USB) up and running cmdCreate(); // Get the SD-Card stuff done sdcardInit(); while (true) { cmdManage(); if(SDU1.config->usbp->state == USB_ACTIVE){ gwinShow(ghImageUSB); } else { gwinHide(ghImageUSB); } // Until the statusbar widget is ready... gwinSetVisible(ghImageSDC, sdcardReady()); sdCardEvent(); chThdSleepMilliseconds(500); } }