diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-03-19 12:08:17 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-03-19 12:08:17 +0200 |
| commit | cc4129c557405accb3ced68f7b6cb19dbdb87a24 (patch) | |
| tree | f86827ef77a6ef6733805f8190bd961934543e5c /Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c | |
| parent | 9d04bbb2b4a2eb2eb14cc813103c856b7bde975a (diff) | |
| download | Tango-cc4129c557405accb3ced68f7b6cb19dbdb87a24.tar.gz Tango-cc4129c557405accb3ced68f7b6cb19dbdb87a24.zip | |
Driver structures and prototypes
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c index 216779f8b..1de8ac0de 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c @@ -1,7 +1,53 @@ /* * DriverWithCallbackExample.c * - * Created on: 11 במרץ 2018 + * Created on: 11 march 2018 * Author: shlomo */ -uint32_t +#include "include.h" +#include "control.h" + + +uint32_t KeepParameter = 0; +callback_fptr ModuleCallback = 0; +bool isValid (uint32_t deviceID); +uint32_t ControlCallBackFunction(uint32_t deviceID, uint32_t ReadValue); + + + +uint32_t DriverActionWithCallback (uint32_t deviceId, uint32_t parameter, callback_fptr callback) +{ + assert (callback); + assert (isValid(deviceId)); + + //call driver action to device id with the parameter + //SetMotorSpeed (deviceId, parameter); + KeepParameter = parameter; + ModuleCallback = callback; + //start control: + + uint32_t ControlId = AddControlCallback( callback, eOneMillisecond, NULL, deviceId, parameter ); + return ControlId; + +} + +uint32_t ControlCallBackFunction(uint32_t deviceId, uint32_t ReadValue) +{ + if (ReadValue == KeepParameter) + { + //stop this control loop + RemoveControlCallback(deviceId, ControlCallBackFunction ); + //possibly: start regular control (speed etc) + //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, NULL, deviceId, Parameter ); + + //call the module callback + ModuleCallback(deviceId,ReadValue); + + } + return OK; +} + +bool isValid (uint32_t deviceID) +{ + return true; +} |
