2021-12-10 01:21 AM
I am trying to get the bits of an uint8_t into an array. I use two for loops for that and don't know why I get this warning.
This is the code I use:
void System_Info_Get_Jumper_State(I2C_HandleTypeDef* hi2c1, uint8_t* Jumper_State_Array_Address)
{
uint8_t Jumper_States[2] = {0x00};
uint8_t Bit_Mask = 1;
HAL_I2C_Mem_Read(hi2c1, System_Info_Address, System_Info_Input_Register1_Address, 1, Jumper_States, 2, 1000);
for(uint8_t Run_Through = 0; Run_Through <= 1; Run_Through ++)
{
for(uint8_t Place = 0; Place <= 7; Place++)
{
Jumper_State_Array_Address[Place] = Bit_Mask & Jumper_States[Run_Through];
Bit_Mask << 1;
}
Bit_Mask = 1;
}
}
The warning points to line 12 where the bit shft happens.
Solved! Go to Solution.
2021-12-10 01:31 AM
2021-12-10 01:31 AM
> Bit_Mask << 1;
You wanted to write:
Bit_Mask <<= 1;
JW
2021-12-10 01:41 AM
Thank you that solved my problem.