From e304ce76cb2e66b3009cee4386d9de098e09ce94 Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Tue, 23 Aug 2022 15:17:50 +0200 Subject: Added a Traffic struct and made the code more generic and easy to maintain --- trafficlight.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'trafficlight.h') diff --git a/trafficlight.h b/trafficlight.h index 52ba584..2f8f33d 100644 --- a/trafficlight.h +++ b/trafficlight.h @@ -1,12 +1,25 @@ #include #include +#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); -- cgit v1.2.3