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

📄 sp35_romlibrary.h

📁 英飞凌公司的单片机的测试计量程序
💻 H
字号:
/* ****************************************************************************************************/
/*                               SP35 ROM Library Functions				              */
/*   -----------------------------------------------------------------------------------------------  */
/*                                                                                                    */   
/*   Purpose:    Defines the Prototypes for the ROM Library functions in the SP35                     */
/*                                                                                                    */
/*                                                                                                    */
/*   Filename:   SP35_ROMLibrary.h                                                                    */
/*                                                                                                    */
/*   Target:     SP35                                                                                 */
/*                                                                                                    */
/*   Dev. Envir: Keil Software C51 V7.10                                                              */
/*               礦ision2 V2.40                                                                       */
/*   Author:     KB, JEN, SH	                                                                      */
/*                                                                                                    */
/*   History:    26. Nov. 2004 ... First version (for demonstration purposes only)                    */
/*               27. Jan. 2006 ... Version update to ROM Library Guide V0.1                           */
/*		 10. Oct. 2006 ... Version update to ROM Library Guide V0.2                           */
/*                                                                                                    */
/*   Status:     Version 1.2                                                                          */
/* ************************************************************************************************** */
/*  (C)opyright Infineon Technologies AG. All rights reserved.                                        */
/* ****************************************************************************************************/

#ifdef C_LIBFCT_H
  #ifdef A_LIBFCT_H
  #endif
#else 

#ifdef __C51__
  #define C_LIBFCT_H
#else
  #define A_LIBFCT_H


  #define USED	1
  #define UNUSED  0


/*    --  A T T E N T I O N  --  A T T E N T I O N  --  A T T E N T I O N  --  A T T E N T I O N  --
/* ****************************************************************************************************/   
/* This section has to be filled out by the Customer when using assembler source files:               */
/* ====================================================================================               */
/* Every function that is called from an assembler source file has to be marked as "USED".            */
/* By default the funcions are marked as "UNUSED" to avoid a loading into the Flash memory without    */
/* further usage. For C source files this loading is done automatically by the linker.                */
/* ****************************************************************************************************/   
  #define Meas_Pressure                  UNUSED
  #define Meas_Acceleration              UNUSED
  #define Meas_Temperature               UNUSED
  #define Comp_Temperature				 UNUSED
  #define Meas_Supply_Voltage            UNUSED
  #define Start_Supply_Voltage           UNUSED
  #define Get_Supply_Voltage             UNUSED
  #define Trig_Supply_Voltage            UNUSED
  #define Powerdown	                       UNUSED
  #define RC_2_XTAL                        UNUSED
  #define XTAL_2_RC                        UNUSED
  #define VCO_Tuning                       UNUSED
  #define IntervalTimerCalibration         UNUSED
  #define UDivLongLong                     UNUSED
  #define UDivIntInt                       UNUSED
  #define CRC8_Calc                        UNUSED
  #define ManuRevNb                        UNUSED
  #define CustomerRevNb                    UNUSED
  #define Read_ID				           UNUSED 
  #define LFBaudrateCalibration            UNUSED
  #define ThermalShutdown                  UNUSED
  #define Erase_UserConfigSector           UNUSED
  #define WriteFlashUserConfigSectorLine   UNUSED
  #define FlashSetLock                     UNUSED
/* ****************************************************************************************************/   
#endif 


#ifdef __C51__
  // C style library function prototype:
  extern unsigned char Meas_Pressure (unsigned char SensorGain, unsigned char SampRate, signed int idata *PressResult );
#else
  #if Meas_Pressure == USED
    #undef Meas_Pressure
    // assembler style prototype for the Library function
    EXTRN CODE (_Meas_Pressure)
  #endif
#endif


#ifdef __C51__
  // C style library function prototype:
  extern unsigned char Meas_Acceleration (unsigned char SensorGain, unsigned char SampRate, signed int idata *AccelResult);
#else
  #if Meas_Acceleration == USED
    #undef Meas_Acceleration
    // assembler style prototype for the Library function
    EXTRN CODE (_Meas_Acceleration)
  #endif
#endif


#ifdef __C51__
  extern unsigned char Meas_Temperature (signed int idata *TempResult);
#else
  #if Meas_Temperature == USED
    #undef Meas_Temperature
    EXTRN CODE (_Meas_Temperature)
  #endif
#endif

#ifdef __C51__
  extern unsigned char Comp_Temperature (signed int idata TempRawIn,signed int idata *TempResult);
#else
  #if Comp_Temperature == USED
    #undef Comp_Temperature
    EXTRN CODE (_Comp_Temperature)
  #endif
#endif


#ifdef __C51__
extern unsigned char Start_Supply_Voltage (void);
#else
  #if Start_Supply_Voltage == USED
    #undef Start_Supply_Voltage
    EXTRN CODE (_Start_Supply_Voltage)
  #endif
#endif


#ifdef __C51__
extern unsigned char Get_Supply_Voltage (signed int idata *BattResult);
#else
  #if Get_Supply_Voltage == USED
    #undef Get_Supply_Voltage
    EXTRN CODE (_Get_Supply_Voltage)
  #endif
#endif

#ifdef __C51__
extern void Trig_Supply_Voltage (void);
#else
  #if Trig_Supply_Voltage == USED
    #undef Trig_Supply_Voltage
    EXTRN CODE (Trig_Supply_Voltage)
  #endif
#endif


#ifdef __C51__
extern unsigned char Meas_Supply_Voltage (signed int idata *BattResult);
#else
  #if Meas_Supply_Voltage == USED
    #undef Meas_Supply_Voltage
    EXTRN CODE (_Meas_Supply_Voltage)
  #endif
#endif


#ifdef __C51__
  extern void Powerdown (void);
  // Turns off the Flash, checks if the interval timer values are synchronized and sets  the 
  // Powerdown bit.
#else
  #if Powerdown == USED
    #undef Powerdown
    EXTRN CODE (Powerdown)
  #endif
#endif


#ifdef __C51__
  extern signed char RC_2_XTAL(void);
  // Switches from Hi RC clock to xtal clock source, utilizes VCO Tuning
  // Return value:  0 ... PLL locked, VCO tuned
  //               -1 ... VCO tuning failure
  //               -2 ... XTAL was selected (no action performed)
#else
  #if RC_2_XTAL == USED
    #undef RC_2_XTAL
    EXTRN CODE (RC_2_XTAL)
  #endif
#endif

#ifdef __C51__
  extern void XTAL_2_RC(void);
   // Switches from crystal clock source to Hi RC clock
#else
  #if XTAL_2_RC == USED
    #undef XTAL_2_RC
    EXTRN CODE (XTAL_2_RC)
  #endif
#endif


#ifdef __C51__
  extern signed char VCO_Tuning (void);
  // Selects the VCO tuning curve and inserts the value into the corresponding SFRs.
  // In case of improper function of the Lock detector the function sets RFVCO to its default value.
  // Parameters: none
  //
  // Return value:  0 ... PLL locked
  //               -1 ... failure
  //               -2 ... Hi RC selected for calibration
#else 
  #if VCO_Tuning == USED
    #undef VCO_Tuning
    EXTRN CODE (_VCO_Tuning)
  #endif
#endif


#ifdef __C51__
  extern signed char IntervalTimerCalibration(unsigned char WU_Frequency);
  // Depending on the selected clock source the internal 2kHz RC Clock is calibrated to get exact wakeup-timing.
  // In case XTAL is used as clock source: Fetches the XTal Value from the Customer Flash (starting at address 0x57FA)
  //     In case no XTAL is inserted in the Customer Flash the function uses a default value of 19MHz.
  // In case Hi RC is used as clock source: Calibrate the Interval Timer vs. the internal 12MHz RC Oscillator.
  // 
  // Parameters: WU_Frequency: This is the base frequency for the Wakeup timer. Range = 1Hz to 20Hz
  //
  //
  //                                         ITPR
  //                                     ---------------  = Wakeup time 
  //                                      WU_Frequency  
  //
  //                    Example: WU_Frequency = 10; ITPR = 7 => Wakeup time = 700ms
  //                                                    
  // Return value:  0 ... Calibration done successful
  //               -1 ... No (valid) crystal value in the User Configuration Sector
  //               -2 ... Invalid frequency range selected.                           
  // 
#else
  #if IntervalTimerCalibration == USED
    #undef IntervalTimerCalibration
	EXTRN CODE (_IntervalTimerCalibration)
  #endif 
#endif


#ifdef __C51__
  extern unsigned long UDivLongLong(unsigned long idata* Dividend,unsigned long idata * Divisor);
  // This ROM function divides the unsigned long value (32bit) Dividend by the unsigned long value Divisor.
  // The returned value is the quotient. The remainder can be found in R2 (MSByte) and R3 (LSByte)
#else 
  #if UDivLongLong == USED
    #undef UDivLongLong
	EXTRN CODE (_UDivLongLong)
  #endif
#endif


#ifdef __C51__
  extern signed int UDivIntInt(unsigned int Dividend, unsigned int Divisor);
  // This ROM function divides the 16 bit unsigned Dividend by the 16 bit unsigned Divisor.
  // The remainder can be found in R4 (MSByte) and R5 (LSByte)
#else 
  #if UDivIntInt == USED
    #undef UDivIntInt
	EXTRN CODE (_UDivIntInt)
  #endif
#endif


#ifdef __C51__
   extern unsigned char CRC8_Calc(unsigned char Preload, unsigned char idata * BlockStart, unsigned char BlockLength);   
   // This function calculates the CRC-8 value of data pointed to by InputData in RAM using 
   // a fixed polynomial (x^8+x^2+x^1+1).   
#else
  #if CRC8_Calc == USED
     #undef CRC8_Calc
     EXTRN CODE (_CRC8_Calc)
  #endif
#endif


#ifdef __C51__
   extern signed int ManuRevNb(void);
   // Returns the Manufacturer Revision Number
#else
  #if ManuRevNb == USED
     #undef ManuRevNb
     EXTRN CODE (ManuRevNb)
  #endif
#endif


#ifdef __C51__
   extern signed int CustomerRevNb(void);
   // Found in the ROM at address 0x2FFC, currently empty.
#else
  #if CustomerRevNb == USED
     #undef CustomerRevNb
     EXTRN CODE (CustomerRevNb)
  #endif
#endif

#ifdef __C51__
   extern void Read_ID (struct ID_Struct idata * idata ID_Result);
   // Found in the ROM at address 0x2FFC, currently empty.
#else
  #if Read_ID == USED
     #undef Read_ID
     EXTRN CODE (Read_ID)
  #endif
#endif


#ifdef __C51__
   extern signed char LF_BaudrateCalibration(unsigned int Baudrate);
   // 
   // RETURNVALUE:   0 ... done
   //               -1 ... failed (Baudrate out of range) 
#else
  #if LFBaudrateCalibration == USED
     #undef LFBaudrateCalibration
     EXTRN CODE (_LF_BaudrateCalibration)
  #endif
#endif


#ifdef __C51__
   extern void ThermalShutdown(void);
   // 
   // RETURNVALUE:   0 ... done
   //               -1 ... failed (temperature to low) 
#else
  #if ThermalShutdown == USED
     #undef ThermalShutdown
     EXTRN CODE (ThermalShutdown)
  #endif
#endif

#ifdef __C51__
   extern signed char Erase_UserConfigSector(void);
   // Erases the Flash User Configuration Sector. Tests (Voltage, Temp) are not included 
   // RETURNVALUE:   0 ... done
   //               -1 ... failed 
#else
  #if Erase_UserConfigSector == USED
     #undef Erase_UserConfigSector
     EXTRN CODE (Erase_UserConfigSector)
  #endif
#endif


#ifdef __C51__
   extern signed char WriteFlashUserConfigSectorLine(unsigned int Startaddress, unsigned char idata * WrData);
   // Programs and verifies one line of the User Configuration Sector in Normal Mode 
   // RETURNVALUE:   0 ... done
   //               -1 ... failed 
   // PARAMETERS:   Startaddress (has to be within the User configuration sector and is cut to a mult.
   //               of 0x20 to ensure start on the physical Flash line
#else
  #if WriteFlashUserConfigSectorLine == USED
     #undef WriteFlashUserConfigSectorLine
     EXTRN CODE (_WriteFlashUserConfigSectorLine)
  #endif
#endif


#ifdef __C51__
   extern signed char FlashSetLock (void);
   // Sets the CRC of the Flash Sectors 0 and 1 and inserts the Lockbyte 0xD1 at 0x57FF.
   // RETURNVALUE:   0 ... done 
   //               -1 ... failed
#else
  #if FlashSetLock == USED
     #undef FlashSetLock
     EXTRN CODE (FlashSetLock)
  #endif
#endif


// Reservation of the ROM function used Idata memory:
// ==================================================
#ifndef RAM_ALLOCATION
	#define RAM_ALLOCATION
	#ifdef __C51__
		unsigned char idata LibSpace[0x27] _at_ 0xC1 ; // Reserve memory for the library functions
	#else
		ISEG AT 0xC1
		DS	027h
	#endif
#endif

#ifdef __C51__
  struct Sens_Coeff {
 	signed char Z0init;
	int Z1;
	int Z2;
	int Z0;
	int S1;
	int S2;
	int S0;
	};
  struct Tmp_Coeff {
	signed char TZ0init;
	int TZ0;
	int TS1;
	int TS2;
	};
  struct Vlt_Coeff {
	signed char VZ0init;
	int VZ0;
	};

	#define	FL_COEFF_START 0x5800 
	#define COEFF_VOLTAGE_OFFS			0x20	// Start offset for Voltage coefficients
	#define COEFF_TEMPERATURE_OFFS		0x25	// Start offset for Temperature coefficients
	#define COEFF_PRESSURE_OFFS			0x30	// Start offset for Pressure coefficients
	#define COEFF_ACCELERATION_OFFS		0x60	// Start offset for Acceleration coefficients

	//  These structures are placed according to Coefficient Sector map
	struct Sens_Coeff code Press_Coeff _at_ (FL_COEFF_START + COEFF_PRESSURE_OFFS); 
	struct Sens_Coeff code Accel_Coeff _at_ (FL_COEFF_START + COEFF_ACCELERATION_OFFS);
	struct Tmp_Coeff code Temp_Coeff   _at_ (FL_COEFF_START + COEFF_TEMPERATURE_OFFS);
	struct Vlt_Coeff code Volt_Coeff   _at_ (FL_COEFF_START + COEFF_VOLTAGE_OFFS);
#endif 

#endif 

⌨️ 快捷键说明

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