mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
71 lines
2.7 KiB
C
71 lines
2.7 KiB
C
|
/*********************************************************************************************************************
|
|||
|
* COPYRIGHT NOTICE
|
|||
|
* Copyright (c) 2020,<EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>
|
|||
|
* All rights reserved.
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD>824575535
|
|||
|
*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD>λʹ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>뱣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD>İ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @file stm_systick
|
|||
|
* @company <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾
|
|||
|
* @author <EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>(QQ3184284598)
|
|||
|
* @version <EFBFBD>鿴doc<EFBFBD><EFBFBD>version<EFBFBD>ļ<EFBFBD> <EFBFBD>汾˵<EFBFBD><EFBFBD>
|
|||
|
* @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;
|
|||
|
}
|