/******************************************************************************
Title:    lcd test
Author:   rue_mohr
Date:     Aug 19 2005
Software: AVR-GCC 3.3 
Hardware: atmega32
  
                         ATmega32 - 40 PIN DIP LAYOUT FOR DECODER AND PWM - 
                                      _______________________
                                      [ 1]PB0         PA0[40] <- up button
                                      [ 2]PB1         PA1[39] <- down button
                                      [ 3]PB2         PA2[38] 
                                      [ 4]PB3         PA3[37] 
                                      [ 5]PB4         PA4[36] 
                                      [ 6]PB5         PA5[35] 
                                      [ 7]PB6         PA6[34] 
                                      [ 8]PB7         PA7[33] 
                             RESET -> [ 9]RST        AREF[32] <- +5V VCC
                            5V VCC -> [10]VCC         GND[31] <- GROUND
                            GROUND -> [11]GND        AVCC[30] <- +5V VCC
                       16 MHZ XTAL -> [12]XTAL1       PC7[29] -> LCD DATA 7
                       16 MHZ XTAL -> [13]XTAL2       PC6[28] -> LCD DATA 6
                                      [14]PD0         PC5[27] -> LCD DATA 5
                                      [15]PD1         PC4[26] -> LCD DATA 4
                                      [16]PD2         PC3[25] -> LCD E  
                                      [17]PD3         PC2[24] -> LCD RS 
                                      [18]PD4         PC1[23] -> LCD RW 
                                      [19]PD5         PC0[22]                  
                                      [20]PD6         PD7[21]  
                                      ______________________                         


what this should do:
it should say "hello world"

    
*******************************************************************************/
 
/****************************| INCLUDGEABLES |********************************/
 
#include<avr/io.h>
#include "global.h"
#include "rprintf.h"
#include "timer.h"
#include "lcd.h"
/*****************************| DEFINIATIONS |********************************/
  
#define OUTPUT             1
#define INPUT              0

#define IsHigh(BIT, PORT)    ((PORT & (1<<BIT)) != 0)
#define IsLow(BIT, PORT)     ((PORT & (1<<BIT)) == 0)
#define SetBit(BIT, PORT)     PORT |= (1<<BIT)
#define ClearBit(BIT, PORT)   PORT &= ~(1<<BIT)

 
/*****************************| VARIDABLES |********************************/
 
 
/************************| FUNCTIONABLE DECLARITABLES |*************************/
 
 
/****************************| CODE... |***********************************/
 
int main (void)  {

  int n;

  DDRA = (INPUT << PA0 | INPUT << PA1 |OUTPUT << PA2 |INPUT << PA3 |INPUT << PA4 |INPUT << PA5 |INPUT << PA6 |INPUT << PA7);
  DDRB = (INPUT << PB0 | INPUT << PB1 |INPUT << PB2 |INPUT << PB3 |INPUT << PB4 |INPUT << PB5 |INPUT << PB6 |INPUT << PB7);
  DDRC = (INPUT << PC0 | INPUT << PC1 |INPUT << PC2 |INPUT << PC3 |INPUT << PC4 |INPUT << PC5 |INPUT << PC6 |INPUT << PC7);
  DDRD = (INPUT << PD0 | INPUT << PD1 |INPUT << PD2 |INPUT << PD3 |INPUT << PD4 |INPUT << PD5 |INPUT << PD6 |INPUT << PD7);        

  n = 10000;

  lcdInit();                  // initialize LCD on PortC, this will change the io of port C as it wishes        
  rprintfInit(lcdDataWrite);  // direct printf output to LCD
  lcdClear();                 // Clear LCD
  lcdGotoXY(0,0);	      // LCD Line 1 , Character 1
  rprintf("Cut the red wire!."); 	

  while(1) {
  
    Delay(65530);
    lcdGotoXY(0,1);	      // LCD Line 1 , Character 1
    rprintf("%d    ", n);
    n--; 
  
  }
  
  
}
    
//------------------------| FUNCTIONS |------------------------


void Delay(int delay) {
  int x;
  for (x = delay; x != 0; x--) {
    asm volatile ("nop"::); 
  }
}
