GEX core repository.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gex-core/utils/cortex_utils.h

31 lines
572 B

7 years ago
//
// Created by MightyPork on 2017/11/26.
//
// Cortex-M utilities (low level stuff missing from CMSIS)
//
7 years ago
#ifndef GEX_CORTEX_UTILS_H
#define GEX_CORTEX_UTILS_H
#include "platform.h"
static inline bool inIRQ(void)
{
return __get_IPSR() != 0;
}
/** Tight asm loop */
#define __asm_loop(cycles) \
do { \
7 years ago
register uint32_t _count asm ("r4") = cycles; \
asm volatile( \
".syntax unified\n" \
".thumb\n" \
"0:" \
7 years ago
"subs %0, #1\n" \
"bne 0b\n" \
7 years ago
: "+r" (_count)); \
} while(0)
7 years ago
#endif //GEX_CORTEX_UTILS_H