83Plus:OS:84 Plus USB Information
OK, I've started this talk page to post information about the 84 Plus USB. This isn't the ideal place, since not all of this stuff has to do with entry point 5254, but it'll have to do. If anyone else would like to contribute any information or thoughts, please do so. Much of this data has been discovered by analyzing how the EasyData application interacts with the EasyTemp probe. --Dan Englender 22:32, 23 May 2005 (PDT)
Contents
Easy Data
The USB entry points that Easy Data uses are:
5254 5257 525A 525D 5260
These routines return carry flag with an error code in A on failure, or no carry on success. On success they return BC=(9C16), DE=(9C1A), and HL=(9C18). I have no idea what these values are.
The entry points seem to be called only on initialization and quit. On initialization 5254 then 525D are called, and then 525A six times. On quit, 5254, then 5260, then 5257 are called.
5254
The 5254 entry point seems to take a callback address to be passed in A (page) and HL (address). That callback address appears to be called on quit, after 5257 is called.
5260 and 5257
The 5260 and 5257 entry points are called right after each other in the code, and don't seem to take any input. I guess they're some kind of USB shut down. 5260 doesn't do much of anything other than set 9C1E to 0000. 5257 plays with the ports some, and then clears the callback address. Since the call back address gets called, I'm assuming it must also call the callback address somewhere in there.
525A and 525D
525A and 525D take some kind of pointer in HL. I'm not sure what yet. The 525D entry point first checks to see if bit 3 of port 4C and bits 0 and 2 of port 8F are set. If they are not, it returns failure. These bits are not set by, say, plugging in the hardware. They are set, however, after 5254 has been called. After checking these bits, 9C1E is set to the passed value of HL. If this value is zero, the routine will return failure. A value of 1 will be stored to HL+2, then a value of 1 will be output to port 8E, a value of 20h to port 94h, and success will be returned.
5290
A BCALL to 5290 alone is enough to turn on the LED on EasyTemp. (Though it turns on to a strange orange color which is never seen during EasyData execution). It must do some sort of USB initialization type stuff. If bit 3,(iy+41) is set, 5290 will fail. So this must either be a USB-already-initialized flag, or a Don't-Use-USB flag I guess.
Other
The callback routine appears to recieve some kind of input in B. I'm not sure what yet.
I'm, err, not exactly clear at this point how the app actually gets the temperature data from the EasyTemp probe, as the entry point seem to only be called on init and quit. The callback routine seemed a likely candidate, but it's not that either. Maybe there's something going on in the interrupt that I'm not aware of. Or maybe there are some more entry points used that I missed.
4087 Header
The calculator knows to run EasyData when the Probe is plugged in because it includes a special header at address 4087h. The format is as follows:
db 096h, 0E2h, 00h, 01h dw TablePtr ..... TablePtr: db 01h, 00h, 03h, 00h, 93h, 40h db 03h, 80h, 03h, 00h, 0F7h, 08h, 02h, 00h, 80h, 03h, 00h, 0F7h db 08h, 03h, 00h, 80h, 03h, 00h, 0F7h, 08h, 04h, 00h, 00h, 00h
The "93h, 40h" on the third to last line is probably a pointer, and it would point to the second to last line. I will verify this later.
50EF
The 50EF BCALL reads the 4087 Header. It is used by the OS.
5263
The 5263 BCALL reads the 4087 Header. it is used by the OS.
Hardware
Ports 55h and 56h are initially polled in the interrupt routine to determine USB activity. If activity is detected, 4Dh, 82h, 84h, 86h, 8Fh, 91h, and others may be polled as well.
Port 56
The default value for port 56h is 00. If the USB-B plug (peripheral) is plugged into the port with no connection on the other side, nothing happens. If there is a connection on the other side, bit 6 will be set. If the USB-A plug (host) is plugged into the port bit 4 will be set, regardless of whether there is a device on the other side. If you plug one connector in, unplug, and then plug the other connector in without doing whatever the interrupt routine does to acknowledge the USB status, you will get both bits 4 and 6 set. This should probably never happen in practice.