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

📄 mmz_rab.lib

📁 modbus 运用事例
💻 LIB
📖 第 1 页 / 共 3 页
字号:
PARAMETER1: baud rate (bits per second).

RETURN VALUE: Always 1.
END DESCRIPTION ******************************************************/
nodebug
int mmrDinit(unsigned long	qBaud)
{
	mmrInit(qBaud);
	return mmDinit(qBaud);
}

/*** BeginHeader */
#if ( _CPU_ID_ >= R3000 )
/*** EndHeader */

/*** BeginHeader mmrEinit */
int mmrEinit(unsigned long);
/*** EndHeader */

/* START FUNCTION DESCRIPTION *****************************************
mmrEinit                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: int mmrEinit(unsigned long qBaud, unsigned wMode)

DESCRIPTION: Initialize serial port E as Modbus RTU Master.
					(Not supported for R2000 CPU products)          
PARAMETER1: baud rate (bits per second).

RETURN VALUE: Always 1.
END DESCRIPTION ******************************************************/
nodebug
int mmrEinit(unsigned long	qBaud)
{
	mmrInit(qBaud);
	return mmEinit(qBaud);
}

/*** BeginHeader mmrFinit */
int mmrFinit(unsigned long);
/*** EndHeader */

/* START FUNCTION DESCRIPTION *****************************************
mmrFinit                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: int mmrFinit(unsigned long qBaud, unsigned wMode)

DESCRIPTION: Initialize serial port F as Modbus RTU Master.
					(Not supported for R2000 CPU products)          
PARAMETER1: baud rate (bits per second).

RETURN VALUE: Always 1.
END DESCRIPTION ******************************************************/
nodebug
int mmrFinit(unsigned long	qBaud)
{
	mmrInit(qBaud);
	return mmFinit(qBaud);
}

/*** BeginHeader */
#endif	//	#if ( _CPU_ID_ >= R3000 )  
/*** EndHeader */

/* START FUNCTION DESCRIPTION *****************************************
mmAopen                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 	int mmAopen(unsigned qBaud)

DESCRIPTION: User function for
				 Initializing serial port A as a Modbus Master.
				 
				 This function must reside in your application code.
				 Typical code for this function would be the following;
				 
int mmAopen(unsigned qBaud)        
{
	// Open the serial port.  THIS MUST BE DONE PRIOR TO SETTING THE
	// DATA BITS AND PARITY SETTINGS.
	
	if (serAopen(qBaud))
	{ 
	  
		// setup parity.  Either PARAM_OPARITY, PARAM_EPARITY, PARAM_NOPARITY, 
		// or PARAM_2STOP  
	
		serAparity(PARAM_EPARITY);
	 
		// setup data bits. Either PARAM_7BIT, or PARAM_8BIT 
		 
		serAdatabits(PARAM_8BIT);
	
  		// Set the Serial port mode. Used for Zworld SBC's only.  
		serMode(0);  
		return(1);
	}
	else return (0);
}
				 

PARAMETER1: slave address.
PARAMETER2: baud rate (bits per second).

RETURN VALUE: 1 if successful, 0 if unsupported baud rate.
END DESCRIPTION ******************************************************/

/* START FUNCTION DESCRIPTION *****************************************
mmArx                         <MSZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 			void	mmArx  (void)

DESCRIPTION: 	User defineable function for disabling the rs485
					transmitter.  This function is needed in your application
					code.  If you are doing RS232, you need only to have
					an empty function like
					
					void mmArx(void)
					{
					}
					
					For rs485 control, you can do the following;

EXAMPLE:	  void mmArx(void)
			  {
			    // Ensure that all the data has bent sent.
			    
			    while (serAwrUsed() || \
			    		  BitRdPortI(SASR,2) || \
			    		  BitRdPortI(SASR,3)); 
				
				// Turn off the RS485 transmitter by doing the following;
				
				//	PORT:				The parrallel port (PADR,PBDR,PCDR etc)          
				// PORTShadow: 	The Shadow register of the port
				//	OFF_VALUE:		1 or 0
				//	PORT_BIT:		parrallel port bit (0-7)
				
					BitWrPortI(PORT,&PORTShadow, OFF_VALUE, PORT_BIT);
					
				//  If your product is a Zworld SBC, you can do the following
				
					ser485Rx();
					
				//  Flush out the serial port read buffer, so you are ready for
				//  the next packet.
					
					serArdFlush();	 
			  }			

RETURN VALUE: none
END DESCRIPTION ******************************************************/

/* START FUNCTION DESCRIPTION *****************************************
mmAtx                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 			void	mmAtx  (void)

DESCRIPTION: 	User defineable function for enabling the rs485
					transmitter.  This function is needed in your application
					code.  If you are doing RS232, you need only to have
					an empty function like
					
					void mmAtx(void)
					{
					}
					
					For rs485 control, you can do the following;

EXAMPLE:	  void mmAtx(void)
			  {
			    // Ensure that all the data has bent sent.
			    
			    / Turn on the RS485 transmitter by doing the following;      
				
				//	PORT:				The parrallel port (PADR,PBDR,PCDR etc)          
				// PORTShadow: 	The Shadow register of the port
				//	ON_VALUE:		1 or 0
				//	PORT_BIT:		parrallel port bit (0-7)
				
					BitWrPortI(PORT,&PORTShadow, ON_VALUE, PORT_BIT);
			    
			    				
				//  If your product is a Zworld SBC, you can do the following
				
					ser485Tx();
					
				
			  }			

RETURN VALUE: none
END DESCRIPTION ******************************************************/
/* START FUNCTION DESCRIPTION *****************************************
mmBopen                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 	int mmBopen(unsigned qBaud)

DESCRIPTION: User function for
				 Initializing serial port B as a Modbus Master.
				 
				 This function must reside in your application code.
				 Typical code for this function would be the following;
				 
int mmBopen(unsigned qBaud)        
{
	// Open the serial port.  THIS MUST BE DONE PRIOR TO SETTING THE
	// DATA BITS AND PARITY SETTINGS.
	
	if (serBopen(qBaud))
	{ 
	  
  		// setup parity.  Either PARAM_OPARITY, PARAM_EPARITY, PARAM_NOPARITY, 
  		// or PARAM_2STOP  
	
  		serBparity(PARAM_EPARITY);
	 
  		// setup data bits. Either PARAM_7BIT, or PARAM_8BIT 
	 
  		serBdatabits(PARAM_8BIT);
	
 	 	// Set the Serial port mode. Used for Zworld SBC's only.  
  		serMode(0);  
  		return(1);
	}
	else return (0);
}
				 

PARAMETER1: slave address.
PARAMETER2: baud rate (bits per second).

RETURN VALUE: 1 if successful, 0 if unsupported baud rate.
END DESCRIPTION ******************************************************/
/* START FUNCTION DESCRIPTION *****************************************
mmBrx                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 			void	mmBrx  (void)

DESCRIPTION: 	User defineable function for disabling the rs485
					transmitter.  This function is needed in your application
					code.  If you are doing RS232, you need only to have
					an empty function like
					
					void mmBrx(void)
					{
					}
					
					For rs485 control, you can do the following;

EXAMPLE:	  void mmBrx(void)
			  {
			    // Ensure that all the data has bent sent.
			    
			    while (serBwrUsed() || \
			    		  BitRdPortI(SBSR,2) || \
			    		  BitRdPortI(SBSR,3)); 
				
				// Turn off the RS485 transmitter by doing the following;
				
				//	PORT:				The parrallel port (PADR,PBDR,PCDR etc)          
				// PORTShadow: 	The Shadow register of the port
				//	OFF_VALUE:		1 or 0
				//	PORT_BIT:		parrallel port bit (0-7)
				
					BitWrPortI(PORT,&PORTShadow, OFF_VALUE, PORT_BIT);
					
				//  If your product is a Zworld SBC, you can do the following
				
					ser485Rx();
					
				//  Flush out the serial port read buffer, so you are ready for
				//  the next packet.
					
					serBrdFlush();	 
			  }			

RETURN VALUE: none
END DESCRIPTION ******************************************************/


/* START FUNCTION DESCRIPTION *****************************************
mmBtx                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 			void	mmBtx  (void)

DESCRIPTION: 	User defineable function for enabling the rs485
					transmitter.  This function is needed in your application
					code.  If you are doing RS232, you need only to have
					an empty function like
					
					void mmBtx(void)
					{
					}
					
					For rs485 control, you can do the following;

EXAMPLE:	  void mmAtx(void)
			  {
			    // Ensure that all the data has bent sent.
			    
			    / Turn on the RS485 transmitter by doing the following;      
				
				//	PORT:				The parrallel port (PADR,PBDR,PCDR etc)          
				// PORTShadow: 	The Shadow register of the port
				//	ON_VALUE:		1 or 0
				//	PORT_BIT:		parrallel port bit (0-7)
				
					BitWrPortI(PORT,&PORTShadow, ON_VALUE, PORT_BIT);
			    
			    				
				//  If your product is a Zworld SBC, you can do the following
				//	 instead
					ser485Tx();
					
				
			  }			

RETURN VALUE: none
END DESCRIPTION ******************************************************/
/* START FUNCTION DESCRIPTION *****************************************
mmCopen                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 	int mmCopen(unsigned qBaud)

DESCRIPTION: User function for
				 Initializing serial port C as a Modbus Master.
				 
				 This function must reside in your application code.
				 Typical code for this function would be the following;
				 
int mmCopen(unsigned qBaud)        
{
	// Open the serial port.  THIS MUST BE DONE PRIOR TO SETTING THE
	// DATA BITS AND PARITY SETTINGS.
	
	if (serCopen(qBaud)) 
	{  
		// setup parity.  Either PARAM_OPARITY, PARAM_EPARITY, PARAM_NOPARITY, 
		// or PARAM_2STOP  
	
		serCparity(PARAM_EPARITY);
  		 
		// setup data bits. Either PARAM_7BIT, or PARAM_8BIT 
	 
  		serCdatabits(PARAM_8BIT);
	
 	 	// Set the Serial port mode. Used for Zworld SBC's only.  
  		serMode(0);  
  		return(1);
	}
	else return (0);
}
				 

PARAMETER1: slave address.
PARAMETER2: baud rate (bits per second).

RETURN VALUE: 1 if successful, 0 if unsupported baud rate.
END DESCRIPTION ******************************************************/
/* START FUNCTION DESCRIPTION *****************************************
mmCrx                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 			void	mmCrx  (void)

DESCRIPTION: 	User defineable function for disabling the rs485
					transmitter.  This function is needed in your application
					code.  If you are doing RS232, you need only to have
					an empty function like
					
					void mmCrx(void)
					{
					}
					
					For rs485 control, you can do the following;

EXAMPLE:	  void mmCrx(void)
			  {
			    // Ensure that all the data has bent sent.
			    
			    while (serCwrUsed() || \
			    		  BitRdPortI(SCSR,2) || \
			    		  BitRdPortI(SCSR,3)); 
				
				// Turn off the RS485 transmitter by doing the following;
				
				//	PORT:				The parrallel port (PADR,PBDR,PCDR etc)          
				// PORTShadow: 	The Shadow register of the port
				//	OFF_VALUE:		1 or 0
				//	PORT_BIT:		parrallel port bit (0-7)
				
					BitWrPortI(PORT,&PORTShadow, OFF_VALUE, PORT_BIT);
					
				// if your product is a Zworld SBC, you can do the following 
				//	instead
				
					ser485Rx();
					
				//  Flush out the serial port read buffer, so you are ready for
				//  the next packet.
					
					serCrdFlush();	 
			  }			

RETURN VALUE: none
END DESCRIPTION ******************************************************/

/* START FUNCTION DESCRIPTION *****************************************
mmCtx                         <MMZ_RAB.LIB>

NOTE: MMZ_RAB.LIB functions are generally not reentrant.

SYNTAX: 			void	mmCtx  (void)

DESCRIPTION: 	User defineable function for enabling the rs485
					transmitter.  This function is needed in your application
					code.  If you are doing RS232, you need only to have
					an empty function like
					
					void mmCtx(void)
					{

⌨️ 快捷键说明

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