-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathht1621.h
More file actions
71 lines (64 loc) · 3.87 KB
/
ht1621.h
File metadata and controls
71 lines (64 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @file ht1621.h
* @author Ed Holmes (ed.holmes(at)me.com)
* @brief Simple HT1621 LCD driver implementing command and successive write functionality.
Developed using HT1621 datasheet Rev 1.30 (August 6, 2003)
* @date 2025-11-09
* @copyright Copyright (c) 2025 Ed Holmes
*
* SPDX-License-Identifier: MIT
*
*/
#ifndef HT1621_H_
#define HT1621_H_
#include "gpio.h"
#include "ht1621_port.h"
#include "main.h"
#include <stdio.h>
#if defined(HT1621_USE_GPIO_INTERFACE) && defined(HT1621_USE_SPI_INTERFACE)
#error "Only one interface can be selected at a time"
#endif
#if !defined(HT1621_USE_GPIO_INTERFACE) && !defined(HT1621_USE_SPI_INTERFACE)
#error "One interface must be selected"
#endif
enum HT1621_CMD_CODE
{
HT1621_CMD_SYSDIS = 0X00, // 100 0000-0000-X, Turn off both system oscillator and LCD bias generator
HT1621_CMD_SYSEN = 0x01, // 100 0000-0001-X, Turn on system oscillator
HT1621_CMD_LCDOFF = 0x02, // 100 0000-0010-X, Turn off LCD bias generator
HT1621_CMD_LCDON = 0x03, // 100 0000-0011-X, Turn on LCD bias generator
HT1621_CMD_TIMDIS = 0x04, // 100 0000-0100-X, Disable time base output
HT1621_CMD_WDTDIS = 0x05, // 100 0000-0101-X, Disable WDT time-out flag output
HT1621_CMD_TIMEN = 0x06, // 100 0000-0110-X, Enable time base output
HT1621_CMD_WDTEN = 0x07, // 100 0000-0111-X, Enable WDT time-out flag output
HT1621_CMD_TONEOFF = 0x08, // 100 0000-1000-X, Turn off tone outputs
HT1621_CMD_TONEON = 0x09, // 100 0000-1001-X, Turn on tone outputs
HT1621_CMD_CLRTIM = 0x0C, // 100 0000-11XX-X, Clear the contents of time base generator
HT1621_CMD_CLRWDT = 0x0E, // 100 0000-111X-X, Clear the contents of WDT stage
HT1621_CMD_XTAL32K = 0x14, // 100 0001-01XX-X, System clock source, crystal oscillator
HT1621_CMD_RC256K = 0x18, // 100 0001-10XX-X, System clock source, on-chip RC oscillator
HT1621_CMD_EXT256K = 0x1C, // 100 0001-11XX-X, System clock source, external clock source
HT1621_CMD_BIAS12 = 0x20, // 100 0010-abX0-X, LCD 1/2 bias option: ab=00: 2 commons option; ab=01: 3 commons option;
// ab=10: 4 commons option
HT1621_CMD_BIAS13 = 0x21, // 100 0010-abX1-X, LCD 1/3 bias option: ab=00: 2 commons option; ab=01: 3 commons option;
// ab=10: 4 commons option
HT1621_CMD_BIAS = 0x29, // 100 0010-1001-X, Bias used to initialize the display, ab = 10
HT1621_CMD_TONE4K = 0x40, // 100 010X-XXXX-X, Tone frequency, 4kHz
HT1621_CMD_TONE2K = 0x60, // 100 011X-XXXX-X, Tone frequency, 2kHz
HT1621_CMD_IRQDIS = 0x80, // 100 100X-0XXX-X, Disable IRQ output
HT1621_CMD_IRQEN = 0x88, // 100 100X-1XXX-X, Enable IRQ output
HT1621_CMD_F1 = 0xA0, // 100 101X-X000-X, Time base/WDT clock output:1Hz The WDT time-out flag after: 4s
HT1621_CMD_F2 = 0xA1, // 100 101X-X001-X, Time base/WDT clock output:2Hz The WDT time-out flag after: 2s
HT1621_CMD_F4 = 0xA2, // 100 101X-X010-X, Time base/WDT clock output:4Hz The WDT time-out flag after: 1s
HT1621_CMD_F8 = 0xA3, // 100 101X-X011-X, Time base/WDT clock output:8Hz The WDT time-out flag after: 1/2s
HT1621_CMD_F16 = 0xA4, // 100 101X-X100-X, Time base/WDT clock output:16Hz The WDT time-out flag after: 1/4s
HT1621_CMD_F32 = 0xA5, // 100 101X-X101-X, Time base/WDT clock output:32Hz The WDT time-out flag after: 1/8s
HT1621_CMD_F64 = 0xA6, // 100 101X-X110-X, Time base/WDT clock output:64Hz The WDT time-out flag after: 1/16s
HT1621_CMD_F128 = 0xA7, // 100 101X-X111-X, Time base/WDT clock output:128Hz The WDT time-out flag after: 1/32s
HT1621_CMD_TEST = 0xE0, // 100 1110-0000-X, Test mode, user don′t use.
HT1621_CMD_NORMAL = 0xE3 // 100 1110-0011-X, Normal mode
};
void HT1621_Init(void);
void HT1621_SuccessiveWrite(uint8_t *data, uint8_t start_address, size_t num_nibbles);
void HT1621_WriteCommand(enum HT1621_CMD_CODE cmd);
#endif