/* * Device and application specific definitions for CANopenNode. * * @file CO_driver_target.h * @author Janez Paternoster * @copyright 2020 Janez Paternoster * * This file is part of CANopenNode, an opensource CANopen Stack. * Project home page is . * For more information on CANopen see . * * 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. */ #ifndef CO_DRIVER_TARGET #define CO_DRIVER_TARGET /* This file contains device and application specific definitions. * It is included from CO_driver.h, which contains documentation * for definitions below. */ #include #include #include #ifdef __cplusplus extern "C" { #endif /* Basic definitions */ #define CO_LITTLE_ENDIAN #define CO_USE_LEDS /* NULL is defined in stddef.h */ /* true and false are defined in stdbool.h */ /* int8_t to uint64_t are defined in stdint.h */ typedef unsigned char bool_t; typedef float float32_t; typedef long double float64_t; typedef char char_t; typedef unsigned char oChar_t; typedef unsigned char domain_t; /* Access to received CAN message */ #define CO_CANrxMsg_readIdent(msg) ((uint16_t)0) #define CO_CANrxMsg_readDLC(msg) ((uint8_t)0) #define CO_CANrxMsg_readData(msg) ((uint8_t *)NULL) /* Received message object */ typedef struct { uint16_t ident; uint16_t mask; void *object; void (*CANrx_callback)(void *object, void *message); } CO_CANrx_t; /* Transmit message object */ typedef struct { uint32_t ident; uint8_t DLC; uint8_t data[8]; volatile bool_t bufferFull; volatile bool_t syncFlag; } CO_CANtx_t; /* CAN module object */ typedef struct { void *CANptr; CO_CANrx_t *rxArray; uint16_t rxSize; CO_CANtx_t *txArray; uint16_t txSize; volatile bool_t CANnormal; volatile bool_t useCANrxFilters; volatile bool_t bufferInhibitFlag; volatile bool_t firstCANtxMessage; volatile uint16_t CANtxCount; uint32_t errOld; void *em; } CO_CANmodule_t; /* (un)lock critical section in CO_CANsend() */ #define CO_LOCK_CAN_SEND() #define CO_UNLOCK_CAN_SEND() /* (un)lock critical section in CO_errorReport() or CO_errorReset() */ #define CO_LOCK_EMCY() #define CO_UNLOCK_EMCY() /* (un)lock critical section when accessing Object Dictionary */ #define CO_LOCK_OD() #define CO_UNLOCK_OD() /* Synchronization between CAN receive and message processing threads. */ #define CO_MemoryBarrier() #define CO_CANrxNew_READ(rxNew) ((rxNew) != NULL) #define CO_CANrxNew_SET(rxNew) {CO_MemoryBarrier(); rxNew = (void*)1L;} #define CO_CANrxNew_CLEAR(rxNew) {CO_MemoryBarrier(); rxNew = NULL;} #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* CO_DRIVER_TARGET */