AnsweredAssumed Answered

Suggestions for USBDM

Question asked by simon qian on Sep 8, 2010
Latest reply on Sep 14, 2010 by simon qian

I'm porting USBDM to my programming tool, most code is portable and do not need to be changed.

But the endianness is not concerned in the USBDM code.

 

For example:

U8 f_CMD_GET_CAPABILITIES(void)
{
   *(U16*)(commandBuffer+1) = CAPABILITY;  // Returns 16-bit value
   returnSize = 3;
   return BDM_RC_OK;
}

 

How about:

U8 f_CMD_GET_CAPABILITIES(void)
{
   SET_BE_U16(&commandBuffer[1], CAPABILITY);  // Returns 16-bit value
   returnSize = 3;
   return BDM_RC_OK;
}

 

Here, BE means big endian.

SET_BE_U16 can be defined to swap the endian if controller is not big endian.

And it can be no effect on original controller, because no swap is done if controller is big endian.

 

And GET_BE_U16 chould be defined to read a U16 value from a BE buffer, example:

U16 addr       = GET_BE_U16(&commandBuffer[6]);

 

BTW:

Does USBDM accpet patches? Does it has a SVN or GIT?

I can try to modify such code and provide the patch.

With these changes, the code will be more generic.

Outcomes