Loading...
Searching...
No Matches
pkt.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016-2018 OTA keys S.A.
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <stdatomic.h>
24
25#include "can/common.h"
26#include "can/can.h"
27#include "msg.h"
28#ifdef MODULE_CAN_MBOX
29#include "mbox.h"
30#endif
31
43
49void can_pkt_init(void);
50
63can_pkt_t *can_pkt_alloc_tx(int ifnum, const can_frame_t *frame, kernel_pid_t tx_pid);
64
73can_pkt_t *can_pkt_alloc_rx(int ifnum, const can_frame_t *frame);
74
75#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
88can_pkt_t *can_pkt_alloc_mbox_tx(int ifnum, const can_frame_t *frame, mbox_t *mbox);
89#endif
90
98
110can_rx_data_t *can_pkt_alloc_rx_data(void *data, size_t len, void *arg);
111
118
128void *can_pkt_buf_alloc(size_t size);
129
136void can_pkt_buf_free(void *data, size_t size);
137
138#ifdef __cplusplus
139}
140#endif
141
can_pkt_t * can_pkt_alloc_tx(int ifnum, const can_frame_t *frame, kernel_pid_t tx_pid)
Allocate a CAN packet to transmit.
void can_pkt_free_rx_data(can_rx_data_t *data)
Free rx data previously allocated by can_pkt_alloc_rx_data()
void can_pkt_buf_free(void *data, size_t size)
Free the data allocated by can_pkt_buf_alloc()
can_pkt_t * can_pkt_alloc_rx(int ifnum, const can_frame_t *frame)
Allocate an incoming CAN packet.
void can_pkt_init(void)
Initialize the CAN packet module.
can_pkt_t * can_pkt_alloc_mbox_tx(int ifnum, const can_frame_t *frame, mbox_t *mbox)
Allocate a CAN packet for a mbox to transmit.
void * can_pkt_buf_alloc(size_t size)
Allocate size bytes and return the pointer.
void can_pkt_free(can_pkt_t *pkt)
Free a CAN packet.
can_rx_data_t * can_pkt_alloc_rx_data(void *data, size_t len, void *arg)
Allocate a can_rx_data_t and initialize it with gieven parameters.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
struct can_rx_data can_rx_data_t
Received data structure.
struct can_reg_entry can_reg_entry_t
registry entry
struct can_frame can_frame_t
CAN frame.
Definition can.h:175
Mailbox API.
Type with the same alignment and size as atomic_uint
A CAN packet.
Definition pkt.h:37
int handle
handle (for tx frames
Definition pkt.h:40
can_frame_t frame
CAN Frame.
Definition pkt.h:41
can_reg_entry_t entry
entry containing ifnum and upper layer info
Definition pkt.h:38
atomic_uint ref_count
Reference counter (for rx frames)
Definition pkt.h:39
Mailbox struct definition.
Definition mbox.h:38
Definitions high-level CAN interface.
Definitions of high-level CAN interface.