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

📄 freescale

📁 Freescale 系列单片机常用模块与综合系统设计
💻
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : LED.C
**     Project   : Flash_Led
**     Processor : MC9S08JM60CLHE
**     Beantype  : BitsIO
**     Version   : Bean 02.097, Driver 03.17, CPU db: 3.00.033
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 2009-9-4, 16:34
**     Abstract  :
**         This bean "BitsIO" implements a multi-bit input/output.
**         It uses selected pins of one 1-bit to 8-bit port.
**         Note: This bean is set to work in Output direction only.
**     Settings  :
**         Port name                   : PTB
**
**         Bit mask of the port        : $00FF
**         Number of bits/pins         : 8
**         Single bit numbers          : 0 to 7
**         Values range                : 0 to 255
**
**         Initial direction           : Output (direction cannot be changed)
**         Initial output value        : 0 = 000H
**         Initial pull option         : off
**
**         Port data register          : PTBD      [$0002]
**         Port control register       : PTBDD     [$0003]
**
**             ----------------------------------------------------
**                   Bit     |   Pin   |   Name
**             ----------------------------------------------------
**                    0      |    34   |   PTB0_MISO2_ADP0
**                    1      |    35   |   PTB1_MOSI2_ADP1
**                    2      |    36   |   PTB2_SPSCK2_ADP2
**                    3      |    37   |   PTB3_SS2_ADP3
**                    4      |    38   |   PTB4_KBIP4_ADP4
**                    5      |    39   |   PTB5_KBIP5_ADP5
**                    6      |    40   |   PTB6_ADP6
**                    7      |    41   |   PTB7_ADP7
**             ----------------------------------------------------
**
**         Optimization for            : speed
**     Contents  :
**         GetDir - bool LED_GetDir(void);
**         GetVal - byte LED_GetVal(void);
**         PutVal - void LED_PutVal(byte Val);
**         GetBit - bool LED_GetBit(byte Bit);
**         PutBit - void LED_PutBit(byte Bit, bool Val);
**         SetBit - void LED_SetBit(byte Bit);
**         ClrBit - void LED_ClrBit(byte Bit);
**         NegBit - void LED_NegBit(byte Bit);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2008
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

/* MODULE LED. */

#include "LED.h"
  /* Including shared modules, which are used in the whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "Cpu.h"


/*
** ===================================================================
**     Method      :  LED_GetMsk (bean BitsIO)
**
**     Description :
**         The method returns a bit mask which corresponds to the 
**         required bit position.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static const  byte LED_Table[8] = {    /* Table of mask constants */
   0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
};

static byte LED_GetMsk (byte PinIndex)
{
  return (byte)(PinIndex<8 ? LED_Table[PinIndex] : 0); /* Check range and return appropriate bit mask */
}

/*
** ===================================================================
**     Method      :  LED_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
**         Note: This bean is set to work in Output direction only.
**     Parameters  : None
**     Returns     :
**         ---        - Input value (0 to 255)
** ===================================================================
*/
byte LED_GetVal(void)
{
  return (byte)(getReg8(PTBD) & 0xFF); /* Return port data */
}

/*
** ===================================================================
**     Method      :  LED_PutVal (bean BitsIO)
**
**     Description :
**         This method writes the new output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Val        - Output value (0 to 255)
**     Returns     : Nothing
** ===================================================================
*/
void LED_PutVal(byte Val)
{
  Val &= 0xFF;                         /* Mask output value */
  setReg8(PTBD, (getReg8(PTBD) & (~0xFF)) | Val); /* Put masked value on port */
}

/*
** ===================================================================
**     Method      :  LED_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
**         Note: This bean is set to work in Output direction only.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to read (0 to 7)
**     Returns     :
**         ---        - Value of the specified bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool LED_GetBit(byte Bit)
{
  byte const Mask = LED_GetMsk(Bit);   /* Temporary variable - bit mask to test */
  return (bool)((getReg8(PTBD) & Mask) == Mask); /* Test if specified bit of port register is set */
}

/*
** ===================================================================
**     Method      :  LED_PutBit (bean BitsIO)
**
**     Description :
**         This method writes the new value to the specified bit
**         of the output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit (0 to 7)
**         Val        - New value of the bit (FALSE or TRUE)
**                      FALSE = "0" or "Low", TRUE = "1" or "High"
**     Returns     : Nothing
** ===================================================================
*/
void LED_PutBit(byte Bit, bool Val)
{
  byte const Mask = LED_GetMsk(Bit);   /* Temporary variable - put bit mask */
  if (Val) {
    setReg8Bits(PTBD, Mask);           /* [bit (Bit)]=0x01 */
  } else { /* !Val */
    clrReg8Bits(PTBD, Mask);           /* [bit (Bit)]=0x00 */
  } /* !Val */
}

/*
** ===================================================================
**     Method      :  LED_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);" ]
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to clear (0 to 7)
**     Returns     : Nothing
** ===================================================================
*/
void LED_ClrBit(byte Bit)
{
  byte const Mask = LED_GetMsk(Bit);   /* Temporary variable - set bit mask */
  clrReg8Bits(PTBD, Mask);             /* [bit (Bit)]=0x00 */
}

/*
** ===================================================================
**     Method      :  LED_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);" ]
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to set (0 to 7)
**     Returns     : Nothing
** ===================================================================
*/
void LED_SetBit(byte Bit)
{
  byte const Mask = LED_GetMsk(Bit);   /* Temporary variable - set bit mask */
  setReg8Bits(PTBD, Mask);             /* [bit (Bit)]=0x01 */
}

/*
** ===================================================================
**     Method      :  LED_NegBit (bean BitsIO)
**
**     Description :
**         This method negates (inverts) the specified bit of the
**         output value.
**     Parameters  :
**         NAME       - DESCRIPTION
**         Bit        - Number of the bit to invert (0 to 31)
**     Returns     : Nothing
** ===================================================================
*/
void LED_NegBit(byte Bit)
{
  byte const Mask = LED_GetMsk(Bit);   /* Temporary variable - set bit mask */
  invertReg8Bits(PTBD, Mask);          /* [bit (Bit)]=invert */
}

/*
** ===================================================================
**     Method      :  LED_GetDir (bean BitsIO)
**
**     Description :
**         This method returns direction of the bean.
**     Parameters  : None
**     Returns     :
**         ---        - Direction of the bean (always TRUE, Output only)
**                      FALSE = Input, TRUE = Output
** ===================================================================
*/
/*
bool LED_GetDir(void)

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


/* END LED. */
/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 3.03 [04.07]
**     for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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