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

📄 lcd_st7032.h

📁 7032显示屏的驱动源码。经过测试可以放心使用。
💻 H
字号:
/** * @file lcd_st7032.h * * @ingroup AlphaNumeric LCD Drivers * * @brief This is the software driver for Sitronix ST7032 Compatible LCD devices *        It supports 4-bit and 8-bit variants of the display - 2 line. */#if defined(LCD_TYPE_ST7032_8BIT) || defined(LCD_TYPE_ST7032_4BIT)#if !defined (__LCD_ST7032_H__)#define __LCD_ST7032_H__/**************************** PUBLIC MACROS ***********************************//// Timing parameters for instruction byte issue */#define P_H_WIDTH_INST  3           ///< P_CLK high pulse width (in T_CLKs)#define P_H_DELAY_INST  0           ///< Delay from active edge of D_CLK to P_CLK high (in T_CLKs)#define D_PERIOD_INST   13517       ///< Period of internal signal D_CLK (in T_CLKs)#define T_DIVISOR_INST  2           ///< T clock division control/// Timing parameters for data byte issue#define P_H_WIDTH_DATA  3           ///< P_CLK high pulse width (in T_CLKs)#define P_H_DELAY_DATA  0           ///< Delay from active edge of D_CLK to P_CLK high (in T_CLKs)#define D_PERIOD_DATA   375         ///< Period of internal signal D_CLK (in T_CLKs)#define T_DIVISOR_DATA  2           ///< T clock division control#define LCD_BLANK_CHAR  0x20        ///< ASCII character for 'blank space'#define LCD_MAX_LINE    2           ///< Number of lines on LCD display#define LCD_MAX_CHAR    16          ///< Number of characters per line#define LCD_LINE0_BASE  0x80        ///< Base address for line 0#define LCD_LINE1_BASE  0xC0        ///< Base address for line 1#define LCD_LINE2_BASE  (LCD_LINE0_BASE + LCD_MAX_CHAR) ///< Base address for line 2#define LCD_LINE3_BASE  (LCD_LINE1_BASE + LCD_MAX_CHAR) ///< Base address for line 3#define LCD_SPECCHAR_MAX_CODE   7   ///< Number of Special Character slots = (LCD_MAX_SPECCHAR_CODE + 1)#define LCD_SPECCHAR_BASE_INST  0x40    ///< Instruction code required to access base of first special character in CGRAM#define LCD_SPECCHAR_BASE_CODE  0x08    ///< Data (ASCII) code required to display first special character from CGRAM#define RS_INSTRUCTION      0 ///< LCD configuration register 2: RS_LEVEL = 0 (instruction byte) #define RS_DATA             1 ///< LCD configuration register 2: RS_LEVEL = 1 (data byte) #define NIBBLE_MODE         0 ///< LCD configuration register 2: DB_WIDTH = 4-bit (nibble mode) #define BYTE_MODE           1 ///< LCD configuration register 2: DB_WIDTH = 8-bit (byte mode) #define BIT_MODE            2 ///< LCD configuration register 2: DB_WIDTH = 1-bit (bit mode) #define NO_SWAP             0 ///< LCD configuration register 2: ORDER = default (LS nibble or bit first) #define NIBBLE_SWAP         1 ///< LCD configuration register 2: ORDER = swapped (MS nibble or bit first) /// Compose value to be written to LCD configuration register 0 from: P_H_WIDTH, P_H_DELAY, D_PERIOD. #define LCD_REG0_VALUE(phw,phd,dp)  ((phw << 24) | (phd << 20) | (dp << 0))/// Compose value to be written to LCD configuration register 1 from: T_DIV. #define LCD_REG1_VALUE(td)          ((td << 28))/// Compose value to be written to LCD configuration register 2 from: RS_LEVEL, DB_WIDTH, ORDER. #define LCD_REG2_VALUE(rs,db,o)     ((rs << 31) | (db << 28) | (o << 27))/// LCD initialisation command sequences#define LCD_INIT_LENGTH_4_BIT 10#define LCD_INIT4_CMD0   0x33#define LCD_INIT4_CMD1   0x32#define LCD_INIT4_CMD2   0x29#define LCD_INIT4_CMD3   0x14#define LCD_INIT4_CMD4   0x78#define LCD_INIT4_CMD5   0x57#define LCD_INIT4_CMD6   0x6a#define LCD_INIT4_CMD7   0x0c#define LCD_INIT4_CMD8   0x01#define LCD_INIT4_CMD9   0x06#define LCD_INIT_LENGTH_8_BIT 7#define LCD_INIT8_CMD0   0x30#define LCD_INIT8_CMD1   0x30#define LCD_INIT8_CMD2   0x30#define LCD_INIT8_CMD3   0x3C#define LCD_INIT8_CMD4   0x0C#define LCD_INIT8_CMD5   0x01#define LCD_INIT8_CMD6   0x06/**************************** PUBLIC  TYPES ***********************************//*! This structure contains the values to be written to the LCD registers for *  instruction and data byte transfers.\n *  The values are written to LCD_reg0, LCD_reg1 and LCD_reg2 to control timing *  and target register (within the LCD device).\n *  These differ for instructions and data.\n *  Macros are provided to compose the values to be written. */typedef struct{    /*! Values to be written to LCD registers for instruction bytes */    unsigned long inst[3];    /*! Values to be written to LCD registers for data bytes */    unsigned long data[3];} LCD_SETUP_REG_T;/**************************** PUBLIC FUNCTION DECLARATIONS ********************//** * LCD Transaction handler for the ST7032 Display * <b>Description:</b>\n *  Prepares and issues commands to send the transaction string to the LCD device. *   *  @param     rowNum              LCD row to be accessed. *  @param     colNum              Column of first character to be written. *  @param     numChar             Number of characters to be written. *  @param     *str                String to be output - NULL to clear space. * *  @return                        ::LCD_OK          if successful.\n *                                 ::LCD_ERR_LENGTH  if string is too long (maximum ::PLATFORM_LCD_WIDTH bytes) */LCD_RETURN_T LCD_ST7032_Transaction (    const short x,    const short y,    const unsigned short numChar,    const unsigned char *str);/** *  LCD Initialisation function for the ST7032 Display *   *  <b>It must be called before any other Alphanumeric LCD API function.</b>\n * *  The function initialises the port using the parameters provided. An internal *  copy of the parameter block is taken. The initialisation string (::initString) *  is used by this function and can then be discarded. The cursor reset data *  (::resetCursor) must be maintained by the caller as it is accessed by other *  LCD API functions. *  @param     *info               Pointer to initialisation parameters. * *  @return                        ::LCD_OK        if successful.\n *                                 ::LCD_ERR_PARAM if initialisation parameters are invalid. */LCD_RETURN_T LCD_ST7032_AlphaInit(const LCD_DEVICE_T *info);/** * LCD Custom character creation handler.\n *  * Defines a 'special character' for use by the LCD and programmes it to the device's CGRAM.\n * It presumes that the range of ASCII values used by the LCD to access user defined  * special characters does not include the value ::LCD_ERR_CODE (used as an error return value). * * @param      code                 Handle indicating the desired 'special char' *                                  slot to use (maximum declared in ::LCD_SPECCHAR_T) * @param     *buf                8 bytes describing the character's bit pattern. * * @return                        ::LCD_ERR_CODE if invalid code parameter specified.\n *                                ASCII value to be used to access the character. */LCD_RETURN_T LCD_ST7032_AlphaSpecialChar (const unsigned long  code, const unsigned char *buf);// Now wrap the functions to this particular implementation#define LCDTransaction (LCD_ST7032_Transaction)#define LCDAlphaInit (LCD_ST7032_AlphaInit)#define LCDAlphaSpecialChar (LCD_ST7032_AlphaSpecialChar)#endif /* __LCD_ST7032_H__ */#endif // LCD_TYPE_ST7032_8BIT | LCD_TYPE_ST7032_4BIT

⌨️ 快捷键说明

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