12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /************************************************************************************************
- * Include *
- ************************************************************************************************/
- #include "dev_can_id.h"
- #include <stdint.h>
- /************************************************************************************************
- * Config *
- ************************************************************************************************/
- union
- {
- uint32_t r;
- struct
- {
- uint8_t sa : 8;
- uint8_t ps : 8;
- uint8_t pf : 8;
- uint8_t dp : 1;
- uint8_t r : 1;
- uint8_t p : 3;
- } b;
- } new_can_id;
- #define CAN_PGN_PF 0xFFFF00
- #define CAN_PGN_PS 0xFF00
- uint32_t g_ps = 0xF4;
- uint32_t g_can_id = 0x18F011F4;
- uint32_t g_can_ota_id = 0x18DFE1F4;
- uint8_t g_can_iap = 0xDF;
- uint32_t get_new_can_id(uint8_t pf)
- {
- new_can_id.r = g_can_id;
- new_can_id.b.ps = new_can_id.b.sa;
- new_can_id.b.sa = g_ps;
- new_can_id.b.pf = pf;
- return new_can_id.r;
- }
- uint32_t set_new_can_id(uint16_t pgn)
- {
- new_can_id.r = g_can_id;
- new_can_id.b.sa = g_ps;
- new_can_id.b.ps = pgn & 0xFF;
- new_can_id.b.pf = pgn >> 8;
- return new_can_id.r;
- }
- uint32_t get_ota_id(uint8_t pf)
- {
- new_can_id.r = g_can_ota_id;
- new_can_id.b.ps = new_can_id.b.sa;
- new_can_id.b.sa = g_ps;
- new_can_id.b.pf = pf;
- return new_can_id.r;
- }
- /************************************************************************************************
- * Data structs *
- ************************************************************************************************/
- /************************************************************************************************
- * implements *
- ************************************************************************************************/
|