aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-03-19 12:08:17 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-03-19 12:08:17 +0200
commitcc4129c557405accb3ced68f7b6cb19dbdb87a24 (patch)
treef86827ef77a6ef6733805f8190bd961934543e5c /Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c
parent9d04bbb2b4a2eb2eb14cc813103c856b7bde975a (diff)
downloadTango-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.c50
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;
+}