Пример #1
0
/*!                                                                                                
**                                                                                                 
**                                                                                                 
** @param d                                                                                        
** @param id                                                                                       
**/   
void LssAlarmSDELAY(CO_Data* d, UNS32 id)
{	
	/* The first switch_delay period expired. Store the node state, change it
	 * so no CAN messages will be sent or received, call the ChangeBaudRate function*/
	if (d->lss_transfer.switchDelayState == SDELAY_FIRST)
	{
		MSG_WAR(0x3D0B, "LSS switch delay first period expired",0);

		d->lss_transfer.switchDelayState=SDELAY_SECOND;
		//(*d->lss_ChangeBaudRate)(d,d->lss_transfer.baudRate);
		canChangeBaudRate(d->lss_transfer.canHandle_t, d->lss_transfer.baudRate);
	} else
	{	 /* d->lss_transfer.switchDelayState==SDELAY_SECOND */
		MSG_WAR(0x3D0C, "LSS switch delay second period expired",0);
		d->lss_transfer.switchDelayState=SDELAY_OFF;
		StopLSS_SDELAY_TIMER();

		if (*(d->iam_a_slave))
		{
			d->canHandle=d->lss_transfer.canHandle_t;
		} else
		{
			d->lss_transfer.dat1=0;
			d->lss_transfer.state=LSS_FINISHED;

			/* Call the user function */
			if(d->lss_transfer.Callback)
			{
				(*d->lss_transfer.Callback)(d,d->lss_transfer.command);
			}
		}
	}
} 
Пример #2
0
void canInit(char* baud)
{
	GPIO_InitTypeDef GPIO_InitStructure;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);

	// Configure CAN pin: RX
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	// Configure CAN pin: TX
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	CAN_Int.NVIC_IRQChannelPreemptionPriority = 14;
	CAN_Int.NVIC_IRQChannelSubPriority = 0;

	CAN_Timing = &CAN_Timings[0];
	canChangeBaudRate(0, baud);

	canHWReinit();
}