change(lp_core): changed wakeup time calc to use a precomputed tick value

Previously we would calculate the wakeup ticks upon every wakeup using the lp-timer clock frequency,
but this caused the binary to pull in software division functions, increasing the binary size.

This value is now precalculated by the hp-core when we configure the ULP. This saves about 1k bytes.
This commit is contained in:
Marius Vikhammer
2024-07-19 15:24:22 +08:00
parent 692eb01fe1
commit b825aa9f95
6 changed files with 42 additions and 6 deletions

View File

@@ -31,6 +31,27 @@ uint64_t ulp_lp_core_lp_timer_get_cycle_count(void);
*/
void ulp_lp_core_lp_timer_set_wakeup_time(uint64_t sleep_duration_us);
/**
* @brief Set the next wakeup alarm in LP timer ticks
*
* @note This only sets the alarm for a single wakeup. For periodic wakeups you will
* have to call this function again after each wakeup to configure the next time.
*
* @note If ulp_lp_core_cfg_t.lp_timer_sleep_duration_us is set the ulp will automatically set
* the next wakeup time after returning from main and override this value.
*
* @param sleep_duration_ticks
*/
void ulp_lp_core_lp_timer_set_wakeup_ticks(uint64_t sleep_duration_ticks);
/**
* @brief Converts from sleep duration in microseconds to LP timer ticks
*
* @param sleep_duration_us Sleep duration in microseconds
* @return uint64_t Number of LP timer ticks to sleep for
*/
uint64_t ulp_lp_core_lp_timer_calculate_sleep_ticks(uint64_t sleep_duration_us);
/**
* @brief Disables the lp timer alarm and clears any pending alarm interrupts
*

View File

@@ -12,7 +12,8 @@ extern "C" {
#endif
typedef struct {
uint64_t sleep_duration_us; /* Configured sleep duration for periodic wakeup, if set the ulp will automatically schedule the next wakeup */
uint64_t sleep_duration_us; /* Configured sleep duration for periodic wakeup, if set the ulp will automatically schedule the next wakeup */
uint64_t sleep_duration_ticks; /* Configured sleep duration, in LP-timer clock ticks, if set it allows us to skip doing integer division when configuring the timer */
} ulp_lp_core_memory_shared_cfg_t;
/**