altos: Add SPI bus parameter to ao_spi_speed
[fw/altos] / src / drivers / ao_st7565.h
1 /*
2  * Copyright © 2023 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AO_ST7565_H_
20 #define _AO_ST7565_H_
21
22 #include <ao_draw.h>
23
24 #define ST7565_DISPLAY_OFF                      0xae
25 #define ST7565_DISPLAY_ON                       0xaf
26 #define ST7565_DISPLAY_START_LINE_SET(line)     (0x40 | (line))
27 #define ST7565_PAGE_ADDRESS_SET(page)           (0xb0 | (page))
28 #define ST7565_COLUMN_ADDRESS_SET_MSN(nib)      (0x10 | (nib))
29 #define ST7565_COLUMN_ADDRESS_SET_LSN(nib)      (0x00 | (nib))
30 #define ST7565_ADC_SELECT_NORMAL                0xa0
31 #define ST7565_ADC_SELECT_REVERSE               0xa1
32 #define ST7565_DISPLAY_NORMAL                   0xa6
33 #define ST7565_DISPLAY_REVERSE                  0xa7
34 #define ST7565_DISPLAY_ALL_POINTS_OFF           0xa4
35 #define ST7565_DISPLAY_ALL_POINTS_ON            0xa5
36 #define ST7565_LCD_BIAS_1_9                     0xa2
37 #define ST7565_LCD_BIAS_1_7                     0xa3
38 #define ST7565_RMW                              0xe0
39 #define ST7565_RMW_END                          0xee
40 #define ST7565_RESET                            0xe2
41 #define ST7565_COMMON_MODE_NORMAL               0xc0
42 #define ST7565_COMMON_MODE_REVERSE              0xc8
43 #define ST7565_POWER_CONTROL_SET(pc)            (0x28 | (pc))
44 #define ST7565_RESISTOR_RATIO_SET(rr)           (0x20 | (rr))
45 #define ST7565_ELECTRONIC_VOLUME_SET            0x81
46 #define ST7565_SLEEP_MODE                       0xac
47 #define ST7565_BOOSTER_RATIO_SET                0xf8
48 #define ST7565_NOP                              0xe3
49
50 #define AO_ST7565_SPI_SPEED                     ao_spi_speed(AO_ST7565_SPI_BUS, 10000000)
51
52 void
53 ao_st7565_update(struct ao_bitmap *bitmap);
54
55 void
56 ao_st7565_init(void);
57
58 #endif /* _AO_ST7565_H_ */