#include <htc.h>
//hardware configuration
#define R GPIO0 //red on GPIO0
#define G GPIO1 //green on gpio1
#define B GPIO2 //blue on gpio2
#define HSync GPIO4 //hsync on gpio4
#define VSync GPIO5 //vsync on gpio5
//end hardware configuration
//macros
//function declaration
void mcu_init(void); //initialize the mcu;
//global variables
//1-bit colors for now
#define RED 0b00000001 //red is 0th bit
#define GREEN 0b00000010 //green is the 1st bit
#define BLUE 0b00000100 //BLUE is the 2nd bit
#define CLR_MASK RED|GREEN|BLUE //port mask used to set the output, value depends on hardware configuration. only the bits set to 1 will be changed.
#define BLACK 0b00000000 //black is nothing
#define H_Res 8 //horizontal resolution
#define V_Res 1 //vertical resolution, set at 1 for now.
const char Vid_RAM[V_Res][H_Res] = { //display ram
{RED, GREEN, BLUE, RED|GREEN, RED|BLUE, GREEN|BLUE, RED|GREEN|BLUE, BLACK}
};
void mcu_init(void) { //initialize the mcu
}
void
main(void)
{
int h_index, v_index; //horizontal and vertical indexes;
char GPIO_VandH; //GPIO's VSync and HSync bits;
mcu_init();
VSync=0; //Vsync is normally low;
HSync=0; //Hsync is normally low;
while (1){
//TODO Auto-generated main function
for (v_index=0; v_index<V_Res*0+200; v_index++){ //one line at a time, v_index should reach V_res but for now, we will try to just repeat the same line
for (h_index=0; h_index<H_Res; h_index++) { //now, generate each line
GPIO = Vid_RAM[0][h_index]; //output video ram's content
}
HSync=1; //send the hsync signal;
NOP();
NOP();
NOP();
HSync=0; //reset the hsync signal;
}
VSync=1; //send the VSync signal;
NOP(); //may need more nop;
VSync=0; //reset the Vsync signal;
}
}