⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app_connectivity.c

📁 BCM 控制demo源代码
💻 C
字号:
/*******************************************************************************/
/**
Copyright (c) 2008 Freescale Semiconductor
\file       app_Connectivity.c
\brief      CAN and LIN connectivity
\author     Freescale Semiconductor
\author     B05114
\version    0.1
\date       March/ 2008
*/
/*******************************************************************************/

/** S12X derivative information */ 
#include <MC9S12XEP100.h> 

#include "main.h"

/** MSCAN ID definitions and function prototypes */
#include "lle_MSCAN.h"

/** Timing function prototypes */
#include "lle_TIME.h"

/** Freescale LIN API */
#include <linapi.h>

/** Connectivity definitions and function prototypes */
#include "app_connectivity.h"


/** Error flag for CAN transmission*/
UINT8 u8ErrorFlag = NO_ERR;
/** CAN transmission buffer */
UINT8 u8TxBuffer[] = {0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80};

/** LIN transmited data  */
unsigned char u8LIN_MsgSent[2] = {0x55,0xAA}; 
/** LIN received data */                               
unsigned char u8LIN_MsgRcv[2];
/** LIN driver status */                                   
LINStatusType u8LINstatus;			           
 
/** Main board status report */
extern UINT8 boardStatus[]; 
 
/*******************************************************************************/
/**
* \brief    
* \author   B05114
* \param    
* \return   void 
*/
void app_initConnectivity(void)
{			    
	lle_CAN_Init(); /* Initialize MSCAN module */ 
		
    LIN_Init();	    /* Start LIN software driver */ 
    
    /* Initialize SCI7 trasmit collision detection */	
	SCI7SR2_AMAP = 1;  
	
	/* Receiver input sampling on 13th time tick of transmitted bit */                    
    SCI7ACR2_BERRM1 = 1;
    SCI7ACR2_BERRM0 = 0;
    
    /* Bit error interrupt enable */ 
    SCI7ACR1_BERRIE = 1;
  
	SCI7SR2_AMAP = 0;  	    
}

/*******************************************************************************/
/**
* \brief    Send CAN frame to specified ID
* \author   B05114
* \param    Identifier to be sent
* \return   void 
*/

void app_Send_CAN_Message(UINT32 u32CAN_ID)
{    
    LIN_StateFlagsInit(); /* LIN driver flags initialization */
    
    /* Load CAN frame on MSCAN module, 
    actual transmission will be handled automatically by MSCAN hardware */
    u8ErrorFlag = lle_CAN_SendFrame((u32CAN_ID),0x00, 
                                    sizeof(u8TxBuffer), u8TxBuffer);
}

/*******************************************************************************/
/**
* \brief    LIN frame transmission 
* \author   B05114
* \param    u8LIN_ID: Identifier of LIN slave
* \return   void 
*/
void app_LIN_Message(UINT8 u8LIN_ID)
{
    /* Necessary LIN driver flags initialization after
       LIN transmit colision is detected (done by SCI module) */
    LIN_StateFlagsInit();
    
    /* Load message buffer */
    u8LINstatus = LIN_PutMsg(u8LIN_ID, u8LIN_MsgSent); 
    
    /* Issue a request for message transmission */
    u8LINstatus = LIN_RequestMsg(u8LIN_ID);
    
    lle_Delay100us();
}

/*******************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -