Missing files for SWo
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@236 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Class.h (c) 2013 Micro-Key bv
|
||||
* -----------------------------------------------------------------------------
|
||||
* Micro-Key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* -----------------------------------------------------------------------------
|
||||
* Description: Macro utilities to hide or protect struct members
|
||||
* -----------------------------------------------------------------------------
|
||||
* $Id$
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _CLASS_H_
|
||||
#define _CLASS_H_
|
||||
|
||||
#ifndef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#define PRIVATE(member) DONOTUSE ## member
|
||||
#undef CLASS_INTERNAL_INCLUDE
|
||||
|
||||
#else
|
||||
|
||||
#define PRIVATE(member) member
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -116,16 +116,21 @@
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct MAX5715;
|
||||
|
||||
struct MAX5715_DAC
|
||||
{
|
||||
struct MAX5715* parent;
|
||||
uint8_t id;
|
||||
uint16_t value;
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
struct MAX5715
|
||||
{
|
||||
const struct IODevice* device;
|
||||
struct MAX5715_DAC dac[MAX5715_NUMBER_OF_DACS];
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -156,7 +161,7 @@ extern ErrorStatus MAX5715_construct(struct MAX5715* self, const struct IODevice
|
||||
*
|
||||
* @param self
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* @return ErrorStatus SUCCESS if destruction was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
@@ -171,7 +176,7 @@ extern void MAX5715_destruct(struct MAX5715* self);
|
||||
*
|
||||
* @param parameters SpiParameters struct to fill
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* @return ErrorStatus SUCCESS if function was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
@@ -187,7 +192,8 @@ extern ErrorStatus MAX5715_getSpiParameters(struct SpiParameters* parameters);
|
||||
*
|
||||
* @param self The MAX5715 instance
|
||||
* @param command The command to be sent
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if function was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
@@ -195,19 +201,38 @@ extern ErrorStatus MAX5715_getSpiParameters(struct SpiParameters* parameters);
|
||||
*/
|
||||
extern ErrorStatus MAX5715_sendCommand(const struct MAX5715* self, uint8_t command, uint16_t data);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* MAX5715DAC_setOutput
|
||||
* Sets the output of the DAC in argument self to the value given in argument
|
||||
* value
|
||||
* MAX5715Channel_construct
|
||||
* Constructor for one of the channels on the MAX5715 DAC
|
||||
*
|
||||
* @param self The DAC to use
|
||||
* @param value The value to set
|
||||
* @return ErrorStatus SUCCESS if initialisation was successful
|
||||
* @param self The channel object to initialize
|
||||
* @param parent The parent object that the channel belongs
|
||||
* to
|
||||
* @param id The channel number
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if construction was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus MAX5715DAC_setOutput(struct MAX5715_DAC self, uint16_t value);
|
||||
extern ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX5715* parent, size_t id);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* MAX5715Channel_setValue
|
||||
* Sends value to the DAC channel in self
|
||||
*
|
||||
* @param self The DAC object
|
||||
* @param value Value to write
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if setting value was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value);
|
||||
|
||||
#endif /* INC_MAX5715_H_ */
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Observable.h (c) 2013 Micro-Key bv
|
||||
* -----------------------------------------------------------------------------
|
||||
* Micro-Key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* -----------------------------------------------------------------------------
|
||||
* Description: Observer design pattern
|
||||
* -----------------------------------------------------------------------------
|
||||
* $Id$
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _OBSERVABLE_H_
|
||||
#define _OBSERVABLE_H_
|
||||
|
||||
/* --------------*
|
||||
* Include files *
|
||||
* --------------*
|
||||
*/
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Class.h"
|
||||
#include "Observer.h"
|
||||
|
||||
/* -------------------------------*
|
||||
* Constant and macro definitions *
|
||||
* -------------------------------*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maximal number of Observers for one Observable.
|
||||
*/
|
||||
#define OBSERVABLE_MAX_OBSERVERS (32)
|
||||
|
||||
/**
|
||||
* Static initializer for the Observable class.
|
||||
* Typical usage: struct Observable observable = OBSERVABLE_INITIALIZER;
|
||||
*/
|
||||
#ifdef CLASS_INTERNAL_INCLUDE
|
||||
#define OBSERVABLE_INITIALIZER { .nrOfObservers = 0, .observers = { 0, } }
|
||||
#else
|
||||
#define OBSERVABLE_INITIALIZER { .DONOTUSEnrOfObservers = 0, .DONOTUSEobservers = { 0, } }
|
||||
#endif
|
||||
|
||||
/* ------------------*
|
||||
* Type definitions. *
|
||||
* ------------------*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Observable class.
|
||||
*/
|
||||
struct Observable
|
||||
{
|
||||
int PRIVATE(nrOfObservers);
|
||||
Observer PRIVATE(observers)[OBSERVABLE_MAX_OBSERVERS];
|
||||
};
|
||||
|
||||
/* ----------------------*
|
||||
* Function declarations *
|
||||
* ----------------------*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes the Observable class.
|
||||
* This is not needed if the Observable has been statically initialized by "struct Observable observable = OBSERVABLE_INITIALIZER".
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_initialize(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Terminates the Observable class. All Observers are removed.
|
||||
* @param self: address of the Observable struct.
|
||||
* @retval none.
|
||||
*/
|
||||
void Observable_terminate(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Adds one Observer to the Observable.
|
||||
* @param self: address of the Observable struct.
|
||||
* @param observer: Observer to be added.
|
||||
* @retval ErrorStatus: returns an error in case the maximum number of Observers have been added.
|
||||
*/
|
||||
ErrorStatus Observable_addObserver(struct Observable* self, const Observer observer);
|
||||
|
||||
/**
|
||||
* Adds one Observer to the Observable at the front of the list.
|
||||
* This ensures that this Observer is notified before Observers added by Observable_addObserver.
|
||||
* @param self: address of the Observable struct.
|
||||
* @param observer: Observer to be added.
|
||||
* @retval ErrorStatus: returns an error in case the maximum number of Observers have been added.
|
||||
*/
|
||||
ErrorStatus Observable_addObserverAtFront(struct Observable* self, const Observer observer);
|
||||
|
||||
/**
|
||||
* Notifies all Observers by calling the Observer callback function. The parameter void* data will be
|
||||
* passed as parameter to the Observer.
|
||||
* @param self: address of the Observable struct.
|
||||
* @param data: void pointer data to be passed as parameter to the Observer.
|
||||
* @retval ErrorStatus: returns an error in case one or more of the Observers returned an error.
|
||||
*/
|
||||
ErrorStatus Observable_notifyObservers(const struct Observable* self, const void* const data);
|
||||
|
||||
/**
|
||||
* Deletes one specific Observer added before. If the Observer cannot be found, no action is taken.
|
||||
* @param self: address of the Observable struct.
|
||||
* @param observer: Observer to be deleted.
|
||||
*/
|
||||
void Observable_deleteObserver(struct Observable* self, const Observer observer);
|
||||
|
||||
/**
|
||||
* Deletes all Observers added.
|
||||
* @param self: address of the Observable struct.
|
||||
*/
|
||||
void Observable_deleteObservers(struct Observable* self);
|
||||
|
||||
/**
|
||||
* Returns the number of Observers currently subscribed to an Observable.
|
||||
* @param self: address of the Observable struct.
|
||||
*/
|
||||
int Observable_nrOfObservers(struct Observable* self);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Observer.h (c) 2013 Micro-Key bv
|
||||
* -----------------------------------------------------------------------------
|
||||
* Micro-Key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* -----------------------------------------------------------------------------
|
||||
* Description: Observer design pattern
|
||||
* -----------------------------------------------------------------------------
|
||||
* $Id$
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _OBSERVER_H_
|
||||
#define _OBSERVER_H_
|
||||
|
||||
/* --------------*
|
||||
* Include files *
|
||||
* --------------*
|
||||
*/
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
/* ------------------*
|
||||
* Type definitions. *
|
||||
* ------------------*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Observable class (which is a function pointer)
|
||||
*/
|
||||
typedef ErrorStatus (*Observer)(const void* const data);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user