CMSIS-Core (Cortex-A): Basic CMSIS Example

| CMSIS-Core (Cortex-A) Version 1.1.4 CMSIS-Core support for Cortex-A processor-based devices

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Basic CMSIS Example

A typical example for using the CMSIS layer is provided below. The example is based on an unspecific Cortex-A9 Device.

#include <ARMCA9.h> // File name depends on device used
static const uint32_t TICK_RATE_HZ = 1000U;
uint32_t volatile msTicks; // Counter for millisecond Interval
static void SysTick_Handler( void )
{
msTicks++; // Increment Counter
}
// We use the Private Tiemer (PTIM) of the Cortex-A9 FVP Model here.
// In general the available Timers are highly vendor specific for Cortex-A processors.
void private_timer_init(void) {
PTIM_SetLoadValue ((SystemCoreClock/TICK_RATE_HZ) - 1U);
PTIM_SetControl (PTIM_GetControl() | 7U);
/* Install SysTick_Handler as the interrupt function for PTIM */
IRQ_SetHandler((IRQn_ID_t)PrivTimer_IRQn, SysTick_Handler);
/* Determine number of implemented priority bits */
IRQ_SetPriority ((IRQn_ID_t)PrivTimer_IRQn, IRQ_PRIORITY_Msk);
/* Set lowest priority -1 */
IRQ_SetPriority ((IRQn_ID_t)PrivTimer_IRQn, GIC_GetPriority((IRQn_ID_t)PrivTimer_IRQn)-1);
/* Enable IRQ */
IRQ_Enable ((IRQn_ID_t)PrivTimer_IRQn);
}
/* Delay execution for given amount of ticks */
void Delay(uint32_t ticks) {
uint32_t tgtTicks = msTicks + ticks; // target tick count to delay execution to
while (msTicks == tgtTicks) {
__WFE (); // Power-Down until next Event/Interrupt
}
}
/* main function */
int main(void)
{
/* Initialize device HAL here */
private_timer_init();
static uint8_t ledState = 0;
/* Infinite loop */
while (1)
{
/* Add application code here */
ledState = !ledState;
Delay(500);
}
}

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 information about project configuration
#include CMSIS_device_header // include <device>.h file