1 /* 2 * Ben NanoNote panel-specific definitions 3 * 4 * Copyright (C) Xiangfu Liu <xiangfu@sharism.cc> 5 * Copyright (C) 2015 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 #define __spi_write_reg1(reg, val) \ 27 do { \ 28 unsigned char no; \ 29 unsigned short value; \ 30 unsigned char a=reg; \ 31 unsigned char b=val; \ 32 __gpio_set_pin(SPEN); \ 33 __gpio_set_pin(SPCK); \ 34 __gpio_clear_pin(SPDA); \ 35 __gpio_clear_pin(SPEN); \ 36 value=((a<<8)|(b&0xFF)); \ 37 for(no=0;no<16;no++) \ 38 { \ 39 __gpio_clear_pin(SPCK); \ 40 if((value&0x8000)==0x8000) \ 41 __gpio_set_pin(SPDA); \ 42 else \ 43 __gpio_clear_pin(SPDA); \ 44 __gpio_set_pin(SPCK); \ 45 value=(value<<1); \ 46 } \ 47 __gpio_set_pin(SPEN); \ 48 } while (0) 49 50 #define __lcd_display_pin_init() \ 51 do { \ 52 __cpm_start_tcu(); \ 53 __gpio_as_output(SPEN); \ 54 __gpio_as_output(SPCK); \ 55 __gpio_as_output(SPDA); \ 56 } while (0) 57 58 #define __lcd_display_on() \ 59 do { \ 60 __spi_write_reg1(0x05, 0x1e); \ 61 __spi_write_reg1(0x05, 0x5e); \ 62 __spi_write_reg1(0x07, 0x8d); \ 63 __spi_write_reg1(0x13, 0x01); \ 64 __spi_write_reg1(0x05, 0x5f); \ 65 } while (0) 66 67 #define __lcd_display_off() \ 68 do { \ 69 __spi_write_reg1(0x05, 0x5e); \ 70 } while (0) 71 72 #endif /* __NANONOTE_GPM940B0_H__ */