Browse Source

Add even more abstraction layers

Jonatan Gezelius 4 years ago
parent
commit
7e88225070

+ 2 - 1
the_actual_project/App/main.c

@@ -1,4 +1,5 @@
 #include "platform.h"
+#include "middleware/status_indicator.h"
 
 int main()
 {
@@ -6,7 +7,7 @@ int main()
 
 	while(1)
 	{
-		pgi_gpio_set(RED_LED);
+		status_indicator_display(STATUS_INDICATOR_ALERT);
 		platform_service();
 	}
 }

+ 22 - 0
the_actual_project/App/middleware/status_indicator.c

@@ -0,0 +1,22 @@
+/*
+ * status_indicator.c
+ *
+ *  Created on: 21 nov. 2021
+ *      Author: Jonatan
+ */
+
+#include "status_indicator.h"
+#include "platform.h"
+
+void status_indicator_display(status_indicator_state_t state)
+{
+	switch(state)
+	{
+	case STATUS_INDICATOR_ALERT:
+		pgi_gpio_set(RED_LED);
+		break;
+	case STATUS_INDICATOR_NORMAL:
+		pgi_gpio_clear(RED_LED);
+		break;
+	}
+}

+ 19 - 0
the_actual_project/App/middleware/status_indicator.h

@@ -0,0 +1,19 @@
+/*
+ * status_indicator.h
+ *
+ *  Created on: 21 nov. 2021
+ *      Author: Jonatan
+ */
+
+#ifndef MIDDLEWARE_STATUS_INDICATOR_H_
+#define MIDDLEWARE_STATUS_INDICATOR_H_
+
+typedef enum
+{
+	STATUS_INDICATOR_NORMAL,
+	STATUS_INDICATOR_ALERT,
+} status_indicator_state_t;
+
+void status_indicator_display(status_indicator_state_t state);
+
+#endif /* MIDDLEWARE_STATUS_INDICATOR_H_ */

+ 2 - 0
the_actual_project/Platform/platform.h

@@ -10,6 +10,8 @@
 
 #include "generic_interfaces/pgi_gpio.h"
 
+
+// TODO: Is extern really needed?
 extern pgi_gpio_pin_t *RED_LED;
 
 void platform_init();