///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 
// Copyright Nurve Networks LLC 2009
// 
// Filename: CHAM_AVR_HELLO_WORLD_01.C
//
// Original Author: Andre' LaMothe
// 
// Last Modified: 9.22.09
//
// Description: NTSC/VGA demo of "Hello World"
//  
// Overview: Simply prints out "Hello World!" to the NTSC and VGA screens in a few lines of code
// Chameleon PIC version nearly identical
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// __AVR_ATmega328P__ , __AVR_ATmega168__
#define __AVR_ATmega328P__ 

// include everything 
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <avr/eeprom.h>
#include <avr/io.h>
#include <avr/sleep.h>
#include <util/delay.h> 
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include <compat/twi.h>
#include <avr/wdt.h>

// include headers required for demo
#include "CHAM_AVR_SYSTEM_V010.h"             // you need this one always
#include "CHAM_AVR_TWI_SPI_DRV_V010.h"        // you need this always
#include "CHAM_AVR_NTSC_DRV_V010.h"           // needed for NTSC driver
#include "CHAM_AVR_VGA_DRV_V010.h"            // needed for VGA driver

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DEFINES AND MACROS /////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// define CPU frequency in Mhz here if not defined in Makefile or other includes, compiler will throw a warning, ignore
#ifndef F_CPU
#define F_CPU 16000000UL // 28636360UL, 14318180UL, 21477270 UL
#endif

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MAIN ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main(void)
{
// initialize and set SPI rate
SPI_Init( SPI_DEFAULT_RATE );

// clear screens
NTSC_ClearScreen();
VGA_ClearScreen();

// enter infinite loop...
while(1)
     {
     // print on NTSC terminal screen 
     NTSC_Color(0);
     NTSC_Term_Print("Hello World!   ");

     // print on VGA terminal screen
     VGA_Color(0);
     VGA_Term_Print("Hello World!   ");

     // slow things down a bit, so we can read the text!
     _delay_ms(10);

     } // end while    

} // end main
