Esempio n. 1
0
/////////////////////////////////////////////////////////////////////////////
//! Initialises a DIO port
/////////////////////////////////////////////////////////////////////////////
s32 MBNG_DIO_PortInit(u8 port, mios32_board_pin_mode_t mode)
{
#if MBNG_PATCH_NUM_DIO == 0
  return -1; // not supported
#else
  switch( port ) {
  case 0: {
    int i;
    for(i=0; i<8; ++i)
      MIOS32_BOARD_J10_PinInit(i, mode);
  } break;

  case 1: {
    int i;
#if defined(MIOS32_FAMILY_STM32F4xx)
    for(i=8; i<16; ++i)
      MIOS32_BOARD_J10_PinInit(i, mode);
#elif defined(MIOS32_FAMILY_LPC17xx)
    for(i=0; i<8; ++i)
      MIOS32_BOARD_J28_PinInit(i, mode);
#else
# error "Please adapt J10B port assignments here"
#endif
  } break;

  default:
    return -1; // invalid port
#if MBNG_PATCH_NUM_DIO > 2
# error "Add pin init function here"
#endif
  }

  return 0; // no error
#endif
}
Esempio n. 2
0
/////////////////////////////////////////////////////////////////////////////
// This hook is called after startup to initialize the application
/////////////////////////////////////////////////////////////////////////////
void APP_Init(void)
{
  // initialize all LEDs
  MIOS32_BOARD_LED_Init(0xffffffff);

  // create semaphores
  xSDCardSemaphore = xSemaphoreCreateRecursiveMutex();

  // initialize the Notestack
  NOTESTACK_Init(&notestack, NOTESTACK_MODE_PUSH_TOP, &notestack_items[0], NOTESTACK_SIZE);

  // init Synth
  SYNTH_Init(0);

  // initialize all J10 pins as inputs with internal Pull-Up
  int pin;
  for(pin=0; pin<8; ++pin)
    MIOS32_BOARD_J10_PinInit(pin, MIOS32_BOARD_PIN_MODE_INPUT_PU);

  // initialize Standard Control Surface
  SCS_Init(0);

  // initialize local SCS configuration
  SCS_CONFIG_Init(0);

  // initialize file system
  SYNTH_FILE_Init(0);

  // start task
  xTaskCreate(TASK_Periodic_1mS, (signed portCHAR *)"Periodic_1mS", configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIODIC_1MS, NULL);
  xTaskCreate(TASK_Period_1mS_LP, (signed portCHAR *)"1mS_LP", configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIOD_1mS_LP, NULL);
}
Esempio n. 3
0
/////////////////////////////////////////////////////////////////////////////
//! Initializes the BLM_CHEAPO driver
//! Should be called from Init() during startup
//! \param[in] mode currently only mode 0 supported
//! \return < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 BLM_CHEAPO_Init(u32 mode)
{
  if( mode != 0 )
    return -1; // only mode 0 supported

  // initialize J15 pins for open drain mode
  MIOS32_BOARD_J15_PortInit(1);

  // initialize all J10 pins as inputs with internal Pull-Up
  int pin;
  for(pin=0; pin<8; ++pin)
    MIOS32_BOARD_J10_PinInit(pin, MIOS32_BOARD_PIN_MODE_INPUT_PU);

  // initialize all pins of J5A and J5B as outputs in Push-Pull Mode
  for(pin=0; pin<8; ++pin)
    MIOS32_BOARD_J5_PinInit(pin, MIOS32_BOARD_PIN_MODE_OUTPUT_PP);

  int row;
  for(row=0; row<NUM_ROWS; ++row) {
    button_row[row] = 0xff;
    button_row_changed[row] = 0x00;
  }

  selected_row = 0;
  button_debounce_ctr = 0;
  button_debounce_reload = 10; // mS

  return 0; // no error
}
Esempio n. 4
0
/////////////////////////////////////////////////////////////////////////////
// initializes the synth
/////////////////////////////////////////////////////////////////////////////
s32 SYNTH_Init(u32 mode)
{
  // use J10A.D0 for performance measurements
  MIOS32_BOARD_J10_PinInit(0, MIOS32_BOARD_PIN_MODE_OUTPUT_PP);

  // start I2S DMA transfers
  return MIOS32_I2S_Start((u32 *)&sample_buffer[0], SAMPLE_BUFFER_SIZE, &SYNTH_ReloadSampleBuffer);
}
Esempio n. 5
0
/////////////////////////////////////////////////////////////////////////////
// Initializes application specific LCD driver
// IN: <mode>: optional configuration
// OUT: returns < 0 if initialisation failed
/////////////////////////////////////////////////////////////////////////////
s32 APP_LCD_Init(u32 mode)
{
  // currently only mode 0 supported
  if( mode != 0 )
    return -1; // unsupported mode

  if( MIOS32_BOARD_J15_PortInit(APP_LCD_OUTPUT_MODE) < 0 )
    return -2; // failed to initialize J15

#if APP_LCD_USE_J10_FOR_CS
  int pin;
  for(pin=0; pin<8; ++pin)
    MIOS32_BOARD_J10_PinInit(pin, APP_LCD_OUTPUT_MODE ? MIOS32_BOARD_PIN_MODE_OUTPUT_OD : MIOS32_BOARD_PIN_MODE_OUTPUT_PP);
#endif

  // set LCD type
  mios32_lcd_type = MIOS32_LCD_TYPE_GLCD;

  // initialize LCD
  APP_LCD_Cmd(0xa8); // Set MUX Ratio
  APP_LCD_Cmd(0x3f);

  APP_LCD_Cmd(0xd3); // Set Display Offset
  APP_LCD_Cmd(0x00);

  APP_LCD_Cmd(0x40); // Set Display Start Line

  APP_LCD_Cmd(0xa0); // Set Segment re-map

  APP_LCD_Cmd(0xc0); // Set COM Output Scan Direction

  APP_LCD_Cmd(0xda); // Set COM Pins hardware configuration
  APP_LCD_Cmd(0x12);

  APP_LCD_Cmd(0x81); // Set Contrast Control
  APP_LCD_Cmd(0x7f); // middle

  APP_LCD_Cmd(0xa4); // Disable Entiere Display On

  APP_LCD_Cmd(0xa6); // Set Normal Display

  APP_LCD_Cmd(0xd5); // Set OSC Frequency
  APP_LCD_Cmd(0x80);

  APP_LCD_Cmd(0x8d); // Enable charge pump regulator
  APP_LCD_Cmd(0x14);

  APP_LCD_Cmd(0xaf); // Display On

  APP_LCD_Cmd(0x20); // Enable Page mode
  APP_LCD_Cmd(0x02);

  return (display_available & (1 << mios32_lcd_device)) ? 0 : -1; // return -1 if display not available
}
Esempio n. 6
0
/////////////////////////////////////////////////////////////////////////////
//! This hook is called after startup to initialize the application
/////////////////////////////////////////////////////////////////////////////
void APP_Init(void)
{
  // initialize all LEDs
  MIOS32_BOARD_LED_Init(0xffffffff);

  // initialize stopwatch for measuring delays
  MIOS32_STOPWATCH_Init(100);

  // hardware will be enabled once configuration has been loaded from SD Card
  // (resp. no SD Card is available)
  hw_enabled = 0;

  // only print error messages by default
  debug_verbose_level = DEBUG_VERBOSE_LEVEL_ERROR;

  // disable MSD by default (has to be enabled in SHIFT menu)
  msd_state = MSD_DISABLED;

  // hardware will be enabled once configuration has been loaded from SD Card
  // (resp. no SD Card is available)
  hw_enabled = 0;

  // initialize all J10 pins as inputs with internal Pull-Up
  int pin;
  for(pin=0; pin<8; ++pin)
    MIOS32_BOARD_J10_PinInit(pin, MIOS32_BOARD_PIN_MODE_INPUT_PU);

  // initialize LCDs
  MBNG_LCD_Init(0);

  // initialize the AINSER module(s)
  AINSER_Init(0);

  // initialize the AOUT module(s)
  AOUT_Init(0);

  // create semaphores
  xSDCardSemaphore = xSemaphoreCreateRecursiveMutex();
  xMIDIINSemaphore = xSemaphoreCreateRecursiveMutex();
  xMIDIOUTSemaphore = xSemaphoreCreateRecursiveMutex();
  xLCDSemaphore = xSemaphoreCreateRecursiveMutex();
  xJ16Semaphore = xSemaphoreCreateRecursiveMutex();

  // install SysEx callback
  MIOS32_MIDI_SysExCallback_Init(APP_SYSEX_Parser);

  // install MIDI Rx/Tx callback functions
  MIOS32_MIDI_DirectRxCallback_Init(&NOTIFY_MIDI_Rx);
  MIOS32_MIDI_DirectTxCallback_Init(&NOTIFY_MIDI_Tx);

  // install timeout callback function
  MIOS32_MIDI_TimeOutCallback_Init(&NOTIFY_MIDI_TimeOut);

  // initialize code modules
  MIDI_PORT_Init(0);
  MBNG_SYSEX_Init(0);
  MIDI_ROUTER_Init(0);
  MBNG_EVENT_Init(0);
  MBNG_DIN_Init(0);
  MBNG_DOUT_Init(0);
  MBNG_ENC_Init(0);
  MBNG_MF_Init(0);
  MBNG_AIN_Init(0);
  MBNG_AINSER_Init(0);
  MBNG_CV_Init(0);
  MBNG_KB_Init(0);
  MBNG_MATRIX_Init(0);
  UIP_TASK_Init(0);
  SCS_Init(0);
  SCS_CONFIG_Init(0);
  TERMINAL_Init(0);
  MIDIMON_Init(0);
  MBNG_FILE_Init(0);
  MBNG_SEQ_Init(0);
  SEQ_MIDI_OUT_Init(0);

  MBNG_PATCH_Init(0);

  //KEYBOARD_Init(0);
  // done in MBNG_PATCH_Init()

#if MIOS32_DONT_SERVICE_SRIO_SCAN
  //MIOS32_SRIO_ScanNumSet(4);

  // standard SRIO scan has been disabled in programming_models/traditional/main.c via MIOS32_DONT_SERVICE_SRIO_SCAN in mios32_config.h
  // start the scan here - and retrigger it whenever it's finished
  APP_SRIO_ServicePrepare();
  MIOS32_SRIO_ScanStart(APP_SRIO_ServiceFinish);
#endif
}