STMicroelectronics / iis3dwb-pid

iis3dwb platform independent driver based on Standard C language and compliant with MISRA standard
BSD 3-Clause "New" or "Revised" License
12 stars 9 forks source link

Fix issue #6 and #7 and add a new API for FIFO tag #9

Closed cparata closed 1 year ago

cparata commented 1 year ago

Hi all, I propose this fix for issues #6 and #7 . I added also a new API to read the tag like in the previous version of the driver. I have also fixed some typos in the comments. Best Regards, Carlo

escherstair commented 1 year ago

This seems nice; not so different from what I proposed in my PR (it has been rejected, but I don't know why). But I would completely remove the function bytecpy https://github.com/STMicroelectronics/iis3dwb-pid/blob/7308781b297470fbcd41fa3f36253a6ae123cf5e/iis3dwb_reg.c#L93-L99 It seems to me that its purpose is to set variables of different size from an uint8_t. As an example here https://github.com/STMicroelectronics/iis3dwb-pid/blob/7308781b297470fbcd41fa3f36253a6ae123cf5e/iis3dwb_reg.c#L921 and here https://github.com/STMicroelectronics/iis3dwb-pid/blob/7308781b297470fbcd41fa3f36253a6ae123cf5e/iis3dwb_reg.c#L3121 But it involves a brutal pointer-cast that is not safe (it depends on the endiannes of the platform). I think that a simple a = b; does the trick as needed. But I can be wrong in case its purpose is different.