⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eval_defs.h

📁 C89c51 usb驱动程序,实现了usb转串口的功能,提供了一个虚拟的串口
💻 H
📖 第 1 页 / 共 2 页
字号:
/*_____________________________ Data storage declarations ________________________________*/


/*** Page allocations in MCU on-chip EEPROM (see _rtos.c) ***/
extern  far uint8  habEEPROM_page0[];
extern  far uint8  habEEPROM_page1[];
extern  far uint8  habEEPROM_page2[];
extern  far uint8  habEEPROM_page3[];
extern  far uint8  habEEPROM_page4[];
extern  far uint8  habEEPROM_page5[];
extern  far uint8  habEEPROM_page6[];
extern  far uint8  habEEPROM_page7[];


struct  tDateTime        /* RTC date.time structure */
{
	uint8  year;
	uint8  month;
	uint8  day;			/* day-of-the-month, 1..31 */
	uint8  dow;			/* day-of-the-week, 0..6, Sunday == 0 */
	uint8  hour;		/* hour of day, 24hour format (0..23) */
	uint8  min;
	uint8  sec;
};

struct tSchedTime		/* Scheduled power-up/power-down time-of-day structure (v2.xx) */
{
	uint8  hour;		/* hour of day, 24hour format (0..23) */
	uint8  min;
	uint8  sec;
};

extern  idata  uint8   gbHCI_Stream;	/* Determines HCI I/O data stream - USB or UART */
	                                    /* gbHCI_Stream can be one of.... */
#define  USB_HOST_LINK   'U'
#define  UART_HOST_LINK  'S'

extern  const  char  kszVersion[];   	/* Firmware version ID; in "_main.c" */
extern  const  char  kszGreeting[];

/*** Variables in "idata" (MCU low RAM), volatile, lost on reset ***/

extern  idata  uint8   gubTaskFlags;           /* B/G task control/status flags */
extern  idata  uint8   gubMiscFlags;           /* Misc. system control & status flags */
extern  idata  uint16  gwSystemError;          /* System error/warning flags */
extern  idata  uint8   gubRespCksm;            /* Response checksum */

extern  idata  char    gacCmdLine[CMD_LINE_SIZE];     /* Command Line buffer for USB input */
extern  idata  char  * pacCmdLinePtr;                /* Pointer into gacCmdLine[] */
extern  idata  char    gacPrompt[];         	      /* Variable prompt string */

extern  idata  struct  tDateTime  gsRTCbuf;  	      /* global RTC buffer for use by application */


/*** Variables in "far" memory (ERAM), volatile, lost on reset ***/
/*  None yet defined  */


/*** Variables in "far" memory (ERAM), persistent data backed up in EEPROM  ***/
extern  far  uint8  ghabParam[];        /* Parameter array */



/*_______________________  F U N C T I O N   P R O T O T Y P E S  ________________________*/

/*** Functions defined in source file: "eval_main.c" ***/

void   initialise_app( void );            /* Initialise application-specific variables, etc */
void   maintain_usb_connection(void);     /* The name says it all */
void   background_process( void );        /* Background task dispatcher */
void   tick_timers_task( void );          /* B/G task executed once every "tick" (5mS) */
void   second_timers_task( void );        /* B/G task executed once every second */
void   new_day_task( void );              /* B/G task executed once every day at 00:00hrs */
void   fetch_persistent_data( void );     /* Read EEPROM data */
void   store_persistent_data( void );     /* Store EEPROM data (invoke task) */
void   eeprom_update_task( void );        /* Background task -- program EEPROM data */


/*** Functions defined in source file: "eval_cmnd.c" ***/

void   DummyCmd( void );                  /* just returns */
void   initialise_cli();                  /* initialises CLI variables */
void   check_uart_HCI_input( void );      /* checks for new data received from UART */
void   check_usb_HCI_input( void );       /* checks for new data received from USB */
void   process_HCI_input_char( char c );  /* builds a command line */
void   do_command( void );                /* executes host command */
void   flush_command_line( void );        /* clears command line buffer; reset pointer */
void   put_prompt( void );                /* outputs the prompt string */

void   help_cmd( void );				  /* "user" command functions */
void   show_set_time_cmd( void );
void   version_cmd( void );
void   watch_app_cmd( void );
void   bootloader_cmd( void );
void   default_params_cmd( void );
void   reset_MCU_cmd( void );

void   show_errors_cmd( void );		  	  /* "debug" command functions */
void   watch_timers_cmd( void );
void   disassemble_cmd( void );
void   dump_memory_cmd( void );
void   read_MCU_mem_cmd( void );
void   write_MCU_mem_cmd( void );
void   read_port_cmd( void );
void   write_port_cmd( void );
void   read_extd_cmd( void );
void   write_extd_cmd( void );
void   execute_cmd( void );

void   putNewLine( void );                /* output newline (CR+LF) to UART1 */
void   putconstr( const char * );         /* output "const" string, NUL terminated */
void   putstr( char * );           		  /* output "idata" string, NUL terminated */
void   putfarstr( char far * );           /* output "far" string, NUL terminated */
void   putBoolean( bool );                /* output Boolean entity as '0' or '1' */
void   putHexdigit( uint8 );              /* output LS nybble as 1 Hex ASCII char */
void   putHexbyte( uint8 );               /* output byte as 2 Hex ASCII chars */
void   putHexword( uint16 );              /* output word as 4 Hex ASCII chars */
void   putDecimal( uint16, uint8 );       /* output word as 1..5 decimal ASCII chars */


/*** Functions defined in source file: "eval_disasm.c" ***/
void   disassemble_cmd( void );
const char * put_assembler( const char * );


/*** Functions defined in source file: "eval_rtos.c" ***/

void   initialise_rtos( void );           /* initialise MCU, I/O and RTOS environment */
void   service_watchdog( void );          /* reset the watchdog timer */
void   initialise_RTI_timer( void );      /* initialise Timer-0 for periodic interrupt */
interrupt  Timer0_service( void );        /* RTI timer (T0) ISR */
void   RTI_Tick_Handler( void );          /* RTI tick handler (foreground) */
uint16 get_ticks( void );                 /* return value of GP tick timer (16b) */
void   wait_ticks( uint16 );              /* delay while running background tasks */
void   set_RTC_date_time( void );         /* set RTC from global structure */
bool   read_RTC_date_time( void );        /* read RTC into global structure */
uint16 days_in_whole_year( uint8 );       /* return number of days in specified year */
uint16 day_of_this_year( void );          /* return day (1..366) of the current year */

void   initialise_uart( void );            /* initialise UART = host PC serial port */
interrupt  uart_service( void );           /* UART ISR */
bool   uart_rx_data_avail( void );        /* TRUE if char available in UART Rx buffer */
char   uart_getch( void );                /* get char from UART1 Rx reg, no echo, no wait */
char   uart_getche( void );               /* get char from UART1 Rx reg and echo, no wait */
char   usb_vuart_getche( void );		  /* get char from USB Rx buffer and echo */
bool   hci_data_avail( void );            /* TRUE if char available from active HCI stream */
char   getch( void );                     /* wait for & input char from active HCI stream */
char   putch( char );                     /* output char to active HCI stream (UART or USB) */

bool   Button_INT0_hit( void );    		  /* Returns TRUE if "INT0" button hit */
bool   Button_TEST_hit( void );    		  /* Returns TRUE if "TEST" button hit */

void   LED_Refresh( void );                     /* LED refresh routine */
void   SetLEDmode( uint8, bool );               /* Set LED mode (continuous ON or OFF) */
void   SetLEDFlashMode( uint8, uint8, uint8);   /* Set LED flash mode, period and duty */
void   SetLEDoutput( uint8, bool );             /* LED low-level device driver */

void   initialise_SPI( void );            /* Initialise the SPI controller as master */
void   SPI_output( uint8  bData );        /* Output a byte via SPI bus */
uint8  SPI_input( void );                 /* Input a byte via SPI bus */

uint8  eeprom_read_byte( uint16 );        /* Read 1 byte from EEPROM */
void   eeprom_read_data( far uint8 *, far uint8 *, uint8 );   /* Read data block from EEPROM */
void   eeprom_write_data( far uint8 *, far uint8 *, uint8 );  /* Write data block to EEPROM */
bool   eeprom_busy( void );               /* Return TRUE if EEPROM is busy (in prog. cycle) */
void   eeprom_start_prog( void );         /* Initiate EEPROM program cycle */

uint8  hexctobin( char );                 /* Hex ASCII char to unsigned byte */
uint8  dectobin( char );                  /* Decimal ASCII char to unsigned byte */
uint16 hexatoi( char * );                 /* Hex ASCII string to 16 bit word */
uint16 decatoi( char *, int8 );           /* Decimal ASCII string to 16 bit word */
uint32 long_decatoi( char *, int8 );      /* Decimal ASCII string to 32 bit word */
bool   isHexDigit( char );                /* TRUE if char is hex ASCII digit */
void   srand( uint16 wSeed16 );           /* Seed the psuedo-random sequence */
uint16 rand( void );                      /* Returns a psuedo-random number */
uint8  peek_code_byte( uint16 uwAddr );   /* Fetch byte from program memory @uwAddr */


/*****
*	Source code uses a variant of Hungarian Notation for C identifiers
*
*	prefix		as data type		as qualifier
*	---------	----------------	----------------
*	a			array				array of
*	b			byte (8 bits)
*	c			char
*	d			double
*	e			enum
*	f			float
*	g			---					global
*	h			---					huge, far
*	i			---					int (signed)^
*	j			---
*	k			---					const
*	l			long (32 bits)
*	m			---
*	n			---					near^
*	o			---
*	p			pointer
*	q			---
*	r			register
*	s, sz		struct, string
*	t, _t		tag, typedef
*	u			union				unsigned^
*	v			---					volatile
*	w			word (16 bits)
*	x			---
*	y			boolean (flag)
*	z, sz		string				zero-terminated
*
*	[^ Qualifier may be omitted if clear from context or unimportant.]
*/

#endif  // _EVAL_DEFS_

/*** end ***/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -