-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
118 lines (88 loc) · 2.31 KB
/
main.c
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "TM4C123.h"
#include "stdio.h"
#include "Io.h"
#include "delays.h"
#include "keypad.h"
#include "lcd.h"
#include "switches.h"
#include "operations.h"
#define NVIC_ST_CTRL_R (*((volatile unsigned long *)0xE000E010))
#define NVIC_ST_RELOAD_R (*((volatile unsigned long *)0xE000E014))
#define NVIC_ST_CURRENT_R (*((volatile unsigned long *)0xE000E018))
void start_reading(unsigned char key);
void beefchicken_cooking(unsigned char weight);
void SysTick_Init(void);
void SysTick_wait1s(void);
unsigned char button_in;
unsigned char door_button;
unsigned char key;
unsigned char weight;
void init(void){};
int f;
int main(void)
{
init();
SysTick_Init();
RGB_Init();
Buzzer_VInit ();
SW1_Init();
SW2_Init();
SW3_Init();
keypad_Init();
LCD_init();
mystate =idle;
while(1){
switch(mystate){
case (idle):
LCD_Clear_screen();
LCD_String("Start!");
while (keypad_getkey() == 0xFF){};
LCD_Clear_screen();
key = keypad_getkey(); // read the keypad
if(key=='A' || key=='B'||key=='C'||key=='D'){
mystate = prep;}
break;
case (prep):
start_reading(key);
mystate = cooking;
break;
case (cooking):
switch(key){
case ('A'):
while (sw_Input() != 0x10 || sw3_Input()==1){}; // wait until sw2 on
mystate=countdown(1, 0);//printing countdown
LCD_command(0x01);//clearing lcd
LCD_command(0x02); //returing cursor to its initial position
break;
case('B'):
LCD_String("Beef weight:");
while (keypad_getkey() == 0xFF){};
weight = keypad_getkey(); // read the keypad
LCD_Write_Char(weight);
while (sw_Input() != 0x10 || sw3_Input()==1){};
beef_cooking(weight);
break;
case('C'):
LCD_String("chicken weight:");
while (keypad_getkey() == 0xFF){};
weight = keypad_getkey();// read the keypad
LCD_Write_Char(weight);
while (sw_Input() != 0x10 || sw3_Input()==1){};
chicken_cooking(weight);
break;
case('D'):
while (sw3_Input()==1){};
mystate=cooking_time();
break;
}
break;
case (finish):
LCD_String("done");
for( f=0 ; f<3 ; f++){
Buzzer_ON ();
Blink();
}
mystate = idle;
break;
}
}}