-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRun_Commands.c
More file actions
154 lines (138 loc) · 3.02 KB
/
Copy pathRun_Commands.c
File metadata and controls
154 lines (138 loc) · 3.02 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* Run_Commands.c
*
* Created on: Jul 4, 2014
* Author: Nate
*/
/*
This file is part of MSP430 DAC.
MSP430 DAC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MSP430 DAC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MSP430 DAC. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Parse_Command.h"
#include "Run_Commands.h"
#include "Command_Lib/Read_Digital.h"
#include "Command_Lib/Set_GPIO_Output.h"
#include "Command_Lib/Define_GPIO.h"
#include "Command_Lib/Get_ADC.h"
#include "Command_Lib/Set_PWM.h"
#include "Command_Lib/Serial_Data.h"
char Command_Buffer[40];
static uint16_t Command_Buffer_Index = 0;
void Add_Char_To_Command_Buffer(char Input_Char)
{
Command_Buffer[Command_Buffer_Index] = Input_Char;
Command_Buffer_Index = (Command_Buffer_Index + 1) % (sizeof(Command_Buffer)-1);
}
void Clear_Command_Buffer()
{
Command_Buffer_Index = 0;
memset(Command_Buffer,0,sizeof(Command_Buffer));
}
void Run_Command(char * Input_Text)
{
bool returnVal = false;
AT_COMMANDS AT_Command;
extern char * AT_INVALID;
do
{
Input_Text = Check_For_AT(Input_Text);
if(Input_Text==0)
{
break;
}
Input_Text = Get_AT_Command(Input_Text,&AT_Command);
if(Input_Text==0)
{
break;
}
else
{
switch(AT_Command)
{
case DEFINE_GPIO:
if(Define_GPIO_Value(Input_Text))
{
returnVal = true;
}
break;
case SET_GPIO_OUTPUT:
if(Set_GPIO_Output(Input_Text))
{
returnVal = true;
}
break;
case READ_DIGITAL_INPUTS:
if(Read_Digital(Input_Text))
{
returnVal = true;
}
break;
case READ_ADC:
if(Get_Adc_Values())
{
returnVal = true;
}
break;
case SET_PWM:
if(Set_PWM_Output(Input_Text))
{
returnVal = true;
}
break;
case CONFIG_SPI:
if(Define_Spi(Input_Text))
{
returnVal = true;
}
break;
case SEND_SPI:
if(Send_SPI_Data(Input_Text))
{
returnVal = true;
}
break;
case NO_COMMAND:
break;
default:
break;
}
}
}while(0);
if(!returnVal)
{
writeUartString((char *)AT_INVALID);
}
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void) {
char Input_Char = 0;
if((IFG2 & UCA0RXIFG))
{
Input_Char =UCA0RXBUF;
if(Input_Char == '\r')
{
Run_Command(Command_Buffer);
Clear_Command_Buffer();
}
else
{
while (!(IFG2 & UCA0TXIFG));
UCA0TXBUF = Input_Char;
//while (UCA0STAT & UCBUSY);
Add_Char_To_Command_Buffer(Input_Char);
}
}
if((IFG2 & UCB0RXIFG))
{
_delay_cycles(1);
}
}