Skip to content

Commit

Permalink
added function to split 12 bits command in high/low registers. rewrit…
Browse files Browse the repository at this point in the history
…e read_salt for it
  • Loading branch information
yabezsh committed Jul 21, 2017
1 parent d483d91 commit 9d2d467
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
20 changes: 16 additions & 4 deletions Salt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,29 @@ void Salt::find_device_address(int8_t high_reg_bits)
this -> set_device_address(chip_id << 5 | high_reg_bits);
}

/*void Salt::read_salt(int8_t high_reg_bits, int8_t low_reg_bits, uint8_t* command)
void Salt::read_salt(int8_t high_reg_bits, int8_t low_reg_bits, uint8_t* command)
{
this -> find_device_address(high_reg_bits);
this -> get_bus_access();
this -> read_buffer(low_reg_bits,command);
}
*/

void Salt::read_salt(int8_t high_reg_bits, int8_t low_reg_bits, uint16_t* command){}
void Salt::write_salt(int8_t high_reg_bits, int8_t low_reg_bits, uint16_t command) {}

void Salt::read_salt(int16_t low_reg_bits, uint16_t* command){}
void Salt::write_salt(int16_t low_reg_bits, uint16_t command) {}
void Salt::read_salt(int16_t full_reg_bits, uint16_t* command)
{
int8_t high_reg_bits,low_reg_bits;
this->split_register(full_reg_bits, &high_reg_bits, &high_reg_bits);
this->read_salt(high_reg_bits,low_reg_bits,command);

}

void Salt::split_register(int16_t full_reg_bits,int8_t* high_reg_bits,int8_t* low_reg_bits)
{
*high_reg_bits = (full_reg_bits >> 8);
*low_reg_bits = full_reg_bits & 0xFF;
}
void Salt::write_salt(int16_t full_reg_bits, uint16_t command) {}

//void Salt::write_salt(int8_t high_reg_bits, int8_t low_reg_bits, uint8_t command) {}
5 changes: 3 additions & 2 deletions Salt.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ class Salt : public I2C {
Salt();
~Salt();
void find_device_address(int8_t);
// void read_salt(int8_t, int8_t, uint8_t*);
void read_salt(int8_t, int8_t, uint8_t*);
void read_salt(int8_t, int8_t, uint16_t*);
void read_salt(int16_t, uint16_t*);
// void write_salt(int8_t, int8_t, uint8_t);
void write_salt(int8_t, int8_t, uint8_t);
void write_salt(int8_t, int8_t, uint16_t);
void write_salt(int16_t, uint16_t);
void split_register(int16_t, int8_t*,int8_t*);
private:
int8_t chip_id;

Expand Down

0 comments on commit 9d2d467

Please sign in to comment.