lcd-ssd1303 (all Clips) : move model specific code in their own files
[kugel-rb.git] / firmware / target / arm / as3525 / sansa-clipplus / lcd-clip-plus.c
blob66e4de98ed9555f176a9077a9851a643a5d9ffcf
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 François Dinel
11 * Copyright (C) 2008-2009 Rafaël Carré
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #include "config.h"
24 #include "lcd.h"
25 #include "system.h"
26 #include "cpu.h"
28 void lcd_hw_init(void)
30 CGU_PERI |= CGU_SSP_CLOCK_ENABLE;
32 SSP_CPSR = AS3525_SSP_PRESCALER; /* OF = 0x10 */
33 SSP_CR0 = (1<<7) | (1<<6) | 7; /* Motorola SPI frame format, 8 bits */
34 SSP_CR1 = (1<<3) | (1<<1); /* SSP Operation enabled */
35 SSP_IMSC = 0; /* No interrupts */
37 GPIOA_DIR |= (1<<5);
38 GPIOB_DIR |= (1<<2) | (1<<7);
39 GPIOB_PIN(7) = 0;
40 GPIOA_PIN(5) = (1<<5);
43 void lcd_write_command(int byte)
45 while(SSP_SR & (1<<4)) /* BSY flag */
48 GPIOB_PIN(2) = 0;
49 SSP_DATA = byte;
51 while(SSP_SR & (1<<4)) /* BSY flag */
55 void lcd_write_data(const fb_data* p_bytes, int count)
57 GPIOB_PIN(2) = (1<<2);
59 while (count--)
61 while(!(SSP_SR & (1<<1))) /* wait until transmit FIFO is not full */
64 SSP_DATA = *p_bytes++;