-
Notifications
You must be signed in to change notification settings - Fork 3k
Kinetis update to fix tickless #11412
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
Kinetis update to fix tickless #11412
Conversation
cc @0xc0170 @jamesbeyond @kjbracey-arm @maciejbocianski |
@mmahadevan108, thank you for your changes. |
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.
Looks basically good to me, except for the apparently unbalanced PRE/POST calls - please check that.
Other stuff is basically style bike-shedding you can take with a pinch of salt.
int clock_enabled = 0; | ||
switch (uart_index) { | ||
case 0: | ||
clock_enabled = (SIM->SCGC4 & SIM_SCGC4_UART0_MASK) >> SIM_SCGC4_UART0_SHIFT; |
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.
Personally, I'd be inclined to pare this down to more like:
static bool serial_is_enabled(uint32_t uart_index)
{
switch (uart_index) {
case 0:
return SIM->SCGC4 & SIM_SCGC4_UART0_MASK;
default:
return false;
}
}
Let bool
take the strain. But this is fine.
|
||
/* Check if data is waiting to be written out of transmit buffer */ | ||
if (!(kUART_TransmissionCompleteFlag & UART_GetStatusFlags((UART_Type *)base))) { | ||
uart_tx_ongoing = 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.
Again, I'd just return true
. But maybe doesn't fit the style in this unit.
serial_wait_tx_complete(STDIO_UART); | ||
/* Check if any of the UART's is transmitting data */ | ||
if (serial_check_tx_ongoing()) { | ||
return; |
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.
Aha! This is actually an approach I hadn't considered, and it is actually much better than waiting or going into shallow sleep. Thank you.
Returning is best here. This gives waking interrupts a chance to operate, rather than sitting there looping with interrupts disabled inside the HAL - possibly bad for performance. The core code will re-enable interrupts briefly, giving them a chance to execute, and then come back here again if it still wants to sleep. The loop will happen at a higher level, with proper "I've changed my mind about sleeping" checks.
Except it looks unbalanced with respect to the vPortPRE_SLEEP_PROCESSING
above. Should this check be done before that?
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.
Aha! This is actually an approach I hadn't considered, and it is actually much better than waiting or going into shallow sleep. Thank you.
Returning is best here. This gives waking interrupts a chance to operate, rather than sitting there looping with interrupts disabled inside the HAL - possibly bad for performance. The core code will re-enable interrupts briefly, giving them a chance to execute, and then come back here again if it still wants to sleep. The loop will happen at a higher level, with proper "I've changed my mind about sleeping" checks.
Except it looks unbalanced with respect to the
vPortPRE_SLEEP_PROCESSING
above. Should this check be done before that?
I have addressed the unbalannce PRE/POST by moving the serial check earlier.
@@ -19,8 +19,7 @@ | |||
|
|||
extern void vPortPRE_SLEEP_PROCESSING(clock_mode_t powermode); | |||
extern void vPortPOST_SLEEP_PROCESSING(clock_mode_t powermode); | |||
extern void serial_wait_tx_complete(uint32_t uart_index); | |||
|
|||
extern int serial_check_tx_ongoing(); |
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 really be bool
. I think only reason there's not much bool in the existing code is because it predates C99 being enabled in Mbed OS. Oh, and (void)
. This isn't C++ - still need (void)
in declarations, or else you're leaving parameters unspecified.
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.
I have changed this to bool.
The code checks if any of the UART's is still transmitting. If so then prevent from entering deepsleep Signed-off-by: Mahesh Mahadevan <[email protected]>
We should not block in case the UART is busy transmitting. The API has been updated to check the status of all UART's and return 1 in case any of them is busy transmitting. Signed-off-by: Mahesh Mahadevan <[email protected]>
a47f5eb
to
5c48e4e
Compare
The code checks if any of the UART's is still transmitting. If so then prevent from entering deepsleep Signed-off-by: Mahesh Mahadevan <[email protected]>
We should not block in case the UART is busy transmitting. The API has been updated to check the status of all UART's and return 1 in case any of them is busy transmitting. Signed-off-by: Mahesh Mahadevan <[email protected]>
5c48e4e
to
31da8ff
Compare
CI started |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
Build failures do not seem related to this PR |
CI restarted |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Hi @0xc0170, this issue, has bigger impacts, and fails one of mbed-os example, I suggest get it into mbed-os-5.14-rc2 |
Release version updated as requested, cc @adbridge |
Description
This should fix issue #11401 (comment)
Pull request type