LPC_CAN1->TDA1 = *(uint32_t *) &msg->data[0]; // Write first 4 data bytes
please tell me why this *(uint32_t ) is used and what is the purpose of this "" before and after the uint32_t
Objective of this code is to copy first 4 bytes present at msg->data[0]
to LPC_CAN1->TDA1
.
&msg->data[0]
gives the address of msg->data[0].
(uint32_t *) &msg->data[0]
casts that address to be an address pointing to a 32-bit unsigned integer.
*(uint32_t *) &msg->data[0]
reads uint32_t value (4-byte unsigned integer) from the address.
Hope that makes sense.