📄 eval_defs.h
字号:
/*
**********************************************************************************
*
* Project Name: AT89C5131 MCU and Hi-Tech 8051 compiler evaluation
*
* File Name: eval_defs.h
*
* Copyright 2004++ by Michael J Bauer [www.hotkey.net.au/~mjbauer]
*
* Date Created: 2004.08.26
*
*
**********************************************************************************
*
* DATA MEMORY MAP -- MCU DATA SPACE (64KB total)
*
* $0000 - $00FF MCU internal RAM (256 bytes) (indirect addr mode)
* $0080 - $00FF MCU special function registers (direct addr mode)
* $0000 - $03FF MCU on-chip "extended" RAM (1KB) (access via MOVX instrn)
*
* CODE MEMORY MAP -- MCU CODE SPACE (64KB total)
*
* $0000 - $7FFF MCU internal Flash code (32KB)
* $F000 - $F3FF MCU internal user EEPROM ???? (1KB)
* $F400 - $FFFF MCU internal boot EEPROM (3KB) - USB bootloader
*
*/
#ifndef _EVAL_DEFS_
#define _EVAL_DEFS_
#define DISASM_INCLUDED TRUE /* Set TRUE to include disassembler in build */
#define WATCHDOG_ENABLED TRUE /* Set TRUE to enable MCU watchdog in build */
#define CMD_LINE_SIZE 20 /* Command string buffer size */
#define RXBUFSIZE 8 /* UART received data RAM buffer size */
#define MILLISEC_PER_TICK 5
#define X2_MODE
#ifdef X2_MODE // defined in evab_defs.h and/or usb_config.h
#define CLOCKS_PER_TICK 13333 /* Number of Fclk periods per RTI "tick" */
#else
#define CLOCKS_PER_TICK 6666 /* Number of Fclk periods per RTI "tick" */
#endif
#define ERROR (-1)
#define FAIL (-1)
#define PASS 1
#define NUL 0
#define EOT 4
#define ENQ 5
#define ACK 6
#define BACKSP 8
#define LF 10
#define CR 13
#define NAK 21
#define SYN 22 // Ctrl-V (Used to switch HCI input stream)
#define ESC 27
#define SPACE 32
#define TRUE 1
#define FALSE 0
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed long int32;
typedef unsigned long uint32;
typedef unsigned char bool;
typedef void (* pfnvoid)(void);
/* Macros for testing ASCII character range */
#define isdigit( c ) ( c >= '0' && c <= '9' ? TRUE : FALSE )
#define isprint( c ) ( c >= 32 && c < 127 ? TRUE : FALSE )
#define toupper( c ) ( c >= 'a' && c <= 'z' ? ( c - 32 ) : ( c ) )
/*
* MACROS FOR BYTE/WORD/REGISTER BIT MANIPULATION
*
* NB: Test_Bit may evaluate to *any* non-zero value to indicate 'TRUE',
* so do not use the expression: if ( Test_Bit( ... ) == TRUE )...
* Correct usage is: if ( Test_Bit( ... ) ) ... // test for bit set (1)
* or, conversely: if ( !Test_Bit( ... ) ) ... // test for bit clear (0)
*
* The 8051 MCU has 16 bytes of RAM dedicated to 128 bit-addressable (boolean) variables.
* The compiler supports this feature by means of the "bit" qualifier (and ".rbit" section).
* The bit feature is NOT exploited in this application, because its use would make the code
* non-ANSI compliant, hence it would be detrimental its portability.
* The macros are quite efficient when applied to "near" or "idata" byte variables.
*
* NB: These macros assume that the compiler generates Read/Modify/Write instructions
* when used to access 8051 on-chip I/O ports. (Check the compiler-generated code!)
*/
#define Test_Bit(entity, bitmask) ((bool)(entity & bitmask))
#define Set_Bit(entity, bitmask) (entity |= bitmask)
#define Clear_Bit(entity, bitmask) (entity &= ~bitmask)
/* Bit mask definitions for use with above macros */
#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80
#define BIT08 0x0100
#define BIT09 0x0200
#define BIT10 0x0400
#define BIT11 0x0800
#define BIT12 0x1000
#define BIT13 0x2000
#define BIT14 0x4000
#define BIT15 0x8000
/* Macros to read/write external data memory and I/O devices */
#define peek_data_byte(addr) ( *(uint8 far *)(addr) )
#define peek_data_word(addr) ( *(uint16 far *)(addr) )
#define poke_data_byte(addr, data) ( *(uint8 far *)(addr) = (uint8)(data) )
#define poke_data_word(addr, data) ( *(uint16 far *)(addr) = (uint16)(data) )
#define HI_BYTE(w16) ((uint8) ((uint16)(w16) >> 8)) /* MSB of 16bit arg */
#define LO_BYTE(w16) ((uint8) ((w16) & 0xFF)) /* LSB of 16bit arg */
/*************** APPLICATION-SPECIFIC DEFINITIONS ***********************************/
#define MAX_PARAMS 128 /* Maximum number of bytes in parameter array */
/* AT89C5131 I/O port bit assignments for PORT3 */
#define INT0_BUTTON BIT2 /* P3.2 == INT0 button */
#define LED0_H1 BIT3 /* P3.3 == LED0 == H1 (green LED) */
#define LED1_H2 BIT5 /* P3.5 == LED1 == H2 (green LED) */
#define LED2_H3 BIT6 /* P3.6 == LED2 == H3 (yellow LED) */
#define LED3_H4 BIT7 /* P3.7 == LED3 == H4 (red LED) */
/* AT89C5131 I/O port bit assignments for PORT1 */
#define TEST_POINT BIT3 /* P1.3 == Testpoint P1.3 (output) */
#define TEST_BUTTON BIT2 /* P1.2 == TEST button (input) */
#define ISP_BUTTON BIT0 /* P1.0 == ISP button (Low Pin Count mode only) */
/* Bit assignments for background task status byte: gubTaskFlags */
#define EEPROM_UPD_TASK BIT7 /* Set to update EEPROM data (ad-hoc task) */
#define RESERVED_6_TASK BIT6 /* Reserved task flag */
#define RESERVED_5_TASK BIT5 /* Reserved task flag */
#define RESERVED_4_TASK BIT4 /* Reserved task flag */
#define NEWDAY_TASK BIT3 /* Set every day at 00:00hrs to invoke B/G task */
#define SECONDS_TASK BIT2 /* Set every second to invoke B/G task */
#define FIFTY_MSEC_TASK BIT1 /* Set every 10th tick (50mS) to invoke B/G task */
#define TICKS_TASK BIT0 /* Set every tick (5mS) to invoke B/G task */
/* Bit assignments for Misc. Flags byte: gubMiscFlags */
#define SCI_TXRDY BIT7 /* TRUE => UART Transmitter Ready (SBUF empty) */
/* Bit assignments for System Error/Warnings word: gwSystemError */
#define SCI_INT_ERROR BIT15 /* UART generated spurious IRQ */
#define RX_FIFO_OVFL BIT14 /* Serial RX RAM buffer overflowed */
#define RTC_INVALID BIT13 /* Real-time/date invalid (warning) */
#define EEPROM_DATA_ERR BIT12 /* Error writing EEPROM data */
#define RESERVED_11_ERR BIT11 /* Reserved error/warning flag */
#define RESERVED_10_ERR BIT10 /* Reserved error/warning flag */
#define RESERVED_09_ERR BIT09 /* Reserved error/warning flag */
#define RESERVED_08_ERR BIT08 /* Reserved error/warning flag */
#define RESERVED_7_ERR BIT7 /* Reserved error/warning flag */
#define RESERVED_6_ERR BIT6 /* Reserved error/warning flag */
#define RESERVED_5_ERR BIT5 /* Reserved error/warning flag */
#define RESERVED_4_ERR BIT4 /* Reserved error/warning flag */
#define NEWDAY_TASK_OVRUN BIT3 /* NewDay periodic task overrun (warning) */
#define TICK_TASK_OVRUN BIT0 /* 5 mSec periodic task overrun (warning) */
#define FIFTYMS_TASK_OVRUN BIT1 /* 50mSec periodic task overrun (warning) */
#define SEC_TASK_OVRUN BIT2 /* Second periodic task overrun (warning) */
#define SUNDAY 0
#define SATURDAY 6
/*
* Identifiers for control-surface LED annunciators for use with LED handler functions:
* SetLEDmode() and SetLEDFlashMode().
* Number of LEDs and their function depends on target hardware platform.
* (NB: LED colours on the Author's development board may not be the same as AT89STK.)
*/
enum eLEDannunciatorID
{
LED_0, /* P3.3 == LED0 == H1 (green LED) */
LED_1, /* P3.5 == LED1 == H2 (red LED) */
NUMBER_OF_LEDS
};
/*
* These are the 8 presets representing LED flash periods and duty-cycle times,
* for use with function: SetLEDFlashMode().
* The implied times (millisecs) assume RTI tick interval = 5mS.
* (see also LED_Refresh function in eval_rtos.c)
*/
enum eLED_FLASH_PRESET_TIME
{
TIME_50mS = 0, // 10 ticks
TIME_100mS, // 20 ticks
TIME_200mS, // 40 ticks
TIME_250mS, // 50 ticks
TIME_400mS, // 80 ticks
TIME_500mS, // 100 ticks
TIME_800mS, // 160 ticks
TIME_1000mS // 200 ticks
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -