⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st79_linuart.h

📁 st公司新出的一款8位单片机st79的lib库
💻 H
字号:
/**
  ********************************************************************************
  * @file st79_linuart.h
  * @brief This file contains all functions prototypes and macros for the LINUART 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>&copy; COPYRIGHT 2007 STMicroelectronics</center></h2>
  * @image html logo.bmp
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ST79_LINUART_H
#define __ST79_LINUART_H

/* Includes ------------------------------------------------------------------*/
#include "st79_map.h"
#include "st79_macro.h"
/* Exported types ------------------------------------------------------------*/

/** @addtogroup LINUART_Exported_Types
  * @{
  */

/* LINUART_FLAG possible values */
typedef enum { LINUART_FLAG_TXE           = 0x80, /**< Transmit Data Register Empty flag  */
               LINUART_FLAG_TC            = 0x40, /**< Transmission Complete flag         */
               LINUART_FLAG_RXNE          = 0x20, /**< Read Data Register Not Empty flag  */
               LINUART_FLAG_IDLE          = 0x10, /**< Idle line detected flag            */
               LINUART_FLAG_ORE           = 0x08, /**< OverRun error flag                 */
               LINUART_FLAG_NE            = 0x04, /**< Noise error flag                   */
               LINUART_FLAG_FE            = 0x02, /**< Framing Error flag                 */
               LINUART_FLAG_PE            = 0x01, /**< Parity Error flag                  */
               LINUART_FLAG_LBD           = 0x00, /**< LIN Break Detection Flag           */
               LINUART_FLAG_SBK           = 0x11,  /**< Send Break Complete interrupt flag */
               LINUART_FLAG_LHE			  = 0x21,  /**<  LIN Header Error flag */
               LINUART_FLAG_LHDF		  = 0x31,   /**< LIN Header Detection Flag*/
               LINUART_FLAG_LSF			  = 0x41  /**< LIN Sync Field Flag*/
             } LINUART_Flag_TypeDef;

/** LINUART Interruption sources  */
typedef enum { LINUART_IT_TIEN         	 = 0x80, /**< 0x80 Transmitter Interruption   Enable         */
               LINUART_IT_TCIEN			 = 0x40, /**< 0x40 Transmission Complete Interruption Enable */
               LINUART_IT_RIEN           = 0x20, /**< 0x20 Receiver Interruption  Enable             */
               LINUART_IT_ILIEN	         = 0x10, /**< 0x10 IDLE Line Interruption   Enable           */
               LINUART_IT_LBDIEN	     = 0x04, /**< 0x04 LIN Break Detection Interruption Enable        */
               LINUART_IT_PIEN           = 0x01,  /**< 0x01 Parity Interruption  Enable              */
               LINUART_IT_LHDIEN		 = 0x44	  /**0x08 LIN Header Detection Interrupt */
             } LINUART_IT_TypeDef;


/** LINUART WakeUP Modes  */
typedef enum { LINUART_WakeUp_IdleLine       = 0x00, /**< 0x01 Idle Line wake up                */
               LINUART_WakeUp_AddressMark    = 0x08 /**< 0x02 Address Mark wake up          */
             } LINUART_WakeUp_TypeDef;

typedef enum { LINUART_LINBreakDetectionLength10	= 0x01, /**< 0x01 10 bits Lin Break detection            */
               LINUART_LINBreakDetectionLength11	= 0x02  /**< 0x02 11 bits Lin Break detection          */
             } LINUART_LINBreakDetectionLength_TypeDef;

typedef enum { LINUART_StopBits_1	    = 0x00, /* One stop bit is  transmitted at the end of frame*/
               LINUART_StopBits_2		= 0x20 /* Two stop bits are  transmitted at the end of frame*/
             } LINUART_StopBits_TypeDef;

typedef enum { LINUART_Parity_No	    = 0x00, /* No Parity*/
               LINUART_Parity_Even	    = 0x04, /* Even Parity*/
               LINUART_Parity_Odd		= 0x06  /* Odd Parity*/
             } LINUART_Parity_TypeDef;

/** LINUART Word length possible values */
typedef enum { LINUART_WordLength_8D = 0x00,/**< 0x00 8 bits Data  */
               LINUART_WordLength_9D = 0x10 /**< 0x10 9 bits Data  */
             } LINUART_WordLength_TypeDef;

/** LINUART Mode possible values */
typedef enum { LINUART_Mode_Rx_Enable   = 0x08, /**< 0x08 Receive Enable                */
               LINUART_Mode_Tx_Enable   = 0x04, /**< 0x04 Transmit Enable               */
               LINUART_Mode_Tx_Disable  = 0x80, /**< 0x80 Receive Enable                */
               LINUART_Mode_Rx_Disable  = 0x40  /**< 0x40 Single-wire Half-duplex mode  */
             } LINUART_Mode_TypeDef;

typedef enum { LINUART_LIN_Master_Mode   = 0x01, /**< 0x01 LIN Master Mode                */
               LINUART_LIN_Slave_Mode    = 0x02 /**< 0x02 LIN Slave Mode            */
             } LINUART_Slave_TypeDef;

typedef enum { LINUART_LIN_Autosync_Enable    = 0x01, /**< 0x01 LIN Autosynchronization Enable                */
               LINUART_LIN_Autosync_Disable    = 0x02 /**< 0x02 LIN LIN Autosynchronization Enable            */
             } LINUART_Autosync_TypeDef;

typedef enum { LINUART_LIN_DivUp_LBRR1       = 0x01, /**< 0x01 LIN LDIV is updated as soon as LBRR1 is written               */
               LINUART_LIN_DivUp_NextRXNE    = 0x02 /**< 0x02 LIN LDIV is updated at the next received character    */
             } LINUART_DivUp_TypeDef;

/**
  * @}
  */

/* Exported constants --------------------------------------------------------*/

/** @addtogroup LINUART_Exported_Constants
  * @{
  */

/**
  * @}
  */

/* Exported macros ------------------------------------------------------------*/

/* Private macros ------------------------------------------------------------*/

/** @addtogroup LINUART_Private_Macros
  * @{
  */
/**
  * @brief Macro used by the assert function in order to check the different sensitivity values for the FLAGs
  */
#define IS_LINUART_FLAG_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_FLAG_TXE) || \
   ((SensitivityValue) == LINUART_FLAG_TC) || \
   ((SensitivityValue) == LINUART_FLAG_RXNE) || \
   ((SensitivityValue) == LINUART_FLAG_IDLE ) || \
   ((SensitivityValue) == LINUART_FLAG_ORE) || \
   ((SensitivityValue) == LINUART_FLAG_NE) || \
   ((SensitivityValue) == LINUART_FLAG_FE) || \
   ((SensitivityValue) == LINUART_FLAG_PE) || \
   ((SensitivityValue) == LINUART_FLAG_LBD) || \
   ((SensitivityValue) == LINUART_FLAG_SBK) || \
   ((SensitivityValue) == LINUART_FLAG_LHE))

/**
 * @brief Macro used by the assert function in order to check the different sensitivity values for the MODEs
 */
#define IS_LINUART_MODE_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == (u8)LINUART_Mode_Rx_Enable) || \
   ((SensitivityValue) == (u8)LINUART_Mode_Rx_Disable) || \
   ((SensitivityValue) == (u8)LINUART_Mode_Tx_Enable) || \
   ((SensitivityValue) == (u8)LINUART_Mode_Tx_Disable) || \
   ((SensitivityValue) == (u8)((u8)LINUART_Mode_Tx_Enable|(u8)LINUART_Mode_Rx_Enable)) || \
   ((SensitivityValue) == (u8)((u8)LINUART_Mode_Tx_Enable|(u8)LINUART_Mode_Rx_Disable)) || \
   ((SensitivityValue) == (u8)((u8)LINUART_Mode_Tx_Disable|(u8)LINUART_Mode_Rx_Disable)) || \
   ((SensitivityValue) == (u8)((u8)LINUART_Mode_Tx_Disable|(u8)LINUART_Mode_Rx_Enable)))

/**
 * @brief Macro used by the assert function in order to check the different sensitivity values for the WordLengths
 */
#define IS_LINUART_WordLength_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_WordLength_8D) || \
   ((SensitivityValue) == LINUART_WordLength_9D))


/**
  * @brief Macro used by the assert function in order to check the different sensitivity values for the Interrupts
  */
#define IS_LINUART_IT_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_IT_PIEN) || \
   ((SensitivityValue) == LINUART_IT_TIEN) || \
   ((SensitivityValue) == LINUART_IT_TCIEN) || \
   ((SensitivityValue) == LINUART_IT_RIEN ) || \
   ((SensitivityValue) == LINUART_IT_ILIEN) || \
   ((SensitivityValue) == LINUART_IT_LBDIEN))

/**
 * @brief Macro used by the assert function in order to check the different sensitivity values for the IrDAModes
 */

/**
  * @brief Macro used by the assert function in order to check the different sensitivity values for the WakeUps
  */
#define IS_LINUART_WakeUp_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_WakeUp_IdleLine) || \
   ((SensitivityValue) == LINUART_WakeUp_AddressMark))

/**
  * @brief Macro used by the assert function in order to check the different sensitivity values for the LINBreakDetectionLengths
  */
#define IS_LINUART_LINBreakDetectionLength_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_LINBreakDetectionLength10) || \
   ((SensitivityValue) == LINUART_LINBreakDetectionLength11))

/**
  * @brief Macro used by the assert function in order to check the different sensitivity values for the LINUART_StopBits
  */
#define IS_LINUART_StopBits_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_StopBits_1) || \
   ((SensitivityValue) == LINUART_StopBits_2))

/**
 * @brief Macro used by the assert function in order to check the different sensitivity values for the Paritys
 */
#define IS_LINUART_Parity_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_Parity_No) || \
   ((SensitivityValue) == LINUART_Parity_Even) || \
    ((SensitivityValue) == LINUART_Parity_Odd ))

/* BaudRate value should be < 625000 bps */
#define IS_LINUART_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 LINUART_Address_Max 0x16
#define IS_LINUART_LINUART_Address_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) < LINUART_Address_Max))


#ifdef HW_PLATFORM_CUT10

#define IS_LINUART_Slave_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_LIN_Master_Mode) || \
   ((SensitivityValue) == LINUART_LIN_Slave_Mode))

#define IS_LINUART_Autosync_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_LIN_Autosync_Enable) || \
   ((SensitivityValue) == LINUART_LIN_Autosync_Disable))

#define IS_LINUART_DivUp_VALUE_OK(SensitivityValue) \
  (((SensitivityValue) == LINUART_LIN_DivUp_LBRR1) || \
   ((SensitivityValue) == LINUART_LIN_DivUp_NextRXNE))

#endif

/**
  * @}
  */

/* Exported functions ------------------------------------------------------- */
void LINUART_ClearFlag(LINUART_TypeDef* LINUARTx, LINUART_Flag_TypeDef LINUART_FLAGT);
void LINUART_Cmd(LINUART_TypeDef* LINUARTx, FunctionalState NewState);
void LINUART_DeInit(LINUART_TypeDef* LINUARTx);
FlagStatus LINUART_GetFlagStatus(LINUART_TypeDef* LINUARTx, LINUART_Flag_TypeDef LINUART_FLAG);
ITStatus LINUART_GetITStatus(LINUART_TypeDef* LINUARTx, LINUART_IT_TypeDef LINUART_IT);
void LINUART_Init(LINUART_TypeDef* LINUARTx,
                  LINUART_WordLength_TypeDef LINUART_WordLength,
                  LINUART_StopBits_TypeDef LINUART_StopBits,
                  LINUART_Parity_TypeDef LINUART_Parity,
                  u32 LINUART_BaudRate,
                  u32 MasterFrequency,
                  LINUART_Mode_TypeDef LINUART_Mode);
void LINUART_ITConfig(LINUART_TypeDef* LINUARTx, LINUART_IT_TypeDef LINUART_IT, FunctionalState NewState);
void LINUART_LINBreakDetectionConfig(LINUART_TypeDef* LINUARTx, LINUART_LINBreakDetectionLength_TypeDef LINUART_LINBreakDetectionLength);
#ifdef HW_PLATFORM_CUT10
void LINUART_LINConfig(LINUART_TypeDef* LINUARTx, LINUART_Slave_TypeDef LINUART_Slave, LINUART_Autosync_TypeDef LINUART_Autosync, LINUART_DivUp_TypeDef LINUART_DivUp);
#endif
void LINUART_LINCmd(LINUART_TypeDef* LINUARTx, FunctionalState NewState);
u8 LINUART_ReceiveData8(LINUART_TypeDef* LINUARTx);
u16 LINUART_ReceiveData9(LINUART_TypeDef* LINUARTx);
void LINUART_ReceiverWakeUpCmd(LINUART_TypeDef* LINUARTx, FunctionalState NewState);
void LINUART_SendBreak(LINUART_TypeDef* LINUARTx);
void LINUART_SendData8(LINUART_TypeDef* LINUARTx, u8 Data);
void LINUART_SendData9(LINUART_TypeDef* LINUARTx, u16 Data);
void LINUART_SetAddress(LINUART_TypeDef* LINUARTx, u8 LINUART_Address);
void LINUART_WakeUpConfig(LINUART_TypeDef* LINUARTx, LINUART_WakeUp_TypeDef LINUART_WakeUp);

#endif /* __ST79_LINUART_H */

/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -