#include "rpp/rpp.h"
+#include "rpp/mutex.h"
+
+RPP_MUTEX_DEFINE(mutex_lout);
#ifndef FREERTOS_POSIX
#include "drv/lout.h"
{
if (initialized)
return FAILURE;
+ if (!RPP_MUTEX_INIT(mutex_lout))
+ return FAILURE;
initialized = TRUE;
#ifndef FREERTOS_POSIX
spi_tms570_init();
return -1;
uint8_t index = pin - 1;
+ RPP_MUTEX_LOCK(mutex_lout);
if (val)
bit_set(out_cache, index);
else
bit_clear(out_cache, index);
+ RPP_MUTEX_UNLOCK(mutex_lout);
return SUCCESS;
}
if ((pin < 1) || (pin > 8))
return -1;
+ int8_t ret_val = LOW;
+
+ RPP_MUTEX_LOCK(mutex_lout);
if (is_bit_set(diag_cache, pin - 1))
- return HIGH;
- return LOW;
+ ret_val = HIGH;
+ RPP_MUTEX_UNLOCK(mutex_lout);
+ return ret_val;
}
int8_t rpp_lout_update()
{
#ifndef FREERTOS_POSIX
+ RPP_MUTEX_LOCK(mutex_lout);
// Update output values
lout_set_word(out_cache);
// FIXME: Check which SPI transfer statuses could be considered errors
// FIXME: Implement. Dummy assign for now.
diag_cache = out_cache;
- if (diag_cache != out_cache)
+ if (diag_cache != out_cache) {
+ RPP_MUTEX_UNLOCK(mutex_lout);
return FAILURE;
-
+ }
+ RPP_MUTEX_UNLOCK(mutex_lout);
#endif
return SUCCESS;