acsim_console_c
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| acsim_console_c [2006/09/01 11:27] – added MIOS_BOX_STAT.BS_AVAILABLE to Init( ) zeichensprecher | acsim_console_c [2007/11/17 16:46] (current) – Corrected zip file text smashtv | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | This page is part of the [[mios_c_simulator_-_debugger]] | ||
| + | [[acsim_console_h|ACSim_console.h]]\\ | ||
| + | **[[acsim_console_c|ACSim_console.c]]**\\ | ||
| + | |||
| + | [[acsim_mios_h|ACSim_mios.h]]\\ | ||
| + | [[acsim_mios_c|ACSim_mios.c]]\\ | ||
| + | |||
| + | [[acsim_toolbox_h|ACSim_toolbox.h]]\\ | ||
| + | [[acsim_toolbox_c|ACSim_toolbox.c]]\\ | ||
| + | [[acmididefines|ACMidiDefines.h]]\\ | ||
| + | \\ | ||
| + | This code is for viewing only and may not be up to date. You can download the files in a zip file {{acsim: | ||
| + | \\ | ||
| + | \\ | ||
| + | <code c> | ||
| + | /* | ||
| + | | ||
| + | | ||
| + | * | ||
| + | | ||
| + | */ | ||
| + | |||
| + | |||
| + | |||
| + | // import standard I/O headers for console in- and output (printf and scanf) | ||
| + | #import < | ||
| + | |||
| + | |||
| + | #ifdef _DEBUG_OS_MAC | ||
| + | #import < | ||
| + | #endif | ||
| + | |||
| + | |||
| + | // ACSim_mios.c contains all MIOS_FUNCTIONS() that are used throughout the program | ||
| + | // eg MIOS_MIDI_AIN_PinGet(0) returns some random numbers in a range 0..127 | ||
| + | // open up ACSim_mios.c to tweak around some values... | ||
| + | // normally there should be no need to change the content of these files: | ||
| + | #import " | ||
| + | |||
| + | // toolbox, handy functions like random number generation, hex-output... | ||
| + | #import " | ||
| + | |||
| + | |||
| + | // import c files that are included in " | ||
| + | //#include " | ||
| + | |||
| + | // import main c source file | ||
| + | #include " | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | // ***** RUNLOOP ***** | ||
| + | |||
| + | void runloop(int loopcount) { | ||
| + | _Bool continueRunloop = TRUE; | ||
| + | char str[64] = ""; | ||
| + | char choice = ' | ||
| + | unsigned char c = 0; | ||
| + | unsigned int i; | ||
| + | unsigned int pin = 0; | ||
| + | unsigned int value = 0; | ||
| + | unsigned int value2 = 0; | ||
| + | // poll Timer() | ||
| + | if(debug_user_timer.TIMER_ENABLED) { | ||
| + | Timer(); | ||
| + | } | ||
| + | // poll Tick() | ||
| + | Tick(); | ||
| + | // poll LCD_Display | ||
| + | DISPLAY_Tick(); | ||
| + | // debug info | ||
| + | printf(" | ||
| + | // read input | ||
| + | fgets(str, 32, stdin); // MAX chars = 32; this is NOT protected against buffer overflows!!! | ||
| + | choice = str[0]; | ||
| + | switch (choice) { | ||
| + | |||
| + | case ' | ||
| + | case ' | ||
| + | continueRunloop = FALSE; | ||
| + | break; | ||
| + | |||
| + | case ' ': // OK | ||
| + | debug_din_value[DEBUG_BUTTON_OK] = 0; | ||
| + | DIN_NotifyToggle(DEBUG_BUTTON_OK, | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | for(i=0; | ||
| + | ENC_NotifyChange(DEBUG_ENCODER, | ||
| + | break; | ||
| + | case ' | ||
| + | for(i=0; | ||
| + | ENC_NotifyChange(DEBUG_ENCODER, | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | if((pin > DEBUG_AIN_NUM) || (value > 1023)) { | ||
| + | printf(" | ||
| + | pin = 0; value = 0; | ||
| + | } else { | ||
| + | printf(" | ||
| + | // " | ||
| + | debug_ain_value[pin] = value; | ||
| + | AIN_NotifyChange(pin, | ||
| + | } | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | debug_MIDI_byteNum = 0; // sending single byte, maybe without MIDI_START/ | ||
| + | sscanf(str, | ||
| + | MPROC_NotifyReceivedByte(pin); | ||
| + | debug_MIDI_byteNum = 0; | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | // invert value for easier rememberance | ||
| + | value = value ^ 0x1; | ||
| + | debug_din_value[pin] = value; | ||
| + | DIN_NotifyToggle(pin, | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | if(pin > DEBUG_ENC_NUM) { | ||
| + | printf(" | ||
| + | return; | ||
| + | } | ||
| + | for(i=3; | ||
| + | if(str[i]==' | ||
| + | c++; | ||
| + | } else if(str[i]==' | ||
| + | c--; | ||
| + | } | ||
| + | } | ||
| + | ENC_NotifyChange(pin, | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | switch(pin) { | ||
| + | case 10: | ||
| + | PORTCbits.RC5 = 1; | ||
| + | Timer(); | ||
| + | PORTCbits.RC5 = 0; | ||
| + | Timer(); | ||
| + | break; | ||
| + | case 14: | ||
| + | PORTDbits.RD4 = 1; | ||
| + | Timer(); | ||
| + | PORTDbits.RD4 = 0; | ||
| + | Timer(); | ||
| + | break; | ||
| + | default: | ||
| + | printf(" | ||
| + | break; | ||
| + | } | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | MPROC_NotifyReceivedEvnt(pin, | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | if((value2 < 1) || (value2 > 16)) { value2 = 1; } | ||
| + | MPROC_NotifyReceivedEvnt((143+value2), | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | pin = ACRandomPin(); | ||
| + | value = ACRandomInt(); | ||
| + | printf(" | ||
| + | // " | ||
| + | debug_ain_value[pin] = value; | ||
| + | AIN_NotifyChange(pin, | ||
| + | break; | ||
| + | |||
| + | case ' | ||
| + | sscanf(str, | ||
| + | // for example: | ||
| + | // | ||
| + | // | ||
| + | break; | ||
| + | |||
| + | default: | ||
| + | // nothing... | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | if(continueRunloop) { | ||
| + | runloop(++loopcount); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | // ***** MAIN ***** | ||
| + | int main(int argc, char **argv) { | ||
| + | int exit_code = 0; | ||
| + | |||
| + | // manual: | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | |||
| + | // init debug | ||
| + | srandomdev(); | ||
| + | |||
| + | // init MIOS | ||
| + | MIOS_BOX_STAT.BS_AVAILABLE = 1; | ||
| + | Init(); | ||
| + | DISPLAY_Init(); | ||
| + | |||
| + | printf(" | ||
| + | |||
| + | // runloop | ||
| + | runloop(0); | ||
| + | |||
| + | return exit_code; | ||
| + | } | ||
| + | |||
| + | |||
| + | </ | ||
