4 * @brief interface of the FRESCAN protocol
15 * This file contains the interface to the FRESCAN protocol
19 * See MaRTE OS license
23 #ifndef _MARTE_FRESCAN_H_
24 #define _MARTE_FRESCAN_H_
26 #include <stdint.h> // uint8_t
27 #include <stdbool.h> // bool
28 #include <unistd.h> // size_t
30 typedef uint8_t frescan_network_t;
31 typedef uint8_t frescan_node_t;
32 typedef uint8_t frescan_channel_t;
33 typedef uint8_t frescan_prio_t;
34 typedef uint8_t frescan_ss_t;
35 typedef uint32_t frescan_budget_t;
38 * frescan_flags_t - frescan flags
40 * @FRESCAN_SS: send the message using sporadic servers
41 * @FRESCAN_FP: send the message using fixed priorities
42 * @FRESCAN_POLL: no buffer copy, only pointer and use the ID to poll status
43 * @FRESCAN_SYNC: no buffer copy, only pointer and block until it is sent
44 * @FRESCAN_ASYNC: use buffer copy and return immediately
48 FRESCAN_SS = 1<<4, // sporadic server
49 FRESCAN_FP = 1<<3, // fixed priorities
50 FRESCAN_POLL = 1<<2, // polling
51 FRESCAN_SYNC = 1<<1, // synchronous
52 FRESCAN_ASYNC = 1 // asynchronous
56 * frescan_send_params_t - send parameters
58 * @net: the network to use
59 * @to: the node where the message shoud be sent to
60 * @channel: the channel in 'to' where the message shoud be sent to
61 * @flags: the flags (see frescan_flags_t)
62 * @prio: the priority for the message if (flags & FRESCAN_FP)
63 * @ss: the sporadic server for the message if (flags & FRESCAN_SS)
67 frescan_network_t net;
69 frescan_channel_t channel;
70 frescan_flags_t flags;
75 } frescan_send_params_t;
78 * frescan_recv_params_t - receive parameters
80 * @net: the network to use
81 * @channel: the channel from which we want to extract a message
82 * @flags: FRESCAN_SYNC/ASYNC
86 frescan_network_t net;
87 frescan_channel_t channel;
88 frescan_flags_t flags;
89 } frescan_recv_params_t;
92 * frescan_init_params_t - initialization parameters
94 * @net: network to initialize (minor number ie: /dev/can0 -> 0)
95 * @node: set the local node identificator
96 * @tx_fp_max_prio: maximum number of priorities for the fixed priority
97 * transmission queues. (prio = 0 .. max_prio - 1)
98 * @rx_num_of_channels: number of rx channels (0 .. rx_num_of_channels - 1)
99 * @rx_channel_max_prio: array (range rx_num_of_channels) saying the number
100 * of priorities for each channel. If this parameter is
101 * NULL tx_fp_max_prio will be used for all queues.
105 frescan_network_t net;
107 uint32_t tx_fp_max_prio;
108 uint32_t rx_num_of_channels;
109 uint32_t *rx_channel_max_prio;
110 } frescan_init_params_t;
113 * frescan_init - initializes the network and the internal structures
115 * @params: the initialization parameters
118 int frescan_init(frescan_init_params_t *params);
121 * frescan_send - send a message
123 * @params: the parameters needed by the protocol to send the message
124 * @msg: the message buffer
125 * @size: the size of the message
127 * This is one of the main functions of the protocol and it provides the
128 * means to send a message through the protocol stack.
131 int frescan_send(const frescan_send_params_t *params,
136 * frescan_recv - receive a message
138 * @params: the parameters needed by the protocol to receive the message
139 * @msg: the message buffer
140 * @size: the size of the message buffer
141 * @recv_bytes: the number of bytes received
142 * @from: the node that sent the message
143 * @prio: the priority of the message
145 * This is one of the main functions of the protocol and it provides the
146 * means to receive a message through the protocol stack.
149 int frescan_recv(const frescan_recv_params_t *params,
153 frescan_node_t *from,
154 frescan_prio_t *prio);
156 #endif // _MARTE_FRESCAN_H_