From c3f4417efaa489c41e5d5d44fb28ae01e65ff6bc Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Thu, 25 Aug 2022 02:24:01 +0200 Subject: Fixed a bug of the pedestrain traffic timer where it would restart from 5 to 1 again and Added comments for the whole project and added timers as a member of the Traffic struct to add more generlization of the --- main.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index afbcce7..2d412b6 100644 --- a/main.c +++ b/main.c @@ -1,24 +1,23 @@ #include "trafficlight.h" -uint32_t period_1 = RED_PERIOD; -uint32_t period_2 = GREEN_PERIOD; -uint32_t period_3 = GREEN_PERIOD; -bool switch_pressed = false; +uint32_t period_1 = RED_PERIOD; // Intial period of tf1 +uint32_t period_2 = GREEN_PERIOD; // Intial period of tf2 +uint32_t period_3 = 0; // Intial peroid of tf_ped -//Traffics -Traffic tf1 = {RED , GPIO_PORTA_BASE, 2, 3, 4}; -Traffic tf2 = {YELLOW, GPIO_PORTF_BASE, 1, 2, 3}; -Traffic tf_ped = {RED , GPIO_PORTB_BASE, 5, 0, 7}; +bool switch_pressed = false; //Decoders Bcd bcd1 = {GPIO_PORTE_BASE, 1, 2, 3, 5}; Bcd bcd2 = {GPIO_PORTD_BASE, 1, 2, 3, 6}; Bcd bcd_ped = {GPIO_PORTA_BASE, 5, 6, 7, 4}; // (5, 6, 7) A and 4 of E +//Traffics +Traffic tf1 = {RED , GPIO_PORTA_BASE, 2, 3, 4, TIMER0_BASE}; +Traffic tf2 = {YELLOW, GPIO_PORTF_BASE, 1, 2, 3, TIMER1_BASE}; +Traffic tf_ped = {RED , GPIO_PORTB_BASE, 5, 0, 7, TIMER2_BASE}; + + int main() { TrafficInit(); - // PortInit(GPIO_PORTE_BASE, SYSCTL_PERIPH_GPIOE, 0x0, 0xFF); // Initialize porta - // GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0); - // GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, (1 << 1) | (1 << 2)); } -- cgit v1.2.3