1 | #include <avr/io.h>
|
2 | #include <inttypes.h>
|
3 | #include "lib_delay.h"
|
4 | #include "lib_lcd.h"
|
5 | #include "init_display_DEM128064K.h"
|
6 |
|
7 | static const uint8_t init_cmd_array[]={
|
8 | 0xA0 + 0, // ADC select, normal = 0, reverse = 1
|
9 | 0xA6 + 0, // normal mode = 0, reverse mode = 1
|
10 | 0xC0 + 8, // select COM output scan direction,
|
11 | 0xA2 + 0, // LCD bias set, 0 = 1/9 bias, 1 = 1/7 bias
|
12 | 0x2F, // power control voltage follow on
|
13 | 0x20 + 1, // regulator resistor 0(light) ... 7(dark)
|
14 | 0x1F, // set contrast
|
15 | 0xB0 + 0, // set page address (0 to 15)
|
16 | 0x40 + 0, // set display start line
|
17 | 0x10 + 0, // set column address MSB from 0 to 15
|
18 | 0x00 + 0, // set column address LSB from 0 bis 15
|
19 | 0xAE + 1, // display on = 1, off = 0
|
20 | 0x81, // electronic volume
|
21 | 0x1B
|
22 | };
|
23 |
|
24 | void init_display_uartspi(void)
|
25 | {
|
26 | uint8_t byte=sizeof(init_cmd_array);
|
27 |
|
28 | PORTE.DIR|= LCD_BACKLIGHT;
|
29 | PORTE.OUT|= LCD_BACKLIGHT;
|
30 | PORTF.DIR|= LCD_CS;
|
31 | PORTF.OUT|= LCD_CS;
|
32 | PORTA.DIR|= LCD_RES;
|
33 |
|
34 | PORTD.DIR|= (LCD_CLK+LCD_A0+LCD_MOSI); // set SCK, A0, MOSI as output
|
35 | PORTD.PIN1CTRL|= (PORT_OPC_TOTEM_gc+PORT_INVEN_bm); // set SCK pin mode
|
36 | PORTD.OUT|= LCD_CLK; // set SCK pin high
|
37 |
|
38 | USARTD0.CTRLC = (USART_CMODE_gm+0x02); // Async, no parity, 8 bit data, 1 stop bit
|
39 | USARTD0.BAUDCTRLB = 0; // BSCALE = 0
|
40 | USARTD0.BAUDCTRLA = 15; // Baudrate 9600 @ 2MHz
|
41 | USARTD0.CTRLB = USART_TXEN_bm; // TX Enable CLK
|
42 |
|
43 | delay_ms(50); // wait for clock stabilize
|
44 |
|
45 | PORTA.OUT&=~LCD_RES; // reset low
|
46 | delay_ms(500);
|
47 | PORTA.OUT|=LCD_RES; // reset high
|
48 |
|
49 | while(byte)
|
50 | {
|
51 | send_lcd_cmd(init_cmd_array[sizeof(init_cmd_array)-byte]);
|
52 | byte--;
|
53 | }
|
54 | fill_display(LCD_WIDTH+1,LCD_HEIGHT,0x00);
|
55 |
|
56 | }
|
57 |
|
58 |
|
59 | #include <avr/io.h>
|
60 | #include <inttypes.h>
|
61 | #include "init_display_DEM128064K.h"
|
62 | #include "lib_delay.h"
|
63 | #include "lib_lcd.h"
|
64 | #include "const_lcd_data.h"
|
65 | #define F_CPU 320000000UL
|
66 |
|
67 | void clock_init(void)
|
68 | {
|
69 | OSC.CTRL |= OSC_RC32MEN_bm;
|
70 | while(!(OSC.STATUS & OSC_RC32MRDY_bm));
|
71 | CCP = CCP_IOREG_gc;
|
72 | CLK.CTRL = CLK_SCLKSEL_RC32M_gc;
|
73 | }
|
74 |
|
75 | int main(void)
|
76 | {
|
77 |
|
78 | int i;
|
79 |
|
80 | //clock_init();
|
81 | init_display_uartspi();
|
82 |
|
83 | while (1)
|
84 | {
|
85 | send_lcd_mem(0xFF);
|
86 | }
|
87 |
|
88 | }
|