📄 lin_con.c
字号:
/******************************************************************************
*
* Freescale Semiconductor Inc. 2006 All rights reserved
*
*******************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE SEMICONDUCTOR "AS IS" AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL FREESCALE SEMICONDUCTOR OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
***************************************************************************//*!
*
* @file lin_con.c
*
* @author R89994
*
* @version 1.0.4.0
*
* @date Jul-25-2006
*
* @brief This file contains routines for LIN connectivity
* initialization and messages processing.
*
* @note Compiler CodeWarrior HCS12X V4.1
*
******************************************************************************/
/******************************************************************************
* INCLUDE
******************************************************************************/
#include <linapi.h> /* LIN driver include */
#include "lin_con.h"
/******************************************************************************
* VARIABLES DEFINITION
******************************************************************************/
unsigned char MsgSent[2]; /* Transmited data */
LINStatusType ret; /* Variable for LIN driver processing */
/**************************************************************************//*!
*
* @brief User call-back.
* Called by the driver after successful transmission or receiving
* of the Master Request Command Frame (ID Field value '0x3C').
*
* @return Nothing
*
******************************************************************************/
void LIN_Command()
{
}
/***************************************************************************//*!
*
* @brief This module initializes the LIN driver flags.
*
* @return Nothing
*
* @remarks The LIN driver s/w does not change state of the LIN_StateFlags after
* the LIN transmit colision is detected by SCI module. Because of this,
* the LIN driver s/w is not capable of any other LIN connectivity
* handling.
* This module calls function, which initializes the LIN_StateFlags
* with LIN_FLAG_IGNORE. This enables correct driver functionality.
*
******************************************************************************/
void LIN_StateFlagsUpdate(void)
{
/* Set initial state -- this is abort any activity */
LIN_StateFlagsInit();
}
/***************************************************************************//*!
*
* @brief This module:
* - initializes LIN driver,
* - initializes LIN physical layer,
* - loads data for 0x17 message.
*
* @return Nothing
*
******************************************************************************/
void LIN_Module_Init(void)
{
/* Initialize LIN driver */
LIN_Init();
/* Initialize SCI0 trasmit collision detection */
/* Alternative control registers are sharing
the address space: module base + (0x0000 -> 0x0002) */
SCI0SR2_AMAP = 1;
/* Receiver input sampling on 13th time tick of transmitted bit */
SCI0ACR2_BERRM1 = 1;
SCI0ACR2_BERRM0 = 0;
/* Bit error interrupt enable */
SCI0ACR1_BERRIE = 1;
/* SCIBDH, SCIBDL and SCICR1 registers are sharing
the address space: module base + (0x0000 -> 0x0002) */
SCI0SR2_AMAP = 0;
/* Enable LIN Physical Interface (set normal baudrate ->
first TxD high, then toggle EN low-to-high) */
LIN1_EN = 1;
LIN1_EN_DDR = 1;
/* Load data for 0x17 message */
MsgSent[0] = 0x55;
MsgSent[1] = 0xAA;
}
/***************************************************************************//*!
*
* @brief This module sends frame with identifier 0x17.
*
* @return Nothing
*
* @remarks The 0x17 message processing takes 6.7ms on the LINbus
* with 9600Bd transmition speed.
*
******************************************************************************/
void LIN_Send_Frame(void)
{
/* Necessary LIN driver flags initialization after
LIN transmit colision is detected (done by SCI module) */
LIN_StateFlagsUpdate();
/* Update message */
ret = LIN_PutMsg(0x17, MsgSent);
/* Send a request for message */
ret = LIN_RequestMsg(0x17);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -