Realistically, would you ever use USB in a C / ICE program?
No
 2%  [ 1 ]
Only if HID / FAT (keyboard, mouse, flash drive) drivers existed
 45%  [ 16 ]
Even if only the functions in usbdrvce.h were implemented (link in top post)
 51%  [ 18 ]
Total Votes : 35

(The usbdrvce.h mentioned in the poll is part of the CE-Toolchain)

It's probable this won't get very far, but even in that case at least I will learn something.

I hope to write a USB driver for the CE based on U-Boot's USB drivers.

The first problem I have encountered is that I have no idea what the USB controller is doing either on CEmu or on a physical calc. Does anyone know of a way to see what packets are sent? I don't know how to debug otherwise.
You *could* use an oscilloscope to see the output from the USB port. However, due to the lowest price being 99 USD and the highest over 14,000 USD, this is only really viable if you can borrow one.
LAX18 wrote:
You *could* use an oscilloscope to see the output from the USB port. However, due to the lowest price being 99 USD and the highest over 14,000 USD, this is only really viable if you can borrow one.

No one really cares about the raw signals from the port, that's all driven by the usb chip. It's kind of like saying you care about the bits going across the ram bus when you are trying to read from memory.
Yes. Yes. And yes again. I will eventually need USB for my CE Star Trek project.
Forgot to post this update until now:

I looked into u-boot a bit more, and the driver does not support isochronous packets. This means it could be used with devices like flash drives, but not USB audio adapters.
I might try this driver from Linux, which supports all four packet types.

Also, jacobly's USB driver does not appear to be linked anywhere on the site besides in IRC. I did not know this existed when I decided to start working on my own program. I haven't had time to try it yet, but I may or may not continue with this project after I do so.
Decided to post an update here because Mateo released his FAT32 library the other day.

I'm still working on USB stuff, but I will use jacobly's driver instead of trying to write my own. My current plan is to make a serial driver that would allow a calculator to communicate with Arduino boards and many other devices. I looked at a packet log of USB serial communication, and it seems incredibly simple. There are bulk endpoints for transferring data in and out and a interrupt endpoint for notifications. Hopefully I can just ignore the interrupt endpoint.
Got a PC serial driver working.
I'm debugging using the most sophisticated hardware known to man:

Hopefully it won't be to hard to do the same thing using host.inc.
lol that's some sophisticated equipment you have! I didn't know Wal-Mart sold those, must've cost millions!

***SM84CE RUUUUUNNNSSSS and HDIES
*HIDES
I'm getting a reset every time I try to send a bulk packet. It's probably a simple mistake on my part, but I'm not really sure how to debug.
Pastebin is here.
The control transfer right above it works fine.
EDIT: Whoops, I was selecting the device configuration rather than the configuration description. Fixed now.
Alright, I think everything is working now. If you want to try it out for yourself and you have a CE, an Arduino, and a USB mini OTG adapter, check out the GitHub repo.

As usual, this isn't fully tested yet, so don't try this if you aren't willing to have your calc reset.

In theory, this should work with any CDC device, including most Arduinos. It's possible that it could work on a modem but I haven't gotten around to trying that yet.
I tried using your serial buffer program, but I get the following abort:
D1AE5A <- D1B343 <- D1AE79 <- D1AF54 <- D1B2D1
Can you figure out what is wrong? Smile
There are still a few bugs with the program, especially when using devices other than an Arduino. I'll try to push a fix for non-Arduino devices today, as I have figured out what the issue is there.

What device are you using? What function does the abort occur in?
I'm using my Arduino Uno. After some more testing, the abort still occurs, but I guess it's because I'm sending too much data. The program aborts about 9.5 seconds after starting sending data with this program:

Code:
const char zero = 0xFF;

void main(void) {
   lineCoding_t lc = {9600, 0, 0, 8};

   os_ClrHome();
   os_PutStrFull("Initializing");
   usb_PrePower(3000);
    os_PutStrFull("Init device");
   if(!srl_InitDevice()) {
        goto err;
    }
    os_PutStrFull("Set config");
   srl_ConfigSerial(&lc);
    os_PutStrFull("Delay");
    delay(50);
    os_PutStrFull("Start sending data");
   
    while (!(kb_Data[1] & kb_2nd)) {
        kb_Scan();
        srl_Write((void*)&zero, 1);
        srl_Write((void*)kb_Data, 18);
        srl_Write(&zero, 2);
        delay(100);
    }
   
err:
    os_PutStrFull("Error happened!");
   usb_Cleanup();
}
I need to be able to switch baud rates in my program, but there isn’t some sort of “srl_End” function. Could you implement that so that the device can be reconfigured?
You should be able to just call srl_ConfigSerial again (while the device is running) to change the baud rate. The only reason that a end function is used with the Arduino is so that pins 1 and 0 can be used as regular inputs/outputs, and that isn't really a concern here.
PT_ wrote:
I'm using my Arduino Uno. After some more testing, the abort still occurs, but I guess it's because I'm sending too much data.

No, the repo just hasn't been updated with the fixes yet.
Super necro update here, but the library broke in a later toolchain version due to a change in how labels are processed. Despite it being fairly easy to fix, I decided to rewrite it as a dynamically linked library similar to graphx or keypadc. The new version can be found on my fork of the toolchain. It's not particularly optimized, as a good bit of it is output from zds from the original version.

I plan on rewriting this again to use the new usbdrvce library rather than host.inc. I also hope to support more devices besides pure ACM/CDC devices, as I've found there aren't many that are. I only have a FTDI chip and a RS232 adapter to test on at the moment.

I've also found that this is compatible with my 3D printer (a Da Vinci AiO), so I might be able to print something out using a calc as a host. Maybe.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement