canard_avr.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2016 UAVCAN Team
  3. *
  4. * Distributed under the MIT License, available in the file LICENSE.
  5. *
  6. */
  7. #ifndef CANARD_AVR_H
  8. #define CANARD_AVR_H
  9. #include <canard.h>
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. /**
  15. * \ingroup communication
  16. * \defgroup canard_avr_interface Libcanard CAN Interface for AVR microcontrollers
  17. * \brief Interface for Libcanard CAN interaction with AVR microcontrollers
  18. *
  19. * \author Matthias Renner <rennerm@ethz.ch>
  20. * \author ETH Zuerich Robotics Systems Lab (http://http://www.rsl.ethz.ch/)
  21. *
  22. * \version 0.1
  23. */
  24. /**
  25. * @ingroup canard_avr_interface
  26. * @brief Initialize CAN interface on AVR microcontroller.
  27. * @warning Enables interrupts!
  28. *
  29. * @param [in] bitrate Set CAN bitrate (bits/sec.)
  30. *
  31. * @retval 0 Successfully initialized.
  32. */
  33. int canardAVRInit(uint32_t bitrate);
  34. /**
  35. * @ingroup canard_avr_interface
  36. * @brief Deinitialize CAN interface on AVR microcontroller.
  37. * @warning Not implemented
  38. *
  39. * @retval 1 Initialisation successful
  40. * @retval -1 Error, bitrate not supported
  41. */
  42. int canardAVRClose(void);
  43. /**
  44. * @ingroup canard_avr_interface
  45. * @brief Transmits a CanardCANFrame to the CAN device.
  46. *
  47. * @param [in] frame Canard CAN frame which contains the data to send
  48. *
  49. * @retval 0 No CAN send buffer free
  50. * @retval -1 Error, data could not be sent
  51. * @retval 1 Data sent successful
  52. */
  53. int canardAVRTransmit(const CanardCANFrame* frame);
  54. /**
  55. * @ingroup canard_avr_interface
  56. * @brief Receives a CanardCANFrame from the CAN device.
  57. *
  58. * @param [out] out_frame Canard CAN frame which contains data received
  59. *
  60. * @retval 0 No new CAN data to be read
  61. * @retval -1 Error, data could not be read
  62. * @retval 1 Data read successful
  63. */
  64. int canardAVRReceive(CanardCANFrame* out_frame);
  65. /**
  66. * @ingroup canard_avr_interface
  67. * @brief Set hardware acceptance filters for specific node ID
  68. *
  69. * @param [in] id node ID for hardware filter
  70. *
  71. * @retval -1 Error, filters could no be set
  72. * @retval 1 Set filter successful
  73. */
  74. int canardAVRConfigureAcceptanceFilters(uint8_t node_id);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif