perf_counter/example/platform.c

73 lines
2.5 KiB
C
Raw Normal View History

2021-01-09 13:18:39 +00:00
/****************************************************************************
* Copyright 2021 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
* *
* 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. *
* *
****************************************************************************/
2021-01-09 13:10:37 +00:00
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
2021-07-19 23:55:51 +01:00
#include "perf_counter.h"
#include "ARMCM0.h" // Keil::Board Support:V2M-MPS2:Common
2021-01-09 13:10:37 +00:00
#include <assert.h>
2023-03-19 23:08:08 +00:00
#include <RTE_Components.h>
#if defined(RTE_Compiler_EventRecorder)
# include <EventRecorder.h>
#endif
2021-01-09 13:10:37 +00:00
extern
void uart_config(uint32_t wUARTFrequency);
__attribute__((weak))
void systimer_1ms_handler(void)
{
//assert(false);
}
static volatile uint32_t s_wMSCounter = 0;
/*----------------------------------------------------------------------------
SysTick / Timer0 IRQ Handler
*----------------------------------------------------------------------------*/
2022-06-13 20:29:20 -04:00
void SysTick_Handler (void)
2021-01-09 13:10:37 +00:00
{
if (s_wMSCounter) {
s_wMSCounter--;
}
systimer_1ms_handler();
}
/*! \brief initialise platform before main()
*/
__attribute__((constructor(101)))
void platform_init(void)
{
SystemCoreClockUpdate();
2023-03-19 23:08:08 +00:00
#if defined(RTE_Compiler_IO_STDOUT) && defined(RTE_Compiler_IO_STDOUT_User)
2021-01-09 13:10:37 +00:00
uart_config(25000000ul);
2023-03-19 23:08:08 +00:00
#endif
2022-06-13 20:29:20 -04:00
2021-01-09 13:10:37 +00:00
/* Generate interrupt each 1 ms */
2022-06-13 20:29:20 -04:00
SysTick_Config(SystemCoreClock / 1000);
2023-03-19 23:08:08 +00:00
#if defined(RTE_Compiler_EventRecorder) && defined(RTE_Compiler_IO_STDOUT_EVR)
EventRecorderInitialize(0,1);
#endif
2021-01-09 13:10:37 +00:00
}