<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: trying to execute the following code the following error occurs in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750119#M30207</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THANK YOU FOR YOUR SUPPORT.&lt;/P&gt;&lt;P&gt;I am using lpc1769 and the program code is from the lpcopen&amp;nbsp;given during program setup. Whe I replace the following code&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;#if defined (__USE_LPCOPEN)&lt;BR /&gt;#if defined(NO_BOARD_LIB)&lt;BR /&gt;#include "chip.h"&lt;BR /&gt;#else&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#endif&lt;BR /&gt;#endif&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;#include &amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;#include &amp;lt;can_17xx_40xx.h&amp;gt;&lt;BR /&gt;#include&amp;lt;uart_17xx_40xx.h&amp;gt;&lt;BR /&gt;// TODO: insert other include files here&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;// TODO: insert other definitions and declarations here&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;int main(void) {&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;#if defined (__USE_LPCOPEN)&lt;BR /&gt;// Read clock settings and update SystemCoreClock variable&lt;BR /&gt;SystemCoreClockUpdate();&lt;BR /&gt;#if !defined(NO_BOARD_LIB)&lt;BR /&gt;// Set up and initialize all required blocks and&lt;BR /&gt;// functions related to the board hardware&lt;BR /&gt;Board_Init();&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;BR /&gt;// Set the LED to the state of "On"&lt;BR /&gt;Board_LED_Set(0, true);&lt;BR /&gt;#endif&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;in the above program with&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;#include "chip.h" only following error occurs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;../src/test3.c:717:24: warning: variable 'i' set but not used [-Wunused-but-set-variable]&lt;BR /&gt; volatile uint32_t i;&lt;BR /&gt; ^&lt;BR /&gt;../src/test3.c: At top level:&lt;BR /&gt;../src/test3.c:1481:1: error: expected identifier or '(' before '}' token&lt;BR /&gt; }&lt;BR /&gt; ^&lt;BR /&gt;make: *** [src/test3.o] Error 1&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Feb 2018 09:34:13 GMT</pubDate>
    <dc:creator>sharuqueshaji</dc:creator>
    <dc:date>2018-02-27T09:34:13Z</dc:date>
    <item>
      <title>trying to execute the following code the following error occurs</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750117#M30205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;#if defined (__USE_LPCOPEN)&lt;BR /&gt;#if defined(NO_BOARD_LIB)&lt;BR /&gt;#include "chip.h"&lt;BR /&gt;#else&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#endif&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;#include &amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;#include &amp;lt;can_17xx_40xx.h&amp;gt;&lt;BR /&gt;#include&amp;lt;uart_17xx_40xx.h&amp;gt;&lt;BR /&gt;// TODO: insert other include files here&lt;/P&gt;&lt;P&gt;// TODO: insert other definitions and declarations here&lt;/P&gt;&lt;P&gt;int main(void) {&lt;/P&gt;&lt;P&gt;#if defined (__USE_LPCOPEN)&lt;BR /&gt; // Read clock settings and update SystemCoreClock variable&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt;#if !defined(NO_BOARD_LIB)&lt;BR /&gt; // Set up and initialize all required blocks and&lt;BR /&gt; // functions related to the board hardware&lt;BR /&gt; Board_Init();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; // Set the LED to the state of "On"&lt;BR /&gt; Board_LED_Set(0, true);&lt;BR /&gt;#endif&lt;BR /&gt;#endif&lt;BR /&gt; STATIC void setBusTiming(LPC_CAN_T *pCAN, IP_CAN_BUS_TIMING_T *pBusTiming) {&lt;BR /&gt; /* Enter to Reset Mode */&lt;BR /&gt; Chip_CAN_SetMode(pCAN, CAN_RESET_MODE, ENABLE);&lt;/P&gt;&lt;P&gt;/* Set Bus Timing */&lt;BR /&gt; pCAN-&amp;gt;BTR = CAN_BTR_BRP(pBusTiming-&amp;gt;BRP)&lt;BR /&gt; | CAN_BTR_SJW(pBusTiming-&amp;gt;SJW)&lt;BR /&gt; | CAN_BTR_TESG1(pBusTiming-&amp;gt;TESG1)&lt;BR /&gt; | CAN_BTR_TESG2(pBusTiming-&amp;gt;TESG2);&lt;/P&gt;&lt;P&gt;if (pBusTiming-&amp;gt;SAM) {&lt;BR /&gt; pCAN-&amp;gt;BTR |= CAN_BTR_SAM;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Exit from Reset Mode */&lt;BR /&gt; Chip_CAN_SetMode(pCAN, CAN_RESET_MODE, DISABLE);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get start row, end row of the given section */&lt;BR /&gt; STATIC void getSectionAddress(LPC_CANAF_T *pCANAF,&lt;BR /&gt; CANAF_RAM_SECTION_T SectionID, uint16_t *StartAddr, uint16_t *EndAddr)&lt;BR /&gt; {&lt;BR /&gt; if (SectionID == CANAF_RAM_FULLCAN_SEC) {&lt;BR /&gt; *StartAddr = 0;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; *StartAddr = CANAF_ENDADDR_VAL(pCANAF-&amp;gt;ENDADDR[SectionID - 1]);&lt;BR /&gt; }&lt;BR /&gt; *EndAddr = CANAF_ENDADDR_VAL(pCANAF-&amp;gt;ENDADDR[SectionID]);&lt;/P&gt;&lt;P&gt;if (*EndAddr &amp;gt; 0) {&lt;BR /&gt; *EndAddr -= 1; /* Minus 1 to get the actual end row */&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; *EndAddr = *StartAddr;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get the total number of entries in LUT */&lt;BR /&gt; STATIC INLINE uint16_t getTotalEntryNum(LPC_CANAF_T *pCANAF)&lt;BR /&gt; {&lt;BR /&gt; return CANAF_ENDADDR_VAL(pCANAF-&amp;gt;ENDADDR[CANAF_RAM_EFF_GRP_SEC]); /* Extended ID Group section is the last section of LUT */&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Set the End Address of a section. EndAddr = the number of the last row of the section + 1. */&lt;BR /&gt; STATIC INLINE void setSectionEndAddress(LPC_CANAF_T *pCANAF,&lt;BR /&gt; CANAF_RAM_SECTION_T SectionID, uint16_t EndAddr)&lt;BR /&gt; {&lt;BR /&gt; pCANAF-&amp;gt;ENDADDR[SectionID] = CANAF_ENDADDR(EndAddr);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get information of the received frame. Return ERROR means no message came.*/&lt;BR /&gt; STATIC INLINE Status getReceiveFrameInfo(LPC_CAN_T *pCAN,&lt;BR /&gt; IP_CAN_001_RX_T *pRxFrame)&lt;BR /&gt; {&lt;BR /&gt; *pRxFrame = pCAN-&amp;gt;RX;&lt;BR /&gt; return (pCAN-&amp;gt;SR &amp;amp; CAN_SR_RBS(0)) ? SUCCESS : ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Set Tx Frame Information */&lt;BR /&gt; STATIC INLINE void setSendFrameInfo(LPC_CAN_T *pCAN, CAN_BUFFER_ID_T TxBufID,&lt;BR /&gt; LPC_CAN_TX_T *pTxFrame)&lt;BR /&gt; {&lt;BR /&gt; pCAN-&amp;gt;TX[TxBufID] = *pTxFrame;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Create the standard ID entry */&lt;BR /&gt; STATIC uint16_t createStdIDEntry(CAN_STD_ID_ENTRY_T *pEntryInfo, bool IsFullCANEntry)&lt;BR /&gt; {&lt;BR /&gt; uint16_t Entry = 0;&lt;BR /&gt; Entry = (pEntryInfo-&amp;gt;CtrlNo &amp;amp; CAN_STD_ENTRY_CTRL_NO_MASK) &amp;lt;&amp;lt; CAN_STD_ENTRY_CTRL_NO_POS;&lt;BR /&gt; Entry |= (pEntryInfo-&amp;gt;Disable &amp;amp; CAN_STD_ENTRY_DISABLE_MASK) &amp;lt;&amp;lt; CAN_STD_ENTRY_DISABLE_POS;&lt;BR /&gt; Entry |= (pEntryInfo-&amp;gt;ID_11 &amp;amp; CAN_STD_ENTRY_ID_MASK) &amp;lt;&amp;lt; CAN_STD_ENTRY_ID_POS;&lt;BR /&gt; if (IsFullCANEntry) {&lt;BR /&gt; Entry |= 1 &amp;lt;&amp;lt; CAN_STD_ENTRY_IE_POS;&lt;BR /&gt; }&lt;BR /&gt; return Entry;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;STATIC INLINE uint16_t createUnUsedSTDEntry(uint8_t CtrlNo)&lt;BR /&gt; {&lt;BR /&gt; return ((CtrlNo &amp;amp; CAN_STD_ENTRY_CTRL_NO_MASK) &amp;lt;&amp;lt; CAN_STD_ENTRY_CTRL_NO_POS) | (1 &amp;lt;&amp;lt; CAN_STD_ENTRY_DISABLE_POS);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get information from the standard ID entry */&lt;BR /&gt; STATIC void readStdIDEntry(uint16_t EntryVal, CAN_STD_ID_ENTRY_T *pEntryInfo)&lt;BR /&gt; {&lt;BR /&gt; pEntryInfo-&amp;gt;CtrlNo = (EntryVal &amp;gt;&amp;gt; CAN_STD_ENTRY_CTRL_NO_POS) &amp;amp; CAN_STD_ENTRY_CTRL_NO_MASK;&lt;BR /&gt; pEntryInfo-&amp;gt;Disable = (EntryVal &amp;gt;&amp;gt; CAN_STD_ENTRY_DISABLE_POS) &amp;amp; CAN_STD_ENTRY_DISABLE_MASK;&lt;BR /&gt; pEntryInfo-&amp;gt;ID_11 = (EntryVal &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Setup Standard iD section */&lt;BR /&gt; STATIC Status setupSTDSection(uint32_t *pCANAFRamAddr,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pStdCANSec,&lt;BR /&gt; uint16_t EntryNum,&lt;BR /&gt; bool IsFullCANEntry)&lt;BR /&gt; {&lt;BR /&gt; uint16_t i;&lt;BR /&gt; uint16_t CurID = 0;&lt;BR /&gt; uint16_t Entry;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;/* Setup FullCAN section */&lt;BR /&gt; for (i = 0; i &amp;lt; EntryNum; i += 2) {&lt;BR /&gt; /* First Entry */&lt;BR /&gt; if (CurID &amp;gt; pStdCANSec[i].ID_11) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;BR /&gt; CurID = pStdCANSec[i].ID_11;&lt;BR /&gt; Entry = createStdIDEntry(&amp;amp;pStdCANSec[i], IsFullCANEntry);&lt;BR /&gt; pCANAFRamAddr[EntryCnt] = Entry &amp;lt;&amp;lt; 16;&lt;/P&gt;&lt;P&gt;/* Second Entry */&lt;BR /&gt; if ((i + 1) &amp;lt; EntryNum) {&lt;BR /&gt; if (CurID &amp;gt; pStdCANSec[i + 1].ID_11) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;BR /&gt; CurID = pStdCANSec[i + 1].ID_11;&lt;BR /&gt; Entry = createStdIDEntry(&amp;amp;pStdCANSec[i + 1], IsFullCANEntry);&lt;BR /&gt; pCANAFRamAddr[EntryCnt] |= Entry;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; pCANAFRamAddr[EntryCnt] |= createUnUsedSTDEntry(pStdCANSec[0].CtrlNo);&lt;BR /&gt; }&lt;BR /&gt; EntryCnt++;&lt;BR /&gt; }&lt;BR /&gt; return SUCCESS;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Setup the Group Standard ID section */&lt;BR /&gt; STATIC Status setupSTDRangeSection(uint32_t *pCANAFRamAddr,&lt;BR /&gt; CAN_STD_ID_RANGE_ENTRY_T *pStdRangeCANSec,&lt;BR /&gt; uint16_t EntryNum)&lt;BR /&gt; {&lt;BR /&gt; return setupSTDSection(pCANAFRamAddr, (CAN_STD_ID_ENTRY_T *) pStdRangeCANSec, EntryNum * 2, false);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Shift a number of entries down 1 position */&lt;BR /&gt; STATIC void shiftSTDEntryDown(uint32_t *arr, int32_t num)&lt;BR /&gt; {&lt;BR /&gt; uint32_t i = 0;&lt;BR /&gt; uint32_t prevRow, curRow;&lt;/P&gt;&lt;P&gt;if (num &amp;lt;= 0) {&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;prevRow = arr[0];&lt;BR /&gt; arr[0] = ((prevRow &amp;amp; 0xFFFF0000) &amp;gt;&amp;gt; 16);&lt;BR /&gt; for (i = 0; i &amp;lt; (num / 2); i++) {&lt;BR /&gt; curRow = arr[i + 1];&lt;BR /&gt; arr[i + 1] = ((prevRow &amp;amp; 0xFFFF) &amp;lt;&amp;lt; 16) | ((curRow &amp;amp; 0xFFFF0000) &amp;gt;&amp;gt; 16);&lt;BR /&gt; prevRow = curRow;&lt;BR /&gt; }&lt;BR /&gt; if ((num % 2) == 0) {&lt;BR /&gt; uint8_t CtrlNo = (prevRow &amp;gt;&amp;gt; CAN_STD_ENTRY_CTRL_NO_POS) &amp;amp; CAN_STD_ENTRY_CTRL_NO_MASK;&lt;BR /&gt; arr[num / 2] = ((prevRow &amp;amp; 0xFFFF) &amp;lt;&amp;lt; 16) | createUnUsedSTDEntry(CtrlNo);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Shift a number of entries up 1 position */&lt;BR /&gt; STATIC void shiftSTDEntryUp(uint32_t *arr, int32_t num)&lt;BR /&gt; {&lt;BR /&gt; int32_t i = 0;&lt;BR /&gt; uint32_t prevRow = 0, curRow = 0;&lt;BR /&gt; uint8_t CtrlNo = 0;&lt;/P&gt;&lt;P&gt;if (num &amp;lt;= 0) {&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;curRow = arr[((num + 1) / 2) - 1];&lt;BR /&gt; CtrlNo = (curRow &amp;gt;&amp;gt; CAN_STD_ENTRY_CTRL_NO_POS) &amp;amp; CAN_STD_ENTRY_CTRL_NO_MASK;&lt;/P&gt;&lt;P&gt;/* If num is odd, the last row only includes one item. Therefore, there is nothing&lt;BR /&gt; to do with it. If num is even, shift the last item to one place of the row.*/&lt;BR /&gt; if ((num % 2) == 0) {&lt;BR /&gt; arr[((num + 1) / 2) - 1] = ((curRow &amp;amp; 0xFFFF) &amp;lt;&amp;lt; 16) | createUnUsedSTDEntry(CtrlNo);&lt;BR /&gt; }&lt;BR /&gt; /* Shift from the row before the last row */&lt;BR /&gt; for (i = ((num + 1) / 2) - 1; i &amp;gt; 0; i--) {&lt;BR /&gt; prevRow = arr[i - 1];&lt;BR /&gt; arr[i - 1] = ((curRow &amp;amp; 0xFFFF0000) &amp;gt;&amp;gt; 16) | ((prevRow &amp;amp; 0xFFFF) &amp;lt;&amp;lt; 16);&lt;BR /&gt; curRow = prevRow;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Create an extended ID entry */&lt;BR /&gt; STATIC uint32_t createExtIDEntry(CAN_EXT_ID_ENTRY_T *pEntryInfo)&lt;BR /&gt; {&lt;BR /&gt; uint32_t Entry = 0;&lt;BR /&gt; Entry = (pEntryInfo-&amp;gt;CtrlNo &amp;amp; CAN_EXT_ENTRY_CTRL_NO_MASK) &amp;lt;&amp;lt; CAN_EXT_ENTRY_CTRL_NO_POS;&lt;BR /&gt; Entry |= (pEntryInfo-&amp;gt;ID_29 &amp;amp; CAN_EXT_ENTRY_ID_MASK) &amp;lt;&amp;lt; CAN_EXT_ENTRY_ID_POS;&lt;BR /&gt; return Entry;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get information from an extended ID entry */&lt;BR /&gt; STATIC void readExtIDEntry(uint32_t EntryVal, CAN_EXT_ID_ENTRY_T *pEntryInfo)&lt;BR /&gt; {&lt;BR /&gt; pEntryInfo-&amp;gt;CtrlNo = (EntryVal &amp;gt;&amp;gt; CAN_EXT_ENTRY_CTRL_NO_POS) &amp;amp; CAN_EXT_ENTRY_CTRL_NO_MASK;&lt;BR /&gt; pEntryInfo-&amp;gt;ID_29 = (EntryVal &amp;gt;&amp;gt; CAN_EXT_ENTRY_ID_POS) &amp;amp; CAN_EXT_ENTRY_ID_MASK;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Setup the Extended ID Section */&lt;BR /&gt; STATIC Status setupEXTSection(uint32_t *pCANAFRamAddr, CAN_EXT_ID_ENTRY_T *pExtCANSec, uint16_t EntryNum)&lt;BR /&gt; {&lt;BR /&gt; uint16_t i;&lt;BR /&gt; uint32_t CurID = 0;&lt;BR /&gt; uint32_t Entry;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;/* Setup FullCAN section */&lt;BR /&gt; for (i = 0; i &amp;lt; EntryNum; i++) {&lt;BR /&gt; if (CurID &amp;gt; pExtCANSec[i].ID_29) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;BR /&gt; CurID = pExtCANSec[i].ID_29;&lt;BR /&gt; Entry = createExtIDEntry(&amp;amp;pExtCANSec[i]);&lt;BR /&gt; pCANAFRamAddr[EntryCnt] = Entry;&lt;BR /&gt; EntryCnt++;&lt;BR /&gt; }&lt;BR /&gt; return SUCCESS;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Setup Group Extended ID section */&lt;BR /&gt; STATIC Status setupEXTRangeSection(uint32_t *pCANAFRamAddr,&lt;BR /&gt; CAN_EXT_ID_RANGE_ENTRY_T *pExtRangeCANSec,&lt;BR /&gt; uint16_t EntryNum)&lt;BR /&gt; {&lt;BR /&gt; return setupEXTSection(pCANAFRamAddr, (CAN_EXT_ID_ENTRY_T *) pExtRangeCANSec, EntryNum * 2);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get entry value from the given start index of the given array. byteNum is 2 or 4 bytes */&lt;BR /&gt; STATIC uint32_t getArrayVal(uint8_t *arr, uint32_t startIndex, uint8_t byteNum)&lt;BR /&gt; {&lt;BR /&gt; uint8_t i = 0;&lt;BR /&gt; uint32_t retVal = 0;&lt;BR /&gt; uint32_t index;&lt;/P&gt;&lt;P&gt;index = startIndex * byteNum;&lt;BR /&gt; if (byteNum == 2) { // each entry uses 2 bytes&lt;BR /&gt; if (startIndex % 2) {&lt;BR /&gt; index -= 2; // little endian&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; index += 2;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; byteNum; i++) {&lt;BR /&gt; retVal |= arr[index + i] &amp;lt;&amp;lt; (8 * i);&lt;BR /&gt; }&lt;BR /&gt; return retVal;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Search the index to insert the new entry */&lt;BR /&gt; STATIC int32_t searchInsertIndex(uint32_t *arr, uint32_t arrNum, uint32_t val, uint32_t mask, uint8_t unitSize)&lt;BR /&gt; {&lt;BR /&gt; uint32_t LowerIndex, UpperIndex, MidIndex;&lt;BR /&gt; uint32_t MidVal;&lt;BR /&gt; uint8_t *byteArray = (uint8_t *) arr;&lt;/P&gt;&lt;P&gt;if (arrNum == 0) {&lt;BR /&gt; return 0; /* Insert into the first line */&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; LowerIndex = 0;&lt;BR /&gt; UpperIndex = arrNum - 1;&lt;BR /&gt; while (LowerIndex + 1 &amp;lt; UpperIndex) {&lt;BR /&gt; MidIndex = (LowerIndex + UpperIndex) / 2;&lt;BR /&gt; MidVal = getArrayVal(byteArray, MidIndex, unitSize) &amp;amp; mask;&lt;BR /&gt; if (MidVal == val) {&lt;BR /&gt; return -1; /* The new value is already in the array */&lt;BR /&gt; }&lt;BR /&gt; else if (MidVal &amp;lt; val) {&lt;BR /&gt; LowerIndex = MidIndex + 1;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; UpperIndex = MidIndex - 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (((getArrayVal(byteArray, LowerIndex, unitSize) &amp;amp; mask) == val) ||&lt;BR /&gt; ((getArrayVal(byteArray, UpperIndex, unitSize) &amp;amp; mask) == val)) {&lt;BR /&gt; return -1; /* The new value is already in the array */&lt;BR /&gt; }&lt;BR /&gt; if ((getArrayVal(byteArray, LowerIndex, unitSize) &amp;amp; mask) &amp;gt; val) {&lt;BR /&gt; return LowerIndex;&lt;BR /&gt; }&lt;BR /&gt; if ((getArrayVal(byteArray, UpperIndex, unitSize) &amp;amp; mask) &amp;lt; val) {&lt;BR /&gt; return UpperIndex + 1;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return UpperIndex;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert an entry into FullCAN Table */&lt;BR /&gt; STATIC Status insertSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pEntry,&lt;BR /&gt; bool IsFullCANEntry)&lt;BR /&gt; {&lt;BR /&gt; int32_t IDIndex = 0;&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;BR /&gt; uint16_t i = 0;&lt;BR /&gt; uint32_t tmp = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;if (getTotalEntryNum(pCANAF) &amp;gt;= CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Check if a number of entries in section is odd or even */&lt;BR /&gt; if (IsFullCANEntry) {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) * 2;&lt;BR /&gt; if ((((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK) ==&lt;BR /&gt; 0) &amp;amp;&amp;amp;&lt;BR /&gt; (((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt;&lt;BR /&gt; CAN_STD_ENTRY_DISABLE_POS) &amp;amp; CAN_STD_ENTRY_DISABLE_MASK) == 1)) { /* Unsed entry */&lt;BR /&gt; EntryCnt -= 1;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Search for Index of new entry */&lt;BR /&gt; IDIndex = searchInsertIndex((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[StartRow],&lt;BR /&gt; EntryCnt,&lt;BR /&gt; pEntry-&amp;gt;ID_11 &amp;amp; CAN_STD_ENTRY_ID_MASK,&lt;BR /&gt; CAN_STD_ENTRY_ID_MASK,&lt;BR /&gt; sizeof(uint16_t));&lt;BR /&gt; if ((IDIndex == -1) || (IDIndex &amp;gt; EntryCnt )) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Move all remaining sections one place down&lt;BR /&gt; if new entry will increase FullCAN list */&lt;BR /&gt; if ((EntryCnt % 2) == 0) {&lt;BR /&gt; uint16_t StartAddr, EndAddr;&lt;/P&gt;&lt;P&gt;for (i = getTotalEntryNum(pCANAF); i &amp;gt; EndRow; i--) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[i] = pCANAFRam-&amp;gt;MASK[i - 1];&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (IsFullCANEntry) {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, EndAddr + 2);&lt;BR /&gt; }&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_SEC, EndAddr + 2);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, EndAddr + 2);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_SEC, EndAddr + 2);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EndAddr + 2);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Shift rows behind the row of search index. If search index is low index of the row, shift the row of search index also. */&lt;BR /&gt; if ((IDIndex % 2) == 0) {&lt;BR /&gt; shiftSTDEntryDown((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2], EntryCnt - IDIndex);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; shiftSTDEntryDown((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2 + 1], EntryCnt - IDIndex - 1);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert new item */&lt;BR /&gt; tmp = createStdIDEntry(pEntry, IsFullCANEntry);&lt;BR /&gt; if ((IDIndex % 2) == 0) {&lt;BR /&gt; if (IDIndex == EntryCnt) {&lt;BR /&gt; /* Insert unused item if the new item is the last item*/&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] = (tmp &amp;lt;&amp;lt; 16) | createUnUsedSTDEntry(pEntry-&amp;gt;CtrlNo);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; uint32_t val;&lt;BR /&gt; val = pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] &amp;amp; 0x0000FFFF;&lt;BR /&gt; /* Insert new item */&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] = val | (tmp &amp;lt;&amp;lt; 16);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; uint32_t val, valNext;&lt;BR /&gt; val = pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2];&lt;BR /&gt; valNext = pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2 + 1];&lt;BR /&gt; /* In case the new entry is not the last item, shift the item at the found index to the next row*/&lt;BR /&gt; if (IDIndex &amp;lt; EntryCnt ) {&lt;/P&gt;&lt;P&gt;pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2 + 1] = (valNext &amp;amp; 0x0000FFFF) | ((val &amp;amp; 0xFFFF) &amp;lt;&amp;lt; 16);&lt;BR /&gt; }&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] = (val &amp;amp; 0xFFFF0000) | tmp;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Read STD Entry */&lt;BR /&gt; STATIC Status readSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; uint16_t Position,&lt;BR /&gt; bool IsFullCANEntry,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pEntry)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;/* Check if a number of entries in section is odd or even */&lt;BR /&gt; if (IsFullCANEntry) {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) * 2;&lt;BR /&gt; if ((((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK) ==&lt;BR /&gt; 0) &amp;amp;&amp;amp;&lt;BR /&gt; (((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt;&lt;BR /&gt; CAN_STD_ENTRY_DISABLE_POS) &amp;amp; CAN_STD_ENTRY_DISABLE_MASK) == 1)) { /* Unsed entry */&lt;BR /&gt; EntryCnt -= 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; if (Position &amp;gt;= EntryCnt) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((Position % 2) == 0) {&lt;BR /&gt; readStdIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position / 2] &amp;gt;&amp;gt; 16, pEntry);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; readStdIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position / 2] &amp;amp; 0xFFFF, pEntry);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove STD Entry from given table */&lt;BR /&gt; Status removeSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; int16_t IDIndex,&lt;BR /&gt; bool IsFullCANEntry)&lt;BR /&gt; {&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0, i;&lt;BR /&gt; uint32_t tmp = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;if (IDIndex &amp;lt; 0) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (getTotalEntryNum(pCANAF) &amp;gt;= CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Check if a number of entries in section is odd or even */&lt;BR /&gt; if (IsFullCANEntry) {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) * 2;&lt;BR /&gt; if ((((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK) ==&lt;BR /&gt; 0) &amp;amp;&amp;amp;&lt;BR /&gt; (((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt;&lt;BR /&gt; CAN_STD_ENTRY_DISABLE_POS) &amp;amp; CAN_STD_ENTRY_DISABLE_MASK) == 1)) { /* Unsed entry */&lt;BR /&gt; EntryCnt -= 1;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; if (IDIndex &amp;gt;= EntryCnt) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Shift rows behind the row of remove index. If remove index is low index of the row, shift the row of remove index also. */&lt;BR /&gt; tmp = pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2 + 1];&lt;BR /&gt; if ((IDIndex % 2) == 0) {&lt;BR /&gt; shiftSTDEntryUp((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2], EntryCnt - IDIndex);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; shiftSTDEntryUp((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2 + 1], EntryCnt - IDIndex - 1);&lt;/P&gt;&lt;P&gt;/* Set value for the entry at remove index */&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] &amp;amp;= 0xFFFF0000;&lt;BR /&gt; if (IDIndex == (EntryCnt - 1)) {&lt;BR /&gt; uint8_t CtrlNo;&lt;BR /&gt; tmp = (pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2]) &amp;gt;&amp;gt; 16;&lt;BR /&gt; CtrlNo = (tmp &amp;gt;&amp;gt; CAN_STD_ENTRY_CTRL_NO_POS) &amp;amp; CAN_STD_ENTRY_CTRL_NO_MASK;&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] |= createUnUsedSTDEntry(CtrlNo);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex / 2] |= (tmp &amp;gt;&amp;gt; 16) &amp;amp; 0xFFFF;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; /* Move all remaining sections one place up&lt;BR /&gt; if new entry will decrease FullCAN list */&lt;BR /&gt; if (EntryCnt % 2) {&lt;BR /&gt; uint16_t StartAddr, EndAddr;&lt;/P&gt;&lt;P&gt;for (i = EndRow; i &amp;lt; getTotalEntryNum(pCANAF); i++) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[i] = pCANAFRam-&amp;gt;MASK[i + 1];&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (IsFullCANEntry) {&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, EndAddr);&lt;BR /&gt; }&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_SEC, EndAddr);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, EndAddr);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_SEC, EndAddr);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EndAddr);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove LUT Entry from given table */&lt;BR /&gt; Status removeLUTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CANAF_RAM_SECTION_T SectionID,&lt;BR /&gt; int16_t Position)&lt;BR /&gt; {&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t StartAddr, EndAddr;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;BR /&gt; uint8_t EntryRowNum = 1;&lt;BR /&gt; uint16_t i = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;if (Position &amp;lt; 0) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (getTotalEntryNum(pCANAF) &amp;gt;= CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (SectionID == CANAF_RAM_FULLCAN_SEC) {&lt;BR /&gt; return removeSTDEntry(pCANAF, pCANAFRam, Position, true);&lt;BR /&gt; }&lt;BR /&gt; else if (SectionID == CANAF_RAM_SFF_SEC) {&lt;BR /&gt; return removeSTDEntry(pCANAF, pCANAFRam, Position, false);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get a number of rows for an entry */&lt;BR /&gt; if (SectionID == CANAF_RAM_EFF_GRP_SEC) {&lt;BR /&gt; EntryRowNum = 2;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get Start Row, End Row */&lt;BR /&gt; getSectionAddress(pCANAF, SectionID, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) / EntryRowNum;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (Position &amp;gt;= EntryCnt) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Move all remaining sections one place up&lt;BR /&gt; if new entry will increase FullCAN list */&lt;BR /&gt; for (i = StartRow + Position * EntryRowNum; i &amp;lt; getTotalEntryNum(pCANAF); i++) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[i] = pCANAFRam-&amp;gt;MASK[i + EntryRowNum];&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get Start Row, End Row */&lt;BR /&gt; switch (SectionID) {&lt;BR /&gt; case CANAF_RAM_SFF_GRP_SEC:&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, EndAddr - EntryRowNum + 1);&lt;/P&gt;&lt;P&gt;case CANAF_RAM_EFF_SEC:&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_SEC, EndAddr - EntryRowNum + 1);&lt;/P&gt;&lt;P&gt;case CANAF_RAM_EFF_GRP_SEC:&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartAddr, &amp;amp;EndAddr);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EndAddr - EntryRowNum + 1);&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;default:&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Clear AF LUT */&lt;BR /&gt; void clearAFLUT(LPC_CANAF_T *pCanAF, LPC_CANAF_RAM_T *pCanAFRam) {&lt;BR /&gt; uint32_t i = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCanAF);&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCanAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Clear AF Ram region */&lt;BR /&gt; for (i = 0; i &amp;lt; CANAF_RAM_ENTRY_NUM; i++) {&lt;BR /&gt; pCanAFRam-&amp;gt;MASK[i] = 0;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Reset address registers */&lt;BR /&gt; setSectionEndAddress(pCanAF, CANAF_RAM_FULLCAN_SEC, 0);&lt;BR /&gt; setSectionEndAddress(pCanAF, CANAF_RAM_SFF_SEC, 0);&lt;BR /&gt; setSectionEndAddress(pCanAF, CANAF_RAM_SFF_GRP_SEC, 0);&lt;BR /&gt; setSectionEndAddress(pCanAF, CANAF_RAM_EFF_SEC, 0);&lt;BR /&gt; setSectionEndAddress(pCanAF, CANAF_RAM_EFF_GRP_SEC, 0);&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCanAF, CurMode);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Returns clock for the peripheral block */&lt;BR /&gt; STATIC CHIP_SYSCTL_CLOCK_T Chip_CAN_GetClockIndex(LPC_CAN_T *pCAN)&lt;BR /&gt; {&lt;BR /&gt; CHIP_SYSCTL_CLOCK_T clkCAN;&lt;/P&gt;&lt;P&gt;if (pCAN == LPC_CAN1) {&lt;BR /&gt; clkCAN = SYSCTL_CLOCK_CAN1;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; clkCAN = SYSCTL_CLOCK_CAN2;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return clkCAN;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;#if defined(CHIP_LPC177X_8X) || defined(CHIP_LPC40XX)&lt;BR /&gt; /* Returns reset ID for the peripheral block */&lt;BR /&gt; STATIC CHIP_SYSCTL_RESET_T Chip_CAN_GetResetIndex(LPC_CAN_T *pCAN)&lt;BR /&gt; {&lt;BR /&gt; CHIP_SYSCTL_RESET_T resetCAN;&lt;/P&gt;&lt;P&gt;if (pCAN == LPC_CAN1) {&lt;BR /&gt; resetCAN = SYSCTL_RESET_CAN1;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; resetCAN = SYSCTL_RESET_CAN2;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return resetCAN;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;#if defined(CHIP_LPC175X_6X)&lt;BR /&gt; /* Returns clock ID for the peripheral block */&lt;BR /&gt; STATIC CHIP_SYSCTL_PCLK_T Chip_CAN_GetClkIndex(LPC_CAN_T *pCAN)&lt;BR /&gt; {&lt;BR /&gt; CHIP_SYSCTL_PCLK_T clkCAN;&lt;/P&gt;&lt;P&gt;if (pCAN == LPC_CAN1) {&lt;BR /&gt; clkCAN = SYSCTL_PCLK_CAN1;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; clkCAN = SYSCTL_PCLK_CAN2;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return clkCAN;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Public functions&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/* Initialize CAN Interface */&lt;BR /&gt; void Chip_CAN_Init(LPC_CAN_T *pCAN, LPC_CANAF_T *pCANAF, LPC_CANAF_RAM_T *pCANAFRam)&lt;BR /&gt; {&lt;BR /&gt; volatile uint32_t i;&lt;/P&gt;&lt;P&gt;Chip_Clock_EnablePeriphClock(Chip_CAN_GetClockIndex(pCAN));&lt;BR /&gt; #if defined(CHIP_LPC177X_8X) || defined(CHIP_LPC40XX)&lt;BR /&gt; Chip_SYSCTL_PeriphReset(Chip_CAN_GetResetIndex(pCAN));&lt;BR /&gt; #endif&lt;/P&gt;&lt;P&gt;/* Enter to Reset Mode */&lt;BR /&gt; pCAN-&amp;gt;MOD = CAN_MOD_RM;&lt;/P&gt;&lt;P&gt;/* Disable all CAN Interrupts */&lt;BR /&gt; pCAN-&amp;gt;IER &amp;amp;= (~CAN_IER_BITMASK) &amp;amp; CAN_IER_BITMASK;&lt;BR /&gt; pCAN-&amp;gt;GSR &amp;amp;= (~CAN_GSR_BITMASK) &amp;amp; CAN_GSR_BITMASK;&lt;/P&gt;&lt;P&gt;/* Request command to release Rx, Tx buffer and clear data overrun */&lt;BR /&gt; pCAN-&amp;gt;CMR = CAN_CMR_RRB | CAN_CMR_AT | CAN_CMR_CDO;&lt;/P&gt;&lt;P&gt;/* Read to clear interrupt pending in interrupt capture register */&lt;BR /&gt; i = pCAN-&amp;gt;ICR;&lt;/P&gt;&lt;P&gt;/* Return to normal mode */&lt;BR /&gt; pCAN-&amp;gt;MOD = CAN_MOD_OPERATION;&lt;/P&gt;&lt;P&gt;/* Initiialize Acceptance filter */&lt;BR /&gt; clearAFLUT(pCANAF, pCANAFRam);&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_NORMAL_MODE);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* De-Initialize CAN Interface */&lt;BR /&gt; void Chip_CAN_DeInit(LPC_CAN_T *pCAN)&lt;BR /&gt; {&lt;BR /&gt; Chip_Clock_DisablePeriphClock(Chip_CAN_GetClockIndex(pCAN));&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Set CAN Bit Rate */&lt;BR /&gt; Status Chip_CAN_SetBitRate(LPC_CAN_T *pCAN, uint32_t BitRate)&lt;BR /&gt; {&lt;BR /&gt; IP_CAN_BUS_TIMING_T BusTiming;&lt;BR /&gt; uint32_t result = 0;&lt;BR /&gt; uint8_t NT, TSEG1 = 0, TSEG2 = 0;&lt;BR /&gt; uint32_t CANPclk = 0;&lt;BR /&gt; uint32_t BRP = 0;&lt;/P&gt;&lt;P&gt;#if defined(CHIP_LPC175X_6X)&lt;BR /&gt; CANPclk = Chip_Clock_GetPeripheralClockRate(Chip_CAN_GetClkIndex(pCAN));&lt;BR /&gt; #else&lt;BR /&gt; CANPclk = Chip_Clock_GetPeripheralClockRate();&lt;BR /&gt; #endif&lt;BR /&gt; result = CANPclk / BitRate;&lt;/P&gt;&lt;P&gt;/* Calculate suitable nominal time value&lt;BR /&gt; * NT (nominal time) = (TSEG1 + TSEG2 + 3)&lt;BR /&gt; * NT &amp;lt;= 24&lt;BR /&gt; * TSEG1 &amp;gt;= 2*TSEG2&lt;BR /&gt; */&lt;BR /&gt; for (NT = 24; NT &amp;gt; 0; NT = NT - 2) {&lt;BR /&gt; if ((result % NT) == 0) {&lt;BR /&gt; BRP = result / NT - 1;&lt;/P&gt;&lt;P&gt;NT--;&lt;/P&gt;&lt;P&gt;TSEG2 = (NT / 3) - 1;&lt;/P&gt;&lt;P&gt;TSEG1 = NT - (NT / 3) - 1;&lt;/P&gt;&lt;P&gt;break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; if (NT == 0) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;BusTiming.TESG1 = TSEG1;&lt;BR /&gt; BusTiming.TESG2 = TSEG2;&lt;BR /&gt; BusTiming.BRP = BRP;&lt;BR /&gt; BusTiming.SJW = 3;&lt;BR /&gt; BusTiming.SAM = 0;&lt;BR /&gt; setBusTiming(pCAN, &amp;amp;BusTiming);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Set CAN Mode */&lt;BR /&gt; void Chip_CAN_SetMode(LPC_CAN_T *pCAN, CAN_MODE_T Mode, FunctionalState NewState)&lt;BR /&gt; {&lt;BR /&gt; if ((Mode &amp;amp; CAN_MOD_LOM) || (Mode &amp;amp; CAN_MOD_STM)) {&lt;BR /&gt; /* Enter to Reset Mode */&lt;BR /&gt; pCAN-&amp;gt;MOD |= CAN_MOD_RM;&lt;/P&gt;&lt;P&gt;/* Change to the given mode */&lt;BR /&gt; if (NewState) {&lt;BR /&gt; pCAN-&amp;gt;MOD |= Mode;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; pCAN-&amp;gt;MOD &amp;amp;= (~Mode) &amp;amp; CAN_MOD_BITMASK;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Release Reset Mode */&lt;BR /&gt; pCAN-&amp;gt;MOD &amp;amp;= (~CAN_MOD_RM) &amp;amp; CAN_MOD_BITMASK;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; if (NewState) {&lt;BR /&gt; pCAN-&amp;gt;MOD |= Mode;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; pCAN-&amp;gt;MOD &amp;amp;= (~Mode) &amp;amp; CAN_MOD_BITMASK;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Get Free TxBuf */&lt;BR /&gt; CAN_BUFFER_ID_T Chip_CAN_GetFreeTxBuf(LPC_CAN_T *pCAN)&lt;BR /&gt; {&lt;BR /&gt; CAN_BUFFER_ID_T TxBufID = CAN_BUFFER_1;&lt;/P&gt;&lt;P&gt;/* Select a free buffer */&lt;BR /&gt; for (TxBufID = (CAN_BUFFER_ID_T) 0; TxBufID &amp;lt; CAN_BUFFER_LAST; TxBufID++) {&lt;BR /&gt; if (Chip_CAN_GetStatus(pCAN) &amp;amp; CAN_SR_TBS(TxBufID)) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return TxBufID;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Set AF Lookup Table */&lt;BR /&gt; Status Chip_CAN_SetAFLUT(LPC_CANAF_T *pCANAF, LPC_CANAF_RAM_T *pCANAFRam, CANAF_LUT_T *pAFSections) {&lt;BR /&gt; uint16_t EntryCnt = 0, FullCANEntryCnt = 0;&lt;BR /&gt; Status ret = ERROR;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;do {&lt;BR /&gt; /* Check a number of entries */&lt;BR /&gt; if ((((pAFSections-&amp;gt;FullCANEntryNum + 1) / 2) +&lt;BR /&gt; ((pAFSections-&amp;gt;SffEntryNum + 1) / 2) +&lt;BR /&gt; (pAFSections-&amp;gt;SffGrpEntryNum) +&lt;BR /&gt; (pAFSections-&amp;gt;EffEntryNum) +&lt;BR /&gt; (pAFSections-&amp;gt;EffGrpEntryNum * 2)) &amp;gt; CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; ret = ERROR;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Setup FullCAN section */&lt;BR /&gt; ret =&lt;BR /&gt; setupSTDSection((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[EntryCnt], pAFSections-&amp;gt;FullCANSec,&lt;BR /&gt; pAFSections-&amp;gt;FullCANEntryNum, true);&lt;BR /&gt; if (ret == ERROR) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; EntryCnt = (pAFSections-&amp;gt;FullCANEntryNum + 1) &amp;gt;&amp;gt; 1;&lt;BR /&gt; FullCANEntryCnt = EntryCnt;&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_FULLCAN_SEC, EntryCnt);&lt;/P&gt;&lt;P&gt;/* Set up Individual Standard ID section */&lt;BR /&gt; ret =&lt;BR /&gt; setupSTDSection((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[EntryCnt],&lt;BR /&gt; pAFSections-&amp;gt;SffSec,&lt;BR /&gt; pAFSections-&amp;gt;SffEntryNum,&lt;BR /&gt; false);&lt;BR /&gt; if (ret == ERROR) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;EntryCnt += (pAFSections-&amp;gt;SffEntryNum + 1) &amp;gt;&amp;gt; 1;&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_SEC, EntryCnt);&lt;/P&gt;&lt;P&gt;/* Set up Group Standard ID section */&lt;BR /&gt; ret =&lt;BR /&gt; setupSTDRangeSection((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[EntryCnt], pAFSections-&amp;gt;SffGrpSec,&lt;BR /&gt; pAFSections-&amp;gt;SffGrpEntryNum);&lt;BR /&gt; if (ret == ERROR) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;EntryCnt += pAFSections-&amp;gt;SffGrpEntryNum;&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, EntryCnt);&lt;/P&gt;&lt;P&gt;/* Setup Individual Extended ID section */&lt;BR /&gt; ret =&lt;BR /&gt; setupEXTSection((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[EntryCnt], pAFSections-&amp;gt;EffSec, pAFSections-&amp;gt;EffEntryNum);&lt;BR /&gt; if (ret == ERROR) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;EntryCnt += pAFSections-&amp;gt;EffEntryNum;&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_SEC, EntryCnt);&lt;/P&gt;&lt;P&gt;/* Setup Group Extended ID section */&lt;BR /&gt; ret =&lt;BR /&gt; setupEXTRangeSection((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[EntryCnt], pAFSections-&amp;gt;EffGrpSec,&lt;BR /&gt; pAFSections-&amp;gt;EffGrpEntryNum);&lt;BR /&gt; if (ret == ERROR) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;EntryCnt += pAFSections-&amp;gt;EffGrpEntryNum * 2;&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EntryCnt);&lt;/P&gt;&lt;P&gt;if ((FullCANEntryCnt &amp;gt; 0) &amp;amp;&amp;amp; ((0x800 - 6 * FullCANEntryCnt) &amp;lt; EntryCnt)) {&lt;BR /&gt; ret = ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;} while (0);&lt;BR /&gt; /* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;/P&gt;&lt;P&gt;return ret;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get the number of entries of the given section */&lt;BR /&gt; uint16_t Chip_CAN_GetEntriesNum(LPC_CANAF_T *pCANAF, LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CANAF_RAM_SECTION_T SectionID)&lt;BR /&gt; {&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, SectionID, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; if (EndRow &amp;lt;= StartRow) {&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;BR /&gt; if ((SectionID == CANAF_RAM_FULLCAN_SEC) ||&lt;BR /&gt; (SectionID == CANAF_RAM_SFF_SEC)) {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) * 2;&lt;BR /&gt; if ((((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK) ==&lt;BR /&gt; 0) &amp;amp;&amp;amp;&lt;BR /&gt; (((pCANAFRam-&amp;gt;MASK[EndRow] &amp;gt;&amp;gt;&lt;BR /&gt; CAN_STD_ENTRY_DISABLE_POS) &amp;amp; CAN_STD_ENTRY_DISABLE_MASK) == 1)) { /* Unsed entry */&lt;BR /&gt; EntryCnt -= 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else if ((SectionID == CANAF_RAM_SFF_GRP_SEC) ||&lt;BR /&gt; (SectionID == CANAF_RAM_EFF_SEC)) {&lt;BR /&gt; EntryCnt = EndRow - StartRow + 1;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) / 2;&lt;BR /&gt; }&lt;BR /&gt; return EntryCnt;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert an entry into FullCAN Table */&lt;BR /&gt; Status Chip_CAN_InsertFullCANEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pEntry) {&lt;BR /&gt; return insertSTDEntry(pCANAF, pCANAFRam, pEntry, true);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert an entry into Individual STD section */&lt;BR /&gt; Status Chip_CAN_InsertSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; return insertSTDEntry(pCANAF, pCANAFRam, pEntry, false);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert an entry into Individual EXT section */&lt;BR /&gt; Status Chip_CAN_InsertEXTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CAN_EXT_ID_ENTRY_T *pEntry) {&lt;BR /&gt; int32_t IDIndex = 0;&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;BR /&gt; uint16_t i = 0;&lt;BR /&gt; uint32_t tmp = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;if (getTotalEntryNum(pCANAF) &amp;gt;= CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Check if a number of entries in section is odd or even */&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = EndRow - StartRow + 1;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Search for Index of new entry */&lt;BR /&gt; IDIndex = searchInsertIndex((uint32_t *) &amp;amp;pCANAFRam-&amp;gt;MASK[StartRow],&lt;BR /&gt; EntryCnt,&lt;BR /&gt; pEntry-&amp;gt;ID_29 &amp;amp; CAN_EXT_ENTRY_ID_MASK,&lt;BR /&gt; CAN_EXT_ENTRY_ID_MASK,&lt;BR /&gt; sizeof(uint32_t));&lt;BR /&gt; if ((IDIndex == -1) || (IDIndex &amp;gt; EntryCnt )) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Move all remaining sections one place down&lt;BR /&gt; if new entry will increase FullCAN list */&lt;/P&gt;&lt;P&gt;for (i = getTotalEntryNum(pCANAF); i &amp;gt; (StartRow + IDIndex); i--) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[i] = pCANAFRam-&amp;gt;MASK[i - 1];&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert new item */&lt;BR /&gt; tmp = createExtIDEntry(pEntry);&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[StartRow + IDIndex] = tmp;&lt;/P&gt;&lt;P&gt;/* Update address table */&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_SEC, EndRow + 2);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EndRow + 2);&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_InsertGroupSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CAN_STD_ID_RANGE_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; uint16_t InsertIndex = 0;&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t LowerID = 0, UpperID = 0;&lt;BR /&gt; uint16_t i = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;if (getTotalEntryNum(pCANAF) &amp;gt;= CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;/* Search for Index of the entry which upper the new item */&lt;BR /&gt; for (InsertIndex = StartRow; InsertIndex &amp;lt;= EndRow; InsertIndex++) {&lt;BR /&gt; LowerID = (pCANAFRam-&amp;gt;MASK[InsertIndex] &amp;gt;&amp;gt; (16 + CAN_STD_ENTRY_ID_POS)) &amp;amp; CAN_STD_ENTRY_ID_MASK;&lt;BR /&gt; UpperID = (pCANAFRam-&amp;gt;MASK[InsertIndex] &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK;&lt;BR /&gt; if (LowerID &amp;gt;= pEntry-&amp;gt;LowerID.ID_11) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Compare to the previous row (if any)*/&lt;BR /&gt; if (InsertIndex &amp;gt; 0) {&lt;BR /&gt; uint16_t PrevUpperID;&lt;BR /&gt; PrevUpperID = (pCANAFRam-&amp;gt;MASK[InsertIndex - 1] &amp;gt;&amp;gt; CAN_STD_ENTRY_ID_POS) &amp;amp; CAN_STD_ENTRY_ID_MASK;&lt;/P&gt;&lt;P&gt;if (PrevUpperID &amp;gt;= pEntry-&amp;gt;UpperID.ID_11) {&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (pEntry-&amp;gt;UpperID.ID_11 &amp;lt; LowerID) {&lt;BR /&gt; if (pEntry-&amp;gt;LowerID.ID_11 &amp;lt; PrevUpperID) { /* The new range is merged to the range of the previous row */&lt;BR /&gt; uint32_t val = pCANAFRam-&amp;gt;MASK[InsertIndex - 1] &amp;amp; 0xFFFF0000;&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex - 1] = val | createStdIDEntry(&amp;amp;pEntry-&amp;gt;UpperID, false);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; goto insert_grp_entry;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Compare to the next row (if any)*/&lt;BR /&gt; if ((EndRow) &amp;amp;&amp;amp; (InsertIndex &amp;lt;= EndRow)) {&lt;BR /&gt; if (pEntry-&amp;gt;UpperID.ID_11 &amp;gt;= UpperID) { /* The new range is merged to the range of the next row */&lt;BR /&gt; uint32_t val;&lt;BR /&gt; val = createStdIDEntry(&amp;amp;pEntry-&amp;gt;LowerID, false) &amp;lt;&amp;lt; 16;&lt;BR /&gt; val |= createStdIDEntry(&amp;amp;pEntry-&amp;gt;UpperID, false);&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] = val;&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; else if (pEntry-&amp;gt;UpperID.ID_11 &amp;lt; UpperID) {&lt;BR /&gt; if (pEntry-&amp;gt;UpperID.ID_11 &amp;gt; LowerID) { /* The new range is merged to the range of the next row */&lt;BR /&gt; uint32_t val = pCANAFRam-&amp;gt;MASK[InsertIndex] &amp;amp; 0x0000FFFF;&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] = val | (createStdIDEntry(&amp;amp;pEntry-&amp;gt;LowerID, false) &amp;lt;&amp;lt; 16);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;insert_grp_entry:&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Move all remaining sections one place down&lt;BR /&gt; if new entry will increase FullCAN list */&lt;/P&gt;&lt;P&gt;for (i = getTotalEntryNum(pCANAF); i &amp;gt; InsertIndex; i--) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[i] = pCANAFRam-&amp;gt;MASK[i - 1];&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert new item */&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] = createStdIDEntry(&amp;amp;pEntry-&amp;gt;LowerID, false) &amp;lt;&amp;lt; 16;&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] |= createStdIDEntry(&amp;amp;pEntry-&amp;gt;UpperID, false);&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, EndRow + 2);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_SEC, EndRow + 2);&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EndRow + 2);&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_InsertGroupEXTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; CAN_EXT_ID_RANGE_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; uint32_t InsertIndex = 0;&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint32_t LowerID = 0, UpperID = 0;&lt;BR /&gt; uint16_t i = 0;&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;if (getTotalEntryNum(pCANAF) &amp;gt;= CANAF_RAM_ENTRY_NUM) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Check if a number of entries in section is odd or even */&lt;BR /&gt; getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;/* Search for Index of new entry */&lt;BR /&gt; for (InsertIndex = StartRow; InsertIndex &amp;lt;= EndRow; InsertIndex += 2) {&lt;BR /&gt; LowerID = (pCANAFRam-&amp;gt;MASK[InsertIndex] &amp;gt;&amp;gt; CAN_EXT_ENTRY_ID_POS) &amp;amp; CAN_EXT_ENTRY_ID_MASK;&lt;BR /&gt; UpperID = (pCANAFRam-&amp;gt;MASK[InsertIndex + 1] &amp;gt;&amp;gt; CAN_EXT_ENTRY_ID_POS) &amp;amp; CAN_EXT_ENTRY_ID_MASK;&lt;BR /&gt; if (LowerID &amp;gt;= pEntry-&amp;gt;LowerID.ID_29) {&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Compare to the previous row (if any)*/&lt;BR /&gt; if (InsertIndex &amp;gt; 0) {&lt;BR /&gt; uint32_t PrevUpperID;&lt;BR /&gt; PrevUpperID = (pCANAFRam-&amp;gt;MASK[(InsertIndex - 2) + 1] &amp;gt;&amp;gt; CAN_EXT_ENTRY_ID_POS) &amp;amp; CAN_EXT_ENTRY_ID_MASK;&lt;/P&gt;&lt;P&gt;if (PrevUpperID &amp;gt;= pEntry-&amp;gt;UpperID.ID_29) {&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (pEntry-&amp;gt;UpperID.ID_29 &amp;lt; LowerID) {&lt;BR /&gt; if (pEntry-&amp;gt;LowerID.ID_29 &amp;lt; PrevUpperID) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[(InsertIndex - 2) + 1] = createExtIDEntry(&amp;amp;pEntry-&amp;gt;UpperID);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; goto insert_grp_entry;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((EndRow) &amp;amp;&amp;amp; (InsertIndex &amp;lt; EndRow)) {&lt;BR /&gt; if (pEntry-&amp;gt;UpperID.ID_29 &amp;gt;= UpperID) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] = createExtIDEntry(&amp;amp;pEntry-&amp;gt;LowerID);&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex + 1] = createExtIDEntry(&amp;amp;pEntry-&amp;gt;UpperID);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; else if (pEntry-&amp;gt;UpperID.ID_29 &amp;lt; UpperID) {&lt;BR /&gt; if (pEntry-&amp;gt;UpperID.ID_29 &amp;gt; LowerID) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] = createExtIDEntry(&amp;amp;pEntry-&amp;gt;LowerID);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;insert_grp_entry:&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;/* Move all remaining sections two places down&lt;BR /&gt; if new entry will increase FullCAN list */&lt;/P&gt;&lt;P&gt;for (i = getTotalEntryNum(pCANAF) + 1; i &amp;gt; InsertIndex; i--) {&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[i] = pCANAFRam-&amp;gt;MASK[i - 2];&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Insert new item */&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex] = createExtIDEntry(&amp;amp;pEntry-&amp;gt;LowerID);&lt;BR /&gt; pCANAFRam-&amp;gt;MASK[InsertIndex + 1] = createExtIDEntry(&amp;amp;pEntry-&amp;gt;UpperID);&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;BR /&gt; setSectionEndAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, EndRow + 3);&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove an entry into FullCAN Table */&lt;BR /&gt; Status Chip_CAN_RemoveFullCANEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; int16_t Position) {&lt;BR /&gt; return removeLUTEntry(pCANAF, pCANAFRam, CANAF_RAM_FULLCAN_SEC, Position);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove an entry into Individual STD section */&lt;BR /&gt; Status Chip_CAN_RemoveSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; int16_t Position)&lt;BR /&gt; {&lt;BR /&gt; return removeLUTEntry(pCANAF, pCANAFRam, CANAF_RAM_SFF_SEC, Position);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove an entry into Group STD section */&lt;BR /&gt; Status Chip_CAN_RemoveGroupSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; int16_t Position)&lt;BR /&gt; {&lt;BR /&gt; return removeLUTEntry(pCANAF, pCANAFRam, CANAF_RAM_SFF_GRP_SEC, Position);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove an entry into Individual EXT section */&lt;BR /&gt; Status Chip_CAN_RemoveEXTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; int16_t Position) {&lt;BR /&gt; return removeLUTEntry(pCANAF, pCANAFRam, CANAF_RAM_EFF_SEC, Position);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Remove an entry into Group EXT section */&lt;BR /&gt; Status Chip_CAN_RemoveGroupEXTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; int16_t Position)&lt;BR /&gt; {&lt;BR /&gt; return removeLUTEntry(pCANAF, pCANAFRam, CANAF_RAM_EFF_GRP_SEC, Position);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_ReadFullCANEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; uint16_t Position,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; return readSTDEntry(pCANAF, pCANAFRam, Position, true, pEntry);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_ReadSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; uint16_t Position,&lt;BR /&gt; CAN_STD_ID_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; return readSTDEntry(pCANAF, pCANAFRam, Position, false, pEntry);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_ReadGroupSTDEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; uint16_t Position,&lt;BR /&gt; CAN_STD_ID_RANGE_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, CANAF_RAM_SFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = EndRow - StartRow + 1;&lt;BR /&gt; }&lt;BR /&gt; if (Position &amp;gt;= EntryCnt) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;readStdIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position] &amp;gt;&amp;gt; 16, &amp;amp;pEntry-&amp;gt;LowerID);&lt;BR /&gt; readStdIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position] &amp;amp; 0xFFFF, &amp;amp;pEntry-&amp;gt;UpperID);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_ReadEXTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; uint16_t Position,&lt;BR /&gt; CAN_EXT_ID_ENTRY_T *pEntry)&lt;BR /&gt; {&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, CANAF_RAM_EFF_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = EndRow - StartRow + 1;&lt;BR /&gt; }&lt;BR /&gt; if (Position &amp;gt;= EntryCnt) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;readExtIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position], pEntry);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Status Chip_CAN_ReadGroupEXTEntry(LPC_CANAF_T *pCANAF,&lt;BR /&gt; LPC_CANAF_RAM_T *pCANAFRam,&lt;BR /&gt; uint16_t Position,&lt;BR /&gt; CAN_EXT_ID_RANGE_ENTRY_T *pEntry)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt; uint16_t StartRow, EndRow;&lt;BR /&gt; uint16_t EntryCnt = 0;&lt;/P&gt;&lt;P&gt;getSectionAddress(pCANAF, CANAF_RAM_EFF_GRP_SEC, &amp;amp;StartRow, &amp;amp;EndRow);&lt;/P&gt;&lt;P&gt;if (EndRow &amp;gt; StartRow) {&lt;BR /&gt; EntryCnt = (EndRow - StartRow + 1) / 2;&lt;BR /&gt; }&lt;BR /&gt; if (Position &amp;gt;= EntryCnt) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;readExtIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position * 2], &amp;amp;pEntry-&amp;gt;LowerID);&lt;BR /&gt; readExtIDEntry(pCANAFRam-&amp;gt;MASK[StartRow + Position * 2 + 1], &amp;amp;pEntry-&amp;gt;UpperID);&lt;BR /&gt; return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Send CAN Message */&lt;BR /&gt; Status Chip_CAN_Send(LPC_CAN_T *pCAN, CAN_BUFFER_ID_T TxBufID, CAN_MSG_T *pMsg)&lt;BR /&gt; {&lt;BR /&gt; uint8_t i = 0;&lt;BR /&gt; LPC_CAN_TX_T TxFrame;&lt;/P&gt;&lt;P&gt;/* Write Frame Information */&lt;BR /&gt; TxFrame.TFI = 0;&lt;BR /&gt; if (pMsg-&amp;gt;Type &amp;amp; CAN_REMOTE_MSG) {&lt;BR /&gt; TxFrame.TFI |= CAN_TFI_RTR;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; TxFrame.TFI |= CAN_TFI_DLC(pMsg-&amp;gt;DLC);&lt;BR /&gt; for (i = 0; i &amp;lt; (CAN_MSG_MAX_DATA_LEN + 3) / 4; i++) {&lt;BR /&gt; TxFrame.TD[i] =&lt;BR /&gt; pMsg-&amp;gt;Data[4 *&lt;BR /&gt; i] |&lt;BR /&gt; (pMsg-&amp;gt;Data[4 * i +&lt;BR /&gt; 1] &amp;lt;&amp;lt; 8) | (pMsg-&amp;gt;Data[4 * i + 2] &amp;lt;&amp;lt; 16) | (pMsg-&amp;gt;Data[4 * i + 3] &amp;lt;&amp;lt; 24);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (pMsg-&amp;gt;ID &amp;amp; CAN_EXTEND_ID_USAGE) {&lt;BR /&gt; TxFrame.TFI |= CAN_TFI_FF;&lt;BR /&gt; TxFrame.TID = CAN_TID_ID29(pMsg-&amp;gt;ID);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; TxFrame.TID = CAN_TID_ID11(pMsg-&amp;gt;ID);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Set message information */&lt;BR /&gt; setSendFrameInfo(pCAN, TxBufID, &amp;amp;TxFrame);&lt;/P&gt;&lt;P&gt;/* Select buffer and Write Transmission Request */&lt;BR /&gt; if (Chip_CAN_GetMode(pCAN) == CAN_SELFTEST_MODE) {&lt;BR /&gt; Chip_CAN_SetCmd(pCAN, CAN_CMR_STB(TxBufID) | CAN_CMR_SRR);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; Chip_CAN_SetCmd(pCAN, CAN_CMR_STB(TxBufID) | CAN_CMR_TR);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Receive CAN Message */&lt;BR /&gt; Status Chip_CAN_Receive(LPC_CAN_T *pCAN, CAN_MSG_T *pMsg) {&lt;BR /&gt; int8_t i;&lt;BR /&gt; IP_CAN_001_RX_T RxFrame;&lt;BR /&gt; if (getReceiveFrameInfo(pCAN, &amp;amp;RxFrame) == SUCCESS) {&lt;/P&gt;&lt;P&gt;/* Read Message Identifier */&lt;BR /&gt; if (RxFrame.RFS &amp;amp; CAN_RFS_FF) {&lt;BR /&gt; pMsg-&amp;gt;ID = CAN_EXTEND_ID_USAGE | CAN_RID_ID_29(RxFrame.RID);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; pMsg-&amp;gt;ID = CAN_RID_ID_11(RxFrame.RID);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Read Data Length */&lt;BR /&gt; pMsg-&amp;gt;DLC = CAN_RFS_DLC(RxFrame.RFS);&lt;/P&gt;&lt;P&gt;/* Read Message Type */&lt;BR /&gt; pMsg-&amp;gt;Type = 0;&lt;BR /&gt; if (RxFrame.RFS &amp;amp; CAN_RFS_RTR) {&lt;BR /&gt; pMsg-&amp;gt;Type |= CAN_REMOTE_MSG;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; /* Read data only if the received message is not Remote message */&lt;BR /&gt; for (i = 0; i &amp;lt; CAN_MSG_MAX_DATA_LEN; i++) {&lt;BR /&gt; pMsg-&amp;gt;Data[i] = (RxFrame.RD[i / 4] &amp;gt;&amp;gt; (8 * (i % 4))) &amp;amp; 0xFF;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Release received message */&lt;BR /&gt; Chip_CAN_SetCmd(pCAN, CAN_CMR_RRB);&lt;/P&gt;&lt;P&gt;return SUCCESS;&lt;BR /&gt; }&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Enable/Disable FullCAN interrupt */&lt;BR /&gt; void Chip_CAN_ConfigFullCANInt(LPC_CANAF_T *pCANAF, FunctionalState NewState)&lt;BR /&gt; {&lt;BR /&gt; CAN_AF_MODE_T CurMode = Chip_CAN_GetAFMode(pCANAF);&lt;/P&gt;&lt;P&gt;/* AF Off */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CAN_AF_OFF_MODE);&lt;/P&gt;&lt;P&gt;if (NewState == ENABLE) {&lt;BR /&gt; pCANAF-&amp;gt;FCANIE |= CANAF_FCANIE;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; pCANAF-&amp;gt;FCANIE &amp;amp;= (~CANAF_FCANIE) &amp;amp; CANAF_FCANIE_BITMASK;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Return to previous mode */&lt;BR /&gt; Chip_CAN_SetAFMode(pCANAF, CurMode);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Get interrupt status of the given object */&lt;BR /&gt; uint32_t Chip_CAN_GetFullCANIntStatus(LPC_CANAF_T *pCANAF, uint8_t ObjID)&lt;BR /&gt; {&lt;BR /&gt; if (ObjID &amp;lt; 64) {&lt;BR /&gt; return (pCANAF-&amp;gt;FCANIC[ObjID / 32] &amp;amp; (1 &amp;lt;&amp;lt; (ObjID % 32))) ? SET : RESET;&lt;BR /&gt; }&lt;BR /&gt; return RESET;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Read FullCAN message received */&lt;BR /&gt; Status Chip_CAN_FullCANReceive(LPC_CANAF_T *pCANAF, LPC_CANAF_RAM_T *pCANAFRam&lt;BR /&gt; , uint8_t ObjID, CAN_MSG_T *pMsg, uint8_t *pSCC) {&lt;BR /&gt; uint32_t *pSrc;&lt;BR /&gt; uint16_t FullCANEntryCnt;&lt;BR /&gt; pSrc = (uint32_t *) pCANAFRam;&lt;/P&gt;&lt;P&gt;FullCANEntryCnt = getTotalEntryNum(pCANAF);&lt;BR /&gt; pSrc += FullCANEntryCnt + ObjID * 3;&lt;BR /&gt; /* If the AF hasn't finished updating msg info */&lt;BR /&gt; if (((pSrc[0] &amp;gt;&amp;gt; CANAF_FULLCAN_MSG_SEM_POS) &amp;amp; CANAF_FULLCAN_MSG_SEM_BITMASK) !=&lt;BR /&gt; CANAF_FULCAN_MSG_AF_FINISHED) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Mark that CPU is handling message */&lt;BR /&gt; pSrc[0] = CANAF_FULCAN_MSG_CPU_READING &amp;lt;&amp;lt; CANAF_FULLCAN_MSG_SEM_POS;&lt;/P&gt;&lt;P&gt;/* Read Message */&lt;BR /&gt; *pSCC = (pSrc[0] &amp;gt;&amp;gt; CANAF_FULLCAN_MSG_SCC_POS) &amp;amp; CANAF_FULLCAN_MSG_SCC_BITMASK;&lt;BR /&gt; pMsg-&amp;gt;ID = (pSrc[0] &amp;gt;&amp;gt; CANAF_FULLCAN_MSG_ID11_POS) &amp;amp; CANAF_FULLCAN_MSG_ID11_BITMASK;&lt;BR /&gt; pMsg-&amp;gt;Type = 0;&lt;BR /&gt; if (pSrc[0] &amp;amp; (1 &amp;lt;&amp;lt; CANAF_FULLCAN_MSG_RTR_POS)) {&lt;BR /&gt; pMsg-&amp;gt;Type = CAN_REMOTE_MSG;&lt;BR /&gt; }&lt;BR /&gt; pMsg-&amp;gt;DLC = (pSrc[0] &amp;gt;&amp;gt; CANAF_FULLCAN_MSG_DLC_POS) &amp;amp; CANAF_FULLCAN_MSG_DLC_BITMASK;&lt;BR /&gt; ((uint32_t *) pMsg-&amp;gt;Data)[0] = pSrc[1];&lt;BR /&gt; ((uint32_t *) pMsg-&amp;gt;Data)[1] = pSrc[2];&lt;/P&gt;&lt;P&gt;/* Recheck message status to make sure data is not be updated while CPU is reading */&lt;BR /&gt; if (((pSrc[0] &amp;gt;&amp;gt; CANAF_FULLCAN_MSG_SEM_POS) &amp;amp; CANAF_FULLCAN_MSG_SEM_BITMASK) !=&lt;BR /&gt; CANAF_FULCAN_MSG_CPU_READING) {&lt;BR /&gt; return ERROR;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return SUCCESS;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;// TODO: insert code here&lt;/P&gt;&lt;P&gt;// Force the counter to be placed into memory&lt;BR /&gt; volatile static int i = 0 ;&lt;BR /&gt; // Enter an infinite loop, just incrementing a counter&lt;BR /&gt; while(1) {&lt;BR /&gt; i++ ;&lt;BR /&gt; }&lt;BR /&gt; return 0 ;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 08:31:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750117#M30205</guid>
      <dc:creator>sharuqueshaji</dc:creator>
      <dc:date>2018-02-15T08:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: trying to execute the following code the following error occurs</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750118#M30206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sharuque,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you tell us more information about what you are trying to achieve? Which MCU are you using? Are you using the periph_can LPCOpen example as base for your application? Which error are you getting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carlos Mendoza&lt;BR /&gt;Technical Support Engineer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 02:29:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750118#M30206</guid>
      <dc:creator>Carlos_Mendoza</dc:creator>
      <dc:date>2018-02-20T02:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: trying to execute the following code the following error occurs</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750119#M30207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THANK YOU FOR YOUR SUPPORT.&lt;/P&gt;&lt;P&gt;I am using lpc1769 and the program code is from the lpcopen&amp;nbsp;given during program setup. Whe I replace the following code&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;#if defined (__USE_LPCOPEN)&lt;BR /&gt;#if defined(NO_BOARD_LIB)&lt;BR /&gt;#include "chip.h"&lt;BR /&gt;#else&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#endif&lt;BR /&gt;#endif&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;#include &amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;#include &amp;lt;can_17xx_40xx.h&amp;gt;&lt;BR /&gt;#include&amp;lt;uart_17xx_40xx.h&amp;gt;&lt;BR /&gt;// TODO: insert other include files here&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;// TODO: insert other definitions and declarations here&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;int main(void) {&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;#if defined (__USE_LPCOPEN)&lt;BR /&gt;// Read clock settings and update SystemCoreClock variable&lt;BR /&gt;SystemCoreClockUpdate();&lt;BR /&gt;#if !defined(NO_BOARD_LIB)&lt;BR /&gt;// Set up and initialize all required blocks and&lt;BR /&gt;// functions related to the board hardware&lt;BR /&gt;Board_Init();&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;BR /&gt;// Set the LED to the state of "On"&lt;BR /&gt;Board_LED_Set(0, true);&lt;BR /&gt;#endif&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;in the above program with&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;#include "chip.h" only following error occurs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;../src/test3.c:717:24: warning: variable 'i' set but not used [-Wunused-but-set-variable]&lt;BR /&gt; volatile uint32_t i;&lt;BR /&gt; ^&lt;BR /&gt;../src/test3.c: At top level:&lt;BR /&gt;../src/test3.c:1481:1: error: expected identifier or '(' before '}' token&lt;BR /&gt; }&lt;BR /&gt; ^&lt;BR /&gt;make: *** [src/test3.o] Error 1&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Feb 2018 09:34:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/trying-to-execute-the-following-code-the-following-error-occurs/m-p/750119#M30207</guid>
      <dc:creator>sharuqueshaji</dc:creator>
      <dc:date>2018-02-27T09:34:13Z</dc:date>
    </item>
  </channel>
</rss>

