Skip to content

Commit

Permalink
added rv32 implementation for get lock
Browse files Browse the repository at this point in the history
  • Loading branch information
EricB-ADI committed Oct 24, 2024
1 parent 5dab6a1 commit 9554720
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 17 additions & 4 deletions Libraries/PeriphDrivers/Source/SYS/mxc_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ void MXC_FreeLock(uint32_t *lock)
/* ************************************************************************** */
int MXC_GetLock(uint32_t *lock, uint32_t value)
{
#warning "Unimplemented for RISCV"

__disable_irq();
if(*lock)
{
__enable_irq();
return E_BUSY;
}

*lock = value

// Ensure memory ordering
__asm volatile("fence rw, rw");
__enable_irq();
return E_NO_ERROR;
}

/* ************************************************************************** */
void MXC_FreeLock(uint32_t *lock)
{
#warning "Unimplemented for RISCV"
void MXC_FreeLock(uint32_t *lock) {
__asm volatile("fence" ::: "memory");
*lock = 0;

}
#endif
6 changes: 0 additions & 6 deletions Libraries/PeriphDrivers/libPeriphDriver.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ include ${CMSIS_ROOT}/../PeriphDrivers/$(TARGET_LC)_files.mk
PERIPH_DRIVER_C_FILES += $(SOURCE_DIR)/SYS/mxc_assert.c
PERIPH_DRIVER_C_FILES += $(SOURCE_DIR)/SYS/mxc_delay.c
PERIPH_DRIVER_C_FILES += $(SOURCE_DIR)/SYS/nvic_table.c
# TODO(JC): Implement mxc_lock for RISC-V. Skip for now.
ifneq "$(RISCV_CORE)" "1"
ifneq "$(RISCV_CORE)" "RV32"
# ^ NOTE(JC): Some legacy Makefiles use "RV32". We recommend using "1" in the UG
PERIPH_DRIVER_C_FILES += $(SOURCE_DIR)/SYS/mxc_lock.c
endif
endif

# # Where to find header files for this project
IPATH += $(PERIPH_DRIVER_INCLUDE_DIR)
Expand Down

0 comments on commit 9554720

Please sign in to comment.