This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
acsim_mios_c [2006/12/05 13:58] audiocommander improved output of special chars |
acsim_mios_c [2007/11/17 16:46] (current) smashtv move acsim.zip to "acsim" namespace |
||
---|---|---|---|
Line 3: | Line 3: | ||
[[acsim_console_h|ACSim_console.h]]\\ | [[acsim_console_h|ACSim_console.h]]\\ | ||
[[acsim_console_c|ACSim_console.c]]\\ | [[acsim_console_c|ACSim_console.c]]\\ | ||
- | |||
- | [[acsim_toolbox_h|ACSim_toolbox.h]]\\ | ||
- | [[acsim_toolbox_c|ACSim_toolbox.c]]\\ | ||
[[acsim_mios_h|ACSim_mios.h]]\\ | [[acsim_mios_h|ACSim_mios.h]]\\ | ||
**[[acsim_mios_c|ACSim_mios.c]]**\\ | **[[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:acsim.zip}}. If you make any updates, please send them to stryd_one and he will update the zip for you. | ||
+ | \\ | ||
\\ | \\ | ||
<code c> | <code c> | ||
/* | /* | ||
* ACSim_mios.c | * ACSim_mios.c | ||
- | * v 0.0.5 | + | * v 0.0.7 |
* | * | ||
* 2006 April 06 Created by Michael Markert, http://www.audiocommander.de | * 2006 April 06 Created by Michael Markert, http://www.audiocommander.de | ||
Line 30: | Line 33: | ||
* YOU ARE ALLOWED TO COPY AND CHANGE | * YOU ARE ALLOWED TO COPY AND CHANGE | ||
* BUT YOU MUST RELEASE THE SOURCE TOO (UNDER GNU GPL) IF YOU RELEASE YOUR PRODUCT | * BUT YOU MUST RELEASE THE SOURCE TOO (UNDER GNU GPL) IF YOU RELEASE YOUR PRODUCT | ||
- | * YOU ARE NOT ALLOWED NOT USE IT WITHIN PROPRIETARY CLOSED-SOURCE PROJECTS | + | * YOU ARE NOT ALLOWED TO USE IT WITHIN PROPRIETARY CLOSED-SOURCE PROJECTS |
*/ | */ | ||
Line 36: | Line 39: | ||
#import <Stdio.h> | #import <Stdio.h> | ||
+ | #import "ACMidiDefines.h" | ||
#import "ACSim_mios.h" | #import "ACSim_mios.h" | ||
- | |||
#import "ACSim_toolbox.h" | #import "ACSim_toolbox.h" | ||
Line 44: | Line 47: | ||
#pragma mark Globals | #pragma mark Globals | ||
// globals | // globals | ||
+ | debug_user_timer_t debug_user_timer; | ||
+ | |||
unsigned char debug_ain_lastPin; | unsigned char debug_ain_lastPin; | ||
unsigned int debug_ain_value[32]; | unsigned int debug_ain_value[32]; | ||
Line 49: | Line 54: | ||
unsigned char debug_din_value[32]; | unsigned char debug_din_value[32]; | ||
unsigned int debug_enc_value[32]; | unsigned int debug_enc_value[32]; | ||
+ | |||
+ | unsigned int debug_MIDI_byteNum = 0; | ||
+ | unsigned int debug_IIC_byteNum = 0; | ||
unsigned char debug_bankstick_ctrl = 0x00; // 1st Bankstick preselected | unsigned char debug_bankstick_ctrl = 0x00; // 1st Bankstick preselected | ||
Line 56: | Line 64: | ||
__PORTCbits_t PORTCbits; | __PORTCbits_t PORTCbits; | ||
__PORTDbits_t PORTDbits; | __PORTDbits_t PORTDbits; | ||
+ | __INTCONbits_t INTCONbits; | ||
mios_box_stat_t MIOS_BOX_STAT; | mios_box_stat_t MIOS_BOX_STAT; | ||
// HLP | // HLP | ||
Line 134: | Line 143: | ||
extern void MIOS_LCD_PrintBCD2(unsigned char v) { printf("%2.2i",v); } | extern void MIOS_LCD_PrintBCD2(unsigned char v) { printf("%2.2i",v); } | ||
extern void MIOS_LCD_PrintBCD3(unsigned char v) { printf("%3.3i",v); } | extern void MIOS_LCD_PrintBCD3(unsigned char v) { printf("%3.3i",v); } | ||
- | extern void MIOS_LCD_PrintBCD4(unsigned int v) { printf("%i",v); } | + | extern void MIOS_LCD_PrintBCD4(unsigned int v) { printf("%4.4i",v); } |
- | extern void MIOS_LCD_PrintBCD5(unsigned int v) { printf("%i",v); } | + | extern void MIOS_LCD_PrintBCD5(unsigned int v) { printf("%5.5i",v); } |
extern void MIOS_LCD_PrintChar(unsigned char c) { | extern void MIOS_LCD_PrintChar(unsigned char c) { | ||
switch(c) { | switch(c) { | ||
Line 181: | Line 190: | ||
return 0; // no error | return 0; // no error | ||
} | } | ||
- | |||
- | |||
// MIOS_BANKSTICK | // MIOS_BANKSTICK | ||
Line 241: | Line 248: | ||
#pragma mark MIOS_MIDI | #pragma mark MIOS_MIDI | ||
// MIOS_MIDI | // MIOS_MIDI | ||
- | extern void MIOS_MIDI_BeginStream(void) { printf("\n**MIOS_MIDI_BeginStream**"); } | + | extern void MIOS_MIDI_BeginStream(void) { |
- | extern void MIOS_MIDI_TxBufferPut(unsigned char b) { printf("\n**MIOS_MIDI_TxBufferPut, %i", b); } | + | printf("\n**MIOS_MIDI_BeginStream**"); |
+ | debug_MIDI_byteNum = 0; | ||
+ | } | ||
+ | extern void MIOS_MIDI_TxBufferPut(unsigned char b) { | ||
+ | unsigned char ch; | ||
+ | printf("\n**MIOS_MIDI_TxBufferPut, %i", b); | ||
+ | debug_MIDI_byteNum++; | ||
+ | #if DEBUG_MIDI_VERBOSE | ||
+ | switch(debug_MIDI_byteNum) { | ||
+ | case 1: | ||
+ | // Channel Voice | ||
+ | ch = (b & 0x0f) + 1; | ||
+ | if( (b>=MIDI_NOTE_OFF) && (b<MIDI_NOTE_ON) ) { printf("\t\t\tMIDI_NOTE_OFF, CH %i",ch); } | ||
+ | if( (b>=MIDI_NOTE_ON) && (b<MIDI_POLY_AFTER) ) { printf("\t\t\tMIDI_NOTE_ON, CH %i",ch); } | ||
+ | if( (b>=MIDI_POLY_AFTER) && (b<MIDI_CC) ) { printf("\t\t\tMIDI_POLY_AFTER, CH %i",ch); } | ||
+ | if( (b>=MIDI_CC) && (b<MIDI_PRG) ) { printf("\t\t\tMIDI_CC, CH %i",ch); } | ||
+ | if( (b>=MIDI_PRG) && (b<MIDI_CH_AFTER) ) { printf("\t\t\tMIDI_PRG, CH %i",ch); } | ||
+ | if( (b>=MIDI_CH_AFTER) && (b<MIDI_PITCH) ) { printf("\t\t\tMIDI_CH_AFTER, CH %i",ch); } | ||
+ | if( (b>=MIDI_PITCH) && (b<MIDI_SYSEX) ) { printf("\t\t\tMIDI_NOTE_OFF, CH %i",ch); } | ||
+ | // System Common | ||
+ | if( (b==MIDI_SYSEX) ) { printf("\t\t\tMIDI_SYSEX"); } | ||
+ | if( (b==MIDI_TIMECODE) ) { printf("\t\t\tMIDI_TIMECODE"); } | ||
+ | if( (b==MIDI_SONG_POSITION_POINTER) ) { printf("\t\t\tMIDI_SONG_POSITION_POINTER"); } | ||
+ | if( (b==MIDI_SONG_SELECT) ) { printf("\t\t\tMIDI_SONG_SELECT"); } | ||
+ | if( (b==MIDI_TUNE_REQUEST) ) { printf("\t\t\tMIDI_TUNE_REQUEST"); } | ||
+ | if( (b==MIDI_EOX) ) { printf("\t\t\tMIDI_END_OF_SYSEX"); } | ||
+ | // System Realtime | ||
+ | if( (b==MIDI_CLOCK) ) { printf("\t\t\tMIDI_CLOCK"); } | ||
+ | if( (b==MIDI_START) ) { printf("\t\t\tMIDI_START"); } | ||
+ | if( (b==MIDI_CONTINUE) ) { printf("\t\t\tMIDI_CONTINUE"); } | ||
+ | if( (b==MIDI_STOP) ) { printf("\t\t\tMIDI_STOP"); } | ||
+ | if( (b==MIDI_ACTIVE_SENSING) ) { printf("\t\t\tMIDI_ACTIVE_SENSING"); } | ||
+ | if( (b==MIDI_RESET) ) { printf("\t\t\tMIDI_RESET"); } | ||
+ | break; | ||
+ | case 2: | ||
+ | case 3: | ||
+ | printf("\t\t\tMIDI_PARAM (BYTE #%i)", b); | ||
+ | break; | ||
+ | } | ||
+ | // reset counter for System Realtime Bytes | ||
+ | if(b >= MIDI_CLOCK) { debug_MIDI_byteNum = 0; } | ||
+ | #endif | ||
+ | } | ||
extern void MIOS_MIDI_EndStream(void) { | extern void MIOS_MIDI_EndStream(void) { | ||
- | printf("\n**MIOS_MIDI_EndStream**"); | + | debug_MIDI_byteNum = 0; |
+ | printf("\n**MIOS_MIDI_EndStream**"); | ||
} | } | ||
Line 268: | Line 318: | ||
extern unsigned char MIOS_MIDI_TxBufferUsed(void) __wparam; | extern unsigned char MIOS_MIDI_TxBufferUsed(void) __wparam; | ||
*/ | */ | ||
- | |||
#pragma mark MIOS_TIMER | #pragma mark MIOS_TIMER | ||
// MIOS_TIMER | // MIOS_TIMER | ||
- | extern void MIOS_TIMER_Init(unsigned char mode, unsigned int period) { return; } | + | extern void MIOS_TIMER_Init(unsigned char mode, unsigned int period) { |
+ | debug_user_timer.TIMER_ENABLED = TRUE; | ||
+ | return; | ||
+ | } | ||
extern void MIOS_TIMER_Start(void) { return; } | extern void MIOS_TIMER_Start(void) { return; } | ||
- | extern void MIOS_TIMER_Stop(void) { return; } | + | extern void MIOS_TIMER_Stop(void) { |
- | extern void MIOS_TIMER_ReInit(unsigned char mode, unsigned int period) { return; } | + | debug_user_timer.TIMER_ENABLED = FALSE; |
+ | return; | ||
+ | } | ||
+ | extern void MIOS_TIMER_ReInit(unsigned char mode, unsigned int period) { | ||
+ | MIOS_TIMER_Init(mode, period); | ||
+ | return; | ||
+ | } | ||
#pragma mark MIOS_IIC | #pragma mark MIOS_IIC | ||
// MIOS_IIC | // MIOS_IIC | ||
- | extern void MIOS_IIC_Start(void) { printf("\n**MIOS_IIC_Start**"); } | + | extern void MIOS_IIC_Start(void) { |
- | extern void MIOS_IIC_Stop(void) { printf("\n**MIOS_IIC_Stop**"); } | + | debug_IIC_byteNum = 0; |
+ | printf("\n**MIOS_IIC_Start**"); | ||
+ | } | ||
+ | extern void MIOS_IIC_Stop(void) { | ||
+ | printf("\n**MIOS_IIC_Stop**"); | ||
+ | } | ||
extern unsigned char MIOS_IIC_ByteSend(unsigned char b) { | extern unsigned char MIOS_IIC_ByteSend(unsigned char b) { | ||
- | printf("\n**MIOS_IIC_ByteSend: %x \t %i \t %c", b, b, b); | + | printf("\n**MIOS_IIC_ByteSend: 0x%x \t %i \t %c", b, b, b); |
+ | #if DEBUG_SPEAKJET_VERBOSE | ||
+ | if(debug_IIC_byteNum == 1) { | ||
+ | // MSA controls | ||
+ | switch(b) { | ||
+ | case 0: case 1: case 2: case 3: case 4: case 5: case 6: printf(" \t MSA_PAUSE"); break; | ||
+ | case 7: printf(" \t MSA_NEXTFAST"); break; | ||
+ | case 8: printf(" \t MSA_NEXTSLOW"); break; | ||
+ | case 14: printf(" \t MSA_NEXTHIGH"); break; | ||
+ | case 15: printf(" \t MSA_NEXTLOW"); break; | ||
+ | case 16: printf(" \t MSA_WAIT"); break; | ||
+ | case 20: printf(" \t MSA_VOLUME"); break; | ||
+ | |||
+ | case 21: printf(" \t MSA_SPEED"); break; | ||
+ | case 22: printf(" \t MSA_PITCH"); break; | ||
+ | case 23: printf(" \t MSA_BEND"); break; | ||
+ | case 24: printf(" \t MSA_PORTCTR"); break; | ||
+ | case 25: printf(" \t MSA_PORT"); break; | ||
+ | case 26: printf(" \t MSA_REPEAT"); break; | ||
+ | |||
+ | case 28: printf(" \t MSA_CALLPHRASE"); break; | ||
+ | case 29: printf(" \t MSA_GOTOPHRASE"); break; | ||
+ | case 30: printf(" \t MSA_DELAY"); break; | ||
+ | case 31: printf(" \t MSA_RESET"); break; | ||
+ | |||
+ | default: | ||
+ | if(b > 127) { | ||
+ | if(b < 200) { | ||
+ | printf(" \t MSA_SOUNDCODE_PHONEME"); | ||
+ | } else if(b < 255) { | ||
+ | printf(" \t MSA_SOUNDCODE_FX"); | ||
+ | } else { | ||
+ | printf(" \t MSA unknown: %i", b); | ||
+ | } | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | // SCP controls | ||
+ | switch(b) { | ||
+ | case SCP_ESCAPE: printf(" \t --- ENTER SCP MODE ---"); break; | ||
+ | case SCP_EXIT: printf(" \t --- LEAVE SCP MODE ___"); break; | ||
+ | case SCP_READY: printf(" \t READY"); break; | ||
+ | case SCP_CLEAR_BUFFER: printf(" \t CLEAR BUFFER"); break; | ||
+ | case SCP_START: printf(" \t START"); break; | ||
+ | case SCP_STOP: printf(" \t STOP"); break; | ||
+ | case SCP_MEMTYPE: printf(" \t ^ MEMTYPE (REG:0 EEPROM_L:2 EEPROM_H:3)"); break; | ||
+ | case SCP_MEMADDR: printf(" \t ^ MEMADDR (freq:1-5 lvl:11-15 dist:6, vol:7)"); break; | ||
+ | case SCP_MEMWRT: printf(" \t ^ STORED"); break; | ||
+ | case SCP_RESET: printf(" \t RESET"); break; | ||
+ | } | ||
+ | #endif | ||
+ | debug_IIC_byteNum++; | ||
return 1; | return 1; | ||
} | } |