CAN_config.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @section License
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2017, Thomas Barth, barth-dev.de
  7. *
  8. * Permission is hereby granted, free of charge, to any person
  9. * obtaining a copy of this software and associated documentation
  10. * files (the "Software"), to deal in the Software without
  11. * restriction, including without limitation the rights to use, copy,
  12. * modify, merge, publish, distribute, sublicense, and/or sell copies
  13. * of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  23. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  24. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26. * SOFTWARE.
  27. */
  28. #ifndef __DRIVERS_CAN_CFG_H__
  29. #define __DRIVERS_CAN_CFG_H__
  30. #include "freertos/FreeRTOS.h"
  31. #include "freertos/queue.h"
  32. #include "freertos/task.h"
  33. #include "driver/gpio.h"
  34. #include "freertos/semphr.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /** \brief CAN Node Bus speed */
  39. typedef enum {
  40. CAN_SPEED_100KBPS = 100, /**< \brief CAN Node runs at 100kBit/s. */
  41. CAN_SPEED_125KBPS = 125, /**< \brief CAN Node runs at 125kBit/s. */
  42. CAN_SPEED_200KBPS = 200, /**< \brief CAN Node runs at 250kBit/s. */
  43. CAN_SPEED_250KBPS = 250, /**< \brief CAN Node runs at 250kBit/s. */
  44. CAN_SPEED_500KBPS = 500, /**< \brief CAN Node runs at 500kBit/s. */
  45. CAN_SPEED_800KBPS = 800, /**< \brief CAN Node runs at 800kBit/s. */
  46. CAN_SPEED_1000KBPS = 1000 /**< \brief CAN Node runs at 1000kBit/s. */
  47. } CAN_speed_t;
  48. /** \brief CAN configuration structure */
  49. typedef struct {
  50. CAN_speed_t speed; /**< \brief CAN speed. */
  51. gpio_num_t tx_pin_id; /**< \brief TX pin. */
  52. gpio_num_t rx_pin_id; /**< \brief RX pin. */
  53. QueueHandle_t rx_queue; /**< \brief Handler to FreeRTOS RX queue. */
  54. QueueHandle_t tx_queue; /**< \brief Handler to FreeRTOS TX queue. */
  55. TaskHandle_t tx_handle; /**< \brief Handler to FreeRTOS TX task. */
  56. TaskHandle_t rx_handle; /**< \brief Handler to FreeRTOS RX task. */
  57. } CAN_device_t;
  58. /** \brief CAN configuration reference */
  59. extern CAN_device_t CAN_cfg;
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* __DRIVERS_CAN_CFG_H__ */