//Project : memory_to_DAC.h
//Date    : 5/23/2005
//Author  : Curtis Rhodes
//Purpose : Holds constants and definitions for the audio player
// Synchronous Serial Port
//	    RC3 (pin 18) == SCL (Clock for Memory Chip)
//	    RC4 (pin 23) == SDA (Serial Data for Memory Chip)
//          
//Chip type   : PIC16F877A
//Clock frequency     : 20 MHz
//===================================================
// define constants
//===================================================

#define MEMORY_CHIP0_READ_CONTROL	0b10100001
#define MEMORY_CHIP1_READ_CONTROL	0b10100011
#define MEMORY_CHIP2_READ_CONTROL	0b10100101
#define MEMORY_CHIP3_READ_CONTROL	0b10100111
#define MEMORY_CHIP4_READ_CONTROL	0b10101001
#define MEMORY_CHIP5_READ_CONTROL	0b10101011
#define MEMORY_CHIP6_READ_CONTROL	0b10101101
#define MEMORY_CHIP7_READ_CONTROL	0b10101111

//===================================================
// function definitions
//===================================================
void rs232_initliazation(unsigned int, unsigned int);	// pass baud rate
void send_byte_to_PC(char);			// pass byte to be sent
void receive_byte_from_PC(char *);	// pass a pointer to get byte
void display_string(const char *, char length);	// pointer & length of a string

//I2C Subroutines
void send_Start_Bit();
void send_Stop_Bit();
void acknowledge();
void write_Data(unsigned int write_data);
void receive_Data();
void wait_For_Memory_Write_Completion(int control_byte);
void initializeI2C();
void memory_chip_write(unsigned char memory_chip, unsigned char address_high, unsigned char address_low, unsigned char data);
void portInitialization();
unsigned char memory_chip_read(unsigned char memory_chip, unsigned char address_high, unsigned char address_low);
void start_sequential_read(unsigned char memory_chip, unsigned char address_high, unsigned char address_low);
unsigned char sequential_memory_chip_read();
void end_sequential_read();
