| Intellicom User's Manual |
4. Software
Dynamic C is an integrated development system for writing embedded software. It runs on an IBM-compatible PC and is designed for use with Z-World controllers and other controllers based on the Rabbit microprocessor.
Chapter 4 provides the libraries, function calls, and sample programs related to the Intellicom.
4.1 Dynamic C Libraries
With Dynamic C running, click File > Open, and select Lib. The following list of Dynamic C libraries and library directories will be displayed.
Two library directories are specific to the Intellicom.
- ICOM--libraries associated with features specific to the Intellicom unit.
- TCPIP--libraries specific to using TCP/IP functions on the Intellicom board.
Other functions applicable to all devices based on the Rabbit 2000 microprocessor are described in the Dynamic C Premier User's Manual.
4.1.1 Library Directories
The ICOM directory contains libraries required to operate the Intellicom unit.
- ICOM.LIB--This library supports OP6600 and OP6700 Intellicom boards only. The functions in this library are described in this chapter.
The TCPIP directory contains libraries with generic TCP/IP functions.
- ARP.LIB--address resolution protocol functions.
- BOOTP.LIB--bootstrap protocol functions.
- BSDNAME.LIB--BSD-style socket routines.
- DCRTCP.LIB--TCP/IP functions.
- DNS.LIB--handles host name resolution.
- FTP_CLIENT.LIB--FTP client functions.
- FTP_SERVER.LIB--FTP server functions.
- HTTP.LIB--HTTP handler.
- ICMP.LIB--ICMP handler.
- IP.LIB--handles the network layer (just above the link layer and the device driver).
- MD5.LIB--implements the MD5 algorithm defined in TCP/IP RFC 1321.
- NET.LIB--general networking API. This is the "top-level" library for the networking library suite. It includes the packet-driver interface.
- PKTDRV.LIB--packet driver functions.
- POP3.LIB--POP3 functions.
- REALTEK.LIB--packet driver functions for the RealTek RTL8019AS.
- SMTP.LIB--SMTP handler.
- TCP.LIB--transmission control protocol.
- UDP.LIB--user datagram protocol.
- VSERIAL.LIB--virtual Telnet functions.
- ZSERVER.LIB--miscellaneous TCP/IP server data structures and routines.
The functions in these libraries are described in the Dynamic C TCP/IP User's Manual included in the manual set with the Dynamic C Premier User's Manual. Additional TCP/IP libraries are added on an ongoing basis.
4.2 Intellicom Function APIs
4.2.1 Board Initialization
void brdInit (void);
- Initializes port registers for the operation of the board. Call this function at the beginning of the application.
- None
dispInit, keyInit4.2.2 Digital I/O
void digOut (int channel, int value);
- Sets the state of a digital output.
- channel is the output channel number (0, 1, 2, or 3).
- value is the output value (0 or 1).
- None.
digIn
int digIn (int channel);
- Reads the state of a digital input.
- channel is the input channel number (0, 1, 2, or 3).
- The state of the input (0 or 1).
digOut4.2.3 Serial Communication
Library files included with Dynamic C provide a full range of serial communications support. The RS232.LIB library provides a set of circular-buffer-based serial functions. The PACKET.LIB library provides packet-based serial functions where packets can be delimited by the 9th bit, by transmission gaps, or with user-defined special characters. Both libraries provide blocking functions, which do not return until they are finished transmitting or receiving, and nonblocking functions, which must be called repeatedly until they are finished. For more information, see the Dynamic C Premier User's Manual and Technical Note 213, Rabbit 2000 Serial Port Software.
The following function calls are specific to the Intellicom.
int serMode (int mode);
- User interface to set up up serial communication lines for the Intellicom board. Call this function after serXOpen().
- mode is the defined serial port configuration of the devices installed.
- 0 if correct mode, 1 if not.
serB485Tx, serB485Rx
void serB485Tx();
- Sets pin 3 (DE) high to disable Rx and enable Tx.
serMode, serB485Rx
void serB485Rx();
- Resets pin 3 (DE) low to enable Rx and disable Tx.
serMode, serB485Tx4.2.4 Keypad Controls
void keyProcess (void);
- Scans and processes keypad data (up to 8 × 8 matrix) for key assignment, debouncing, press and release, and repeat. Provides debouncing, user-definable key code, separate press and release code (both optional), two- and three-speed auto repeat.
- None.
keyConfig, keyGet, keypadDef
void keyConfig (char cRaw, char cPress, char cRelease, char cCntHold, char cSpdLo, char cCntLo, char cSpdHi );
- Assigns user-defined keys to keypad positions. Defines ticks for key debouncing and speed.
- cRaw is the Raw Key Code Index, a 2 × 6 keypad matrix with the following raw keycode index assignments.
- cPress is the Key Press Code, an 8-bit value returned when a key is pressed (0 = Unused). See keypadDef for default press codes.
- cRelease is the Key Release Code, an 8-bit value to be returned when a key is released (0 = Unused).
- cCntHold is Hold Ticks, how long to hold before repeating (0 = No Repeat).
- cSpdLo is Low-Speed Repeat Ticks, how many times to repeat (0 = None).
- cCntLo is Low-Speed Hold Ticks, how long to hold before going to high-speed repeat (0 = Slow Only).
- cSpdHi isHigh-Speed Repeat Ticks, how many times to repeat after low-speed repeat (0 = None).
- None.
keyProcess, keyGet, keypadDef
char keyGet (void);
- Gets next keypress.
- The next keypress, or 0 if none.
keyConfig, keyProcess, keypadDef
void keyInit (void);
- Initializes keypad process.
- None.
brdInit
void keypadDef();
- Configures keypad to default layout:
- [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ . ]
- [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 0 ] [Enter]
None.
keyConfig, keyGet, keyProcess4.2.5 Display Controls
void dispContrast (char vcontrast);
- Sets display contrast.
- Suggested values are 40-128 for high to low contrast, although 4-252 can be used. Contrast adjustment not supported on VFDs.
- None.
dispOnoff, dispBacklight
void dispCursor (unsigned int wStyle);
- Sets cursor type: on, off, or blinking.
- wStyle is one of the following cursor macros:
DISP_CUROFF for cursor off
DISP_CURON for cursor on
DISP_CURBLINK for cursor blink
- None.
dispClear, dispGoto
void dispGoto (unsigned wX, unsigned wY);
- Positions the cursor.
- wX is the column position, 0 to 19.
- wY is the row position, 0 to 3.
- None.
dispClear, dispCursor
void dispClear (void);
- Clears the display and homes cursor.
- None.
dispGoto, dispCursor
void dispPutc (char cByte);
- Puts a character on the display.
- cByte is the character to display.
- None.
dispPrintf
void dispPrintf (char *pcFormat, ...);
- Prints formatted string to the display, similar to printf call.
- pcFormat is the formatted string.
- None.
dispPutc
void dispOnoff (int onOff);
- Turns the display on or off.
- Set or write 1 to turn the display on. Clear or write 0 to turn the display off.
- None.
dispContrast, dispBacklight
void dispBacklight (int onOff);
- Sets the backlight on or off. Not supported on VFDs.
- Set or write 1 to turn the backlight on. Clear or write 0 to turn the backlight off.
- None.
dispContrast, dispOnoff
void dispInit();
- Initializes the display. Specifically, the function reinitializes the display controller, clears the display, and puts a nonblinking underline cursor in the top left position.
brdInit4.2.6 Speaker Controls
void spkrOut (unsigned int wFreq, unsigned int wAmp );
- Outputs speaker frequency and volume with various frequency and voltage values.
- wFreq--suggested frequency values are from 575 Hz to 3,000 Hz: for example, enter 1000 for 1 kHz. Values less than 575 (575 Hz) will be ignored.
- wAmp--voltage amplitude (volume) values are 0, 1, 2, and 3: 0 = off, and 3 = loudest volume.
- None.
4.3 Sample Programs
Sample programs are provided in the Dynamic C Samples folder, which is shown below.
The various folders contain specific sample programs that illustrate the use of the corresponding Dynamic C libraries. For example, the sample program PONG.C demonstrates the output to the STDIO window.
The ICOM and TCPIP folders provide sample programs specific to the Intellicom board. Each sample program has comments that describe the purpose and function of the program. Follow the instructions at the beginning of the sample program.
Let's take a look at the ICOM folder.
- COFTERMA.C--Demonstrates cofunctions, the cofunction serial library, and using a serial ANSI terminal such as Hyperterminal from an available PC COM port connection.
- DEMOBRD1.C--Flashes LEDs on Demonstration Board included in Development Kit. See Appendix D for hookup instructions for the Demonstration Board.
- DEMOBRD2.C--Flashes LEDs on Demonstration Board included in Development Kit and illustrates the Dynamic C runwatch function. See Appendix D for hookup instructions for the Demonstration Board.
- DEMOBRD3.C--Flashes LEDs on Demonstration Board included in Development Kit and demonstrates the use of costatements. See Appendix D for hookup instructions for the Demonstration Board.
- HTTPDEMO.C--Allows a Web browser to view and change the state of the Intellicom board. See Appendix D for hookup instructions for the Demonstration Board.
- ICOM232.C--Demonstrates a simple RS-232 loopback.
- ICOM485.C--Demonstrates a simple RS-485 transmission from master to slave.
- ICOM5WIRE.C--Demonstrates a 5-wire RS-232 loopback in an Intellicom set up for 5-wire RS-232.
- ICOMDEMO.C--Demonstration program to illustrate Intellicom features. This demonstration program comes up when the Intellicom is first powered up before new programs are compiled and run.
- ICOMIO.C--Demonstrates how to turn the digital I/O on and off.
- KEYLCD.C--Demonstrates use of LCD and keypad.
- MBOXDEMO.C--Implements a Web server that allows e-mail messages to be entered and then shown on the LCD display. See Appendix D for hookup instructions for the Demonstration Board.
- MUSIC.C--Speaker demonstration: plays one line of "Bicycle Built For Two" (with lyrics).
- MUSIC2.C--Speaker demonstration: plays one line of "Für Elise" as background music while other processing is going on.
- REMOTE1.C--Demonstrates simple serial data communication using a remote ANSI terminal such as Hyperterminal from an available PC COM port connection.
- SMTPDEMO.C--Uses the TCPIP\SMTP.LIB library to send an e-mail when a key on the keypad or a switch on the Demonstration Board is pressed. See Appendix D for hookup instructions for the Demonstration Board.
- SPEAKER.C--Demonstrates how to adjust the speaker frequency and volume.
- TCP_RESPOND.C--Shows how to receive messages and respond.
- TCP_SEND.C--Shows how to send message to specific addresses and ports.
The programs TCP_SEND.C and TCP_RESPOND.C are meant to be executed on two different Intellicom boards so that the two boards communicate with each other. In the absence of a second board, PCSEND.EXE (used with TCP_SEND.C) and PCRESPOND.EXE (used with TCP_RESPOND.C) in the SAMPLES\ICOM\WINDOWS directory can be used on the PC console side at the command prompt. Both the executables and the C source code are located in the WINDOWS directory.
PCSEND.C is the source code for PCSEND.EXE used on the PC console side to communicate with an Intellicom board. The executable PCSEND.EXE is similar to TCP_SEND.C, but is run at the command prompt to communicate with an Intellicom board running TCP_RESPOND.C.
PCRESPOND.C is the source code for PCRESPOND.EXE used on the PC console side to communicate with an Intellicom board. The executable PCRESPOND.EXE is similar to TCP_RESPOND.C, but is run at the command prompt to communicate with an Intellicom board running TCP_SEND.C.
4.4 Using Dynamic C
To run a sample program, open it with the File menu (if it is not still open), compile it using the Compile menu, and then run it by selecting Run in the Run menu. The Intellicom must be in Program mode (see Section 3.1, "Switching Between Program Mode and Run Mode") and must be connected to a PC using the programming cable as described in Section 4, "Programming Cable Connections".
More complete information on Dynamic C is provided in the Dynamic C Premier User's Manual. TCP/IP-specific functions are described in the Dynamic C TCP/IP User's Manual.
| Z-World http://www.zworld.com Voice: (530) 757-3737 FAX: (530) 757-3792 sales@zworld.com |