; main.asm
;
; Copyright (C) 2006,2007 Nuno Sucena Almeida
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
;

; Using a Microchip 16F88 @ 20MHz
; 4k (words) Flash
; 368 bytes RAM
; 256 bytes EEPROM
; AUSART, PWM, ADC, SSP, I2C, etc
;
; This is the controller code for ThE lEd mAtRiX


	include	<proc.inc>

	udata

;--------------------------------------------------------------------
; external functions
	extern	setup
	extern	uart_setup
	extern	uart_send
	extern	uart_receive
	extern	i2c_setup
	extern	i2c_ioe_setup
	extern	i2c_ioe_rotate
	extern	i2c_eeprom_setup
	extern	uart_send_ee_string
	extern	main_menu


;--------------------------------------------------------------------
; external symbols
	extern	ee_ct1fox
	extern	ee_prompt_ready
	extern	ee_OK


; without bootloader:	resetvector	code 0x00
;					goto	main
resetvector	code	0x00
		goto	main

	code
main:
mainrst:
	; PIC initialization
	call	setup
	; RS232 initialization
	call	uart_setup
	; I2C initialization
	call	i2c_setup
mainloop0:
	clrwdt
	; I2C I/O Expander initialization
   	call	i2c_ioe_setup

	; I2C EEPROM initialization
	call	i2c_eeprom_setup
;	goto	mainloop0

;    	movlw	ee_ct1fox
;    	call	uart_send_ee_string
mainloop1:
	clrwdt
 	movlw	ee_OK
 	call	uart_send_ee_string
; 	banksel	PORTA
; 	bsf	PORTA,0
; 	banksel	PORTA
; 	bcf	PORTA,0
;   	call	i2c_ioe_setup
;   	call	i2c_ioe_rotate
  	goto	main_menu
;	goto	i2c_eeprom_test	
	goto mainloop1

end