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

📄 ports.lst

📁 该程序是ST7MC驱动三洋压缩机(交流)
💻 LST
字号:
ANSI-C/cC++ Compiler for ST7 V-5.0.7, Aug 21 2001

    1:  /**************** (c) 2004 STMicroelectronics **********************
    2:  
    3:  PROJECT  : 3-phase AC induction motor drive Software Library
    4:  COMPILER : COSMIC / METROWERKS
    5:  
    6:  MODULE  :  ports.c
    7:  VERSION :  1.1
    8:  
    9:  CREATION DATE : 07.2003 
   10:  AUTHOR :      Florent COSTE	/  Microcontroller Application Lab  / ST Hong Kong
   11:  
   12:  -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   13:  
   14:  DESCRIPTION :  I/O line control routines
   15:  
   16:  -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   17:  
   18:  MODIFICATIONS
   19:  
   20:  04.2004 (V. Onde) Rel 1.1: Remove unused functions and variables
   21:  
   22:  ******************************************************************************
   23:  THE SOFTWARE INCLUDED IN THIS FILE IS FOR GUIDANCE ONLY. ST MICROELECTRONICS
   24:  SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES
   25:  WITH RESPECT TO ANY CLAIMS ARISING FROM USE OF THIS SOFTWARE.
   26:  ******************************************************************************
   27:                
   28:  -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   29:  
   30:  ******************************************************************************/
   31:                              
   32:  #include "lib.h"
   33:  #include "ports.h"
   34:  #include "ST7FMC2N6.h"
   35:  #include "pwmart.h"
   36:  
   37:  #define		BUTTON			0
   38:  #define		BUTTON_PORT		PCDR
   39:  
   40:  #define		LED		((u8)0x80)	/* PB7 */
   41:  #define		PB7		((u8)7)
   42:  
   43:  static u8 KeyState;      		// status of key panel
   44:  
   45:  #define KEY_IDLE		((u8)0)
   46:  #define KEY_IDLE_NEXT	((u8)1)
   47:  #define KEY_PUSHED		((u8)2)
   48:  
   49:  
   50:  
   51:  /*-----------------------------------------------------------------------------
   52:  ROUTINE NAME : PORTS_Init
   53:  INPUT/OUTPUT : None
   54:  
   55:  DESCRIPTION  : Configure the ports
   56:  
   57:  COMMENTS     :
   58:  -----------------------------------------------------------------------------*/
   59:  void PORTS_Init(void)           // Setting for 56 pins case of Starter kit
   60:  {

Function: PORTS_Init
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

   61:  
   62:  	PADDR    = 0x00;    //PA7 to PA0 floating Input
  0000 3f00     CLR   PADDR
   63:  	PAOR	 = 0x00;
  0002 3f00     CLR   PAOR
   64:  
   65:    	PBDDR    = 0x80; 	//PB7 output push pull
  0004 a680     LD    A,#128
  0006 b700     LD    PBDDR,A
   66:  	PBOR     = 0x80;    //PB6 to PB0 floating Input
  0008 b700     LD    PBOR,A
   67:  
   68:  	PCDDR    = 0x00; 	//PC7 to PC0 floating Input
  000a 3f00     CLR   PCDDR
   69:  	PCOR     = 0x00;      
  000c 3f00     CLR   PCOR
   70:  
   71:  	PDDDR    = 0x00; 	//PD7 to PD0 floating Input
  000e 3f00     CLR   PDDDR
   72:  	PDOR     = 0x00;
  0010 3f00     CLR   PDOR
   73:      
   74:  	PEDDR    = 0x00;    //PE7 to PE0 floating Input
  0012 3f00     CLR   PEDDR
   75:  	PEOR     = 0x00;
  0014 3f00     CLR   PEOR
   76:  
   77:  	PFDDR    = 0x00;	//PF7 to PF0 floating Input
  0016 3f00     CLR   PFDDR
   78:  	PFOR     = 0x00;
  0018 3f00     CLR   PFOR
   79:  
   80:  	KeyState = 0;
  001a 4f       CLR   A
  001b c70000   LD    KeyState,A
   81:  }
  001e 81       RET   
   82:  
   83:  
   84:  /*-----------------------------------------------------------------------------
   85:  ROUTINE NAME : PORTS_RedLedOn; PORTS_RedLedOff; PORTS_RedLedToggle
   86:  					PORTS_GreenLedOn; PORTS_GreenLedOff; PORTS_GreenLedToggle
   87:  					PORTS_RedGreenLedToggle; PORTS_BothLedOff
   88:  INPUT/OUTPUT : None
   89:  
   90:  DESCRIPTION  : Set/Reset/Toggle Red or Green  or Both LED
   91:  
   92:  COMMENTS     :
   93:  -----------------------------------------------------------------------------*/
   94:  void PORTS_RedLedOn(void)
   95:  {

Function: PORTS_RedLedOn
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

   96:  	PBDDR |= LED; 				//PB7 push-pull Output
  0000 1e00     BSET  PBDDR,#7
   97:  	PBOR  |= LED;        
  0002 1e00     BSET  PBOR,#7
   98:  	PBDR  |= LED;
  0004 1e00     BSET  PBDR,#7
   99:  }
  0006 81       RET   
  100:  
  101:  void PORTS_RedLedOff(void)
  102:  {

Function: PORTS_RedLedOff
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  103:  	PBOR  &= (u8)~LED;      // touch PBOR first
  0000 1f00     BRES  PBOR,#7
  104:  	PBDDR &= (u8)~LED; 		// then PBDDR -> PB7 Floating Input
  0002 1f00     BRES  PBDDR,#7
  105:  }
  0004 81       RET   
  106:  
  107:  void PORTS_RedLedToggle(void)
  108:  {

Function: PORTS_RedLedToggle
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  109:  if (ValBit(PBDDR,PB7))    // push-pull config?
  0000 0f0005   BTJF  PBDDR,#7,*8 ;abs = 0008
  110:  		{
  111:  		PBOR  &= (u8)~LED;
  0003 1f00     BRES  PBOR,#7
  112:  		PBDDR &= (u8)~LED; //Toggle PB7 direction (Floating Input or push-pull Output)
  0005 1f00     BRES  PBDDR,#7
  113:      	}
  0007 81       RET   
  114:  else
  115:  		{
  116:  		PBDDR |= LED; 		//Toggle PB7 direction (Floating Input or push-pull Output)
  0008 1e00     BSET  PBDDR,#7
  117:  		PBOR  |= LED;
  000a 1e00     BSET  PBOR,#7
  118:  		PBDR  |= LED;		// ((u8)0x80)
  000c 1e00     BSET  PBDR,#7
  119:  		}
  120:  }
  000e 81       RET   
  121:  
  122:  void PORTS_GreenLedOn(void)
  123:  {

Function: PORTS_GreenLedOn
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  124:  	PBDDR |= LED; 			//PB7 push-pull Output
  0000 1e00     BSET  PBDDR,#7
  125:  	PBOR  |= LED;        
  0002 1e00     BSET  PBOR,#7
  126:  	PBDR  &= (u8)~LED;
  0004 1f00     BRES  PBDR,#7
  127:  }
  0006 81       RET   
  128:  
  129:  void PORTS_GreenLedOff(void)
  130:  {

Function: PORTS_GreenLedOff
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  131:  	PBOR  &= (u8)~LED;      // touch first PBOR
  0000 1f00     BRES  PBOR,#7
  132:  	PBDDR &= (u8)~LED; 		// then PBDDR -> PB7 Floating Input
  0002 1f00     BRES  PBDDR,#7
  133:  }
  0004 81       RET   
  134:  
  135:  void PORTS_GreenLedToggle(void)
  136:  {

Function: PORTS_GreenLedToggle
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  137:  	if (ValBit(PBDDR,PB7))          // output config?
  0000 0f0005   BTJF  PBDDR,#7,*8 ;abs = 0008
  138:  		{
  139:  		PBOR  &= (u8)~LED;
  0003 1f00     BRES  PBOR,#7
  140:  		PBDDR &= (u8)~LED; 				//Toggle PB7 direction (Floating Input or push-pull Output)
  0005 1f00     BRES  PBDDR,#7
  141:      	}
  0007 81       RET   
  142:  	else
  143:  		{
  144:  		PBDDR |= LED; 		//Toggle PB7 direction (Floating Input or push-pull Output)
  0008 1e00     BSET  PBDDR,#7
  145:  		PBOR  |= LED;
  000a 1e00     BSET  PBOR,#7
  146:  		PBDR  &= (u8)~LED;
  000c 1f00     BRES  PBDR,#7
  147:  		}
  148:  }
  000e 81       RET   
  149:  
  150:  void PORTS_RedGreenLedToggle(void)
  151:  {

Function: PORTS_RedGreenLedToggle
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  152:  if (!ValBit(PBDDR,PB7))
  0000 0e0004   BTJT  PBDDR,#7,*7 ;abs = 0007
  153:  	{
  154:  	PBDDR |= LED; 		//Toggle PB7 direction (Floating Input or push-pull Output)
  0003 1e00     BSET  PBDDR,#7
  155:  	PBOR  |= LED; 
  0005 1e00     BSET  PBOR,#7
  156:  	}
  157:  PBDR ^= LED;
  0007 b600     LD    A,PBDR
  0009 a880     XOR   A,#128
  000b b700     LD    PBDR,A
  158:  }	
  000d 81       RET   
  159:  
  160:  void PORTS_BothLedOff(void)
  161:  {

Function: PORTS_BothLedOff
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  162:  	PBDDR &= (u8)~LED; 		//PB7 Floating Input
  0000 1f00     BRES  PBDDR,#7
  163:  	PBOR  &= (u8)~LED;
  0002 1f00     BRES  PBOR,#7
  164:  }
  0004 81       RET   
  165:  
  166:  /*-----------------------------------------------------------------------------
  167:  ROUTINE Name :  key_scan
  168:  Description :  return TRUE if button is read and released
  169:  -----------------------------------------------------------------------------*/ 
  170:  BOOL PORTS_KeyScan(void)
  171:  {

Function: PORTS_KeyScan
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  172:  if (!ValBit(BUTTON_PORT,BUTTON)) // Button released (Pull-up resistor)
  0000 00001e   BTJT  PCDR,#0,*33 ;abs = 0021
  173:  	{
  174:    	switch(KeyState)
  0003 c60000   LD    A,KeyState
  0006 2710     JREQ  *18 ;abs = 0018
  0008 a102     CP    A,#2
  000a 2619     JRNE  *27 ;abs = 0025
  175:  		{
  176:  		case KEY_PUSHED:
  177:                 	if (DebounceButton == 0) 
  000c c60000   LD    A,DebounceButton
  000f 4d       TNZ   A
  0010 2613     JRNE  *21 ;abs = 0025
  178:  		    		{
  179:  		    		KeyState = KEY_IDLE_NEXT;
  0012 a601     LD    A,#1
  0014 c70000   LD    KeyState,A
  180:  		    		return (TRUE);
  0017 81       RET   
  181:  		    		}
  182:  				else return (FALSE);
  183:  				break;
  184:  		case KEY_IDLE:
  185:  				DebounceButton = 10;	// 100ms debounce time
  0018 a60a     LD    A,#10
  001a c70000   LD    DebounceButton,A
  186:              KeyState = KEY_PUSHED;
  001d a602     LD    A,#2
  187:  				return(FALSE);
  001f 2001     JRT   *3 ;abs = 0022
  188:  				break;
  189:          case KEY_IDLE_NEXT:
  190:  		default:
  191:  				return(FALSE);
  192:  				break;
  193:  		}
  194:  	}
  195:  else KeyState = KEY_IDLE;
  0021 4f       CLR   A
  0022 c70000   LD    KeyState,A
  196:  return(FALSE);
  0025 4f       CLR   A
  197:  }
  0026 81       RET   
  198:  
  199:  #ifdef __HIWARE__				/* test for HIWARE Compiler */
  200:  #pragma TRAP_PROC SAVE_REGS		/* additional registers will be saved */
  201:  #else
  202:  #ifdef __CSMC__					/* test for Cosmic Compiler */
  203:  @interrupt						/* Cosmic interrupt handling */
  204:  #else
  205:  #error"Unsupported Compiler!"	/* Compiler Defines not found! */
  206:  #endif
  207:  #endif
  208:  
  209:  /*-----------------------------------------------------------------------------
  210:  ROUTINE NAME : PORTS_0_Interrupt
  211:  INPUT/OUTPUT : None
  212:  
  213:  DESCRIPTION  : 
  214:  
  215:  COMMENTS     : 
  216:  -----------------------------------------------------------------------------*/ 
  217:  void PORTS_0_Interrupt(void)
  218:  {

Function: PORTS_0_Interrupt
Source  : ..\..\source\ports.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  0000 9089     PUSH  Y
  0002 b600     LD    A,_R_Z
  0004 88       PUSH  A
  0005 b601     LD    A,_LEX:1
  0007 88       PUSH  A
  0008 b600     LD    A,_LEX
  000a 88       PUSH  A
  000b b601     LD    A,_SEX:1
  000d 88       PUSH  A
  000e b600     LD    A,_SEX
  0010 88       PUSH  A
  219:  
  220:  }
  0011 84       POP   A
  0012 b700     LD    _SEX,A
  0014 84       POP   A
  0015 b701     LD    _SEX:1,A
  0017 84       POP   A
  0018 b700     LD    _LEX,A
  001a 84       POP   A
  001b b701     LD    _LEX:1,A
  001d 84       POP   A
  001e b700     LD    _R_Z,A
  0020 9085     POP   Y
  0022 80       IRET  
  221:  
  222:  /*** (c) 2004  STMicroelectronics ****************** END OF FILE ***/

⌨️ 快捷键说明

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