Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 225199

Forum Post: RE: LP-AM243: MCAN Loopback Test (Interrupt) Extended Format Realization Method

$
0
0
/// my init { /* Initialize MCAN module initParams */ MCAN_initOperModeParams(&initParams); initParams.fdMode = FALSE; // classic canはFALSE initParams.brsEnable = FALSE; // classic canはFALSE } /// my msgram config static char trial_MCAN_MsgRAMConfigParams(uint32_t mode, MCAN_MsgRAMConfigParams *pConfig) { MCAN_MsgRAMConfigParams wk_cfg; if (pConfig == NULL) { return -1; } /* * Configure the user required msg ram params */ // This API will initialize MCAN message config RAM params to default. MCAN_initMsgRamConfigParams(&wk_cfg); if (mode == MCAN_MODE_STANDARD) { wk_cfg.lss = LLD_MCAN_STD_ID_FILTER_CNT; // List Size: Standard ID wk_cfg.lse = 0; // List Size: Extended ID } else { wk_cfg.lss = 0; // List Size: Standard ID wk_cfg.lse = LLD_MCAN_EXT_ID_FILTER_CNT; // List Size: Extended ID } /* Maximum TX Buffer + TX FIFO, combined can be configured is 32 */ wk_cfg.txBufCnt = LLD_MCAN_TX_BUFF_CNT; // (1) wk_cfg.txFIFOCnt = LLD_MCAN_TX_FIFO_CNT; // (0) /* * Buffer/FIFO mode is selected */ wk_cfg.txBufMode = MCAN_TX_MEM_TYPE_BUF; /* Maximum TX Event FIFO can be configured is 32 */ wk_cfg.txEventFIFOCnt = LLD_MCAN_TX_EVENT_FIFO_CNT; /* Maximum RX FIFO 0 can be configured is 64 */ wk_cfg.rxFIFO0Cnt = LLD_MCAN_FIFO_0_CNT; /* Maximum RX FIFO 1 can be configured is 64 and * rest of the memory is allocated to RX buffer which is again of max size 64 */ wk_cfg.rxFIFO1Cnt = LLD_MCAN_FIFO_1_CNT; /* FIFO blocking mode is selected */ wk_cfg.rxFIFO0OpMode = MCAN_RX_FIFO_OPERATION_MODE_BLOCKING; wk_cfg.rxFIFO1OpMode = MCAN_RX_FIFO_OPERATION_MODE_BLOCKING; wk_cfg.rxBufElemSize = MCAN_ELEM_SIZE_8BYTES; wk_cfg.rxFIFO0ElemSize = MCAN_ELEM_SIZE_8BYTES; wk_cfg.rxFIFO1ElemSize = MCAN_ELEM_SIZE_8BYTES; //This API will calculate start addresses of message RAM params (void)MCAN_calcMsgRamParamsStartAddr(&wk_cfg); (void)memcpy((void*)pConfig, &wk_cfg, sizeof(wk_cfg)); return 0; } /// my std filter static char trial_StdFilterElemParams(MCAN_StdMsgIDFilterElement *pstdFiltElem) { if (pstdFiltElem == NULL) { return -1; } /* sfid1 defines the ID of the standard message to be stored. */ pstdFiltElem->sfid1 = 0; /* As buffer mode is selected, sfid2 should be bufNum[0 - 63] */ pstdFiltElem->sfid2 = 0; /* Store message in buffer */ // Store into Rx Buffer or as debug message, configuration of SFT[1:0] ignored. pstdFiltElem->sfec = MCAN_STD_FILT_ELEM_BUFFER; #if 0 uint32_t sft; /** sft = MCAN_STD_FILT_TYPE_CLASSIC; return 0; } /// my std filter { (void)trial_StdFilterElemParams(&stdFiltElem[0]); stdFiltElem[0].sfid1 = pTrial->acceptanceCode; // 0x0c stdFiltElem[0].sfid2 = pTrial->acceptanceMask; // 0x0c } /// my ext filter static char trial_ExtFilterElemParams(MCAN_ExtMsgIDFilterElement *pextFiltElem) { if (pextFiltElem == NULL) { return -1; } /* efid1 defines the ID of the standard message to be stored. * Message id configured is 0xD0 to 0xD4 */ pextFiltElem->efid1 = 0; /* As fifo mode is selected, efid2 should be mask */ pextFiltElem->efid2 = 0; /* Store message in buffer */ //pextFiltElem->efec = MCAN_STD_FILT_ELEM_FIFO0; pextFiltElem->efec = MCAN_EXT_FILT_ELEM_BUFFER; #if 0 uint32_t eft; /** eft = MCAN_STD_FILT_TYPE_CLASSIC; return 0; } /// my ext filter { (void)trial_ExtFilterElemParams(&extFiltElem[0]); extFiltElem[0].efid1 = pTrial->acceptanceCode; // 0xd0 extFiltElem[0].efid2 = pTrial->acceptanceMask; // 0xd0 } /// my send config char trial_SendConfig( uint32_t baseAddr, uint32_t mode, TRIAL_t* pTrial, MCAN_TxBufElement* plld_tx ) { MCAN_TxBufElement wk_tx; uint8_t ii; /* Initialize message to transmit */ MCAN_initTxBufElement(&wk_tx); /** id; /** frame; /** length; for(ii = 0; ii length; ii++) { wk_tx.data[ii] = pTrial->data[ii]; } memcpy((void*)plld_tx, &wk_tx, sizeof(wk_tx)); return 0; }

Viewing all articles
Browse latest Browse all 225199

Trending Articles