; 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	"can_test"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "can_test.c"
; file "can_test.c":
;    1 |
;    2 |#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
;    3 |#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
;    4 |#include "CAN.h"
	.symb	FILE, "CAN.h"
	.symb	ENDF
;    5 |
;    6 |// Message Objekts sind konfiguriert:
;    7 |// Object 0 = CAN-A empfang
;    8 |// Object 1 = CAN-A senden
;    9 |// Object 2 = CAN-B empfang
;   10 |// Object 3 = CAN-B senden
;   11 |
;   12 |unsigned char ucCAN_Test(void);
;   13 |
;   14 |unsigned char ucCAN_Test(void)
;   15 |{
	.sdecl	"code.can_test",CODE
	.sect	"code.can_test"
	.align	4
	.symb	LINE, 15
	.symb	TYPE, 272, 'X', 8, #3, 26, 0
	.symb	GFUN, "ucCAN_Test", ucCAN_Test, #272, 0, 48, 0
	.symb	ALAB, ucCAN_Test, #272
ucCAN_Test:
	.symb	SOFF, 48
	.symb	IDEN, "CAN_A_rec", -48, #270, 129, 0x5
	.symb	IDEN, "CAN_B_rec", -28, #270, 129, 0x5
	.symb	IDEN, "i", -8, #3, 131, 0x5
	nop
	sub16.a	sp,#48
;   16 |TCAN_SWObj CAN_A_rec;
;   17 |TCAN_SWObj CAN_B_rec;
;   18 |unsigned char i;
;   19 |
;   20 |printf("Start of CAN1 and CAN2 test...\n");
	.symb	LINE, 20
	movh.a	a4,#@his(_17)
	lea	a4,[a4]@los(_17)
	callg	printf
;   21 |
;   22 |// CAN-A senden
;   23 |CAN_vTransmit(1);
	.symb	LINE, 23
	mov16	d4,#1				; 1
	callg	CAN_vTransmit
;   24 |//printf ("	CAN-A message sent\n");
;   25 |//CAN-B empfangen
;   26 |while (CAN_ubNewData(2) != 1) // warte auf Message in CAN-B
	.symb	LINE, 26
	j	_21
_20:
_21:
_22:
	mov16	d4,#2				; 2
	callg	CAN_ubNewData
	jne	d2,#1,_22
;   27 |	{
;   28 |//	printf ("	CAN-B waiting for message\n");
;   29 |	}
;   30 |//printf ("	CAN-B message recieved\n");
;   31 |CAN_vGetMsgObj(2,&CAN_B_rec); // hole Message CAN-B
	.symb	LINE, 31
	mov16	d4,#2				; 2
	lea	a4,[sp]20
	callg	CAN_vGetMsgObj
;   32 |CAN_vReleaseObj(2);  // lösche empfangene Message CAN-B
	.symb	LINE, 32
	mov16	d4,#2				; 2
	callg	CAN_vReleaseObj
;   33 |
;   34 |// CAN-B senden
;   35 |CAN_vTransmit(3);
	.symb	LINE, 35
	mov16	d4,#3				; 3
	callg	CAN_vTransmit
;   36 |//printf ("	CAN-B message sent\n");
;   37 |//CAN-A empfangen
;   38 |while (CAN_ubNewData(0) != 1) // warte auf Message in CAN-A
	.symb	LINE, 38
	j	_24
_23:
_24:
_25:
	mov16	d4,#0				; 0
	callg	CAN_ubNewData
	jne	d2,#1,_25
;   39 |	{
;   40 |//	printf ("	CAN-A waiting for message\n");
;   41 |	}
;   42 |//printf ("	CAN-A message recieved\n");
;   43 |CAN_vGetMsgObj(0,&CAN_A_rec); // hole Message von CAN-A
	.symb	LINE, 43
	mov16	d4,#0				; 0
	lea	a4,[sp]
	callg	CAN_vGetMsgObj
;   44 |CAN_vReleaseObj(0);  // lösche empfangene Message aus CAN-A
	.symb	LINE, 44
	mov16	d4,#0				; 0
	callg	CAN_vReleaseObj
;   45 |
;   46 |// printf("	Checking recieved Data...\n");
;   47 |for (i=0; i<=7; i++)
	.symb	LINE, 47
	mov16	d15,#0				; i
	st.b	[sp]40,d15			; i
	j	_28
_26:
;   48 |	{
;   49 |// 	printf ("CAN-B-Data = %2x  CAN-A-Data = %2x\n",
;   50 |// 			CAN_B_rec.ubData[i],(CAN_A_rec.ubData[i]-0x10));
;   51 |		if ((CAN_A_rec.ubData[i]-0x10) != CAN_B_rec.ubData[i])
	.symb	LINE, 51
	nop
	lea	a15,[sp]
	ld.bu	d15,[sp]40			; i
	addsc.a	a15,a15,d15,#0
	ld.bu	d15,[a15]10
	addi	d15,d15,#-16
	lea	a15,[sp]20
	ld.bu	d7,[sp]40			; i
	addsc.a	a15,a15,d7,#0
	ld.bu	d7,[a15]10
	jeq	d15,d7,_27
;   52 |			{
;   53 |			 printf("	ERROR: CAN data compare fails!\n");
	.symb	LINE, 53
	movh.a	a4,#@his(_18)
	lea	a4,[a4]@los(_18)
	callg	printf
;   54 |			 return(ucErrorFlag);
	.symb	LINE, 54
	ld.bu	d2,ucErrorFlag			; ucErrorFlag
	ret16
;   55 |			}
	.symb	LINE, 55
_27:
	.symb	LINE, 47
	nop
	ld.bu	d15,[sp]40			; i
	add16	d15,#1				; i
	st.b	[sp]40,d15			; i
_28:
	nop
	ld.bu	d15,[sp]40			; i
	lt	d15,d15,#8
	jne	d15,#0,_26
;   56 |	}
;   57 |
;   58 |printf("Both CAN´s are O.K.\n");
	.symb	LINE, 58
	movh.a	a4,#@his(_19)
	lea	a4,[a4]@los(_19)
	callg	printf
;   59 |return(ucErrorFlag);
	.symb	LINE, 59
	ld.bu	d2,ucErrorFlag			; ucErrorFlag
;   60 |}
	.symb	LINE, 60
_29:
	ret16
	.symb	EFUN
;   61 |
	.symb	ENDF
	.sdecl	"fardata.can_test",DATA,INIT
	.sect	"fardata.can_test"
	.align	4
_19:
	.ascii	"Both CAN´s are O.K."
	.byte	0x0a,0x00
	.symb	TYPE, 273, 'X', 8, #1, 26, 1, #3
	.symb	ALAB, CAN_vReleaseObj, #273
	.symb	ALAB, ucErrorFlag, #3
	.symb	TYPE, 274, 'X', 8, #1, 26, 1, #3
	.symb	ALAB, CAN_vTransmit, #274
	.align	2
_18:
	.ascii	"	ERROR: CAN data compare fails!"
	.byte	0x0a,0x00
	.symb	TYPE, 275, 'X', 8, #3, 26, 1, #3
	.symb	ALAB, CAN_ubNewData, #275
	.symb	TYPE, 276, 'X', 8, #16, 26, 2, #258, #1
	.symb	ALAB, printf, #276
	.symb	TYPE, 279, 'P', #270
	.symb	TYPE, 277, 'X', 8, #1, 26, 2, #3, #279
	.symb	ALAB, CAN_vGetMsgObj, #277
	.align	2
_17:
	.ascii	"Start of CAN1 and CAN2 test..."
	.byte	0x0a,0x00
	.global	ucCAN_Test
	.extern	(CODE) CAN_ubNewData
	.extern	(CODE) CAN_vGetMsgObj
	.extern	(CODE) CAN_vReleaseObj
	.extern	(CODE) CAN_vTransmit
	.extern	(CODE) printf
	.extern	(DATA,ABS18) ucErrorFlag
	.calls	"ucCAN_Test", "CAN_ubNewData"
	.calls	"ucCAN_Test", "CAN_vGetMsgObj"
	.calls	"ucCAN_Test", "CAN_vReleaseObj"
	.calls	"ucCAN_Test", "CAN_vTransmit"
	.calls	"ucCAN_Test", "printf"
