VS1010D USB Host Driver and MP3 play

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Post Reply
User avatar
Panu
VLSI Staff
Posts: 2798
Joined: Tue 2010-06-22 13:43

VS1010D USB Host Driver and MP3 play

Post by Panu » Thu 2021-02-04 10:52

Dear VS1010 users,

Here's a new take on the VS1010 USB Host functionality. The USB host code has been rewritten for VS1010D. Here's a self-contained program that combines USB host functionality with a simple main loop, which repeatedly asks the user to insert a new USB flash memory stick and then plays MP3 files from the root of the flash memory stick.
VS1010>usbplaytest
Please insert USB flash..
VendorID:0781 ProductID:5567
Scan and init filesystem...
Device '15264M USB store' has FAT filesystem, good. Playing *.MP3 from root..

Crockett's Theme 12 inch.mp3

Code: Select all

ioresult main (char *params) {
	int attempts = 0;
	ioresult r;
	PowerSetVoltages((void*)(&regulator));
	VODEV('U') = &usbFlash;
			
	while (lastReceivedCharUart0 != 27) {		
		printf("Please insert USB flash..\n");		
		while (UsbDeviceProbe()) {
			DelayL(10000);
		}

		printf("VendorID:%04X ProductID:%04X\n",Swap16(udp->vid),Swap16(udp->pid));
		printf("Scan and init filesystem...\n");
		
		if (ioctl(&usbFlash, IOCTL_RESTART, NULL) == (IOCTL_RESULT)&FatFileSystem) {
			printf("Device '%s' has FAT filesystem, good. Playing *.MP3 from root..\n", Identify(VODEV('U')));
			shellcmd("play","U:*.MP3");
		} else {
			printf("Init error at ioctl_restart\n");
		}
		
		printf("Done, please remove USB flash..\n");
		
		usbTotalSectors32 = 0;		
		Xvm((void*)resetUsbHostHw); // Set initial state				
		while ((PERIP(USB_UTMIR) & USB_UTMIR_LSTATE) != 0) {
			//Wait for no stick
		}

		printf("USB device disconnected\n");
	}
	VODEV('U') = NULL;
	return S_OK;
}
-Panu
Attachments
usbPlayTest.dlx
Plays MP3 files from USB memory sticks. VS1010 VSOS DLX executable
(8.8 KiB) Downloaded 3 times
arch-usbPlayTest-2021-02-04-10-44-RC1.zip
Source code, VSIDE Solution
(30.9 KiB) Downloaded 5 times
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

User avatar
Panu
VLSI Staff
Posts: 2798
Joined: Tue 2010-06-22 13:43

Re: VS1010D USB Host driver

Post by Panu » Thu 2021-02-04 12:26

Dear All,

Here's the driver proper extracted from the above project. Run this once from the command line or from CONFIG.TXT. It creates an auto-reconfiguring device U: for the USB flash. Uses 1069 words of code memory and 565 words of X data memory.

VS1010>usbhost4
USB: 7377M USB store

VS1010>liblist
0: 0x1000:UsbHost4.dl I[0x80..0x4ad] X[0x1000..0x1249] Y[0x1000..0xfff]
1: 0x124a:LIBLIST.DLX I[0x4ae..0x51f] X[0x124a..0x12cd] Y[0x1000..0xfff]

VS1010>devices
D: SD/SD Card
F: SPI Flash c217
I: STREAM
R: ROMDISK
S: SD/SD Card
U: 7377M USB store

VS1010>dir u:
File list of 7377M USB store u:*
D 1: uc232a_windows_setup_v1.0.084
D 2: vside_cable_driver
3: 01_5AM.MP3
4: 07_Beauty.mp3
5: 10_AndThen.mp3
6: putty-0.72-installer.msi
7: teraterm-4.102.exe
7 file(s) found.

VS1010>
-Panu
Attachments
UsbHost4.dlx
USB Host Driver for VS1010D. Run exactly once from the command line or from config.txt.
(7.65 KiB) Downloaded 3 times
arch-UsbHost4-2021-02-04-12-21-USBHostDriverVS1010.zip
VS1010D USB Host Driver Source Code, VSIDE Solution.
(34.61 KiB) Downloaded 5 times
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Post Reply