[En-Nut-Discussion] Nut/OS Device Control Block amke errors.

Grahame M. Kelly grahame at wildpossum.com
Tue May 31 05:39:04 CEST 2005


Hi Everyone.

I have a syntax or header problem(s) in trying to build a very simple LCD 
controller structured around the NutOS foundation device driver.

Given the LCD Information Block and its generic Device Control Block are as 
follows:

/*!
 * \brief LCD device information structure.
 */
NUTDEVICE devLcd20 = {
    0,              /*!< Pointer to next device. */
    {'l', 'c', 'd', '2', '0', 0, 0, 0, 0},      /*!< Unique device name. */
    IFTYP_STREAM,   /*!< Type of device. */
    0,              /*!< Base address. */
    0,              /*!< First interrupt number. */
    0,              /*!< Interface control block. */
    &dcb_term,      /*!< Driver control block. */
    TermInit,       /*!< Driver initialization routine. */
    TermIOCtl,      /*!< Driver specific control function. */
    0,
    TermWrite,
    TermWrite_P,
    TermOpen,
    TermClose,
    0
};


/*!
 * \brief Terminal device control block structure.
 */
TERMDCB dcb_term = {

    LcdInit,            /*!< \brief Initialize display subsystem, dss_init. */
    LcdWriteData,       /*!< \brief Write display character, dss_write. */
    LcdWriteCmd,        /*!< \brief Write display command, dss_command. */
    LcdClear,           /*!< \brief Clear display, dss_clear. */
    LcdSetCursor,       /*!< \brief Set display cursor, dss_set_cursor. */
    LcdCursorHome,      /*!< \brief Set display cursor home, dss_cursor_home. 
*/
    LcdCursorLeft,      /*!< \brief Move display cursor left, dss_cursor_left. 
*/
    LcdCursorRight,     /*!< \brief Move display cursor right, 
dss_cursor_right. */
    LcdCursorMode,      /*!< \brief Switch cursor on/off, dss_cursor_mode. */
    0,                  /*!< \brief Mode flags. */
    0,                  /*!< \brief Status flags. */
    2,                  /*!< \brief Number of rows. */
    16,                 /*!< \brief Number of columns per row. */
    16,                 /*!< \brief Number of visible columns. */
    0,                  /*!< \brief Cursor row. */
    0,                  /*!< \brief Cursor column. */
    0                   /*!< \brief Display shadow memory. */
};

Why do I get the following make errors almost throughout this structure.

gmkelly at glider:~/ethernut/nut/app/NutLCD> make
avr-gcc -c -mmcu=atmega128 -Os -Wall -Wstrict-prototypes -Wa,-ahlms=nutlcd.lst 
-D__HARVARD_ARCH__  -I../../include  nutlcd.c -o nutlcd.o

nutlcd.c:50: error: `dcb_term' undeclared here (not in a function)
nutlcd.c:50: error: initializer element is not constant
nutlcd.c:50: error: (near initialization for `devLcd20.dev_dcb')
nutlcd.c:66: error: `LcdInit' undeclared here (not in a function)
nutlcd.c:66: error: initializer element is not constant
nutlcd.c:66: error: (near initialization for `dcb_term.dss_init')
nutlcd.c:67: error: `LcdWriteData' undeclared here (not in a function)
nutlcd.c:67: error: initializer element is not constant
nutlcd.c:67: error: (near initialization for `dcb_term.dss_write')
nutlcd.c:68: error: `LcdWriteCmd' undeclared here (not in a function)
nutlcd.c:68: error: initializer element is not constant
nutlcd.c:68: error: (near initialization for `dcb_term.dss_command')
nutlcd.c:69: error: `LcdClear' undeclared here (not in a function)
nutlcd.c:69: error: initializer element is not constant

Can anyone kindly put me out of my initial misary and offer the solution to 
this C structure puzzle on why make sees 

A> terms undeclared (not in a fuction)?

B> Why the initializer element is not constant?  
I thought the preambled Static would have fixed this.

C> The  near initialization form...?  

i.e.: Simply what do I have to do to remove these make errors.

I second the idea currently floating around that there should be a "standard"
device driver format structure for each and every device, in line with the way
Linux does it IMHO and one vote!

----------------------------------------
Much Thanks. Grahame



More information about the En-Nut-Discussion mailing list