add functions for bit setting and checking

This commit is contained in:
Sem van der Hoeven
2024-10-02 00:00:50 +02:00
parent f9cef163b9
commit ac2c2d6643
3 changed files with 35 additions and 0 deletions

View File

@@ -52,6 +52,21 @@ void obd2_elm327_get_state(obd2_elm327_t *elm327, char *state)
strcpy(state, bt_states[elm327->bt_state]);
}
char obd2_el327_is_bit_set(obd2_elm327_t *elm327, uint16_t pos)
{
return elm327->value_updates & (1 << pos);
}
void obd2_el327_set_bit(obd2_elm327_t *elm327, uint16_t pos)
{
elm327->value_updates |= (1 << pos);
}
void obd2_el327_clear_bit(obd2_elm327_t *elm327, uint16_t pos)
{
elm327->value_updates &= ~(1 << pos);
}
void obd2_elm327_check_connection(obd2_elm327_t *elm327)
{
if (elm327->bt_state != BT_CONNECTED)