Blame view

RIOT/sys/include/can/dll.h 2.41 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  /*
   * Copyright (C) 2016 OTA keys S.A.
   *
   * This file is subject to the terms and conditions of the GNU Lesser General
   * Public License v2.1. See the file LICENSE in the top level directory for more
   * details.
   */
  
  /**
   * @ingroup    sys_can_dll
   * @{
   *
   * @file
   * @brief       Definitions of low-level CAN DLL interface
   *
   * @author      Vincent Dupont <vincent@otakeys.com>
   * @author      Toon Stegen <toon.stegen@altran.com>
   */
  
  #ifndef CAN_DLL_H
  #define CAN_DLL_H
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  #include "can/common.h"
  #include "can/pkt.h"
  #include "can/device.h"
  #include "thread.h"
  
  /**
   * @brief Initialize the CAN DLL
   *
   * @return 0 on success
   */
  int can_dll_init(void);
  
  /**
   * @brief Register a CAN device into the DLL
   *
   * This function must be called by the device thread to register the device into the DLL
   *
   * @param[in] candev  the candev to register
   *
   * @return interface number on success
   * @return -ENODEV if ifnum is invalid
   */
  int can_dll_register_candev(candev_dev_t *candev);
  
  /**
   * @brief Dispatch a received frame
   *
   * This function is used to send a message to the DLL thread when a @p frame is received
   * from the device identified by its @p pid
   *
   * @param[in] frame the received frame
   * @param[in] pid   the pid of the receiver device
   *
   * @return 0 on success
   * @return -ENOMEM if the message can not be sent
   */
  int can_dll_dispatch_rx_frame(struct can_frame *frame, kernel_pid_t pid);
  
  /**
   * @brief Dispatch a tx confirmation
   *
   * This function is used to send a message to the sender thread when the
   * @p pkt has been sent correctly.
   *
   * @param[in] pkt   the pkt which has been sent
   *
   * @return 0 on success
   * @return -ENOMEM if the message can not be sent
   */
  int can_dll_dispatch_tx_conf(can_pkt_t *pkt);
  
  /**
   * @brief Dispatch a tx error
   *
   * This function is used to send a message to the sender thread when the
   * @p pkt has not been sent correctly
   *
   * @param[in] pkt   the pkt which has not been sent correctly
   *
   * @return 0 on success
   * @return -ENOMEM if the message can not be sent
   */
  int can_dll_dispatch_tx_error(can_pkt_t *pkt);
  
  /**
   * @brief Dispatch RX error from a device
   *
   * Dispatch RX error from a device to receivers threads
   * which have subscribed to frames on that interface
   *
   * @param[in] pid   the device thread pid
   *
   * @return 0 on success
   */
  int can_dll_dispatch_bus_off(kernel_pid_t pid);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* CAN_DLL_H */
  
  /** @} */