/**
 * Sends DEADBEEF out the UART pins.
 *
 * Written to put the EEPROM argument to rest.
 * It creates code that LOOKS broken, but is so broken it actually 
 * works.  EEPROM data apparently needs to be 16-bit aligned for some 
 * reason, and the useless 'retlw' instruction that doesn't even belong 
 * in EEPROM makes it line up just right.
 *
 * So in the end we get DEADBEEF out of the EEPROM, character by 
 * character, despite it all.
 */

#define BAUD 9600L
#define BAUD_HI 1L
#define KHZ 4000L

#define __16f628a
#include "pic14/pic16f628a.h"
#include "tsmtypes.h"
#include "tsmserial.h"
#include "tsmee.h"

// Set the __CONFIG word:
Uint16 at 0x2007  __CONFIG = CONFIG_WORD;

// These are fixed.  The 16f628a can only use these as transmit and recieve.
#define TX_PORT	2
#define RX_PORT	1
#define TX_BIT	(1<<TX_PORT)
#define RX_BIT	(1<<RX_PORT)

__code Uint32 __at 0x2100 t=0xdeadbeef;

void main(void)
{
	static unsigned char i;

	TRISB=TX_BIT|RX_BIT;	// These need to be 1 for USART to work

	ASYNC_INIT();


	// Send in reverse order.
	SENDHEX(EEPROM_READ_ADDRESS(0^3));
	SENDHEX(EEPROM_READ_ADDRESS(1^3));
	SENDHEX(EEPROM_READ_ADDRESS(2^3));
	SENDHEX(EEPROM_READ_ADDRESS(3^3));

	while(1);	// Loop forever.
}

