Exemplo n.º 1
0
void transmit_iso(iso_m *m)
{
//	byte i;
	
	do {
		CANTBSEL = CANTFLG;
	} while (CANTBSEL == 0);
	
/*	CANTIDR0 = m->priority<<5 | m->edp<<4 | m->dp<<3 | (m->pf)>>5;
	CANTIDR1 = 0x18 | (m->pf<<1 & 0x6) | (m->pf<<3 & 0xE0) | m->ps>>7;
	CANTIDR2 = m->ps<<1 | source_address>>7;
	CANTIDR3 = source_address<<1;		// note rtr bit is always 0 (data frame)*/
	
	m->bits.sa = source_address;
	CANTIDR = m->dw_id;
	
	/*for (i=0;i<m->bits.length;i++) {
		CANTDSR_ARR[i] = m->bits.data[i];
	} */
	_memcpy_8bitCount((void *)CANTDSR_ARR, m->bits.data, m->bits.length);
	CANTDLR = m->bits.length;
	
	if (!loopback_mode)
		print_to_serial(&CANTIDR0);

	
#if !LISTEN_ONLY_MODE
	// transmit the message
	CANTFLG = CANTBSEL;
#endif
}
Exemplo n.º 2
0
/*
	Function will print positive and negative integers up to 4 digits
*/
void print_int(int i)
{
	char arr[5] = {'0','0','0','0','0'};
	if(i < 0)
	{
		arr[0] = '-';
		i = -i;
	}
	arr[4] = '0' + (i % 10);
	i /=10;
	arr[3] = '0' + (i % 10);
	i /=10;
	arr[2] = '0' + (i % 10);
	i /=10;
	arr[1] = '0' + (i % 10);
	print_to_serial(arr, 5);
}
Exemplo n.º 3
0
//#define HEX_OUT
__interrupt VectorNumber_Vcanrx void receive_isr()
{

	if (!loopback_mode) {
		// if address claim message and not loopback, process message
		switch (CANIDAC_IDHIT) {
		case ISO_PDU1_HIT: iso_pdu1_rx(&CANRIDR0); break;	//TODO fix this
		}
	}
	
	
	print_to_serial(&CANRIDR0);
	
	// send message to main()
	//mainFlags |= F_CAN_RX;
	
	// clear interrupt flag
	CANRFLG_RXF = 1;
}