Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2018-03-30 20:39:09 +0300
committerDavid Crocker <dcrocker@eschertech.com>2018-03-30 20:39:09 +0300
commitde270d2a00fd83cc3961a749432bff940601f1dd (patch)
tree7a9f781a99def2ffa10734c1053d94e0cb3651d4 /src/Heating
parent22e0ac40dd0f7fb5a362476d054bfbb6e8aa4293 (diff)
Thread safe file system
Various changes to maske the filesystem thread safe
Diffstat (limited to 'src/Heating')
-rw-r--r--src/Heating/Heat.cpp14
-rw-r--r--src/Heating/Sensors/SpiTemperatureSensor.cpp31
2 files changed, 23 insertions, 22 deletions
diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp
index ff607e6f..977e0b28 100644
--- a/src/Heating/Heat.cpp
+++ b/src/Heating/Heat.cpp
@@ -32,15 +32,13 @@ Licence: GPL
#ifdef RTOS
# include "Tasks.h"
-# include "FreeRTOS.h"
-# include "task.h"
const uint32_t HeaterTaskStackSize = 128; // task stack size in dwords
const uint32_t HeaterTaskPriority = 1;
-static StackType_t heaterTaskStack[HeaterTaskStackSize];
-static StaticTask_t heaterTaskBuffer;
-static TaskHandle_t heaterTaskHandle;
+static uint32_t heaterTaskStack[HeaterTaskStackSize];
+static TaskStorage heaterTaskBuffer;
+static TaskHandle heaterTaskHandle;
extern "C" void HeaterTask(void * pvParameters)
{
@@ -147,7 +145,7 @@ void Heat::Init()
coldExtrude = false;
#ifdef RTOS
- heaterTaskHandle = xTaskCreateStatic(HeaterTask, "HEAT", ARRAY_SIZE(heaterTaskStack), nullptr, HeaterTaskPriority, heaterTaskStack, &heaterTaskBuffer);
+ heaterTaskHandle = RTOSIface::CreateTask(HeaterTask, "HEAT", ARRAY_SIZE(heaterTaskStack), nullptr, HeaterTaskPriority, heaterTaskStack, heaterTaskBuffer);
#else
lastTime = millis() - platform.HeatSampleInterval(); // flag the PIDS as due for spinning
longWait = millis();
@@ -163,7 +161,7 @@ void Heat::Exit()
}
#ifdef RTOS
- vTaskSuspend(heaterTaskHandle);
+ RTOSIface::SuspendTask(heaterTaskHandle);
#else
active = false;
#endif
@@ -747,7 +745,7 @@ bool Heat::WriteBedAndChamberTempSettings(FileStore *f) const
buf.printf("M141 P%u S%.1f\n", index, (double)GetActiveTemperature(chamberHeater));
}
}
- return (buf.Length() == 0) || f->Write(buf.Pointer());
+ return (buf.strlen() == 0) || f->Write(buf.Pointer());
}
// End
diff --git a/src/Heating/Sensors/SpiTemperatureSensor.cpp b/src/Heating/Sensors/SpiTemperatureSensor.cpp
index 7195d6cc..a1a4fc26 100644
--- a/src/Heating/Sensors/SpiTemperatureSensor.cpp
+++ b/src/Heating/Sensors/SpiTemperatureSensor.cpp
@@ -6,6 +6,7 @@
*/
#include "SpiTemperatureSensor.h"
+#include "Tasks.h"
SpiTemperatureSensor::SpiTemperatureSensor(unsigned int channel, const char *name, unsigned int relativeChannel, uint8_t spiMode, uint32_t clockFrequency)
: TemperatureSensor(channel, name)
@@ -27,24 +28,26 @@ void SpiTemperatureSensor::InitSpi()
// Send and receive 1 to 8 bytes of data and return the result as a single 32-bit word
TemperatureError SpiTemperatureSensor::DoSpiTransaction(const uint8_t dataOut[], size_t nbytes, uint32_t& rslt) const
{
- if (!sspi_acquire())
+ uint8_t rawBytes[8];
+ spi_status_t sts;
{
- return TemperatureError::busBusy;
- }
+ Locker lock(Tasks::GetSpiMutextHandle(), 50);
+ if (!lock)
+ {
+ return TemperatureError::busBusy;
+ }
- sspi_master_setup_device(&device);
- delayMicroseconds(1);
- sspi_select_device(&device);
- delayMicroseconds(1);
+ sspi_master_setup_device(&device);
+ delayMicroseconds(1);
+ sspi_select_device(&device);
+ delayMicroseconds(1);
- uint8_t rawBytes[8];
- spi_status_t sts = sspi_transceive_packet(dataOut, rawBytes, nbytes);
+ sts = sspi_transceive_packet(dataOut, rawBytes, nbytes);
- delayMicroseconds(1);
- sspi_deselect_device(&device);
- delayMicroseconds(1);
-
- sspi_release();
+ delayMicroseconds(1);
+ sspi_deselect_device(&device);
+ delayMicroseconds(1);
+ }
if (sts != SPI_OK)
{