- (*((uint32_t*)ep1_tx_buff))=slot->msg.id;
- (*((uint32_t*)(ep1_tx_buff+4)))=slot->msg.flags<<8 | (slot->msg.length&0xFF);
- for (i=0;i<CAN_MSG_LENGTH;i++){
- (*((uint32_t*)(ep1_tx_buff+8+i)))=slot->msg.data[i];
+ uint16_t msgflags;
+ uint32_t msgid;
+
+ *(uint8_t *)(ep1_tx_buff)=0;
+ *(uint8_t *)(ep1_tx_buff+1)=slot->msg.length;
+
+ msgflags=slot->msg.flags;
+ msgid=slot->msg.id;
+ #if __BYTE_ORDER == __BIG_ENDIAN
+ msgflags = bswap_16( msgflags);
+ msgid = bswap_32( msgid);
+ #endif
+
+ *(uint16_t *)(ep1_tx_buff+2)=msgflags;
+ *(uint32_t *)(ep1_tx_buff+4)=msgid;
+ for (i=0;i<slot->msg.length;i++){
+ *(uint8_t *)(ep1_tx_buff+8+i)=slot->msg.data[i];
+ }
+ for (;i<CAN_MSG_LENGTH;i++){
+ *(uint8_t *)(ep1_tx_buff+8+i)=0;