paul@9 | 1 | /* |
paul@33 | 2 | * Ben NanoNote panel-specific definitions |
paul@9 | 3 | * |
paul@33 | 4 | * Copyright (C) Xiangfu Liu <xiangfu@sharism.cc> |
paul@112 | 5 | * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> |
paul@9 | 6 | * |
paul@9 | 7 | * This program is free software; you can redistribute it and/or |
paul@9 | 8 | * modify it under the terms of the GNU General Public License as |
paul@9 | 9 | * published by the Free Software Foundation; either version 2 of |
paul@9 | 10 | * the License, or (at your option) any later version. |
paul@9 | 11 | * |
paul@9 | 12 | * This program is distributed in the hope that it will be useful, |
paul@9 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@9 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@9 | 15 | * GNU General Public License for more details. |
paul@9 | 16 | * |
paul@9 | 17 | * You should have received a copy of the GNU General Public License |
paul@9 | 18 | * along with this program; if not, write to the Free Software |
paul@42 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@42 | 20 | * Boston, MA 02110-1301, USA |
paul@9 | 21 | */ |
paul@9 | 22 | |
paul@27 | 23 | #ifndef __NANONOTE_GPM940B0_H__ |
paul@27 | 24 | #define __NANONOTE_GPM940B0_H__ |
paul@9 | 25 | |
paul@112 | 26 | #include "board.h" |
paul@112 | 27 | #include "nanonote.h" |
paul@112 | 28 | |
paul@112 | 29 | static inline void __spi_write_reg1(u8 reg, u8 val) |
paul@112 | 30 | { |
paul@112 | 31 | u8 no, a=reg, b=val; |
paul@112 | 32 | u16 value; |
paul@112 | 33 | |
paul@112 | 34 | __gpio_set_pin(SPEN); |
paul@112 | 35 | __gpio_set_pin(SPCK); |
paul@112 | 36 | __gpio_clear_pin(SPDA); |
paul@112 | 37 | __gpio_clear_pin(SPEN); |
paul@112 | 38 | |
paul@112 | 39 | value = ((a << 8) | (b & 0xFF)); |
paul@112 | 40 | |
paul@112 | 41 | for (no=0; no<16; no++) |
paul@112 | 42 | { |
paul@112 | 43 | __gpio_clear_pin(SPCK); |
paul@112 | 44 | |
paul@112 | 45 | if ((value & 0x8000) == 0x8000) |
paul@112 | 46 | __gpio_set_pin(SPDA); |
paul@112 | 47 | else |
paul@112 | 48 | __gpio_clear_pin(SPDA); |
paul@9 | 49 | |
paul@112 | 50 | __gpio_set_pin(SPCK); |
paul@112 | 51 | value = (value << 1); |
paul@112 | 52 | } |
paul@112 | 53 | __gpio_set_pin(SPEN); |
paul@112 | 54 | } |
paul@112 | 55 | |
paul@112 | 56 | static inline void __lcd_display_pin_init() |
paul@112 | 57 | { |
paul@112 | 58 | __cpm_start_tcu(); |
paul@112 | 59 | __gpio_as_output(SPEN); |
paul@112 | 60 | __gpio_as_output(SPCK); |
paul@112 | 61 | __gpio_as_output(SPDA); |
paul@112 | 62 | } |
paul@9 | 63 | |
paul@112 | 64 | static inline void __lcd_display_on() |
paul@112 | 65 | { |
paul@112 | 66 | __spi_write_reg1(0x05, 0x1e); |
paul@112 | 67 | __spi_write_reg1(0x05, 0x5e); |
paul@112 | 68 | __spi_write_reg1(0x07, 0x8d); |
paul@112 | 69 | __spi_write_reg1(0x13, 0x01); |
paul@112 | 70 | __spi_write_reg1(0x05, 0x5f); |
paul@112 | 71 | } |
paul@9 | 72 | |
paul@112 | 73 | static inline void __lcd_display_off() |
paul@112 | 74 | { |
paul@112 | 75 | __spi_write_reg1(0x05, 0x5e); |
paul@112 | 76 | } |
paul@9 | 77 | |
paul@27 | 78 | #endif /* __NANONOTE_GPM940B0_H__ */ |