📄 freescale
字号:
/** ###################################################################
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : LCD_CONTROL.C
** Project : handheld_ultrasonic_rangefinder
** Processor : MC9S08JM60CLHE
** Component : BitsIO
** Version : Component 02.102, Driver 03.22, CPU db: 3.00.046
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2010-1-8, 19:43
** 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 : PTC
**
** Bit mask of the port : $0007
** Number of bits/pins : 3
** Single bit numbers : 0 to 2
** Values range : 0 to 7
**
** Initial direction : Output (direction cannot be changed)
** Initial output value : 0 = 000H
** Initial pull option : off
**
** Port data register : PTCD [$0004]
** Port control register : PTCDD [$0005]
**
** ----------------------------------------------------
** Bit | Pin | Name
** ----------------------------------------------------
** 0 | 60 | PTC0_SCL
** 1 | 61 | PTC1_SDA
** 2 | 62 | PTC2
** ----------------------------------------------------
**
** Optimization for : speed
** Contents :
** GetDir - bool LCD_CONTROL_GetDir(void);
** GetVal - byte LCD_CONTROL_GetVal(void);
** PutVal - void LCD_CONTROL_PutVal(byte Val);
** GetBit - bool LCD_CONTROL_GetBit(byte Bit);
** PutBit - void LCD_CONTROL_PutBit(byte Bit, bool Val);
** SetBit - void LCD_CONTROL_SetBit(byte Bit);
** ClrBit - void LCD_CONTROL_ClrBit(byte Bit);
** NegBit - void LCD_CONTROL_NegBit(byte Bit);
**
** Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**
** http : www.freescale.com
** mail : support@freescale.com
** ###################################################################*/
/* MODULE LCD_CONTROL. */
#include "LCD_CONTROL.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 : LCD_CONTROL_GetMsk (component 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 LCD_CONTROL_Table[3] = { /* Table of mask constants */
0x01, 0x02, 0x04
};
static byte LCD_CONTROL_GetMsk (byte PinIndex)
{
return (byte)(PinIndex<3 ? LCD_CONTROL_Table[PinIndex] : 0); /* Check range and return appropriate bit mask */
}
/*
** ===================================================================
** Method : LCD_CONTROL_GetVal (component 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 7)
** ===================================================================
*/
byte LCD_CONTROL_GetVal(void)
{
return (byte)(getReg8(PTCD) & 0x07); /* Return port data */
}
/*
** ===================================================================
** Method : LCD_CONTROL_PutVal (component BitsIO)
**
** Description :
** This method writes the new output value.
** Parameters :
** NAME - DESCRIPTION
** Val - Output value (0 to 7)
** Returns : Nothing
** ===================================================================
*/
void LCD_CONTROL_PutVal(byte Val)
{
Val &= 0x07; /* Mask output value */
setReg8(PTCD, (getReg8(PTCD) & (~0x07)) | Val); /* Put masked value on port */
}
/*
** ===================================================================
** Method : LCD_CONTROL_GetBit (component 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 2)
** Returns :
** --- - Value of the specified bit (FALSE or TRUE)
** FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool LCD_CONTROL_GetBit(byte Bit)
{
byte const Mask = LCD_CONTROL_GetMsk(Bit); /* Temporary variable - bit mask to test */
return (bool)((getReg8(PTCD) & Mask) == Mask); /* Test if specified bit of port register is set */
}
/*
** ===================================================================
** Method : LCD_CONTROL_PutBit (component 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 2)
** Val - New value of the bit (FALSE or TRUE)
** FALSE = "0" or "Low", TRUE = "1" or "High"
** Returns : Nothing
** ===================================================================
*/
void LCD_CONTROL_PutBit(byte Bit, bool Val)
{
byte const Mask = LCD_CONTROL_GetMsk(Bit); /* Temporary variable - put bit mask */
if (Val) {
setReg8Bits(PTCD, Mask); /* [bit (Bit)]=0x01 */
} else { /* !Val */
clrReg8Bits(PTCD, Mask); /* [bit (Bit)]=0x00 */
} /* !Val */
}
/*
** ===================================================================
** Method : LCD_CONTROL_ClrBit (component 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 2)
** Returns : Nothing
** ===================================================================
*/
void LCD_CONTROL_ClrBit(byte Bit)
{
byte const Mask = LCD_CONTROL_GetMsk(Bit); /* Temporary variable - set bit mask */
clrReg8Bits(PTCD, Mask); /* [bit (Bit)]=0x00 */
}
/*
** ===================================================================
** Method : LCD_CONTROL_SetBit (component 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 2)
** Returns : Nothing
** ===================================================================
*/
void LCD_CONTROL_SetBit(byte Bit)
{
byte const Mask = LCD_CONTROL_GetMsk(Bit); /* Temporary variable - set bit mask */
setReg8Bits(PTCD, Mask); /* [bit (Bit)]=0x01 */
}
/*
** ===================================================================
** Method : LCD_CONTROL_NegBit (component 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 LCD_CONTROL_NegBit(byte Bit)
{
byte const Mask = LCD_CONTROL_GetMsk(Bit); /* Temporary variable - set bit mask */
invertReg8Bits(PTCD, Mask); /* [bit (Bit)]=invert */
}
/*
** ===================================================================
** Method : LCD_CONTROL_GetDir (component 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 LCD_CONTROL_GetDir(void)
** This method is implemented as a macro. See LCD_CONTROL.h file. **
*/
/* END LCD_CONTROL. */
/*
** ###################################################################
**
** This file was created by Processor Expert 3.07 [04.34]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -