Skip to content

SPI and deep sleep fixes for FUTURE_SEQUANA target. #8905

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

Merged
merged 2 commits into from
Dec 10, 2018

Conversation

lrusinowicz
Copy link
Contributor

Description

  1. Proper handling of (NC) in the SPI initialization to allow only a subset SPI pins to be used for communication (e.g. no SS pin or tx-only SPI mode).

  2. DEVICE_LOWPOWERTIMER was renamed into DEVICE_LPTICKER in one of the prevoius Mbed OS releases. This was missed in a few places in Sequana code.

  3. Better handling of deep sleep entry in hal_deepsleep()

  4. Cypress Power Manager deep sleep callback removed from HAL serial driver. Callbacks are not strictly necessary, serial works anyway, but having them breaks assumed timing dependencies in HAL sleep tests - serial callback handling delays deep sleep mode entry more than allowed in these tests.

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

- fix to allow using only a subset of pins for SPI communication
- added missing conter increment in spi_master_block_write()
@0xc0170 0xc0170 requested review from a team November 29, 2018 12:43
@0xc0170
Copy link
Contributor

0xc0170 commented Dec 6, 2018

@ARMmbed/mbed-os-hal Please review

Copy link
Contributor

@donatieng donatieng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but a few things on deepsleep

@@ -374,7 +374,7 @@ static cy_en_syspm_status_t serial_pm_callback(cy_stc_syspm_callback_params_t *p

case CY_SYSPM_CHECK_FAIL:
/* Enable the UART to operate */
Cy_SCB_UART_Enable(obj->base);
//Cy_SCB_UART_Enable(obj->base);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was it removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the point #4 in description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups... you're right, it doesn't make sense.

@@ -384,7 +384,7 @@ static cy_en_syspm_status_t serial_pm_callback(cy_stc_syspm_callback_params_t *p

case CY_SYSPM_AFTER_TRANSITION:
/* Enable the UART to operate */
Cy_SCB_UART_Enable(obj->base);
//Cy_SCB_UART_Enable(obj->base);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well

@@ -26,16 +29,34 @@ void hal_sleep(void)
Cy_SysPm_Sleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
}


#define DEEP_SLEEP_ENTER_TIMEOUT_US 260000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This potentially violates this requirement:

 *   * the wake-up time should be less than 10 ms - Verified by deepsleep_lpticker_test().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this requirement assumes the hardware is in a state ready to enter deep sleep mode when the hal_deepsleep() function is called. But this seems not always to be satisfied and my code tries to implement a workaround. Ideally, HAL API should be able to return an error code when it is not able to enter deep sleep mode as requested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not able to enter deepsleep, it should return immediately

static volatile uint32_t in_progress = 0;

// SysPm API is not re-entrant, so make sure not to enter it multiple times.
if (core_util_atomic_incr_u32(&in_progress, 1) == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hal_deepsleep() does not need to be re-entrant. It's called from a critical section (not doing that yields undefined behaviour as it doesn't protect against early Iinterrupts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, HAL requirements are not well documented in Mbed.
I can remove it, should I?

Copy link
Contributor

@donatieng donatieng Dec 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go further - you must ;)
Agreed that we should review doc

@adbridge
Copy link
Contributor

adbridge commented Dec 7, 2018

@lrusinowicz please take a look at Don's review comments
cc @MarceloSalazar

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 10, 2018

@lrusinowicz will you able to address deep sleep comments today? This is scheduled for rc3 that we would like to finalize today

- fixed feature rename (from DEVICE_LOWPOWERTIMER to DEVICE_LPTICKER) in all missed places
- disabled power manager callback for serial driver
@lrusinowicz
Copy link
Contributor Author

I have edited my commits to address the comments and removed the changes in sleep_API.c. Comments has pointed I went completely wrong with these, so it should be OK now.

@adbridge
Copy link
Contributor

@donatieng could you re-review please?

Copy link
Contributor

@donatieng donatieng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 10, 2018

CI started

@mbed-ci
Copy link

mbed-ci commented Dec 10, 2018

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@cmonr cmonr merged commit f50403a into ARMmbed:master Dec 10, 2018
@cmonr cmonr removed the needs: CI label Dec 10, 2018
@MarceloSalazar
Copy link

FYI @alzix @orenc17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants