| 1 | // ************************************************************
 | 
| 2 | // Initialize LCD module
 | 
| 3 | // ************************************************************
 | 
| 4 | 
 | 
| 5 | void dogm_init(void)
 | 
| 6 | {
 | 
| 7 |   dogm_port_init();                     // initialize ports
 | 
| 8 | 
 | 
| 9 |   _delay_ms(400);                       // 40ms delay
 | 
| 10 |   dogm_write_once(0x30);                // Function Set #1: DL=1
 | 
| 11 |   _delay_ms(2);                         // 2ms delay
 | 
| 12 |   dogm_write_once(0x30);                // Function Set #2: DL=1
 | 
| 13 | 
 | 
| 14 |   _delay_us(30);                        // 30us delay
 | 
| 15 |   dogm_write_once(0x30);                // Function Set #3: DL=1
 | 
| 16 |   _delay_us(30);                        // 30us delay
 | 
| 17 | 
 | 
| 18 |   dogm_chk_busy();                      // Check busy flag
 | 
| 19 |   dogm_write_once(0x20);                // Function Set #4: DL=0
 | 
| 20 | 
 | 
| 21 |   _delay_us(30);                        // 30us delay
 | 
| 22 |   dogm_write_check(0, 0x29);            // Function Set #5: DL=0, N=1, IS2=0, IS1=1
 | 
| 23 |   _delay_us(30);                        // 30us delay
 | 
| 24 | 
 | 
| 25 |   dogm_write_check(0, 0x14);            // Bias Set: BS=0, FX=0
 | 
| 26 |   _delay_us(30);                        // 30us delay
 | 
| 27 | 
 | 
| 28 |   dogm_write_check(0, 0x78);            // Contrast Set: C3=1, C2=C1=C0=0
 | 
| 29 |   _delay_us(30);                        // 30us delay
 | 
| 30 | 
 | 
| 31 |   dogm_write_check(0, 0x5E);            // Power/ICON/Contrast: Icon=1, Bon=1, C5=1, C4=0
 | 
| 32 |   _delay_us(30);                        // 30us delay
 | 
| 33 | 
 | 
| 34 |   dogm_write_check(0, 0x6A);            // Follower Ctrl: Fon=1, Rab2=0, Rab1=1, Rab0=0
 | 
| 35 |   _delay_us(30);                        // 30us delay
 | 
| 36 | 
 | 
| 37 |   dogm_write_check(0, 0x0C);            // DISPLAY ON: D=1, C=0, B=0
 | 
| 38 |   _delay_us(30);                        // 30us delay
 | 
| 39 | 
 | 
| 40 |   dogm_write_check(0, 0x01);            // CLEAR DISPLAY
 | 
| 41 |   _delay_ms(2);                         // 2ms delay
 | 
| 42 | 
 | 
| 43 |   dogm_write_check(0, 0x06);            // Entry mode set: I/D=1, S=0
 | 
| 44 |   _delay_us(30);                        // 30us delay
 | 
| 45 | }
 |