1.1 --- a/examples/vga-dual/main.c Tue Oct 23 22:14:20 2018 +0200
1.2 +++ b/examples/vga-dual/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 @@ -105,14 +100,17 @@
1.40 dma_init(0, 3);
1.41 dma_set_auto_enable(0, 1);
1.42 dma_set_interrupt(0, T2, 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 dma_init(1, 3);
1.50 dma_set_auto_enable(1, 1);
1.51 dma_set_interrupt(1, T2, 1);
1.52 - dma_set_transfer(1, PHYSICAL((uint32_t) screenstart + LINE_LENGTH / 2), LINE_LENGTH / 2,
1.53 + dma_set_transfer(1, PHYSICAL((uint32_t) display_config.screen_start +
1.54 + display_config.line_length / 2),
1.55 + display_config.line_length / 2,
1.56 HW_PHYSICAL(PORTB), 1,
1.57 TRANSFER_CELL_SIZE);
1.58
1.59 @@ -202,9 +200,10 @@
1.60
1.61 /* Set the line address. */
1.62
1.63 - linedata = screenstart;
1.64 - dma_set_source(0, PHYSICAL((uint32_t) linedata), LINE_LENGTH / 2);
1.65 - dma_set_source(1, PHYSICAL((uint32_t) linedata + LINE_LENGTH / 2), LINE_LENGTH / 2);
1.66 + linedata = display_config.screen_start;
1.67 + dma_set_source(0, PHYSICAL((uint32_t) linedata), display_config.line_length / 2);
1.68 + dma_set_source(1, PHYSICAL((uint32_t) linedata + display_config.line_length / 2),
1.69 + display_config.line_length / 2);
1.70
1.71 /* Enable the channels for the next line. */
1.72
1.73 @@ -222,15 +221,16 @@
1.74 {
1.75 /* Update the line address and handle wraparound. */
1.76
1.77 - if (!(line % LINE_MULTIPLIER))
1.78 + if (!(line % display_config.line_multiplier))
1.79 {
1.80 - linedata += LINE_LENGTH;
1.81 - if (linedata >= linedatalimit)
1.82 - linedata -= SCREEN_SIZE;
1.83 + linedata += display_config.line_length;
1.84 + if (linedata >= display_config.screen_limit)
1.85 + linedata -= display_config.screen_size;
1.86 }
1.87
1.88 - dma_set_source(0, PHYSICAL((uint32_t) linedata), LINE_LENGTH / 2);
1.89 - dma_set_source(1, PHYSICAL((uint32_t) linedata + LINE_LENGTH / 2), LINE_LENGTH / 2);
1.90 + dma_set_source(0, PHYSICAL((uint32_t) linedata), display_config.line_length / 2);
1.91 + dma_set_source(1, PHYSICAL((uint32_t) linedata + display_config.line_length / 2),
1.92 + display_config.line_length / 2);
1.93 return;
1.94 }
1.95