📄 st79_usart.h
字号:
/**
********************************************************************************
* @file st79_usart.h
* @brief This file contains all functions prototypes and macros for the USART peripheral.
* @author STMicroelectronics - MCD & APG Car Body Application Labs
* @version V0.01
* @date 04-JUL-2007
******************************************************************************
*
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2007 STMicroelectronics</center></h2>
* @image html logo.bmp
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ST79_USART_H
#define __ST79_USART_H
/* Includes ------------------------------------------------------------------*/
#include "st79_map.h"
#include "st79_macro.h"
/* Exported types ------------------------------------------------------------*/
/** @addtogroup USART_Exported_Types
* @{
*/
/* USART_FLAG possible values */
typedef enum { USART_FLAG_TXE = 0x80, /**< Transmit Data Register Empty flag */
USART_FLAG_TC = 0x40, /**< Transmission Complete flag */
USART_FLAG_RXNE = 0x20, /**< Read Data Register Not Empty flag */
USART_FLAG_IDLE = 0x10, /**< Idle line detected flag */
USART_FLAG_ORE = 0x08, /**< OverRun error flag */
USART_FLAG_NE = 0x04, /**< Noise error flag */
USART_FLAG_FE = 0x02, /**< Framing Error flag */
USART_FLAG_PE = 0x01, /**< Parity Error flag */
USART_FLAG_LBD = 0x00, /**< LIN Break Detection Flag */
USART_FLAG_SBK = 0x11 /**< Send Break Complete interrupt flag */
} USART_Flag_TypeDef;
/** USART Interruption sources */
typedef enum { USART_IT_TIEN = 0x80, /**< 0x80 Transmitter Interruption Enable */
USART_IT_TCIEN = 0x40, /**< 0x40 Transmission Complete Interruption Enable */
USART_IT_RIEN = 0x20, /**< 0x20 Receiver Interruption Enable */
USART_IT_ILIEN = 0x10, /**< 0x10 IDLE Line Interruption Enable */
USART_IT_LBDIEN = 0x04, /**< 0x04 LIN Break Detection Interruption Enable */
USART_IT_PIEN = 0x01 /**< 0x01 Parity Interruption Enable */
} USART_IT_TypeDef;
/** USART Irda Modes */
typedef enum { USART_IrDAMode_LowPower = 0x01, /**< 0x01 Irda Low Power Mode */
USART_IrDAMode_Normal = 0x02 /**< 0x02 Irda Normal Mode */
} USART_IrDAMode_TypeDef;
/** USART WakeUP Modes */
typedef enum { USART_WakeUp_IdleLine = (u8)0x00, /**< 0x01 Idle Line wake up */
USART_WakeUp_AddressMark = (u8)0x08 /**< 0x02 Address Mark wake up */
} USART_WakeUp_TypeDef;
typedef enum { USART_LINBreakDetectionLength10 = 0x01, /**< 0x01 10 bits Lin Break detection */
USART_LINBreakDetectionLength11 = 0x02 /**< 0x02 11 bits Lin Break detection */
} USART_LINBreakDetectionLength_TypeDef;
typedef enum { USART_StopBits_1 = 0x00, /* One stop bit is transmitted at the end of frame*/
USART_StopBits_0_5 = 0x10, /* Half stop bits is transmitted at the end of frame*/
USART_StopBits_2 = 0x20, /* Two stop bits are transmitted at the end of frame*/
USART_StopBits_1_5 = 0x30 /* One and half stop bits*/
} USART_StopBits_TypeDef;
typedef enum { USART_Parity_No = 0x00, /* No Parity*/
USART_Parity_Even = 0x04, /* Even Parity*/
USART_Parity_Odd = 0x06 /* Odd Parity*/
} USART_Parity_TypeDef;
/** USART Synchrone modes */
typedef enum { USART_Clock_Disable = 0x80, /**< 0x80 Sync mode Disable, SLK pin Disable */
USART_Clock_Enable = 0x08, /**< 0x08 Sync mode Enable, SLK pin Enable */
USART_CPOL_Low = 0x40, /**< 0x40 Steady low value on SCLK pin outside transmission window */
USART_CPOL_High = 0x04, /**< 0x04 Steady high value on SCLK pin outside transmission window */
USART_CPHA_Middle = 0x20, /**< 0x20 SCLK clock line activated in middle of data bit */
USART_CPHA_Begining = 0x02, /**< 0x02 SCLK clock line activated at beginning of data bit */
USART_LastBit_Disable = 0x10, /**< 0x10 The clock pulse of the last data bit is not output to the SCLK pin */
USART_LastBit_Enable = 0x01 /**< 0x01 The clock pulse of the last data bit is output to the SCLK pin */
} USART_SyncMode_TypeDef;
/** USART Word length possible values */
typedef enum { USART_WordLength_8D = 0x00,/**< 0x00 8 bits Data */
USART_WordLength_9D = 0x10 /**< 0x10 9 bits Data */
} USART_WordLength_TypeDef;
/** USART Mode possible values */
typedef enum { USART_Mode_Rx_Enable = 0x08, /**< 0x08 Receive Enable */
USART_Mode_Tx_Enable = 0x04, /**< 0x04 Transmit Enable */
USART_Mode_Tx_Disable = 0x80, /**< 0x80 Receive Enable */
USART_Mode_Rx_Disable = 0x40 /**< 0x40 Single-wire Half-duplex mode */
} USART_Mode_TypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @addtogroup USART_Exported_Constants
* @{
*/
/**
* @}
*/
/* Exported macros ------------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup USART_Private_Macros
* @{
*/
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the FLAGs
*/
#define IS_USART_FLAG_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_FLAG_TXE) || \
((SensitivityValue) == USART_FLAG_TC) || \
((SensitivityValue) == USART_FLAG_RXNE) || \
((SensitivityValue) == USART_FLAG_IDLE ) || \
((SensitivityValue) == USART_FLAG_ORE) || \
((SensitivityValue) == USART_FLAG_NE) || \
((SensitivityValue) == USART_FLAG_FE) || \
((SensitivityValue) == USART_FLAG_PE) || \
((SensitivityValue) == USART_FLAG_LBD) || \
((SensitivityValue) == USART_FLAG_SBK))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the MODEs
* possible combination should be one of the following
*/
#define IS_USART_MODE_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == (u8)USART_Mode_Rx_Enable) || \
((SensitivityValue) == (u8)USART_Mode_Rx_Disable) || \
((SensitivityValue) == (u8)USART_Mode_Tx_Enable) || \
((SensitivityValue) == (u8)USART_Mode_Tx_Disable) || \
((SensitivityValue) == (u8)((u8)USART_Mode_Tx_Enable|(u8)USART_Mode_Rx_Enable)) || \
((SensitivityValue) == (u8)((u8)USART_Mode_Tx_Enable|(u8)USART_Mode_Rx_Disable)) || \
((SensitivityValue) == (u8)((u8)USART_Mode_Tx_Disable|(u8)USART_Mode_Rx_Disable)) || \
((SensitivityValue) == (u8)((u8)USART_Mode_Tx_Disable|(u8)USART_Mode_Rx_Enable)))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the WordLengths
*/
#define IS_USART_WordLength_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_WordLength_8D) || \
((SensitivityValue) == USART_WordLength_9D))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the SyncModes; it should exclude values such as USART_Clock_Enable|USART_Clock_Disable
* USART_SyncMode value should exclude values such as USART_Clock_Enable|USART_Clock_Disable
*/
#define IS_USART_SyncMode_VALUE_OK(SensitivityValue) \
(!((((SensitivityValue)&(((u8)USART_Clock_Enable)|((u8)USART_Clock_Disable))) == (((u8)USART_Clock_Enable)|((u8)USART_Clock_Disable))) || \
(((SensitivityValue)&(((u8)USART_CPOL_Low)|((u8)USART_CPOL_High))) == (((u8)USART_CPOL_Low)|((u8)USART_CPOL_High))) || \
(((SensitivityValue)&(((u8)USART_CPHA_Middle)|((u8)USART_CPHA_Begining))) == (((u8)USART_CPHA_Middle)|((u8)USART_CPHA_Begining))) || \
(((SensitivityValue)&(((u8)USART_LastBit_Disable)|((u8)USART_LastBit_Enable))) == (((u8)USART_LastBit_Disable)|((u8)USART_LastBit_Enable)))))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the Interrupts
*/
#define IS_USART_IT_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_IT_PIEN) || \
((SensitivityValue) == USART_IT_TIEN) || \
((SensitivityValue) == USART_IT_TCIEN) || \
((SensitivityValue) == USART_IT_RIEN ) || \
((SensitivityValue) == USART_IT_ILIEN) || \
((SensitivityValue) == USART_IT_LBDIEN))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the IrDAModes
*/
#define IS_USART_IrDAMode_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_IrDAMode_LowPower) || \
((SensitivityValue) == USART_IrDAMode_Normal))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the WakeUps
*/
#define IS_USART_WakeUp_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_WakeUp_IdleLine) || \
((SensitivityValue) == USART_WakeUp_AddressMark))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the LINBreakDetectionLengths
*/
#define IS_USART_LINBreakDetectionLength_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_LINBreakDetectionLength10) || \
((SensitivityValue) == USART_LINBreakDetectionLength11))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the USART_StopBits
*/
#define IS_USART_StopBits_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_StopBits_1) || \
((SensitivityValue) == USART_StopBits_0_5) || \
((SensitivityValue) == USART_StopBits_2) || \
((SensitivityValue) == USART_StopBits_1_5 ))
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the Paritys
*/
#define IS_USART_Parity_VALUE_OK(SensitivityValue) \
(((SensitivityValue) == USART_Parity_No) || \
((SensitivityValue) == USART_Parity_Even) || \
((SensitivityValue) == USART_Parity_Odd ))
/* BaudRate value should be < 625000 bps */
#define IS_USART_BAUDRATE_OK(NUM) ((NUM) <= (u32) 625000)
/**
* @brief Macro used by the assert function in order to check the different sensitivity values for the Paritys
*/
#define USART_Address_Max 0x16
#define IS_USART_USART_Address_VALUE_OK(SensitivityValue) \
(((SensitivityValue) < USART_Address_Max))
/**
* @}
*/
/* Exported functions ------------------------------------------------------- */
void USART_ClearFlag (USART_TypeDef *USARTx, USART_Flag_TypeDef USART_FLAG);
void USART_Cmd(USART_TypeDef *USARTx, FunctionalState NewState);
void USART_DeInit(USART_TypeDef *USARTx);
FlagStatus USART_GetFlagStatus(USART_TypeDef *USARTx, USART_Flag_TypeDef USART_FLAG);
ITStatus USART_GetITStatus(USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT);
void USART_HalfDuplexCmd(USART_TypeDef *USARTx, FunctionalState NewState);
void USART_Init(USART_TypeDef *USARTx,
USART_WordLength_TypeDef USART_WordLength,
USART_StopBits_TypeDef USART_StopBits,
USART_Parity_TypeDef USART_Parity,
USART_SyncMode_TypeDef USART_SyncMode,
u32 USART_BaudRate,
u32 MasterFrequency,
USART_Mode_TypeDef USART_Mode);
void USART_IrDAConfig(USART_TypeDef *USARTx, USART_IrDAMode_TypeDef USART_IrDAMode);
void USART_IrDACmd(USART_TypeDef *USARTx, FunctionalState NewState);
void USART_ITConfig(USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT, FunctionalState NewState);
void USART_LINBreakDetectionConfig(USART_TypeDef *USARTx, USART_LINBreakDetectionLength_TypeDef USART_LINBreakDetectionLength);
void USART_LINCmd(USART_TypeDef *USARTx, FunctionalState NewState);
u8 USART_ReceiveData8(USART_TypeDef *USARTx);
u16 USART_ReceiveData9(USART_TypeDef *USARTx);
void USART_ReceiverWakeUpCmd(USART_TypeDef *USARTx, FunctionalState NewState);
void USART_SendBreak(USART_TypeDef *USARTx);
void USART_SendData8(USART_TypeDef *USARTx, u8 Data);
void USART_SendData9(USART_TypeDef *USARTx, u16 Data);
void USART_SetAddress(USART_TypeDef *USARTx, u8 USART_Address);
void USART_SetGuardTime(USART_TypeDef *USARTx, u8 USART_GuardTime);
void USART_SetPrescaler(USART_TypeDef *USARTx, u8 USART_Prescaler);
void USART_SmartCardCmd(USART_TypeDef *USARTx, FunctionalState NewState);
void USART_SmartCardNACKCmd(USART_TypeDef *USARTx, FunctionalState NewState);
void USART_WakeUpConfig(USART_TypeDef *USARTx, USART_WakeUp_TypeDef USART_WakeUp);
#endif /* __ST79_USART_H */
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -