📄 freescale
字号:
/** ###################################################################
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : LCD_DATA.C
** Project : handheld_ultrasonic_rangefinder
** Processor : MC9S08JM60CLHE
** Component : ByteIO
** Version : Component 02.058, Driver 03.20, CPU db: 3.00.046
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2010-1-8, 19:44
** Abstract :
** This bean "ByteIO" implements an one-byte input/output.
** It uses one 8-bit port.
** Methods of this bean are mostly implemented as a macros
** (if supported by target langauage and compiler).
** Settings :
** Port name : PTB
**
** Initial direction : Output (direction can be changed)
** Safe mode : yes
** Initial output value : 0 = 000H
** Initial pull option : off
**
** 8-bit data register : PTBD [$0002]
** 8-bit 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
** ----------------------------------------------------
** Contents :
** GetDir - bool LCD_DATA_GetDir(void);
** SetDir - void LCD_DATA_SetDir(bool Dir);
** GetVal - byte LCD_DATA_GetVal(void);
** PutVal - void LCD_DATA_PutVal(byte Val);
** GetBit - bool LCD_DATA_GetBit(byte Bit);
** PutBit - void LCD_DATA_PutBit(byte Bit, bool Val);
** SetBit - void LCD_DATA_SetBit(byte Bit);
** ClrBit - void LCD_DATA_ClrBit(byte Bit);
** NegBit - void LCD_DATA_NegBit(byte Bit);
**
** Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**
** http : www.freescale.com
** mail : support@freescale.com
** ###################################################################*/
/* MODULE LCD_DATA. */
#include "LCD_DATA.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_DATA_GetMsk (component ByteIO)
**
** 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_DATA_Table[8] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
}; /* Table of mask constants */
static byte LCD_DATA_GetMsk (byte PinIndex)
{
return (byte)(PinIndex<8 ? LCD_DATA_Table[PinIndex] : 0); /* Check range and return appropriate bit mask */
}
/*
** ===================================================================
** Method : LCD_DATA_GetVal (component ByteIO)
**
** 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 255)
** ===================================================================
*/
/*
byte LCD_DATA_GetVal(void)
** This method is implemented as a macro. See LCD_DATA.h file. **
*/
/*
** ===================================================================
** Method : LCD_DATA_PutVal (component ByteIO)
**
** 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 255)
** Returns : Nothing
** ===================================================================
*/
/*
void LCD_DATA_PutVal(byte Val)
** This method is implemented as a macro. See LCD_DATA.h file. **
*/
/*
** ===================================================================
** Method : LCD_DATA_GetBit (component ByteIO)
**
** 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 7)
** Returns :
** --- - Value of the specified bit (FALSE or TRUE)
** FALSE = "0" or "Low", TRUE = "1" or "High"
** ===================================================================
*/
bool LCD_DATA_GetBit(byte Bit)
{
byte const Mask = LCD_DATA_GetMsk(Bit); /* Temporary variable - bit mask to test */
return (bool)((getReg8(PTBD) & Mask) == Mask); /* Test if specified bit of port data register is set */
}
/*
** ===================================================================
** Method : LCD_DATA_PutBit (component ByteIO)
**
** 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 7)
** Val - New value of the bit (FALSE or TRUE)
** FALSE = "0" or "Low", TRUE = "1" or "High"
** Returns : Nothing
** ===================================================================
*/
void LCD_DATA_PutBit(byte Bit, bool Val)
{
byte const Mask = LCD_DATA_GetMsk(Bit); /* Temporary variable - put bit mask */
if (Val) {
setReg8Bits(PTBD, Mask); /* [bit Bit]=0x01 */
Shadow_PTB |= Mask; /* Set appropriate bit in shadow variable */
} else { /* !Val */
clrReg8Bits(PTBD, Mask); /* [bit Bit]=0x00 */
Shadow_PTB &= (byte)~Mask; /* Clear appropriate bit in shadow variable */
} /* !Val */
}
/*
** ===================================================================
** Method : LCD_DATA_SetBit (component ByteIO)
**
** 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 7)
** Returns : Nothing
** ===================================================================
*/
void LCD_DATA_SetBit(byte Bit)
{
byte const Mask = LCD_DATA_GetMsk(Bit); /* Temporary variable - set bit mask */
setReg8Bits(PTBD, Mask); /* [bit Bit]=0x01 */
Shadow_PTB |= Mask; /* Set appropriate bit in shadow variable */
}
/*
** ===================================================================
** Method : LCD_DATA_ClrBit (component ByteIO)
**
** 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 7)
** Returns : Nothing
** ===================================================================
*/
void LCD_DATA_ClrBit(byte Bit)
{
byte const Mask = LCD_DATA_GetMsk(Bit); /* Temporary variable - set bit mask */
clrReg8Bits(PTBD, Mask); /* [bit Bit]=0x00 */
Shadow_PTB &= (byte)~Mask; /* Set appropriate bit in shadow variable */
}
/*
** ===================================================================
** Method : LCD_DATA_NegBit (component ByteIO)
**
** 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 7)
** Returns : Nothing
** ===================================================================
*/
void LCD_DATA_NegBit(byte Bit)
{
byte const Mask = LCD_DATA_GetMsk(Bit); /* Temporary variable - set bit mask */
invertReg8Bits(PTBD, Mask); /* [bit Bit]=invert */
Shadow_PTB ^= Mask; /* Set appropriate bit in shadow variable */
}
/*
** ===================================================================
** Method : LCD_DATA_GetDir (component ByteIO)
**
** Description :
** This method returns direction of the bean.
** Parameters : None
** Returns :
** --- - Direction of the bean (FALSE or TRUE)
** FALSE = Input, TRUE = Output
** ===================================================================
*/
/*
bool LCD_DATA_GetDir(void)
** This method is implemented as a macro. See LCD_DATA.h file. **
*/
/*
** ===================================================================
** Method : LCD_DATA_SetDir (component ByteIO)
**
** 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 LCD_DATA_SetDir(bool Dir)
{
if (Dir) {
setReg8(PTBD, Shadow_PTB); /* PTBD0-PTBD7=Shadow_PTB[bits 0-7] */
setReg8(PTBDD, 0xFF); /* PTBDD7=0x01, PTBDD6=0x01, PTBDD5=0x01, PTBDD4=0x01, PTBDD3=0x01, PTBDD2=0x01, PTBDD1=0x01, PTBDD0=0x01 */
} else { /* !Dir */
setReg8(PTBDD, 0x00); /* PTBDD7=0x00, PTBDD6=0x00, PTBDD5=0x00, PTBDD4=0x00, PTBDD3=0x00, PTBDD2=0x00, PTBDD1=0x00, PTBDD0=0x00 */
} /* !Dir */
}
/* END LCD_DATA. */
/*
** ###################################################################
**
** 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 + -