?? bits_drivemosfet.c
字號:
/** ###################################################################
** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : Bits_Drivemosfet.C
** Project : vvvf_56F8346
** Processor : 56F8346
** Beantype : BitsIO
** Version : Bean 02.091, Driver 01.15, CPU db: 2.87.097
** Compiler : Metrowerks DSP C Compiler
** Date/Time : 2008-3-7, 9:38
** Abstract :
** This bean "BitsIO" implements a multi-bit input/output.
** It uses selected pins of one 1-bit to 8-bit port.
** Settings :
** Port name : GPIOE_High
**
** Bit mask of the port : 3072
** Number of bits/pins : 2
** Single bit numbers : 0 to 1
** Values range : 0 to 3
**
** Initial direction : Output (direction can be changed)
** Safe mode : yes
** Initial output value : 0 = 000H
** Initial pull option : off
**
** Port data register : GPIO_E_DR [62257]
** Port control register : GPIO_E_DDR [62258]
** Port function register : GPIO_E_PER [62259]
**
** ----------------------------------------------------
** Bit | Pin | Name
** ----------------------------------------------------
** 0 | 116 | GPIOE10_TD0
** 1 | 117 | GPIOE11_TD1
** ----------------------------------------------------
**
** Optimization for : speed
** Contents :
** GetDir - bool Bits_Drivemosfet_GetDir(void);
** SetDir - void Bits_Drivemosfet_SetDir(bool Dir);
** GetVal - byte Bits_Drivemosfet_GetVal(void);
** PutVal - void Bits_Drivemosfet_PutVal(byte Val);
** GetBit - bool Bits_Drivemosfet_GetBit(byte Bit);
** PutBit - void Bits_Drivemosfet_PutBit(byte Bit,bool Val);
** SetBit - void Bits_Drivemosfet_SetBit(byte Bit);
** ClrBit - void Bits_Drivemosfet_ClrBit(byte Bit);
** NegBit - void Bits_Drivemosfet_NegBit(byte Bit);
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE Bits_Drivemosfet. */
#include "Bits_Drivemosfet.h"
/*Include shared modules, which are used for whole project*/
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "Cpu.h"
static const word Bits_Drivemosfet_Table[2]={
1024,2048}; /* Table of mask constants */
/*
** ===================================================================
** Method : Bits_Drivemosfet_GetMsk (bean BitsIO)
**
** Description :
** Returns pin mask. The method is called automatically as a part
** of bit method.
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static word Bits_Drivemosfet_GetMsk(byte Value)
{
return((Value<2)?Bits_Drivemosfet_Table[Value]:(word)0); /* Return appropriate bit mask */
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_GetVal (bean BitsIO)
**
** Description :
** This method returns an input value.
** a) direction = Input : reads the input value from the
** pins and returns it
** b) direction = Output : returns the last written value
** Parameters : None
** Returns :
** --- - Input value (0 to 3)
** ===================================================================
*/
/*
byte Bits_Drivemosfet_GetVal(void)
** This method is implemented as a macro. See Bits_Drivemosfet.h file. **
*/
/*
** ===================================================================
** Method : Bits_Drivemosfet_PutVal (bean BitsIO)
**
** Description :
** This method writes the new output value.
** a) direction = Input : sets the new output value;
** this operation will be shown on
** output after the direction has
** been switched to output
** (SetDir(TRUE);)
** b) direction = Output : directly writes the value to the
** appropriate pins
** Parameters :
** NAME - DESCRIPTION
** Val - Output value (0 to 3)
** Returns : Nothing
** ===================================================================
*/
void Bits_Drivemosfet_PutVal(byte Val)
{
register word Temp; /* Temporary variable */
Temp = (((word)Val)<<10) & Bits_Drivemosfet_PIN_MASK; /* Prepare value for output */
Shadow_GPIO_E_DR = Shadow_GPIO_E_DR & ~Bits_Drivemosfet_PIN_MASK | Temp; /* Set-up bits in shadow variable */
setReg(GPIO_E_DR,(getReg(GPIO_E_DR)) & ~Bits_Drivemosfet_PIN_MASK | Temp); /* Set-up bits on port */
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_GetBit (bean BitsIO)
**
** Description :
** This method returns the specified bit of the input value.
** a) direction = Input : reads the input value from pins
** and returns the specified bit
** b) direction = Output : returns the specified bit
** of the last written value
** Parameters :
** NAME - DESCRIPTION
** Bit - Number of the bit to read (0 to 1)
** Returns :
** --- - Value of the specified bit (FALSE or TRUE)
** FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool Bits_Drivemosfet_GetBit(byte Bit)
{
register word Mask=Bits_Drivemosfet_GetMsk(Bit); /* Temporary variable - bit mask */
return((bool)((Mask)?((getReg(GPIO_E_DR)) & Mask) == Mask:(bool)0)); /* Return input value */
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_PutBit (bean BitsIO)
**
** Description :
** This method writes the new value to the specified bit
** of the output value.
** a) direction = Input : sets the value of the specified
** bit; this operation will be
** shown on output after the
** direction has been switched to
** output (SetDir(TRUE);)
** b) direction = Output : directly writes the value of the
** bit to the appropriate pin
** Parameters :
** NAME - DESCRIPTION
** Bit - Number of the bit (0 to 1)
** Val - New value of the bit (FALSE or TRUE)
** FALSE = "0" or "Low", TRUE = "1" or "High"
** Returns : Nothing
** ===================================================================
*/
void Bits_Drivemosfet_PutBit(byte Bit, bool Val)
{
register word Mask=Bits_Drivemosfet_GetMsk(Bit); /* Temporary variable - bit mask */
if (Mask) /* Is bit mask correct? */
if (Val) { /* Is it one to be written? */
Shadow_GPIO_E_DR |= Mask; /* Set appropriate bit in shadow variable */
setRegBits(GPIO_E_DR,Mask); /* Set appropriate bit on port */
}
else { /* Is it zero to be written? */
Shadow_GPIO_E_DR &= ~Mask; /* Clear appropriate bit in shadow variable */
clrRegBits(GPIO_E_DR,Mask); /* Clear appropriate bit on port */
}
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_SetBit (bean BitsIO)
**
** Description :
** This method sets (sets to one) the specified bit of the
** output value.
** [ It is the same as "PutBit(Bit,TRUE);" ]
** a) direction = Input : sets the specified bit to "1";
** this operation will be shown on
** output after the direction has
** (SetDir(TRUE);)
** b) direction = Output : directly writes "1" to the
** appropriate pin
** Parameters :
** NAME - DESCRIPTION
** Bit - Number of the bit to set (0 to 1)
** Returns : Nothing
** ===================================================================
*/
void Bits_Drivemosfet_SetBit(byte Bit)
{
register word Mask=Bits_Drivemosfet_GetMsk(Bit); /* Temporary variable - bit mask */
if (Mask) { /* Is bit mask correct? */
Shadow_GPIO_E_DR |= Mask; /* Set appropriate bit in shadow variable */
setRegBits(GPIO_E_DR,Mask); /* Set appropriate bit on port */
}
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_ClrBit (bean BitsIO)
**
** Description :
** This method clears (sets to zero) the specified bit
** of the output value.
** [ It is the same as "PutBit(Bit,FALSE);" ]
** a) direction = Input : sets the specified bit to "0";
** this operation will be shown on
** output after the direction has
** beenswitched to output
** (SetDir(TRUE);)
** b) direction = Output : directly writes "0" to the
** appropriate pin
** Parameters :
** NAME - DESCRIPTION
** Bit - Number of the bit to clear (0 to 1)
** Returns : Nothing
** ===================================================================
*/
void Bits_Drivemosfet_ClrBit(byte Bit)
{
register word Mask=Bits_Drivemosfet_GetMsk(Bit); /* Temporary variable - bit mask */
if (Mask) { /* Is bit mask correct? */
Shadow_GPIO_E_DR &= ~Mask; /* Clear appropriate bit in shadow variable */
clrRegBits(GPIO_E_DR,Mask); /* Clear appropriate bit on port */
}
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_NegBit (bean BitsIO)
**
** Description :
** This method negates (inverts) the specified bit of the
** output value.
** a) direction = Input : inverts the specified bit;
** this operation will be shown on
** output after the direction has
** been switched to output
** (SetDir(TRUE);)
** b) direction = Output : directly inverts the value
** of the appropriate pin
** Parameters :
** NAME - DESCRIPTION
** Bit - Number of the bit to invert (0 to 31)
** Returns : Nothing
** ===================================================================
*/
void Bits_Drivemosfet_NegBit(byte Bit)
{
register word Mask=Bits_Drivemosfet_GetMsk(Bit); /* Temporary variable - bit mask */
if (Mask) { /* Is bit mask correct? */
Shadow_GPIO_E_DR ^= Mask; /* Negate appropriate bit in shadow variable */
changeRegBits(GPIO_E_DR,Mask); /* Negate appropriate bit on port */
}
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_SetDir (bean BitsIO)
**
** Description :
** This method sets direction of the bean.
** Parameters :
** NAME - DESCRIPTION
** Dir - Direction to set (FALSE or TRUE)
** FALSE = Input, TRUE = Output
** Returns : Nothing
** ===================================================================
*/
void Bits_Drivemosfet_SetDir(bool Dir)
{
if (Dir) { /* Is given direction output? */
setReg(GPIO_E_DR,((getReg(GPIO_E_DR)) & ~Bits_Drivemosfet_PIN_MASK)|(Shadow_GPIO_E_DR & Bits_Drivemosfet_PIN_MASK)); /* Restore correct value of output from shadow variable */
setRegBits(GPIO_E_DDR,Bits_Drivemosfet_PIN_MASK); /* Set direction to output */
}
else { /* Is direction input? */
clrRegBits(GPIO_E_DDR,Bits_Drivemosfet_PIN_MASK); /* Set direction to input */
}
}
/*
** ===================================================================
** Method : Bits_Drivemosfet_GetDir (bean BitsIO)
**
** Description :
** This method returns direction of the bean.
** Parameters : None
** Returns :
** --- - Direction of the bean (FALSE or TRUE)
** FALSE = Input, TRUE = Output
** ===================================================================
*/
/*
bool Bits_Drivemosfet_GetDir(void)
** This method is implemented as a macro. See Bits_Drivemosfet.h file. **
*/
/* END Bits_Drivemosfet. */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 2.97 [03.74]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -