Skip to content

Commit

Permalink
add perf_counter
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Mar 24, 2021
1 parent ed90b5b commit 247c65c
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "sources/gmsi/utilities/3rd-party/PLOOC"]
path = sources/gmsi/utilities/3rd-party/PLOOC
url = https://github.com/GorgonMeducer/PLOOC.git
[submodule "sources/gmsi/arch/arm/cortex-m/perf_counter"]
path = sources/gmsi/arch/arm/cortex-m/perf_counter
url = https://github.com/GorgonMeducer/perf_counter
28 changes: 0 additions & 28 deletions example/app_platform/app_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ FILEHANDLE $Sub$$_sys_open(const char *name, int openmode)
*/
void app_platform_1ms_event_handler(void)
{
counter_overflow();
STREAM_IN_1ms_event_handler();
}

Expand All @@ -88,32 +87,5 @@ void app_platform_init( void )

NVIC_SystemReset();
}

volatile static int32_t s_nCycleCounts = 0;

/*! \brief start performance counter (cycle accurate)
*/
void start_counter(void)
{
__IRQ_SAFE {
s_nCycleCounts = (int32_t)SysTick->VAL - (int32_t)SysTick->LOAD;
}
}

static ALWAYS_INLINE void counter_overflow(void)
{
s_nCycleCounts += SysTick->LOAD;
}

/*! \brief stop performance counter (cycle accurate)
*! \retval cycle elapsed.
*/
int32_t stop_counter(void)
{
__IRQ_SAFE {
s_nCycleCounts += (int32_t)SysTick->LOAD - (int32_t)SysTick->VAL;
}
return s_nCycleCounts;
}

/* EOF */
48 changes: 36 additions & 12 deletions example/build/mdk/Blinky.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@

<Group>
<GroupName>gmsi</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\sources\gmsi\utilities\arm\signal.c</PathWithFileName>
Expand Down Expand Up @@ -872,17 +872,41 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>53</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\sources\gmsi\arch\arm\cortex-m\arch_cortex-m.c</PathWithFileName>
<FilenameWithoutPath>arch_cortex-m.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>54</FileNumber>
<FileType>4</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\sources\gmsi\arch\arm\cortex-m\perf_counter\lib\perf_counter.lib</PathWithFileName>
<FilenameWithoutPath>perf_counter.lib</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>

<Group>
<GroupName>app_platform</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>53</FileNumber>
<FileNumber>55</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -894,7 +918,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>54</FileNumber>
<FileNumber>56</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -906,7 +930,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>55</FileNumber>
<FileNumber>57</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -918,7 +942,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>56</FileNumber>
<FileNumber>58</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -938,7 +962,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>57</FileNumber>
<FileNumber>59</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -950,7 +974,7 @@
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>58</FileNumber>
<FileNumber>60</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -962,7 +986,7 @@
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>59</FileNumber>
<FileNumber>61</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -974,7 +998,7 @@
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>60</FileNumber>
<FileNumber>62</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -986,7 +1010,7 @@
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>61</FileNumber>
<FileNumber>63</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand Down
10 changes: 10 additions & 0 deletions example/build/mdk/Blinky.uvprojx
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,16 @@
<FileType>1</FileType>
<FilePath>..\..\..\sources\gmsi\utilities\delegate.c</FilePath>
</File>
<File>
<FileName>arch_cortex-m.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\sources\gmsi\arch\arm\cortex-m\arch_cortex-m.c</FilePath>
</File>
<File>
<FileName>perf_counter.lib</FileName>
<FileType>4</FileType>
<FilePath>..\..\..\sources\gmsi\arch\arm\cortex-m\perf_counter\lib\perf_counter.lib</FilePath>
</File>
</Files>
</Group>
<Group>
Expand Down
9 changes: 9 additions & 0 deletions example/build/mdk/EventRecorderStub.scvd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">

<component name="EventRecorderStub" version="1.0.0"/> <!--name and version of the component-->
<events>
</events>

</component_viewer>
35 changes: 35 additions & 0 deletions sources/gmsi/arch/app_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/****************************************************************************
* Copyright 2021 Gorgon Meducer (Email:[email protected]) *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/


//! \note do not move this pre-processor statement to other places
#include "..\app_cfg.h"

#ifndef __ARCH_APP_CFG_H__
#define __ARCH_APP_CFG_H__

/*============================ INCLUDES ======================================*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/


#endif
/* EOF */
44 changes: 44 additions & 0 deletions sources/gmsi/arch/arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/****************************************************************************
* Copyright 2021 Gorgon Meducer (Email:[email protected]) *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

#ifndef __ARCH_H__
#define __ARCH_H__

/*============================ INCLUDES ======================================*/
#include ".\app_cfg.h"

#ifndef __GMSI_ARCH_HEADER
# error no specified architecture
#endif

#include __GMSI_ARCH_HEADER

/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
/*! \note initialize architecture
* \param none
* \retval true initialization succeeded.
* \retval false initialization failed
*/
extern bool arch_init( void );

#endif
/* EOF */
35 changes: 35 additions & 0 deletions sources/gmsi/arch/arm/app_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/****************************************************************************
* Copyright 2021 Gorgon Meducer (Email:[email protected]) *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/


//! \note do not move this pre-processor statement to other places
#include "..\app_cfg.h"

#ifndef __ARCH_ARM_APP_CFG_H__
#define __ARCH_ARM_APP_CFG_H__

/*============================ INCLUDES ======================================*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/


#endif
/* EOF */
35 changes: 35 additions & 0 deletions sources/gmsi/arch/arm/cortex-m/app_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/****************************************************************************
* Copyright 2021 Gorgon Meducer (Email:[email protected]) *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/


//! \note do not move this pre-processor statement to other places
#include "..\app_cfg.h"

#ifndef __ARCH_CORTEX_M_APP_CFG_H__
#define __ARCH_CORTEX_M_APP_CFG_H__

/*============================ INCLUDES ======================================*/
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/


#endif
/* EOF */
Loading

0 comments on commit 247c65c

Please sign in to comment.