stm32: Improvements to CAN bus ID generation. And added a small fast hash library (#3165)
Improved CAM bus ID generation, there were issues with ID collisions. Added a small fast hash library. Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "sched.h" // DECL_INIT
|
||||
#include <string.h>
|
||||
#include "can.h"
|
||||
#include <fasthash.h>
|
||||
|
||||
#if (CONFIG_CAN_PINS_PA11_PA12)
|
||||
DECL_CONSTANT_STR("RESERVE_PINS_CAN", "PA11,PA12");
|
||||
@@ -151,10 +152,8 @@ static void can_transmit(uint32_t id, uint32_t dlc, uint8_t *pkt)
|
||||
// Convert Unique 96-bit value into 48 bit representation
|
||||
static void pack_uuid(uint8_t* u)
|
||||
{
|
||||
for(int i=0; i<SHORT_UUID_LEN; i++) {
|
||||
u[i] = *((uint8_t*)(UID_BASE+i)) ^
|
||||
*((uint8_t*)(UID_BASE+i+SHORT_UUID_LEN));
|
||||
}
|
||||
uint64_t hash = fasthash64((uint8_t*)UID_BASE, 12, 0xA16231A7);
|
||||
memcpy(u, &hash, SHORT_UUID_LEN);
|
||||
}
|
||||
|
||||
static void can_uuid_resp(void)
|
||||
|
||||
Reference in New Issue
Block a user