Download Circuit Cellar, Inc.
Transcript
39 for a similar approach) has two entry points. The main routine is getdsl990(*string), which performs all the steps involved in initializing the DS1990, command signaling, and data extraction using just one wire. Since a one-wire protocol presents the very real potential for acquiring gibberish, a CRC is appended to the DS1990’s datastream to ensure that valid data had been read. The get d s 19 9 0 routine only returns a good result code if all criteria are met for data verification. A bad read is indistinguishable from a no-read as far as the caller is concerned. The other routine in this module is chsckdsl990( 1, whichverifies that the DS1990 is not connected. The routine disconnects only if the initialization (presence detect) routine fails on 250 consecutive passes. This retrying should be enough to reject any contact chatter and indicates that the DS1990 is really not there. The mixed C and assembler module AT. C, found in Listing 2, is the keyboard-emulation driver, which is based on the pure assembler keyboard driver I presented in last month’s column. Providing public entry points for both character and string output, this module handles the initial table manipulations in C and drops into assembler to handle the low-level bit operations most efficiently. This approach illustrates use of the respective languages strengths. There’s no reason the entire program could not be written in C, and last month, I illustrated how it could be all done in assembler. The mix used here represents a reasonable compromisea path of least resistance. I did make one minor change to the fundamental logic I presented last month. As I pointed out, although the PC BIOS does not make use of most of the keys’ break codes, you must realize that many (if not most) of the application programs on the market bypass the BIOS code entirely. Instead, they hook directly into the keyboard controller and make use of its output as they see fit. It seems that certain programs interpret successive make codes as an Listing Z-continued /* Primary ASCII to scan code lookup table */ /* O=control character, Oxff=shifted, else scan code */ static char keytablel[l281 = i oxoo,oxoo,oxoo,oxoo,oxoo,oxoo.oxoo,oxoo, 0x66,0x0d,0x00,0x00,OxOO,Ox5a,OxOO,OxOO, oxoo,oxoo,oxoo,oxoo,oxoo,oxoo,oxoo,oxoo, oxoo,oxoo,oxoo,oxoo,oxoo,oxoo,oxoo,oxoo, 0x29,0xff,Oxff,Oxff,oxff,Oxff,oxff,ox5z* Oxff,Oxff,Oxff,Oxff,Ox4l,Ox4e,Ox49,Ox4a, 0x45,0x16,0x1e,0x26,OxZ5,OxZe,Ox36,Ox3d, 0x3e,0x46,0xff,0x4c,Oxff,Ox55,Oxff,Oxff, Oxff,Oxff,Oxff,Oxff.oxff,oxff,oxff,oxff, Oxff,Oxff,Oxff,Oxff,oxff,oxff,oxff,oxff, Oxff,Oxff,Oxff,Oxff,oxff,oxff,oxff,oxff, Oxff,Oxff,Oxff,0x54,Ox5d,Ox5b,Oxff,Oxff, 0x0e,0x1c,0x32,0x21.Ox23,Ox24,OxZb,Ox34, 0x33,0x43.0x3b.0x42,Ox4b,Ox3a,Ox3l,Ox44, 0x4d,0x15,0x2d,0x1b.Ox2c,Ox3c,OxZa,Oxld, 0x22,0x35,0x1a.Oxff,Oxff,Oxff,Oxff,0x71 I: /* Secondary ASCII to scan code lookup table */ /* All are legal scan codes */ static char keytableZC1281 = 1 (continued) OUR SMALLEST Eliminate the need to burn and learn all in a package about the size of a 9 volt battery -1 l l I 2” l l l l l 1 l l l l 411 Washinaton Street. Otsego, Miclhigan 4907’8 TEL: 616-694-4920 FAX: 616-692-2651 Since 1985 Super small (about 2”xl “xl “) Uses Surface Mount Design Fits in EPROM socket Downloads in less than 7 seconds Emulates 2764, 27 128, 27256, 275 12 Access time <l OONS Plug and Play: Plug cable into computer and download. Once power is supplied to circuit, cable can be removed Includes software for IBM compatable PC’s Loads Intel Hex and Binary files Includes Serial Cable & Battery Backup Nearly same footprint as EPROM CALL NO Wfor Your Special Introductory Price of $194.95 phs $5.00 shipping and band&g VI.%4 C MASTEROlRDACCEmD 37 Circuit Cellar INK Issue #58 May 1995 79