Ht1621b chip display driver
For details about the ht1621b chip, refer to the Data Manual: Baidu Library ht1621b Chinese materials
The following is the chip Driver (ipv8 microcontroller ):
/* Includes ------------------------------------------------------------------ */# include "stm8s. H "# include" Global. H "/* Private typedef character * // * Private define character */# define command_code 0x80 // command code # define write_data_code 0xa0 // write command # define read_data_code 0xc0 // read command # define display_begin_addr (0x0f <2) // display start address # define sys_en 0x02 # define rc_256k 0x30 # define bias_13 0x52 # define tone_on 0x12 // enable sound output # define tone_off 0x10 # define tone_2k 0xc0 # define tone_4k 0x80 # define LCD _on 0x06/* private variables limit */void ht1621_writecommand (uint8_t cmd ); void ht1621_writenbit (uint8_t bitcnt, uint8_t wdata);/* Public Functions ------------------- Optional */void ht1621_init (void); void ht1621_writedata (const uint8_t * wdatabuf); void ht1621_buzzercontrol (uint8_t runflag ); /*************************************** **************************************** function: delay function MS parameters: return values: no *************************************** **************************************** /void ht1621_delay (uint8_t MS) {unsigned short JJ; For (JJ = 1; jj <= MS; JJ ++) {Nop ();}} /*************************************** **************************************** function: ht1621 initialization parameter: return value: no *************************************** **************************************** /void ht1621_init (void) {Listen (sys_en); // sys_en open the system oscillator ht1621_delay (5); ht1621_writecommand (rc_256k); // rc_256k the RC oscillator ht1621_delay (5) in the system clock source chip ); ht1621_writecommand (bias_13); // bias1 3 4 public ports: ht1621_delay (5); ht1621_writecommand (tone_4k); // tone_2kc0 tone_4k80 ht1621_delay (5); ht1621_writecommand (LCD _on ); // LCD _on enable the LCD bias generator ht1621_delay (5 );} /*************************************** **************************************** function: ht1621 write a single byte of data parameters: the number of digits to write data and the returned data values: no *************************************** **************************************** /void ht1621_writenbit (uint8_t wdata, uint8 _ T bitcnt) {uint8_t I; for (I = 0; I <bitcnt; I ++) {ht1621wrlow; ht1621_delay (2); If (wdata <I) & 0x80) {ht1621datahigh;} else {ht1621datalow;} ht1621_delay (2); ht1621wrhigh; ht1621_delay (2 );}} /*************************************** **************************************** function: ht1621 data write operation (three write operation commands + six address +... data) parameter: Write Data Pointer return value: no *************************************** ***************************** * **********/Void ht1621_writedata (const uint8_t * wdatabuf) {uint8_t I; ht1621cslow; ht1621_delay (2); Compile (write_data_code, 3 ); ht1621_writenbit (display_begin_addr, 6); // todo: 20140820 hzg pay attention to the starting address on the corresponding schematic for (I = 0; I <12; I ++) {ht1621_writenbit (wdatabuf [I], 8);} ht1621cshigh; ht1621_delay (2 );} /*************************************** **************************************** function: ht1621 write command operation (12-bit command data) parameter: command value return value: no *************************************** **************************************** /void ht1621_writecommand (uint8_t cmd) {ht1621cslow; ht1621_delay (2); ht1621_writenbit (command_code, 4); ht1621_writenbit (CMD, 8); ht1621cshweigh; ht1621_delay (2 );} /*************************************** **************************************** function: ht1621 buzzer Output Control (12-bit command data) parameter: switch flag return value: No ******************* **************************************** * ******************/Void ht1621_buzzercontrol (uint8_t runflag) {(runflag = 0 )? Ht1621_writecommand (tone_off): ht1621_writecommand (tone_on );}
LCD display-ht1621b chip display driver