Пример #1
0
/////////////////////////////////////////////////////////////////////////////
// Parser
/////////////////////////////////////////////////////////////////////////////
s32 CONSOLE_Parse(mios32_midi_port_t port, u8 byte)
{
  // temporary change debug port (will be restored at the end of this function)
  mios32_midi_port_t prev_debug_port = MIOS32_MIDI_DebugPortGet();
  MIOS32_MIDI_DebugPortSet(port);

  if( byte == '\r' ) {
    // ignore
  } else if( byte == '\n' ) {
    // example for parsing the command:
    char *separators = " \t";
    char *brkt;
    char *parameter;

    if( (parameter = strtok_r(line_buffer, separators, &brkt)) ) {
      if( strcmp(parameter, "help") == 0 ) {
	MIOS32_MIDI_SendDebugMessage("Welcome to " MIOS32_LCD_BOOT_MSG_LINE1 "!");
	MIOS32_MIDI_SendDebugMessage("Following commands are available:");
	MIOS32_MIDI_SendDebugMessage("  reset:          clears the current measurements\n");
	MIOS32_MIDI_SendDebugMessage("  help:           this page\n");
      } else if( strcmp(parameter, "reset") == 0 ) {
	MIOS32_IRQ_Disable();
	u8 including_min_max = 1;
	DelayInit(&d_tick, including_min_max);
	DelayInit(&d_measure, including_min_max);
	DelayInit(&d_beat, including_min_max);
	midi_clock_ctr = 0;
	total_delay = 0;
	MIOS32_IRQ_Enable();

	MIOS32_MIDI_SendDebugMessage("Measurements have been cleared!\n");
      } else {
	MIOS32_MIDI_SendDebugMessage("Unknown command - type 'help' to list available commands!\n");
      }
    }

    line_ix = 0;

  } else if( line_ix < (STRING_MAX-1) ) {
    line_buffer[line_ix++] = byte;
    line_buffer[line_ix] = 0;
  }

  // restore debug port
  MIOS32_MIDI_DebugPortSet(prev_debug_port);

  return 0; // no error
}
Пример #2
0
/////////////////////////////////////////////////////////////////////////////
// Receive a response from KissBox
/////////////////////////////////////////////////////////////////////////////
s32 TERMINAL_KissboxReceiveMsgPackage(mios32_midi_package_t p)
{
    if( p.type != 1 )
        return -1; // no message package

    u8 buffer[3];
    buffer[0] = p.evnt0;
    buffer[1] = p.evnt1;
    buffer[2] = p.evnt2;

    {
        int i;
        for(i=0; i<3; ++i) {
            // end of message string or max string size reached
            if( !buffer[i] || kissbox_line_ix >= (KISSBOX_STRING_MAX-1) ) {
                // temporary change debug port (will be restored at the end of this function)
                mios32_midi_port_t prev_debug_port = MIOS32_MIDI_DebugPortGet();
                MIOS32_MIDI_DebugPortSet(kissbox_debug_port);

                // -> send to MIOS terminal
                MIOS32_MIDI_SendDebugString(kissbox_line_buffer);

                // restore original debug port
                MIOS32_MIDI_DebugPortSet(prev_debug_port);

                // reset line buffer
                kissbox_line_buffer[0] = 0;
                kissbox_line_ix = 0;

                // terminate if 0 has been sent
                if( !buffer[i] )
                    break;
            } else {
                kissbox_line_buffer[kissbox_line_ix++] = buffer[i];
                kissbox_line_buffer[kissbox_line_ix] = 0;
            }
        }
    }

    return 0; // no error
}
Пример #3
0
/////////////////////////////////////////////////////////////////////////////
//! Parser
/////////////////////////////////////////////////////////////////////////////
s32 TERMINAL_Parse(mios32_midi_port_t port, char byte)
{
  // temporary change debug port (will be restored at the end of this function)
  mios32_midi_port_t prev_debug_port = MIOS32_MIDI_DebugPortGet();
  MIOS32_MIDI_DebugPortSet(port);

  if( byte == '\r' ) {
    // ignore
  } else if( byte == '\n' ) {
    MUTEX_MIDIOUT_TAKE;
    TERMINAL_ParseLine(line_buffer, MIOS32_MIDI_SendDebugMessage);
    MUTEX_MIDIOUT_GIVE;
    line_ix = 0;
    line_buffer[line_ix] = 0;
  } else if( line_ix < (STRING_MAX-1) ) {
    line_buffer[line_ix++] = byte;
    line_buffer[line_ix] = 0;
  }

  // restore debug port
  MIOS32_MIDI_DebugPortSet(prev_debug_port);

  return 0; // no error
}
Пример #4
0
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a MIDI package has been received
/////////////////////////////////////////////////////////////////////////////
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
{
  if( midi_package.type == NoteOn && midi_package.velocity > 0 ) {
    // change debug interface (where messages are forwarded)
    MIOS32_MIDI_DebugPortSet(port);

    // reset benchmark
    BENCHMARK_Reset();

    portENTER_CRITICAL(); // port specific FreeRTOS function to disable tasks (nested)

    // turn on LED (e.g. for measurements with a scope)
    MIOS32_BOARD_LED_Set(0xffffffff, 1);

    // reset stopwatch
    MIOS32_STOPWATCH_Reset();

    // start benchmark
    BENCHMARK_Start();

    // capture counter value
    benchmark_cycles = MIOS32_STOPWATCH_ValueGet();

    // turn off LED
    MIOS32_BOARD_LED_Set(0xffffffff, 0);

    portEXIT_CRITICAL(); // port specific FreeRTOS function to enable tasks (nested)

    // print result on MIOS terminal
    if( benchmark_cycles == 0xffffffff )
      MIOS32_MIDI_SendDebugMessage("Time: overrun!\n");
    else
      MIOS32_MIDI_SendDebugMessage("Time: %5d.%d mS\n", benchmark_cycles/10, benchmark_cycles%10);

    // print status screen
    print_msg = PRINT_MSG_STATUS;
  }
}
Пример #5
0
/////////////////////////////////////////////////////////////////////////////
// Parser
/////////////////////////////////////////////////////////////////////////////
s32 SEQ_TERMINAL_Parse(mios32_midi_port_t port, u8 byte)
{
  // temporary change debug port (will be restored at the end of this function)
  mios32_midi_port_t prev_debug_port = MIOS32_MIDI_DebugPortGet();
  MIOS32_MIDI_DebugPortSet(port);

  if( byte == '\r' ) {
    // ignore
  } else if( byte == '\n' ) {
    // example for parsing the command:
    char *separators = " \t";
    char *brkt;
    char *parameter;

    if( (parameter = strtok_r(line_buffer, separators, &brkt)) ) {
      if( strcmp(parameter, "help") == 0 ) {
	SEQ_TERMINAL_PrintHelp(DEBUG_MSG);
      } else if( strcmp(parameter, "system") == 0 ) {
	SEQ_TERMINAL_PrintSystem(DEBUG_MSG);
      } else if( strcmp(parameter, "global") == 0 ) {
	SEQ_TERMINAL_PrintGlobalConfig(DEBUG_MSG);
      } else if( strcmp(parameter, "bookmarks") == 0 ) {
	SEQ_TERMINAL_PrintBookmarks(DEBUG_MSG);
      } else if( strcmp(parameter, "config") == 0 ) {
	SEQ_TERMINAL_PrintSessionConfig(DEBUG_MSG);
      } else if( strcmp(parameter, "tracks") == 0 ) {
	SEQ_TERMINAL_PrintTracks(DEBUG_MSG);
      } else if( strcmp(parameter, "track") == 0 ) {
	  char *arg;
	  if( (arg = strtok_r(NULL, separators, &brkt)) ) {
	    int track = get_dec(arg);
	    if( track < 1 || track > SEQ_CORE_NUM_TRACKS ) {
	      MUTEX_MIDIOUT_TAKE;
	      DEBUG_MSG("Wrong track number %d - expected track 1..%d\n", track, SEQ_CORE_NUM_TRACKS);
	      MUTEX_MIDIOUT_GIVE;
	    } else {
	      SEQ_TERMINAL_PrintTrack(DEBUG_MSG, track-1);
	    }
	  } else {
	    MUTEX_MIDIOUT_TAKE;
	    DEBUG_MSG("Please specify track, e.g. \"track 1\"\n");
	    MUTEX_MIDIOUT_GIVE;
	  }
      } else if( strcmp(parameter, "mixer") == 0 ) {
	SEQ_TERMINAL_PrintCurrentMixerMap(DEBUG_MSG);
      } else if( strcmp(parameter, "song") == 0 ) {
	SEQ_TERMINAL_PrintCurrentSong(DEBUG_MSG);
      } else if( strcmp(parameter, "grooves") == 0 ) {
	SEQ_TERMINAL_PrintGrooveTemplates(DEBUG_MSG);
      } else if( strcmp(parameter, "memory") == 0 ) {
	SEQ_TERMINAL_PrintMemoryInfo(DEBUG_MSG);
#if !defined(MIOS32_FAMILY_EMULATION)
      } else if( strcmp(parameter, "network") == 0 ) {
	SEQ_TERMINAL_PrintNetworkInfo(DEBUG_MSG);
      } else if( strcmp(parameter, "udpmon") == 0 ) {
	MUTEX_MIDIOUT_TAKE;
	char *arg;
	if( (arg = strtok_r(NULL, separators, &brkt)) ) {
	  int level = get_dec(arg);
	  switch( level ) {
	  case UDP_MONITOR_LEVEL_0_OFF:
	    DEBUG_MSG("Set UDP monitor level to %d (off)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_1_OSC_REC:
	    DEBUG_MSG("Set UDP monitor level to %d (received packets assigned to a OSC1..4 port)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_2_OSC_REC_AND_SEND:
	    DEBUG_MSG("Set UDP monitor level to %d (received and sent packets assigned to a OSC1..4 port)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_3_ALL_GEQ_1024:
	    DEBUG_MSG("Set UDP monitor level to %d (all received and sent packets with port number >= 1024)\n", level);
	    break;
	  case UDP_MONITOR_LEVEL_4_ALL:
	    DEBUG_MSG("Set UDP monitor level to %d (all received and sent packets)\n", level);
	    break;
	  default:
	    DEBUG_MSG("Invalid level %d - please specify monitor level 0..4\n", level);
	    level = -1; // invalidate level for next if() check
	  }

	  if( level >= 0 )
	    UIP_TASK_UDP_MonitorLevelSet(level);
	} else {
	  DEBUG_MSG("Please specify monitor level (0..4)\n");
	}
	MUTEX_MIDIOUT_GIVE;
#endif
      } else if( strcmp(parameter, "sdcard") == 0 ) {
	SEQ_TERMINAL_PrintSdCardInfo(DEBUG_MSG);
      } else if( strcmp(parameter, "testaoutpin") == 0 ) {
	char *arg;
	int pin_number = -1;
	int level = -1;

	if( (arg = strtok_r(NULL, separators, &brkt)) ) {
	  if( strcmp(arg, "cs") == 0 )
	    pin_number = 1;
	  else if( strcmp(arg, "si") == 0 )
	    pin_number = 2;
	  else if( strcmp(arg, "sc") == 0 )
	    pin_number = 3;
	  else if( strcmp(arg, "reset") == 0 ) {
	    pin_number = 0;
	    level = 0; // dummy
	  }
	}

	if( pin_number < 0 ) {
	  MUTEX_MIDIOUT_TAKE;
	  DEBUG_MSG("Please specifiy valid AOUT pin name: cs, si or sc\n");
	  MUTEX_MIDIOUT_GIVE;
	} else {
	  if( (arg = strtok_r(NULL, separators, &brkt)) )
	    level = get_dec(arg);

	  if( level != 0 && level != 1 ) {
	    MUTEX_MIDIOUT_TAKE;
	    DEBUG_MSG("Please specifiy valid logic level for AOUT pin: 0 or 1\n");
	    MUTEX_MIDIOUT_GIVE;
	  }
	}

	if( pin_number >= 0 && level >= 0 ) {
	  SEQ_TERMINAL_TestAoutPin(DEBUG_MSG, pin_number, level);
	} else {
	  MUTEX_MIDIOUT_TAKE;
	  DEBUG_MSG("Following commands are supported:\n");
	  DEBUG_MSG("testaoutpin cs 0  -> sets AOUT:CS to 0.4V");
	  DEBUG_MSG("testaoutpin cs 1  -> sets AOUT:CS to ca. 4V");
	  DEBUG_MSG("testaoutpin si 0  -> sets AOUT:SI to ca. 0.4V");
	  DEBUG_MSG("testaoutpin si 1  -> sets AOUT:SI to ca. 4V");
	  DEBUG_MSG("testaoutpin sc 0  -> sets AOUT:SC to ca. 0.4V");
	  DEBUG_MSG("testaoutpin sc 1  -> sets AOUT:SC to ca. 4V");
	  DEBUG_MSG("testaoutpin reset -> re-initializes AOUT module so that it can be used again.");
	  MUTEX_MIDIOUT_GIVE;
	}
      } else if( strcmp(parameter, "play") == 0 ) {
	SEQ_UI_Button_Play(0);
	MUTEX_MIDIOUT_TAKE;
	DEBUG_MSG("Sequencer started...\n");
	MUTEX_MIDIOUT_GIVE;
      } else if( strcmp(parameter, "stop") == 0 ) {
	SEQ_UI_Button_Stop(0);
	MUTEX_MIDIOUT_TAKE;
	DEBUG_MSG("Sequencer stopped...\n");
	MUTEX_MIDIOUT_GIVE;
      } else if( strcmp(parameter, "reset") == 0 ) {
	MIOS32_SYS_Reset();
      } else {
	MUTEX_MIDIOUT_TAKE;
	DEBUG_MSG("Unknown command - type 'help' to list available commands!\n");
	MUTEX_MIDIOUT_GIVE;
      }
    }

    line_ix = 0;

  } else if( line_ix < (STRING_MAX-1) ) {
    line_buffer[line_ix++] = byte;
    line_buffer[line_ix] = 0;
  }

  // restore debug port
  MIOS32_MIDI_DebugPortSet(prev_debug_port);

  return 0; // no error
}