mirror of
https://github.com/whowechina/musec_pico.git
synced 2026-10-11 08:48:19 +03:00
Tmag5273 can change address
This commit is contained in:
@@ -111,6 +111,14 @@ bool tmag5273_is_present()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tmag5273_change_addr(uint8_t i2c_addr)
|
||||
{
|
||||
tmag5273_write_reg(0x0c, (i2c_addr << 1) | 0x01);
|
||||
instances[current_instance].addr = i2c_addr;
|
||||
uint8_t new_addr = tmag5273_read_reg(0x0c) >> 1;
|
||||
return new_addr == i2c_addr;
|
||||
}
|
||||
|
||||
bool tmag5273_init_sensor()
|
||||
{
|
||||
tmag5273_write_reg(0x03, 0x01 << 2); // Enable angle calculation
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
void tmag5273_init(unsigned instance, i2c_inst_t *i2c_port, uint8_t i2c_addr);
|
||||
void tmag5273_use(unsigned instance);
|
||||
bool tmag5273_is_present();
|
||||
bool tmag5273_change_addr(uint8_t i2c_addr);
|
||||
|
||||
bool tmag5273_init_sensor();
|
||||
|
||||
uint8_t tmag5273_read_reg(uint8_t addr);
|
||||
|
||||
Reference in New Issue
Block a user