MTB CAT1 Peripheral driver library

General Description

Functions

cy_en_lin_status_t Cy_LIN_DeInit (LIN_CH_Type *base)
 Deinitialization of a LIN module. More...
 
cy_en_lin_status_t Cy_LIN_Init (LIN_CH_Type *base, const cy_stc_lin_config_t *pstcConfig)
 Initializes the LIN module. More...
 
cy_en_lin_status_t Cy_LIN_ReadData (LIN_CH_Type *base, uint8_t *data)
 Reads response data. More...
 
cy_en_lin_status_t Cy_LIN_WriteData (LIN_CH_Type *base, const uint8_t *data, uint8_t dataLength)
 Writes response data. More...
 
cy_en_lin_status_t Cy_LIN_Enable (LIN_CH_Type *base)
 Enables LIN channel. More...
 
cy_en_lin_status_t Cy_LIN_Disable (LIN_CH_Type *base)
 Disables LIN channel. More...
 
cy_en_lin_status_t Cy_LIN_SetBreakWakeupFieldLength (LIN_CH_Type *base, uint8_t length)
 Sets LIN break/wakeup field length. More...
 
cy_en_lin_status_t Cy_LIN_SetDataLength (LIN_CH_Type *base, uint8_t length)
 Sets LIN response field data length. More...
 
cy_en_lin_status_t Cy_LIN_SetChecksumType (LIN_CH_Type *base, cy_en_lin_checksum_type_t type)
 Sets LIN checksum type setting. More...
 
cy_en_lin_status_t Cy_LIN_SetCmd (LIN_CH_Type *base, uint32_t command)
 Sets LIN operation command. More...
 
cy_en_lin_status_t Cy_LIN_SetHeader (LIN_CH_Type *base, uint8_t id)
 Sets LIN header for master tx header operation. More...
 
cy_en_lin_status_t Cy_LIN_GetHeader (LIN_CH_Type *base, uint8_t *id, uint8_t *parity)
 Returns received LIN header. More...
 
cy_en_lin_status_t Cy_LIN_SetInterruptMask (LIN_CH_Type *base, uint32_t mask)
 Sets interrupt source to be accepted. More...
 
cy_en_lin_status_t Cy_LIN_GetInterruptMask (LIN_CH_Type *base, uint32_t *mask)
 Returns interrupt mask setting. More...
 
cy_en_lin_status_t Cy_LIN_GetInterruptMaskedStatus (LIN_CH_Type *base, uint32_t *status)
 Returns interrupt masked status. More...
 
cy_en_lin_status_t Cy_LIN_GetInterruptStatus (LIN_CH_Type *base, uint32_t *status)
 Returns interrupt raw status. More...
 
cy_en_lin_status_t Cy_LIN_ClearInterrupt (LIN_CH_Type *base, uint32_t mask)
 Clears interrupt status. More...
 
cy_en_lin_status_t Cy_LIN_GetStatus (LIN_CH_Type *base, uint32_t *status)
 Returns LIN module status. More...
 
cy_en_lin_status_t Cy_LIN_EnOut_Enable (LIN_CH_Type *base)
 Enables LIN channel 'en' out. More...
 
cy_en_lin_status_t Cy_LIN_EnOut_Disable (LIN_CH_Type *base)
 Disables LIN channel 'en' out. More...
 
cy_en_lin_status_t Cy_LIN_TestMode_Enable (LIN_Type *base, const cy_stc_lin_test_config_t *lin_test_config)
 Enables LIN Testing mode. More...
 
cy_en_lin_status_t Cy_LIN_TestMode_Disable (LIN_Type *base)
 Disables LIN Testing mode. More...
 
cy_en_lin_status_t Cy_LIN_ErrCtl_Enable (LIN_Type *base, cy_stc_lin_test_error_config_t *test_error_config)
 Enables LIN ERROR CTL. More...
 
cy_en_lin_status_t Cy_LIN_ErrCtl_Disable (LIN_Type *base)
 Disables LIN ERROR CTL. More...
 

Function Documentation

◆ Cy_LIN_DeInit()

cy_en_lin_status_t Cy_LIN_DeInit ( LIN_CH_Type *  base)

Deinitialization of a LIN module.

This function deinitializes the selected LIN channel.

Parameters
[in]basePointer to LIN instance channel register
Return values
Refercy_en_lin_status_t
Function Usage
if(CY_LIN_SUCCESS != Cy_LIN_DeInit (LIN0_CH0))
{
/* Insert error handling */
}

◆ Cy_LIN_Init()

cy_en_lin_status_t Cy_LIN_Init ( LIN_CH_Type *  base,
const cy_stc_lin_config_t pstcConfig 
)

Initializes the LIN module.

This function initializes LIN according to the options setup in the passed Config Struct. Several checkings are done before that and an error is returned if invalid Modes are requested.

Precondition
The Application must configure corresponding LIN pins (SIN, SOT) according to requirements and settings of LIN instance. And must set baud rate using SysClk. LIN I/F has internal fixed oversampling value (16). Therefore, LIN clock / 16 is actual baud rate.
Parameters
[in]basePointer to LIN instance register area
[in]pstcConfigLIN module configuration. See cy_stc_lin_config_t.
Return values
Refercy_en_lin_status_t
Function Usage
#define LIN_MASTER_CHANNEL LIN0_CH0
#define LIN_SLAVE_CHANNEL LIN0_CH1
const cy_stc_lin_config_t lin_0_ch0_config =
{
.masterMode = true,
.linTransceiverAutoEnable = true,
.breakFieldLength = 13,
.breakDelimiterLength = LIN_BREAK_DILIMITER_LENGTH_4BITS,
.stopBit = LIN_ONE_STOP_BIT,
.filterEnable = true,
};
if(CY_LIN_SUCCESS != Cy_LIN_Init(LIN0_CH0, &lin_0_ch0_config))
{
/* Insert error handling */
}

◆ Cy_LIN_ReadData()

cy_en_lin_status_t Cy_LIN_ReadData ( LIN_CH_Type *  base,
uint8_t *  data 
)

Reads response data.

Data is read in Bytes. Maximum data length is 8-bytes.

Precondition
Must be run after RX_RESPONSE_DONE.
Note
This function returns last received data set.
Parameters
base[in] Pointer to LIN instance register area.
data[out] Pointer to received data. Must have enough space for current Rx data.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN interrupt handler */
/*
* Master Interrupt handler
* Master Sends the header and wait for interrupts.
* If the Interrupt is for Tx Header Done then Header is transferred properly.
* If the interrupt is for Rx Response Done then Master reads the response.
* If the Interrupt is for Tx Response Done then response is transferred properly.
* Handle any Errors if there is an error interrupt.
*/
void lin_master_intHandler(void)
{
uint32_t status;
uint32_t maskStatus;
cy_en_lin_status_t linStatus;
Cy_LIN_GetInterruptMaskedStatus(LIN_MASTER_CHANNEL, &maskStatus);
if ((maskStatus & LIN_INTR_ALL_ERROR_MASK_MASTER) != 0u)
{
/* There are some error */
/* Handle error if needed. */
/* Disable the channel to reset LIN status */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);
/* Re-enable the channel */
Cy_LIN_Enable(LIN_MASTER_CHANNEL);
}
else
{
if(maskStatus & LIN_INTR_TX_HEADER_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE);
}
else if(maskStatus & LIN_INTR_TX_RESPONSE_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus);
}
else if(maskStatus & LIN_INTR_RX_RESPONSE_DONE)
{
memset(dstData, 0, LIN_DATA_LENGTH_MAX*sizeof(dstData[0]));
linStatus = Cy_LIN_ReadData(LIN_MASTER_CHANNEL, dstData);
if(linStatus != CY_LIN_SUCCESS)
{
/* Insert error handling */
}
else
{
status = memcmp(srcData, dstData, (LIN_DATA_LENGTH_MAX*sizeof(dstData[0])));
if (status !=0)
{
/* Insert error handling */
}
}
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus); /* Clear all accepted interrupt. */
}
}
}

◆ Cy_LIN_WriteData()

cy_en_lin_status_t Cy_LIN_WriteData ( LIN_CH_Type *  base,
const uint8_t *  data,
uint8_t  dataLength 
)

Writes response data.

Data is written in Bytes. Maximum data length is 8-bytes.

Parameters
base[in] Pointer to LIN instance register area.
data[in] Pointer to response data.
dataLength[in] Data length in bytes.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN reception callback */
/*
* Master setCmd function
* Sets the interrupt mask for desired interrupt callback notification.
* Sets the command based on the type of command to be sent.
* Master always sends the header.
*/
void lin_master_setCmd(void)
{
cy_en_lin_status_t linStatus;
/* LIN operation */
linStatus = Cy_LIN_SetInterruptMask(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE | LIN_INTR_TX_RESPONSE_DONE | LIN_INTR_RX_RESPONSE_DONE | LIN_INTR_ALL_ERROR_MASK_SLAVE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetChecksumType(LIN_MASTER_CHANNEL,LIN_CHECKSUM_TYPE_EXTENDED);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetHeader(LIN_MASTER_CHANNEL, master_msgContext[scheduleIdx].id);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetDataLength(LIN_MASTER_CHANNEL, LIN_DATA_LENGTH_MAX);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
if((master_msgContext[scheduleIdx].id == 0x02) || (master_msgContext[scheduleIdx].id == 0x11))
{
linStatus = Cy_LIN_WriteData(LIN_MASTER_CHANNEL, srcData, LIN_DATA_LENGTH_MAX);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetCmd(LIN_MASTER_CHANNEL, LIN_CMD_TX_HEADER_TX_RESPONSE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
}
else
{
linStatus = Cy_LIN_SetCmd(LIN_MASTER_CHANNEL, LIN_CMD_TX_HEADER_RX_RESPONSE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
}
}

◆ Cy_LIN_Enable()

cy_en_lin_status_t Cy_LIN_Enable ( LIN_CH_Type *  base)

Enables LIN channel.

Parameters
base[in] Pointer to LIN instance register area.
Return values
Refercy_en_lin_status_t
Function Usage
if(CY_LIN_SUCCESS != Cy_LIN_Enable(LIN0_CH0))
{
/* Insert error handling */
}

◆ Cy_LIN_Disable()

cy_en_lin_status_t Cy_LIN_Disable ( LIN_CH_Type *  base)

Disables LIN channel.

Disabling LIN channel causes clearing of non retained registers. e.g) CMD register, INTR register, STATUS register. This behavior can be used for re-initialization, after error or abort RX operation.

Parameters
base[in] Pointer to LIN instance register area.
Return values
Refercy_en_lin_status_t
Function Usage
if(CY_LIN_SUCCESS != Cy_LIN_Disable(LIN0_CH0))
{
/* Insert error handling */
}

◆ Cy_LIN_SetBreakWakeupFieldLength()

cy_en_lin_status_t Cy_LIN_SetBreakWakeupFieldLength ( LIN_CH_Type *  base,
uint8_t  length 
)

Sets LIN break/wakeup field length.

Normally this I/F is used for detection of the wakeup pulse.

Parameters
base[in] Pointer to LIN instance register area.
length[in] Bit length of the break/wakeup field.
Return values
Refercy_en_lin_status_t

◆ Cy_LIN_SetDataLength()

cy_en_lin_status_t Cy_LIN_SetDataLength ( LIN_CH_Type *  base,
uint8_t  length 
)

Sets LIN response field data length.

Data is in Bytes and maximum data length is 8-bytes.

Parameters
base[in] Pointer to LIN instance register area.
length[in] Data length in byte
Return values
Refercy_en_lin_status_t
Function Usage
{
/* Insert error handling */
}

◆ Cy_LIN_SetChecksumType()

cy_en_lin_status_t Cy_LIN_SetChecksumType ( LIN_CH_Type *  base,
cy_en_lin_checksum_type_t  type 
)

Sets LIN checksum type setting.

Parameters
base[in] Pointer to LIN instance register area.
type[in] Checksum type. Refer cy_en_lin_checksum_type_t
Return values
Refercy_en_lin_status_t
Function Usage
{
/* Insert error handling */
}

◆ Cy_LIN_SetCmd()

cy_en_lin_status_t Cy_LIN_SetCmd ( LIN_CH_Type *  base,
uint32_t  command 
)

Sets LIN operation command.

Note
As a normal usage, following combinations are used.
  • Master Header TX only : LIN_CMD_TX_HEADER Header TX & TX response : LIN_CMD_TX_HEADER_TX_RESPONSE Header TX & RX response : LIN_CMD_TX_HEADER_RX_RESPONSE
  • Slave Header RX : LIN_CMD_RX_HEADER_RX_RESPONSE TX response : LIN_CMD_TX_RESPONSE RX response : Already set when header RX As a typical usage, RX response is always set at header RX phase.
  • Wakeup frame : LIN_CMD_TX_WAKEUP Instead of above macro, you can use raw definition LIN_CH_CMD_*_Msk defined in IO header file.
Parameters
base[in] Pointer to LIN instance register area.
command[in] Required operation command. Refer LIN Command Type Definition
Return values
Refercy_en_lin_status_t
Function Usage
{
/* Insert error handling */
}

◆ Cy_LIN_SetHeader()

cy_en_lin_status_t Cy_LIN_SetHeader ( LIN_CH_Type *  base,
uint8_t  id 
)

Sets LIN header for master tx header operation.

Parameters
base[in] Pointer to LIN instance register area.
id[in] ID value
Return values
Refercy_en_lin_status_t
Function Usage
uint8_t id = 0x01; /* frame identifier of the predefined messages agreed between master and slave. */
if(CY_LIN_SUCCESS != Cy_LIN_SetHeader(LIN0_CH0, id))
{
/* Insert error handling */
}

◆ Cy_LIN_GetHeader()

cy_en_lin_status_t Cy_LIN_GetHeader ( LIN_CH_Type *  base,
uint8_t *  id,
uint8_t *  parity 
)

Returns received LIN header.

Parameters
base[in] Pointer to LIN instance register area.
id[out] Received ID value.
parity[out] Received parity value. Note that parity check is always done by HW automatically.
Return values
Refercy_en_lin_status_t

◆ Cy_LIN_SetInterruptMask()

cy_en_lin_status_t Cy_LIN_SetInterruptMask ( LIN_CH_Type *  base,
uint32_t  mask 
)

Sets interrupt source to be accepted.

Parameters
base[in] Pointer to LIN instance register area.
mask[in] The mask with the OR of the interrupt source to be accepted. See LIN ALL Interrupt Mask Definition for the set of constants.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN reception callback */
/*
* Master setCmd function
* Sets the interrupt mask for desired interrupt callback notification.
* Sets the command based on the type of command to be sent.
* Master always sends the header.
*/
void lin_master_setCmd(void)
{
cy_en_lin_status_t linStatus;
/* LIN operation */
linStatus = Cy_LIN_SetInterruptMask(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE | LIN_INTR_TX_RESPONSE_DONE | LIN_INTR_RX_RESPONSE_DONE | LIN_INTR_ALL_ERROR_MASK_SLAVE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetChecksumType(LIN_MASTER_CHANNEL,LIN_CHECKSUM_TYPE_EXTENDED);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetHeader(LIN_MASTER_CHANNEL, master_msgContext[scheduleIdx].id);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetDataLength(LIN_MASTER_CHANNEL, LIN_DATA_LENGTH_MAX);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
if((master_msgContext[scheduleIdx].id == 0x02) || (master_msgContext[scheduleIdx].id == 0x11))
{
linStatus = Cy_LIN_WriteData(LIN_MASTER_CHANNEL, srcData, LIN_DATA_LENGTH_MAX);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetCmd(LIN_MASTER_CHANNEL, LIN_CMD_TX_HEADER_TX_RESPONSE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
}
else
{
linStatus = Cy_LIN_SetCmd(LIN_MASTER_CHANNEL, LIN_CMD_TX_HEADER_RX_RESPONSE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
}
}

◆ Cy_LIN_GetInterruptMask()

cy_en_lin_status_t Cy_LIN_GetInterruptMask ( LIN_CH_Type *  base,
uint32_t *  mask 
)

Returns interrupt mask setting.

Parameters
base[in] Pointer to LIN instance register area.
mask[out] The mask with the OR of the interrupt source which is masked. See LIN ALL Interrupt Mask Definition for the set of constants.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN reception callback */
/*
* Master setCmd function
* Sets the interrupt mask for desired interrupt callback notification.
* Sets the command based on the type of command to be sent.
* Master always sends the header.
*/
void lin_master_setCmd(void)
{
cy_en_lin_status_t linStatus;
/* LIN operation */
linStatus = Cy_LIN_SetInterruptMask(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE | LIN_INTR_TX_RESPONSE_DONE | LIN_INTR_RX_RESPONSE_DONE | LIN_INTR_ALL_ERROR_MASK_SLAVE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetChecksumType(LIN_MASTER_CHANNEL,LIN_CHECKSUM_TYPE_EXTENDED);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetHeader(LIN_MASTER_CHANNEL, master_msgContext[scheduleIdx].id);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetDataLength(LIN_MASTER_CHANNEL, LIN_DATA_LENGTH_MAX);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
if((master_msgContext[scheduleIdx].id == 0x02) || (master_msgContext[scheduleIdx].id == 0x11))
{
linStatus = Cy_LIN_WriteData(LIN_MASTER_CHANNEL, srcData, LIN_DATA_LENGTH_MAX);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
linStatus = Cy_LIN_SetCmd(LIN_MASTER_CHANNEL, LIN_CMD_TX_HEADER_TX_RESPONSE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
}
else
{
linStatus = Cy_LIN_SetCmd(LIN_MASTER_CHANNEL, LIN_CMD_TX_HEADER_RX_RESPONSE);
if(CY_LIN_SUCCESS != linStatus)
{
/* Insert error handling */
}
}
}

◆ Cy_LIN_GetInterruptMaskedStatus()

cy_en_lin_status_t Cy_LIN_GetInterruptMaskedStatus ( LIN_CH_Type *  base,
uint32_t *  status 
)

Returns interrupt masked status.

Parameters
base[in] Pointer to LIN instance register area.
status[out] The mask with the OR of the interrupt source which occurs. See LIN ALL Interrupt Mask Definition for the set of constants.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN interrupt handler */
/*
* Master Interrupt handler
* Master Sends the header and wait for interrupts.
* If the Interrupt is for Tx Header Done then Header is transferred properly.
* If the interrupt is for Rx Response Done then Master reads the response.
* If the Interrupt is for Tx Response Done then response is transferred properly.
* Handle any Errors if there is an error interrupt.
*/
void lin_master_intHandler(void)
{
uint32_t status;
uint32_t maskStatus;
cy_en_lin_status_t linStatus;
Cy_LIN_GetInterruptMaskedStatus(LIN_MASTER_CHANNEL, &maskStatus);
if ((maskStatus & LIN_INTR_ALL_ERROR_MASK_MASTER) != 0u)
{
/* There are some error */
/* Handle error if needed. */
/* Disable the channel to reset LIN status */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);
/* Re-enable the channel */
Cy_LIN_Enable(LIN_MASTER_CHANNEL);
}
else
{
if(maskStatus & LIN_INTR_TX_HEADER_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE);
}
else if(maskStatus & LIN_INTR_TX_RESPONSE_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus);
}
else if(maskStatus & LIN_INTR_RX_RESPONSE_DONE)
{
memset(dstData, 0, LIN_DATA_LENGTH_MAX*sizeof(dstData[0]));
linStatus = Cy_LIN_ReadData(LIN_MASTER_CHANNEL, dstData);
if(linStatus != CY_LIN_SUCCESS)
{
/* Insert error handling */
}
else
{
status = memcmp(srcData, dstData, (LIN_DATA_LENGTH_MAX*sizeof(dstData[0])));
if (status !=0)
{
/* Insert error handling */
}
}
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus); /* Clear all accepted interrupt. */
}
}
}

◆ Cy_LIN_GetInterruptStatus()

cy_en_lin_status_t Cy_LIN_GetInterruptStatus ( LIN_CH_Type *  base,
uint32_t *  status 
)

Returns interrupt raw status.

Parameters
base[in] Pointer to LIN instance register area.
status[out] The mask with the OR of the interrupt source which occurs. See LIN ALL Interrupt Mask Definition for the set of constants.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN interrupt handler */
/*
* Master Interrupt handler
* Master Sends the header and wait for interrupts.
* If the Interrupt is for Tx Header Done then Header is transferred properly.
* If the interrupt is for Rx Response Done then Master reads the response.
* If the Interrupt is for Tx Response Done then response is transferred properly.
* Handle any Errors if there is an error interrupt.
*/
void lin_master_intHandler(void)
{
uint32_t status;
uint32_t maskStatus;
cy_en_lin_status_t linStatus;
Cy_LIN_GetInterruptMaskedStatus(LIN_MASTER_CHANNEL, &maskStatus);
if ((maskStatus & LIN_INTR_ALL_ERROR_MASK_MASTER) != 0u)
{
/* There are some error */
/* Handle error if needed. */
/* Disable the channel to reset LIN status */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);
/* Re-enable the channel */
Cy_LIN_Enable(LIN_MASTER_CHANNEL);
}
else
{
if(maskStatus & LIN_INTR_TX_HEADER_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE);
}
else if(maskStatus & LIN_INTR_TX_RESPONSE_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus);
}
else if(maskStatus & LIN_INTR_RX_RESPONSE_DONE)
{
memset(dstData, 0, LIN_DATA_LENGTH_MAX*sizeof(dstData[0]));
linStatus = Cy_LIN_ReadData(LIN_MASTER_CHANNEL, dstData);
if(linStatus != CY_LIN_SUCCESS)
{
/* Insert error handling */
}
else
{
status = memcmp(srcData, dstData, (LIN_DATA_LENGTH_MAX*sizeof(dstData[0])));
if (status !=0)
{
/* Insert error handling */
}
}
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus); /* Clear all accepted interrupt. */
}
}
}

◆ Cy_LIN_ClearInterrupt()

cy_en_lin_status_t Cy_LIN_ClearInterrupt ( LIN_CH_Type *  base,
uint32_t  mask 
)

Clears interrupt status.

Parameters
base[in] Pointer to LIN instance register area.
mask[in] The mask with the OR of the interrupt source to be cleared. See LIN ALL Interrupt Mask Definition for the set of constants.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN interrupt handler */
/*
* Master Interrupt handler
* Master Sends the header and wait for interrupts.
* If the Interrupt is for Tx Header Done then Header is transferred properly.
* If the interrupt is for Rx Response Done then Master reads the response.
* If the Interrupt is for Tx Response Done then response is transferred properly.
* Handle any Errors if there is an error interrupt.
*/
void lin_master_intHandler(void)
{
uint32_t status;
uint32_t maskStatus;
cy_en_lin_status_t linStatus;
Cy_LIN_GetInterruptMaskedStatus(LIN_MASTER_CHANNEL, &maskStatus);
if ((maskStatus & LIN_INTR_ALL_ERROR_MASK_MASTER) != 0u)
{
/* There are some error */
/* Handle error if needed. */
/* Disable the channel to reset LIN status */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);
/* Re-enable the channel */
Cy_LIN_Enable(LIN_MASTER_CHANNEL);
}
else
{
if(maskStatus & LIN_INTR_TX_HEADER_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE);
}
else if(maskStatus & LIN_INTR_TX_RESPONSE_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus);
}
else if(maskStatus & LIN_INTR_RX_RESPONSE_DONE)
{
memset(dstData, 0, LIN_DATA_LENGTH_MAX*sizeof(dstData[0]));
linStatus = Cy_LIN_ReadData(LIN_MASTER_CHANNEL, dstData);
if(linStatus != CY_LIN_SUCCESS)
{
/* Insert error handling */
}
else
{
status = memcmp(srcData, dstData, (LIN_DATA_LENGTH_MAX*sizeof(dstData[0])));
if (status !=0)
{
/* Insert error handling */
}
}
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus); /* Clear all accepted interrupt. */
}
}
}

◆ Cy_LIN_GetStatus()

cy_en_lin_status_t Cy_LIN_GetStatus ( LIN_CH_Type *  base,
uint32_t *  status 
)

Returns LIN module status.

Parameters
base[in] Pointer to LIN instance register area.
status[out] LIN module status.
Return values
Refercy_en_lin_status_t
Function Usage
/* LIN interrupt handler */
/*
* Master Interrupt handler
* Master Sends the header and wait for interrupts.
* If the Interrupt is for Tx Header Done then Header is transferred properly.
* If the interrupt is for Rx Response Done then Master reads the response.
* If the Interrupt is for Tx Response Done then response is transferred properly.
* Handle any Errors if there is an error interrupt.
*/
void lin_master_intHandler(void)
{
uint32_t status;
uint32_t maskStatus;
cy_en_lin_status_t linStatus;
Cy_LIN_GetInterruptMaskedStatus(LIN_MASTER_CHANNEL, &maskStatus);
if ((maskStatus & LIN_INTR_ALL_ERROR_MASK_MASTER) != 0u)
{
/* There are some error */
/* Handle error if needed. */
/* Disable the channel to reset LIN status */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);
/* Re-enable the channel */
Cy_LIN_Enable(LIN_MASTER_CHANNEL);
}
else
{
if(maskStatus & LIN_INTR_TX_HEADER_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, LIN_INTR_TX_HEADER_DONE);
}
else if(maskStatus & LIN_INTR_TX_RESPONSE_DONE)
{
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus);
}
else if(maskStatus & LIN_INTR_RX_RESPONSE_DONE)
{
memset(dstData, 0, LIN_DATA_LENGTH_MAX*sizeof(dstData[0]));
linStatus = Cy_LIN_ReadData(LIN_MASTER_CHANNEL, dstData);
if(linStatus != CY_LIN_SUCCESS)
{
/* Insert error handling */
}
else
{
status = memcmp(srcData, dstData, (LIN_DATA_LENGTH_MAX*sizeof(dstData[0])));
if (status !=0)
{
/* Insert error handling */
}
}
Cy_LIN_ClearInterrupt(LIN_MASTER_CHANNEL, maskStatus); /* Clear all accepted interrupt. */
}
}
}

◆ Cy_LIN_EnOut_Enable()

cy_en_lin_status_t Cy_LIN_EnOut_Enable ( LIN_CH_Type *  base)

Enables LIN channel 'en' out.

If linTransceiverAutoEnable in cy_stc_lin_config_t config structure is set to true then transceiver is set automatically and user need not call this function, else user has to call Cy_Status_EnOut_Enable() before sending a message and call Cy_Status_EnOut_Disable() after sending the message.

Parameters
base[in] Pointer to LIN instance register area.
Return values
Refercy_en_lin_status_t
Function Usage
if(CY_LIN_SUCCESS != Cy_LIN_Init(LIN_MASTER_CHANNEL, &lin_0_ch0_config))
{
/* Error processing */
}
/* Enables the configuration changes to set Test mode */
Cy_LIN_EnOut_Enable(LIN_MASTER_CHANNEL);
/* Sets the Test mode configuration */
const cy_stc_lin_test_config_t lin_test_cfg =
{
/* .chidx */ 0UL, /* channel index */
/* .mode */ 1UL
};
Cy_LIN_TestMode_Enable(LIN0, &lin_test_cfg);
/* Disables the configuration changes */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);

◆ Cy_LIN_EnOut_Disable()

cy_en_lin_status_t Cy_LIN_EnOut_Disable ( LIN_CH_Type *  base)

Disables LIN channel 'en' out.

If linTransceiverAutoEnable in cy_stc_lin_config_t config structure is set to true then transceiver is set automatically and user need not call this function, else user has to call Cy_Status_EnOut_Enable() before sending a message and call Cy_Status_EnOut_Disable() after sending the message.

Parameters
base[in] Pointer to LIN instance register area.
Return values
Refercy_en_lin_status_t

◆ Cy_LIN_TestMode_Enable()

cy_en_lin_status_t Cy_LIN_TestMode_Enable ( LIN_Type *  base,
const cy_stc_lin_test_config_t lin_test_config 
)

Enables LIN Testing mode.

This testing functionality simplifies SW development, but may also be used in the field to verify correct channel functionality.

Parameters
base[in] Pointer to LIN instance register area.
lin_test_config[in] pointer to Test configuration structure.
Return values
Refercy_en_lin_status_t
Function Usage
if(CY_LIN_SUCCESS != Cy_LIN_Init(LIN_MASTER_CHANNEL, &lin_0_ch0_config))
{
/* Error processing */
}
/* Enables the configuration changes to set Test mode */
Cy_LIN_EnOut_Enable(LIN_MASTER_CHANNEL);
/* Sets the Test mode configuration */
const cy_stc_lin_test_config_t lin_test_cfg =
{
/* .chidx */ 0UL, /* channel index */
/* .mode */ 1UL
};
Cy_LIN_TestMode_Enable(LIN0, &lin_test_cfg);
/* Disables the configuration changes */
Cy_LIN_Disable(LIN_MASTER_CHANNEL);

◆ Cy_LIN_TestMode_Disable()

cy_en_lin_status_t Cy_LIN_TestMode_Disable ( LIN_Type *  base)

Disables LIN Testing mode.

This testing functionality simplifies SW development, but may also be used in the field to verify correct channel functionality.

Parameters
base[in] Pointer to LIN instance register area.
Return values
Refercy_en_lin_status_t

◆ Cy_LIN_ErrCtl_Enable()

cy_en_lin_status_t Cy_LIN_ErrCtl_Enable ( LIN_Type *  base,
cy_stc_lin_test_error_config_t test_error_config 
)

Enables LIN ERROR CTL.

Enables HW injected channel transmitter errors. The receiver should detect these errors and report these errors through activation of corresponding interrupt causes.

Parameters
base[in] Pointer to LIN instance register area.
test_error_config[in] pointer to Test Error configuration structure.
Return values
Refercy_en_lin_status_t

◆ Cy_LIN_ErrCtl_Disable()

cy_en_lin_status_t Cy_LIN_ErrCtl_Disable ( LIN_Type *  base)

Disables LIN ERROR CTL.

Disables HW injected channel transmitter errors.

Parameters
base[in] Pointer to LIN instance register area.
Return values
Refercy_en_lin_status_t