summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorOmar Magdy <omar.professional8777@gmail.com>2022-08-25 02:24:01 +0200
committerOmar Magdy <omar.professional8777@gmail.com>2022-08-25 02:24:01 +0200
commitc3f4417efaa489c41e5d5d44fb28ae01e65ff6bc (patch)
treee64fe589fe32c39b6cdb4f81f07ca746f38c4b75 /main.c
parentbc90dfb83866078bce80034d06607b0094aa63e4 (diff)
downloadTraffic-light-c3f4417efaa489c41e5d5d44fb28ae01e65ff6bc.tar.xz
Traffic-light-c3f4417efaa489c41e5d5d44fb28ae01e65ff6bc.zip
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
Diffstat (limited to 'main.c')
-rw-r--r--main.c21
1 files changed, 10 insertions, 11 deletions
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));
}