summaryrefslogtreecommitdiff
path: root/fw/src
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2020-12-21 16:47:44 +0100
committerjaseg <git@jaseg.de>2020-12-21 16:47:44 +0100
commit5edb1cebfebedbd384d28df09739bdaf764284f9 (patch)
tree9d3ca77bc828e9c1be1b3e4326d786570a8ecb31 /fw/src
parentddd40092f539385ff030669814b93bdc948e18d6 (diff)
downloadminikbd-5edb1cebfebedbd384d28df09739bdaf764284f9.tar.gz
minikbd-5edb1cebfebedbd384d28df09739bdaf764284f9.tar.bz2
minikbd-5edb1cebfebedbd384d28df09739bdaf764284f9.zip
Remove malloc
Diffstat (limited to 'fw/src')
-rw-r--r--fw/src/usbd_conf.c20
-rw-r--r--fw/src/usbd_conf.h32
2 files changed, 25 insertions, 27 deletions
diff --git a/fw/src/usbd_conf.c b/fw/src/usbd_conf.c
index ccc4b16..b6815e5 100644
--- a/fw/src/usbd_conf.c
+++ b/fw/src/usbd_conf.c
@@ -2,6 +2,10 @@
#include "stm32f0xx_hal.h"
#include "usbd_def.h"
#include "usbd_core.h"
+#include "usbd_hid.h"
+
+#include <stdbool.h>
+#include <assert.h>
PCD_HandleTypeDef hpcd_USB_FS;
@@ -574,3 +578,19 @@ void USBD_LL_Delay(uint32_t Delay /* ms */)
HAL_Delay(Delay);
}
+static USBD_HID_HandleTypeDef *static_hid_handle;
+static bool static_hid_handle_allocated = false;
+
+void *USBD_static_malloc(uint32_t size)
+{
+ assert(!static_hid_handle_allocated);
+ static_hid_handle_allocated = true;
+ return static_hid_handle;
+}
+
+void USBD_static_free(void *p)
+{
+ assert(static_hid_handle_allocated);
+ static_hid_handle_allocated = false;
+}
+
diff --git a/fw/src/usbd_conf.h b/fw/src/usbd_conf.h
index c194c70..0f47bad 100644
--- a/fw/src/usbd_conf.h
+++ b/fw/src/usbd_conf.h
@@ -23,35 +23,10 @@
/* #define for FS and HS identification */
#define DEVICE_FS 0
-/**
- * @}
- */
-
-/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
- * @brief Aliases.
- * @{
- */
-
-/* Memory management macros */
-
-/** Alias for memory allocation. */
-#define USBD_malloc malloc
-//(uint32_t *)USBD_static_malloc
-
-/** Alias for memory release. */
-#define USBD_free free
-
-/** Alias for memory set. */
-#define USBD_memset /* Not used */
-
-/** Alias for memory copy. */
-#define USBD_memcpy /* Not used */
-
-/** Alias for delay. */
+#define USBD_malloc (void *)USBD_static_malloc
+#define USBD_free USBD_static_free
#define USBD_Delay HAL_Delay
-/* DEBUG macros */
-
#if (USBD_DEBUG_LEVEL > 0)
#define USBD_UsrLog(...) printf(__VA_ARGS__);\
printf("\n");
@@ -76,6 +51,9 @@
#define USBD_DbgLog(...)
#endif
+void *USBD_static_malloc(uint32_t size);
+void USBD_static_free(void *p);
+
/* Set unset defines */
#include "usbd_def.h"