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

📄 bits1.c

📁 基于56F8346的异步电机VVVF控制程序。
💻 C
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Bits1.C
**     Project   : vvvf_56F8346
**     Processor : 56F8346
**     Beantype  : BitsIO
**     Version   : Bean 02.045, Driver 01.08, CPU db: 2.87.069
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2008-2-3, 下午 02:57
**     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                   : GPIOA_High
**
**         Bit mask of the port        : 256
**         Number of bits/pins         : 1
**         Single bit numbers          : 0 to 0
**         Values range                : 0 to 1
**
**         Initial direction           : Output (direction can be changed)
**         Safe mode                   : yes
**         Initial output value        : 0 = 000H
**         Initial pull option         : off
**
**         Port data register          : GPIO_A_DR [62177]
**         Port control register       : GPIO_A_DDR [62178]
**         Port function register      : GPIO_A_PER [62179]
**
**             ----------------------------------------------------
**                   Bit     |   Pin   |   Name
**             ----------------------------------------------------
**                    0      |    138  |   GPIOA8_A0
**             ----------------------------------------------------
**
**         Optimization for            : speed
**     Contents  :
**         GetDir - bool Bits1_GetDir(void);
**         SetDir - void Bits1_SetDir(bool Dir);
**         GetVal - byte Bits1_GetVal(void);
**         PutVal - void Bits1_PutVal(byte Val);
**         GetBit - bool Bits1_GetBit(byte Bit);
**         PutBit - void Bits1_PutBit(byte Bit,bool Val);
**         SetBit - void Bits1_SetBit(byte Bit);
**         ClrBit - void Bits1_ClrBit(byte Bit);
**         NegBit - void Bits1_NegBit(byte Bit);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2004
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

/* MODULE Bits1. */

#include "Bits1.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 Bits1_Table[1]={ 
256};                                     /* Table of mask constants */
/*
** ===================================================================
**     Method      :  Bits1_GetMsk (bean BitsIO)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
static word Bits1_GetMsk(byte Value)
{
  return((Value<1)?Bits1_Table[Value]:(word)0); /* Return appropriate bit mask */
}

/*
** ===================================================================
**     Method      :  Bits1_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 1)
** ===================================================================
*/
/*
byte Bits1_GetVal(void)

**  This method is implemented as a macro. See Bits1.h file.  **
*/

/*
** ===================================================================
**     Method      :  Bits1_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 1)
**     Returns     : Nothing
** ===================================================================
*/
void Bits1_PutVal(byte Val)
{
  register word Temp;                  /* Temporary variable */

  Temp = (((word)Val)<<8) & Bits1_PIN_MASK; /* Prepare value for output */
  Shadow_GPIO_A_DR = Shadow_GPIO_A_DR & ~Bits1_PIN_MASK | Temp; /* Set-up bits in shadow variable */
  setReg(GPIO_A_DR,(getReg(GPIO_A_DR)) & ~Bits1_PIN_MASK | Temp); /* Set-up bits on port */
}

/*
** ===================================================================
**     Method      :  Bits1_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 0)
**     Returns     :
**         ---        - Value of the specified bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool Bits1_GetBit(byte Bit)
{
  register word Mask=Bits1_GetMsk(Bit); /* Temporary variable - bit mask */

  return((bool)((Mask)?((getReg(GPIO_A_DR)) & Mask) == Mask:(bool)0)); /* Return input value */
}

/*
** ===================================================================
**     Method      :  Bits1_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 0)
**         Val        - New value of the bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
**     Returns     : Nothing
** ===================================================================
*/
void Bits1_PutBit(byte Bit, bool Val)
{
  register word Mask=Bits1_GetMsk(Bit); /* Temporary variable - bit mask */

  if (Mask)                            /* Is bit mask correct? */
    if (Val) {                         /* Is it one to be written? */
      Shadow_GPIO_A_DR |= Mask;        /* Set appropriate bit in shadow variable */
      setRegBits(GPIO_A_DR,Mask);      /* Set appropriate bit on port */
    }
    else {                             /* Is it zero to be written? */
      Shadow_GPIO_A_DR &= ~Mask;       /* Clear appropriate bit in shadow variable */
      clrRegBits(GPIO_A_DR,Mask);      /* Clear appropriate bit on port */
    }
}

/*
** ===================================================================
**     Method      :  Bits1_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
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly writes "1" to the
**                                   appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to set (0 to 0)
**     Returns     : Nothing
** ===================================================================
*/
void Bits1_SetBit(byte Bit)
{
  register word Mask=Bits1_GetMsk(Bit); /* Temporary variable - bit mask */

  if (Mask) {                          /* Is bit mask correct? */
    Shadow_GPIO_A_DR |= Mask;          /* Set appropriate bit in shadow variable */
    setRegBits(GPIO_A_DR,Mask);        /* Set appropriate bit on port */
  }
}

/*
** ===================================================================
**     Method      :  Bits1_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 0)
**     Returns     : Nothing
** ===================================================================
*/
void Bits1_ClrBit(byte Bit)
{
  register word Mask=Bits1_GetMsk(Bit); /* Temporary variable - bit mask */

  if (Mask) {                          /* Is bit mask correct? */
    Shadow_GPIO_A_DR &= ~Mask;         /* Clear appropriate bit in shadow variable */
    clrRegBits(GPIO_A_DR,Mask);        /* Clear appropriate bit on port */
  }
}

/*
** ===================================================================
**     Method      :  Bits1_NegBit (bean BitsIO)
**
**     Description :
**         This method negates (invertes) the specified bit of the
**         output value.
**           a) direction = Input  : invertes the specified bit;
**                                   this operation will be shown on
**                                   output after the direction has
**                                   been switched to output
**                                   (SetDir(TRUE);)
**           b) direction = Output : directly invertes the value
**                                   of the appropriate pin
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to invert (0 to 31)
**     Returns     : Nothing
** ===================================================================
*/
void Bits1_NegBit(byte Bit)
{
  register word Mask=Bits1_GetMsk(Bit); /* Temporary variable - bit mask */

  if (Mask) {                          /* Is bit mask correct? */
    Shadow_GPIO_A_DR ^= Mask;          /* Negate appropriate bit in shadow variable */
    changeRegBits(GPIO_A_DR,Mask);     /* Negate appropriate bit on port */
  }
}

/*
** ===================================================================
**     Method      :  Bits1_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 Bits1_SetDir(bool Dir)
{
  if (Dir) {                           /* Is given direction output? */
    setReg(GPIO_A_DR,((getReg(GPIO_A_DR)) & ~Bits1_PIN_MASK)|(Shadow_GPIO_A_DR & Bits1_PIN_MASK)); /* Restore correct value of output from shadow variable */
    setRegBits(GPIO_A_DDR,Bits1_PIN_MASK); /* Set direction to output */
  }
  else {                               /* Is direction input? */
    clrRegBits(GPIO_A_DDR,Bits1_PIN_MASK); /* Set direction to input */
  }
}

/*
** ===================================================================
**     Method      :  Bits1_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 Bits1_GetDir(void)

**  This method is implemented as a macro. See Bits1.h file.  **
*/

/* END Bits1. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 03.47 for 
**     the Motorola 56800 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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