📄 init.c
字号:
/* * RTEMS configuration/initialization * * This program may be distributed and used for any purpose. * I ask only that you: * 1. Leave this author information intact. * 2. Document any changes you make. * * W. Eric Norum * Saskatchewan Accelerator Laboratory * University of Saskatchewan * Saskatoon, Saskatchewan, CANADA * eric@skatter.usask.ca * * Additions: * Charles-Antoine Gauthier * Software Engineering Group * Institute for Information Technology * National Research Council of Canada * charles.gauthier@nrc.ca * * $Id: init.c,v 1.8 2002/10/31 05:20:45 ccj Exp $ */#include <bsp.h>#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER#define CONFIGURE_MAXIMUM_TASKS 1#define CONFIGURE_RTEMS_INIT_TASKS_TABLE#define CONFIGURE_MICROSECONDS_PER_TICK 1000#define CONFIGURE_INITrtems_task Init (rtems_task_argument argument);#include <confdefs.h>#include <stdio.h>#include <unistd.h>#include <termios.h>#include <errno.h>#include <string.h>#include <tmacros.h>#if !defined(fileno)int fileno( FILE *stream); /* beyond ANSI */#endif/* Some of the termios dumping code depends on bit positions! */void print_32bits( unsigned long bits, unsigned char size, char * names[] ){ unsigned char i; for( i = 0; i < size; i++ ) { if( (bits >> i) & 0x1 ) printf( "%s ", names[i] ); }}void print_c_iflag( struct termios * tp ){ char * c_iflag_bits [] = { "IGNBRK", /* 0000001 */ "BRKINT", /* 0000002 */ "IGNPAR", /* 0000004 */ "PARMRK", /* 0000010 */ "INPCK", /* 0000020 */ "ISTRIP", /* 0000040 */ "INLCR", /* 0000100 */ "IGNCR", /* 0000200 */ "ICRNL", /* 0000400 */ "IUCLC", /* 0001000 */ "IXON", /* 0002000 */ "IXANY", /* 0004000 */ "IXOFF", /* 0010000 */ "IMAXBEL", /* 0020000 */ "unknown", /* 0040000 */ "unknown", /* 0100000 */ "unknown", /* 0200000 */ "unknown", /* 0400000 */ "unknown", /* 1000000 */ "unknown", /* 2000000 */ "unknown" /* 4000000 */ }; printf( "c_iflag = 0x%08x\n\t", tp->c_iflag ); print_32bits( tp->c_iflag, sizeof( c_iflag_bits )/sizeof( char * ), c_iflag_bits ); printf( "\n" );}void print_c_oflag( struct termios * tp ){ printf( "c_oflag = 0x%08x\n\t", tp->c_oflag ); if( tp->c_oflag & OPOST ) printf( "OPOST " ); if( tp->c_oflag & OLCUC ) printf( "OLCUC " ); if( tp->c_oflag & ONLCR ) printf( "ONLCR " ); if( tp->c_oflag & OCRNL ) printf( "OCRNL " ); if( tp->c_oflag & ONOCR ) printf( "ONOCR " ); if( tp->c_oflag & ONLRET ) printf( "ONLRET " ); if( tp->c_oflag & OFILL ) printf( "OFILL " ); if( tp->c_oflag & OFDEL ) printf( "OFDEL " ); switch( tp->c_oflag & NLDLY ) { case NL0: printf( "NL0 " ); break; case NL1: printf( "NL1 " ); break; } switch( tp->c_oflag & CRDLY ) { case CR0: printf( "CR0 " ); break; case CR1: printf( "CR1 " ); break; case CR2: printf( "CR2 " ); break; case CR3: printf( "CR3 " ); break; } switch( tp->c_oflag & TABDLY ) { case TAB0: printf( "TAB0 " ); break; case TAB1: printf( "TAB1 " ); break; case TAB2: printf( "TAB2 " ); break; case TAB3: printf( "TAB3 " ); break; } switch( tp->c_oflag & BSDLY ) { case BS0: printf( "BS0 " ); break; case BS1: printf( "BS1 " ); break; } switch( tp->c_oflag & VTDLY ) { case VT0: printf( "VT0 " ); break; case VT1: printf( "VT1 " ); break; } switch( tp->c_oflag & FFDLY ) { case FF0: printf( "FF0" ); break; case FF1: printf( "FF1" ); break; } printf( "\n" );}void print_c_lflag( struct termios * tp ){ char * c_lflag_bits [] = { "ISIG", /* 0000001 */ "ICANON", /* 0000002 */ "XCASE", /* 0000004 */ "ECHO", /* 0000010 */ "ECHOE", /* 0000020 */ "ECHOK", /* 0000040 */ "ECHONL", /* 0000100 */ "NOFLSH", /* 0000200 */ "TOSTOP", /* 0000400 */ "ECHOCTL", /* 0001000 */ "ECHOPRT", /* 0002000 */ "ECHOKE", /* 0004000 */ "FLUSHO", /* 0010000 */ "unknown", /* 0020000 */ "PENDIN", /* 0040000 */ "IEXTEN", /* 0100000 */ "unknown", /* 0200000 */ "unknown", /* 0400000 */ "unknown", /* 1000000 */ "unknown", /* 2000000 */ "unknown", /* 4000000 */ }; printf( "c_lflag = 0x%08x\n\t", tp->c_lflag ); print_32bits( tp->c_lflag, sizeof( c_lflag_bits )/sizeof( char * ), c_lflag_bits ); printf( "\n" );}void print_c_cflag( struct termios * tp ){ unsigned int baud; printf( "c_cflag = 0x%08x\n", tp->c_cflag ); baud = (tp->c_cflag & CBAUD) ;#if defined(__sh2__) if ( tp->c_cflag & CBAUDEX )#endif switch( baud ) { case B0: printf( "\tCBAUD =\tB0\n" ); break; case B50: printf( "\tCBAUD =\tB50\n" ); break; case B75: printf( "\tCBAUD =\tB75\n" ); break; case B110: printf( "\tCBAUD =\tB110\n" ); break; case B134: printf( "\tCBAUD =\tB134\n" ); break; case B150: printf( "\tCBAUD =\tB150\n" ); break; case B200: printf( "\tCBAUD =\tB200\n" ); break; case B300: printf( "\tCBAUD =\tB300\n" ); break; case B600: printf( "\tCBAUD =\tB600\n" ); break; case B1200: printf( "\tCBAUD =\tB1200\n" ); break; case B1800: printf( "\tCBAUD =\tB1800\n" ); break; case B2400: printf( "\tCBAUD =\tB2400\n" ); break; case B4800: printf( "\tCBAUD =\tB4800\n" ); break; case B9600: printf( "\tCBAUD =\tB9600\n" ); break; case B19200: printf( "\tCBAUD =\tB19200\n" ); break; case B38400: printf( "\tCBAUD =\tB38400\n" ); break;#if defined(__sh2__) } else switch ( baud ) {#endif case B57600: printf( "\tCBAUD =\tB57600\n" ); break; case B115200: printf( "\tCBAUD =\tB115200\n" ); break; case B230400: printf( "\tCBAUD =\tB230400\n" ); break; case B460800: printf( "\tCBAUD =\tB460800\n" ); break; default: printf( "\tCBAUD =\tunknown (0x%08x)\n", baud ); break; } switch( tp->c_cflag & CSIZE ) { case CS5: printf( "\tCSIZE =\tCS5\n" ); break; case CS6: printf( "\tCSIZE =\tCS6\n" ); break; case CS7: printf( "\tCSIZE =\tCS7\n" ); break; case CS8: printf( "\tCSIZE =\tCS8\n" ); break; } if( tp->c_cflag & CSTOPB ) printf( "\tCSTOPB set: send 2 stop bits\n" ); else printf( "\tCSTOPB clear: send 1 stop bit\n" ); if( tp->c_cflag & PARENB ) printf( "\tPARENB set: parity enabled\n" ); else printf( "\tPARENB clear: parity disabled\n" ); if( tp->c_cflag & PARODD ) printf( "\tPARODD set: parity odd\n" ); else printf( "\tPARODD clear: parity even\n" ); if( tp->c_cflag & CREAD ) printf( "\tCREAD set: receiver enabled\n" ); else printf( "\tCREAD clear: treceiver disabled\n" ); if( tp->c_cflag & HUPCL ) printf( "\tHUPCL set: enabled\n" ); else printf( "\tHUPCL clear: disabled\n" ); if( tp->c_cflag & CLOCAL ) printf( "\tCLOCAL set: ignore modem lines\n" ); else printf( "\tCLOCAL clear: don't ignore modem lines\n" ); #if defined(CBAUDEX) if( tp->c_cflag & CBAUDEX ) printf( "\tCBAUDEX set: What does this do?\n" ); else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -