; TASKING TriCore C compiler v1.5r1 Build 322 SN 00090364
; options: -e -A1 -g -O0 -Id:\ctri\include -s -N8 -zTC112_COR1 -zTC112_COR4
;          -zTC112_COR10 -zTC112_COR13 -zTC112_COR14 -zTC112_COR16 -zTC112_COR17
	.name	"eeprom_test"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "eeprom_test.c"
; file "eeprom_test.c":
;    1 |// EEPROM_Test.c
;    2 |
;    3 |#include "stdio.h"
	.symb	FILE, "d:\\ctri\\include\\stdio.h"
	.symb	FILE, "d:\\ctri\\include\\stdarg.h"
	.symb	ENDF
	.symb	TYPE, 258, 'P', #2
	.symb	TYPE, 259, "_iobuf", 'S', 24,\
		 "_ptr", #258, 0,\
		 "_base", #258, 4,\
		 "_cnt", #16, 8,\
		 "_bufsiz", #16, 12,\
		 "_flag", #5, 16,\
		 "_file", #2, 18,\
		 "_wcnt", #16, 20
	.symb	TYPE, 260, "FILE", 'T', #259
	.symb	TYPE, 261, "va_list", 'T', #258
	.symb	TYPE, 262, "size_t", 'T', #18
	.symb	TYPE, 263, "fpos_t", 'T', #7
	.symb	TYPE, 264, "off_t", 'T', #6
	.symb	ENDF
;    4 |#include "main.h"
	.symb	FILE, "main.h"
	.symb	TYPE, 265, "uword", 'T', #18
	.symb	FILE, "TC1775BRegs.h"
	.symb	ENDF
	.symb	FILE, "IO.H"
	.symb	ENDF
	.symb	FILE, "ASC0.H"
	.symb	TYPE, 266, "ushort", 'T', #5
	.symb	ENDF
	.symb	FILE, "ASC1.H"
	.symb	ENDF
	.symb	FILE, "CAN.H"
	.symb	TYPE, 267, "ubyte", 'T', #3
	.symb	TYPE, 268, 'Z', #3, 7
	.symb	TYPE, 270, 'S', 20,\
		 "usMsgCfg", #5, 0,\
		 "uwID", #18, 2,\
		 "uwMask", #18, 6,\
		 "ubData", #268, 10,\
		 "usCounter", #5, 18
	.symb	TYPE, 271, "TCAN_SWObj", 'T', #270
	.symb	ENDF
	.symb	ENDF
;    5 |#include "i2c_bus.h"
	.symb	FILE, "i2c_bus.h"
	.symb	ENDF
;    6 |
;    7 |
;    8 |
;    9 |
;   10 |unsigned char ucTemperatur(void)
;   11 |{
	.sdecl	"code.eeprom_test",CODE
	.sect	"code.eeprom_test"
	.align	4
	.symb	LINE, 11
	.symb	TYPE, 272, 'X', 8, #3, 26, 0
	.symb	GFUN, "ucTemperatur", ucTemperatur, #272, 0, 16, 0
	.symb	ALAB, ucTemperatur, #272
ucTemperatur:
	.symb	SOFF, 16
	.symb	IDEN, "temp", -16, #3, 131, 0x5
	nop
	sub16.a	sp,#16
;   12 |unsigned char temp;
;   13 |
;   14 |I2CRead( &temp, 0x9F , 0x00 , 0x0001 , ADDR_8BIT);
	.symb	LINE, 14
	lea	a4,[sp]
	mov	d4,#159				; 159
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	mov16	d7,#0				; 0
	callg	I2CRead
;   15 |// negative or positiv Temperatur?
;   16 |if (temp > 125) //negative Temperatur
	.symb	LINE, 16
	ld16.bu	d15,[sp]			; temp
	ge	d15,d15,#126
	jeq	d15,#0,_17
;   17 |	{
;   18 |	temp = ~temp+1;
	.symb	LINE, 18
	ld16.bu	d15,[sp]			; temp
	xnor	d15,d15,#0
	add16	d15,#1
	st16.b	[sp],d15			; temp
;   19 |	}
	.symb	LINE, 19
_17:
;   20 |return (temp);
	.symb	LINE, 20
	nop
	ld16.bu	d2,[sp]				; temp
;   21 |}
	.symb	LINE, 21
_18:
	ret16
	.symb	EFUN
;   22 |
;   23 |
;   24 |unsigned char ucEEPromTest(void)
;   25 |	{
	.symb	LINE, 25
	.symb	TYPE, 273, 'X', 8, #3, 26, 0
	.symb	GFUN, "ucEEPromTest", ucEEPromTest, #273, 0, 32, 0
	.symb	ALAB, ucEEPromTest, #273
ucEEPromTest:
	.symb	SOFF, 32
	.symb	IDEN, "x", -32, #18, 131, 0x5
	.symb	IDEN, "y", -28, #18, 131, 0x5
	.symb	IDEN, "ucRead", -24, #3, 131, 0x5
	.symb	IDEN, "ucTestPat", -20, #3, 131, 0x5
	.symb	IDEN, "ucErrorFlag", -16, #3, 131, 0x5
	nop
	sub16.a	sp,#32
;   26 |	unsigned int x,y;
;   27 |	unsigned char ucRead;
;   28 |	unsigned char ucTestPat;
;   29 |	unsigned char ucErrorFlag;
;   30 |
;   31 |	ucTestPat = 0xA5;
	.symb	LINE, 31
	mov16	d15,#165			; ucTestPat
	st16.b	[sp]12,d15			; ucTestPat
;   32 |
;   33 |	printf("Testing EEPROM on U13...\n");
	.symb	LINE, 33
	movh.a	a4,#@his(_19)
	lea	a4,[a4]@los(_19)
	callg	printf
;   34 |	if (I2CWrite(&ucTestPat, 0xAC, 0x00, 0x01,ADDR_8BIT) != I2C_SUCCESSFUL)
	.symb	LINE, 34
	lea	a4,[sp]12
	mov	d4,#172				; 172
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	mov16	d7,#0				; 0
	callg	I2CWrite
	jeq	d2,#0,_24
;   35 |		{
;   36 |		printf("	ERROR: could not write to EEROM\n");
	.symb	LINE, 36
	movh.a	a4,#@his(_20)
	lea	a4,[a4]@los(_20)
	callg	printf
;   37 |		return (ucErrorFlag = 1);
	.symb	LINE, 37
	mov16	d2,#1				; 1
	st.b	[sp]16,d2			; ucErrorFlag
	ret16
;   38 |		}
	.symb	LINE, 38
_24:
;   39 |
;   40 |// wait for EEPROM to finish write Data
;   41 |	x=0;
	.symb	LINE, 41
	mov16	d15,#0				; x
	st16.w	[sp],d15			; x
;   42 |	y=0;
	.symb	LINE, 42
	mov16	d15,#0				; y
	st16.w	[sp]4,d15			; y
;   43 |	for(x=0;x<0x30000;x++)
	.symb	LINE, 43
	mov16	d15,#0				; x
	st16.w	[sp],d15			; x
	j	_26
_25:
;   44 |		{
;   45 |		y++;
	.symb	LINE, 45
	nop
	ld16.w	d15,[sp]4			; y
	add16	d15,#1				; y
	st16.w	[sp]4,d15			; y
	.symb	LINE, 43
	ld16.w	d15,[sp]			; x
	add16	d15,#1				; x
	st16.w	[sp],d15			; x
_26:
	nop
	ld16.w	d15,[sp]			; x
	movh	d7,#0x3				; 196608
	jlt.u	d15,d7,_25
;   46 |		}
;   47 |
;   48 |	if (I2CRead(&ucRead, 0xAC, 0x00, 0x01,ADDR_8BIT) != I2C_SUCCESSFUL)
	.symb	LINE, 48
	lea	a4,[sp]8
	mov	d4,#172				; 172
	mov16	d5,#0				; 0
	mov16	d6,#1				; 1
	mov16	d7,#0				; 0
	callg	I2CRead
	jeq	d2,#0,_27
;   49 |		{
;   50 |		printf("	ERROR: could not read from EEPROM\n");
	.symb	LINE, 50
	movh.a	a4,#@his(_21)
	lea	a4,[a4]@los(_21)
	callg	printf
;   51 |		return (ucErrorFlag = 1);
	.symb	LINE, 51
	mov16	d2,#1				; 1
	st.b	[sp]16,d2			; ucErrorFlag
	ret16
;   52 |		}
	.symb	LINE, 52
_27:
;   53 |
;   54 |	if (ucRead != ucTestPat) 
	.symb	LINE, 54
	nop
	ld16.bu	d15,[sp]8			; ucRead
	ld.bu	d7,[sp]12			; ucTestPat
	jeq	d15,d7,_28
;   55 |		{
;   56 |		printf("	ERROR: Data compare failed");
	.symb	LINE, 56
	movh.a	a4,#@his(_22)
	lea	a4,[a4]@los(_22)
	callg	printf
;   57 |		return (ucErrorFlag = 1);
	.symb	LINE, 57
	mov16	d2,#1				; 1
	st.b	[sp]16,d2			; ucErrorFlag
	ret16
;   58 |		}
	.symb	LINE, 58
_28:
;   59 |	else 
;   60 |		{
;   61 |		printf("	EEPROM Test O.K.");
	.symb	LINE, 61
	movh.a	a4,#@his(_23)
	lea	a4,[a4]@los(_23)
	callg	printf
;   62 |		return (ucErrorFlag = 0);
	.symb	LINE, 62
	mov16	d2,#0				; 0
	st.b	[sp]16,d2			; ucErrorFlag
;   63 |		}
;   64 |}
	.symb	LINE, 64
_31:
	ret16
	.symb	EFUN
	.symb	ENDF
	.symb	TYPE, 276, 'P', #3
	.symb	TYPE, 274, 'X', 8, #3, 26, 5, #276, #3, #5, #5, #3
	.symb	ALAB, I2CRead, #274
	.symb	TYPE, 277, 'X', 8, #3, 26, 5, #276, #3, #5, #5, #3
	.symb	ALAB, I2CWrite, #277
	.sdecl	"fardata.eeprom_test",DATA,INIT
	.sect	"fardata.eeprom_test"
	.align	4
_22:
	.ascii	"	ERROR: Data compare failed"
	.byte	0x00
	.symb	TYPE, 278, 'X', 8, #16, 26, 2, #258, #1
	.symb	ALAB, printf, #278
_23:
	.ascii	"	EEPROM Test O.K."
	.byte	0x00
_19:
	.ascii	"Testing EEPROM on U13..."
	.byte	0x0a,0x00
_20:
	.ascii	"	ERROR: could not write to EEROM"
	.byte	0x0a,0x00
_21:
	.ascii	"	ERROR: could not read from EEPROM"
	.byte	0x0a,0x00
	.align	4
	.global	ucEEPromTest
	.global	ucTemperatur
	.extern	(CODE) I2CRead
	.extern	(CODE) I2CWrite
	.extern	(CODE) printf
	.calls	"ucEEPromTest", "I2CRead"
	.calls	"ucEEPromTest", "I2CWrite"
	.calls	"ucEEPromTest", "printf"
	.calls	"ucTemperatur", "I2CRead"
