From 1c30439959c59d5ec44eee2a896c3a72b8dce047 Mon Sep 17 00:00:00 2001 From: garlichs <garlichs@ibr.cs.tu-bs.de> Date: Tue, 24 Nov 2015 17:08:15 +0100 Subject: [PATCH] dw1000: fixes readSubregisterFromISR function. crashed before --- Inc/dw1000.h | 1 + Src/dw1000_hal.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Inc/dw1000.h b/Inc/dw1000.h index 4e395b9..4e1a4d5 100644 --- a/Inc/dw1000.h +++ b/Inc/dw1000.h @@ -2,6 +2,7 @@ #define __dw1000_H #include "FreeRTOS.h" #include <stdint.h> +#include "cmsis_os.h" //DECA:DW1000 SLEEP and WAKEUP configuration parameters #define DWT_LOADLDO 0x1000 // ONW_LLDO - on wakeup load the LDO tune value #define DWT_LOADUCODE 0x0800 // ONW_LLDE - on wakeup load the LDE ucode diff --git a/Src/dw1000_hal.c b/Src/dw1000_hal.c index 398ae9b..1d81a8d 100644 --- a/Src/dw1000_hal.c +++ b/Src/dw1000_hal.c @@ -75,7 +75,7 @@ int dw1000Hal_readSubRegisterFromIsr(uint8_t regID, uint16_t offset, int ret; //portENTER_CRITICAL(); if ((spiSema != NULL) - && (xSemaphoreTake(spiSema, ( TickType_t ) DW1000HAL_SPI_TIMEOUT) + && (xSemaphoreTakeFromISR(spiSema, ( TickType_t ) DW1000HAL_SPI_TIMEOUT) == pdTRUE)) { if (len <= 127) { dummy[0] = regID & 0x3f; //set the first two bit 0 (read access, no subregister) @@ -97,7 +97,7 @@ int dw1000Hal_readSubRegisterFromIsr(uint8_t regID, uint16_t offset, dw1000Hal_chipDeselect(); while (hspi->State != HAL_SPI_STATE_READY) ; - xSemaphoreGive(spiSema); + xSemaphoreGiveFromISR(spiSema, pdFALSE); } else { ret = HAL_LOCKED; } -- GitLab