Initial Rev 3 flash driver#30
Conversation
|
@NArmistead adding you for review bc this has stalled. if you're uncomfortable reviewing a driver lmk |
NArmistead
left a comment
There was a problem hiding this comment.
Only thing from me is that there are a couple functions that would need a null check on the flash handle to be consistent with the other functions that have it. If it isn't necessary I'll approve.
| FLASH_BLOCK_13 , | ||
| FLASH_BLOCK_14 , | ||
| FLASH_BLOCK_15 | ||
| FLASH_BLOCK_15 , |
There was a problem hiding this comment.
Can fix. If youre curious, this arose because I was originally going to extend the enum to support the number of blocks on the new chip, but theres hundreds of pages & the smallest block size.
There was a problem hiding this comment.
I have to say: these kinds of inits made me wish C (and more languages in general) just had a way to create these kinds of types that are basically just ranges without crazy enums or (in the case of OOP languages like C++) a janky setup of operator overloading.
Is it time for SDR to contribute to the ISO C specification?
There was a problem hiding this comment.
I think C2y (expected to be C29) will do something like this for switch statements! Syntax like:
case 1 ... case 99:
There was a problem hiding this comment.
also inb4 the preprocessor lets you do for loops lol. turing complete c preprocessor when?
There was a problem hiding this comment.
sometimes I kinda wish C had the C++ constexpr stuff
There was a problem hiding this comment.
Agreed, guaranteed compile time evaluation would go hard asf.
| FLASH_STATUS flash_is_flash_busy | ||
| ( | ||
| HFLASH_BUFFER* pflash_handle | ||
| ) | ||
| { | ||
| if ( flash_get_status( pflash_handle ) != FLASH_OK ) |
There was a problem hiding this comment.
should there be a check that pflash_handle is not NULL?
There was a problem hiding this comment.
We can. There was a colton-era assumption that the flash handle would always be non-null, but we practice defensive programming and should null-check on new drivers.
| FLASH_STATUS flash_init | ||
| ( | ||
| HFLASH_BUFFER* pflash_handle | ||
| ) | ||
| { |
There was a problem hiding this comment.
should there be a check that pflash_handle is not NULL?
| if ( timeout_ms != 0xFFFFFFFFu ) | ||
| { | ||
| if ( ( HAL_GetTick() - start ) > timeout_ms ) |
There was a problem hiding this comment.
I think these two if statements can be consolidated into one
There was a problem hiding this comment.
yeah why did i do that lol
| * @file : MX25L51245GZ2I-08G.c | ||
| * @brief : Driver for the flash chip on FC rev 3. | ||
| ****************************************************************************** | ||
| * @attention |
There was a problem hiding this comment.
should we be using @copyright?
There was a problem hiding this comment.
I believe I inherited this from STM, but will revisit this when I get home. Either way @copyright is probably the correct tag for doxygen generation.
| } | ||
|
|
||
| /* Validate addresses */ | ||
| if( end_addr > FLASH_MAX_ADDR ) |
There was a problem hiding this comment.
nit: space before parenthesis
266-750Balloons
left a comment
There was a problem hiding this comment.
Again, flash isn't my area of expertise, but I don't see anything problematic here.
| FLASH_BLOCK_13 , | ||
| FLASH_BLOCK_14 , | ||
| FLASH_BLOCK_15 | ||
| FLASH_BLOCK_15 , |
There was a problem hiding this comment.
I have to say: these kinds of inits made me wish C (and more languages in general) just had a way to create these kinds of types that are basically just ranges without crazy enums or (in the case of OOP languages like C++) a janky setup of operator overloading.
Is it time for SDR to contribute to the ISO C specification?
Description
Implements the critical APIs needed to operate flash on Rev. 3.
Issue Link
Closes #5.
Child: SunDevilRocketry/Flight-Computer-Firmware#261
Depends on: SunDevilRocketry/mod#127 (can be reviewed separately though, just make sure this branch is checked out if you run any tests)
Testing
N/A -- no testing possible until rev3 initial integration.
Other
N/A
Reviewer Checklist
Standards
Error Handling
Memory
Performance