1.1 --- a/examples/vga/main.c Sun Oct 28 01:22:54 2018 +0200
1.2 +++ b/examples/vga/main.c Sun Oct 28 18:08:21 2018 +0100
1.3 @@ -47,6 +47,20 @@
1.4 #define TRANSFER_TIMER 0
1.5 #endif
1.6
1.7 +/* Define different output ports and pins for parallel mode. */
1.8 +
1.9 +#ifndef PARALLEL_MODE
1.10 +#define VGA_OUTPUT PORTB
1.11 +#define OC1_PIN RPA0R
1.12 +#define OC2_PIN RPA1R
1.13 +#define LED_PIN (1 << 3)
1.14 +#else
1.15 +#define VGA_OUTPUT PM_REG(0, PMxDIN)
1.16 +#define OC1_PIN RPB4R
1.17 +#define OC2_PIN RPB5R
1.18 +#define LED_PIN (1 << 2)
1.19 +#endif
1.20 +
1.21
1.22
1.23 /* Bundled image data. */
1.24 @@ -95,6 +109,16 @@
1.25
1.26 init_dma();
1.27
1.28 +#ifdef PARALLEL_MODE
1.29 + init_pm();
1.30 +
1.31 + /* Configure parallel master mode. */
1.32 +
1.33 + pm_init(0, 0b10);
1.34 + pm_set_output(0, 1, 0);
1.35 + pm_on(0);
1.36 +#endif
1.37 +
1.38 /* Initialise VGA output with one or two line channels, configuring a line
1.39 timer and any transfer timer, with an initiating channel being introduced
1.40 if a transfer timer is specified. */
1.41 @@ -104,7 +128,7 @@
1.42 /* Configure VGA output transfer to the output register, also configuring
1.43 output compare units for horizontal and vertical sync. */
1.44
1.45 - vga_configure_transfer(PORTB);
1.46 + vga_configure_transfer(VGA_OUTPUT);
1.47 vga_configure_sync(1, 2);
1.48
1.49 uart_init(1, FPB, 115200);
1.50 @@ -113,7 +137,7 @@
1.51 interrupts_on();
1.52
1.53 copy_to_framebuffer(&display_config, screendata, screendata_width, screendata_height);
1.54 - blink(1 << 24, PORTA, 1 << 3);
1.55 + blink(1 << 24, PORTA, LED_PIN);
1.56 }
1.57
1.58
1.59 @@ -122,7 +146,7 @@
1.60
1.61 void exception_handler(void)
1.62 {
1.63 - blink(3 << 12, PORTA, 1 << 3);
1.64 + blink(3 << 12, PORTA, LED_PIN);
1.65 }
1.66
1.67 void interrupt_handler(void)
1.68 @@ -146,13 +170,13 @@
1.69
1.70 void config_oc(void)
1.71 {
1.72 - /* Map OC1 to RPA0. */
1.73 + /* Map OC1. */
1.74
1.75 - REG(RPA0R) = 0b0101; /* RPA0R<3:0> = 0101 (OC1) */
1.76 + REG(OC1_PIN) = 0b0101;
1.77
1.78 - /* Map OC2 to RPA1. */
1.79 + /* Map OC2. */
1.80
1.81 - REG(RPA1R) = 0b0101; /* RPA1R<3:0> = 0101 (OC2) */
1.82 + REG(OC2_PIN) = 0b0101;
1.83 }
1.84
1.85 void config_uart(void)