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