A typical example for using the CMSIS layer is provided below. The example is based on an unspecific Cortex-A9 Device.
#include <ARMCA9.h>
static const uint32_t TICK_RATE_HZ = 1000U;
uint32_t volatile msTicks;
static void SysTick_Handler( void )
{
msTicks++;
}
void private_timer_init(void) {
PTIM_SetControl (PTIM_GetControl() | 7U);
IRQ_SetHandler((IRQn_ID_t)PrivTimer_IRQn, SysTick_Handler);
IRQ_SetPriority ((IRQn_ID_t)PrivTimer_IRQn, IRQ_PRIORITY_Msk);
IRQ_SetPriority ((IRQn_ID_t)PrivTimer_IRQn, GIC_GetPriority((IRQn_ID_t)PrivTimer_IRQn)-1);
IRQ_Enable ((IRQn_ID_t)PrivTimer_IRQn);
}
void Delay(uint32_t ticks) {
uint32_t tgtTicks = msTicks + ticks;
while (msTicks == tgtTicks) {
__WFE ();
}
}
int main(void)
{
private_timer_init();
static uint8_t ledState = 0;
while (1)
{
ledState = !ledState;
Delay(500);
}
}
uint32_t SystemCoreClock
Variable to hold the system core clock value.
Definition: Ref_SystemAndClock.txt:67
CMSIS-Pack provides the #define CMSIS_header_file in RTE_Components.h which gives you access to the device.h file of a project. This allows you to generate generic software components that use the device selected in a project.
#include "RTE_Components.h"
#include CMSIS_device_header