This repository has been archived by the owner on Dec 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setups.c
103 lines (88 loc) · 2.89 KB
/
setups.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
/****************************************************************************************
setups.c
by group 2: Raul Rojas, Christa McDaniel, Alex Fotso
Objective:
This File contains the initialization of hardware as well as the boot and shutdown
command sequences for the system.
Functions:
setups()
bootSequence()
shutDownSequence()
****************************************************************************************/
#include <wiringPi.h>
#include <lcd.h>
#include <stdio.h>
#include <mcp23017.h>
#include <time.h>
#include "finalHeader.h"
//GLOBAL VARIABLES
extern int page; // variables to keep track of page and line
extern int line;
extern int lcdhdl;
extern int set;
/****************************************************************************************
void setups(void)
Description: This function initializes the gpio functionality using the wiringPi
library as well as set all used pines to a known default state. The LCD is also
initialized here.
****************************************************************************************/
void setups(void)
{
int i;
wiringPiSetupGpio();
mcp23017Setup (100, 0x20); //Gpio expander initialization.
for (i=0;i<8;++i) //loop to set pin modes for LCD. (on GPIO expander pins)
{
pinMode(100+i,OUTPUT);
}
//The following sets the gpio's to a default known state.
pinMode(FAN, OUTPUT);
pinMode(COOL, OUTPUT);
pinMode(HEAT, OUTPUT);
pinMode(pwrLED, OUTPUT);
//pinMode(syncLED, OUTPUT);
pinMode(entSwitch, INPUT);
pinMode(dwnSwitch, INPUT);
pinMode(upSwitch, INPUT);
pinMode(syncSwitch, INPUT);
pinMode(rstSwitch, INPUT);
pinMode(pwrSwitch, INPUT);
digitalWrite(FAN, HIGH);
digitalWrite(COOL, HIGH);
digitalWrite(HEAT, HIGH);
digitalWrite(pwrLED, HIGH);
//digitalWrite(syncLED, HIGH);
digitalWrite(pwrLED, LOW);
lcdinitialization();
return;
}
/****************************************************************************************
void bootSequence(void)
Description: This function initializes all arrays used in this program to a known
state of 0. As well as perform an LCD test.
****************************************************************************************/
void bootSequence(void)
{
//lcdBoot();
initArray();
initTimeArr();
initRegFlow();
initTempsArr();
initRocArray();
return;
}
/****************************************************************************************
void shutDownSequence(void)
Description: This function sets all led off and clears the LCD before the program
terminates.
****************************************************************************************/
void shutDownSequence(void)
{
//turn off all LED's, relay signals, and clear lcd.
lcdClear(lcdhdl);
digitalWrite(pwrLED, HIGH);
digitalWrite(COOL, HIGH);
digitalWrite(HEAT, HIGH);
digitalWrite(FAN, HIGH);
return;
}