Add .lss files for GCC for current Mac CrossPack
[avr_serial_lcd.git] / gcc_c / serial_lcd.lss
1
2 serial_lcd.elf:     file format elf32-avr
3
4 Sections:
5 Idx Name          Size      VMA       LMA       File off  Algn
6   0 .text         000002aa  00000000  00000000  00000074  2**1
7                   CONTENTS, ALLOC, LOAD, READONLY, CODE
8   1 .noinit       00000030  00800060  00800060  0000031e  2**0
9                   ALLOC
10   2 .stab         0000069c  00000000  00000000  00000320  2**2
11                   CONTENTS, READONLY, DEBUGGING
12   3 .stabstr      00000082  00000000  00000000  000009bc  2**0
13                   CONTENTS, READONLY, DEBUGGING
14   4 .debug_aranges 00000050  00000000  00000000  00000a3e  2**0
15                   CONTENTS, READONLY, DEBUGGING
16   5 .debug_pubnames 0000003a  00000000  00000000  00000a8e  2**0
17                   CONTENTS, READONLY, DEBUGGING
18   6 .debug_info   00000765  00000000  00000000  00000ac8  2**0
19                   CONTENTS, READONLY, DEBUGGING
20   7 .debug_abbrev 0000026d  00000000  00000000  0000122d  2**0
21                   CONTENTS, READONLY, DEBUGGING
22   8 .debug_line   0000068a  00000000  00000000  0000149a  2**0
23                   CONTENTS, READONLY, DEBUGGING
24   9 .debug_frame  00000080  00000000  00000000  00001b24  2**2
25                   CONTENTS, READONLY, DEBUGGING
26  10 .debug_str    00000298  00000000  00000000  00001ba4  2**0
27                   CONTENTS, READONLY, DEBUGGING
28  11 .debug_loc    000001cd  00000000  00000000  00001e3c  2**0
29                   CONTENTS, READONLY, DEBUGGING
30  12 .debug_ranges 000000a8  00000000  00000000  00002009  2**0
31                   CONTENTS, READONLY, DEBUGGING
32
33 Disassembly of section .text:
34
35 00000000 <__vectors>:
36    0:   18 c0           rjmp    .+48            ; 0x32 <__ctors_end>
37    2:   1d c0           rjmp    .+58            ; 0x3e <__bad_interrupt>
38    4:   1c c0           rjmp    .+56            ; 0x3e <__bad_interrupt>
39    6:   1b c0           rjmp    .+54            ; 0x3e <__bad_interrupt>
40    8:   1a c0           rjmp    .+52            ; 0x3e <__bad_interrupt>
41    a:   19 c0           rjmp    .+50            ; 0x3e <__bad_interrupt>
42    c:   18 c0           rjmp    .+48            ; 0x3e <__bad_interrupt>
43    e:   42 c0           rjmp    .+132           ; 0x94 <__vector_7>
44   10:   16 c0           rjmp    .+44            ; 0x3e <__bad_interrupt>
45   12:   15 c0           rjmp    .+42            ; 0x3e <__bad_interrupt>
46   14:   14 c0           rjmp    .+40            ; 0x3e <__bad_interrupt>
47   16:   13 c0           rjmp    .+38            ; 0x3e <__bad_interrupt>
48   18:   12 c0           rjmp    .+36            ; 0x3e <__bad_interrupt>
49   1a:   18 c1           rjmp    .+560           ; 0x24c <__vector_13>
50   1c:   10 c0           rjmp    .+32            ; 0x3e <__bad_interrupt>
51   1e:   0f c0           rjmp    .+30            ; 0x3e <__bad_interrupt>
52   20:   0e c0           rjmp    .+28            ; 0x3e <__bad_interrupt>
53   22:   0d c0           rjmp    .+26            ; 0x3e <__bad_interrupt>
54   24:   0c c0           rjmp    .+24            ; 0x3e <__bad_interrupt>
55
56 00000026 <BaudLookupTable>:
57   26:   07 17 2f 5f                                         ../_
58
59 0000002a <ledPwmPatterns>:
60   2a:   10 11 4a 55 5d ee 7f ff                             ..JU]...
61
62 00000032 <__ctors_end>:
63   32:   11 24           eor     r1, r1
64   34:   1f be           out     0x3f, r1        ; 63
65   36:   cf ed           ldi     r28, 0xDF       ; 223
66   38:   cd bf           out     0x3d, r28       ; 61
67   3a:   5c d0           rcall   .+184           ; 0xf4 <main>
68   3c:   34 c1           rjmp    .+616           ; 0x2a6 <_exit>
69
70 0000003e <__bad_interrupt>:
71   3e:   e0 cf           rjmp    .-64            ; 0x0 <__vectors>
72
73 00000040 <LcdBusyWait>:
74   LCD_CONTROL_PORT &= ~(1<<LCD_E);
75 }
76
77 unsigned char LcdBusyWait (void) {
78   unsigned char LCDStatus;
79   LCD_DATA_DIR = 0x00; // Set LCD data port to inputs
80   40:   17 ba           out     0x17, r1        ; 23
81   LCD_CONTROL_PORT &= ~(1<<LCD_RS); // Set display to "Register mode"
82   42:   95 98           cbi     0x12, 5 ; 18
83   LCD_CONTROL_PORT |= (1<<LCD_RW); // Put the display in the read mode
84   44:   94 9a           sbi     0x12, 4 ; 18
85   NOP();
86   46:   00 00           nop
87   do {
88     wdt_reset();
89   48:   a8 95           wdr
90     LCD_CONTROL_PORT |= (1<<LCD_E);
91   4a:   96 9a           sbi     0x12, 6 ; 18
92   #else
93     #define ENABLE_WAIT() __delay_cycles(4);
94   #endif
95 #elif defined(__GNUC__)
96   static __inline__ void _NOP1 (void) { __asm__ volatile ( "nop    " "\n\t" ); }
97   static __inline__ void _NOP2 (void) { __asm__ volatile ( "rjmp 1f" "\n\t"  "1:" "\n\t" ); }
98   4c:   00 c0           rjmp    .+0             ; 0x4e <LcdBusyWait+0xe>
99     ENABLE_WAIT();
100     LCDStatus = LCD_DATA_PIN_REG;
101   4e:   00 c0           rjmp    .+0             ; 0x50 <LcdBusyWait+0x10>
102   50:   96 b3           in      r25, 0x16       ; 22
103     LCD_CONTROL_PORT &= ~(1<<LCD_E);
104   52:   96 98           cbi     0x12, 6 ; 18
105   } while (LCDStatus & (1<<LCD_BUSY));
106   54:   97 fd           sbrc    r25, 7
107   56:   f8 cf           rjmp    .-16            ; 0x48 <LcdBusyWait+0x8>
108   LCD_CONTROL_PORT &= ~(1<<LCD_RW); // Put display in write mode
109   58:   94 98           cbi     0x12, 4 ; 18
110   LCD_DATA_DIR = 0xFF; // Set LCD data port to outputs
111   5a:   8f ef           ldi     r24, 0xFF       ; 255
112   5c:   87 bb           out     0x17, r24       ; 23
113   return (LCDStatus);
114 }
115   5e:   89 2f           mov     r24, r25
116   60:   08 95           ret
117
118 00000062 <LcdWriteData>:
119   LCD_CONTROL_PORT &= ~(1<<LCD_E);
120   NOP();
121   LCD_CONTROL_PORT |= (1<<LCD_RS); // Set display to "Character mode"
122 }
123
124 void LcdWriteData (unsigned char c) {
125   62:   1f 93           push    r17
126   64:   18 2f           mov     r17, r24
127   LcdBusyWait();
128   66:   ec df           rcall   .-40            ; 0x40 <LcdBusyWait>
129   LCD_CONTROL_PORT |= (1<<LCD_RS); // Set display to "Character Mode"
130   68:   95 9a           sbi     0x12, 5 ; 18
131   LCD_DATA_PORT = c;
132   6a:   18 bb           out     0x18, r17       ; 24
133   NOP();
134   6c:   00 00           nop
135   LCD_CONTROL_PORT |= (1<<LCD_E);
136   6e:   96 9a           sbi     0x12, 6 ; 18
137   70:   00 c0           rjmp    .+0             ; 0x72 <LcdWriteData+0x10>
138   ENABLE_WAIT();
139   LCD_CONTROL_PORT &= ~(1<<LCD_E);
140   72:   00 c0           rjmp    .+0             ; 0x74 <LcdWriteData+0x12>
141   74:   96 98           cbi     0x12, 6 ; 18
142 }
143   76:   1f 91           pop     r17
144   78:   08 95           ret
145
146 0000007a <LcdWriteCmd>:
147     }
148   }
149   MAIN_FUNC_LAST();
150 }
151
152 void LcdWriteCmd (unsigned char Cmd) {
153   7a:   1f 93           push    r17
154   7c:   18 2f           mov     r17, r24
155   LcdBusyWait();
156   7e:   e0 df           rcall   .-64            ; 0x40 <LcdBusyWait>
157   LCD_DATA_PORT = Cmd;  // BusyWait leaves RS low in "Register mode"
158   80:   18 bb           out     0x18, r17       ; 24
159   NOP();
160   82:   00 00           nop
161   LCD_CONTROL_PORT |= (1<<LCD_E);
162   84:   96 9a           sbi     0x12, 6 ; 18
163   86:   00 c0           rjmp    .+0             ; 0x88 <LcdWriteCmd+0xe>
164   ENABLE_WAIT();
165   LCD_CONTROL_PORT &= ~(1<<LCD_E);
166   88:   00 c0           rjmp    .+0             ; 0x8a <LcdWriteCmd+0x10>
167   8a:   96 98           cbi     0x12, 6 ; 18
168   NOP();
169   8c:   00 00           nop
170   LCD_CONTROL_PORT |= (1<<LCD_RS); // Set display to "Character mode"
171   8e:   95 9a           sbi     0x12, 5 ; 18
172 }
173   90:   1f 91           pop     r17
174   92:   08 95           ret
175
176 00000094 <__vector_7>:
177 #pragma interrupt_handler usart_rx_handler:iv_USART0_RXC
178 void usart_rx_handler(void)
179 #else
180 ISR(USART_RX_vect)
181 #endif
182 {
183   94:   1f 92           push    r1
184   96:   0f 92           push    r0
185   98:   0f b6           in      r0, 0x3f        ; 63
186   9a:   0f 92           push    r0
187   9c:   11 24           eor     r1, r1
188   9e:   8f 93           push    r24
189   a0:   ef 93           push    r30
190   a2:   ff 93           push    r31
191   UartStoreRx(UDR);
192   a4:   8c b1           in      r24, 0x0c       ; 12
193
194 INLINE_FUNC_DECLARE(static void UartStoreRx (uint8_t rx));
195 static inline void UartStoreRx (uint8_t rx) {
196   unsigned char tmphead;
197
198   if (UCSRA & (1<<FE)) {
199   a6:   5c 99           sbic    0x0b, 4 ; 11
200   a8:   0d c0           rjmp    .+26            ; 0xc4 <__vector_7+0x30>
201     // some applications may benefit from addind error notification for serial port data overruns
202   }
203 #endif
204
205   // Calculate next buffer position.
206   tmphead = sUartRxHead;
207   aa:   e5 2d           mov     r30, r5
208   if (tmphead == UART_RX_BUFFER_SIZE-1)
209   ac:   ef 32           cpi     r30, 0x2F       ; 47
210   ae:   11 f4           brne    .+4             ; 0xb4 <__vector_7+0x20>
211   b0:   e0 e0           ldi     r30, 0x00       ; 0
212   b2:   01 c0           rjmp    .+2             ; 0xb6 <__vector_7+0x22>
213     tmphead = 0;
214   else
215     tmphead++;
216   b4:   ef 5f           subi    r30, 0xFF       ; 255
217   // store in buffer if there is room
218   if (tmphead != sUartRxTail) {
219   b6:   e6 15           cp      r30, r6
220   b8:   29 f0           breq    .+10            ; 0xc4 <__vector_7+0x30>
221     sUartRxHead = tmphead;         // Store new index.
222   ba:   5e 2e           mov     r5, r30
223     sUartRxBuf[tmphead] = rx;
224   bc:   f0 e0           ldi     r31, 0x00       ; 0
225   be:   e0 5a           subi    r30, 0xA0       ; 160
226   c0:   ff 4f           sbci    r31, 0xFF       ; 255
227   c2:   80 83           st      Z, r24
228 #else
229 ISR(USART_RX_vect)
230 #endif
231 {
232   UartStoreRx(UDR);
233 }
234   c4:   ff 91           pop     r31
235   c6:   ef 91           pop     r30
236   c8:   8f 91           pop     r24
237   ca:   0f 90           pop     r0
238   cc:   0f be           out     0x3f, r0        ; 63
239   ce:   0f 90           pop     r0
240   d0:   1f 90           pop     r1
241   d2:   18 95           reti
242
243 000000d4 <WaitRxChar>:
244
245 static unsigned char WaitRxChar (void) {
246   // waits for next RX character, then return it
247   unsigned char tail;
248   do {
249     tail = sUartRxTail; // explicitly set order of volatile variable access
250   d4:   86 2d           mov     r24, r6
251     wdt_reset();
252   } while (sUartRxHead == tail); // while buffer is empty
253   d6:   95 2d           mov     r25, r5
254 static unsigned char WaitRxChar (void) {
255   // waits for next RX character, then return it
256   unsigned char tail;
257   do {
258     tail = sUartRxTail; // explicitly set order of volatile variable access
259     wdt_reset();
260   d8:   a8 95           wdr
261   } while (sUartRxHead == tail); // while buffer is empty
262   da:   98 17           cp      r25, r24
263   dc:   e9 f3           breq    .-6             ; 0xd8 <WaitRxChar+0x4>
264   // CTS inactive if byte fills buffer after we remove current byte
265   cli();
266 #endif
267
268   // increment tail position
269   if (tail == UART_RX_BUFFER_SIZE-1)
270   de:   8f 32           cpi     r24, 0x2F       ; 47
271   e0:   11 f4           brne    .+4             ; 0xe6 <__stack+0x7>
272     sUartRxTail = 0;
273   e2:   66 24           eor     r6, r6
274   e4:   01 c0           rjmp    .+2             ; 0xe8 <__stack+0x9>
275   else
276     sUartRxTail++;
277   e6:   63 94           inc     r6
278 #if USE_CTS
279   CTS_PORT |= (1<<CTS_PIN); // Ensure CTS is active since just removed a byte
280   sei();   // Allow UART ISR to read character and change potentially change CTS
281 #endif
282
283   return sUartRxBuf[sUartRxTail];
284   e8:   e6 2d           mov     r30, r6
285   ea:   f0 e0           ldi     r31, 0x00       ; 0
286   ec:   e0 5a           subi    r30, 0xA0       ; 160
287   ee:   ff 4f           sbci    r31, 0xFF       ; 255
288   f0:   80 81           ld      r24, Z
289 }
290   f2:   08 95           ret
291
292 000000f4 <main>:
293   LcdWriteCmd (LCD_ON); // Power up the display
294   LcdWriteCmd (LCD_CLR); // Power up the display
295 }
296
297 MAIN_FUNC() {
298   MCUSR = 0; // clear all reset flags
299   f4:   14 be           out     0x34, r1        ; 52
300
301   wdt_reset();
302   f6:   a8 95           wdr
303 #if defined(__CODEVISIONAVR__)
304 #pragma optsize-
305 #endif
306   WDTCSR |= (1<<WDCE)|(1<<WDE); // start timed sequence (keep old prescaler)
307   f8:   81 b5           in      r24, 0x21       ; 33
308   fa:   88 61           ori     r24, 0x18       ; 24
309   fc:   81 bd           out     0x21, r24       ; 33
310   WDTCSR = (1<<WDE)|(1<<WDP3)|(1<<WDP0); // 1024K cycles, 8.0sec
311   fe:   89 e2           ldi     r24, 0x29       ; 41
312  100:   81 bd           out     0x21, r24       ; 33
313 #if defined(__CODEVISIONAVR__) && defined(_OPTIMIZE_SIZE_)
314 #pragma optsize+
315 #endif
316   MCUCR &= ~((1<<SM1)|(1<<SM0)); // use idle sleep mode
317  102:   85 b7           in      r24, 0x35       ; 53
318  104:   8f 7a           andi    r24, 0xAF       ; 175
319  106:   85 bf           out     0x35, r24       ; 53
320
321 INLINE_FUNC_DECLARE(static void LedPwmInit (void));
322 static inline void LedPwmInit (void) {
323   // setup PWM to run at 1.25ms per interrupt.
324   // This allows 8 levels of brightness at minimum of 100Hz flicker rate.
325   TCCR0A = (1<<WGM01);  // CTC mode
326  108:   82 e0           ldi     r24, 0x02       ; 2
327  10a:   80 bf           out     0x30, r24       ; 48
328   TCCR0B = 0;           // timer off
329  10c:   13 be           out     0x33, r1        ; 51
330   OCR0A = 72;           // 1.25ms with CLK/256 prescaler @ 14.7456MHz
331  10e:   88 e4           ldi     r24, 0x48       ; 72
332  110:   86 bf           out     0x36, r24       ; 54
333   TIMSK = (1<<OCIE0A);  // Turn on timer0 COMPA intr (all other timer intr off)
334  112:   81 e0           ldi     r24, 0x01       ; 1
335  114:   89 bf           out     0x39, r24       ; 57
336   LED_PORT &= ~(1<<LED_PIN); // Ensure LED is off during initialization
337  116:   91 98           cbi     0x12, 1 ; 18
338   LED_DIR |= (1<<LED_PIN);   // Ensure LED is output direction
339  118:   89 9a           sbi     0x11, 1 ; 17
340   BACKLIGHT_OFF();       // note that LED is off
341  11a:   a0 98           cbi     0x14, 0 ; 20
342   ledPwmPattern = 0xFF; // maximum brightness
343  11c:   9f ef           ldi     r25, 0xFF       ; 255
344  11e:   93 bb           out     0x13, r25       ; 19
345
346
347 INLINE_FUNC_DECLARE(static void LcdInit (void));
348 static inline void LcdInit (void) {
349   // Set BAUD_J2:BAUD_J1 PULL-UPS active
350   LCD_CONTROL_PORT = (1<<BAUD_J2) | (1<<BAUD_J1);
351  120:   8c e0           ldi     r24, 0x0C       ; 12
352  122:   82 bb           out     0x12, r24       ; 18
353   // Set LCD_control BAUD_J2:BAUD_J1 to inputs
354   LCD_CONTROL_DIR = 0xF2;
355  124:   82 ef           ldi     r24, 0xF2       ; 242
356  126:   81 bb           out     0x11, r24       ; 17
357     milliseconds can be achieved.
358  */
359 void
360 _delay_loop_2(uint16_t __count)
361 {
362         __asm__ volatile (
363  128:   e0 e0           ldi     r30, 0x00       ; 0
364  12a:   f8 ed           ldi     r31, 0xD8       ; 216
365  12c:   31 97           sbiw    r30, 0x01       ; 1
366  12e:   f1 f7           brne    .-4             ; 0x12c <main+0x38>
367
368   _delay_us(15000);
369   LCD_CONTROL_PORT |= (1<<LCD_RS); // Set LCD_RS HIGH
370  130:   95 9a           sbi     0x12, 5 ; 18
371
372   // Initialize the LCD Data AVR I/O
373   LCD_DATA_DIR = 0xFF; // Set LCD_DATA_PORT as all outputs
374  132:   97 bb           out     0x17, r25       ; 23
375   LCD_DATA_PORT = 0x00; // Set LCD_DATA_PORT to logic low
376  134:   18 ba           out     0x18, r1        ; 24
377
378   // Initialize the LCD controller
379   LCD_CONTROL_PORT &= ~(1<<LCD_RS);
380  136:   95 98           cbi     0x12, 5 ; 18
381   LcdWriteData (DATA_8);
382  138:   80 e3           ldi     r24, 0x30       ; 48
383  13a:   93 df           rcall   .-218           ; 0x62 <LcdWriteData>
384  13c:   8a e0           ldi     r24, 0x0A       ; 10
385  13e:   9b e3           ldi     r25, 0x3B       ; 59
386  140:   01 97           sbiw    r24, 0x01       ; 1
387  142:   f1 f7           brne    .-4             ; 0x140 <main+0x4c>
388
389   _delay_us(4100);
390   LcdWriteData (DATA_8);
391  144:   80 e3           ldi     r24, 0x30       ; 48
392  146:   8d df           rcall   .-230           ; 0x62 <LcdWriteData>
393  148:   80 e7           ldi     r24, 0x70       ; 112
394  14a:   91 e0           ldi     r25, 0x01       ; 1
395  14c:   01 97           sbiw    r24, 0x01       ; 1
396  14e:   f1 f7           brne    .-4             ; 0x14c <main+0x58>
397
398   _delay_us(100);
399   LcdWriteData (DATA_8);
400  150:   80 e3           ldi     r24, 0x30       ; 48
401  152:   87 df           rcall   .-242           ; 0x62 <LcdWriteData>
402   LCD_CONTROL_PORT |= (1<<LCD_RS);
403  154:   95 9a           sbi     0x12, 5 ; 18
404
405   // The display will be out into 8 bit data mode here
406   LcdWriteCmd (LCD_8_Bit | LCD_4_Line); // Set 8 bit data, 4 display lines
407  156:   88 e3           ldi     r24, 0x38       ; 56
408  158:   90 df           rcall   .-224           ; 0x7a <LcdWriteCmd>
409   LcdWriteCmd (LCD_ON); // Power up the display
410  15a:   8c e0           ldi     r24, 0x0C       ; 12
411  15c:   8e df           rcall   .-228           ; 0x7a <LcdWriteCmd>
412   LcdWriteCmd (LCD_CLR); // Power up the display
413  15e:   81 e0           ldi     r24, 0x01       ; 1
414  160:   8c df           rcall   .-232           ; 0x7a <LcdWriteCmd>
415
416
417 INLINE_FUNC_DECLARE(static void UsartInit (void));
418 static inline void UsartInit(void) {
419   // Initialize USART
420   UCSRB = 0; // Disable while setting baud rate
421  162:   1a b8           out     0x0a, r1        ; 10
422   UCSRA = 0;
423  164:   1b b8           out     0x0b, r1        ; 11
424   UCSRC = (1<<UCSZ1) | (1<<UCSZ0); // 8 bit data
425  166:   86 e0           ldi     r24, 0x06       ; 6
426  168:   83 b9           out     0x03, r24       ; 3
427 = {BAUD_115200, BAUD_38400, BAUD_19200, BAUD_9600};
428
429 INLINE_FUNC_DECLARE(static unsigned char GetUsartBaud (void));
430 static inline unsigned char GetUsartBaud (void) {
431   // Get BAUD rate jumper settings
432   unsigned char BaudSelectJumpersValue  = BAUD_PIN_REG;
433  16a:   e0 b3           in      r30, 0x10       ; 16
434   // Mask off unwanted bits
435   BaudSelectJumpersValue &= (1<<BAUD_J2) | (1<<BAUD_J1);
436  16c:   ec 70           andi    r30, 0x0C       ; 12
437   // This is two bits too far to the left and the array index will
438   // increment by 4, instead of 1.
439   // Shift BAUD_J2 & BAUD_J1 right by two bit positions for proper array indexing
440   BaudSelectJumpersValue = (BaudSelectJumpersValue >> BAUD_J1);
441
442   return PGM_READ_BYTE (&BaudLookupTable[BaudSelectJumpersValue]);
443  16e:   e6 95           lsr     r30
444  170:   e6 95           lsr     r30
445  172:   f0 e0           ldi     r31, 0x00       ; 0
446  174:   ea 5d           subi    r30, 0xDA       ; 218
447  176:   ff 4f           sbci    r31, 0xFF       ; 255
448  178:   e4 91           lpm     r30, Z+
449 static inline void UsartInit(void) {
450   // Initialize USART
451   UCSRB = 0; // Disable while setting baud rate
452   UCSRA = 0;
453   UCSRC = (1<<UCSZ1) | (1<<UCSZ0); // 8 bit data
454   UBRRL = GetUsartBaud (); // Set baud rate
455  17a:   e9 b9           out     0x09, r30       ; 9
456   UBRRH = 0; // Set baud rate hi
457  17c:   12 b8           out     0x02, r1        ; 2
458   UCSRB = (1<<RXEN)|(1<<RXCIE); // RXEN = Enable
459  17e:   80 e9           ldi     r24, 0x90       ; 144
460  180:   8a b9           out     0x0a, r24       ; 10
461   sUartRxHead = 0; // register variable, need to explicitly zero
462  182:   55 24           eor     r5, r5
463   sUartRxTail = 0; // register variable, need to explicitly zero
464  184:   66 24           eor     r6, r6
465   LcdInit ();
466
467   // Initialize the AVR USART
468   UsartInit ();
469
470   sei();
471  186:   78 94           sei
472   TCCR0B = 0;
473 }
474
475 INLINE_FUNC_DECLARE(static void LedTimerStart (void));
476 static inline void LedTimerStart (void) {
477   TCCR0B = (1<<CS02); // Start with 256 prescaler
478  188:   14 e0           ldi     r17, 0x04       ; 4
479   UsartInit ();
480
481   sei();
482   while (1) {
483     unsigned char tail = sUartRxTail; // explicitly set order of volatile access
484     if (tail != sUartRxHead) { // Check if UART RX buffer has a character
485  18a:   65 14           cp      r6, r5
486  18c:   09 f4           brne    .+2             ; 0x190 <main+0x9c>
487  18e:   41 c0           rjmp    .+130           ; 0x212 <main+0x11e>
488       unsigned char rx_byte = WaitRxChar();
489  190:   a1 df           rcall   .-190           ; 0xd4 <WaitRxChar>
490
491       // avoid use of switch statement as ImageCraft and GCC produce signifcantly
492       // more code for a switch statement than a sequence of if/else if
493       if (rx_byte == LED_SW_OFF) {
494  192:   8d 3f           cpi     r24, 0xFD       ; 253
495  194:   21 f4           brne    .+8             ; 0x19e <main+0xaa>
496   }
497 }
498
499 INLINE_FUNC_DECLARE(static void LedPwmSwitchOff (void));
500 static inline void LedPwmSwitchOff (void) {
501   LED_PORT &= ~(1<<LED_PIN);
502  196:   91 98           cbi     0x12, 1 ; 18
503   BACKLIGHT_OFF();
504  198:   a0 98           cbi     0x14, 0 ; 20
505
506 #else
507 // Using a platform that has proper inline functions
508 INLINE_FUNC_DECLARE(static void LedTimerStop (void));
509 static inline void LedTimerStop (void) {
510   TCCR0B = 0;
511  19a:   13 be           out     0x33, r1        ; 51
512  19c:   f6 cf           rjmp    .-20            ; 0x18a <main+0x96>
513
514       // avoid use of switch statement as ImageCraft and GCC produce signifcantly
515       // more code for a switch statement than a sequence of if/else if
516       if (rx_byte == LED_SW_OFF) {
517         LedPwmSwitchOff();
518       } else if (rx_byte == LED_SW_ON) {
519  19e:   8c 3f           cpi     r24, 0xFC       ; 252
520  1a0:   29 f4           brne    .+10            ; 0x1ac <main+0xb8>
521   LedTimerStop();
522 }
523
524 INLINE_FUNC_DECLARE(static void LedPwmSwitchOn (void));
525 static inline void LedPwmSwitchOn (void) {
526   BACKLIGHT_ON();
527  1a2:   a0 9a           sbi     0x14, 0 ; 20
528   if (ledPwmPattern == 0xFF) { // maximum brightness, no need for PWM
529  1a4:   83 b3           in      r24, 0x13       ; 19
530  1a6:   8f 3f           cpi     r24, 0xFF       ; 255
531  1a8:   59 f5           brne    .+86            ; 0x200 <main+0x10c>
532  1aa:   25 c0           rjmp    .+74            ; 0x1f6 <main+0x102>
533       // more code for a switch statement than a sequence of if/else if
534       if (rx_byte == LED_SW_OFF) {
535         LedPwmSwitchOff();
536       } else if (rx_byte == LED_SW_ON) {
537         LedPwmSwitchOn();
538       } else if (rx_byte == LED_SET_BRIGHTNESS) {
539  1ac:   8b 3f           cpi     r24, 0xFB       ; 251
540  1ae:   51 f5           brne    .+84            ; 0x204 <main+0x110>
541         rx_byte = WaitRxChar();  // read next byte which will be brightness
542  1b0:   91 df           rcall   .-222           ; 0xd4 <WaitRxChar>
543
544 INLINE_FUNC_DECLARE(static void LedPwmSetBrightness (unsigned char brightness));
545 static inline void LedPwmSetBrightness (unsigned char brightness) {
546   unsigned char ledPwmPos;
547
548   if (brightness == 0) { // turn backlight off for 0 brightness
549  1b2:   88 23           and     r24, r24
550  1b4:   39 f4           brne    .+14            ; 0x1c4 <main+0xd0>
551     if (IS_BACKLIGHT_ON()) {
552  1b6:   a0 9b           sbis    0x14, 0 ; 20
553  1b8:   e8 cf           rjmp    .-48            ; 0x18a <main+0x96>
554
555 #else
556 // Using a platform that has proper inline functions
557 INLINE_FUNC_DECLARE(static void LedTimerStop (void));
558 static inline void LedTimerStop (void) {
559   TCCR0B = 0;
560  1ba:   13 be           out     0x33, r1        ; 51
561   unsigned char ledPwmPos;
562
563   if (brightness == 0) { // turn backlight off for 0 brightness
564     if (IS_BACKLIGHT_ON()) {
565       LedTimerStop();
566       ledPwmPattern = 0;
567  1bc:   13 ba           out     0x13, r1        ; 19
568       ledPwmCycling = 0;
569  1be:   77 24           eor     r7, r7
570       LED_PORT &= ~(1<<LED_PIN);
571  1c0:   91 98           cbi     0x12, 1 ; 18
572  1c2:   e3 cf           rjmp    .-58            ; 0x18a <main+0x96>
573     }
574     return;
575   }
576
577   ledPwmPos = (brightness * (LED_BRIGHTNESS_LEVELS-1) + (unsigned int) 127) >> 8;
578  1c4:   90 e0           ldi     r25, 0x00       ; 0
579  1c6:   67 e0           ldi     r22, 0x07       ; 7
580  1c8:   70 e0           ldi     r23, 0x00       ; 0
581  1ca:   5b d0           rcall   .+182           ; 0x282 <__mulhi3>
582  1cc:   81 58           subi    r24, 0x81       ; 129
583  1ce:   9f 4f           sbci    r25, 0xFF       ; 255
584  1d0:   89 2f           mov     r24, r25
585  1d2:   99 27           eor     r25, r25
586  1d4:   98 2f           mov     r25, r24
587  1d6:   88 30           cpi     r24, 0x08       ; 8
588  1d8:   08 f0           brcs    .+2             ; 0x1dc <main+0xe8>
589  1da:   97 e0           ldi     r25, 0x07       ; 7
590   // Below is probably not required, but ensures we don't exceed array
591   if (ledPwmPos > LED_BRIGHTNESS_LEVELS - 1)
592     ledPwmPos = LED_BRIGHTNESS_LEVELS - 1;
593
594   ledPwmPattern = PGM_READ_BYTE (&ledPwmPatterns[ledPwmPos]);
595  1dc:   e9 2f           mov     r30, r25
596  1de:   f0 e0           ldi     r31, 0x00       ; 0
597  1e0:   e6 5d           subi    r30, 0xD6       ; 214
598  1e2:   ff 4f           sbci    r31, 0xFF       ; 255
599  1e4:   e4 91           lpm     r30, Z+
600  1e6:   e3 bb           out     0x13, r30       ; 19
601   ledPwmCount = 0;
602  1e8:   44 24           eor     r4, r4
603   ledPwmCycling = ledPwmPattern;
604  1ea:   83 b3           in      r24, 0x13       ; 19
605  1ec:   78 2e           mov     r7, r24
606   if (ledPwmPos >= LED_BRIGHTNESS_LEVELS-1) { // maximum brightness
607  1ee:   97 30           cpi     r25, 0x07       ; 7
608  1f0:   29 f4           brne    .+10            ; 0x1fc <main+0x108>
609     // don't need PWM for continuously on
610     if (IS_BACKLIGHT_ON()) {
611  1f2:   a0 9b           sbis    0x14, 0 ; 20
612  1f4:   ca cf           rjmp    .-108           ; 0x18a <main+0x96>
613
614 #else
615 // Using a platform that has proper inline functions
616 INLINE_FUNC_DECLARE(static void LedTimerStop (void));
617 static inline void LedTimerStop (void) {
618   TCCR0B = 0;
619  1f6:   13 be           out     0x33, r1        ; 51
620   ledPwmCycling = ledPwmPattern;
621   if (ledPwmPos >= LED_BRIGHTNESS_LEVELS-1) { // maximum brightness
622     // don't need PWM for continuously on
623     if (IS_BACKLIGHT_ON()) {
624       LedTimerStop();
625       LED_PORT |= (1<<LED_PIN);
626  1f8:   91 9a           sbi     0x12, 1 ; 18
627  1fa:   c7 cf           rjmp    .-114           ; 0x18a <main+0x96>
628     }
629   } else {
630     if (IS_BACKLIGHT_ON()) {
631  1fc:   a0 9b           sbis    0x14, 0 ; 20
632  1fe:   c5 cf           rjmp    .-118           ; 0x18a <main+0x96>
633   TCCR0B = 0;
634 }
635
636 INLINE_FUNC_DECLARE(static void LedTimerStart (void));
637 static inline void LedTimerStart (void) {
638   TCCR0B = (1<<CS02); // Start with 256 prescaler
639  200:   13 bf           out     0x33, r17       ; 51
640  202:   c3 cf           rjmp    .-122           ; 0x18a <main+0x96>
641       } else if (rx_byte == LED_SW_ON) {
642         LedPwmSwitchOn();
643       } else if (rx_byte == LED_SET_BRIGHTNESS) {
644         rx_byte = WaitRxChar();  // read next byte which will be brightness
645         LedPwmSetBrightness(rx_byte);
646       } else if (rx_byte == REG_MODE) {
647  204:   8e 3f           cpi     r24, 0xFE       ; 254
648  206:   19 f4           brne    .+6             ; 0x20e <main+0x11a>
649         LcdWriteCmd (WaitRxChar()); // Send LCD command character
650  208:   65 df           rcall   .-310           ; 0xd4 <WaitRxChar>
651  20a:   37 df           rcall   .-402           ; 0x7a <LcdWriteCmd>
652  20c:   be cf           rjmp    .-132           ; 0x18a <main+0x96>
653       } else {
654         LcdWriteData (rx_byte); // Send LCD data character
655  20e:   29 df           rcall   .-430           ; 0x62 <LcdWriteData>
656  210:   bc cf           rjmp    .-136           ; 0x18a <main+0x96>
657       }
658     } else {
659       // No characters waiting in RX buffer
660
661       cli();
662  212:   f8 94           cli
663       wdt_reset();
664  214:   a8 95           wdr
665       MCUSR &= ~(1<<WDRF); // clear any watchdog interrupt flags
666  216:   84 b7           in      r24, 0x34       ; 52
667  218:   87 7f           andi    r24, 0xF7       ; 247
668  21a:   84 bf           out     0x34, r24       ; 52
669
670 #if defined(__CODEVISIONAVR__)
671 #pragma optsize-
672 #endif
673       WDTCSR |= (1<<WDCE)|(1<<WDE); // start timed sequence (keep old prescaler)
674  21c:   81 b5           in      r24, 0x21       ; 33
675  21e:   88 61           ori     r24, 0x18       ; 24
676  220:   81 bd           out     0x21, r24       ; 33
677       WDTCSR &= ~(1<<WDE); // watchdog timer off
678  222:   81 b5           in      r24, 0x21       ; 33
679  224:   87 7f           andi    r24, 0xF7       ; 247
680  226:   81 bd           out     0x21, r24       ; 33
681 #if defined(__CODEVISIONAVR__) && defined(_OPTIMIZE_SIZE_)
682 #pragma optsize+
683 #endif
684
685       sei();
686  228:   78 94           sei
687
688       sleep_enable();
689  22a:   85 b7           in      r24, 0x35       ; 53
690  22c:   80 62           ori     r24, 0x20       ; 32
691  22e:   85 bf           out     0x35, r24       ; 53
692       sleep_cpu();
693  230:   88 95           sleep
694       sleep_disable();
695  232:   85 b7           in      r24, 0x35       ; 53
696  234:   8f 7d           andi    r24, 0xDF       ; 223
697  236:   85 bf           out     0x35, r24       ; 53
698
699       cli();
700  238:   f8 94           cli
701       wdt_reset();
702  23a:   a8 95           wdr
703
704 #if defined(__CODEVISIONAVR__)
705 #pragma optsize-
706 #endif
707       WDTCSR |= (1<<WDCE)|(1<<WDE); // start timed sequence (keep old prescaler)
708  23c:   81 b5           in      r24, 0x21       ; 33
709  23e:   88 61           ori     r24, 0x18       ; 24
710  240:   81 bd           out     0x21, r24       ; 33
711       WDTCSR &= ~(1<<WDCE);
712  242:   81 b5           in      r24, 0x21       ; 33
713  244:   8f 7e           andi    r24, 0xEF       ; 239
714  246:   81 bd           out     0x21, r24       ; 33
715 #if defined(__CODEVISIONAVR__) && defined(_OPTIMIZE_SIZE_)
716 #pragma optsize+
717 #endif
718
719       sei();
720  248:   78 94           sei
721  24a:   9f cf           rjmp    .-194           ; 0x18a <main+0x96>
722
723 0000024c <__vector_13>:
724 #pragma interrupt_handler timer0_compa_handler:iv_TIMER0_COMPA
725 void timer0_compa_handler(void)
726 #else
727   ISR(TIMER0_COMPA_vect)
728 #endif
729 {
730  24c:   1f 92           push    r1
731  24e:   0f 92           push    r0
732  250:   0f b6           in      r0, 0x3f        ; 63
733  252:   0f 92           push    r0
734  254:   11 24           eor     r1, r1
735  256:   8f 93           push    r24
736   sei(); // Okay to allow USART interrupts while controlling LED PWM
737  258:   78 94           sei
738
739   // Set current LED state based on cycling variable
740   if (ledPwmCycling & 0x01) {
741  25a:   70 fe           sbrs    r7, 0
742  25c:   02 c0           rjmp    .+4             ; 0x262 <__vector_13+0x16>
743     LED_PORT |= (1<<LED_PIN);
744  25e:   91 9a           sbi     0x12, 1 ; 18
745  260:   01 c0           rjmp    .+2             ; 0x264 <__vector_13+0x18>
746   } else {
747     LED_PORT &= ~(1<<LED_PIN);
748  262:   91 98           cbi     0x12, 1 ; 18
749   }
750
751   // Update cycling variable for next interrupt
752   if (ledPwmCount >= LED_BRIGHTNESS_LEVELS-1) {
753  264:   86 e0           ldi     r24, 0x06       ; 6
754  266:   84 15           cp      r24, r4
755  268:   20 f4           brcc    .+8             ; 0x272 <__vector_13+0x26>
756     ledPwmCount = 0;
757  26a:   44 24           eor     r4, r4
758     ledPwmCycling = ledPwmPattern;
759  26c:   83 b3           in      r24, 0x13       ; 19
760  26e:   78 2e           mov     r7, r24
761  270:   02 c0           rjmp    .+4             ; 0x276 <__vector_13+0x2a>
762   } else {
763     ledPwmCount++;
764  272:   43 94           inc     r4
765     ledPwmCycling >>= 1;
766  274:   76 94           lsr     r7
767   }
768 }
769  276:   8f 91           pop     r24
770  278:   0f 90           pop     r0
771  27a:   0f be           out     0x3f, r0        ; 63
772  27c:   0f 90           pop     r0
773  27e:   1f 90           pop     r1
774  280:   18 95           reti
775
776 00000282 <__mulhi3>:
777  282:   55 27           eor     r21, r21
778  284:   00 24           eor     r0, r0
779
780 00000286 <__mulhi3_loop>:
781  286:   80 ff           sbrs    r24, 0
782  288:   02 c0           rjmp    .+4             ; 0x28e <__mulhi3_skip1>
783  28a:   06 0e           add     r0, r22
784  28c:   57 1f           adc     r21, r23
785
786 0000028e <__mulhi3_skip1>:
787  28e:   66 0f           add     r22, r22
788  290:   77 1f           adc     r23, r23
789  292:   61 15           cp      r22, r1
790  294:   71 05           cpc     r23, r1
791  296:   21 f0           breq    .+8             ; 0x2a0 <__mulhi3_exit>
792  298:   96 95           lsr     r25
793  29a:   87 95           ror     r24
794  29c:   00 97           sbiw    r24, 0x00       ; 0
795  29e:   99 f7           brne    .-26            ; 0x286 <__mulhi3_loop>
796
797 000002a0 <__mulhi3_exit>:
798  2a0:   95 2f           mov     r25, r21
799  2a2:   80 2d           mov     r24, r0
800  2a4:   08 95           ret
801
802 000002a6 <_exit>:
803  2a6:   f8 94           cli
804
805 000002a8 <__stop_program>:
806  2a8:   ff cf           rjmp    .-2             ; 0x2a8 <__stop_program>