Changeset 12147 for fact/tools/hvMCUtest/ARDUINO_FTDI
- Timestamp:
- 09/21/11 17:24:15 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/hvMCUtest/ARDUINO_FTDI/ARDUINO_FTDI.pde
r12143 r12147 29 29 */ 30 30 //define non transferable variables 31 #define NUMCHANNELS 416 31 #define MAXBOARDS 13 32 #define EXISTINGBOARDS 10 33 #define CHPERBOARD 32 34 #define NUMCHANNELS EXISTINGBOARDS*CHPERBOARD 32 35 #define BLANKBYTE 0x00 33 36 #define READSTATEBYTE 0x20 … … 40 43 41 44 typedef enum { 45 set_message, 46 send_message, 47 get_message, 48 pc_serial, 49 parsing 50 } state_contr; //Type to define what microcontroller should do 51 52 typedef enum { 42 53 channel_status, 43 54 sys_reset, 44 55 global_set, 45 56 channel_set 46 } function_t; 57 } function_t; //Type to define which function of PLD shell be build 47 58 48 59 typedef enum { 49 set_message,50 send_message,51 get_message 52 } state_contr; 60 transmit_PLD_answer, 61 get_request, 62 } communication; //Type to define communication with PC 63 53 64 54 65 const unsigned char wr = 2; … … 59 70 volatile unsigned char databus = 0x00; //temp. memory for Reading Databus interrupt 60 71 unsigned char message[3]; //field where the 3 Byte message is saved 61 unsigned char messageindex =0; //index of field62 72 unsigned char messageindex = 0; //index of field 73 unsigned char incommingByte = 0; //for incomming serial Data 63 74 unsigned int recent_voltages[NUMCHANNELS]; //The actual Voltage of each channel is saved in this variable 64 75 unsigned int set_voltage; //The Value to which channel shell be set is saved in the variable … … 68 79 69 80 function_t function; 70 state_contr state_controler = set_message; 81 state_contr state_controler; 82 communication pc_com = get_request; 71 83 72 84 //unsigned char call_function; //variable to call a funtion … … 98 110 function = channel_set; 99 111 set_voltage = 0xaaa; 100 state_controler = set_message; //just for development112 state_controler = pc_serial; //just for development 101 113 digitalWrite(FREE1, LOW); 102 114 … … 141 153 } 142 154 if ( state_controler == send_message){ 155 //Serial.print ("sending message"); 143 156 //RisingEdge_RD = false; 144 157 //This is the FIFO Read Cycle, PLD reads from FIFO, ARDUINO writes to FIFO … … 203 216 message[messageindex] = databus; 204 217 messageindex = 0; 205 state_controler = set_message; 218 state_controler = pc_serial; 219 pc_com = transmit_PLD_answer; 206 220 break; 207 221 } … … 213 227 214 228 // delay(1000); //slow down process for test pourpose 229 230 // Communication with PC via USB 231 if ( state_controler == pc_serial){ 232 233 // Outgoing Commands 234 switch ( pc_com ){ 235 //report PLD response to PC 236 case transmit_PLD_answer: 237 Serial.println("PLD answered: "); 238 for (messageindex = 0; messageindex < 3; messageindex++){ 239 Serial.print(message[messageindex], BIN); 240 Serial.print( "\t" ); 241 } 242 Serial.println(" in BIN "); 243 for (messageindex = 0; messageindex < 3; messageindex++){ 244 Serial.print(message[messageindex], HEX); 245 Serial.print( "\t" ); 246 } 247 messageindex = 0; 248 Serial.println(" in HEX "); 249 Serial.println( "_______________________ " ); 250 pc_com = get_request; 251 break; 252 253 // Incoming Commands 254 case get_request: 255 while (Serial.available() < 3){}; 256 if (Serial.available() > 0){ 257 Serial.print("I received: "); 258 messageindex = 0; 259 while (messageindex < 3){ 260 message[messageindex] = Serial.read(); 261 Serial.print( "0x" ); 262 Serial.print(message[messageindex], HEX); 263 messageindex++; 264 Serial.print( " " ); 265 } 266 messageindex = 0; 267 //Serial.print(incommingByte, BYTE); 268 Serial.println(",du Nase!"); 269 } 270 state_controler = send_message; 271 break; 272 273 } 274 275 } 276 215 277 } 216 278
Note:
See TracChangeset
for help on using the changeset viewer.