summaryrefslogtreecommitdiff
path: root/trafficlight.h
diff options
context:
space:
mode:
authorOmar Magdy <omar.professional8777@gmail.com>2022-08-23 15:17:50 +0200
committerOmar Magdy <omar.professional8777@gmail.com>2022-08-23 15:17:50 +0200
commite304ce76cb2e66b3009cee4386d9de098e09ce94 (patch)
tree73fd498f47eb4c1a47554b4e6168114c1859ba27 /trafficlight.h
parent33756429cda89ed7ed2fd97b4ae0ca87e3bf36f1 (diff)
downloadTraffic-light-e304ce76cb2e66b3009cee4386d9de098e09ce94.tar.xz
Traffic-light-e304ce76cb2e66b3009cee4386d9de098e09ce94.zip
Added a Traffic struct and made the code more generic and easy to
maintain
Diffstat (limited to 'trafficlight.h')
-rw-r--r--trafficlight.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/trafficlight.h b/trafficlight.h
index 52ba584..2f8f33d 100644
--- a/trafficlight.h
+++ b/trafficlight.h
@@ -1,12 +1,25 @@
#include <stdint.h>
#include <stdbool.h>
+#include "tivaware.h"
#include "color.h"
-#include "dio.h"
#define TIVA_CLK 16e6
#define GREEN_PERIOD TIVA_CLK * 5
#define YELLOW_PERIOD TIVA_CLK * 2
#define RED_PERIOD TIVA_CLK * 7
+
+typedef struct Traffic{
+ uint8_t cur_color;
+ uint32_t port;
+ uint8_t red;
+ uint8_t yellow;
+ uint8_t green;
+} Traffic;
+
+extern Traffic tf1;
+extern Traffic tf2;
+
+void set_tf_color(Traffic tf, uint8_t color);
void PortInit(uint32_t port, uint32_t clk);
void TimerInit(uint32_t timer, void(*timer_handler)(), uint32_t clk, uint32_t delay);