paul@50 | 1 | /* |
paul@50 | 2 | * Generate a VGA signal using a PIC32 microcontroller. |
paul@50 | 3 | * |
paul@50 | 4 | * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> |
paul@50 | 5 | * |
paul@50 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@50 | 7 | * it under the terms of the GNU General Public License as published by |
paul@50 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@50 | 9 | * (at your option) any later version. |
paul@50 | 10 | * |
paul@50 | 11 | * This program is distributed in the hope that it will be useful, |
paul@50 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@50 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@50 | 14 | * GNU General Public License for more details. |
paul@50 | 15 | * |
paul@50 | 16 | * You should have received a copy of the GNU General Public License |
paul@50 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@50 | 18 | */ |
paul@50 | 19 | |
paul@53 | 20 | #include "init.h" |
paul@50 | 21 | #include "vga_display.h" |
paul@50 | 22 | |
paul@50 | 23 | |
paul@50 | 24 | |
paul@50 | 25 | /* Display state. */ |
paul@50 | 26 | |
paul@125 | 27 | VGA_Display(vga_display); |
paul@50 | 28 | |
paul@56 | 29 | /* Pixel data. */ |
paul@56 | 30 | |
paul@56 | 31 | static const int ZERO_LENGTH = 1; |
paul@56 | 32 | static const uint8_t zerodata[1] = {0}; |
paul@56 | 33 | |
paul@50 | 34 | |
paul@50 | 35 | |
paul@50 | 36 | /* Initialise the state machine. */ |
paul@50 | 37 | |
paul@56 | 38 | void init_vga(display_config_t *display_config, int line_channels, |
paul@59 | 39 | int line_timer, int transfer_int_num) |
paul@50 | 40 | { |
paul@50 | 41 | /* Display parameters. */ |
paul@50 | 42 | |
paul@50 | 43 | vga_display.display_config = display_config; |
paul@56 | 44 | vga_display.line_channels = line_channels; |
paul@50 | 45 | |
paul@50 | 46 | /* Initial state. */ |
paul@50 | 47 | |
paul@50 | 48 | vga_display.state_handler = vbp_active; |
paul@50 | 49 | vga_display.line = 0; |
paul@59 | 50 | |
paul@59 | 51 | /* Configure a general display timer to start line data transfer and for the |
paul@59 | 52 | horizontal sync. */ |
paul@59 | 53 | |
paul@59 | 54 | vga_display.line_timer = line_timer; |
paul@59 | 55 | |
paul@59 | 56 | /* Configure a separate transfer interrupt condition, if indicated. |
paul@59 | 57 | Otherwise, transfers are initiated by the line timer. */ |
paul@59 | 58 | |
paul@59 | 59 | vga_display.transfer_int_num = transfer_int_num; |
paul@92 | 60 | |
paul@92 | 61 | /* Update the addresses used for the display. */ |
paul@92 | 62 | |
paul@92 | 63 | vga_set_frame(display_config); |
paul@59 | 64 | } |
paul@59 | 65 | |
paul@59 | 66 | /* Initialise a separate transfer timer if different from the general display |
paul@59 | 67 | timer. */ |
paul@59 | 68 | |
paul@59 | 69 | void init_vga_with_timers(display_config_t *display_config, int line_channels, |
paul@59 | 70 | int line_timer, int transfer_timer) |
paul@59 | 71 | { |
paul@59 | 72 | /* Initialise the basic properties of the display. */ |
paul@59 | 73 | |
paul@59 | 74 | init_vga(display_config, line_channels, line_timer, |
paul@59 | 75 | transfer_timer ? timer_interrupt_number(transfer_timer) : -1); |
paul@59 | 76 | |
paul@59 | 77 | /* Configure a line timer for horizontal sync and line data transfers. */ |
paul@59 | 78 | |
paul@59 | 79 | /* The timers have no prescaling (0). */ |
paul@59 | 80 | |
paul@125 | 81 | timer_init(line_timer, 0, vga_display.hfreq_limit); |
paul@88 | 82 | |
paul@88 | 83 | /* Enable interrupt requests when the CPU needs to perform the transfer, as |
paul@88 | 84 | opposed to the DMA channels doing so. */ |
paul@88 | 85 | |
paul@88 | 86 | if (!line_channels) |
paul@88 | 87 | timer_init_interrupt(line_timer, 7, 3); |
paul@88 | 88 | |
paul@59 | 89 | timer_on(line_timer); |
paul@59 | 90 | |
paul@59 | 91 | /* Configure a separate transfer timer, if indicated. */ |
paul@59 | 92 | |
paul@88 | 93 | if (!line_channels || !transfer_timer || (transfer_timer == line_timer)) |
paul@59 | 94 | return; |
paul@59 | 95 | |
paul@59 | 96 | /* The timer wraps around immediately. */ |
paul@59 | 97 | |
paul@59 | 98 | timer_init(transfer_timer, 0, 1); |
paul@59 | 99 | timer_on(transfer_timer); |
paul@50 | 100 | } |
paul@50 | 101 | |
paul@56 | 102 | |
paul@56 | 103 | |
paul@88 | 104 | /* Configure the transfer of pixel data. */ |
paul@88 | 105 | |
paul@88 | 106 | void vga_configure_transfer(uint32_t output) |
paul@88 | 107 | { |
paul@88 | 108 | vga_display.output = output; |
paul@88 | 109 | |
paul@88 | 110 | if (vga_display.line_channels) |
paul@88 | 111 | vga_configure_dma_transfer(output); |
paul@88 | 112 | } |
paul@88 | 113 | |
paul@56 | 114 | /* Configure DMA channels for the transfer of pixel data. */ |
paul@56 | 115 | |
paul@88 | 116 | void vga_configure_dma_transfer(uint32_t output) |
paul@56 | 117 | { |
paul@56 | 118 | int dual_channel = vga_display.line_channels == 2; |
paul@56 | 119 | int channel = 0; |
paul@56 | 120 | |
paul@59 | 121 | /* Determine whether an initiating channel is used. */ |
paul@59 | 122 | |
paul@59 | 123 | int initiating_channel = vga_display.transfer_int_num >= 0; |
paul@59 | 124 | |
paul@59 | 125 | /* Determine the different interrupt conditions, with pixel data employing |
paul@59 | 126 | any specified transfer condition or the line condition otherwise. */ |
paul@59 | 127 | |
paul@59 | 128 | int line_int_num = timer_interrupt_number(vga_display.line_timer); |
paul@59 | 129 | int transfer_int_num = initiating_channel ? |
paul@59 | 130 | vga_display.transfer_int_num : line_int_num; |
paul@59 | 131 | |
paul@56 | 132 | /* Where dual line channels are involved, put the first before any |
paul@56 | 133 | initiating channel, chaining it to such a channel. */ |
paul@56 | 134 | |
paul@56 | 135 | if (dual_channel) |
paul@56 | 136 | { |
paul@56 | 137 | vga_configure_line_channel(channel++, transfer_int_num, |
paul@56 | 138 | initiating_channel ? dma_chain_next : dma_chain_none, |
paul@56 | 139 | output); |
paul@56 | 140 | } |
paul@56 | 141 | |
paul@59 | 142 | /* Introduce a special initiating channel if a separate transfer interrupt |
paul@59 | 143 | has been indicated. */ |
paul@56 | 144 | |
paul@56 | 145 | if (initiating_channel) |
paul@56 | 146 | { |
paul@59 | 147 | vga_configure_zero_channel(channel++, line_int_num, 1, output); |
paul@56 | 148 | } |
paul@56 | 149 | |
paul@56 | 150 | /* A line channel is always configured, chaining it to any initiating |
paul@56 | 151 | channel. */ |
paul@56 | 152 | |
paul@56 | 153 | vga_configure_line_channel(channel++, transfer_int_num, |
paul@56 | 154 | initiating_channel ? dma_chain_previous : dma_chain_none, |
paul@56 | 155 | output); |
paul@56 | 156 | |
paul@56 | 157 | /* A zero channel is always configured, chaining it to the preceding line |
paul@56 | 158 | channel, with the same transfer interrupt initiating the transfer. */ |
paul@56 | 159 | |
paul@56 | 160 | vga_configure_zero_channel(channel, transfer_int_num, 0, output); |
paul@56 | 161 | } |
paul@56 | 162 | |
paul@56 | 163 | void vga_configure_line_channel(int channel, int int_num, enum dma_chain chain, |
paul@56 | 164 | uint32_t output) |
paul@56 | 165 | { |
paul@56 | 166 | dma_init(channel, 2); |
paul@56 | 167 | |
paul@56 | 168 | /* If initiating, configure to always be enabled. */ |
paul@56 | 169 | |
paul@56 | 170 | if (chain == dma_chain_none) |
paul@56 | 171 | dma_set_auto_enable(channel, 1); |
paul@56 | 172 | |
paul@56 | 173 | /* Chain to either the previous or next channel where a special initiating |
paul@56 | 174 | channel is used. */ |
paul@56 | 175 | |
paul@56 | 176 | else |
paul@56 | 177 | dma_set_chaining(channel, chain); |
paul@56 | 178 | |
paul@56 | 179 | /* Initiate DMA on the transfer interrupt, transferring line data to the |
paul@56 | 180 | first byte of the output word. */ |
paul@56 | 181 | |
paul@56 | 182 | dma_set_interrupt(channel, int_num, 1); |
paul@56 | 183 | |
paul@56 | 184 | dma_set_destination(channel, HW_PHYSICAL(output), 1); |
paul@125 | 185 | dma_set_cell(channel, vga_display.transfer_cell_size); |
paul@56 | 186 | } |
paul@56 | 187 | |
paul@56 | 188 | void vga_configure_zero_channel(int channel, int int_num, int initiating, |
paul@56 | 189 | uint32_t output) |
paul@56 | 190 | { |
paul@56 | 191 | dma_init(channel, 3); |
paul@56 | 192 | |
paul@56 | 193 | /* If initiating, configure to always be enabled. */ |
paul@56 | 194 | |
paul@56 | 195 | if (initiating) |
paul@56 | 196 | dma_set_auto_enable(channel, 1); |
paul@56 | 197 | |
paul@56 | 198 | /* Otherwise, chain to the preceding channel and register prior transfer |
paul@56 | 199 | events before the channel is activated. */ |
paul@56 | 200 | |
paul@56 | 201 | else |
paul@56 | 202 | { |
paul@56 | 203 | dma_set_chaining(channel, dma_chain_previous); |
paul@56 | 204 | dma_set_receive_events(channel, 1); |
paul@56 | 205 | } |
paul@56 | 206 | |
paul@56 | 207 | /* Transfer upon the indicated interrupt condition. */ |
paul@56 | 208 | |
paul@56 | 209 | dma_set_interrupt(channel, int_num, 1); |
paul@56 | 210 | dma_set_transfer(channel, PHYSICAL((uint32_t) zerodata), |
paul@56 | 211 | ZERO_LENGTH, |
paul@56 | 212 | HW_PHYSICAL(output), 1, |
paul@56 | 213 | ZERO_LENGTH); |
paul@56 | 214 | } |
paul@56 | 215 | |
paul@59 | 216 | /* Configure output compare units for horizontal and vertical sync. */ |
paul@53 | 217 | |
paul@59 | 218 | void vga_configure_sync(int hsync_unit, int vsync_unit) |
paul@53 | 219 | { |
paul@54 | 220 | /* Record the peripherals in use. */ |
paul@54 | 221 | |
paul@54 | 222 | vga_display.hsync_unit = hsync_unit; |
paul@54 | 223 | vga_display.vsync_unit = vsync_unit; |
paul@54 | 224 | |
paul@53 | 225 | /* Horizontal sync. */ |
paul@65 | 226 | |
paul@53 | 227 | /* Configure output compare in dual compare (continuous output) mode using |
paul@53 | 228 | the timer as time base. The interrupt condition drives the first DMA |
paul@53 | 229 | channel and is handled to drive the display state machine. */ |
paul@53 | 230 | |
paul@59 | 231 | oc_init(hsync_unit, 0b101, vga_display.line_timer); |
paul@125 | 232 | oc_set_pulse(hsync_unit, vga_display.hsync_end); |
paul@125 | 233 | oc_set_pulse_end(hsync_unit, vga_display.hsync_start); |
paul@53 | 234 | oc_init_interrupt(hsync_unit, 7, 3); |
paul@53 | 235 | oc_on(hsync_unit); |
paul@53 | 236 | |
paul@53 | 237 | /* Vertical sync. */ |
paul@53 | 238 | |
paul@53 | 239 | /* Configure output compare in single compare (output driven low) mode using |
paul@53 | 240 | the timer as time base. The unit is enabled later. It is only really used |
paul@53 | 241 | to achieve precisely-timed level transitions in hardware. */ |
paul@65 | 242 | |
paul@59 | 243 | oc_init(vsync_unit, 0b010, vga_display.line_timer); |
paul@53 | 244 | oc_set_pulse(vsync_unit, 0); |
paul@53 | 245 | } |
paul@53 | 246 | |
paul@50 | 247 | |
paul@50 | 248 | |
paul@92 | 249 | /* Update the display addresses from the general display configuration. */ |
paul@92 | 250 | |
paul@92 | 251 | void vga_set_frame(display_config_t *display_config) |
paul@92 | 252 | { |
paul@97 | 253 | vga_wait_visible(); |
paul@97 | 254 | |
paul@92 | 255 | vga_display.screen_start = display_config->screen_start; |
paul@92 | 256 | vga_display.screen_limit = display_config->screen_limit; |
paul@92 | 257 | vga_display.screen_size = display_config->screen_size; |
paul@92 | 258 | } |
paul@92 | 259 | |
paul@96 | 260 | /* Wait for the visible region to be completed. */ |
paul@96 | 261 | |
paul@96 | 262 | void vga_wait_visible(void) |
paul@96 | 263 | { |
paul@96 | 264 | while (((volatile void (*)()) vga_display.state_handler) == visible_active) |
paul@96 | 265 | __asm__ __volatile__("wait"); |
paul@96 | 266 | } |
paul@96 | 267 | |
paul@96 | 268 | |
paul@96 | 269 | |
paul@88 | 270 | /* Display state machine interrupt handler. */ |
paul@50 | 271 | |
paul@50 | 272 | void vga_interrupt_handler(void) |
paul@50 | 273 | { |
paul@88 | 274 | uint32_t ifs; |
paul@88 | 275 | |
paul@88 | 276 | if (!vga_display.line_channels) |
paul@88 | 277 | { |
paul@88 | 278 | /* Check for a timer interrupt condition. */ |
paul@88 | 279 | |
paul@88 | 280 | ifs = REG(TIMERIFS) & TIMER_INT_FLAGS(vga_display.line_timer, TxIF); |
paul@88 | 281 | |
paul@88 | 282 | if (ifs) |
paul@88 | 283 | { |
paul@88 | 284 | vga_transfer_interrupt_handler(); |
paul@88 | 285 | CLR_REG(TIMERIFS, ifs); |
paul@88 | 286 | } |
paul@88 | 287 | } |
paul@88 | 288 | |
paul@88 | 289 | /* Check for a OC1 interrupt condition. */ |
paul@88 | 290 | |
paul@88 | 291 | ifs = REG(OCIFS) & OC_INT_FLAGS(1, OCxIF); |
paul@88 | 292 | |
paul@88 | 293 | if (ifs) |
paul@88 | 294 | { |
paul@88 | 295 | vga_hsync_interrupt_handler(); |
paul@88 | 296 | CLR_REG(OCIFS, ifs); |
paul@88 | 297 | } |
paul@88 | 298 | |
paul@88 | 299 | } |
paul@88 | 300 | |
paul@88 | 301 | /* Display state machine interrupt handler. */ |
paul@88 | 302 | |
paul@88 | 303 | void vga_hsync_interrupt_handler(void) |
paul@88 | 304 | { |
paul@50 | 305 | vga_display.line += 1; |
paul@50 | 306 | vga_display.state_handler(); |
paul@50 | 307 | } |
paul@50 | 308 | |
paul@88 | 309 | /* Visible region pixel output handler, used when the CPU is responsible for |
paul@88 | 310 | producing pixel output rather than the DMA channels. */ |
paul@88 | 311 | |
paul@88 | 312 | void vga_transfer_interrupt_handler(void) |
paul@88 | 313 | { |
paul@88 | 314 | display_config_t *cfg = vga_display.display_config; |
paul@88 | 315 | uint8_t *current, *end, *output; |
paul@88 | 316 | |
paul@88 | 317 | if (vga_display.state_handler != visible_active) |
paul@88 | 318 | return; |
paul@88 | 319 | |
paul@88 | 320 | /* Generate the pixel signal. */ |
paul@88 | 321 | |
paul@88 | 322 | output = (uint8_t *) vga_display.output; |
paul@88 | 323 | end = vga_display.linedata + cfg->line_length; |
paul@88 | 324 | |
paul@88 | 325 | /* This is potentially not as efficient as loading words and shifting bytes |
paul@88 | 326 | but it appears difficult to implement that approach without experiencing |
paul@88 | 327 | data load exceptions. */ |
paul@88 | 328 | |
paul@88 | 329 | for (current = vga_display.linedata; current < end; current++) |
paul@88 | 330 | REG(output) = *current; |
paul@88 | 331 | |
paul@88 | 332 | /* Reset the signal level. */ |
paul@88 | 333 | |
paul@88 | 334 | REG(output) = 0; |
paul@88 | 335 | } |
paul@88 | 336 | |
paul@50 | 337 | |
paul@50 | 338 | |
paul@50 | 339 | /* Vertical back porch region. */ |
paul@50 | 340 | |
paul@50 | 341 | void vbp_active(void) |
paul@50 | 342 | { |
paul@125 | 343 | if (vga_display.line < vga_display.visible_start) |
paul@50 | 344 | return; |
paul@50 | 345 | |
paul@50 | 346 | /* Enter the visible region. */ |
paul@50 | 347 | |
paul@50 | 348 | vga_display.state_handler = visible_active; |
paul@50 | 349 | |
paul@50 | 350 | /* Set the line address. */ |
paul@50 | 351 | |
paul@92 | 352 | vga_display.linedata = vga_display.screen_start; |
paul@88 | 353 | |
paul@88 | 354 | if (vga_display.line_channels) |
paul@88 | 355 | start_visible(); |
paul@50 | 356 | } |
paul@50 | 357 | |
paul@50 | 358 | /* Visible region. */ |
paul@50 | 359 | |
paul@50 | 360 | void visible_active(void) |
paul@50 | 361 | { |
paul@81 | 362 | display_config_t *cfg = vga_display.display_config; |
paul@81 | 363 | |
paul@125 | 364 | if (vga_display.line < vga_display.vfp_start) |
paul@50 | 365 | { |
paul@50 | 366 | /* Update the line address and handle wraparound. */ |
paul@50 | 367 | |
paul@81 | 368 | if (!(vga_display.line % cfg->line_multiplier)) |
paul@50 | 369 | { |
paul@81 | 370 | vga_display.linedata += cfg->line_length; |
paul@50 | 371 | |
paul@92 | 372 | if (vga_display.linedata >= vga_display.screen_limit) |
paul@92 | 373 | vga_display.linedata -= vga_display.screen_size; |
paul@50 | 374 | } |
paul@50 | 375 | |
paul@88 | 376 | if (vga_display.line_channels) |
paul@88 | 377 | update_visible(); |
paul@50 | 378 | return; |
paul@50 | 379 | } |
paul@50 | 380 | |
paul@50 | 381 | /* End the visible region. */ |
paul@50 | 382 | |
paul@50 | 383 | vga_display.state_handler = vfp_active; |
paul@50 | 384 | |
paul@50 | 385 | /* Disable the channel for the next line. */ |
paul@50 | 386 | |
paul@88 | 387 | if (vga_display.line_channels) |
paul@88 | 388 | stop_visible(); |
paul@50 | 389 | } |
paul@50 | 390 | |
paul@50 | 391 | /* Vertical front porch region. */ |
paul@50 | 392 | |
paul@50 | 393 | void vfp_active(void) |
paul@50 | 394 | { |
paul@125 | 395 | if (vga_display.line < vga_display.vsync_start) |
paul@50 | 396 | return; |
paul@50 | 397 | |
paul@50 | 398 | /* Enter the vertical sync region. */ |
paul@50 | 399 | |
paul@50 | 400 | vga_display.state_handler = vsync_active; |
paul@50 | 401 | |
paul@50 | 402 | /* Bring vsync low when the next line starts. */ |
paul@50 | 403 | |
paul@54 | 404 | vsync_low(); |
paul@50 | 405 | } |
paul@50 | 406 | |
paul@50 | 407 | /* Vertical sync region. */ |
paul@50 | 408 | |
paul@50 | 409 | void vsync_active(void) |
paul@50 | 410 | { |
paul@125 | 411 | if (vga_display.line < vga_display.vsync_end) |
paul@50 | 412 | return; |
paul@50 | 413 | |
paul@50 | 414 | /* Start again at the top of the display. */ |
paul@50 | 415 | |
paul@50 | 416 | vga_display.line = 0; |
paul@50 | 417 | vga_display.state_handler = vbp_active; |
paul@50 | 418 | |
paul@50 | 419 | /* Bring vsync high when the next line starts. */ |
paul@50 | 420 | |
paul@54 | 421 | vsync_high(); |
paul@50 | 422 | } |
paul@54 | 423 | |
paul@54 | 424 | |
paul@54 | 425 | |
paul@56 | 426 | /* Enable the channels for the next line. */ |
paul@56 | 427 | |
paul@56 | 428 | void start_visible(void) |
paul@56 | 429 | { |
paul@56 | 430 | update_visible(); |
paul@56 | 431 | update_transfers(1); |
paul@56 | 432 | } |
paul@56 | 433 | |
paul@56 | 434 | /* Update the channels for the next line. */ |
paul@56 | 435 | |
paul@56 | 436 | void update_visible(void) |
paul@56 | 437 | { |
paul@56 | 438 | uint32_t transfer_start = (uint32_t) vga_display.linedata; |
paul@56 | 439 | uint32_t transfer_length = vga_display.display_config->line_length / |
paul@56 | 440 | vga_display.line_channels; |
paul@56 | 441 | |
paul@56 | 442 | /* Determine whether an initiating channel is used. */ |
paul@56 | 443 | |
paul@59 | 444 | int initiating_channel = vga_display.transfer_int_num >= 0; |
paul@56 | 445 | int channel = 0; |
paul@56 | 446 | |
paul@56 | 447 | /* Update the source of a secondary line channel. */ |
paul@56 | 448 | |
paul@56 | 449 | if (vga_display.line_channels == 2) |
paul@56 | 450 | { |
paul@56 | 451 | dma_set_source(channel, PHYSICAL(transfer_start), transfer_length); |
paul@56 | 452 | transfer_start += transfer_length; |
paul@56 | 453 | channel++; |
paul@56 | 454 | } |
paul@56 | 455 | |
paul@56 | 456 | /* Skip any initiating channel. */ |
paul@56 | 457 | |
paul@56 | 458 | if (initiating_channel) |
paul@56 | 459 | channel++; |
paul@56 | 460 | |
paul@56 | 461 | /* Update the source of a line channel, with potentially updated start |
paul@56 | 462 | address. */ |
paul@56 | 463 | |
paul@56 | 464 | dma_set_source(channel, PHYSICAL(transfer_start), transfer_length); |
paul@56 | 465 | } |
paul@56 | 466 | |
paul@56 | 467 | /* Disable the channels for the next line. */ |
paul@56 | 468 | |
paul@56 | 469 | void stop_visible(void) |
paul@56 | 470 | { |
paul@56 | 471 | update_transfers(0); |
paul@56 | 472 | } |
paul@56 | 473 | |
paul@56 | 474 | /* Enable or disable transfers. */ |
paul@56 | 475 | |
paul@56 | 476 | void update_transfers(int enable) |
paul@56 | 477 | { |
paul@59 | 478 | void (*fn)() = enable ? dma_on : dma_off; |
paul@59 | 479 | |
paul@59 | 480 | /* Determine whether an initiating channel is used. */ |
paul@59 | 481 | |
paul@59 | 482 | int initiating_channel = vga_display.transfer_int_num >= 0; |
paul@56 | 483 | int channel = 0; |
paul@56 | 484 | |
paul@56 | 485 | /* Update line channels if no initiating channel is used. */ |
paul@56 | 486 | |
paul@56 | 487 | if (vga_display.line_channels == 2) |
paul@56 | 488 | { |
paul@56 | 489 | if (!initiating_channel) |
paul@56 | 490 | fn(channel); |
paul@56 | 491 | channel++; |
paul@56 | 492 | } |
paul@56 | 493 | |
paul@56 | 494 | /* Update any initiating channel. */ |
paul@56 | 495 | |
paul@56 | 496 | if (initiating_channel) |
paul@56 | 497 | { |
paul@56 | 498 | fn(channel); |
paul@56 | 499 | channel++; |
paul@56 | 500 | } |
paul@56 | 501 | |
paul@56 | 502 | /* Update line channels if no initiating channel is used. */ |
paul@56 | 503 | |
paul@56 | 504 | if (!initiating_channel) |
paul@56 | 505 | fn(channel); |
paul@56 | 506 | } |
paul@56 | 507 | |
paul@56 | 508 | |
paul@56 | 509 | |
paul@54 | 510 | /* Bring vsync low (single compare, output driven low) when the next line |
paul@54 | 511 | starts. */ |
paul@54 | 512 | |
paul@54 | 513 | void vsync_low(void) |
paul@54 | 514 | { |
paul@59 | 515 | oc_init(vga_display.vsync_unit, 0b010, vga_display.line_timer); |
paul@54 | 516 | oc_on(vga_display.vsync_unit); |
paul@54 | 517 | } |
paul@54 | 518 | |
paul@54 | 519 | /* Bring vsync high (single compare, output driven high) when the next line |
paul@54 | 520 | starts. */ |
paul@54 | 521 | |
paul@54 | 522 | void vsync_high(void) |
paul@54 | 523 | { |
paul@59 | 524 | oc_init(vga_display.vsync_unit, 0b001, vga_display.line_timer); |
paul@54 | 525 | oc_on(vga_display.vsync_unit); |
paul@54 | 526 | } |