Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

NIOS-II and USB

Altera_Forum
Honored Contributor II
1,992 Views

Hi all, 

 

I am having a lot of problems getting started with developing for the USB controller on the Microtronix Cyclone Development Board. 

 

The USB controller is a Cypress SL811HS, but how on earth do I "talk" to the controller? Assuming I download the usb_32 example to the FPGA, I should be able to communicate with the controller, but since there are NO (none, zip, nada) code samples it is extremely difficult to get started. 

 

Does anyone have any pointers as to how, and where I can get information about this sort of thing. 

 

btw. Searching for IORD_ALTERA_AVALON_PIO_EDGE_CAP on google, returns 2 results. I guess no-one uses this kind of thing?
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
967 Views

What's the interface to the controller? Parallel data with just latching signals?

0 Kudos
Altera_Forum
Honored Contributor II
967 Views

See, that's a good question. I have no idea what you are talking about. 

 

I naively assumed that since the USB controller is on the same board, and since the project is called usb_32 that I could play with the USB controller as easily as I play with the LEDs and Switches. 

 

Looking at some of the code in the installation of the microtronix board on my PC, I see that there's a "driver" in there. It uses the command "outb (..)" quite a bit. I don't know if the driver works, or what it does, it is as poorly documented as the rest.
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

Sorry forgot it wasn't you're board but off the shelf. 

 

I'd start by searching for that chip to see how it works. Then the next step is to find the signals going to it from the controller IC to the FPGA. Once you know how the controller works then you probably won't need an example. 

 

If they give you drivers (NIOS II I assume), then make sure you have the correct system downloaded to your board. Again, if you can figure out how to use the controller and how it's connected to the FPGA you can develope your own method to talk to it.
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

Thanks, I was hoping that someone had some experience with the Microtronix Cyclone Dev-board. 

 

The thing I was looking for is something similar to this: 

 

void main (void) 

// config USB controller 

 

// set up interrupt control 

IOWR_ALTERA_AVALON_PIO_DATA(USB_BASE, USB_INTERRUPT_CONTROL_REG) 

IOWR_ALTERA_AVALON_PIO_DATA(USB_BASE + 4, ENABLE_SEND | ENABLE_RECV ) 

 

etc. 

}
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

What type of transfers are you doing, byte or burst? 

 

Basically those lines are just cache bypass writes to the parallel interface. Do you have more that you can show (none of that is really USB specific, that's just IO to the parallel interface).
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

Hello, 

 

The missing example source code for the USB device was a mistake on our part while the Cyclone Development Kit for Nios II was being put together. The next release of the Kit will contain the example source code. 

 

In the meantime, a Nios II IDE example software project that makes use of the USB device has been made available in the downloads area. 

 

nios ii microtronix cyclone development board usb test project (http://www.niosforum.com/downloads/examples/mtx_cyc_board_usb_test.zip

 

installation 

 

Unzip the file to 

 

.../altera/kits/nios2/examples/software 

 

usage 

 

1. Create a new Altera Nios II C/C++ Application 

2. Select the ptf file from the usb_32 project for the Microtronix Cyclone Development Board example designs. 

3. Select USB Example at your project template. 

4. Build the project. 

5. Ensure that the usb_32 core is running on the Microtronix Cyclone Development Board 

6. Plug in a USB device (such as a mouse) into the board (J2) 

7. Run the project. 

 

The example code will display information from the device descriptor for the USB peripheral when run. 

 

I hope it helps, Please feel free to contact us for assistance if necessary.
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

Ken, thank you for your mail! 

 

BadOmen, I am hoping to do interrupt transfer, but before I can even start to think about that, I want to know how I communicate with the controller ( then, later, we get to device descriptors etc. but that kind of thing is well-documented elsewhere) 

 

I looked at the old code, and I am now making headway. I&#39;ll post a small example later on http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif  

 

Thank you for your time!
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

OK, so now we got a bit further. I am now able to communicate with the controller. 

 

When searching for info about the SL811HST chip, it seems that everyone is focusing on its Host capabilities. However, reading through the code supplied for NIOS (the old kit) it seems the "driver" is a modification of SL811S chip driver for Linux ( the files are also called SL811S.h/.c ). I am just guessing here, but perhaps, when in slave mode, the SL811HS works just like a SL811S? 

 

From the Microtronix Docs, i can see that I need to move some jumpers around to go into slave mode. I set up the jumpers for slave mode, and hooked up a USB packet analyzer. It works like a charm with my MP3 player, now when I plug in the Dev Board nothing happens. I had the impression that the Device detection mechanism in USB, is some pulldown resistors - so when the Host ( PC ) detects the cable is being plugged in, I would assume that a SETUP token would be sent... BUT.. NOTHING!! NOTHING is sent.. EVER.. when the DevBoard is being plugged in and out. 

 

One thing I thought was weird though, when I plug in the USB w/o power on the Dev Board, two leds light up. It seems that the Board is wired to be powered over USB or something like that.
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

Hello, 

 

One thing you can try is removing one of jumpers J5 and J6, then connect the board. If that doesn&#39;t work, try the other one. Let me know if either configuration works. 

 

You are correct in guessing that the slave mode works like a SL811S. We had a developer get slave mode to work at one point under MicroC/OS-II. I&#39;ll see if we can get that code to you as well. 

 

One side-effect of the way the board is wired up is that some of the USB power makes its way to other areas of the board when connected to a USB host. Don&#39;t count on it to power the whole board reliably though. 

 

Dennis Scott 

Microtronix Datacom Ltd.
0 Kudos
Altera_Forum
Honored Contributor II
967 Views

Tadaaa...  

 

Perhaps there&#39;s a typo somewhere, or perhaps I didn&#39;t read carefully enough 

 

Slave Mode both speeds: 

J3 = Open 

J4 = Open 

 

Full Speed: 

J5 = Open 

J6 = Closed 

 

Low Speed 

J5 = Closed 

J6 = Open 

 

I deduce the Fullspeed/Lowspeed by the presense of Low Speed Keep Alive Packets in the Stream. 

 

Now all I need to figure out is how to get the USB interrupts. I do this: 

 

alt_irq_enable_all(USB_IRQ); 

alt_irq_register (USB_IRQ, NULL, handle_USB_interrupts); 

 

Is that all I need, or... http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif  

 

best Regards  

Morten
0 Kudos
Reply