|
|
@ -264,25 +264,35 @@ TFMINI_I2C::measure() |
|
|
|
// Send the command to take a measurement.
|
|
|
|
// Send the command to take a measurement.
|
|
|
|
// const uint8_t CMD_FW_VERSION[] = { 0x5A, 0x04, 0x01, 0x5F };
|
|
|
|
// const uint8_t CMD_FW_VERSION[] = { 0x5A, 0x04, 0x01, 0x5F };
|
|
|
|
// const uint8_t CMD_FW_VERSION[] = { 0x5A, 0x04, 0x01, 0x5F };
|
|
|
|
// const uint8_t CMD_FW_VERSION[] = { 0x5A, 0x04, 0x01, 0x5F };
|
|
|
|
const uint8_t CMD_READ_MEASUREMENT[] = { 0x5A, 0x05, 0x00, 0x07, 0x66 }; |
|
|
|
set_to_uart_mode(); |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
// const uint8_t CMD_READ_MEASUREMENT[] = { 0x5A, 0x05, 0x00, 0x07, 0x66 };
|
|
|
|
|
|
|
|
|
|
|
|
// uint8_t cmd = TFMINI_I2C_TAKE_RANGE_REG;
|
|
|
|
// // uint8_t cmd = TFMINI_I2C_TAKE_RANGE_REG;
|
|
|
|
int ret_val = transfer(CMD_READ_MEASUREMENT, 5, nullptr, 0); |
|
|
|
// int ret_val = transfer(CMD_READ_MEASUREMENT, 5, nullptr, 0);
|
|
|
|
|
|
|
|
|
|
|
|
return ret_val; |
|
|
|
// return ret_val;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int TFMINI_I2C::set_to_uart_mode() |
|
|
|
int TFMINI_I2C::set_to_uart_mode() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
uint8_t cmd[5] = {0x5A, 0x05, 0x0A, 0,69}; |
|
|
|
uint8_t urt[5] = {0x5A, 0x05, 0x0A, 0,0x69}; |
|
|
|
|
|
|
|
uint8_t cmd[4] = {0x5A,0x04,0x10,0x6E}; |
|
|
|
|
|
|
|
uint8_t save[4] = {0x5A,0x04,0x11,0x6F}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transfer(urt, sizeof(urt), nullptr, 0) != PX4_OK) { |
|
|
|
|
|
|
|
PX4_INFO("could reset to uart mode"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
px4_usleep(100_ms); |
|
|
|
if (transfer(cmd, sizeof(cmd), nullptr, 0) != PX4_OK) { |
|
|
|
if (transfer(cmd, sizeof(cmd), nullptr, 0) != PX4_OK) { |
|
|
|
PX4_INFO("could reset to uart mode"); |
|
|
|
PX4_INFO("could reset to uart mode"); |
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("---reset to uart mode ok ******\n"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
px4_usleep(100_ms); |
|
|
|
|
|
|
|
if (transfer(save, sizeof(save), nullptr, 0) != PX4_OK) { |
|
|
|
|
|
|
|
PX4_INFO("could reset to uart mode"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
px4_usleep(1000_ms); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
int |
|
|
|
int |
|
|
@ -569,8 +579,8 @@ TFMINI_I2C::print_test() |
|
|
|
void |
|
|
|
void |
|
|
|
TFMINI_I2C::set_uart_mode() |
|
|
|
TFMINI_I2C::set_uart_mode() |
|
|
|
{ |
|
|
|
{ |
|
|
|
set_to_uart_mode(); |
|
|
|
// int ret = set_to_uart_mode();
|
|
|
|
printf("---reset to uart mode ******\n"); |
|
|
|
printf("---reset to uart mode %d******\n"); |
|
|
|
printf("-----qwerqwerqwer*********\n"); |
|
|
|
printf("-----qwerqwerqwer*********\n"); |
|
|
|
printf("-------xfgvzxcvzxdv***************\n"); |
|
|
|
printf("-------xfgvzxcvzxdv***************\n"); |
|
|
|
} |
|
|
|
} |
|
|
|