📄 sm1.h
字号:
/** ###################################################################
** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : SM1.H
** Project : spi_master
** Processor : 56F8346
** Beantype : SynchroMaster
** Version : Bean 02.213, Driver 01.15, CPU db: 2.87.097
** Compiler : Metrowerks DSP C Compiler
** Date/Time : 2009-1-16, 8:43
** Abstract :
** This bean "SynchroMaster" implements MASTER part of synchronous
** serial master-slave communication.
** Settings :
** Synchro type : MASTER
**
** Serial channel : SPI0
**
** Protocol
** Init baud rate : 4_267us
** Clock edge : rising
** Width : 8 bits
** Empty character : 0
** Empty char. on input : RECEIVED
**
** Registers
** Input buffer : SPI0_DRR [62114]
** Output buffer : SPI0_DTR [62115]
** Control register : SPI0_SCR [62112]
** Mode register : SPI0_DSR [62113]
** Baud setting reg. : SPI0_SCR [62112]
**
**
**
** Used pins :
** ----------------------------------------------------------
** Function | On package | Name
** ----------------------------------------------------------
** Input | 131 | GPIOE6_MISO0
** Output | 132 | GPIOE5_MOSI0
** Clock | 130 | GPIOE4_SCLK0
** ----------------------------------------------------------
**
** Contents :
** Enable - byte SM1_Enable(void);
** Disable - byte SM1_Disable(void);
** RecvChar - byte SM1_RecvChar(SM1_TComData *Chr);
** SendChar - byte SM1_SendChar(SM1_TComData Chr);
** CharsInRxBuf - byte SM1_CharsInRxBuf(word *Chr);
** GetCharsInRxBuf - word SM1_GetCharsInRxBuf(void);
** CharsInTxBuf - byte SM1_CharsInTxBuf(word *Chr);
** GetCharsInTxBuf - word SM1_GetCharsInTxBuf(void);
** SetShiftClockPolarity - byte SM1_SetShiftClockPolarity(byte Edge);
** SetIdleClockPolarity - byte SM1_SetIdleClockPolarity(byte Level);
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
#ifndef __SM1
#define __SM1
/* MODULE SM1. */
/*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 "Cpu.h"
#ifndef __BWUserType_SM1_TError
#define __BWUserType_SM1_TError
typedef union {
byte err;
struct {
bool OverRun : 1; /* OverRun error flag */
bool RxBufOvf : 1; /* Rx buffer full error flag */
bool FaultErr : 1; /* Fault mode error flag */
}errName;
} SM1_TError; /* Error flags. For languages which don't support bit access is byte access only to error flags possible. */
#endif
#define SM1_EOF 0 /* Empty character */
#ifndef __BWUserType_SM1_TComData
#define __BWUserType_SM1_TComData
typedef byte SM1_TComData; /* User type for communication. Size of this type depends on the communication data witdh. */
#endif
byte SM1_Enable(void);
/*
** ===================================================================
** Method : SM1_Enable (bean SynchroMaster)
**
** Description :
** Enable the bean - it starts send and receive functions.
** Events may be generated ("DisableEvent"/"EnableEvent").
** Parameters : None
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ===================================================================
*/
byte SM1_Disable(void);
/*
** ===================================================================
** Method : SM1_Disable (bean SynchroMaster)
**
** Description :
** Disable the bean - it stops the send and receive
** functions. No events will be generated.
** Parameters : None
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ===================================================================
*/
byte SM1_RecvChar(SM1_TComData *Chr);
/*
** ===================================================================
** Method : SM1_RecvChar (bean SynchroMaster)
**
** Description :
** If any data is received, this method returns one
** character, otherwise it returns an error code (it does
** not wait for data).
** DMA mode:
** If DMA controller is available on selected CPU and
** receiver is configured to use DMA controller then this
** method only sets the selected DMA channel. Status of the
** DMA transfer can then be checked using method
** GetCharsInRxBuf. See typical usage for details about
** communication using DMA.
** Parameters :
** NAME - DESCRIPTION
** * Chr - A pointer to the received character
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ERR_RXEMPTY - No data in receiver
** ERR_OVERRUN - Overrun error was detected
** from the last char or block received
** ERR_FAULT - Fault error was detected
** from the last char or block received.
** This error may not be supported on some
** CPUs (see generated code).
** ===================================================================
*/
byte SM1_SendChar(SM1_TComData Chr);
/*
** ===================================================================
** Method : SM1_SendChar (bean SynchroMaster)
**
** Description :
** Sends one character to the channel.
** DMA mode:
** If DMA controller is available on the selected CPU and
** the transmitter is configured to use DMA controller then
** this method only sets the selected DMA channel. The
** status of the DMA transfer can then be checked using
** GetCharsInTxBuf method. See the typical usage for details
** about communication using DMA.
** 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 (only
** if output DMA is supported and enabled)
** ERR_TXFULL - Transmitter is full
** ===================================================================
*/
byte SM1_CharsInRxBuf(word *Chr);
/*
** ===================================================================
** Method : SM1_CharsInRxBuf (bean SynchroMaster)
**
** Description :
** Returns the number of characters in the input buffer.
** Note: If the Interrupt service is disabled, and the
** Ignore empty character is set to yes, and a character has
** been received, then this method returns 1 although it was
** an empty character.
** (deprecated method)
** DMA mode:
** If DMA controller is available on the selected CPU and
** the receiver is configured to use DMA controller then
** this method returns the number of characters in the
** receive buffer.
** Parameters :
** NAME - DESCRIPTION
** * Chr - A pointer to number of characters in
** the input buffer
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ===================================================================
*/
#define SM1_GetCharsInRxBuf() (getRegBit(SPI0_SCR,SPRF)?(word)1:(word)0) /* Return number of chars in receive buffer */
/*
** ===================================================================
** Method : SM1_GetCharsInRxBuf (bean SynchroMaster)
**
** Description :
** Returns the number of characters in the input buffer.
** Note: If the Interrupt service is disabled, and the
** Ignore empty character is set to yes, and a character has
** been received, then this method returns 1 although it was
** an empty character.
** DMA mode:
** If DMA controller is available on the selected CPU and
** the receiver is configured to use DMA controller then
** this method returns the number of characters in the
** receive buffer.
** Parameters : None
** Returns :
** --- - Number of characters in the input
** buffer.
** ===================================================================
*/
byte SM1_CharsInTxBuf(word *Chr);
/*
** ===================================================================
** Method : SM1_CharsInTxBuf (bean SynchroMaster)
**
** Description :
** Returns the number of characters in the output buffer.
** (deprecated method)
** DMA mode:
** If DMA controller is available on the selected CPU and
** the transmitter is configured to use DMA controller then
** this method returns the number of characters in the
** transmit buffer.
** Parameters :
** NAME - DESCRIPTION
** * Chr - A pointer to the number of characters
** in the output buffer
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_SPEED - This device does not work in
** the active speed mode
** ===================================================================
*/
word SM1_GetCharsInTxBuf(void);
/*
** ===================================================================
** Method : SM1_GetCharsInTxBuf (bean SynchroMaster)
**
** Description :
** Returns the number of characters in the output buffer.
** DMA mode:
** If DMA controller is available on the selected CPU and
** the transmitter is configured to use DMA controller then
** this method returns the number of characters in the
** transmit buffer.
** Parameters : None
** Returns :
** --- - Number of characters in the output
** buffer.
** ===================================================================
*/
byte SM1_SetShiftClockPolarity(byte Edge);
/*
** ===================================================================
** Method : SM1_SetShiftClockPolarity (bean SynchroMaster)
**
** Description :
** Sets the shift clock polarity at runtime. Output data
** will be shifted on the selected edge polarity.
** Parameters :
** NAME - DESCRIPTION
** Edge - Edge polarity.
** 0-falling edge
** 1-rising edge
** 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_RANGE - Parameter out of range
** ===================================================================
*/
byte SM1_SetIdleClockPolarity(byte Level);
/*
** ===================================================================
** Method : SM1_SetIdleClockPolarity (bean SynchroMaster)
**
** Description :
** Sets the idle clock polarity at runtime. If the
** communication does not run, the clock signal will have
** required level.
** Parameters :
** NAME - DESCRIPTION
** Level - Idle clock polarity:
** 0-low
** 1-high
** 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_RANGE - Parameter out of range
** ===================================================================
*/
void SM1_Init(void);
/*
** ===================================================================
** Method : SM1_Init (bean SynchroMaster)
**
** Description :
** Initializes the associated peripheral(s) and the beans
** internal variables. The method is called automatically as a
** part of the application initialization code.
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
/* END SM1. */
#endif /* ifndef __SM1 */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 2.97 [03.74]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -