Skip to content
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

STM32U5 HAL update, NUCLEO_U575ZI upload method file #184

Merged
merged 3 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hal/tests/TESTS/mbed_hal/sleep/sleep_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ bool compare_timestamps(unsigned int delta_ticks, unsigned int ticker_width, uns
return false;
}
} else {
if ((actual >= lower_bound && actual <= counter_mask) || (actual >= 0 && actual <= upper_bound)) {
if ((actual >= lower_bound && actual <= counter_mask) || (actual <= upper_bound)) {
return true;
} else {
return false;
Expand Down
52 changes: 28 additions & 24 deletions hal/tests/TESTS/mbed_hal/sleep_manager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "unity/unity.h"
#include "greentea-client/test_env.h"
#include <limits.h>
#include <cinttypes>
#include "mbed.h"
#include "mbed_lp_ticker_wrapper.h"
#include "hal/us_ticker_api.h"
Expand All @@ -31,6 +32,8 @@
#define SLEEP_DURATION_US 50000ULL

// Tolerance for extra sleep time in the deep sleep test.
// This accounts for the time that the processor spends going to sleep and waking up.
// The hal_deepsleep() docs specify this to be less than 10ms
// Current leader is the MIMXRT105x, which takes almost 5ms to enter/exit deep sleep.
#define DEEP_SLEEP_TOLERANCE_US 5000ULL

Expand Down Expand Up @@ -147,7 +150,7 @@ void test_sleep_auto()
const ticker_info_t *lp_ticker_info = get_lp_ticker_data()->interface->get_info();
const unsigned lp_ticker_mask = ((1 << lp_ticker_info->bits) - 1);
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr);
uint32_t us_ts1, us_ts2, lp_ts1, lp_ts2, us_diff1, us_diff2, lp_diff1, lp_diff2;
uint32_t us_diff1, us_diff2, lp_diff1, lp_diff2;

const unsigned int sleep_duration_lp_ticks = us_to_ticks(SLEEP_DURATION_US, lp_ticker_info->frequency);
const unsigned int sleep_duration_us_ticks = us_to_ticks(SLEEP_DURATION_US, us_ticker_info->frequency);
Expand All @@ -156,28 +159,28 @@ void test_sleep_auto()
// interrupts on some targets, which wake us from sleep.
busy_wait_ms(SERIAL_FLUSH_TIME_MS);

/* Some targets may need an interrupt short time after LPTIM interrupt is
* set and forbid deep_sleep during that period. Let this period pass */
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());

sleep_manager_lock_deep_sleep();

/* Let's avoid the Lp ticker wrap-around case */
wraparound_lp_protect();
uint32_t lp_wakeup_ts_raw = lp_ticker_read() + sleep_duration_lp_ticks;

uint32_t start_lp_time = lp_ticker_read();
uint32_t start_us_time = us_ticker_read();
uint32_t lp_wakeup_ts_raw = start_lp_time + sleep_duration_lp_ticks;
timestamp_t lp_wakeup_ts = overflow_protect(lp_wakeup_ts_raw, lp_ticker_info->bits);
lp_ticker_set_interrupt(lp_wakeup_ts);

us_ts1 = us_ticker_read();
lp_ts1 = lp_ticker_read();
/* Some targets may need an interrupt short time after LPTIM interrupt is
* set and forbid deep_sleep during that period. Let this period pass */
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());

sleep_manager_lock_deep_sleep();

sleep_manager_sleep_auto();

us_ts2 = us_ticker_read();
lp_ts2 = lp_ticker_read();
uint32_t end_us_time = us_ticker_read();
uint32_t end_lp_time = lp_ticker_read();

us_diff1 = (us_ts1 <= us_ts2) ? (us_ts2 - us_ts1) : (us_ticker_mask - us_ts1 + us_ts2 + 1);
lp_diff1 = (lp_ts1 <= lp_ts2) ? (lp_ts2 - lp_ts1) : (lp_ticker_mask - lp_ts1 + lp_ts2 + 1);
us_diff1 = (start_us_time <= end_us_time) ? (end_us_time - start_us_time) : (us_ticker_mask - start_us_time + end_us_time + 1);
lp_diff1 = (start_lp_time <= end_lp_time) ? (end_lp_time - start_lp_time) : (lp_ticker_mask - start_lp_time + end_lp_time + 1);

// Deep sleep locked -- ordinary sleep mode used:
// * us_ticker powered ON,
Expand All @@ -189,30 +192,30 @@ void test_sleep_auto()
TEST_ASSERT_UINT64_WITHIN_MESSAGE(sleep_duration_us_ticks / 10ULL, sleep_duration_us_ticks, us_diff1, "us ticker sleep time incorrect - perhaps deep sleep mode was used?");

sleep_manager_unlock_deep_sleep();
/* Some targets may need an interrupt short time after LPTIM interrupt is
* set and forbid deep_sleep during that period. Let this period pass */
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());

// Wait for hardware serial buffers to flush. This is because serial transmissions generate
// interrupts on some targets, which wake us from sleep.
busy_wait_ms(SERIAL_FLUSH_TIME_MS);

/* Let's avoid the Lp ticker wrap-around case */
wraparound_lp_protect();
lp_wakeup_ts_raw = lp_ticker_read() + us_to_ticks(SLEEP_DURATION_US, lp_ticker_info->frequency);
start_lp_time = lp_ticker_read();
start_us_time = us_ticker_read();
lp_wakeup_ts_raw = start_lp_time + us_to_ticks(SLEEP_DURATION_US, lp_ticker_info->frequency);
lp_wakeup_ts = overflow_protect(lp_wakeup_ts_raw, lp_ticker_info->bits);
lp_ticker_set_interrupt(lp_wakeup_ts);

us_ts1 = us_ticker_read();
lp_ts1 = lp_ticker_read();
/* Some targets may need an interrupt short time after LPTIM interrupt is
* set and forbid deep_sleep during that period. Let this period pass */
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep_test_check());

sleep_manager_sleep_auto();

us_ts2 = us_ticker_read();
lp_ts2 = lp_ticker_read();
end_us_time = us_ticker_read();
end_lp_time = lp_ticker_read();

us_diff2 = (us_ts1 <= us_ts2) ? (us_ts2 - us_ts1) : (us_ticker_mask - us_ts1 + us_ts2 + 1);
lp_diff2 = (lp_ts1 <= lp_ts2) ? (lp_ts2 - lp_ts1) : (lp_ticker_mask - lp_ts1 + lp_ts2 + 1);
us_diff2 = (start_us_time <= end_us_time) ? (end_us_time - start_us_time) : (us_ticker_mask - start_us_time + end_us_time + 1);
lp_diff2 = (start_lp_time <= end_lp_time) ? (end_lp_time - start_lp_time) : (lp_ticker_mask - start_lp_time + end_lp_time + 1);

// Deep sleep unlocked -- deep sleep mode used:
// * us_ticker powered OFF,
Expand All @@ -225,6 +228,7 @@ void test_sleep_auto()
const unsigned int deepsleep_tolerance_lp_ticks = us_to_ticks(DEEP_SLEEP_TOLERANCE_US, lp_ticker_info->frequency);
const unsigned int deepsleep_tolerance_us_ticks = us_to_ticks(DEEP_SLEEP_TOLERANCE_US, us_ticker_info->frequency);


// us ticker should not have incremented during deep sleep. It should be zero, plus some tolerance for the time to enter deep sleep.
TEST_ASSERT_UINT64_WITHIN_MESSAGE(deepsleep_tolerance_us_ticks, 0, us_diff2, "us ticker sleep time incorrect - perhaps deep sleep mode was not used?");
TEST_ASSERT_UINT64_WITHIN_MESSAGE(deepsleep_tolerance_lp_ticks, sleep_duration_lp_ticks, lp_diff2, "lp ticker sleep time incorrect");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This software component is provided to you as part of a software package and
applicable license terms are in the Package_license file. If you received this
software component outside of a package or without applicable license terms,
the terms of the Apache-2.0 license shall apply.
You may obtain a copy of the Apache-2.0 at:
https://opensource.org/licenses/Apache-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
******************************************************************************
* @file partition_stm32u5xx.h
* @author MCD Application Team
* @brief CMSIS STM32U5xx Device Header File for Initial Setup for
* Secure / Non-Secure Zones based on CMSIS CORE V5.4.0
*
* The file is included in system_stm32u5xx_s.c in secure application.
* It includes the configuration section that allows to select the
* STM32U5xx device partitioning file for system core secure attributes
* and interrupt secure and non-secure assignment.
*
******************************************************************************
* @attention
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/

/** @addtogroup CMSIS
* @{
*/

/** @addtogroup stm32u5xx
* @{
*/

#ifndef PARTITION_STM32U5XX_H
#define PARTITION_STM32U5XX_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/** @addtogroup Secure_configuration_section
* @{
*/

#if defined(STM32U575xx)
#include "partition_stm32u575xx.h"
#elif defined(STM32U585xx)
#include "partition_stm32u585xx.h"
#elif defined(STM32U595xx)
#include "partition_stm32u595xx.h"
#elif defined(STM32U5A5xx)
#include "partition_stm32u5a5xx.h"
#elif defined(STM32U599xx)
#include "partition_stm32u599xx.h"
#elif defined(STM32U5A9xx)
#include "partition_stm32u5a9xx.h"
#elif defined(STM32U535xx)
#include "partition_stm32u535xx.h"
#elif defined(STM32U545xx)
#include "partition_stm32u545xx.h"
#else
#error "Please select first the target STM32U5xx device used in your application (in stm32u5xx.h file)"
#endif

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* PARTITION_STM32U5XX_H */
/**
* @}
*/

/**
* @}
*/




Loading
Loading