
209
Chapter 10, How to Build an Internet Toaster
Exhibit B: TCU Firmware Code
Option Explicit
Dim keypad1 as byte
Dim keypad2 as byte
Dim keypad3 as byte
Dim keypad4 as byte
Dim inbuffer1(1 to 20) as byte
Dim outbuffer1(1 to 20) as byte
Dim inbuffer3(1 to 20) as byte
Dim outbuffer3(1 to 20) as byte
Dim ch as byte
dim ch2 as byte
dim lettera as string
Dim letterb as string
dim codea as byte
dim codeb as byte
‘ Toast Control Unit firmware
‘ version 1.0
‘ 5/4/02
‘ Scott Fullam
Public Sub Main()
Call init_ports()
begin:
Call scan_keys()
Call scan_serialport()
GOTO begin
End Sub
Private Sub init_ports()
Call putpin (5, 3)
Call putpin (6,3)
Call putpin (7,3)
Call putpin (8,3)
Call Putpin (9, 0)
call putpin (10, 0)
call openqueue (inbuffer1, 20)
call openqueue (outbuffer1, 20)
call openqueue (outbuffer3, 20)
‘ set up com1 for communications to PC
Call OpenCom(1, 19200, Inbuffer1, Outbuffer1)
call Putqueuestr(Outbuffer1, “Toaster 1.0”)
Exhibit B
ch10_toaster.indd 209
1/13/2002 2:45:04 PM