|
| 1 | +/** |
| 2 | + * @file steering_can_protocol.h |
| 3 | + * @brief Steering CAN Protocol. |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | + |
| 8 | +#ifndef _OSCC_STEERING_CAN_PROTOCOL_H_ |
| 9 | +#define _OSCC_STEERING_CAN_PROTOCOL_H_ |
| 10 | + |
| 11 | + |
| 12 | +#include <stdint.h> |
| 13 | +#include "magic.h" |
| 14 | + |
| 15 | + |
| 16 | +/* |
| 17 | + * @brief Steering command message (CAN frame) ID. |
| 18 | + * |
| 19 | + */ |
| 20 | +#define OSCC_STEERING_COMMAND_CAN_ID (0x64) |
| 21 | + |
| 22 | +/* |
| 23 | + * @brief Steering report message (CAN frame) ID. |
| 24 | + * |
| 25 | + */ |
| 26 | +#define OSCC_STEERING_REPORT_CAN_ID (0x65) |
| 27 | + |
| 28 | +/* |
| 29 | + * @brief Steering report message (CAN frame) length. |
| 30 | + * |
| 31 | + */ |
| 32 | +#define OSCC_STEERING_REPORT_CAN_DLC (8) |
| 33 | + |
| 34 | +/* |
| 35 | + * @brief Steering report message publishing frequency. [Hz] |
| 36 | + * |
| 37 | + */ |
| 38 | +#define OSCC_REPORT_STEERING_PUBLISH_FREQ_IN_HZ (50) |
| 39 | + |
| 40 | +/* |
| 41 | + * @brief Steering DTC bitfield position indicating an invalid sensor value. |
| 42 | + * |
| 43 | + */ |
| 44 | +#define OSCC_STEERING_DTC_INVALID_SENSOR_VAL (0x0) |
| 45 | + |
| 46 | + |
| 47 | +#pragma pack(push) |
| 48 | +#pragma pack(1) |
| 49 | + |
| 50 | +/** |
| 51 | + * @brief Steering command message data. |
| 52 | + * |
| 53 | + * CAN frame ID: \ref OSCC_STEERING_COMMAND_CAN_ID |
| 54 | + * |
| 55 | + */ |
| 56 | +typedef struct |
| 57 | +{ |
| 58 | + uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC. |
| 59 | + Byte 0 should be \ref OSCC_MAGIC_BYTE_0. |
| 60 | + Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */ |
| 61 | + |
| 62 | + uint16_t spoof_value_low; /*!< Value to be sent on the low spoof signal. */ |
| 63 | + |
| 64 | + uint16_t spoof_value_high; /*!< Value to be sent on the high spoof signal. */ |
| 65 | + |
| 66 | + uint8_t enable; /*!< Command to enable or disable steering control. |
| 67 | + * Zero value means disable. |
| 68 | + * Non-zero value means enable. */ |
| 69 | + |
| 70 | + uint8_t reserved; /*!< Reserved. */ |
| 71 | +} oscc_steering_command_s; |
| 72 | + |
| 73 | + |
| 74 | +/** |
| 75 | + * @brief Steering report message data. |
| 76 | + * |
| 77 | + * CAN frame ID: \ref OSCC_STEERING_REPORT_CAN_ID |
| 78 | + * |
| 79 | + */ |
| 80 | +typedef struct |
| 81 | +{ |
| 82 | + uint8_t magic[2]; /* Magic number identifying CAN frame as from OSCC. |
| 83 | + Byte 0 should be \ref OSCC_MAGIC_BYTE_0. |
| 84 | + Byte 1 should be \ref OSCC_MAGIC_BYTE_1. */ |
| 85 | + |
| 86 | + uint8_t enabled; /*!< Steering controls enabled state. |
| 87 | + * Zero value means disabled (commands are ignored). |
| 88 | + * Non-zero value means enabled (no timeouts or overrides have occured). */ |
| 89 | + |
| 90 | + uint8_t operator_override; /*!< Driver override state. |
| 91 | + * Zero value means there has been no operator override. |
| 92 | + * Non-zero value means an operator has physically overridden |
| 93 | + * the system. */ |
| 94 | + |
| 95 | + uint8_t dtcs; /* Bitfield of DTCs present in the module. */ |
| 96 | + |
| 97 | + uint8_t reserved[3]; /*!< Reserved. */ |
| 98 | +} oscc_steering_report_s; |
| 99 | + |
| 100 | +#pragma pack(pop) |
| 101 | + |
| 102 | + |
| 103 | +#endif /* _OSCC_STEERING_CAN_PROTOCOL_H_ */ |
0 commit comments