1 /*********************************************************************************************************//** 2 * @file ht32f5xxxx_sled.h 3 * @version $Rev:: 3875 $ 4 * @date $Date:: 2019-05-10 #$ 5 * @brief The header file of the SLED library. 6 ************************************************************************************************************* 7 * @attention 8 * 9 * Firmware Disclaimer Information 10 * 11 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the 12 * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the 13 * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and 14 * other intellectual property laws. 15 * 16 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the 17 * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties 18 * other than HOLTEK and the customer. 19 * 20 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference 21 * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including 22 * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including 23 * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. 24 * 25 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2> 26 ************************************************************************************************************/ 27 28 /* Define to prevent recursive inclusion -------------------------------------------------------------------*/ 29 #ifndef __HT32F5XXXX_SLED_H 30 #define __HT32F5XXXX_SLED_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* Includes ------------------------------------------------------------------------------------------------*/ 37 #include "ht32.h" 38 39 /** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver 40 * @{ 41 */ 42 43 /** @addtogroup SLED 44 * @{ 45 */ 46 47 48 /* Exported types ------------------------------------------------------------------------------------------*/ 49 /** @defgroup SLED_Exported_Types SLED exported types 50 * @{ 51 */ 52 53 /** 54 * @brief Enumeration of CK_SLED prescaler. 55 */ 56 typedef enum 57 { 58 SLED_CLKPRE_DIV1 = 0, 59 SLED_CLKPRE_DIV2, 60 SLED_CLKPRE_DIV4, 61 SLED_CLKPRE_DIV3 62 } SLED_CLKPRE_TypeDef; 63 64 /** 65 * @brief Definition of SLED Init Structure. 66 */ 67 typedef struct 68 { 69 u8 ClockPrescaler; 70 u8 BaudRate; 71 u8 T0H; 72 u8 T1H; 73 u8 TRST; 74 u8 SyncState; 75 u8 IdleState; 76 u8 ResetState; 77 u8 SyncMode; 78 u8 OutputPolarity; 79 } SLED_InitTypeDef; 80 /** 81 * @} 82 */ 83 84 /* Exported constants --------------------------------------------------------------------------------------*/ 85 /** @defgroup SLED_Exported_Constants SLED exported constants 86 * @{ 87 */ 88 #define SLED_SYNC_STATE_T0 (0) 89 #define SLED_SYNC_STATE_T1 (1) 90 91 #define SLED_IDLE_STATE_LOW (0) 92 #define SLED_IDLE_STATE_HIGH (1) 93 94 #define SLED_RESET_STATE_LOW (0) 95 #define SLED_RESET_STATE_HIGH (1) 96 97 #define SLED_SYNC_MODE_DISABLE (0) 98 #define SLED_SYNC_MODE_ENABLE (1) 99 100 #define SLED_OUTPUT_NONINVERTING (0) 101 #define SLED_OUTPUT_INVERTING (1) 102 103 #define SLED_FIFO_LEVEL_0 (0 << 6) 104 #define SLED_FIFO_LEVEL_1 (1 << 6) 105 #define SLED_FIFO_LEVEL_2 (2 << 6) 106 #define SLED_FIFO_LEVEL_3 (3 << 6) 107 108 #define IS_SLED_FIFO_LEVEL(LEVEL) ((LEVEL == SLED_FIFO_LEVEL_0) || \ 109 (LEVEL == SLED_FIFO_LEVEL_1) || \ 110 (LEVEL == SLED_FIFO_LEVEL_2) || \ 111 (LEVEL == SLED_FIFO_LEVEL_3)) 112 113 #define IS_SLED(SLED) ((SLED == HT_SLED0) || (SLED == HT_SLED1)) 114 /** 115 * @} 116 */ 117 118 /* Exported functions --------------------------------------------------------------------------------------*/ 119 /** @defgroup SLED_Exported_Functions SLED exported functions 120 * @{ 121 */ 122 void SLED_DeInit(HT_SLED_TypeDef* SLEDx); 123 void SLED_Init(HT_SLED_TypeDef* SLEDx, SLED_InitTypeDef* SLED_InitStruct); 124 125 void SLED_Cmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); 126 void SLED_OutputCmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); 127 void SLED_PDMACmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); 128 129 void SLED_IntCmd(HT_SLED_TypeDef* SLEDx, ControlStatus NewState); 130 void SLED_ClearIntFlag(HT_SLED_TypeDef* SLEDx); 131 132 void SLED_InsertResetCode(HT_SLED_TypeDef* SLEDx); 133 FlagStatus SLED_GetResetCodeStatus(HT_SLED_TypeDef* SLEDx); 134 135 FlagStatus SLED_GetBusyStatus(HT_SLED_TypeDef* SLEDx); 136 137 void SLED_FIFOTrigLevelConfig(HT_SLED_TypeDef* SLEDx, u8 FifoLevel); 138 u8 SLED_GetFIFOStatus(HT_SLED_TypeDef* SLEDx); 139 void SLED_FIFOReset(HT_SLED_TypeDef* SLEDx); 140 /** 141 * @} 142 */ 143 144 145 /** 146 * @} 147 */ 148 149 /** 150 * @} 151 */ 152 153 #ifdef __cplusplus 154 } 155 #endif 156 157 #endif 158