-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gas sensor firmware update #733
base: master
Are you sure you want to change the base?
Conversation
divkam
commented
Feb 2, 2017
- added commands to read gas sensor firmware version, status register, error register
- command line support to test firmware update
- periodic upload of gas sensor firmware version as part of periodic protobuf (Fields for gas sensor fw update proto#145)
- not tested
|
||
assert(xSemaphoreTakeRecursive(i2c_smphr, 30000)); | ||
|
||
(I2C_IF_Write(tvoc_i2c_addr, i2c_payload, 9, 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the number of bytes read in, in case it's less than the i2c payload size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the payload size has to be 9 though. if the bytes read is less, it breaks out of the loop
|
||
res = hello_fs_read(&fp,&i2c_payload[1],bytes_to_read, &bytes_read); | ||
} | ||
LOGI("TV: program done. Bytes read: %d, res:%d\n", bytes_read, res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe LOGE if bytes_read != bytes_to_read
(I2C_IF_Write(tvoc_i2c_addr, erase_cmd, 5, 1)); | ||
xSemaphoreGiveRecursive(i2c_smphr); | ||
|
||
vTaskDelay(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much margin does this give?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
500ms delay is as recommended in the datasheet. The entire programming takes 3-5 seconds.
LOGI("TVOC FW Filename:%s\n",bin_file); | ||
|
||
// reset CCS811 | ||
if(_tvoc_reset()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to get the I2C semaphore here and hold it for the entire process. The lock can still be left within the private functions in case they are called independently.
What happens if it is acquired for one step but not others?
kitsune/i2c_cmd.c
Outdated
bool tvoc_wa = false; | ||
uint8_t tvoc_i2c_addr = 0x5A; | ||
int init_tvoc(int measmode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a check here in case the device has been put into a bad state by the update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do. thanks
- removed status register read before boot since the register contents are garbage - added check for app valid. if sensor is in a bad state after a fw update, the status register read after boot will indicate the same - use Uartprintf instead of LOGI because init_tvoc is called before uart logger init