~aleteoryx/muditaos

ref: b3f228878dcebeb519d2206c9d333091abe650d0 muditaos/module-os/board/rt1051/fsl_runtimestat_gpt.c -rw-r--r-- 990 bytes
b3f22887 — GravisZro [EGD-7254] Fix submodule update script 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "fsl_gpt.h"

static inline GPT_Type *vPortGetGptBase(void)
{
    return GPT1;
}

void vConfigureTimerForRunTimeStats(void)
{
	const gpt_config_t GPT1_config = {
	  .clockSource = kGPT_ClockSource_Periph,
	  // freq = (f_Osc / divider) -> (24 MHz / 2400) = 10 kHz
	  .divider = 2400UL,
	  .enableFreeRun = false,
	  .enableRunInWait = true,
	  .enableRunInStop = true,
	  .enableRunInDoze = false,
	  .enableRunInDbg = false,
	  .enableMode = true
	};

	GPT_Type *pxGptBase = vPortGetGptBase();

	/* GPT device and channels initialization */
	GPT_Init(pxGptBase, &GPT1_config);
	GPT_SetOscClockDivider(pxGptBase, 1);
	/* Enable GPT interrupt sources */
	GPT_EnableInterrupts(pxGptBase, 0);
	/* Start the GPT timer */
	GPT_StartTimer(pxGptBase);
}

uint32_t ulHighFrequencyTimerTicks(void)
{
	return GPT_GetCurrentTimerCount(vPortGetGptBase());
}