1.1 --- a/examples/vga-timer/main.c Tue Oct 23 22:14:20 2018 +0200
1.2 +++ b/examples/vga-timer/main.c Tue Oct 23 23:25:47 2018 +0200
1.3 @@ -28,6 +28,7 @@
1.4 #include "devconfig.h"
1.5 #include "vga.h"
1.6 #include "display.h"
1.7 +#include "display_config.h"
1.8
1.9
1.10
1.11 @@ -38,12 +39,11 @@
1.12
1.13 /* Pointers to pixel lines. */
1.14
1.15 -static uint8_t *linedata, *linedatalimit, *screenstart;
1.16 +static uint8_t *linedata;
1.17
1.18 /* Pixel data. */
1.19
1.20 static const uint8_t zerodata[ZERO_LENGTH] = {0};
1.21 -static uint8_t framebuffer[SCREEN_SIZE];
1.22
1.23
1.24
1.25 @@ -77,12 +77,7 @@
1.26 {
1.27 line = 0;
1.28 state_handler = vbp_active;
1.29 - test_linedata(framebuffer);
1.30 -
1.31 - /* Initialise the current display line pointer and display limit. */
1.32 -
1.33 - linedatalimit = framebuffer + SCREEN_SIZE;
1.34 - screenstart = framebuffer;
1.35 + test_linedata(&display_config);
1.36
1.37 init_memory();
1.38 init_pins();
1.39 @@ -124,7 +119,8 @@
1.40 dma_init(0, 3);
1.41 dma_set_chaining(0, dma_chain_next);
1.42 dma_set_interrupt(0, T3, 1);
1.43 - dma_set_transfer(0, PHYSICAL((uint32_t) screenstart), LINE_LENGTH / 2,
1.44 + dma_set_transfer(0, PHYSICAL((uint32_t) display_config.screen_start),
1.45 + display_config.line_length / 2,
1.46 HW_PHYSICAL(PORTB), 1,
1.47 TRANSFER_CELL_SIZE);
1.48
1.49 @@ -134,7 +130,9 @@
1.50 dma_init(2, 3);
1.51 dma_set_chaining(2, dma_chain_previous);
1.52 dma_set_interrupt(2, T3, 1);
1.53 - dma_set_transfer(2, PHYSICAL((uint32_t) screenstart + LINE_LENGTH / 2), LINE_LENGTH / 2,
1.54 + dma_set_transfer(2, PHYSICAL((uint32_t) display_config.screen_start +
1.55 + display_config.line_length / 2),
1.56 + display_config.line_length / 2,
1.57 HW_PHYSICAL(PORTB), 1,
1.58 TRANSFER_CELL_SIZE);
1.59
1.60 @@ -229,9 +227,10 @@
1.61
1.62 /* Set the line address. */
1.63
1.64 - linedata = screenstart;
1.65 - dma_set_source(0, PHYSICAL((uint32_t) linedata), LINE_LENGTH / 2);
1.66 - dma_set_source(2, PHYSICAL((uint32_t) linedata + LINE_LENGTH / 2), LINE_LENGTH / 2);
1.67 + linedata = display_config.screen_start;
1.68 + dma_set_source(0, PHYSICAL((uint32_t) linedata), display_config.line_length / 2);
1.69 + dma_set_source(2, PHYSICAL((uint32_t) linedata + display_config.line_length / 2),
1.70 + display_config.line_length / 2);
1.71
1.72 /* Enable the channels for the next line. */
1.73
1.74 @@ -248,15 +247,16 @@
1.75 {
1.76 /* Update the line address and handle wraparound. */
1.77
1.78 - if (!(line % LINE_MULTIPLIER))
1.79 + if (!(line % display_config.line_multiplier))
1.80 {
1.81 - linedata += LINE_LENGTH;
1.82 - if (linedata >= linedatalimit)
1.83 - linedata -= SCREEN_SIZE;
1.84 + linedata += display_config.line_length;
1.85 + if (linedata >= display_config.screen_limit)
1.86 + linedata -= display_config.screen_size;
1.87 }
1.88
1.89 - dma_set_source(0, PHYSICAL((uint32_t) linedata), LINE_LENGTH / 2);
1.90 - dma_set_source(2, PHYSICAL((uint32_t) linedata + LINE_LENGTH / 2), LINE_LENGTH / 2);
1.91 + dma_set_source(0, PHYSICAL((uint32_t) linedata), display_config.line_length / 2);
1.92 + dma_set_source(2, PHYSICAL((uint32_t) linedata + display_config.line_length / 2),
1.93 + display_config.line_length / 2);
1.94 return;
1.95 }
1.96