Bibliography

JDR Microdevices 1850 South 10th Street San Jose, CA 95112-4108 (800) 538-5000 (408) 494-1400

PDS-601 link:

http://www.jdr.com/interact/item.asp?itemno=gr-pds

*****************************************************************************************

* Embedded Systons Building Blocks

* Complete and Ready-to-Use Modules in C

* Configuration File

* (c) Copyright 1999, Jean J. Labrosse, Weston, FL

* All Rights Reserved

* Programmer : Jean J. Labrosse *********************************************************************************************************

#include "includes.h"

Listing 1.22 (continued) CFG.C

******************************************************************************************

* KEYBOARD

* INITIALIZE I/O PORTS *********************************************************************************************************

#if M3DULE_KEY_MN

void KeylnitPort (void) {

outp(KEY_FOKT_CW, 0x82); /* Initialize 82C55A: A=OUT, B=IN (COLS), C=OOT (ROWS) */

*********************************************************************************************************

* KEYBOARD

SELECT A ROW

* Description : This function is called to select a rcw on the keyboard.

* Arguments : 'rcw' is the row number (0..7) or KEY_ALL_RCWS

* Note : The rcw is selected by writing a LOW. *********************************************************************************************************

void KeySeLRow CENT8U row) {

*********************************************************************************************************

* KEYBOARD

* READ COLUMNS

* Description : This function is called to read the column port.

* Arguments : none

* Returns : the ccrnplanent of the column port thus, ones are keys pressed *********************************************************************************************************

INT8U KeyGetCol (void) {

return (~inp(KEY_PORT_CQL)); /* Carplement columns (ones indicate key is pressed) */

#endif

************************************************************************************

* MULTIPLEXED LED DISPLAY

* I/O PORTS INITIALIZATION

* Description: This is called by DispInitO to initialize the output ports used in the LED multiplexing.

* Arguments : none

* Notes : 74HC573 8 bit latches are used for both the segments and digits outputs. *********************************************************************************************************

#if M)DULE_IED

void DispInitPort (void) {

outp(DISP_P0KT_SB3, 0x00); outp(DISP_POKT_DIG, 0x00);

*********************************************************************************************************

* MULTIPLEXED LED DISPLAY

* SBaffiNTS output

* Description: This function outputs seven-segment patterns.

* Arguments : seg is the seven-segment patterns to output

*********************************************************************************************************

void DispOutSeg (INT8U seg) {

*********************************************************************************************************

* MULTIPLEXED LED DISPLAY

* DIGIT output

* Description: This function outputs the digit selector.

* Arguments : msk is the mask used to select the current digit.

*********************************************************************************************************

void DispOutDig (INT8U msk) {

outp(DISP_PORT_DIG, msk);

#endif

Listing 1.22 (continued) CFG. C

*************************************************************************

* DCD DISPLAY MDDULE

* INITIALIZE DISPLAY DRIVER I/O PORTS

* Description : This initializes the I/O ports used by the display driver.

* Arguments : none

********************************************************************************************************* */

#if MDDULE_LCD

void DispInitPort (void) {

outp (DISP_EORT_CMD, 0x82); /* Set to Mode 0: A are output, B are inputs, C are outputs */

*********************************************************************************************************

* LCD DISPLAY MDDULE

* WRITE DATA TO DISPLAY DEVICE

* Description : This function sends a single BYTE to the display device.

* Arguments : 'data' is the BYTE to send to the display device

* Notes : You will need to adjust the value of DISP_DLY_CNrs (ICD.H) to produce a delay between

* writes" of at least 40 uS. The display I used for the test actually required a delay of

* 80 uS! If characters seen to appear randomly on the screen, you might want to increase

* the value of DISP_DLY_CWrS. *********************************************************************************************************

void DispEataWr CENT8U data) {

INT8U dly;

outp (DISP_EORT_nATA,

data);

/*

Write

data to display module

*/

outp (DISP_EORT_CMD,

0x01) ;

/*

Set E

line HIGH

*/

DispEurnny (} ;

/*

Delay

about 1 uS

*/

outp (DISP_EORT_CMD,

0x00) ;

/*

Set E

line LOW

*/

for (dly = DISP_DLY_

CNTS; dly > 0; dly—)

( /*

Delay

for at least 40 uS

******************************************************

* LCD DISPLAY MODULE

* SELECT CCMMAND OR DATA REGISTER

* Description : This function read a BYTE frcsn the display device.

* Arguments : none **************************************************************

void DispSel (XNT8U sel) {

outp(DISP_PORT_CMD, 0x02); /* Select the ccrrmand register (RS low) */

outp(DISP_PORT_CMD, 0x03); /* Select the data register (RS high) */

#endif

*********************************************************************************************************

* CLOCK/CALENDAR MDDULE

*********************************************************************************************************

#if MXULELCLK #endif

*********************************************************************************************************

* TIMER MANAGER

*********************************************************************************************************

#if MDDULEJIMR #endif

Listing 1.22 (continued) CFG.C

****************************************************************************

* DISCRETE I/O MODULE

* INITIALIZE PHYSICAL I/Os

* Description : This function is by DIOInitO to initialze the physical I/O used by the DIO driver.

* Notes : The physical I/O is assumed to be an 82C55A chip initialized as follows:

* Port A = OUT (Discrete outputs) (Address 0x0300)

* Control Wbrd (Address 0x0303)

* Refer to the Intel 82C55A data sheet. *********************************************************************************************************

#if MDDULE_DIO

void DIOInitIO (void) {

ou t}? (0x0303, 0x82); /* Port A = CUT, Port B = IN, Port C = OUT */

*********************************************************************************************************

* DISCRETE I/O MDDULE

* READ PHYSICAL INPUTS

* Description : This function is called to read and map all of the physical inputs used for discrete

* inputs and map these inputs to their appropriate discrete input data structure.

********************************************************************************************************* */

/* Point at beginning of discrete inputs */

**************************************************************

* DISCRETE I/O MDOJLE

* UPDATE PHYSICAL OUTPUTS

* Description : This function is called to map all of the discrete output channels to their appropriate

* physical destinations.

*********************************************************************************************************

outp(0x0300, out);

#endif

/* Point at first discrete output channel */

/* Output port image to physical port

Listing 1.22 (continued) CFG.C

********************************************************************

* ANALOG I/O MDDULE

* INITIALIZE PHYSICAL I/Os

* Description : This function is called by AlOInitO to initialize the physical I/O used by the AIO

********************************************************************************************************* */

#if MOCULE_AIO

void AlOInitIO (void) {

/* This is where you will need to put you initialization code for the ADCs and DACs */

/* You should also consider initializing the contents of your DAC(s) to a known value. */

*********************************************************************************************************

* ANALOG I/O MODULE

* READ PHYSICAL INPUTS

* Description : This function is called to read a physical ADC channel. The function is assumed to

* also control a multiplexer if more than one analog input is connected to the ADC.

* Arguments : ch is the ADC logical channel number (0. .AIO_MAX_AI-l) .

* Returns : The raw ADC counts from the physical device. *********************************************************************************************************

INT16S AIRd dNT8U ch) {

/* This is where you will need to provide the code to read your ADC(s) . */

/* AIRdO is passed a 'LOGICAL' channel number. You will have to convert this logical channel */

/* number into actual physical port locations (or addresses) where your MUX. and ADCs are located. */

/* 4) Waiting for the ADC to complete its conversion, */

/* 6) Returning the counts to the calling function. */

* ANALOG I/O MODULE

* UPDATE PHYSICAL OUTPUTS

* Description : This function is called to write the 'raw' counts to the proper analog output device

* (i.e. DAC) . It is up to this function to direct the DAC counts to the proper DAC if more

* Arguments : ch is the DAC logical channel number (0. .AIO_MAX_AQ-l) .

* cnts are the DAC counts to write to the DAC

* Returns : None. ***************************************************************************

void aowt cnnrau ch, nsrrl6s cnts) {

/* This is where you will need to provide the code to update your DAC is). */

/* AOWrO is passed a 'LOGICAL' channel number. You will have to convert this logical channel */ /* number into actual physical port locations (or addresses) where your DACs are located. */

/* ACWr() is responsible for writing the counts to the selected DAC based on a logical number. */

#endif

Listing 1.23 CFG. H

*********************************************************************************************

* Embedded Systems Building Blocks

* Complete and Ready-to-Use Modules in C

* Configuration Header File

* (c) Copyright 1999, Jean J. Labrosse, Weston, FL

* All Rights Reserved

* Programmer : Jean J. Labrosse *********************************************************************************************************

****************************************************

* KEYBOARD CONFIGURATION CONSTANTS

* Note: These #defines would normally reside in your application specific code. *********************************************************************************************************

#if

M3DULE_KEY_MN

#define

KEY_BUF_SIZE

10

/*

Size of the KEYBOARD buffer

*/

#define

KEY_MAX_ROWS

4

/*

The maximum number of rows on the keyboard

*/

#define

KEY_MAX_COLS

6

/*

The maximum number of columns on the keyboard

*/

ttdefine

KEY_PORT_ROW

0x0312

/*

The port address of the keyboard matrix ROWs

*/

#define

KEY_PORT_COL

0x0311

/*

The port address of the keyboard matrix COLUMNS

*/

#define

KEY_PORT_CW

0x0313

/*

The port address of the I/O ports control word

*/

#define

KEY_RPT_DLY

20

/*

Number of scan times before auto repeat executes again

*/

#define

KEY_RPT_START_DLY

100

/*

Number of scan times before auto repeat function engages*/

#define

KEY_SCAN_TASK_DLY

50

/*

Number of milliseconds between keyboard scans

*/

#define

KEY_SCAN_TASK_PRIO

50

/*

Set priority of keyboard scan task

*/

#define

KEY_SCAN_TASK_STK_SIZE

1024

/*

Size of keyboard scan task stack

*/

#define

KEY_SHIET1_MSK

0x80

/*

The SHIFT1 key is on bit B7 of the column input port

*/

/*

(A 0x00 indicates that a SHIFT1 key is not present)

*/

#define

KEY_SHIETl_OFFSET

24

/*

The scan code offset to add when SHIFT1 is pressed

*/

#define

KEY_SHIET2_MSK

0x40

/*

The SHIFT2 key is on bit B6 of the column input port

*/

/*

(A 0x00 indicates that an SHIFT2 key is not present)

*/

#define

KEY_SHIET2_OFFSET

48

/*

The scan code offset to add when SHIFT2 is pressed

*/

#define

KEY_SffiFT3_MSK

0x00

/*

The SHIFT3 key is on bit B5 of the column irput port

*/

/*

(A 0x00 indicates that a SHIFT3 key is not present)

*/

ttdefine

KEY_5HIET3_OFFSET

0

/*

The scan code offset to add when SHIFT3 is pressed

*/

#endif

* MULTIPLEXED LED DISPLAY DRIVER CONFIGURATION CONSTANTS

* (Chapter 4) ***********************************************************************************

#if M3DULE_LED

#define DISP_PORT_SB3 0x0300 /* Port address of SEGMENTS output */

#define DISP_PORT_DIG 0x0301 /* Port address of DIGITS output */

#define DISP_N_DIG 8 /* Total number of digits (including status indicators) */

#define DISP_N_SS 7 /* Total number of seven-segment digits */

#endif

*************************************************************************************

* LCD DISPLAY MODULE DRIVER CONFIGURATION CONSTANTS

* {Chapter 5) *********************************************************************************************************

#if M3DULEJXD

#define DISP_DLY_CNTS 100 /* Number of iterations to delay for 40 uS (software loop) */

ttdefine DISP_PORT_DATA 0x0300 /* Port address of the DATA port of the LCD nodule */

#define DISP_PORT_CMD 0x0303 /* Address of the Control Word (82C55) to control RS & E */

#endif

Listing 1.23 (continued) CFG.H

*************************************************************

* ojock/calendar module configuration constants

* (Chapter 6) *********************************************************************************************************

#if M3DULELCLK

»define

CLK_TASK_PRIO

45

/*

This defines the priority of ClkTaskO

*/

»define

CLK_DLY_TICKS

œ_TIOœ_PER_SEC

/*

# of clock ticks to obtain 1 second

*/

»define

CLK_TASK_STK_SIZE

512

/*

Stack size in BYTEs for ClkTaskO

*/

»define

CLK_DATE_EN

1

/*

Enable DATE (»ten 1)

*/

»define

CLK_TS_EN

1

/*

Enable TIME-STAMPS (when 1)

*/

»define

CLK_USE_DLY

1

/*

Task will use OSTimeDly () instead of pend on sen.

#endif

*********************************************************************************************************

* TIMER MANAGER

* {Chapter 7) *********************************************************************************************************

#if M3DULEL1MR

#define TMR_TASK_PRIO

»define TOR_DLY_TIC3<S

512 20

»endif

************************************************************************************************

* DISCRETE I/O MODULE CONFIGURATION CONSTANTS

* (Chapter 8) ****************************************************************************

#if MDDULE_DIO

»define DIO_TASK_PRIO «define DIO_TASK_DLY_TICKS »define DIO_TASK_STK_SIZE

#define DIO_MAX_DI »define DIOJ®X_DO

»define DI_EDGE_EN »define DO_HLINK_MDDE_EN

/* Maximum number of Discrete Input Channels {1. .255) /* Maximum number of Discrete Output Channels (1. .255)

1 /* Enable code generation to support edge trig, (when 1) */

1 /* Enable code generation to support blink mode (when 1) */

*********************************************************************************************************

* ANALOG I/O MODULE CONFIGURATION CONSTANTS

* (Chapter 10) *********************************************************************************************************

»if MODOLE_AIO

»define AIO_TASK_PRIO

»define AIO_TASK_DLY

»define AIO_TASK_STK_SIZE

»define AIO_MAX_AI

»define AIO_MAX_AO

8 /* Maximum number of Analog Input Channels (1. .250) */

8 /* Maximum number of Analog Output Channels (1. .250) */

»endif

Listing 1.23 (continued) CFG.H

****************************************************************

* ASYNCHRONOUS SERIAL CCMMDNICATICNS MODULE CONFIGURATION CONSTANTS

M3DULE_CCWM_PC

#define CCMM1_BASE #define CCMM2_BASE

0x03F8 0x02F8

/* Base address of PC's OCML /* Base address of PC's CCM2

#define CCWM_MAX_EX #endif

/* Maximum number of characters in Rx buffer of I* ... NS16450 UART. 2 for 16450, 16 for 16550.

#if tO^ULE_CCMM_BGND

#define CCMML #define CCWM2

#define #define

CCMM_RX_BUF_SIZE CCWM_TX_BUF_SIZE

64 64

/* Number of characters in Rx ring buffer /* Number of characters in Tx ring buffer

#endif

MDEULE_CCMM_RIOS

#define CCMM1 #define CCMM2

#define ft define

<XMM_RX_BUF_SIZE CCMM_TXBUF_SIZE

64 64

/* Number of characters in Rx ring buffer /* Number of characters in Tx ring buffer

#endif

*********************************************************************************************************

Btibedded Systems Building Blocks Caiplete and Ready-to-Use Modules in C

^faster Include File

(c) Copyright 1999, Jean J. Labrosse, Weston, FL All Rights Reserved

INCLUDES.H Jean J. Labrosse

*********************************************************************************************************

*************************************************************

* CONSTANTS

*********************************************************************************************************

*************************************************************

* CONSTANTS

*********************************************************************************************************

/*

M3DULE ENABLED (1) or DISABLED (0)

* /

#define

M3EULE_KEY__MN

1

/*

Keyboard module

* /

#define

MDEXJLE_LED

0

/*

Multiplexed LED module

*

#define

MDDULE_LCD

1

/*

LCD Character module

* /

#define

MDDULE_CLK

1

/*

Clock/Calendar module

*

#define

MDDULE_ÏMR

1

/*

Timer Manager module

* /

#define

MDIXJLE_DIO

1

/*

Discrete I/O module

* /

#define

MDDULE_AIO

1

/*

Analog I/O module

* /

#define

M3EULE_CCMM_PC

1

/*

Asynchronous Serial Cannunications module

*

#define

MDDULE_CCWM_B«ID

0

/*

Foreground/Background buffered serial I/O

*

#define

MDDULEJXMMJiTOS

1

/*

Real-Time Kernel buffered serial I/O

* /

#define

MDDULE_ELAPSED

1

/*

Elapsed time measurement module

* /

#define

CFG_C

/*

Indicate that application specific code is found in CPG.C

* /

#define

CFG_H

/*

Indicate that configuration #defines is found in CFG.H

* /

*********************************************************************************************************

* constants

*********************************************************************************************************

*********************************************************************************************************

* constants

*********************************************************************************************************

#define FALSE 0 #define TRUE 1

Filename Programmer

Was this article helpful?

0 0

Post a comment