1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /************************************************************************************************
- * Include *
- ************************************************************************************************/
- #include "can_id_deal.h"
- #include "can_task.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;
- 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;
- }
- uint8_t can_id_set(pdu_tag rec_msg)
- {
- uint8_t ps = 0;
- if (rec_msg.data.u8_buf[0] == 0x01)
- {
- g_ps = rec_msg.data.u8_buf[1];
- rec_msg.data.u8_buf[1] = 1;
- }
- else
- {
- rec_msg.data.u8_buf[1] = 0;
- }
- ps = rec_msg.id.b.ps;
- rec_msg.id.b.ps = rec_msg.id.b.ps;
- rec_msg.id.b.sa = ps;
- push_can_message_to_queue(rec_msg.id.r, 2, rec_msg.data.u8_buf);
- return 0;
- }
- 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 *
- ************************************************************************************************/
|