Documentation is an ongoing process...
Right now I have the XMOS StartKit connected to a separate PCB which houses a 24-bit RGB DAC, NTSC/PAL Video Encoder chip, misc. support components, and VGA, S-Video, and Composite Video output connectors.
Source Code
Source code is released under the GPL, can can be found at https://bitbucket.org/kpatterson/anacon-xc/
Project Layout
If you want to familiarize yourself with the code, I suggest taking a look at the header files first, starting at the top of the Repo.
The project is written in two main languages. xC exposes the hardware-level parallelism and event-driven nature of the xCore microcontroller in a simple way, so most I/O and timing routines are written in xC. However, C++ is my preferred language and eases the development of object-oriented hierarchies. Most of the code that does not require xC is written in C++. In particular, the graphics engine uses a "render list" of objects derived from a basic Rect class. xC and C++ don't mix in the same compilation unit, so "plain C" interfaces are used when calls need to be made back and forth. These "bridge" interfaces are typically encapsulated in ".h" header files.
Some file naming conventions:
- .h - "Standard C" header file, for inclusion anywhere needed
- .xc.h - xC header file. May use xC language-specific features, and should only be included in .xc source files.
- .hpp - C++ header file. May use C++ language-specific features, and should only be included in .cpp source files.
- .xc - xC source file
- .cpp - C++ source file
Hardware
Right now the project runs on an XMOS "StartKit" development board, which is only about $15. The StartKit features an XS-1 device with a single xCore tile available for use, supporting up to 8 hardware threads on 4 logical cores. The scanline rendering loop can run in multiple threads simultaneously, depending on how much performance you need. Right now I am using 2 threads, but any number from 1 to 4 (or more) should work if you monkey around with the code properly. Contact me for details on that until I get it better documented.
I'm pushing the pixels out of a 32-bit port, but the StartKit board does not expose all the pins. In particular, bits 20-27 of that port are not exposed on headers, so I have opted to output the RGB data on the lower 18 bits only, using 6 bits for each color. Full 24-bit data is generated internally and then "packed" using the PackPixel and PackPixels methods in src/Grafx/Screen.cpp. The code is these methods can be altered for different output.
I'm using an Exar CDK3404CTQ48 24-bit RGB DAC and Analog Devices AD724JRZ NSTC/PAL Video encoder. Support circuitry for these chips can be found in their datasheets, but I will probably be making some kind of board available in the future.
Pin Mappings
StartKit pin mappings for video output can be found at the top of the src/VideoOut.xc file. Video timing parameters (based on an internal 100 MHz clock) are currently set for interlaced NTSC (TV) video output, and can be found in the VideoOutInit() function at the bottom of the same file. PAL support should work with the right timing parameters, but has not been tested yet. The basic requirements for VGA output are there but it is not yet ready to be tested.
StartKit pin mappings for PS/2 input are around line 64 of src/UserInput/PS2/PS2.xc. Any number of PS/2 ports can be handled, but I have only mapped pins for two. I am using 4 pins per port (separate pins for input and output). You'll need an interface circuit between the StartKit and your PS/2 device(s). Figure 1 on this page will give you an idea. Keep in mind that the XS-1 chip on the StartKit does not have 5V-tolerant inputs, so you'll need to handle level conversion properly. Also, I'm using inverting logic in my interface circuit. There's a #define in src/Globals.h where you can change that. You can also change the number of PS/2 ports there.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.