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@33 | 5 | * Copyright (C) 2015 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@9 | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
paul@9 | 20 | * MA 02111-1307 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@9 | 26 | #define __spi_write_reg1(reg, val) \ |
paul@9 | 27 | do { \ |
paul@9 | 28 | unsigned char no; \ |
paul@9 | 29 | unsigned short value; \ |
paul@9 | 30 | unsigned char a=reg; \ |
paul@9 | 31 | unsigned char b=val; \ |
paul@9 | 32 | __gpio_set_pin(SPEN); \ |
paul@9 | 33 | __gpio_set_pin(SPCK); \ |
paul@9 | 34 | __gpio_clear_pin(SPDA); \ |
paul@9 | 35 | __gpio_clear_pin(SPEN); \ |
paul@9 | 36 | value=((a<<8)|(b&0xFF)); \ |
paul@9 | 37 | for(no=0;no<16;no++) \ |
paul@9 | 38 | { \ |
paul@9 | 39 | __gpio_clear_pin(SPCK); \ |
paul@9 | 40 | if((value&0x8000)==0x8000) \ |
paul@9 | 41 | __gpio_set_pin(SPDA); \ |
paul@9 | 42 | else \ |
paul@9 | 43 | __gpio_clear_pin(SPDA); \ |
paul@9 | 44 | __gpio_set_pin(SPCK); \ |
paul@9 | 45 | value=(value<<1); \ |
paul@9 | 46 | } \ |
paul@9 | 47 | __gpio_set_pin(SPEN); \ |
paul@9 | 48 | } while (0) |
paul@9 | 49 | |
paul@9 | 50 | #define __lcd_display_pin_init() \ |
paul@9 | 51 | do { \ |
paul@9 | 52 | __cpm_start_tcu(); \ |
paul@21 | 53 | __gpio_as_output(SPEN); \ |
paul@21 | 54 | __gpio_as_output(SPCK); \ |
paul@21 | 55 | __gpio_as_output(SPDA); \ |
paul@9 | 56 | } while (0) |
paul@9 | 57 | |
paul@9 | 58 | #define __lcd_display_on() \ |
paul@9 | 59 | do { \ |
paul@9 | 60 | __spi_write_reg1(0x05, 0x1e); \ |
paul@9 | 61 | __spi_write_reg1(0x05, 0x5e); \ |
paul@9 | 62 | __spi_write_reg1(0x07, 0x8d); \ |
paul@9 | 63 | __spi_write_reg1(0x13, 0x01); \ |
paul@9 | 64 | __spi_write_reg1(0x05, 0x5f); \ |
paul@9 | 65 | } while (0) |
paul@9 | 66 | |
paul@9 | 67 | #define __lcd_display_off() \ |
paul@9 | 68 | do { \ |
paul@9 | 69 | __spi_write_reg1(0x05, 0x5e); \ |
paul@9 | 70 | } while (0) |
paul@9 | 71 | |
paul@27 | 72 | #endif /* __NANONOTE_GPM940B0_H__ */ |