1 /*********************************************************************************************************//** 2 * @file ht32f5xxxx_lcd.h 3 * @version V1.00 4 * @date 11/15/2017 5 * @brief The header file of the LCD 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_LCD_H 30 #define __HT32F5XXXX_LCD_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 LCD 44 * @{ 45 */ 46 47 48 /* Exported types ------------------------------------------------------------------------------------------*/ 49 /** @defgroup LCD_Exported_Types LCD exported types 50 * @{ 51 */ 52 /** 53 * @brief Enumeration of LCD mask time. 54 */ 55 typedef enum { 56 LCD_MaskTime_25ns = (0x00 << 24), /*!< MCONT mask time = 25 ns */ 57 LCD_MaskTime_40ns = (0x01 << 24), /*!< MCONT mask time = 40 ns */ 58 } LCD_MaskTime_Enum; 59 60 /** 61 * @brief Enumeration of LCD STATIC switch. 62 */ 63 typedef enum { 64 LCD_StaticSwitch_Close = (0x00 << 14), /*!< STATIC switch is closed during dead time */ 65 LCD_StaticSwitch_Open = (0x01 << 14), /*!< STATIC switch is open during dead time */ 66 } LCD_StaticSwitch_Enum; 67 68 /** 69 * @brief Enumeration of LCD MUXCOM7. 70 */ 71 typedef enum 72 { 73 /*!< 57341: SEG28/COM7 */ 74 /*!< 57352: SEG36/COM7 */ 75 LCD_MUXCOM7_IS_COM7 = (0x00 << 11), 76 LCD_MUXCOM7_IS_SEGx = (0x01 << 11), 77 } LCD_MUXCOM7_Enum; 78 79 /** 80 * @brief Enumeration of LCD MUXCOM6. 81 */ 82 typedef enum 83 { 84 /*!< 57341: SEG27/COM6 */ 85 /*!< 57352: SEG35/COM6 */ 86 LCD_MUXCOM6_IS_COM6 = (0x00 << 10), 87 LCD_MUXCOM6_IS_SEGx = (0x01 << 10), 88 } LCD_MUXCOM6_Enum; 89 90 /** 91 * @brief Enumeration of LCD MUXCOM5. 92 */ 93 typedef enum 94 { 95 /*!< 57341: SEG26/COM5 */ 96 /*!< 57352: SEG34/COM5 */ 97 LCD_MUXCOM5_IS_COM5 = (0x00 << 9), 98 LCD_MUXCOM5_IS_SEGx = (0x01 << 9), 99 } LCD_MUXCOM5_Enum; 100 101 /** 102 * @brief Enumeration of LCD MUXCOM4. 103 */ 104 typedef enum 105 { 106 /*!< 57341: SEG25/COM4 */ 107 /*!< 57352: SEG33/COM4 */ 108 LCD_MUXCOM4_IS_COM4 = (0x00 << 8), 109 LCD_MUXCOM4_IS_SEGx = (0x01 << 8), 110 } LCD_MUXCOM4_Enum; 111 112 /** 113 * @brief Enumeration of LCD waveform. 114 */ 115 typedef enum 116 { 117 LCD_Type_A_Waveform = (0x00 << 7), /*!< Type A waveform */ 118 LCD_Type_B_Waveform = (0x01 << 7), /*!< Type B waveform */ 119 } LCD_Waveform_Enum; 120 121 /** 122 * @brief Enumeration of LCD bias. 123 */ 124 typedef enum { 125 LCD_Bias_1_4 = (0x00 << 5), /*!< 1/4 bias */ 126 LCD_Bias_1_2 = (0x01 << 5), /*!< 1/2 bias */ 127 LCD_Bias_1_3 = (0x02 << 5), /*!< 1/3 bias */ 128 LCD_Bias_Static = (0x03 << 5), /*!< Static bias */ 129 } LCD_Bias_Enum; 130 131 /** 132 * @brief Enumeration of LCD duty. 133 */ 134 typedef enum { 135 LCD_Duty_Static = (0x00 << 2), /*!< Static duty */ 136 LCD_Duty_1_2 = (0x01 << 2), /*!< 1/2 duty */ 137 LCD_Duty_1_3 = (0x02 << 2), /*!< 1/3 duty */ 138 LCD_Duty_1_4 = (0x03 << 2), /*!< 1/4 duty */ 139 LCD_Duty_1_6 = (0x04 << 2), /*!< 1/6 duty */ 140 LCD_Duty_1_8 = (0x05 << 2), /*!< 1/8 duty */ 141 } LCD_Duty_Enum; 142 143 /** 144 * @brief Enumeration of LCD voltage source. 145 */ 146 typedef enum { 147 LCD_VoltageSource_External = (0x00 << 1), /*!< External voltage source */ 148 LCD_VoltageSource_Internal = (0x01 << 1), /*!< Internal voltage source */ 149 } LCD_VoltageSource_Enum; 150 151 /** 152 * @brief Enumeration of LCD clock prescaler. 153 */ 154 typedef enum { 155 LCD_Prescaler_1 = (0x00 << 22), /*!< CK_PS = CK_LCD / 1 */ 156 LCD_Prescaler_2 = (0x01 << 22), /*!< CK_PS = CK_LCD / 2 */ 157 LCD_Prescaler_4 = (0x02 << 22), /*!< CK_PS = CK_LCD / 4 */ 158 LCD_Prescaler_8 = (0x03 << 22), /*!< CK_PS = CK_LCD / 8 */ 159 LCD_Prescaler_16 = (0x04 << 22), /*!< CK_PS = CK_LCD / 16 */ 160 LCD_Prescaler_32 = (0x05 << 22), /*!< CK_PS = CK_LCD / 32 */ 161 LCD_Prescaler_64 = (0x06 << 22), /*!< CK_PS = CK_LCD / 64 */ 162 LCD_Prescaler_128 = (0x07 << 22), /*!< CK_PS = CK_LCD / 128 */ 163 LCD_Prescaler_256 = (0x08 << 22), /*!< CK_PS = CK_LCD / 256 */ 164 LCD_Prescaler_512 = (0x09 << 22), /*!< CK_PS = CK_LCD / 512 */ 165 LCD_Prescaler_1024 = (0x0A << 22), /*!< CK_PS = CK_LCD / 1024 */ 166 LCD_Prescaler_2048 = (0x0B << 22), /*!< CK_PS = CK_LCD / 2048 */ 167 LCD_Prescaler_4096 = (0x0C << 22), /*!< CK_PS = CK_LCD / 4096 */ 168 LCD_Prescaler_8192 = (0x0D << 22), /*!< CK_PS = CK_LCD / 8192 */ 169 LCD_Prescaler_16384 = (0x0E << 22), /*!< CK_PS = CK_LCD / 16384 */ 170 LCD_Prescaler_32768 = (0x0F << 22) /*!< CK_PS = CK_LCD / 32768 */ 171 } LCD_Prescaler_Enum; 172 173 /** 174 * @brief Enumeration of LCD clock divider. 175 */ 176 typedef enum { 177 LCD_Divider_16 = (0x00 << 18), /*!< CK_DIV = CK_PS / 16 */ 178 LCD_Divider_17 = (0x01 << 18), /*!< CK_DIV = CK_PS / 17 */ 179 LCD_Divider_18 = (0x02 << 18), /*!< CK_DIV = CK_PS / 18 */ 180 LCD_Divider_19 = (0x03 << 18), /*!< CK_DIV = CK_PS / 19 */ 181 LCD_Divider_20 = (0x04 << 18), /*!< CK_DIV = CK_PS / 20 */ 182 LCD_Divider_21 = (0x05 << 18), /*!< CK_DIV = CK_PS / 21 */ 183 LCD_Divider_22 = (0x06 << 18), /*!< CK_DIV = CK_PS / 22 */ 184 LCD_Divider_23 = (0x07 << 18), /*!< CK_DIV = CK_PS / 23 */ 185 LCD_Divider_24 = (0x08 << 18), /*!< CK_DIV = CK_PS / 24 */ 186 LCD_Divider_25 = (0x09 << 18), /*!< CK_DIV = CK_PS / 25 */ 187 LCD_Divider_26 = (0x0A << 18), /*!< CK_DIV = CK_PS / 26 */ 188 LCD_Divider_27 = (0x0B << 18), /*!< CK_DIV = CK_PS / 27 */ 189 LCD_Divider_28 = (0x0C << 18), /*!< CK_DIV = CK_PS / 28 */ 190 LCD_Divider_29 = (0x0D << 18), /*!< CK_DIV = CK_PS / 29 */ 191 LCD_Divider_30 = (0x0E << 18), /*!< CK_DIV = CK_PS / 30 */ 192 LCD_Divider_31 = (0x0F << 18), /*!< CK_DIV = CK_PS / 31 */ 193 } LCD_Divider_Enum; 194 195 /** 196 * @brief Enumeration of LCD blink mode. 197 */ 198 typedef enum { 199 LCD_BlinkMode_Off = (0x00 << 16), /*!< Blink inactive */ 200 LCD_BlinkMode_SEG0_COM0 = (0x01 << 16), /*!< SEG0 on COM0 blink */ 201 LCD_BlinkMode_SEG0_AllCOM = (0x02 << 16), /*!< SEG0 on All COM blink */ 202 LCD_BlinkMode_AllSEG_AllCOM = (0x03 << 16), /*!< All SEG on All COM blink */ 203 } LCD_BlinkMode_Enum; 204 205 /** 206 * @brief Enumeration of LCD blink frequency. 207 */ 208 typedef enum 209 { 210 LCD_BlinkFrequency_Div8 = (0x00 << 13), /*!< Blink frequency = frame rate / 8 */ 211 LCD_BlinkFrequency_Div16 = (0x01 << 13), /*!< Blink frequency = frame rate / 16 */ 212 LCD_BlinkFrequency_Div32 = (0x02 << 13), /*!< Blink frequency = frame rate / 32 */ 213 LCD_BlinkFrequency_Div64 = (0x03 << 13), /*!< Blink frequency = frame rate / 64 */ 214 LCD_BlinkFrequency_Div128 = (0x04 << 13), /*!< Blink frequency = frame rate / 128 */ 215 LCD_BlinkFrequency_Div256 = (0x05 << 13), /*!< Blink frequency = frame rate / 256 */ 216 LCD_BlinkFrequency_Div512 = (0x06 << 13), /*!< Blink frequency = frame rate / 512 */ 217 LCD_BlinkFrequency_Div1024 = (0x07 << 13), /*!< Blink frequency = frame rate / 1024 */ 218 } LCD_BlinkFrequency_Enum; 219 220 /** 221 * @brief Enumeration of LCD charge pump. 222 */ 223 typedef enum 224 { 225 LCD_ChargePump_2V65 = (0x00 << 10), /*!< Charge pump voltage = 2.65 V */ 226 LCD_ChargePump_2V75 = (0x01 << 10), /*!< Charge pump voltage = 2.75 V */ 227 LCD_ChargePump_2V85 = (0x02 << 10), /*!< Charge pump voltage = 2.85 V */ 228 LCD_ChargePump_2V95 = (0x03 << 10), /*!< Charge pump voltage = 2.95 V */ 229 LCD_ChargePump_3V10 = (0x04 << 10), /*!< Charge pump voltage = 3.10 V */ 230 LCD_ChargePump_3V25 = (0x05 << 10), /*!< Charge pump voltage = 3.25 V */ 231 LCD_ChargePump_3V40 = (0x06 << 10), /*!< Charge pump voltage = 3.40 V */ 232 LCD_ChargePump_3V55 = (0x07 << 10), /*!< Charge pump voltage = 3.55 V */ 233 } LCD_ChargePump_Enum; 234 235 /** 236 * @brief Enumeration of LCD dead time. 237 */ 238 typedef enum 239 { 240 LCD_Deadtime_0 = (0x00 << 7), /*!< No dead time */ 241 LCD_Deadtime_1 = (0x01 << 7), /*!< Type A: 1/2 phase period; Type B: 1 phase period */ 242 LCD_Deadtime_2 = (0x02 << 7), /*!< Type A: 2/2 phase period; Type B: 2 phase period */ 243 LCD_Deadtime_3 = (0x03 << 7), /*!< Type A: 3/2 phase period; Type B: 3 phase period */ 244 LCD_Deadtime_4 = (0x04 << 7), /*!< Type A: 4/2 phase period; Type B: 4 phase period */ 245 LCD_Deadtime_5 = (0x05 << 7), /*!< Type A: 5/2 phase period; Type B: 5 phase period */ 246 LCD_Deadtime_6 = (0x06 << 7), /*!< Type A: 6/2 phase period; Type B: 6 phase period */ 247 LCD_Deadtime_7 = (0x07 << 7), /*!< Type A: 7/2 phase period; Type B: 7 phase period */ 248 } LCD_DeadTime_Enum; 249 250 /** 251 * @brief Enumeration of LCD high drive. 252 */ 253 typedef enum 254 { 255 LCD_HighDrive_0 = (0x00 << 4), /*!< No high drive */ 256 LCD_HighDrive_1 = (0x01 << 4), /*!< High drive duration = 1 CK_PS pulses */ 257 LCD_HighDrive_2 = (0x02 << 4), /*!< High drive duration = 2 CK_PS pulses */ 258 LCD_HighDrive_3 = (0x03 << 4), /*!< High drive duration = 3 CK_PS pulses */ 259 LCD_HighDrive_4 = (0x04 << 4), /*!< High drive duration = 4 CK_PS pulses */ 260 LCD_HighDrive_5 = (0x05 << 4), /*!< High drive duration = 5 CK_PS pulses */ 261 LCD_HighDrive_6 = (0x06 << 4), /*!< High drive duration = 6 CK_PS pulses */ 262 LCD_HighDrive_7 = (0x07 << 4), /*!< High drive duration = 7 CK_PS pulses */ 263 LCD_HighDrive_Static = (0xff), /*!< Static high drive */ 264 } LCD_HighDrive_Enum; 265 266 /** 267 * @brief Definition of LCD Init Structure. 268 */ 269 typedef struct 270 { 271 LCD_Prescaler_Enum LCD_Prescaler; 272 LCD_Divider_Enum LCD_Divider; 273 LCD_Duty_Enum LCD_Duty; 274 LCD_Bias_Enum LCD_Bias; 275 LCD_Waveform_Enum LCD_Waveform; 276 LCD_VoltageSource_Enum LCD_VoltageSource; 277 } LCD_InitTypeDef; 278 /** 279 * @} 280 */ 281 282 /* Exported constants --------------------------------------------------------------------------------------*/ 283 /** @defgroup LCD_Exported_Constants LCD exported constants 284 * @{ 285 */ 286 #define LCD_INT_UDD ((u32)0x00000002) 287 #define LCD_INT_SOF ((u32)0x00000001) 288 289 #define IS_LCD_INT(INT) ((((INT) & 0xFFFFFFFC) == 0) && ((INT) != 0)) 290 291 292 #define LCD_FLAG_FCRSF ((u32)0x00000020) 293 #define LCD_FLAG_RDY ((u32)0x00000010) 294 #define LCD_FLAG_UDD ((u32)0x00000008) 295 #define LCD_FLAG_UDR ((u32)0x00000004) 296 #define LCD_FLAG_SOF ((u32)0x00000002) 297 #define LCD_FLAG_ENS ((u32)0x00000001) 298 299 #define IS_LCD_FLAG(FLAG) (((FLAG) == LCD_FLAG_FCRSF) || \ 300 ((FLAG) == LCD_FLAG_RDY) || \ 301 ((FLAG) == LCD_FLAG_UDD) || \ 302 ((FLAG) == LCD_FLAG_UDR) || \ 303 ((FLAG) == LCD_FLAG_SOF) || \ 304 ((FLAG) == LCD_FLAG_ENS)) 305 306 307 #define LCD_CLR_UDD ((u32)0x00000002) 308 #define LCD_CLR_SOF ((u32)0x00000001) 309 310 #define IS_LCD_CLEAR(CLR) ((((CLR) & 0xFFFFFFFC) == 0) && ((CLR) != 0)) 311 /** 312 * @} 313 */ 314 315 /* Exported functions --------------------------------------------------------------------------------------*/ 316 /** @defgroup LCD_Exported_Functions LCD exported functions 317 * @{ 318 */ 319 320 /* !!! NOTICE !!! 321 Before using the following functions, be sure to confirm LCDENS = 0 by "LCD_GetFlagStatus(LCD_FLAG_ENS);", 322 otherwise the LCD may display abnormally. 323 LCD_DriverInit() 324 LCD_MaskTimeConfig() 325 LCD_StaticSwitchConfig() 326 LCD_MuxCOM7Config() 327 LCD_MuxCOM6Config() 328 LCD_MuxCOM5Config() 329 LCD_MuxCOM4Config() 330 LCD_WaveformConfig() 331 LCD_BiasConfig() 332 LCD_DutyConfig() 333 LCD_VoltageSourceConfig() 334 LCD_ChargePumpConfig() 335 */ 336 337 void LCD_DriverDeInit(void); 338 void LCD_DriverInit(LCD_InitTypeDef* LCD_InitStruct); 339 340 void LCD_MaskTimeConfig(LCD_MaskTime_Enum Sel); 341 void LCD_HalfRLCmd(ControlStatus NewState); 342 void LCD_StaticSwitchConfig(LCD_StaticSwitch_Enum Sel); 343 void LCD_MuxCOM7Config(LCD_MUXCOM7_Enum Sel); 344 void LCD_MuxCOM6Config(LCD_MUXCOM6_Enum Sel); 345 void LCD_MuxCOM5Config(LCD_MUXCOM5_Enum Sel); 346 void LCD_MuxCOM4Config(LCD_MUXCOM4_Enum Sel); 347 void LCD_WaveformConfig(LCD_Waveform_Enum Sel); 348 void LCD_BiasConfig(LCD_Bias_Enum Sel); 349 void LCD_DutyConfig(LCD_Duty_Enum Sel); 350 void LCD_VoltageSourceConfig(LCD_VoltageSource_Enum Sel); 351 void LCD_Cmd(ControlStatus NewState); 352 353 void LCD_PrescalerConfig(LCD_Prescaler_Enum Sel); 354 void LCD_DividerConfig(LCD_Divider_Enum Sel); 355 void LCD_BlinkModeConfig(LCD_BlinkMode_Enum Sel); 356 void LCD_BlinkFreqConfig(LCD_BlinkFrequency_Enum Sel); 357 void LCD_ChargePumpConfig(LCD_ChargePump_Enum Sel); 358 void LCD_DeadTimeConfig(LCD_DeadTime_Enum Sel); 359 void LCD_HighDriveConfig(LCD_HighDrive_Enum Sel); 360 361 void LCD_IntConfig(u32 LCD_Int, ControlStatus NewState); 362 FlagStatus LCD_GetFlagStatus(u32 LCD_Flag); 363 void LCD_SetUpdateDisplayRequest(void); 364 void LCD_ClearFlag(u32 LCD_Flag); 365 /** 366 * @} 367 */ 368 369 370 /** 371 * @} 372 */ 373 374 /** 375 * @} 376 */ 377 378 #ifdef __cplusplus 379 } 380 #endif 381 382 #endif 383