can_helper.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /** \addtogroup hal */
  2. /** @{*/
  3. /* mbed Microcontroller Library
  4. * Copyright (c) 2006-2013 ARM Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef MBED_CAN_HELPER_H
  19. #define MBED_CAN_HELPER_H
  20. #if DEVICE_CAN
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /**
  25. *
  26. * \enum CANFormat
  27. *
  28. * \brief Values that represent CAN Format
  29. **/
  30. enum CANFormat {
  31. CANStandard = 0,
  32. CANExtended = 1,
  33. CANAny = 2
  34. };
  35. typedef enum CANFormat CANFormat;
  36. /**
  37. *
  38. * \enum CANType
  39. *
  40. * \brief Values that represent CAN Type
  41. **/
  42. enum CANType {
  43. CANData = 0,
  44. CANRemote = 1
  45. };
  46. typedef enum CANType CANType;
  47. /**
  48. *
  49. * \struct CAN_Message
  50. *
  51. * \brief Holder for single CAN message.
  52. *
  53. **/
  54. struct CAN_Message {
  55. unsigned int id; // 29 bit identifier
  56. unsigned char data[8]; // Data field
  57. unsigned char len; // Length of data field in bytes
  58. CANFormat format; // Format ::CANFormat
  59. CANType type; // Type ::CANType
  60. };
  61. typedef struct CAN_Message CAN_Message;
  62. #ifdef __cplusplus
  63. };
  64. #endif
  65. #endif
  66. #endif // MBED_CAN_HELPER_H
  67. /** @}*/