64 #if defined(BSPACM_DOXYGEN) || (BSPACM_CORE_TOOLCHAIN_GCC - 0)
65 #define BSPACM_CORE_INLINE __inline__
67 #define BSPACM_CORE_INLINE inline
76 #if defined(BSPACM_DOXYGEN) || (BSPACM_CORE_TOOLCHAIN_GCC - 0)
78 #define BSPACM_CORE_INLINE_FORCED BSPACM_CORE_INLINE __attribute__((__always_inline__))
80 #define BSPACM_CORE_INLINE_FORCED BSPACM_CORE_INLINE
91 #if defined(BSPACM_DOXYGEN) || (BSPACM_CORE_TOOLCHAIN_GCC - 0)
92 #define BSPACM_CORE_PACKED_STRUCT(nm_) struct __attribute__((__packed__)) nm_
104 #if defined(BSPACM_DOXYGEN) || (BSPACM_CORE_TOOLCHAIN_GCC - 0)
105 #define BSPACM_CORE_ALIGNED_OBJECT(sz_) __attribute__((__aligned__(sz_)))
113 #include <bspacm/device.h>
128 #define BSPACM_VERSION 20150113
132 #define BSPACM_CORE_DISABLE_INTERRUPT() __disable_irq()
136 #define BSPACM_CORE_ENABLE_INTERRUPT() __enable_irq()
148 #define BSPACM_CORE_SAVED_INTERRUPT_STATE(var_) unsigned int const var_ = __get_PRIMASK()
154 #define BSPACM_CORE_RESTORE_INTERRUPT_STATE(var_) do { \
156 BSPACM_CORE_DISABLE_INTERRUPT(); \
158 BSPACM_CORE_ENABLE_INTERRUPT(); \
165 #define BSPACM_CORE_REENABLE_INTERRUPT(var_) do { \
166 if (! (1U & var_)) { \
167 BSPACM_CORE_ENABLE_INTERRUPT(); \
171 #if defined(BSPACM_DOXYGEN) || (! defined(BSPACM_CORE_SLEEP))
192 #define BSPACM_CORE_SLEEP() do { \
197 #if defined(BSPACM_DOXYGEN) || (! defined(BSPACM_CORE_DEEP_SLEEP))
226 #define BSPACM_CORE_DEEP_SLEEP() do { \
227 uint32_t in_sleepdeep = (SCB->SCR & SCB_SCR_SLEEPDEEP_Msk); \
228 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; \
230 SCB->SCR &= ~in_sleepdeep; \
236 #if defined(DWT_CTRL_NOCYCCNT_Msk)
237 #define BSPACM_CORE_SUPPORTS_CYCCNT 1
239 #define BSPACM_CORE_SUPPORTS_CYCCNT 0
249 #if (BSPACM_CORE_SUPPORTS_CYCCNT - 0)
250 #define BSPACM_CORE_ENABLE_CYCCNT() do { \
251 if (! (DWT_CTRL_NOCYCCNT_Msk & DWT->CTRL)) { \
252 CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; \
254 DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; \
258 #define BSPACM_CORE_ENABLE_CYCCNT() do { } while (0)
263 #if (BSPACM_CORE_SUPPORTS_CYCCNT - 0)
264 #define BSPACM_CORE_DISABLE_CYCCNT() do { \
265 if (! (DWT_CTRL_NOCYCCNT_Msk & DWT->CTRL)) { \
266 DWT->CTRL &= ~DWT_CTRL_CYCCNTENA_Msk; \
267 CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk; \
271 #define BSPACM_CORE_DISABLE_CYCCNT() do { } while (0)
282 #if (BSPACM_CORE_SUPPORTS_CYCCNT - 0)
283 #define BSPACM_CORE_CYCCNT() DWT->CYCCNT
285 #define BSPACM_CORE_CYCCNT() 0
294 #if (BSPACM_CORE_SUPPORTS_CYCCNT - 0)
295 #define BSPACM_CORE_DELAY_CYCLES(cycles_) do { \
296 uint32_t const delta = (cycles_); \
297 uint32_t const cc0 = DWT->CYCCNT; \
298 while ((DWT->CYCCNT - cc0) < delta) { \
303 #define BSPACM_CORE_DELAY_CYCLES(cycles_) do { \
304 uint32_t const cycles_per_iter = 3; \
305 uint32_t remaining = (cycles_); \
306 while (remaining > cycles_per_iter) { \
307 remaining -= cycles_per_iter; \
315 #if defined(BSPACM_DOXYGEN) || (defined(BSPACM_CORE_SRAM_BASE) && defined(BSPACM_CORE_SRAM_BITBAND_BASE))
317 #define BSPACM_CORE_BITBAND_SRAM_(object_, bit_) (BSPACM_CORE_SRAM_BITBAND_BASE + 4 * ((bit_) + 8 * ((uintptr_t)&(object_) - BSPACM_CORE_SRAM_BASE)))
339 #define BSPACM_CORE_BITBAND_SRAM32(object_, bit_) (*(volatile uint32_t *)BSPACM_CORE_BITBAND_SRAM_(object_, bit_))
344 #define BSPACM_CORE_BITBAND_SRAM16(object_, bit_) (*(volatile uint16_t *)BSPACM_CORE_BITBAND_SRAM_(object_, bit_))
349 #define BSPACM_CORE_BITBAND_SRAM8(object_, bit_) (*(volatile uint8_t *)BSPACM_CORE_BITBAND_SRAM_(object_, bit_))
353 #if defined(BSPACM_DOXYGEN) || (defined(BSPACM_CORE_PERIPH_BASE) && defined(BSPACM_CORE_PERIPH_BITBAND_BASE))
374 #define BSPACM_CORE_BITBAND_PERIPH(object_, bit_) (*(volatile uint32_t *)(BSPACM_CORE_PERIPH_BITBAND_BASE + 4 * ((bit_) + 8 * ((uintptr_t)&(object_) - BSPACM_CORE_PERIPH_BASE))))
397 }
else if (0x2U == mask) {
399 }
else if (0x4U == mask) {
401 }
else if (0x8U == mask) {
403 }
else if (0x10U == mask) {
405 }
else if (0x20U == mask) {
407 }
else if (0x40U == mask) {
409 }
else if (0x80U == mask) {
411 }
else if (0x100U == mask) {
413 }
else if (0x200U == mask) {
415 }
else if (0x400U == mask) {
417 }
else if (0x800U == mask) {
419 }
else if (0x1000U == mask) {
421 }
else if (0x2000U == mask) {
423 }
else if (0x4000U == mask) {
425 }
else if (0x8000U == mask) {
427 }
else if (0x10000U == mask) {
429 }
else if (0x20000U == mask) {
431 }
else if (0x40000U == mask) {
433 }
else if (0x80000U == mask) {
435 }
else if (0x100000U == mask) {
437 }
else if (0x200000U == mask) {
439 }
else if (0x400000U == mask) {
441 }
else if (0x800000U == mask) {
443 }
else if (0x1000000U == mask) {
445 }
else if (0x2000000U == mask) {
447 }
else if (0x4000000U == mask) {
449 }
else if (0x8000000U == mask) {
451 }
else if (0x10000000U == mask) {
453 }
else if (0x20000000U == mask) {
455 }
else if (0x40000000U == mask) {
457 }
else if (0x80000000U != mask) {
483 volatile uint32_t *
const wordp = basep + (pin / 8);
484 const unsigned int shift = 4 * (pin % 8);
485 *wordp = (*wordp & ~(0x0F << shift)) | ((0x0F & value) << shift);
Application/board-specific header.
static BSPACM_CORE_INLINE void vBSPACMcoreSetPinNybble(volatile uint32_t *basep, unsigned int pin, unsigned int value)
Definition: core.h:479
#define BSPACM_CORE_INLINE
Definition: core.h:65
static BSPACM_CORE_INLINE unsigned int uiBSPACMcoreBitFromMask(uint32_t mask)
Definition: core.h:393