1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef CAN_MAIL_H 10 #define CAN_MAIL_H 11 12 #include "can_core.h" 13 #include "can_msg.h" 14 #include "platform_queue.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif /* __cplusplus */ 19 20 struct CanRxBox { 21 struct PlatformQueue *queue; 22 struct DListHead node; 23 struct DListHead filters; 24 OsalSpinlock spin; 25 }; 26 27 struct CanRxBox *CanRxBoxCreate(void); 28 29 void CanRxBoxDestroy(struct CanRxBox *rbox); 30 CanRxBoxLock(struct CanRxBox * rbox)31static inline void CanRxBoxLock(struct CanRxBox *rbox) 32 { 33 (void)OsalSpinLock(&rbox->spin); 34 } 35 CanRxBoxUnlock(struct CanRxBox * rbox)36static inline void CanRxBoxUnlock(struct CanRxBox *rbox) 37 { 38 (void)OsalSpinUnlock(&rbox->spin); 39 } 40 41 int32_t CanRxBoxAddMsg(struct CanRxBox *rbox, struct CanMsg *cmsg); 42 43 int32_t CanRxBoxGetMsg(struct CanRxBox *rbox, struct CanMsg **cmsg, uint32_t tms); 44 45 int32_t CanRxBoxAddFilter(struct CanRxBox *rbox, const struct CanFilter *filter); 46 47 int32_t CanRxBoxDelFilter(struct CanRxBox *rbox, const struct CanFilter *filter); 48 49 #ifdef __cplusplus 50 } 51 #endif /* __cplusplus */ 52 53 #endif 54