These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frank26080115 0:bf7b9fba3924 1 /***********************************************************************//**
frank26080115 0:bf7b9fba3924 2 * @file can_AFLUT_dynamic.c
frank26080115 0:bf7b9fba3924 3 * @purpose This example used to test acceptance filter operation and
frank26080115 0:bf7b9fba3924 4 * functions that support load/remove AFLUT entry dynamically
frank26080115 0:bf7b9fba3924 5 * @version 2.0
frank26080115 0:bf7b9fba3924 6 * @date 21. May. 2010
frank26080115 0:bf7b9fba3924 7 * @author NXP MCU SW Application Team
frank26080115 0:bf7b9fba3924 8 *---------------------------------------------------------------------
frank26080115 0:bf7b9fba3924 9 * Software that is described herein is for illustrative purposes only
frank26080115 0:bf7b9fba3924 10 * which provides customers with programming information regarding the
frank26080115 0:bf7b9fba3924 11 * products. This software is supplied "AS IS" without any warranties.
frank26080115 0:bf7b9fba3924 12 * NXP Semiconductors assumes no responsibility or liability for the
frank26080115 0:bf7b9fba3924 13 * use of the software, conveys no license or title under any patent,
frank26080115 0:bf7b9fba3924 14 * copyright, or mask work right to the product. NXP Semiconductors
frank26080115 0:bf7b9fba3924 15 * reserves the right to make changes in the software without
frank26080115 0:bf7b9fba3924 16 * notification. NXP Semiconductors also make no representation or
frank26080115 0:bf7b9fba3924 17 * warranty that such application will be suitable for the specified
frank26080115 0:bf7b9fba3924 18 * use without further testing or modification.
frank26080115 0:bf7b9fba3924 19 **********************************************************************/
frank26080115 0:bf7b9fba3924 20 #include "lpc17xx_can.h"
frank26080115 0:bf7b9fba3924 21 #include "lpc17xx_libcfg.h"
frank26080115 0:bf7b9fba3924 22 #include "lpc17xx_pinsel.h"
frank26080115 0:bf7b9fba3924 23 #include "debug_frmwrk.h"
frank26080115 0:bf7b9fba3924 24
frank26080115 0:bf7b9fba3924 25 /* Example group ----------------------------------------------------------- */
frank26080115 0:bf7b9fba3924 26 /** @defgroup CAN_test_aflut CAN_test_aflut
frank26080115 0:bf7b9fba3924 27 * @ingroup CAN_Examples
frank26080115 0:bf7b9fba3924 28 * @{
frank26080115 0:bf7b9fba3924 29 */
frank26080115 0:bf7b9fba3924 30
frank26080115 0:bf7b9fba3924 31 /************************** PRIVATE DEFINTIONS*************************/
frank26080115 0:bf7b9fba3924 32 #define MAX_ENTRY 512
frank26080115 0:bf7b9fba3924 33 #define CAN_TX_MSG_CNT 10
frank26080115 0:bf7b9fba3924 34 #define CAN_RX_MSG_CNT 5
frank26080115 0:bf7b9fba3924 35
frank26080115 0:bf7b9fba3924 36 /************************** PRIVATE VARIABLES *************************/
frank26080115 0:bf7b9fba3924 37 uint8_t menu[]=
frank26080115 0:bf7b9fba3924 38 "********************************************************************************\n\r"
frank26080115 0:bf7b9fba3924 39 "Hello NXP Semiconductors \n\r"
frank26080115 0:bf7b9fba3924 40 "CAN demo \n\r"
frank26080115 0:bf7b9fba3924 41 "\t - MCU: LPC17xx \n\r"
frank26080115 0:bf7b9fba3924 42 "\t - Core: ARM CORTEX-M3 \n\r"
frank26080115 0:bf7b9fba3924 43 "\t - Communicate via: UART0 - 115200 bps \n\r"
frank26080115 0:bf7b9fba3924 44 "Use 2 CAN peripherals: CAN1&CAN2 to transfer data\n\r"
frank26080115 0:bf7b9fba3924 45 "This example tests full Acceptance Filter operation \n\r"
frank26080115 0:bf7b9fba3924 46 "and load/remove AFLUT entry dynamically functions \n\r"
frank26080115 0:bf7b9fba3924 47 "********************************************************************************\n\r";
frank26080115 0:bf7b9fba3924 48
frank26080115 0:bf7b9fba3924 49 //messages for test Acceptance Filter mode
frank26080115 0:bf7b9fba3924 50 CAN_MSG_Type AFTxMsg[CAN_TX_MSG_CNT], AFRxMsg[CAN_RX_MSG_CNT];
frank26080115 0:bf7b9fba3924 51 uint32_t CANRxCount = 0, CANTxCount = 0;
frank26080115 0:bf7b9fba3924 52 uint32_t CANErrCount = 0;
frank26080115 0:bf7b9fba3924 53
frank26080115 0:bf7b9fba3924 54 AF_SectionDef AFTable;
frank26080115 0:bf7b9fba3924 55 FullCAN_Entry FullCAN_Table[6];
frank26080115 0:bf7b9fba3924 56 SFF_Entry SFF_Table[6];
frank26080115 0:bf7b9fba3924 57 SFF_GPR_Entry SFF_GPR_Table[6];
frank26080115 0:bf7b9fba3924 58 EFF_Entry EFF_Table[6];
frank26080115 0:bf7b9fba3924 59 EFF_GPR_Entry EFF_GPR_Table[6];
frank26080115 0:bf7b9fba3924 60
frank26080115 0:bf7b9fba3924 61 /************************** PRIVATE FUNCTIONS *************************/
frank26080115 0:bf7b9fba3924 62 /* CAN interrupt service routine */
frank26080115 0:bf7b9fba3924 63 void CAN_IRQHandler(void);
frank26080115 0:bf7b9fba3924 64
frank26080115 0:bf7b9fba3924 65 void CAN_PinCfg(void);
frank26080115 0:bf7b9fba3924 66 void CAN_InitMessage(void);
frank26080115 0:bf7b9fba3924 67 void CAN_SetupAFTable(void);
frank26080115 0:bf7b9fba3924 68 void CAN_InitAFMessage(void);
frank26080115 0:bf7b9fba3924 69 void PrintMessage(CAN_MSG_Type* msg);
frank26080115 0:bf7b9fba3924 70 void print_menu(void);
frank26080115 0:bf7b9fba3924 71
frank26080115 0:bf7b9fba3924 72 /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
frank26080115 0:bf7b9fba3924 73 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 74 * @brief CAN IRQ Handler
frank26080115 0:bf7b9fba3924 75 * @param[in] none
frank26080115 0:bf7b9fba3924 76 * @return none
frank26080115 0:bf7b9fba3924 77 **********************************************************************/
frank26080115 0:bf7b9fba3924 78 void CAN_IRQHandler(void)
frank26080115 0:bf7b9fba3924 79 {
frank26080115 0:bf7b9fba3924 80 uint8_t IntStatus;
frank26080115 0:bf7b9fba3924 81 //check FullCAN interrupt enable or not
frank26080115 0:bf7b9fba3924 82 if(CAN_FullCANIntGetStatus(LPC_CANAF)== SET)
frank26080115 0:bf7b9fba3924 83 { //check is FullCAN interrupt occurs or not
frank26080115 0:bf7b9fba3924 84 if ((CAN_FullCANPendGetStatus(LPC_CANAF,FULLCAN_IC0))
frank26080115 0:bf7b9fba3924 85 ||(CAN_FullCANPendGetStatus(LPC_CANAF,FULLCAN_IC1)))
frank26080115 0:bf7b9fba3924 86 {
frank26080115 0:bf7b9fba3924 87 //read received FullCAN Object in Object Section
frank26080115 0:bf7b9fba3924 88 FCAN_ReadObj(LPC_CANAF, &AFRxMsg[CANRxCount]);
frank26080115 0:bf7b9fba3924 89 CANRxCount++;
frank26080115 0:bf7b9fba3924 90 }
frank26080115 0:bf7b9fba3924 91 }
frank26080115 0:bf7b9fba3924 92 /* get interrupt status
frank26080115 0:bf7b9fba3924 93 * Note that: Interrupt register CANICR will be reset after read.
frank26080115 0:bf7b9fba3924 94 * So function "CAN_IntGetStatus" should be call only one time
frank26080115 0:bf7b9fba3924 95 */
frank26080115 0:bf7b9fba3924 96 IntStatus = CAN_IntGetStatus(LPC_CAN2);
frank26080115 0:bf7b9fba3924 97 //check receive interrupt
frank26080115 0:bf7b9fba3924 98 if((IntStatus>>0)&0x01)
frank26080115 0:bf7b9fba3924 99 {
frank26080115 0:bf7b9fba3924 100 CAN_ReceiveMsg(LPC_CAN2, &AFRxMsg[CANRxCount]);
frank26080115 0:bf7b9fba3924 101 CANRxCount++;
frank26080115 0:bf7b9fba3924 102 }
frank26080115 0:bf7b9fba3924 103 }
frank26080115 0:bf7b9fba3924 104
frank26080115 0:bf7b9fba3924 105 /*-------------------------PRIVATE FUNCTIONS----------------------------*/
frank26080115 0:bf7b9fba3924 106 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 107 * @brief Print Message via COM1
frank26080115 0:bf7b9fba3924 108 * param[in] msg: point to CAN_MSG_Type object that will be printed
frank26080115 0:bf7b9fba3924 109 * @return none
frank26080115 0:bf7b9fba3924 110 **********************************************************************/
frank26080115 0:bf7b9fba3924 111 void PrintMessage(CAN_MSG_Type* CAN_Msg)
frank26080115 0:bf7b9fba3924 112 {
frank26080115 0:bf7b9fba3924 113 uint32_t data;
frank26080115 0:bf7b9fba3924 114 _DBG("Message ID: ");
frank26080115 0:bf7b9fba3924 115 _DBH32(CAN_Msg->id);_DBG_("");
frank26080115 0:bf7b9fba3924 116 _DBG("Message length: ");
frank26080115 0:bf7b9fba3924 117 _DBH32(CAN_Msg->len);_DBG_(" BYTES");
frank26080115 0:bf7b9fba3924 118 _DBG("Message type: ");
frank26080115 0:bf7b9fba3924 119 if(CAN_Msg->type==DATA_FRAME)
frank26080115 0:bf7b9fba3924 120 {
frank26080115 0:bf7b9fba3924 121 _DBG_("DATA FRAME ");
frank26080115 0:bf7b9fba3924 122 }
frank26080115 0:bf7b9fba3924 123 else
frank26080115 0:bf7b9fba3924 124 _DBG_("REMOTE FRAME ");
frank26080115 0:bf7b9fba3924 125 _DBG("Message format: ");
frank26080115 0:bf7b9fba3924 126 if(CAN_Msg->format==STD_ID_FORMAT)
frank26080115 0:bf7b9fba3924 127 {
frank26080115 0:bf7b9fba3924 128 _DBG_("STANDARD ID FRAME FORMAT");
frank26080115 0:bf7b9fba3924 129 }
frank26080115 0:bf7b9fba3924 130 else
frank26080115 0:bf7b9fba3924 131 _DBG_("EXTENDED ID FRAME FORMAT");
frank26080115 0:bf7b9fba3924 132 _DBG("Message dataA: ");
frank26080115 0:bf7b9fba3924 133 data = (CAN_Msg->dataA[0])|(CAN_Msg->dataA[1]<<8)|(CAN_Msg->dataA[2]<<16)|(CAN_Msg->dataA[3]<<24);
frank26080115 0:bf7b9fba3924 134 _DBH32(data);_DBG_("");
frank26080115 0:bf7b9fba3924 135 data = (CAN_Msg->dataB[0])|(CAN_Msg->dataB[1]<<8)|(CAN_Msg->dataB[2]<<16)|(CAN_Msg->dataB[3]<<24);
frank26080115 0:bf7b9fba3924 136 _DBG("Message dataB: ");
frank26080115 0:bf7b9fba3924 137 _DBH32(data);_DBG_("");
frank26080115 0:bf7b9fba3924 138 _DBG_("");
frank26080115 0:bf7b9fba3924 139 }
frank26080115 0:bf7b9fba3924 140
frank26080115 0:bf7b9fba3924 141 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 142 * @brief Init AF-Look Up Table Sections entry value
frank26080115 0:bf7b9fba3924 143 * We setup entries for 5 sections:
frank26080115 0:bf7b9fba3924 144 * - 6 entries for FullCAN Frame Format Section
frank26080115 0:bf7b9fba3924 145 * - 6 entries for Explicit Standard ID Frame Format Section
frank26080115 0:bf7b9fba3924 146 * - 6 entries for Group of Standard ID Frame Format Section
frank26080115 0:bf7b9fba3924 147 * - 6 entries for Explicit Extended ID Frame Format Section
frank26080115 0:bf7b9fba3924 148 * - 6 entries for Group of Extended ID Frame Format Section
frank26080115 0:bf7b9fba3924 149 * @param[in] none
frank26080115 0:bf7b9fba3924 150 * @return none
frank26080115 0:bf7b9fba3924 151 **********************************************************************/
frank26080115 0:bf7b9fba3924 152 void CAN_SetupAFTable(void) {
frank26080115 0:bf7b9fba3924 153 FullCAN_Table[0].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 154 FullCAN_Table[0].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 155 FullCAN_Table[0].id_11 = 0x01;
frank26080115 0:bf7b9fba3924 156 FullCAN_Table[1].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 157 FullCAN_Table[1].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 158 FullCAN_Table[1].id_11 = 0x02;
frank26080115 0:bf7b9fba3924 159 FullCAN_Table[2].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 160 FullCAN_Table[2].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 161 FullCAN_Table[2].id_11 = 0x03;
frank26080115 0:bf7b9fba3924 162 FullCAN_Table[3].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 163 FullCAN_Table[3].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 164 FullCAN_Table[3].id_11 = 0x06;
frank26080115 0:bf7b9fba3924 165 FullCAN_Table[4].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 166 FullCAN_Table[4].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 167 FullCAN_Table[4].id_11 = 0x0C;
frank26080115 0:bf7b9fba3924 168 FullCAN_Table[5].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 169 FullCAN_Table[5].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 170 FullCAN_Table[5].id_11 = 0x0D;
frank26080115 0:bf7b9fba3924 171
frank26080115 0:bf7b9fba3924 172 SFF_Table[0].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 173 SFF_Table[0].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 174 SFF_Table[0].id_11 = 0x08;
frank26080115 0:bf7b9fba3924 175 SFF_Table[1].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 176 SFF_Table[1].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 177 SFF_Table[1].id_11 = 0x09;
frank26080115 0:bf7b9fba3924 178 SFF_Table[2].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 179 SFF_Table[2].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 180 SFF_Table[2].id_11 = 0x0A;
frank26080115 0:bf7b9fba3924 181 SFF_Table[3].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 182 SFF_Table[3].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 183 SFF_Table[3].id_11 = 0x0B;
frank26080115 0:bf7b9fba3924 184 SFF_Table[4].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 185 SFF_Table[4].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 186 SFF_Table[4].id_11 = 0x0E;
frank26080115 0:bf7b9fba3924 187 SFF_Table[5].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 188 SFF_Table[5].disable = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 189 SFF_Table[5].id_11 = 0x0F;
frank26080115 0:bf7b9fba3924 190
frank26080115 0:bf7b9fba3924 191 SFF_GPR_Table[0].controller1 = SFF_GPR_Table[0].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 192 SFF_GPR_Table[0].disable1 = SFF_GPR_Table[0].disable2 = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 193 SFF_GPR_Table[0].lowerID = 0x10;
frank26080115 0:bf7b9fba3924 194 SFF_GPR_Table[0].upperID = 0x20;
frank26080115 0:bf7b9fba3924 195 SFF_GPR_Table[1].controller1 = SFF_GPR_Table[1].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 196 SFF_GPR_Table[1].disable1 = SFF_GPR_Table[1].disable2 = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 197 SFF_GPR_Table[1].lowerID = 0x20;
frank26080115 0:bf7b9fba3924 198 SFF_GPR_Table[1].upperID = 0x25;
frank26080115 0:bf7b9fba3924 199 SFF_GPR_Table[2].controller1 = SFF_GPR_Table[2].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 200 SFF_GPR_Table[2].disable1 = SFF_GPR_Table[2].disable2 = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 201 SFF_GPR_Table[2].lowerID = 0x30;
frank26080115 0:bf7b9fba3924 202 SFF_GPR_Table[2].upperID = 0x40;
frank26080115 0:bf7b9fba3924 203 SFF_GPR_Table[3].controller1 = SFF_GPR_Table[3].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 204 SFF_GPR_Table[3].disable1 = SFF_GPR_Table[3].disable2 = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 205 SFF_GPR_Table[3].lowerID = 0x40;
frank26080115 0:bf7b9fba3924 206 SFF_GPR_Table[3].upperID = 0x50;
frank26080115 0:bf7b9fba3924 207 SFF_GPR_Table[4].controller1 = SFF_GPR_Table[4].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 208 SFF_GPR_Table[4].disable1 = SFF_GPR_Table[4].disable2 = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 209 SFF_GPR_Table[4].lowerID = 0x50;
frank26080115 0:bf7b9fba3924 210 SFF_GPR_Table[4].upperID = 0x60;
frank26080115 0:bf7b9fba3924 211 SFF_GPR_Table[5].controller1 = SFF_GPR_Table[5].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 212 SFF_GPR_Table[5].disable1 = SFF_GPR_Table[5].disable2 = MSG_ENABLE;
frank26080115 0:bf7b9fba3924 213 SFF_GPR_Table[5].lowerID = 0x60;
frank26080115 0:bf7b9fba3924 214 SFF_GPR_Table[5].upperID = 0x70;
frank26080115 0:bf7b9fba3924 215
frank26080115 0:bf7b9fba3924 216 EFF_Table[0].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 217 EFF_Table[0].ID_29 = (1 << 11);
frank26080115 0:bf7b9fba3924 218 EFF_Table[1].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 219 EFF_Table[1].ID_29 = (2 << 11);
frank26080115 0:bf7b9fba3924 220 EFF_Table[2].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 221 EFF_Table[2].ID_29 = (3 << 11);
frank26080115 0:bf7b9fba3924 222 EFF_Table[3].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 223 EFF_Table[3].ID_29 = (4 << 11);
frank26080115 0:bf7b9fba3924 224 EFF_Table[4].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 225 EFF_Table[4].ID_29 = (0x0e << 11);
frank26080115 0:bf7b9fba3924 226 EFF_Table[5].controller = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 227 EFF_Table[5].ID_29 = (0x0f << 11);
frank26080115 0:bf7b9fba3924 228
frank26080115 0:bf7b9fba3924 229 EFF_GPR_Table[0].controller1 = EFF_GPR_Table[0].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 230 EFF_GPR_Table[0].lowerEID = (5 << 11);
frank26080115 0:bf7b9fba3924 231 EFF_GPR_Table[0].upperEID = (6 << 11);
frank26080115 0:bf7b9fba3924 232 EFF_GPR_Table[1].controller1 = EFF_GPR_Table[1].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 233 EFF_GPR_Table[1].lowerEID = (7 << 11);
frank26080115 0:bf7b9fba3924 234 EFF_GPR_Table[1].upperEID = (8 << 11);
frank26080115 0:bf7b9fba3924 235 EFF_GPR_Table[2].controller1 = EFF_GPR_Table[2].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 236 EFF_GPR_Table[2].lowerEID = (9 << 11);
frank26080115 0:bf7b9fba3924 237 EFF_GPR_Table[2].upperEID = (0x0a << 11);
frank26080115 0:bf7b9fba3924 238 EFF_GPR_Table[3].controller1 = EFF_GPR_Table[3].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 239 EFF_GPR_Table[3].lowerEID = (0x0b << 11);
frank26080115 0:bf7b9fba3924 240 EFF_GPR_Table[3].upperEID = (0x0c << 11);
frank26080115 0:bf7b9fba3924 241 EFF_GPR_Table[4].controller1 = EFF_GPR_Table[4].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 242 EFF_GPR_Table[4].lowerEID = (0x11 << 11);
frank26080115 0:bf7b9fba3924 243 EFF_GPR_Table[4].upperEID = (0x12 << 11);
frank26080115 0:bf7b9fba3924 244 EFF_GPR_Table[5].controller1 = EFF_GPR_Table[5].controller2 = CAN2_CTRL;
frank26080115 0:bf7b9fba3924 245 EFF_GPR_Table[5].lowerEID = (0x13 << 11);
frank26080115 0:bf7b9fba3924 246 EFF_GPR_Table[5].upperEID = (0x14 << 11);
frank26080115 0:bf7b9fba3924 247
frank26080115 0:bf7b9fba3924 248 AFTable.FullCAN_Sec = &FullCAN_Table[0];
frank26080115 0:bf7b9fba3924 249 AFTable.FC_NumEntry = 6;
frank26080115 0:bf7b9fba3924 250 AFTable.SFF_Sec = &SFF_Table[0];
frank26080115 0:bf7b9fba3924 251 AFTable.SFF_NumEntry = 6;
frank26080115 0:bf7b9fba3924 252 AFTable.SFF_GPR_Sec = &SFF_GPR_Table[0];
frank26080115 0:bf7b9fba3924 253 AFTable.SFF_GPR_NumEntry = 6;
frank26080115 0:bf7b9fba3924 254 AFTable.EFF_Sec = &EFF_Table[0];
frank26080115 0:bf7b9fba3924 255 AFTable.EFF_NumEntry = 6;
frank26080115 0:bf7b9fba3924 256 AFTable.EFF_GPR_Sec = &EFF_GPR_Table[0];
frank26080115 0:bf7b9fba3924 257 AFTable.EFF_GPR_NumEntry = 6;
frank26080115 0:bf7b9fba3924 258 }
frank26080115 0:bf7b9fba3924 259 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 260 * @brief Change AFLUT table
frank26080115 0:bf7b9fba3924 261 * @param[in] none
frank26080115 0:bf7b9fba3924 262 * @return none
frank26080115 0:bf7b9fba3924 263 **********************************************************************/
frank26080115 0:bf7b9fba3924 264 void CAN_ChangeAFTable(void)
frank26080115 0:bf7b9fba3924 265 {
frank26080115 0:bf7b9fba3924 266 CAN_LoadFullCANEntry(LPC_CAN2, 4);
frank26080115 0:bf7b9fba3924 267 CAN_LoadExplicitEntry(LPC_CAN2, 5, STD_ID_FORMAT);
frank26080115 0:bf7b9fba3924 268 CAN_LoadGroupEntry(LPC_CAN2,0x25,0x30, STD_ID_FORMAT);
frank26080115 0:bf7b9fba3924 269 CAN_LoadExplicitEntry(LPC_CAN2, (3<<11)+0x05, EXT_ID_FORMAT);
frank26080115 0:bf7b9fba3924 270 CAN_LoadGroupEntry(LPC_CAN2,(0x0a<<11),(0x0b<<11), EXT_ID_FORMAT);
frank26080115 0:bf7b9fba3924 271
frank26080115 0:bf7b9fba3924 272 CAN_RemoveEntry(FULLCAN_ENTRY, 0);
frank26080115 0:bf7b9fba3924 273 CAN_RemoveEntry(EXPLICIT_STANDARD_ENTRY, 0);
frank26080115 0:bf7b9fba3924 274 CAN_RemoveEntry(GROUP_STANDARD_ENTRY, 0);
frank26080115 0:bf7b9fba3924 275 CAN_RemoveEntry(EXPLICIT_EXTEND_ENTRY, 2);
frank26080115 0:bf7b9fba3924 276 CAN_RemoveEntry(GROUP_EXTEND_ENTRY, 2);
frank26080115 0:bf7b9fba3924 277
frank26080115 0:bf7b9fba3924 278 }
frank26080115 0:bf7b9fba3924 279 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 280 * @brief Init Transmit Message
frank26080115 0:bf7b9fba3924 281 * We use 10 message to test Acceptance Filter operation, include:
frank26080115 0:bf7b9fba3924 282 * - 5 messages that ID exit in 5 AF Sections -> they will be receive
frank26080115 0:bf7b9fba3924 283 * - 5 messages that ID not exit in 5 AF Sections -> they will be ignored
frank26080115 0:bf7b9fba3924 284 * @param[in] none
frank26080115 0:bf7b9fba3924 285 * @return none
frank26080115 0:bf7b9fba3924 286 **********************************************************************/
frank26080115 0:bf7b9fba3924 287 void CAN_InitAFMessage(void) {
frank26080115 0:bf7b9fba3924 288 /* 1st Message with 11-bit ID which exit in AF Look-up Table in FullCAN Section */
frank26080115 0:bf7b9fba3924 289 AFTxMsg[0].id = 0x01;
frank26080115 0:bf7b9fba3924 290 AFTxMsg[0].len = 0x08;
frank26080115 0:bf7b9fba3924 291 AFTxMsg[0].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 292 AFTxMsg[0].format = STD_ID_FORMAT;
frank26080115 0:bf7b9fba3924 293 AFTxMsg[0].dataA[0] = AFTxMsg[0].dataA[1] = AFTxMsg[0].dataA[2]= AFTxMsg[0].dataA[3]= 0x78;
frank26080115 0:bf7b9fba3924 294 AFTxMsg[0].dataB[0] = AFTxMsg[0].dataB[1] = AFTxMsg[0].dataB[2]= AFTxMsg[0].dataB[3]= 0x21;
frank26080115 0:bf7b9fba3924 295
frank26080115 0:bf7b9fba3924 296 /* 2nd Message with 11-bit ID which not exit in AF Look-up Table */
frank26080115 0:bf7b9fba3924 297 AFTxMsg[1].id = 0x04;
frank26080115 0:bf7b9fba3924 298 AFTxMsg[1].len = 0x08;
frank26080115 0:bf7b9fba3924 299 AFTxMsg[1].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 300 AFTxMsg[1].format = STD_ID_FORMAT;
frank26080115 0:bf7b9fba3924 301 AFTxMsg[1].dataA[0] = AFTxMsg[1].dataA[1] = AFTxMsg[1].dataA[2]= AFTxMsg[1].dataA[3]= 0x23;
frank26080115 0:bf7b9fba3924 302 AFTxMsg[1].dataB[0] = AFTxMsg[1].dataB[1] = AFTxMsg[1].dataB[2]= AFTxMsg[1].dataB[3]= 0x45;
frank26080115 0:bf7b9fba3924 303
frank26080115 0:bf7b9fba3924 304 /* 3th Message with 11-bit ID which exit in AF Look-up Table in SFF Section*/
frank26080115 0:bf7b9fba3924 305 AFTxMsg[2].id = 0x08;
frank26080115 0:bf7b9fba3924 306 AFTxMsg[2].len = 0x08;
frank26080115 0:bf7b9fba3924 307 AFTxMsg[2].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 308 AFTxMsg[2].format = STD_ID_FORMAT;
frank26080115 0:bf7b9fba3924 309 AFTxMsg[2].dataA[0] = AFTxMsg[2].dataA[1] = AFTxMsg[2].dataA[2]= AFTxMsg[2].dataA[3]= 0x15;
frank26080115 0:bf7b9fba3924 310 AFTxMsg[2].dataB[0] = AFTxMsg[2].dataB[1] = AFTxMsg[2].dataB[2]= AFTxMsg[2].dataB[3]= 0x36;
frank26080115 0:bf7b9fba3924 311
frank26080115 0:bf7b9fba3924 312 /* 4th Message with 11-bit ID which not exit in AF Look-up Table */
frank26080115 0:bf7b9fba3924 313 AFTxMsg[3].id = 0x05;
frank26080115 0:bf7b9fba3924 314 AFTxMsg[3].len = 0x08;
frank26080115 0:bf7b9fba3924 315 AFTxMsg[3].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 316 AFTxMsg[3].format = STD_ID_FORMAT;
frank26080115 0:bf7b9fba3924 317 AFTxMsg[3].dataA[0] = AFTxMsg[3].dataA[1] = AFTxMsg[3].dataA[2]= AFTxMsg[3].dataA[3]= 0x78;
frank26080115 0:bf7b9fba3924 318 AFTxMsg[3].dataB[0] = AFTxMsg[3].dataB[1] = AFTxMsg[3].dataB[2]= AFTxMsg[3].dataB[3]= 0x21;
frank26080115 0:bf7b9fba3924 319
frank26080115 0:bf7b9fba3924 320 /* 5th Message with 11-bit ID which exit in AF Look-up Table in Group SFF Section*/
frank26080115 0:bf7b9fba3924 321 AFTxMsg[4].id = 0x15;
frank26080115 0:bf7b9fba3924 322 AFTxMsg[4].len = 0x08;
frank26080115 0:bf7b9fba3924 323 AFTxMsg[4].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 324 AFTxMsg[4].format = STD_ID_FORMAT;
frank26080115 0:bf7b9fba3924 325 AFTxMsg[4].dataA[0] = AFTxMsg[4].dataA[1] = AFTxMsg[4].dataA[2]= AFTxMsg[4].dataA[3]= 0x65;
frank26080115 0:bf7b9fba3924 326 AFTxMsg[4].dataB[0] = AFTxMsg[4].dataB[1] = AFTxMsg[4].dataB[2]= AFTxMsg[4].dataB[3]= 0x37;
frank26080115 0:bf7b9fba3924 327
frank26080115 0:bf7b9fba3924 328 /* 6th Message with 11-bit ID which not exit in AF Look-up Table */
frank26080115 0:bf7b9fba3924 329 AFTxMsg[5].id = 0x26;
frank26080115 0:bf7b9fba3924 330 AFTxMsg[5].len = 0x08;
frank26080115 0:bf7b9fba3924 331 AFTxMsg[5].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 332 AFTxMsg[5].format = STD_ID_FORMAT;
frank26080115 0:bf7b9fba3924 333 AFTxMsg[5].dataA[0] = AFTxMsg[5].dataA[1] = AFTxMsg[5].dataA[2]= AFTxMsg[5].dataA[3]= 0x76;
frank26080115 0:bf7b9fba3924 334 AFTxMsg[5].dataB[0] = AFTxMsg[5].dataB[1] = AFTxMsg[5].dataB[2]= AFTxMsg[5].dataB[3]= 0x32;
frank26080115 0:bf7b9fba3924 335
frank26080115 0:bf7b9fba3924 336 /* 7th Message with 29-bit ID which exit in AF Look-up Table in EFF Section */
frank26080115 0:bf7b9fba3924 337 AFTxMsg[6].id = (3 << 11); //0x00001800
frank26080115 0:bf7b9fba3924 338 AFTxMsg[6].len = 0x08;
frank26080115 0:bf7b9fba3924 339 AFTxMsg[6].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 340 AFTxMsg[6].format = EXT_ID_FORMAT;
frank26080115 0:bf7b9fba3924 341 AFTxMsg[6].dataA[0] = AFTxMsg[6].dataA[1] = AFTxMsg[6].dataA[2]= AFTxMsg[6].dataA[3]= 0x45;
frank26080115 0:bf7b9fba3924 342 AFTxMsg[6].dataB[0] = AFTxMsg[6].dataB[1] = AFTxMsg[6].dataB[2]= AFTxMsg[6].dataB[3]= 0x87;
frank26080115 0:bf7b9fba3924 343
frank26080115 0:bf7b9fba3924 344 /* 8th Message with 29-bit ID which not exit in AF Look-up Table */
frank26080115 0:bf7b9fba3924 345 AFTxMsg[7].id = (3 << 11) + 0x05; //0x00001801
frank26080115 0:bf7b9fba3924 346 AFTxMsg[7].len = 0x08;
frank26080115 0:bf7b9fba3924 347 AFTxMsg[7].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 348 AFTxMsg[7].format = EXT_ID_FORMAT;
frank26080115 0:bf7b9fba3924 349 AFTxMsg[7].dataA[0] = AFTxMsg[7].dataA[1] = AFTxMsg[7].dataA[2]= AFTxMsg[7].dataA[3]= 0x78;
frank26080115 0:bf7b9fba3924 350 AFTxMsg[7].dataB[0] = AFTxMsg[7].dataB[1] = AFTxMsg[7].dataB[2]= AFTxMsg[7].dataB[3]= 0x21;
frank26080115 0:bf7b9fba3924 351
frank26080115 0:bf7b9fba3924 352 /* 9th Message with 29-bit ID which exit in AF Look-up Table in Group of EFF Section*/
frank26080115 0:bf7b9fba3924 353 AFTxMsg[8].id = (9 << 11) + 0x01; //0x00004801
frank26080115 0:bf7b9fba3924 354 AFTxMsg[8].len = 0x08;
frank26080115 0:bf7b9fba3924 355 AFTxMsg[8].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 356 AFTxMsg[8].format = EXT_ID_FORMAT;
frank26080115 0:bf7b9fba3924 357 AFTxMsg[8].dataA[0] = AFTxMsg[8].dataA[1] = AFTxMsg[8].dataA[2]= AFTxMsg[8].dataA[3]= 0x52;
frank26080115 0:bf7b9fba3924 358 AFTxMsg[8].dataB[0] = AFTxMsg[8].dataB[1] = AFTxMsg[8].dataB[2]= AFTxMsg[8].dataB[3]= 0x06;
frank26080115 0:bf7b9fba3924 359
frank26080115 0:bf7b9fba3924 360 /* 10th Message with 29-bit ID which not exit in AF Look-up Table */
frank26080115 0:bf7b9fba3924 361 AFTxMsg[9].id = (0x0A << 11) + 0x01; //0x00005001
frank26080115 0:bf7b9fba3924 362 AFTxMsg[9].len = 0x08;
frank26080115 0:bf7b9fba3924 363 AFTxMsg[9].type = DATA_FRAME;
frank26080115 0:bf7b9fba3924 364 AFTxMsg[9].format = EXT_ID_FORMAT;
frank26080115 0:bf7b9fba3924 365 AFTxMsg[9].dataA[0] = AFTxMsg[9].dataA[1] = AFTxMsg[9].dataA[2]= AFTxMsg[9].dataA[3]= 0x85;
frank26080115 0:bf7b9fba3924 366 AFTxMsg[9].dataB[0] = AFTxMsg[9].dataB[1] = AFTxMsg[9].dataB[2]= AFTxMsg[9].dataB[3]= 0x27;
frank26080115 0:bf7b9fba3924 367
frank26080115 0:bf7b9fba3924 368 AFRxMsg[0].id = AFRxMsg[1].id = AFRxMsg[2].id = AFRxMsg[3].id = AFRxMsg[4].id = 0x00;
frank26080115 0:bf7b9fba3924 369 AFRxMsg[0].len = AFRxMsg[1].len = AFRxMsg[2].len = AFRxMsg[3].len = AFRxMsg[4].len = 0x00;
frank26080115 0:bf7b9fba3924 370 AFRxMsg[0].type = AFRxMsg[1].type = AFRxMsg[2].type = AFRxMsg[3].type = AFRxMsg[4].type = 0x00;
frank26080115 0:bf7b9fba3924 371 AFRxMsg[0].format = AFRxMsg[1].format = AFRxMsg[2].format = AFRxMsg[3].format = AFRxMsg[4].format = 0x00;
frank26080115 0:bf7b9fba3924 372 AFRxMsg[0].dataA[0] = AFRxMsg[1].dataA[0] = AFRxMsg[2].dataA[0] = AFRxMsg[3].dataA[0] = AFRxMsg[4].dataA[0] = 0x00;
frank26080115 0:bf7b9fba3924 373 AFRxMsg[0].dataA[1] = AFRxMsg[1].dataA[1] = AFRxMsg[2].dataA[1] = AFRxMsg[3].dataA[1] = AFRxMsg[4].dataA[1] = 0x00;
frank26080115 0:bf7b9fba3924 374 AFRxMsg[0].dataA[2] = AFRxMsg[1].dataA[2] = AFRxMsg[2].dataA[2] = AFRxMsg[3].dataA[2] = AFRxMsg[4].dataA[2] = 0x00;
frank26080115 0:bf7b9fba3924 375 AFRxMsg[0].dataA[3] = AFRxMsg[1].dataA[3] = AFRxMsg[2].dataA[3] = AFRxMsg[3].dataA[3] = AFRxMsg[4].dataA[3] = 0x00;
frank26080115 0:bf7b9fba3924 376
frank26080115 0:bf7b9fba3924 377 AFRxMsg[0].dataB[0] = AFRxMsg[1].dataB[0] = AFRxMsg[2].dataB[0] = AFRxMsg[3].dataB[0] = AFRxMsg[4].dataB[0] = 0x00;
frank26080115 0:bf7b9fba3924 378 AFRxMsg[0].dataB[1] = AFRxMsg[1].dataB[1] = AFRxMsg[2].dataB[1] = AFRxMsg[3].dataB[1] = AFRxMsg[4].dataB[1] = 0x00;
frank26080115 0:bf7b9fba3924 379 AFRxMsg[0].dataB[2] = AFRxMsg[1].dataB[2] = AFRxMsg[2].dataB[2] = AFRxMsg[3].dataB[2] = AFRxMsg[4].dataB[2] = 0x00;
frank26080115 0:bf7b9fba3924 380 AFRxMsg[0].dataB[3] = AFRxMsg[1].dataB[3] = AFRxMsg[2].dataB[3] = AFRxMsg[3].dataB[3] = AFRxMsg[4].dataB[3] = 0x00;
frank26080115 0:bf7b9fba3924 381 }
frank26080115 0:bf7b9fba3924 382 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 383 * @brief print menu
frank26080115 0:bf7b9fba3924 384 * @param[in] none
frank26080115 0:bf7b9fba3924 385 * @return none
frank26080115 0:bf7b9fba3924 386 **********************************************************************/
frank26080115 0:bf7b9fba3924 387 void print_menu()
frank26080115 0:bf7b9fba3924 388 {
frank26080115 0:bf7b9fba3924 389 _DBG_(menu);
frank26080115 0:bf7b9fba3924 390 }
frank26080115 0:bf7b9fba3924 391
frank26080115 0:bf7b9fba3924 392 /*-------------------------MAIN FUNCTION------------------------------*/
frank26080115 0:bf7b9fba3924 393 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 394 * @brief c_entry: Main CAN program body
frank26080115 0:bf7b9fba3924 395 * @param[in] none
frank26080115 0:bf7b9fba3924 396 * @return int
frank26080115 0:bf7b9fba3924 397 **********************************************************************/
frank26080115 0:bf7b9fba3924 398 int c_entry(void) { /* Main Program */
frank26080115 0:bf7b9fba3924 399 uint32_t i;
frank26080115 0:bf7b9fba3924 400 uint32_t cnt;
frank26080115 0:bf7b9fba3924 401 CAN_ERROR error;
frank26080115 0:bf7b9fba3924 402 PINSEL_CFG_Type PinCfg;
frank26080115 0:bf7b9fba3924 403
frank26080115 0:bf7b9fba3924 404 /* Initialize debug via UART0
frank26080115 0:bf7b9fba3924 405 * – 115200bps
frank26080115 0:bf7b9fba3924 406 * – 8 data bit
frank26080115 0:bf7b9fba3924 407 * – No parity
frank26080115 0:bf7b9fba3924 408 * – 1 stop bit
frank26080115 0:bf7b9fba3924 409 * – No flow control
frank26080115 0:bf7b9fba3924 410 */
frank26080115 0:bf7b9fba3924 411 debug_frmwrk_init();
frank26080115 0:bf7b9fba3924 412 print_menu();
frank26080115 0:bf7b9fba3924 413
frank26080115 0:bf7b9fba3924 414 /* Pin configuration
frank26080115 0:bf7b9fba3924 415 * CAN1: select P0.0 as RD1. P0.1 as TD1
frank26080115 0:bf7b9fba3924 416 * CAN2: select P2.7 as RD2, P2.8 as RD2
frank26080115 0:bf7b9fba3924 417 */
frank26080115 0:bf7b9fba3924 418 PinCfg.Funcnum = 1;
frank26080115 0:bf7b9fba3924 419 PinCfg.OpenDrain = 0;
frank26080115 0:bf7b9fba3924 420 PinCfg.Pinmode = 0;
frank26080115 0:bf7b9fba3924 421 PinCfg.Pinnum = 0;
frank26080115 0:bf7b9fba3924 422 PinCfg.Portnum = 0;
frank26080115 0:bf7b9fba3924 423 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 424 PinCfg.Pinnum = 1;
frank26080115 0:bf7b9fba3924 425 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 426
frank26080115 0:bf7b9fba3924 427 PinCfg.Pinnum = 7;
frank26080115 0:bf7b9fba3924 428 PinCfg.Portnum = 2;
frank26080115 0:bf7b9fba3924 429 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 430 PinCfg.Pinnum = 8;
frank26080115 0:bf7b9fba3924 431 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 432
frank26080115 0:bf7b9fba3924 433 //Initialize CAN1 & CAN2
frank26080115 0:bf7b9fba3924 434 CAN_Init(LPC_CAN1, 125000);
frank26080115 0:bf7b9fba3924 435 CAN_Init(LPC_CAN2, 125000);
frank26080115 0:bf7b9fba3924 436
frank26080115 0:bf7b9fba3924 437 //Enable Receive Interrupt
frank26080115 0:bf7b9fba3924 438 CAN_IRQCmd(LPC_CAN2, CANINT_FCE, ENABLE);
frank26080115 0:bf7b9fba3924 439 CAN_IRQCmd(LPC_CAN2, CANINT_RIE, ENABLE);
frank26080115 0:bf7b9fba3924 440
frank26080115 0:bf7b9fba3924 441 //Enable CAN Interrupt
frank26080115 0:bf7b9fba3924 442 NVIC_EnableIRQ(CAN_IRQn);
frank26080115 0:bf7b9fba3924 443
frank26080115 0:bf7b9fba3924 444 /* First, we send 10 messages:
frank26080115 0:bf7b9fba3924 445 * - message 0,2,4,6,8 have id in AFLUT >>> will be received
frank26080115 0:bf7b9fba3924 446 * - message 1,3,5,7,9 don't have id in AFLUT >>> will be ignored
frank26080115 0:bf7b9fba3924 447 * Then, we change AFLUT by load/remove entries in AFLUT and re-send messages
frank26080115 0:bf7b9fba3924 448 * - message 1,3,5,7,9 have id in AFLUT >>> will be received
frank26080115 0:bf7b9fba3924 449 * - message 0,2,4,6,8 don't have id in AFLUT >>> will be ignored
frank26080115 0:bf7b9fba3924 450 * Note that: FullCAN Object must be read from FullCAN Object Section next to AFLUT
frank26080115 0:bf7b9fba3924 451 */
frank26080115 0:bf7b9fba3924 452 /*-------------------------Init Message & AF Look-up Table------------------------*/
frank26080115 0:bf7b9fba3924 453
frank26080115 0:bf7b9fba3924 454 _DBG_("Test Acceptance Filter function...");
frank26080115 0:bf7b9fba3924 455 _DBG_("Press '1' to initialize message and AF Loop-up Table...");_DBG_("");
frank26080115 0:bf7b9fba3924 456 while(_DG !='1');
frank26080115 0:bf7b9fba3924 457 CAN_InitAFMessage(); /* initialize Transmit Message */
frank26080115 0:bf7b9fba3924 458 _DBG_("Init message finished!!!");
frank26080115 0:bf7b9fba3924 459 CAN_SetupAFTable(); /* initialize AF Look-up Table sections*/
frank26080115 0:bf7b9fba3924 460 error = CAN_SetupAFLUT(LPC_CANAF,&AFTable); /* install AF Look-up Table */
frank26080115 0:bf7b9fba3924 461 if (error != CAN_OK) {
frank26080115 0:bf7b9fba3924 462 _DBG_("Setup AF: ERROR...");
frank26080115 0:bf7b9fba3924 463 while (1); // AF Table has error
frank26080115 0:bf7b9fba3924 464 }
frank26080115 0:bf7b9fba3924 465 else _DBG_("Setup AF: SUCCESSFUL!!!");_DBG_("");
frank26080115 0:bf7b9fba3924 466
frank26080115 0:bf7b9fba3924 467
frank26080115 0:bf7b9fba3924 468 /*-------------------------Send messages------------------------*/
frank26080115 0:bf7b9fba3924 469 _DBG_("Press '2' to start CAN transferring operation...");_DBG_("");
frank26080115 0:bf7b9fba3924 470 while(_DG !='2');
frank26080115 0:bf7b9fba3924 471 for (i = 0; i < CAN_TX_MSG_CNT; i++) {
frank26080115 0:bf7b9fba3924 472 CAN_SendMsg(LPC_CAN1, &AFTxMsg[i]);
frank26080115 0:bf7b9fba3924 473 PrintMessage(&AFTxMsg[i]);_DBG_("");
frank26080115 0:bf7b9fba3924 474 for(cnt=0;cnt<10000;cnt++); //transmit delay
frank26080115 0:bf7b9fba3924 475 CANTxCount++;
frank26080115 0:bf7b9fba3924 476 }
frank26080115 0:bf7b9fba3924 477 _DBG_("Sending finished !!!");
frank26080115 0:bf7b9fba3924 478
frank26080115 0:bf7b9fba3924 479 /*-------------------------Display Received messages------------------------*/
frank26080115 0:bf7b9fba3924 480 _DBG_("Press '3' to display received messages...");_DBG_("");
frank26080115 0:bf7b9fba3924 481 while(_DG !='3');
frank26080115 0:bf7b9fba3924 482 for (i = 0; i < CAN_RX_MSG_CNT; i++) {
frank26080115 0:bf7b9fba3924 483 PrintMessage(&AFRxMsg[i]);_DBG_("");
frank26080115 0:bf7b9fba3924 484 }
frank26080115 0:bf7b9fba3924 485
frank26080115 0:bf7b9fba3924 486 /*-------------------------Change AFLUT Table --------------------*/
frank26080115 0:bf7b9fba3924 487 _DBG_("Press '4' to change AF look-up table...");_DBG_("");
frank26080115 0:bf7b9fba3924 488 while(_DG !='4');
frank26080115 0:bf7b9fba3924 489 CAN_ChangeAFTable();
frank26080115 0:bf7b9fba3924 490 _DBG_("Change AFLUT: FINISHED!!!");
frank26080115 0:bf7b9fba3924 491 CAN_SetAFMode(LPC_CANAF, CAN_eFCAN);
frank26080115 0:bf7b9fba3924 492 CAN_InitAFMessage();
frank26080115 0:bf7b9fba3924 493 CANRxCount = CANTxCount = 0;
frank26080115 0:bf7b9fba3924 494
frank26080115 0:bf7b9fba3924 495 /*-------------------------Re-Send messages------------------------*/
frank26080115 0:bf7b9fba3924 496 _DBG_("Press '5' to re-send messages...");_DBG_("");
frank26080115 0:bf7b9fba3924 497 while(_DG !='5');
frank26080115 0:bf7b9fba3924 498 for (i = 0; i < CAN_TX_MSG_CNT; i++) {
frank26080115 0:bf7b9fba3924 499 CAN_SendMsg(LPC_CAN1, &AFTxMsg[i]);
frank26080115 0:bf7b9fba3924 500 PrintMessage(&AFTxMsg[i]);_DBG_("");
frank26080115 0:bf7b9fba3924 501 for(cnt=0;cnt<10000;cnt++); //transmit delay
frank26080115 0:bf7b9fba3924 502 CANTxCount++;
frank26080115 0:bf7b9fba3924 503 }
frank26080115 0:bf7b9fba3924 504
frank26080115 0:bf7b9fba3924 505 /*-------------------------Display received messages------------------------*/
frank26080115 0:bf7b9fba3924 506 _DBG_("Re-Sending finished !!!");
frank26080115 0:bf7b9fba3924 507
frank26080115 0:bf7b9fba3924 508 _DBG_("Press '6' to display received messages...");_DBG_("");
frank26080115 0:bf7b9fba3924 509 while(_DG !='6');
frank26080115 0:bf7b9fba3924 510 for (i = 0; i < CAN_RX_MSG_CNT; i++) {
frank26080115 0:bf7b9fba3924 511 PrintMessage(&AFRxMsg[i]);_DBG_("");
frank26080115 0:bf7b9fba3924 512 }
frank26080115 0:bf7b9fba3924 513 _DBG_("Demo terminal !!!");
frank26080115 0:bf7b9fba3924 514
frank26080115 0:bf7b9fba3924 515 CAN_DeInit(LPC_CAN1);
frank26080115 0:bf7b9fba3924 516 CAN_DeInit(LPC_CAN2);
frank26080115 0:bf7b9fba3924 517 while (1);
frank26080115 0:bf7b9fba3924 518 return 0;
frank26080115 0:bf7b9fba3924 519 }
frank26080115 0:bf7b9fba3924 520
frank26080115 0:bf7b9fba3924 521 /* With ARM and GHS toolsets, the entry point is main() - this will
frank26080115 0:bf7b9fba3924 522 allow the linker to generate wrapper code to setup stacks, allocate
frank26080115 0:bf7b9fba3924 523 heap area, and initialize and copy code and data segments. For GNU
frank26080115 0:bf7b9fba3924 524 toolsets, the entry point is through __start() in the crt0_gnu.asm
frank26080115 0:bf7b9fba3924 525 file, and that startup code will setup stacks and data */
frank26080115 0:bf7b9fba3924 526 int main(void) {
frank26080115 0:bf7b9fba3924 527 return c_entry();
frank26080115 0:bf7b9fba3924 528 }
frank26080115 0:bf7b9fba3924 529
frank26080115 0:bf7b9fba3924 530 #ifdef DEBUG
frank26080115 0:bf7b9fba3924 531 /*******************************************************************************
frank26080115 0:bf7b9fba3924 532 * @brief Reports the name of the source file and the source line number
frank26080115 0:bf7b9fba3924 533 * where the CHECK_PARAM error has occurred.
frank26080115 0:bf7b9fba3924 534 * @param[in] file Pointer to the source file name
frank26080115 0:bf7b9fba3924 535 * @param[in] line assert_param error line source number
frank26080115 0:bf7b9fba3924 536 * @return None
frank26080115 0:bf7b9fba3924 537 *******************************************************************************/
frank26080115 0:bf7b9fba3924 538 void check_failed(uint8_t *file, uint32_t line) {
frank26080115 0:bf7b9fba3924 539 /* User can add his own implementation to report the file name and line number,
frank26080115 0:bf7b9fba3924 540 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
frank26080115 0:bf7b9fba3924 541
frank26080115 0:bf7b9fba3924 542 /* Infinite loop */
frank26080115 0:bf7b9fba3924 543 while (1)
frank26080115 0:bf7b9fba3924 544 ;
frank26080115 0:bf7b9fba3924 545 }
frank26080115 0:bf7b9fba3924 546 #endif
frank26080115 0:bf7b9fba3924 547
frank26080115 0:bf7b9fba3924 548 /*
frank26080115 0:bf7b9fba3924 549 * @}
frank26080115 0:bf7b9fba3924 550 */