
I am using the VLSI breakout board with power supplied by USB. Is there a way I can send files through these forums in a private message? I looked around and cannot find the option.
Code: Select all
/*
* detect USB supply and start mass storage service if powered from USB
*/
GpioSetAsInput(PINDEF_POWER_DETECTUSB);
if(GpioReadPin(PINDEF_POWER_DETECTUSB))
{
u_int16 *usbmscLib = NULL;
usbmscLib = LoadLibraryP("usbmsc", "E");
if(usbmscLib){
RunLoadedFunction(usbmscLib, ENTRY_MAIN, (int)"E");
do{
newEvent = Button_getEvents();
}while(newEvent == buttonEvents_noEvent); // exit as soon as a button is pressed
DropLibrary(usbmscLib);
}
}
//...continue with regular program
Code: Select all
#include <vo_stdio.h>
#include <volink.h> // Linker directives like DLLENTRY
#include <apploader.h> // RunLibraryFunction etc
#include "usbmsc.h"
#include <taskandstack.h>
#include <kernel.h>
u_int16 *self; //ptr to our own loaded library
s_int16 usbTaskRunning;
//Set absolute location of AddTask in VS1005G ROM. Another option would be to include rom1005g.o in linking.
CHIPSPECIFIC (VS1005G) LINK_ABS (AddTask,36693)
ioresult main(char *parameters) {
int newDevice = parameters ? (*parameters & ~0x20) : 0;
int i=0;
while(1) { //Find our own library reference
self = loadedLib[i++]; //for each loaded library
if (self[2] == (u_int16)main) break; //if library main entry is our main function, then break.
}
self[1]++; //increase our reference count so we are not dropped from memory even if we are started from the commmand line
if (newDevice>='A' && newDevice<='Z') {
newDevice -= 'A';
usbDisk = vo_pdevices[newDevice];
usbTaskRunning = IS_RUNNING;
CreateTaskAndStack(UsbMainLoop, "USBD", 512, 10);
} else {
self[1]=1; //set our own ref count to 1 so we are dropped from memory when main returns (DropLibrary will call fini()).
}
}
void fini(void) {
printf("USBD:Exiting\n");
usbTaskRunning = PLEASE_STOP;
while (usbTaskRunning != NOT_RUNNING) {
Delay(10); //wait for USB task to finish
}
}
Good Luck!S:>usbmscd d
USB publishing disk SD/SD Card.
S:>
[SD card is now visible in the PC]
S:>cd ::
Currently installed system devices are:
- D: 922M SD/SD Card, handled by FAT.
- S: 1920K SPI Flash c814, handled by FAT.
S:>
S:>usbmscd
USBD:Exiting
[SD card is now removed from the PC]
S:>
Code: Select all
RunLoadedFunction(usbmscLib, ENTRY_FINI, 0);
Code: Select all
Driver: USBMSC... E: Symbol _RingBufCopyjZC (CRC32 222a86d1) not found.
1 fatal errors. Stop.