freescale
来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 263 行
TXT
263 行
/** ###################################################################
** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : led_section.C
** Project : key_scan
** Processor : MC9S08JM60CLHE
** Beantype : ByteIO
** Version : Bean 02.055, Driver 03.15, CPU db: 3.00.033
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2009-10-2, 15:14
** Abstract :
** This bean "ByteIO" implements an one-byte input/output.
** It uses one 8-bit port.
** Note: This bean is set to work in Output direction only.
** Methods of this bean are mostly implemented as a macros
** (if supported by target langauage and compiler).
** Settings :
** Port name : PTE
**
** Initial direction : Output (direction cannot be changed)
** Initial output value : 0 = 000H
** Initial pull option : off
**
** 8-bit data register : PTED [$0008]
** 8-bit control register : PTEDD [$0009]
**
** ----------------------------------------------------
** Bit | Pin | Name
** ----------------------------------------------------
** 0 | 13 | PTE0_TxD1
** 1 | 14 | PTE1_RxD1
** 2 | 15 | PTE2_TPM1CH0
** 3 | 16 | PTE3_TPM1CH1
** 4 | 17 | PTE4_MISO1
** 5 | 18 | PTE5_MOSI1
** 6 | 19 | PTE6_SPSCK1
** 7 | 20 | PTE7_SS1
** ----------------------------------------------------
** Contents :
** GetDir - bool led_section_GetDir(void);
** GetVal - byte led_section_GetVal(void);
** PutVal - void led_section_PutVal(byte Val);
** GetBit - bool led_section_GetBit(byte Bit);
** PutBit - void led_section_PutBit(byte Bit, bool Val);
** SetBit - void led_section_SetBit(byte Bit);
** ClrBit - void led_section_ClrBit(byte Bit);
** NegBit - void led_section_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_section. */
#include "led_section.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_section_GetMsk (bean 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 led_section_Table[8] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
}; /* Table of mask constants */
static byte led_section_GetMsk (byte PinIndex)
{
return (byte)(PinIndex<8 ? led_section_Table[PinIndex] : 0); /* Check range and return appropriate bit mask */
}
/*
** ===================================================================
** Method : led_section_GetVal (bean 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
** Note: This bean is set to work in Output direction only.
** Parameters : None
** Returns :
** --- - Input value (0 to 255)
** ===================================================================
*/
/*
byte led_section_GetVal(void)
** This method is implemented as a macro. See led_section.h file. **
*/
/*
** ===================================================================
** Method : led_section_PutVal (bean ByteIO)
**
** Description :
** This method writes the new output value.
** Parameters :
** NAME - DESCRIPTION
** Val - Output value (0 to 255)
** Returns : Nothing
** ===================================================================
*/
/*
void led_section_PutVal(byte Val)
** This method is implemented as a macro. See led_section.h file. **
*/
/*
** ===================================================================
** Method : led_section_GetBit (bean 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
** 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_section_GetBit(byte Bit)
{
byte const Mask = led_section_GetMsk(Bit); /* Temporary variable - bit mask to test */
return (bool)((getReg8(PTED) & Mask) == Mask); /* Test if specified bit of port data register is set */
}
/*
** ===================================================================
** Method : led_section_PutBit (bean ByteIO)
**
** 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_section_PutBit(byte Bit, bool Val)
{
byte const Mask = led_section_GetMsk(Bit); /* Temporary variable - put bit mask */
if (Val) {
setReg8Bits(PTED, Mask); /* [bit Bit]=0x01 */
} else { /* !Val */
clrReg8Bits(PTED, Mask); /* [bit Bit]=0x00 */
} /* !Val */
}
/*
** ===================================================================
** Method : led_section_SetBit (bean ByteIO)
**
** 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_section_SetBit(byte Bit)
{
byte const Mask = led_section_GetMsk(Bit); /* Temporary variable - set bit mask */
setReg8Bits(PTED, Mask); /* [bit Bit]=0x01 */
}
/*
** ===================================================================
** Method : led_section_ClrBit (bean ByteIO)
**
** 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_section_ClrBit(byte Bit)
{
byte const Mask = led_section_GetMsk(Bit); /* Temporary variable - set bit mask */
clrReg8Bits(PTED, Mask); /* [bit Bit]=0x00 */
}
/*
** ===================================================================
** Method : led_section_NegBit (bean ByteIO)
**
** Description :
** This method negates (inverts) the specified bit of the
** output value.
** Parameters :
** NAME - DESCRIPTION
** Bit - Number of the bit to invert (0 to 7)
** Returns : Nothing
** ===================================================================
*/
void led_section_NegBit(byte Bit)
{
byte const Mask = led_section_GetMsk(Bit); /* Temporary variable - set bit mask */
invertReg8Bits(PTED, Mask); /* [bit Bit]=invert */
}
/*
** ===================================================================
** Method : led_section_GetDir (bean ByteIO)
**
** 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_section_GetDir(void)
** This method is implemented as a macro. See led_section.h file. **
*/
/* END led_section. */
/*
** ###################################################################
**
** 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 + =
减小字号Ctrl + -
显示快捷键?