1.1 --- a/examples/vga-dual/main.c Wed Oct 24 15:31:56 2018 +0200
1.2 +++ b/examples/vga-dual/main.c Wed Oct 24 15:46:42 2018 +0200
1.3 @@ -67,8 +67,7 @@
1.4
1.5 void main(void)
1.6 {
1.7 - init_vga(&display_config, start_visible, update_visible, stop_visible,
1.8 - vsync_high, vsync_low);
1.9 + init_vga(&display_config, start_visible, update_visible, stop_visible);
1.10
1.11 test_linedata(&display_config);
1.12
1.13 @@ -189,24 +188,6 @@
1.14 dma_off(1);
1.15 }
1.16
1.17 -/* Bring vsync low (single compare, output driven low) when the next line
1.18 - starts. */
1.19 -
1.20 -void vsync_low(void)
1.21 -{
1.22 - oc_init(2, 0b010, 2);
1.23 - oc_on(2);
1.24 -}
1.25 -
1.26 -/* Bring vsync high (single compare, output driven high) when the next line
1.27 - starts. */
1.28 -
1.29 -void vsync_high(void)
1.30 -{
1.31 - oc_init(2, 0b001, 2);
1.32 - oc_on(2);
1.33 -}
1.34 -
1.35
1.36
1.37 /* Peripheral pin configuration. */
2.1 --- a/examples/vga-dual/main.h Wed Oct 24 15:31:56 2018 +0200
2.2 +++ b/examples/vga-dual/main.h Wed Oct 24 15:46:42 2018 +0200
2.3 @@ -33,9 +33,4 @@
2.4 void update_visible(vga_display_t *vga_display);
2.5 void stop_visible(vga_display_t *vga_display);
2.6
2.7 -/* Vertical sync operations. */
2.8 -
2.9 -void vsync_high(void);
2.10 -void vsync_low(void);
2.11 -
2.12 #endif /* __MAIN_H__ */
3.1 --- a/examples/vga-pmp/main.c Wed Oct 24 15:31:56 2018 +0200
3.2 +++ b/examples/vga-pmp/main.c Wed Oct 24 15:46:42 2018 +0200
3.3 @@ -67,8 +67,7 @@
3.4
3.5 void main(void)
3.6 {
3.7 - init_vga(&display_config, start_visible, update_visible, stop_visible,
3.8 - vsync_high, vsync_low);
3.9 + init_vga(&display_config, start_visible, update_visible, stop_visible);
3.10
3.11 test_linedata(&display_config);
3.12
3.13 @@ -178,24 +177,6 @@
3.14 dma_off(0);
3.15 }
3.16
3.17 -/* Bring vsync low (single compare, output driven low) when the next line
3.18 - starts. */
3.19 -
3.20 -void vsync_low(void)
3.21 -{
3.22 - oc_init(2, 0b010, 2);
3.23 - oc_on(2);
3.24 -}
3.25 -
3.26 -/* Bring vsync high (single compare, output driven high) when the next line
3.27 - starts. */
3.28 -
3.29 -void vsync_high(void)
3.30 -{
3.31 - oc_init(2, 0b001, 2);
3.32 - oc_on(2);
3.33 -}
3.34 -
3.35
3.36
3.37 /* Peripheral pin configuration. */
4.1 --- a/examples/vga-pmp/main.h Wed Oct 24 15:31:56 2018 +0200
4.2 +++ b/examples/vga-pmp/main.h Wed Oct 24 15:46:42 2018 +0200
4.3 @@ -33,9 +33,4 @@
4.4 void update_visible(vga_display_t *vga_display);
4.5 void stop_visible(vga_display_t *vga_display);
4.6
4.7 -/* Vertical sync operations. */
4.8 -
4.9 -void vsync_high(void);
4.10 -void vsync_low(void);
4.11 -
4.12 #endif /* __MAIN_H__ */
5.1 --- a/examples/vga-timer/main.c Wed Oct 24 15:31:56 2018 +0200
5.2 +++ b/examples/vga-timer/main.c Wed Oct 24 15:46:42 2018 +0200
5.3 @@ -67,8 +67,7 @@
5.4
5.5 void main(void)
5.6 {
5.7 - init_vga(&display_config, start_visible, update_visible, stop_visible,
5.8 - vsync_high, vsync_low);
5.9 + init_vga(&display_config, start_visible, update_visible, stop_visible);
5.10
5.11 test_linedata(&display_config);
5.12
5.13 @@ -214,24 +213,6 @@
5.14 dma_off(1);
5.15 }
5.16
5.17 -/* Bring vsync low (single compare, output driven low) when the next line
5.18 - starts. */
5.19 -
5.20 -void vsync_low(void)
5.21 -{
5.22 - oc_init(2, 0b010, 2);
5.23 - oc_on(2);
5.24 -}
5.25 -
5.26 -/* Bring vsync high (single compare, output driven high) when the next line
5.27 - starts. */
5.28 -
5.29 -void vsync_high(void)
5.30 -{
5.31 - oc_init(2, 0b001, 2);
5.32 - oc_on(2);
5.33 -}
5.34 -
5.35
5.36
5.37 /* Peripheral pin configuration. */
6.1 --- a/examples/vga-timer/main.h Wed Oct 24 15:31:56 2018 +0200
6.2 +++ b/examples/vga-timer/main.h Wed Oct 24 15:46:42 2018 +0200
6.3 @@ -33,9 +33,4 @@
6.4 void update_visible(vga_display_t *vga_display);
6.5 void stop_visible(vga_display_t *vga_display);
6.6
6.7 -/* Vertical sync operations. */
6.8 -
6.9 -void vsync_high(void);
6.10 -void vsync_low(void);
6.11 -
6.12 #endif /* __MAIN_H__ */
7.1 --- a/examples/vga/main.c Wed Oct 24 15:31:56 2018 +0200
7.2 +++ b/examples/vga/main.c Wed Oct 24 15:46:42 2018 +0200
7.3 @@ -67,8 +67,7 @@
7.4
7.5 void main(void)
7.6 {
7.7 - init_vga(&display_config, start_visible, update_visible, stop_visible,
7.8 - vsync_high, vsync_low);
7.9 + init_vga(&display_config, start_visible, update_visible, stop_visible);
7.10
7.11 test_linedata(&display_config);
7.12
7.13 @@ -169,24 +168,6 @@
7.14 dma_off(0);
7.15 }
7.16
7.17 -/* Bring vsync low (single compare, output driven low) when the next line
7.18 - starts. */
7.19 -
7.20 -void vsync_low(void)
7.21 -{
7.22 - oc_init(2, 0b010, 2);
7.23 - oc_on(2);
7.24 -}
7.25 -
7.26 -/* Bring vsync high (single compare, output driven high) when the next line
7.27 - starts. */
7.28 -
7.29 -void vsync_high(void)
7.30 -{
7.31 - oc_init(2, 0b001, 2);
7.32 - oc_on(2);
7.33 -}
7.34 -
7.35
7.36
7.37 /* Peripheral pin configuration. */
8.1 --- a/examples/vga/main.h Wed Oct 24 15:31:56 2018 +0200
8.2 +++ b/examples/vga/main.h Wed Oct 24 15:46:42 2018 +0200
8.3 @@ -33,9 +33,4 @@
8.4 void update_visible(vga_display_t *vga_display);
8.5 void stop_visible(vga_display_t *vga_display);
8.6
8.7 -/* Vertical sync operations. */
8.8 -
8.9 -void vsync_high(void);
8.10 -void vsync_low(void);
8.11 -
8.12 #endif /* __MAIN_H__ */
9.1 --- a/include/vga_display.h Wed Oct 24 15:31:56 2018 +0200
9.2 +++ b/include/vga_display.h Wed Oct 24 15:46:42 2018 +0200
9.3 @@ -38,10 +38,9 @@
9.4 void (*update_visible)();
9.5 void (*stop_visible)();
9.6
9.7 - /* Vertical sync operations. */
9.8 + /* Horizontal and vertical sync peripherals. */
9.9
9.10 - void (*vsync_high)();
9.11 - void (*vsync_low)();
9.12 + int timer, hsync_unit, vsync_unit;
9.13
9.14 /* Current scanline. */
9.15
9.16 @@ -64,9 +63,7 @@
9.17 void init_vga(display_config_t *display_config,
9.18 void (*start_visible)(),
9.19 void (*update_visible)(),
9.20 - void (*stop_visible)(),
9.21 - void (*vsync_high)(),
9.22 - void (*vsync_low)());
9.23 + void (*stop_visible)());
9.24
9.25 void vga_configure_sync(int hsync_unit, int vsync_unit, int timer);
9.26
9.27 @@ -81,4 +78,9 @@
9.28 void vfp_active(void);
9.29 void vsync_active(void);
9.30
9.31 +/* Vertical sync operations. */
9.32 +
9.33 +void vsync_high(void);
9.34 +void vsync_low(void);
9.35 +
9.36 #endif /* __VGA_DISPLAY_H__ */
10.1 --- a/lib/vga_display.c Wed Oct 24 15:31:56 2018 +0200
10.2 +++ b/lib/vga_display.c Wed Oct 24 15:46:42 2018 +0200
10.3 @@ -34,9 +34,7 @@
10.4 void init_vga(display_config_t *display_config,
10.5 void (*start_visible)(),
10.6 void (*update_visible)(),
10.7 - void (*stop_visible)(),
10.8 - void (*vsync_high)(),
10.9 - void (*vsync_low)())
10.10 + void (*stop_visible)())
10.11 {
10.12 /* Display parameters. */
10.13
10.14 @@ -48,11 +46,6 @@
10.15 vga_display.update_visible = update_visible;
10.16 vga_display.stop_visible = stop_visible;
10.17
10.18 - /* Vertical sync operations. */
10.19 -
10.20 - vga_display.vsync_high = vsync_high;
10.21 - vga_display.vsync_low = vsync_low;
10.22 -
10.23 /* Initial state. */
10.24
10.25 vga_display.state_handler = vbp_active;
10.26 @@ -64,6 +57,12 @@
10.27
10.28 void vga_configure_sync(int hsync_unit, int vsync_unit, int timer)
10.29 {
10.30 + /* Record the peripherals in use. */
10.31 +
10.32 + vga_display.hsync_unit = hsync_unit;
10.33 + vga_display.vsync_unit = vsync_unit;
10.34 + vga_display.timer = timer;
10.35 +
10.36 /* Configure a timer for the horizontal sync. The timer has no prescaling
10.37 (0). */
10.38
10.39 @@ -163,7 +162,7 @@
10.40
10.41 /* Bring vsync low when the next line starts. */
10.42
10.43 - vga_display.vsync_low();
10.44 + vsync_low();
10.45 }
10.46
10.47 /* Vertical sync region. */
10.48 @@ -180,5 +179,25 @@
10.49
10.50 /* Bring vsync high when the next line starts. */
10.51
10.52 - vga_display.vsync_high();
10.53 + vsync_high();
10.54 }
10.55 +
10.56 +
10.57 +
10.58 +/* Bring vsync low (single compare, output driven low) when the next line
10.59 + starts. */
10.60 +
10.61 +void vsync_low(void)
10.62 +{
10.63 + oc_init(vga_display.vsync_unit, 0b010, vga_display.timer);
10.64 + oc_on(vga_display.vsync_unit);
10.65 +}
10.66 +
10.67 +/* Bring vsync high (single compare, output driven high) when the next line
10.68 + starts. */
10.69 +
10.70 +void vsync_high(void)
10.71 +{
10.72 + oc_init(vga_display.vsync_unit, 0b001, vga_display.timer);
10.73 + oc_on(vga_display.vsync_unit);
10.74 +}