36 #ifndef _SSD1306_VGA_ATMEGA328P_ISR_H_ 37 #define _SSD1306_VGA_ATMEGA328P_ISR_H_ 47 #if defined(CONFIG_VGA_AVAILABLE) && defined(CONFIG_VGA_ENABLE) && defined(__AVR_ATmega328P__) 49 #ifndef DEJITTER_OFFSET 50 #define DEJITTER_OFFSET -4 53 #if defined(CONFIG_VGA_128X64_ENABLE) 55 static const uint16_t __VGA_VERTICAL_PIXELS = 64;
56 static const uint16_t __VGA_LINE_BYTES = 16;
57 static const uint16_t __VGA_PIXEL_HEIGHT = 7;
58 volatile uint8_t __vga_buffer[16*64] = {0};
59 static const volatile uint8_t *__VGA_BUFFER_PTR = &__vga_buffer[0];
61 void ssd1306_vga_controller_128x64_init_no_output(
void);
62 void ssd1306_vga_controller_128x64_init_enable_output(
void);
63 void ssd1306_vga_controller_128x64_init_enable_output_no_jitter_fix(
void);
64 void ssd1306_debug_print_vga_buffer_128x64(
void (*func)(uint8_t));
66 #elif defined(CONFIG_VGA_96X40_ENABLE) 68 static const uint16_t __VGA_VERTICAL_PIXELS = 40;
69 static const uint16_t __VGA_LINE_BYTES = 36;
70 static const uint16_t __VGA_PIXEL_HEIGHT = 10;
71 volatile uint8_t __vga_buffer[36*40] = {0};
72 static const volatile uint8_t * __VGA_BUFFER_PTR = &__vga_buffer[0];
74 void ssd1306_vga_controller_96x40_init_no_output(
void);
75 void ssd1306_vga_controller_96x40_init_enable_output(
void);
76 void ssd1306_vga_controller_96x40_init_enable_output_no_jitter_fix(
void);
77 void ssd1306_debug_print_vga_buffer_96x40(
void (*func)(uint8_t));
80 #error "Please, define one of VGA options" 83 #if !defined(VGA_CONTROLLER_DEBUG) 86 static const uint16_t VGA_TOTAL_MODE_LINES = __VGA_VERTICAL_PIXELS*__VGA_PIXEL_HEIGHT;
90 static const uint8_t V_BACKPORCH_LINES = 40;
94 volatile int s_current_scan_line;
96 volatile uint8_t s_lines_to_skip;
97 volatile uint8_t s_scan_line_index;
98 volatile const uint8_t *
volatile s_current_scan_line_data = __VGA_BUFFER_PTR;
99 extern volatile uint8_t s_vga_frames;
100 extern unsigned long timer0_millis;
104 s_current_scan_line = 0;
105 s_scan_line_index = 0;
106 s_current_scan_line_data = __VGA_BUFFER_PTR;
107 s_lines_to_skip = V_BACKPORCH_LINES;
112 #if defined(CONFIG_VGA_128X64_ENABLE) 113 static inline void do_scan_line()
121 "out %[port], r24\n\t" 124 "out %[port], r24\n\t" 126 "out %[port], r24\n\t" 129 "out %[port], r24\n\t" 132 "out %[port], r24\n\t" 135 "out %[port], r24\n\t" 138 "out %[port], r24\n\t" 141 "out %[port], r24\n\t" 146 "out %[port], r24 \n\t" 149 : [port]
"I" (_SFR_IO_ADDR(PORTC)),
150 "z" "I" ((uint8_t *)s_current_scan_line_data )
154 #elif defined(CONFIG_VGA_96X40_ENABLE) 155 static inline void do_scan_line()
164 "out %[port], r24\n\t" 168 "out %[port], r24\n\t" 172 "out %[port], r25\n\t" 177 "out %[port], r25\n\t" 182 "out %[port], r20\n\t" 187 "out %[port], r20\n\t" 192 "out %[port], r24\n\t" 197 "out %[port], r24\n\t" 203 "out %[port], r24 \n\t" 206 : [port]
"I" (_SFR_IO_ADDR(PORTC)),
207 "z" "I" ((uint8_t *)s_current_scan_line_data )
208 :
"r24",
"r25",
"r20",
"memory" 216 ISR(TIMER2_COMPB_vect)
225 else if (s_current_scan_line >= VGA_TOTAL_MODE_LINES)
229 #ifndef SSD1306_VGA_SLEEP_MODE 232 " lds r24, %[timer0] \n\t" 233 " subi r24, %[toffset] \n\t" 235 " ldi r31, pm_hi8(LW) \n\t" 236 " ldi r30, pm_lo8(LW) \n\t" 238 " adc r31, __zero_reg__ \n\t" 249 : [timer0]
"i" (&TCNT0),
250 [toffset]
"i" ((uint8_t)DEJITTER_OFFSET)
251 :
"r30",
"r31",
"r24",
"r25");
254 s_current_scan_line++;
256 if ( s_scan_line_index >= __VGA_PIXEL_HEIGHT )
259 s_current_scan_line_data += __VGA_LINE_BYTES;
263 #endif // VGA_CONTROLLER_DEBUG 265 #if defined(CONFIG_VGA_128X64_ENABLE) 267 static inline void ssd1306_vga_controller_init(
void)
270 #if defined(VGA_CONTROLLER_DEBUG) 271 ssd1306_vga_controller_128x64_init_no_output();
272 #elif defined(SSD1306_VGA_SLEEP_MODE) 273 ssd1306_vga_controller_128x64_init_enable_output_no_jitter_fix();
275 ssd1306_vga_controller_128x64_init_enable_output();
281 ssd1306_debug_print_vga_buffer_128x64(func);
284 #elif defined(CONFIG_VGA_96X40_ENABLE) 286 static inline void ssd1306_vga_controller_init(
void)
289 #if defined(VGA_CONTROLLER_DEBUG) 290 ssd1306_vga_controller_96x40_init_no_output();
291 #elif defined(SSD1306_VGA_SLEEP_MODE) 292 ssd1306_vga_controller_96x40_init_enable_output_no_jitter_fix();
294 ssd1306_vga_controller_96x40_init_enable_output();
300 ssd1306_debug_print_vga_buffer_96x40(func);
303 #endif // CONFIG_VGA_XXX_ENABLE 305 #endif // SSD1306_BUILTIN_VGA_SUPPORT
void ssd1306_debug_print_vga_buffer(void(*func)(uint8_t))