-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ht09 fall david #5
base: main
Are you sure you want to change the base?
Conversation
…to execute write and read functions. Need to add MessageInterface
…into ht09-fall-david
uint16_t _pec15Table[256]; | ||
|
||
/** | ||
* We will need this for both models of the IC | ||
* This determines where we get our signals from on the Arduino | ||
* It can only be 9 or 10 | ||
* NOTE: needs to be initialized | ||
*/ | ||
std::array<int, num_chip_selects> _chip_select; | ||
|
||
/** | ||
* We will need this for both models of the IC | ||
* This determines where we get our signals from on the Arduino | ||
* It can only be 9 or 10 | ||
* NOTE: needs to be initialized | ||
*/ | ||
std::array<int, num_chips> _chip_select_per_chip; | ||
|
||
/** | ||
* We will only end up using the address if this is a LTC6811-2 | ||
* NOTE: But if we are, we need to call a setup function to instatiate each with the correct addresses | ||
* BMS Segments 1, 4, and 5 are on chip select 9 | ||
* BMS Segments 2, 3, and 6 are on chip select 10 | ||
* Those segments correspond to 2 ICs each, so the instance with chip_select 9 | ||
* Will have IC addresses: 0,1,6,7,8,9 | The rest are for chip_select 10 | ||
*/ | ||
std::array<int, num_chips> _address; |
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.
make these const if they are not going to change during runtime
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.
Since pec15table has to be initialized through a function call during runtime, in order to make it const I have to modify the implementation by doing a static function call in the constructor (according to chatgpt). If this isn't preferable I can change it back
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.
you can make the initialization of the _pec15table be calculated as a constexpr
: https://en.cppreference.com/w/cpp/language/constexpr
essentially what this allows you to do is, as long as all inputs are known at compile time, your pectable generated and is calculated by the compiler when you are compiling your code so your micro does not handle the computation itself and instead just gets given a pre-computed table to pull from.
if (_chip_type == LTC6811_Type_e::LTC6811_1) | ||
{ | ||
return _read_data_through_broadcast(); | ||
} | ||
else | ||
{ | ||
return _read_data_through_address(); | ||
} |
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.
please use if constexpr
here instead instead and make the type const
.
cmd[0] = (adc_cmd >> 8) & 0xFF; | ||
cmd[1] = adc_cmd & 0xFF; | ||
|
||
if (_chip_type == LTC6811_Type_e::LTC6811_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.
if constexpr
updated for loop for read_data and added a package cell voltage/auxillaries so there's no switch statement.
I also used the logic analyzer for the broadcast signal, and for some reason the 2 second delay time threw the enable / SCK off, so I increased it to 5 and that fixed it. Not once have I been able to get a MISO signal from the new board, so I'm still trying to figure that out.