Issue with word Data Type When Porting Arduino Library to STM32

Hi @Middleware & OS I am porting some Arduino library code to STM32 and encountering issues with the word data type. The compiler gives me the error: "expected expression before 'word'". Here is the code:
uint8_t au8Buffer[MAX_BUFFER];
uint16_t *au16regs;
....
if(i % 2)
{
au16regs[i / 2] = word(au8Buffer[i + u8byte], lowByte(au16regs[i / 2]));
}
uint8_t au8Buffer[MAX_BUFFER];
uint16_t *au16regs;
....
if(i % 2)
{
au16regs[i / 2] = word(au8Buffer[i + u8byte], lowByte(au16regs[i / 2]));
}
The Arduino compiler does not produce an error for this code. Do you have any suggestions? I tried replacing word with unsigned short or uint16_t, but the error persists.
Solution:
@Sterling The issue arises because word is a specific data type and function in the Arduino environment, which may not be directly available or compatible with STM32 libraries.
Jump to solution
4 Replies
Solution
Dtynin
Dtynin4mo ago
@Sterling The issue arises because word is a specific data type and function in the Arduino environment, which may not be directly available or compatible with STM32 libraries.
Dtynin
Dtynin4mo ago
Instead of using word, manually combine the bytes to create the 16-bit word.
Sterling
Sterling4mo ago
Woah, I tried this @Dtynin ... Thanks 🙏
Dtynin
Dtynin4mo ago
You're welcome 😁 what are friends for?😁😊
Want results from more Discord servers?
Add your server