int _start( int argc, char *argv[]) { printf("USB HDD FileSystem Driver v%d.%d\n", MAJOR_VER, MINOR_VER); if (RegisterLibraryEntries(&_exp_usbmass) != 0) { printf("USBHDFSD: Already registered.\n"); return MODULE_NO_RESIDENT_END; } // initialize the FAT driver if(InitFAT() != 0) { printf("USBHDFSD: Error initializing FAT driver!\n"); return MODULE_NO_RESIDENT_END; } // initialize the USB driver if(InitUSB() != 0) { printf("USBHDFSD: Error initializing USB driver!\n"); return MODULE_NO_RESIDENT_END; } // initialize the file system driver if(InitFS() != 0) { printf("USBHDFSD: Error initializing FS driver!\n"); return MODULE_NO_RESIDENT_END; } // return resident return MODULE_RESIDENT_END; }
int _start(int argc, char** argv) { if(InitFAT() != 0) { printf("Error initializing FAT driver!\n"); return MODULE_NO_RESIDENT_END; } init_ieee1394DiskDriver(); InitFS(); return MODULE_RESIDENT_END; }
int _start(int argc, char** argv) { if(InitFAT() != 0) { printf("Error initializing FAT driver!\n"); return MODULE_NO_RESIDENT_END; } init_ieee1394DiskDriver(); DelDrv(dev_name); AddDrv(&device_driver); #if 0 iop_sys_clock_t lTime; u32 lSecStart, lUSecStart; u32 lSecEnd, lUSecEnd, nbytes; int fd, size, bytesToRead, block_size; printf("trying to open file..."); while((fd=open("sd0:PS2ESDL/SLPM_55052_00.pdi", O_RDONLY))<0){DelayThread(2000);}; nbytes=size=lseek(fd, 0, SEEK_END)/4; block_size=2048*512; lseek(fd, 0, SEEK_SET); printf("Read test start\n" ); GetSystemTime ( &lTime ); SysClock2USec ( &lTime, &lSecStart, &lUSecStart ); void *buffer; if((buffer=malloc(block_size))==NULL) printf("Unable to allocate memory. :(\n"); printf("Read test: %p.\n", buffer); while(size>0){ bytesToRead=(size>(block_size))?(block_size):size; read(fd, buffer, bytesToRead); size-=bytesToRead; } free(buffer); printf("Completed.\n"); GetSystemTime ( &lTime ); SysClock2USec ( &lTime, &lSecEnd, &lUSecEnd ); close(fd); printf("Done: %lu %lu/%lu %lu\n", lSecStart, lUSecStart, lSecEnd, lUSecEnd ); printf("KB: %ld, time: %ld, Approximate KB/s: %ld.\n", (nbytes/1024), (lSecEnd -lSecStart), (nbytes/1024)/(lSecEnd -lSecStart)); #endif return MODULE_RESIDENT_END; }
int main (void) { unsigned char i; unsigned char playfile; unsigned char SD_State_Old = 255; /* Initialize */ SYS_ConfigureOscillator(); Init_App(); Init_System(); PWM_SetColor(OFF); RTCC_SetTime(); /* Display Banner */ UART_DisplayBanner(); /* Play start up message out of debug port */ UART_DEBUG_SendStringConstCRLN("Starting..."); /* Display status of PIR sensor */ if(PIR_STATUS) { UART_DEBUG_SendStringConstCRLN("PIR sensor initialized"); } else { UART_DEBUG_SendStringConstCRLN("PIR sensor not working"); } /* Flash LEDS */ MSC_RedLEDOFF(); for(i=0; i<20;i++) { PWM_SetColor(i>>1); MSC_RedLEDTOGGLE(); MSC_DelayUS(50000); } MSC_RedLEDOFF(); /* Play start-up song */ DAC_Play_Startup(); PWM_SetColor(RED); /* Read Voltage rails */ ADC_ReadVIN(); ADC_ReadFiveVoltRail(); while(1) { //RTCC_Read(&CurrentTime); /* SD card routine */ if(SD_CardPresent()) { SD_POWER(ON); if(SD_State == NOT_INITIALIZED) { if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("Initializing SD Card"); } InitSD(); } else if(SD_State == INITIALIZED) { if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("Searching the FAT32 partition for WAV files"); } if(InitFAT()) { UART_DEBUG_SendStringConstCRLN("SD card is correctly formatted FAT32 and contains WAV files"); SD_State = WAV_READY; } } else if(SD_State == WAV_READY) { if(Valid_Wav) { /* there are WAV files to be played */ if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("Ready to play WAV"); } PWM_SetColor(GREEN); if(Motion == TRUE || DoorOpened == TRUE) { UART_DEBUG_SendStringConstCRLN("Motion Detected: Selecting random file for playback"); playfile = (unsigned char)TMR_RandomNum((long)WaveFilesNumLow,(long)WaveFilesNumHigh); /* Check to see if the file is marked as valid */ while(ValidWAVFiles[playfile] != PASS) { if(playfile >= WaveFilesNumHigh) { playfile = 0; } else { playfile++; } } PWM_SetColor(BLUE); PIR_Interrupt(OFF); UART_DEBUG_SendStringConst("Playing WAV file: "); UART_DEBUG_SendStringConstCRLN(&FileList[playfile].name); if(WAV_PlayFile_Random_Sector(playfile)) { UART_DEBUG_SendStringConstCRLN("Wav played successfully"); } else { UART_DEBUG_SendStringConstCRLN("Wav failed"); if(SD_CardPresent() == FAIL) { SD_State = NOT_INITIALIZED; UART_DEBUG_SendStringConstCRLN("SD card removed"); } } Motion = FALSE; DoorOpened = FALSE; PIR_Interrupt(ON); PWM_SetColor(GREEN); MSC_RedLEDOFF(); } } else { /* there are no satisfactory WAV files on the card */ if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN(" WAV files are corrupted"); } /* Reinitialize */ SD_State = NOT_INITIALIZED; } } } else { SD_State = NOT_INITIALIZED; if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("No SD card found"); } if(Motion == TRUE || DoorOpened == TRUE) { PIR_Interrupt(OFF); MSC_RedLEDON(); PWM_SetColor(WHITE); MSC_DelayUS(50000); Motion = FALSE; DoorOpened = FALSE; PIR_Interrupt(ON); } MSC_RedLEDOFF(); SD_POWER(OFF); PWM_SetColor(RED); } SD_State_Old = SD_State; } }