CANpie FD
CAN programming interface environment - Version 3.08
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Modules Pages
demo_buffer_fifo.c

//============================================================================//
// File: demo_buffer_fifo.c //
// Description: Example for CANpie FIFO configuration //
// //
// Copyright 2017 MicroControl GmbH & Co. KG //
// 53844 Troisdorf - Germany //
// www.microcontrol.net //
// //
//----------------------------------------------------------------------------//
// Redistribution and use in source and binary forms, with or without //
// modification, are permitted provided that the following conditions //
// are met: //
// 1. Redistributions of source code must retain the above copyright //
// notice, this list of conditions, the following disclaimer and //
// the referenced file 'LICENSE'. //
// 2. Redistributions in binary form must reproduce the above copyright //
// notice, this list of conditions and the following disclaimer in the //
// documentation and/or other materials provided with the distribution. //
// 3. Neither the name of MicroControl nor the names of its contributors //
// may be used to endorse or promote products derived from this software //
// without specific prior written permission. //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
//============================================================================//
#include "cp_core.h"
#include "cp_msg.h"
#define FIFO_RCV_SIZE 32
static CpFifo_ts tsFifoRcvS;
static CpCanMsg_ts atsCanMsgRcvS[FIFO_RCV_SIZE];
//----------------------------------------------------------------------------//
// DemoFifoConfig() //
// //
//----------------------------------------------------------------------------//
void DemoFifoConfig(CpPort_ts * ptsCanPortV)
{
//------------------------------------------------------
// set message buffer 2 as receive buffer for classic
// CAN frame with identifier 180h .. 18Fh
//
(uint32_t) 0x180,
(uint32_t) 0x7F0, // mask
CpFifoInit(&tsFifoRcvS, &atsCanMsgRcvS[0], FIFO_RCV_SIZE);
CpCoreFifoConfig(ptsCanPortV, eCP_BUFFER_2, &tsFifoRcvS);
}
//----------------------------------------------------------------------------//
// DemoFifoRead() //
// //
//----------------------------------------------------------------------------//
void DemoFifoRead(CpPort_ts * ptsCanPortV)
{
CpCanMsg_ts tsCanMsgReadT;
uint32_t ulMsgCntT;
//------------------------------------------------------
// try to read one CAN message
//
ulMsgCntT = 1;
&tsCanMsgReadT,
&ulMsgCntT);
}




CpCoreBufferConfig
CpStatus_tv CpCoreBufferConfig(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint32_t ulIdentifierV, uint32_t ulAcceptMaskV, uint8_t ubFormatV, uint8_t ubDirectionV)
Initialise message buffer.
cp_msg.h
CANpie message access
CpCoreFifoRead
CpStatus_tv CpCoreFifoRead(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpCanMsg_ts *ptsCanMsgV, uint32_t *pulMsgCntV)
Read a CAN message from FIFO.
cp_core.h
CANpie core functions.
CpCoreFifoConfig
CpStatus_tv CpCoreFifoConfig(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpFifo_ts *ptsFifoV)
Assign FIFO to message buffer.
eCP_BUFFER_DIR_RCV
@ eCP_BUFFER_DIR_RCV
Definition: canpie.h:937
CpFifo_s
Administration variables of a CAN message FIFO.
Definition: cp_fifo.h:89
CP_MSG_FORMAT_CBFF
#define CP_MSG_FORMAT_CBFF
Definition: canpie.h:414
CpCanMsg_s
CAN message structure.
Definition: canpie.h:1003
CpFifoInit
void CpFifoInit(CpFifo_ts *ptsFifoV, CpCanMsg_ts *ptsCanMsgV, uint32_t ulSizeV)
eCP_BUFFER_2
@ eCP_BUFFER_2
Definition: canpie.h:901