blob: f1f94a9281ffec7278fef7fbff351be597000f53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "tivaware.h"
#define TIVA_CLK 16e6
#define GREEN_PERIOD TIVA_CLK * 5
#define YELLOW_PERIOD TIVA_CLK * 2
#define RED_PERIOD TIVA_CLK * 7
#define RED 1
#define YELLOW 2
#define GREEN 3
typedef struct Traffic{
uint8_t cur_color;
uint32_t port;
uint8_t red;
uint8_t yellow;
uint8_t green;
} Traffic;
typedef struct Bcd{
uint32_t port;
uint8_t A;
uint8_t B;
uint8_t C;
uint8_t D;
} Bcd;
extern Traffic tf1;
extern Traffic tf2;
extern Traffic tf_ped;
extern Bcd bcd1;
extern Bcd bcd2;
extern Bcd bcd_ped;
extern bool switch_pressed;
extern uint32_t period_1;
extern uint32_t period_2;
extern uint32_t period_3;
void TrafficInit();
void Traffic_Handler(Traffic *tf, uint32_t timer);
void set_tf_color(Traffic tf, uint8_t color);
void PortInit(uint32_t port, uint32_t clk, uint32_t input, uint32_t output);
void TimerInit(uint32_t timer, void(*timer_handler)(), uint32_t clk, uint32_t delay);
void BcdWrite(Bcd bcd, uint32_t timer, bool ped);
|