AnsweredAssumed Answered

HAL driver CAN msg typedefs

Question asked by batuu on Oct 16, 2015
Latest reply on Oct 20, 2015 by Andrei Chichak
I worked a lot with the StandardPeriphLib but now I try to migrate over to the HAL driver for new projects. The HAL driver come with a heavy overhead. For example, without any optimization level the function HAL_DMA_IRQHandler(...) compiles to a size of approx. 10kB Flash ... wow!

In real time applications I try keep the code as fast and small as possible.
I came across some problems, when I tried to copy data to CAN-msg struct.
In the past I usually used:

memcpy(txMsg->Data, &some_data[0], 8);

But now with the HAL driver I got wrong data on the CAN-Bus. Why?
They changed the type definition to:

typedef struct
{
  uint32_t StdId; 
  uint32_t ExtId; 
  uint32_t IDE; 
  uint32_t RTR;
  uint32_t DLC;    
  uint32_t Data[8];
}CanTxMsgTypeDef;

I real don't get the point, why the Data field now is an uint32_t array. It does not reflact the CAN-Bus specification or not even the internal register structure.

So can anybody explain this change?

Copying data now will take much more time and much more memory.
I have to rewrite a lot of code.

Outcomes