#include "delay_us.h"
delay_us(n_us)
{
uint32_t load_ms, load_us, n_us_tick, a_tick, end_tick, now_tick;
load_ms=systick->LOAD;
load_us=systick->LOAD/1000;
n_us_tick=n_us*load_us;
a_tick=systick->VAL;
if(a_tick>=n_us_tick)
{
end_tick=a_tick-n_us_tick;
do
{
now_tick=systick->VAL;
}while (now_tick }
else
{
end_tick=load_ms-n_us_tick+a_tick;
do
{
now_tick=systick->VAL;
}while ((now_tick>n_us_tick)&&(now_tick }
} |