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

📄 main.h

📁 嵌入式操作系统Salvo 在单片机C8051F350上的移植
💻 H
📖 第 1 页 / 共 2 页
字号:
/************************************************************ 
Copyright (C) 1995-2002 Pumpkin, Inc. and its
Licensor(s). Freely distributable.

$Source: C:\\RCS\\d\\salvo\\tut\\tu1\\main.h,v $
$Author: aek $
$Revision: 3.32 $
$Date: 2003-07-19 20:11:27-07 $

Header file for tutorial programs.

************************************************************/
                                                            
/*                                                          */                                                                
/* ===================== PICmicro ========================= */
/*                                                          */                                                                
#if   defined(SYSA) /* HI-TECH PICC         */ \
   || defined(SYSE) /* Microchip MPLAB-C18  */ \
   || defined(SYSF) /* HI-TECH PICC-18      */ \
   || defined(SYSH) /* HI-TECH PICC         */ \
   || defined(SYSP) /* IAR PIC18 C          */


#if   defined(SYSP)
#include <io18c452.h> /* for generic PIC18C452 */
#endif


/* setup which port to use, and initialize it */
#if   defined(SYSA) \
   || defined(SYSE) \
   || defined(SYSF) \
   || defined(SYSP)
#define PORT                        PORTB
#define InitPORT()                  do { PORTB = 0x00; \
                                         TRISB = 0x00; \
                                    } while (0) 
#elif defined(SYSH)
#define PORT                        PORTC
#define InitPORT()                  do { PORTC = 0x00; \
                                         TRISC = 0x00; \
                                    } while (0) 
#endif 


/* when interrupts are used (tu5 & tu6), they need to be    */
/*  appropriately initialized.                              */
#if !defined(USE_INTERRUPTS) 
#define Init()         
#else
#if   defined(SYSA) \
   || defined(SYSF) \
   || defined(SYSH) \
   || defined(SYSP)

/* PICC-18 and IAR PIC18 C use different nomenclature */
#if defined(SYSF)      
#define PS2                         T0PS2
#define PS1                         T0PS1
#define PS0                         T0PS0
#define T0IE                        TMR0IE
#elif defined(SYSP)            
#define PS2                         T0PS2
#define PS1                         T0PS1
#define PS0                         T0PS0
#endif                          

#define Init()                      do { T0CS = 0; \
                                         PSA  = 0; \
                                         PS2  = 1; \
                                         PS1  = 0; \
                                         PS0  = 1; \
                                         T0IE = 1; \
                                    } while (0) 


/*  MPLAB-C18 uses different nomenclature for certain PIC18 */
/*   family members                                         */
#elif  defined(SYSE)        
#if  defined(__18C601)  || defined(__18C658)  || defined(__18C801)  \
 ||  defined(__18C858)  || defined(__18F2220) || defined(__18F2320) \
 ||  defined(__18F2331) || defined(__18F2431) || defined(__18F4220) \
 ||  defined(__18F4320) || defined(__18F4331) || defined(__18F4431)
#define Init()                      do { T0CONbits.T0CS    = 0; \
                                         T0CONbits.T0PS0   = 1; \
                                         T0CONbits.T0PS1   = 0; \
                                         T0CONbits.T0PS2   = 1; \
                                         T0CONbits.T0PS3   = 0; \
                                         INTCONbits.TMR0IE = 1; \
                                    } while (0)
#else
#define Init()                      do { T0CONbits.T0CS    = 0; \
                                         T0CONbits.T0PS0   = 1; \
                                         T0CONbits.T0PS1   = 0; \
                                         T0CONbits.T0PS2   = 1; \
                                         T0CONbits.PSA     = 0; \
                                         INTCONbits.TMR0IE = 1; \
                                    } while (0)
#endif                          

#endif
                           
#endif                     


/*                                                          */                                                                
/* ======================= 8051 =========================== */
/*                                                          */                                                                
#elif defined(SYSI) /* Keil Cx51     */ \
   || defined(SYSM) /* HI-TECH 8051C */ \
   || defined(SYSN) /* Tasking C51   */ 
   
#if   defined(SYSI)
//#include <reg51.h>  /* for generic 8051 */

#include <C8051F350.h>

#elif defined(SYSM)
#include <8051.h>   /* for generic 8051 */
#elif defined(SYSN)
#error main.h: Not supported.
#endif

/* Reload values for Timer0 - 5msec interrupts for          */
/*  Oscillator at 11.0592 MHz. This code courtesy Michael   */
/*  Stepanov.                                               */
//#define TIMER_H                     238 /* TH0 reload value */
//#define TIMER_L                     0   /* TL0 reload value */ 

#define TIMER_H                     0x10 /* TH0 reload value */
#define TIMER_L                     0xBE  /* TL0 reload value */ 

/* we'll be outputting to port P1 */
#define PORT                        P1 
#define InitPORT()                  do { PORT = 0x00; } while (0)
#if !defined(USE_INTERRUPTS)
#define Init()                      do { ; } while (0)
#else
#define Init()                      do { TMOD =    0x21; /* TMOD:timer1-mode2 - 8-bit reload,timer0-mode1,16-bit */ \
                                         CKCON     = 0x01;\
																				 TL0  = TIMER_L; \
                                         TH0  = TIMER_H; \                                         
                                         PT0  =       1; /* max priority for T0 interrupt */ \
                                         ET0  =       1; /* enable timer 0 interrupt */ \
                                         TR0  =       1; /* start Timer0 */ \
                                    } while (0)
#endif


/*                                                          */                                                                
/* =================== ARClite microRISC ================== */
/*                                                          */                                                                
#elif defined(SYSL)

unsigned char PORTB; 

#if !defined(USE_INTERRUPTS) 
#define Init()                      di()
#else
/* INTENB=1, RET=1, RUN=1, prescalar disabled */
#define Init()                      do { TIMER_CTL = 0x51; \
                                      TIMER_PRESCL =    0; \
                                      TIMER_MAXA   = 40000; \
                                      TIMER_MAXB   = 40000; \
                                      ei(); \
                                    } while (0)
#endif
#define PORT                        PORTB
#define InitPORT()                  do { PORT = 0x00; } while (0)


/*                                                          */                                                                
/* ====================== MSP430 ========================== */
/*                                                          */                                                                
#elif defined(SYSQ) /* IAR MSP430 C              */ \
   || defined(SYSR) /* Archelon Quadravox AQ430  */ \
   || defined(SYSS) /* ImageCraft ICC430         */ \
   || defined(SYSX) /* Rowley CrossStudio MSP430 */

#if   defined(SYSQ)
#include <msp430x14x.h> /* for MSP430F149 */
#elif defined(SYSR)
#include <msp430x14x.h> /* for MSP430F149 */
#elif defined(SYSS)
#include <msp430x14x.h> /* for MSP430F149 */
#elif defined(SYSX)
#endif


#define PORT                        P1OUT
#if !defined(USE_INTERRUPTS)

⌨️ 快捷键说明

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