freescale
来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 417 行 · 第 1/2 页
TXT
417 行
/** ###################################################################
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : I2C_Slave.H
** Project : IIC_Slave
** Processor : MC9S08JM60CLHE
** Component : InternalI2C
** Version : Component 01.267, Driver 01.24, CPU db: 3.00.046
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2010-1-15, 10:53
** Abstract :
** This component encapsulates the internal I2C communication
** interface. The implementation of the interface is based
** on the Philips I2C-bus specification version 2.0.
** Interface features:
** MASTER mode
** - Multi master communication
** - The combined format of communication possible
** (see "Automatic stop condition" property)
** - 7-bit slave addressing (10-bit addressing can be made as well)
** - Acknowledge polling provided
** - No wait state initiated when a slave device holds the SCL line low
** - Holding of the SCL line low by slave device recognized as 'not available bus'
** - Invalid start/stop condition detection provided
** SLAVE mode
** - 7-bit slave addressing
** - General call address detection provided
** Settings :
** Serial channel : IIC
**
** Protocol
** Mode : SLAVE
** Slave address : 2
** Empty character : 0
**
** Initialization
**
** Bean function : Enabled
** Events : Enabled
**
** Registers
** Input buffer : IICD [$005C]
** Output buffer : IICD [$005C]
** Control register : IICC1 [$005A]
** Status register : IICS [$005B]
** Baud setting reg. : IICF [$0059]
** Address register : IICA [$0058]
**
** Interrupt
** Vector name : Viic
** Priority :
**
** Used pins :
** ----------------------------------------------------------
** Function | On package | Name
** ----------------------------------------------------------
** SDA | 61 | PTC1_SDA
** SCL | 60 | PTC0_SCL
** ----------------------------------------------------------
** Contents :
** SendChar - byte I2C_Slave_SendChar(byte Chr);
** RecvChar - byte I2C_Slave_RecvChar(byte *Chr);
** SendBlock - byte I2C_Slave_SendBlock(void* Ptr, word Siz, word *Snt);
** RecvBlock - byte I2C_Slave_RecvBlock(void* Ptr, word Siz, word *Rcv);
** ClearTxBuf - byte I2C_Slave_ClearTxBuf(void);
** ClearRxBuf - byte I2C_Slave_ClearRxBuf(void);
** GetCharsInTxBuf - word I2C_Slave_GetCharsInTxBuf(void);
** GetCharsInRxBuf - word I2C_Slave_GetCharsInRxBuf(void);
**
** Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**
** http : www.freescale.com
** mail : support@freescale.com
** ###################################################################*/
#ifndef __I2C_Slave
#define __I2C_Slave
/* MODULE I2C_Slave. */
/*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 inherited beans */
#include "Cpu.h"
#define I2C_Slave_EOF 0 /* Empty character*/
/* MODULE I2C_Slave. */
extern volatile word I2C_Slave_SndRcvTemp;
__interrupt void I2C_Slave_Interrupt(void);
/*
** ===================================================================
** Method : I2C_Slave_Interrupt (component InternalI2C)
**
** Description :
** The method services the interrupt of the selected peripheral(s)
** and eventually invokes event(s) of the bean.
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
byte I2C_Slave_SendChar(byte Chr);
/*
** ===================================================================
** Method : I2C_Slave_SendChar (component InternalI2C)
**
** Description :
** When working as a MASTER, this method writes one (7-bit
** addressing) or two (10-bit addressing) slave address
** bytes inclusive of R/W bit = 0 to the I2C bus and then
** writes one character (byte) to the bus. The slave address
** must be specified before, by the "SelectSlave" or
** "SelectSlave10" method or in the bean initialization
** section, "Target slave address init" property. If
** interrupt service is enabled and the method returns
** ERR_OK, it doesn't mean that transmission was successful.
** The state of transmission is obtainable from
** (OnTransmitData, OnError or OnArbitLost) events.
** When working as a SLAVE, this method writes a character
** to the internal output slave buffer and, after the master
** starts the communication, to the I2C bus. If no character
** is ready for a transmission (internal output slave buffer
** is empty), the Empty character will be sent (see "Empty
** character" property).
** Parameters :
** NAME - DESCRIPTION
** Chr - Character to send.
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ERR_DISABLED - Device is disabled
** ERR_BUSY - The slave device is busy, it
** does not respond by an acknowledge (only
** in master mode and when interrupt
** service is disabled)
** ERR_BUSOFF - Clock timeout elapsed or
** device cannot transmit data
** ERR_TXFULL - Transmitter is full (slave
** mode only)
** ERR_ARBITR - Arbitration lost (only when
** interrupt service is disabled and in
** master mode)
** ===================================================================
*/
#define I2C_Slave_RecvChar(Chr) I2C_Slave_RecvBlock((Chr), (word)1, (word*)&I2C_Slave_SndRcvTemp)
/*
** ===================================================================
** Method : I2C_Slave_RecvChar (component InternalI2C)
**
** Description :
** When working as a MASTER, this method writes one (7-bit
** addressing) or two (10-bit addressing) slave address
** bytes inclusive of R/W bit = 1 to the I2C bus, then reads
** one character (byte) from the bus and then sends the stop
** condition. The slave address must be specified before, by
** the "SelectSlave" or "SelectSlave10" method or in bean
** initialization section, property "Target slave address
** init". If interrupt service is enabled and the method
** returns ERR_OK, it doesn't mean that transmission was
** finished successfully. The state of transmission must be
** tested by means of events (OnReceiveData, OnError or
** OnArbitLost). In case of successful transmission,
** received data is ready after OnReceiveData event is
** called.
** When working as a SLAVE, this method reads a character
** from the input slave buffer.
** Parameters :
** NAME - DESCRIPTION
** * Chr - Received character.
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ERR_DISABLED - Device is disabled
** ERR_BUSY - The slave device is busy, it
** does not respond by the acknowledge
** (only in master mode and when interrupt
** service is disabled)
** ERR_BUSOFF - Clock timeout elapsed or
** device cannot receive data
** ERR_RXEMPTY - No data in receiver (slave
** mode only)
** ERR_OVERRUN - Overrun error was detected
** from the last character or block
** received (slave mode only)
** ERR_ARBITR - Arbitration lost (only when
** interrupt service is disabled and in
** master mode)
** ERR_NOTAVAIL - Method is not available
** in current mode - see generated code
** comment
** ===================================================================
*/
byte I2C_Slave_SendBlock(void * Ptr,word Siz,word *Snt);
/*
** ===================================================================
** Method : I2C_Slave_SendBlock (component InternalI2C)
**
** Description :
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?