Mutex

EmbeddedUtilities/Mutex.h

#include “EmbeddedUtilities/Mutex.h”

Typedefs

typedef struct Mutex Mutex

Functions

void lockMutex(Mutex *self, void *lock)
void unlockMutex(Mutex *self, void *lock)
void initMutex(Mutex *self)

Variables

const uint8_t MUTEX_WAS_NOT_LOCKED = 0x01
const uint8_t MUTEX_WAS_NOT_UNLOCKED = 0x02
struct Mutex

Public Members

void *lock

File

#ifndef COMMUNICATIONMODULE_MUTEX_H
#define COMMUNICATIONMODULE_MUTEX_H

#include <stdint.h>

typedef struct Mutex Mutex;

struct Mutex
{
  void *lock;
};

static const uint8_t MUTEX_WAS_NOT_LOCKED = 0x01;
static const uint8_t MUTEX_WAS_NOT_UNLOCKED = 0x02;

void
lockMutex(Mutex *self, void *lock);

void
unlockMutex(Mutex *self, void *lock);

void
initMutex(Mutex *self);

#endif //COMMUNICATIONMODULE_MUTEX_H

EmbeddedUtilities/Atomic.h

#include “EmbeddedUtilities/Atomic.h”

Functions

void executeAtomically(GenericCallback callback)

File

#ifndef COMMUNICATIONMODULE_ATOMIC_H
#define COMMUNICATIONMODULE_ATOMIC_H

#include "EmbeddedUtilities/Callback.h"

/**
 * \file Util/Atomic.h
 * 
 * This function has to be implemented
 * by the user of the library.
 * The function provided as parameter
 * is assumed to be executed without
 * being interrupted. Enabling and
 * disabling interrupts usually depends
 * on the platform the application runs on.
 * To avoid introducing this dependency into
 * the communication module we rely on the
 * user providing this function during
 * link time. For most atmega
 * platforms an implementation
 * like the following should be sufficient:
 *
 * ```c
 * #include <util/atomic.h>
 *
 * void
 * executeAtomically(GenericCallback callback)
 * {
 *   ATOMIC_BLOCK(ATOMIC_STATERESTORE)
 *   {
 *     callback.function(callback.argument);
 *   }
 * }
 * ```
 */

void
executeAtomically(GenericCallback callback);

#endif //COMMUNICATIONMODULE_ATOMIC_H