-
Notifications
You must be signed in to change notification settings - Fork 108
Update Flash Examples, Add API for Critical Sections #357
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
Conversation
Note to self: reverted some commits that accidentally made it from |
static inline void MXC_SYS_Crit_Enter(void) | ||
{ | ||
_mxc_crit_get_state(); | ||
if (_state.ie_status) |
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.
Add curly brackets to these if statements.
* @brief Exit a critical section of code, re-enabling interrupts if they | ||
* were previously. | ||
*/ | ||
static inline void MXC_SYS_Crit_Exit(void) |
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.
Why these are inline functions? Not saying it's wrong or needs to be changed, just curious.
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.
Inline is used to give the lowest possible timing overhead. Since this API is essentially just a wrapper around an assembly function, it doesn't make sense to add the 2-4uS overhead associated with a normal function call. Especially because the code needs to enter the critical section as soon as possible to avoid getting interrupted on its way there.
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's "static inline" as well because that is a forced requirement for accessing other static member variables and using static function calls.
Examples/MAX32660/Flash/main.c
Outdated
#define TESTSIZE 8192 //2 pages worth so we can do erase functions | ||
|
||
#define MXC_FLASH_MEM_SIZE_TEST MXC_FLASH_MEM_SIZE | ||
#define TEST_ADDRESS 0x0003E000 |
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.
Define TEST_ADDRESS with MXC_FLASH_ defines. (MXC_FLASH_MEM_SIZE - <page_num>*MXC_FLASH_PAGE_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.
Thanks, I like that. Done in 9be3fd4
} | ||
printf("Done!\n"); |
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.
Should the write be validated here as well?
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.
Yes it makes sense to validate again here. Added in 6c58802
printf("----------------\n"); | ||
) | ||
// clang-format on | ||
if (err) |
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.
Add curly brackets. Same for lines 283, 293, and 296.
The max32672.h changes were merged into main. And hopefully with the inclusion of Libraries/CMSIS/5.9.0/Core/Include/core_cm4.h, the build examples action will pass. I'll review when it's ready! |
- Simplify example and demonstrate Flash values surviving a power cycle/reset
Add API for critical sections to AI85 mxc_sys drivers
- Remove local headers that now live in MiscDrivers - Add MiscDrivers to IPATH/VPATH in board.mk files
4c2327e
to
324896d
Compare
@sihyung-maxim build issues are fixed, ready for your review |
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.
Nice. I like these new Flash examples.
Only thing I noticed was a small typo present in all the READMEs and main.c printfs.
Examples/MAX32520/Flash/README.md
Outdated
Press Push Button 1 (PB1/SW1) to continue... | ||
|
||
---(Critical)--- | ||
Sucessfully erased page 64 of flash (addr 0x1007e000) |
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.
Typo for Successfully.
Examples/MAX32520/Flash/main.c
Outdated
if (retval != E_NO_ERROR) { | ||
return retval; | ||
} | ||
printf("Sucessfully verified test pattern!\n\n"); |
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.
Typo for successfully.
Examples/MAX32572/Flash/main.c
Outdated
} | ||
|
||
retval = MXC_FLC_Write(end, end_len, buffer); | ||
printf("Sucessfully verified test pattern!\n\n"); |
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.
Typo for successfully
This PR resolves #287 by fixing and simplifying all micro's Flash examples. It also adds a purely inline API for entering and exiting a critical section of code to all micro's
mxc_sys.h
.Flash examples key changes:
Critical Section API key changes:
MXC_SYS_Crit_Enter/Exit
andMXC_SYS_In_Crit_Section
functions tomxc_sys.h
(supports ARM and RISC-V)MXC_CRITICAL(...)
macro tomxc_sys.h
Libraries/CMSIS/5.9.0/Core/Include/core_rv32.h
to undefine__CORTEX_M
when building for RISC-VCritical Section Example Usage:
or...
This macro is equivalent to:
How to Review:
Check out the
fix/flash-examples
branch locally and open the Flash example in your preferred IDE. Review the readme and run through the example on your preferred micro.Optionally review the critical API implementation in
mxc_sys.h
for your preferred micro.