paul@24 | 1 | /* |
paul@24 | 2 | * Generate a VGA signal using a PIC32 microcontroller. |
paul@24 | 3 | * |
paul@24 | 4 | * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> |
paul@24 | 5 | * |
paul@24 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@24 | 7 | * it under the terms of the GNU General Public License as published by |
paul@24 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@24 | 9 | * (at your option) any later version. |
paul@24 | 10 | * |
paul@24 | 11 | * This program is distributed in the hope that it will be useful, |
paul@24 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@24 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@24 | 14 | * GNU General Public License for more details. |
paul@24 | 15 | * |
paul@24 | 16 | * You should have received a copy of the GNU General Public License |
paul@24 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@24 | 18 | */ |
paul@24 | 19 | |
paul@24 | 20 | |
paul@108 | 21 | #include "debug.h" |
paul@108 | 22 | #include "display.h" |
paul@108 | 23 | #include "font.h" |
paul@24 | 24 | #include "init.h" |
paul@108 | 25 | #include "pic32_c.h" |
paul@108 | 26 | #include "utils.h" |
paul@108 | 27 | #include "vga_display.h" |
paul@41 | 28 | |
paul@41 | 29 | /* Specific functionality. */ |
paul@41 | 30 | |
paul@47 | 31 | #include "devconfig.h" |
paul@49 | 32 | #include "display_config.h" |
paul@78 | 33 | #include "main.h" |
paul@87 | 34 | |
paul@88 | 35 | |
paul@88 | 36 | |
paul@88 | 37 | /* Define DMA channels if not indicated in the build configuration. */ |
paul@88 | 38 | |
paul@88 | 39 | /* CPU-based transfers: no channels. */ |
paul@88 | 40 | |
paul@88 | 41 | #ifdef TRANSFER_CPU |
paul@88 | 42 | #define SCROLL_XSTEP 1 |
paul@88 | 43 | |
paul@88 | 44 | /* DMA-based transfers: single channel by default. */ |
paul@88 | 45 | |
paul@87 | 46 | #else |
paul@88 | 47 | #define SCROLL_XSTEP LINE_CHANNELS |
paul@87 | 48 | #endif |
paul@24 | 49 | |
paul@24 | 50 | |
paul@41 | 51 | |
paul@59 | 52 | /* Define timers if not indicated in the build configuration. */ |
paul@59 | 53 | |
paul@59 | 54 | #ifndef LINE_TIMER |
paul@59 | 55 | #define LINE_TIMER 2 |
paul@59 | 56 | #endif |
paul@59 | 57 | |
paul@59 | 58 | #ifndef TRANSFER_TIMER |
paul@59 | 59 | #define TRANSFER_TIMER 0 |
paul@59 | 60 | #endif |
paul@59 | 61 | |
paul@72 | 62 | /* Define different output ports and pins for parallel mode. */ |
paul@72 | 63 | |
paul@72 | 64 | #ifndef PARALLEL_MODE |
paul@72 | 65 | #define VGA_OUTPUT PORTB |
paul@72 | 66 | #define OC1_PIN RPA0R |
paul@72 | 67 | #define OC2_PIN RPA1R |
paul@72 | 68 | #define LED_PIN (1 << 3) |
paul@72 | 69 | #else |
paul@72 | 70 | #define VGA_OUTPUT PM_REG(0, PMxDIN) |
paul@72 | 71 | #define OC1_PIN RPB4R |
paul@72 | 72 | #define OC2_PIN RPB5R |
paul@72 | 73 | #define LED_PIN (1 << 2) |
paul@72 | 74 | #endif |
paul@72 | 75 | |
paul@59 | 76 | |
paul@59 | 77 | |
paul@101 | 78 | /* Define the relationship between source images and the screen. */ |
paul@101 | 79 | |
paul@101 | 80 | #ifndef SOURCE_HEIGHT |
paul@101 | 81 | #define SOURCE_HEIGHT 256 |
paul@101 | 82 | #endif |
paul@101 | 83 | |
paul@101 | 84 | #define SOURCE_YSTEP (SOURCE_HEIGHT / LINE_COUNT) |
paul@101 | 85 | |
paul@101 | 86 | |
paul@101 | 87 | |
paul@93 | 88 | /* Framebuffer memory. */ |
paul@93 | 89 | |
paul@93 | 90 | static uint8_t framebuffer[FRAME_SIZE * FRAME_COUNT]; |
paul@93 | 91 | |
paul@93 | 92 | |
paul@93 | 93 | |
paul@78 | 94 | /* Bundled image and font data. */ |
paul@69 | 95 | |
paul@69 | 96 | extern uint8_t screendata[]; |
paul@69 | 97 | extern uint32_t screendata_width, screendata_height; |
paul@74 | 98 | extern uint8_t sprite[]; |
paul@74 | 99 | extern uint32_t sprite_width, sprite_height; |
paul@74 | 100 | |
paul@78 | 101 | extern uint8_t fontchars[]; |
paul@78 | 102 | extern uint32_t fonttable[]; |
paul@78 | 103 | extern uint32_t fontbase, fontlimit; |
paul@78 | 104 | |
paul@78 | 105 | static font_config_t font_config; |
paul@78 | 106 | |
paul@69 | 107 | |
paul@69 | 108 | |
paul@94 | 109 | /* Copy to the store from the display, then blit the image. */ |
paul@94 | 110 | |
paul@94 | 111 | static void plot_sprite(uint8_t *background, int x, int y) |
paul@94 | 112 | { |
paul@94 | 113 | copy_display(&display_config, background, |
paul@101 | 114 | sprite_width, sprite_height / SOURCE_YSTEP, 1, |
paul@94 | 115 | x, y, -1, 0); |
paul@94 | 116 | copy_display(&display_config, sprite, |
paul@101 | 117 | sprite_width, sprite_height, SOURCE_YSTEP, |
paul@94 | 118 | x, y, 0x8c, 1); |
paul@94 | 119 | } |
paul@94 | 120 | |
paul@94 | 121 | /* Copy to the display from the store, restoring the original background. */ |
paul@94 | 122 | |
paul@94 | 123 | static void unplot_sprite(uint8_t *background, int x, int y) |
paul@94 | 124 | { |
paul@94 | 125 | copy_display(&display_config, background, |
paul@101 | 126 | sprite_width, sprite_height / SOURCE_YSTEP, 1, |
paul@94 | 127 | x, y, -1, 1); |
paul@94 | 128 | } |
paul@94 | 129 | |
paul@94 | 130 | /* Plot the revealed region at the edge of the screen after scrolling. */ |
paul@94 | 131 | |
paul@94 | 132 | static void plot_screen_edge(int xorigin, int yorigin, int xstep) |
paul@94 | 133 | { |
paul@103 | 134 | /* Determine positions within the image. */ |
paul@103 | 135 | |
paul@103 | 136 | int xpos = wrap_value(xorigin, screendata_width); |
paul@103 | 137 | int ypos = wrap_value(yorigin, screendata_height); |
paul@103 | 138 | |
paul@94 | 139 | /* The display region is either the left or right edge. */ |
paul@94 | 140 | |
paul@94 | 141 | int xdisplay = xstep < 0 ? 0 : screendata_width - xstep; |
paul@94 | 142 | |
paul@94 | 143 | /* The source region depends on the origin within the background image. */ |
paul@94 | 144 | |
paul@103 | 145 | int xsource = wrap_value(xdisplay + xpos, screendata_width); |
paul@94 | 146 | |
paul@94 | 147 | /* The column width is the absolute increment. */ |
paul@94 | 148 | |
paul@94 | 149 | int width = xstep < 0 ? -xstep : xstep; |
paul@94 | 150 | |
paul@103 | 151 | /* Not all of the column may be available if close to the edge of the |
paul@103 | 152 | image, requiring multiple slices. */ |
paul@103 | 153 | |
paul@103 | 154 | int available = screendata_width - xsource; |
paul@94 | 155 | |
paul@103 | 156 | while (width) |
paul@103 | 157 | { |
paul@103 | 158 | /* Plot a column in two pieces if the vertical origin is |
paul@103 | 159 | non-zero. The first piece is at (xdisplay, 0) and |
paul@103 | 160 | provides the lower part of the background image displaced |
paul@103 | 161 | upwards (or downwards having wrapped around) on the |
paul@103 | 162 | screen. */ |
paul@94 | 163 | |
paul@94 | 164 | copy_display_section(&display_config, screendata, |
paul@94 | 165 | screendata_width, screendata_height, |
paul@103 | 166 | xsource, ypos, |
paul@103 | 167 | width, screendata_height - ypos, |
paul@101 | 168 | SOURCE_YSTEP, |
paul@103 | 169 | xdisplay, 0, |
paul@94 | 170 | -1, 1); |
paul@103 | 171 | |
paul@103 | 172 | /* The second column is at (xdisplay, h - ypos) and |
paul@103 | 173 | provides the upper part of the background image displaced |
paul@103 | 174 | downwards (or upwards having wrapped around) on the |
paul@103 | 175 | screen. */ |
paul@94 | 176 | |
paul@103 | 177 | if (ypos) |
paul@103 | 178 | copy_display_section(&display_config, screendata, |
paul@103 | 179 | screendata_width, screendata_height, |
paul@103 | 180 | xsource, 0, |
paul@103 | 181 | width, ypos, |
paul@103 | 182 | SOURCE_YSTEP, |
paul@103 | 183 | xdisplay, (screendata_height - ypos) / SOURCE_YSTEP, |
paul@103 | 184 | -1, 1); |
paul@103 | 185 | |
paul@103 | 186 | /* Get the next slice of the column. */ |
paul@94 | 187 | |
paul@103 | 188 | if (available < width) |
paul@103 | 189 | { |
paul@103 | 190 | width -= available; |
paul@103 | 191 | xsource = 0; |
paul@103 | 192 | xdisplay = wrap_value(xdisplay + available, screendata_width); |
paul@103 | 193 | available = screendata_width; |
paul@103 | 194 | } |
paul@103 | 195 | else |
paul@103 | 196 | width = 0; |
paul@103 | 197 | } |
paul@94 | 198 | } |
paul@94 | 199 | |
paul@74 | 200 | /* Move a sprite around on the framebuffer. */ |
paul@74 | 201 | |
paul@74 | 202 | static void animate(uint32_t delay) |
paul@74 | 203 | { |
paul@88 | 204 | /* Stored region behind the sprite. */ |
paul@88 | 205 | |
paul@102 | 206 | uint8_t background[FRAME_COUNT][(sprite_width * sprite_height) / SOURCE_YSTEP]; |
paul@102 | 207 | |
paul@102 | 208 | /* Positions of the stored regions for each frame. */ |
paul@102 | 209 | |
paul@102 | 210 | int background_x[FRAME_COUNT], background_y[FRAME_COUNT]; |
paul@102 | 211 | int background_stored[FRAME_COUNT]; |
paul@102 | 212 | |
paul@102 | 213 | /* Screen start values for each frame. */ |
paul@102 | 214 | |
paul@102 | 215 | uint32_t frame_offset[FRAME_COUNT]; |
paul@88 | 216 | |
paul@88 | 217 | /* Sprite position. */ |
paul@88 | 218 | |
paul@74 | 219 | int x, y; |
paul@88 | 220 | |
paul@88 | 221 | /* Scrolling directions. */ |
paul@88 | 222 | |
paul@94 | 223 | int dir[] = {1, 0, -1, 0, 1}; |
paul@94 | 224 | int dirindex = 0; |
paul@88 | 225 | |
paul@88 | 226 | /* Scrolling position. */ |
paul@88 | 227 | |
paul@88 | 228 | int xorigin = 0, yorigin = 0; |
paul@88 | 229 | |
paul@102 | 230 | /* Scrolling positions for each frame. */ |
paul@102 | 231 | |
paul@102 | 232 | int xorigins[FRAME_COUNT], yorigins[FRAME_COUNT]; |
paul@102 | 233 | |
paul@94 | 234 | /* Scroll increments and replotted column details. */ |
paul@88 | 235 | |
paul@102 | 236 | int xdir, ydir, xstep, ystep; |
paul@102 | 237 | |
paul@102 | 238 | /* Current frame being accessed. */ |
paul@102 | 239 | |
paul@102 | 240 | int frame; |
paul@102 | 241 | |
paul@102 | 242 | for (frame = 0; frame < display_config.frames; frame++) |
paul@102 | 243 | { |
paul@102 | 244 | background_stored[frame] = 0; |
paul@102 | 245 | frame_offset[frame] = 0; |
paul@102 | 246 | xorigins[frame] = xorigin; |
paul@102 | 247 | yorigins[frame] = yorigin; |
paul@102 | 248 | } |
paul@102 | 249 | |
paul@102 | 250 | frame = display_config.frame; |
paul@102 | 251 | |
paul@102 | 252 | /* Animation loop. */ |
paul@74 | 253 | |
paul@74 | 254 | while (1) |
paul@83 | 255 | { |
paul@102 | 256 | for (y = 0; y < display_config.line_count - sprite_height; y++) |
paul@83 | 257 | { |
paul@102 | 258 | for (x = 0; x < display_config.line_length - sprite_width; x++) |
paul@74 | 259 | { |
paul@102 | 260 | plot_sprite(background[frame], x, y); |
paul@102 | 261 | |
paul@102 | 262 | /* Record the stored background. */ |
paul@102 | 263 | |
paul@102 | 264 | background_x[frame] = x; |
paul@102 | 265 | background_y[frame] = y; |
paul@102 | 266 | background_stored[frame] = 1; |
paul@74 | 267 | |
paul@92 | 268 | /* Update the display with the frame details. */ |
paul@74 | 269 | |
paul@92 | 270 | vga_set_frame(&display_config); |
paul@74 | 271 | wait(delay); |
paul@74 | 272 | |
paul@102 | 273 | /* Select the next frame to plot to. */ |
paul@102 | 274 | |
paul@102 | 275 | frame = wrap_value(frame + 1, display_config.frames); |
paul@102 | 276 | select_frame(&display_config, frame, frame_offset[frame]); |
paul@102 | 277 | |
paul@102 | 278 | /* Prepare the frame for updates. */ |
paul@102 | 279 | |
paul@102 | 280 | if (background_stored[frame]) |
paul@102 | 281 | unplot_sprite(background[frame], background_x[frame], background_y[frame]); |
paul@83 | 282 | |
paul@83 | 283 | /* Scroll in the indicated direction. */ |
paul@83 | 284 | |
paul@94 | 285 | xdir = dir[dirindex]; |
paul@94 | 286 | ydir = dir[dirindex + 1]; |
paul@94 | 287 | |
paul@102 | 288 | /* Update the origin if appropriate. */ |
paul@83 | 289 | |
paul@102 | 290 | /* Due to the effect of a simple screen start increment in the |
paul@102 | 291 | dual channel configuration, horizontal scrolling involves two |
paul@102 | 292 | pixel increments and thus requires a two-pixel column to be |
paul@103 | 293 | plotted per scrolling increment. */ |
paul@102 | 294 | |
paul@102 | 295 | if (xdir) |
paul@102 | 296 | xorigin += xdir * SCROLL_XSTEP; |
paul@84 | 297 | |
paul@103 | 298 | /* For vertically-scaled backgrounds, the full resolution image |
paul@103 | 299 | is traversed by multiples of the scrolling increment. */ |
paul@103 | 300 | |
paul@94 | 301 | if (ydir) |
paul@102 | 302 | yorigin += ydir * SOURCE_YSTEP; |
paul@102 | 303 | |
paul@102 | 304 | /* Determine the magnitude of the scrolling required from this |
paul@102 | 305 | frame to the current origin. */ |
paul@102 | 306 | |
paul@102 | 307 | xstep = xorigin - xorigins[frame]; |
paul@102 | 308 | ystep = yorigin - yorigins[frame]; |
paul@102 | 309 | |
paul@102 | 310 | /* Scroll the frame. */ |
paul@102 | 311 | |
paul@102 | 312 | scroll_display(&display_config, xstep / SCROLL_XSTEP, |
paul@102 | 313 | ystep / SOURCE_YSTEP); |
paul@102 | 314 | |
paul@102 | 315 | /* Record the new screen start offset. */ |
paul@102 | 316 | |
paul@102 | 317 | frame_offset[frame] = get_start_offset(&display_config); |
paul@102 | 318 | |
paul@83 | 319 | /* For horizontal scrolling, plot the exposed column at the left |
paul@83 | 320 | (if scrolling left) or at the right (if scrolling right). */ |
paul@83 | 321 | |
paul@102 | 322 | if (xstep) |
paul@102 | 323 | plot_screen_edge(xorigin, yorigin, xstep); |
paul@83 | 324 | |
paul@102 | 325 | /* Record the origin for this frame. */ |
paul@84 | 326 | |
paul@102 | 327 | xorigins[frame] = xorigin; |
paul@102 | 328 | yorigins[frame] = yorigin; |
paul@74 | 329 | } |
paul@83 | 330 | |
paul@83 | 331 | /* Switch direction periodically. */ |
paul@83 | 332 | |
paul@94 | 333 | dirindex = wrap_value(dirindex + 1, 4); |
paul@83 | 334 | } |
paul@83 | 335 | } |
paul@74 | 336 | } |
paul@74 | 337 | |
paul@78 | 338 | /* Fill the screen with characters. */ |
paul@78 | 339 | |
paul@78 | 340 | static void write_chars(void) |
paul@78 | 341 | { |
paul@109 | 342 | const int line_height = 9; |
paul@78 | 343 | int x = 0, y = 0; |
paul@78 | 344 | char c; |
paul@78 | 345 | |
paul@78 | 346 | font_config.chars = (char_definition_t *) fontchars; |
paul@78 | 347 | font_config.table = fonttable; |
paul@78 | 348 | font_config.base = fontbase; |
paul@78 | 349 | font_config.limit = fontlimit; |
paul@78 | 350 | |
paul@109 | 351 | while (y + line_height < display_config.line_count) |
paul@109 | 352 | { |
paul@78 | 353 | for (c = (char) font_config.base; c < (char) font_config.limit; c++) |
paul@78 | 354 | { |
paul@109 | 355 | if (x + get_char_definition(&font_config, c)->width > display_config.line_length) |
paul@78 | 356 | { |
paul@109 | 357 | x = 0; y += line_height; |
paul@78 | 358 | } |
paul@109 | 359 | |
paul@109 | 360 | if (y + line_height >= display_config.line_count) |
paul@109 | 361 | break; |
paul@109 | 362 | |
paul@109 | 363 | x = write_char(&display_config, &font_config, c, x, y, 0xff); |
paul@78 | 364 | } |
paul@109 | 365 | } |
paul@78 | 366 | } |
paul@78 | 367 | |
paul@98 | 368 | /* Set up a background. */ |
paul@98 | 369 | |
paul@98 | 370 | static void setup(void) |
paul@98 | 371 | { |
paul@98 | 372 | int frame; |
paul@98 | 373 | |
paul@98 | 374 | for (frame = 0; frame < display_config.frames; frame++) |
paul@98 | 375 | { |
paul@98 | 376 | /* Obtain the frame. */ |
paul@98 | 377 | |
paul@98 | 378 | select_frame(&display_config, frame, 0); |
paul@98 | 379 | |
paul@98 | 380 | /* Plot the image centred on the screen. */ |
paul@98 | 381 | |
paul@101 | 382 | copy_display(&display_config, screendata, |
paul@101 | 383 | screendata_width, screendata_height, |
paul@101 | 384 | SOURCE_YSTEP, |
paul@98 | 385 | (display_config.line_length - screendata_width) / 2, |
paul@101 | 386 | (display_config.line_count - (screendata_height / SOURCE_YSTEP)) / 2, |
paul@101 | 387 | -1, 1); |
paul@98 | 388 | |
paul@98 | 389 | /* Write a sequence of characters. */ |
paul@98 | 390 | |
paul@98 | 391 | write_chars(); |
paul@98 | 392 | } |
paul@98 | 393 | |
paul@98 | 394 | select_frame(&display_config, 0, 0); |
paul@98 | 395 | } |
paul@98 | 396 | |
paul@24 | 397 | |
paul@24 | 398 | |
paul@24 | 399 | /* Main program. */ |
paul@24 | 400 | |
paul@24 | 401 | void main(void) |
paul@24 | 402 | { |
paul@24 | 403 | init_memory(); |
paul@24 | 404 | init_pins(); |
paul@24 | 405 | init_outputs(); |
paul@24 | 406 | |
paul@24 | 407 | unlock_config(); |
paul@24 | 408 | config_oc(); |
paul@24 | 409 | config_uart(); |
paul@24 | 410 | lock_config(); |
paul@24 | 411 | |
paul@87 | 412 | #ifndef TRANSFER_CPU |
paul@24 | 413 | init_dma(); |
paul@87 | 414 | #endif |
paul@57 | 415 | |
paul@72 | 416 | #ifdef PARALLEL_MODE |
paul@72 | 417 | init_pm(); |
paul@72 | 418 | |
paul@72 | 419 | /* Configure parallel master mode. */ |
paul@72 | 420 | |
paul@72 | 421 | pm_init(0, 0b10); |
paul@72 | 422 | pm_set_output(0, 1, 0); |
paul@72 | 423 | pm_on(0); |
paul@72 | 424 | #endif |
paul@72 | 425 | |
paul@93 | 426 | uart_init(1, FPB, 115200); |
paul@93 | 427 | uart_on(1); |
paul@93 | 428 | |
paul@93 | 429 | /* Initialise memory for a double-buffered display. */ |
paul@93 | 430 | |
paul@93 | 431 | init_display(&display_config, framebuffer, LINE_LENGTH, LINE_COUNT, FRAME_COUNT); |
paul@93 | 432 | |
paul@59 | 433 | /* Initialise VGA output with one or two line channels, configuring a line |
paul@59 | 434 | timer and any transfer timer, with an initiating channel being introduced |
paul@59 | 435 | if a transfer timer is specified. */ |
paul@57 | 436 | |
paul@59 | 437 | init_vga_with_timers(&display_config, LINE_CHANNELS, LINE_TIMER, TRANSFER_TIMER); |
paul@24 | 438 | |
paul@59 | 439 | /* Configure VGA output transfer to the output register, also configuring |
paul@59 | 440 | output compare units for horizontal and vertical sync. */ |
paul@24 | 441 | |
paul@72 | 442 | vga_configure_transfer(VGA_OUTPUT); |
paul@59 | 443 | vga_configure_sync(1, 2); |
paul@24 | 444 | |
paul@24 | 445 | interrupts_on(); |
paul@24 | 446 | |
paul@74 | 447 | /* Move a sprite around on the screen with a delay between each movement. */ |
paul@74 | 448 | |
paul@98 | 449 | setup(); |
paul@96 | 450 | animate(1 << 18); |
paul@24 | 451 | } |
paul@24 | 452 | |
paul@24 | 453 | |
paul@24 | 454 | |
paul@24 | 455 | /* Exception and interrupt handlers. */ |
paul@24 | 456 | |
paul@24 | 457 | void exception_handler(void) |
paul@24 | 458 | { |
paul@79 | 459 | blink(1 << 22, PORTA, LED_PIN); |
paul@24 | 460 | } |
paul@24 | 461 | |
paul@24 | 462 | void interrupt_handler(void) |
paul@24 | 463 | { |
paul@88 | 464 | vga_interrupt_handler(); |
paul@24 | 465 | } |
paul@24 | 466 | |
paul@24 | 467 | |
paul@24 | 468 | |
paul@24 | 469 | /* Peripheral pin configuration. */ |
paul@24 | 470 | |
paul@24 | 471 | void config_oc(void) |
paul@24 | 472 | { |
paul@72 | 473 | /* Map OC1. */ |
paul@24 | 474 | |
paul@72 | 475 | REG(OC1_PIN) = 0b0101; |
paul@24 | 476 | |
paul@72 | 477 | /* Map OC2. */ |
paul@24 | 478 | |
paul@72 | 479 | REG(OC2_PIN) = 0b0101; |
paul@24 | 480 | } |
paul@24 | 481 | |
paul@24 | 482 | void config_uart(void) |
paul@24 | 483 | { |
paul@24 | 484 | /* Map U1RX to RPB13. */ |
paul@24 | 485 | |
paul@24 | 486 | REG(U1RXR) = 0b0011; /* U1RXR<3:0> = 0011 (RPB13) */ |
paul@24 | 487 | |
paul@24 | 488 | /* Map U1TX to RPB15. */ |
paul@24 | 489 | |
paul@24 | 490 | REG(RPB15R) = 0b0001; /* RPB15R<3:0> = 0001 (U1TX) */ |
paul@24 | 491 | |
paul@24 | 492 | /* Set RPB13 to input. */ |
paul@24 | 493 | |
paul@24 | 494 | SET_REG(TRISB, 1 << 13); |
paul@24 | 495 | } |