Library for Modtronix NZ32 STM32 boards, like the NZ32-SC151, NZ32-SB072, NZ32-SE411 and others

Revision:
13:328bfac0e686
Parent:
11:86288b5c75cb
Child:
15:3fd3c1ce01be
--- a/nz32s.h	Thu Sep 17 11:53:01 2015 +1000
+++ b/nz32s.h	Wed Oct 21 14:53:20 2015 +1100
@@ -24,8 +24,40 @@
 #include "mbed.h"
 #include "mx_tick.h"
 #include "mx_helpers.h"
+#include "mx_circular_buffer.h"
+#include "mx_cmd_buffer.h"
 #include "nz32s_default_config.h"
 
+
+// Debugging //////////////////////////////////////////////////////////////////
+// To enable debug output from this file, define MX_DEBUG and DEBUG_ENABLE_NZ32S before
+// including this file.
+//
+//Defines for MXH_DEBUG - debugging for include file
+#if !defined(DEBUG_ENABLE_NZ32S)
+    #define DEBUG_ENABLE_NZ32S          0
+#endif
+#if !defined(DEBUG_ENABLE_INFO_NZ32S)
+    #define DEBUG_ENABLE_INFO_NZ32S     0
+#endif
+
+#if !defined(MXH_DEBUG)
+    #if defined(MX_DEBUG) && (DEBUG_ENABLE_NZ32S==1)
+        #define MXH_DEBUG MX_DEBUG
+    #else
+        #define MXH_DEBUG(format, args...) ((void)0)
+    #endif
+#endif
+
+#if !defined(MXH_DEBUG_INFO)
+    #if defined(MX_DEBUG) && (DEBUG_ENABLE_NZ32S==1) && (DEBUG_ENABLE_INFO_NZ32S==1)
+        #define MXH_DEBUG_INFO MX_DEBUG
+    #else
+        #define MXH_DEBUG_INFO(format, args...) ((void)0)
+    #endif
+#endif
+
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -47,8 +79,9 @@
 
     /** Toggle System LED1
     */
-    static inline void toggle_led1(void) {
+    static inline bool toggle_led1(void) {
         led1 = !led1;
+        return (bool)led1.read();
     }
 
     /** Set System LED1
@@ -69,8 +102,13 @@
         led1 = val;
     }
 
+    /** Get state of LED2
+     */
+    static inline bool get_led1(void) {
+        return (bool)led1.read();
+    }
 
-    /** Get state of button1
+    /** Get state of button1. Returns 1 when pressed
      */
     static inline bool get_btn1(void) {
         return (bool)btn1.read();
@@ -126,7 +164,7 @@
         //MaxTimeOut = (256 * 4096) / 32000 = 32.768 seconds
         NZ32S::hiwdg.Instance = IWDG;
 
-        //MXH_DEBUG("\r\nwatchdog_start() called!!!!!!!!!!!!!!");
+        MXH_DEBUG("\r\nwatchdog_start() called!");
 
         //For values below 4000, use IWDG_PRESCALER_32. This will cause timeout period to be
         //equal to 'timeout' value in ms
@@ -187,4 +225,11 @@
 };
 #endif
 
+#if defined(MXH_DEBUG)
+    #undef MXH_DEBUG
+#endif
+#if defined(MXH_DEBUG_INFO)
+    #undef MXH_DEBUG_INFO
+#endif
+
 #endif //NZ32S_H_