move get_core_num() into platform.h (#852)

This commit is contained in:
Graham Sanderson 2022-06-06 08:20:00 -05:00 committed by GitHub
parent 4e4cf11d9b
commit f3c446ae14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 11 deletions

View File

@ -86,8 +86,6 @@ bool is_spin_locked(const spin_lock_t *lock);
void spin_unlock(spin_lock_t *lock, uint32_t saved_irq); void spin_unlock(spin_lock_t *lock, uint32_t saved_irq);
uint get_core_num();
spin_lock_t *spin_lock_init(uint lock_num); spin_lock_t *spin_lock_init(uint lock_num);
void clear_spin_locks(void); void clear_spin_locks(void);

View File

@ -139,6 +139,9 @@ static inline int32_t __mul_instruction(int32_t a,int32_t b)
static inline void __compiler_memory_barrier(void) { static inline void __compiler_memory_barrier(void) {
} }
uint get_core_num();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -304,15 +304,6 @@ __force_inline static void spin_unlock(spin_lock_t *lock, uint32_t saved_irq) {
restore_interrupts(saved_irq); restore_interrupts(saved_irq);
} }
/*! \brief Get the current core number
* \ingroup hardware_sync
*
* \return The core number the call was made from
*/
__force_inline static uint get_core_num(void) {
return (*(uint32_t *) (SIO_BASE + SIO_CPUID_OFFSET));
}
/*! \brief Initialise a spin lock /*! \brief Initialise a spin lock
* \ingroup hardware_sync * \ingroup hardware_sync
* *

View File

@ -17,6 +17,8 @@
*/ */
#include "hardware/platform_defs.h" #include "hardware/platform_defs.h"
#include "hardware/regs/addressmap.h"
#include "hardware/regs/sio.h"
// Marker for builds targeting the RP2040 // Marker for builds targeting the RP2040
#define PICO_RP2040 1 #define PICO_RP2040 1
@ -423,6 +425,15 @@ static inline void busy_wait_at_least_cycles(uint32_t minimum_cycles) {
); );
} }
/*! \brief Get the current core number
* \ingroup pico_platform
*
* \return The core number the call was made from
*/
__force_inline static uint get_core_num(void) {
return (*(uint32_t *) (SIO_BASE + SIO_CPUID_OFFSET));
}
#else // __ASSEMBLER__ #else // __ASSEMBLER__
#define WRAPPER_FUNC_NAME(x) __wrap_##x #define WRAPPER_FUNC_NAME(x) __wrap_##x