Skip to content

Commit

Permalink
Added GetStackPointer function to CoreN2G
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Nov 3, 2021
1 parent 376859a commit ab6995a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/AnalogIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace LegacyAnalogIn
AnalogCallback_t AnalogInSetCallback(AnalogCallback_t) noexcept;

// Start converting the enabled channels, to include the specified ones. Disabled channels are ignored.
void AnalogInStartConversion(uint32_t channels = 0xFFFFFFFF) noexcept;
void AnalogInStartConversion(uint32_t channels = 0xFFFFFFFFu) noexcept;

// Finalise a conversion
#if SAME70
Expand All @@ -116,7 +116,7 @@ namespace LegacyAnalogIn

// Check whether all conversions of the specified channels have been completed since the last call to AnalogStartConversion.
// Disabled channels are ignored
bool AnalogInCheckReady(uint32_t channels = 0xFFFFFFFF) noexcept;
bool AnalogInCheckReady(uint32_t channels = 0xFFFFFFFFu) noexcept;

// Convert a pin number to an AnalogIn channel
extern AnalogChannelNumber PinToAdcChannel(uint32_t pin) noexcept;
Expand Down
15 changes: 15 additions & 0 deletions src/CoreIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ inline void memcpyf(float *dst, const float *src, size_t numFloats) noexcept
memcpyu32(reinterpret_cast<uint32_t*>(dst), reinterpret_cast<const uint32_t*>(src), numFloats);
}

// Get the stack pointer
#ifdef __ECV__

// eCv doesn't accept the GCC syntax used to get the stack pointer, so leave it undefined
extern const uint32_t *_ecv_array GetStackPointer() noexcept;

#else

static inline const uint32_t *_ecv_array GetStackPointer() noexcept
{
register const uint32_t * stack_ptr asm ("sp");
return stack_ptr;
}

#endif

// Atomic section locker, alternative to InterruptCriticalSectionLocker (is safe to call from within an ISR, and may be faster)
/**
Expand Down

0 comments on commit ab6995a

Please sign in to comment.