air
Member level 3
I am learning c for embedded system programming. I have 5 questions list below. I'll appreciate it if someone can explain some of them or even all. Or can someone recommend me some references to leanr these conventions?
1 what is this convention like this: (copy from Hi-tech c)
#ifndef _PIC_H
#define _PIC_H
especially the underscore puzzles me a lot.
2. what is the signs &, *, +, @ , and the parenthesis of (unsigned) mean in the following (from Hi-tech)
static bit LCD_RS @ ((unsigned)&PORTA*8+2);
3. what does this statment mean? (from Hi-tech c)
#define LCD_STROBE ((LCD_EN = 1),(LCD_EN=0))
4. What is the underscore and < ....> mean? (from sourceboost C)
#define _LCD_Read LCD_Read <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
5. who can explain
_LCD_TEMPL and template
in the part of the program as following: (from sourceboost C)
......
// These macros make susequent code more readable, but can seem a little confusing
#define _LCD_RawWriteNibble LCD_RawWriteNibble <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_RawWriteNibbleInline LCD_RawWriteNibbleInline <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_Read LCD_Read <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_WaitForNotBusy LCD_WaitForNotBusy <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_Write LCD_Write <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_FunctionMode LCD_FunctionMode <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_DataMode LCD_DataMode <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_RawWrite LCD_RawWrite <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_ClockOut LCD_ClockOut <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_TEMPL template < unsigned char InterfaceType,\
unsigned char UseBusy,\
unsigned int DataPort, unsigned int Data_PortTris,\
unsigned int CtrlPort, unsigned int Ctrl_PortTris,\
unsigned char RS, unsigned char RW, unsigned char E>
_LCD_TEMPL
inline void LCD_FunctionMode( void )
{
volatile bit rs@CtrlPort.RS = 0;
}
_LCD_TEMPL
inline void LCD_DataMode( void )
{
volatile bit rs@CtrlPort.RS = 1;
}
......
1 what is this convention like this: (copy from Hi-tech c)
#ifndef _PIC_H
#define _PIC_H
especially the underscore puzzles me a lot.
2. what is the signs &, *, +, @ , and the parenthesis of (unsigned) mean in the following (from Hi-tech)
static bit LCD_RS @ ((unsigned)&PORTA*8+2);
3. what does this statment mean? (from Hi-tech c)
#define LCD_STROBE ((LCD_EN = 1),(LCD_EN=0))
4. What is the underscore and < ....> mean? (from sourceboost C)
#define _LCD_Read LCD_Read <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
5. who can explain
_LCD_TEMPL and template
in the part of the program as following: (from sourceboost C)
......
// These macros make susequent code more readable, but can seem a little confusing
#define _LCD_RawWriteNibble LCD_RawWriteNibble <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_RawWriteNibbleInline LCD_RawWriteNibbleInline <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_Read LCD_Read <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_WaitForNotBusy LCD_WaitForNotBusy <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_Write LCD_Write <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_FunctionMode LCD_FunctionMode <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_DataMode LCD_DataMode <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_RawWrite LCD_RawWrite <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_ClockOut LCD_ClockOut <InterfaceType, UseBusy, DataPort, Data_PortTris, CtrlPort, Ctrl_PortTris, RS, RW, E>
#define _LCD_TEMPL template < unsigned char InterfaceType,\
unsigned char UseBusy,\
unsigned int DataPort, unsigned int Data_PortTris,\
unsigned int CtrlPort, unsigned int Ctrl_PortTris,\
unsigned char RS, unsigned char RW, unsigned char E>
_LCD_TEMPL
inline void LCD_FunctionMode( void )
{
volatile bit rs@CtrlPort.RS = 0;
}
_LCD_TEMPL
inline void LCD_DataMode( void )
{
volatile bit rs@CtrlPort.RS = 1;
}
......