|
|
@ -1,5 +1,6 @@ |
|
|
|
#include "chip_helper.hpp"
|
|
|
|
|
|
|
|
#include "sdk\chip\basic\logger.hpp"
|
|
|
|
extern "C" { |
|
|
|
static uint8_t g_port_exit_critical_count; |
|
|
|
|
|
|
@ -285,10 +286,17 @@ uint32_t chip_get_timer_clock_sorce_freq(TIM_HandleTypeDef* tim) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static float zfeq(float val0, float val1, float eps = 0.0001) { |
|
|
|
float dv = val0 - val1; |
|
|
|
if (dv < 0) dv = -dv; |
|
|
|
if (dv < eps) return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool chip_calculate_prescaler_and_autoreload_by_expect_freq(uint32_t timerInClk, float infreqhz, uint32_t* prescaler, uint32_t* autoreload) { |
|
|
|
/**
|
|
|
|
* @brief ¼ÆËã¼Ä´æÆ÷ÊýÖµ |
|
|
|
*/ |
|
|
|
ZEARLY_ASSERT(!zfeq(infreqhz, 0, 0.01)); |
|
|
|
float psc_x_arr = timerInClk / infreqhz; |
|
|
|
uint32_t psc = 0; |
|
|
|
uint32_t arr = 65534; |
|
|
|