Skip to content

Instantly share code, notes, and snippets.

@good5dog5
Created March 28, 2015 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save good5dog5/ed0854613a2c4042ea21 to your computer and use it in GitHub Desktop.
Save good5dog5/ed0854613a2c4042ea21 to your computer and use it in GitHub Desktop.
// main.c +13
// define memory location of NVIC
#define NVIC_INTERRUPTx_PRIORITY ( ( volatile unsigned char *) 0xE000E400 )
// +317
int get_interrupt_priority(int interrupt)
{
if (interrupt < 240) // ARM 有 240 種 external interrupt(0~239) 和16種inernal interrupt
/* 根據 interrupt 設定 priority,這個常數宣告為 char*,故等同 array */
return NVIC_INTERRUPTx_PRIORITY[interrupt];
return -1;
}
// +296
unsigned int get_reload()
{
return *(uint32_t *) 0xE000E014; // access SysTick Register of Reload Value
}
// +301
unsigned int get_current()
{
return *(uint32_t *) 0xE000E018; // access SysTick Register of Current Value
}
// +306
unsigned int get_time()
{
static unsigned int const *reload = (void *) 0xE000E014;
static unsigned int const *current = (void *) 0xE000E018;
static const unsigned int scale = 1000000 / configTICK_RATE_HZ;
/* microsecond */
return xTaskGetTickCount() * scale + (*reload - *current) / (*reload / scale);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment