2022-01-18 00:58:54 +08:00

71 lines
2.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*********************************************************************************************************************
* COPYRIGHT NOTICE
* Copyright (c) 2020,<2C><><EFBFBD>ɿƼ<C9BF>
* All rights reserved.
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<51><C8BA><EFBFBD><EFBFBD>Ⱥ<EFBFBD><C8BA>824575535
*
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>;<EFBFBD><CDBE>
* <20><>ӭ<EFBFBD><D3AD>λʹ<CEBB>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC>İ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @file stm_systick
* @company <09>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD>޹<EFBFBD>˾
* @author <09><><EFBFBD>ɿƼ<C9BF>(QQ3184284598)
* @version <09>鿴doc<6F><63>version<6F>ļ<EFBFBD> <20>汾˵<E6B1BE><CBB5>
* @Software ADS v1.2.2
* @Target core TC264D
* @Taobao https://seekfree.taobao.com/
* @date 2020-3-23
********************************************************************************************************************/
#include "IfxStm.h"
#include "IFXSTM_CFG.h"
#include "zf_stm_systick.h"
static uint32 systick_count[2];
//-------------------------------------------------------------------------------------------------------------------
// @brief systick<63><6B>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
// @param time <20><>Ҫ<EFBFBD><D2AA>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1>
// @return void
// Sample usage: <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>û<EFBFBD><C3BB><EFBFBD>ʹ<EFBFBD><CAB9>h<EFBFBD>ļ<EFBFBD><C4BC>еĺ궨<C4BA><EAB6A8>
//-------------------------------------------------------------------------------------------------------------------
void systick_delay(STMN_enum stmn, uint32 time)
{
uint32 stm_clk;
stm_clk = IfxStm_getFrequency(IfxStm_getAddress((IfxStm_Index)stmn));
IfxStm_waitTicks(IfxStm_getAddress((IfxStm_Index)stmn), (uint32)((uint64)stm_clk*time/1000000000));
}
//-------------------------------------------------------------------------------------------------------------------
// @brief systick<63><6B>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param stmn ѡ<><D1A1>ʹ<EFBFBD>õ<EFBFBD>ģ<EFBFBD><C4A3>
// @return void
// Sample usage: systick_start(STM0);//<2F><>¼<EFBFBD>µ<EFBFBD>ǰ<EFBFBD><C7B0>ʱ<EFBFBD><CAB1>
//-------------------------------------------------------------------------------------------------------------------
void systick_start(STMN_enum stmn)
{
systick_count[stmn] = IfxStm_getLower(IfxStm_getAddress((IfxStm_Index)stmn));
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20><><EFBFBD>õ<EFBFBD>ǰSystem tick timer<65><72>ֵ
// @param stmn ѡ<><D1A1>ʹ<EFBFBD>õ<EFBFBD>ģ<EFBFBD><C4A3>
// @return uint32 <09><><EFBFBD>شӿ<D8B4>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ʱ<EFBFBD><CAB1>(<28><>λ10ns)
// Sample usage: uint32 tim = systick_getval(STM0);
//-------------------------------------------------------------------------------------------------------------------
uint32 systick_getval(STMN_enum stmn)
{
uint32 time;
uint32 stm_clk;
stm_clk = IfxStm_getFrequency(IfxStm_getAddress((IfxStm_Index)stmn));
time = IfxStm_getLower(IfxStm_getAddress((IfxStm_Index)stmn)) - systick_count[stmn];
time = (uint32)((uint64)time * 100000000 / stm_clk);
return time;
}