///////////////////////////////////////////////////////////////////////////// // This hook is called after startup to initialize the application ///////////////////////////////////////////////////////////////////////////// void APP_Init(void) { int i; // create semaphores xMIDIINSemaphore = xSemaphoreCreateRecursiveMutex(); xMIDIOUTSemaphore = xSemaphoreCreateRecursiveMutex(); // clear SysEx buffers for(i=0; i<NUM_SYSEX_BUFFERS; ++i) sysex_buffer_len[i] = 0; // install SysEx callback MIOS32_MIDI_SysExCallback_Init(APP_SYSEX_Parser); // read EEPROM content PRESETS_Init(0); // init terminal TERMINAL_Init(0); // init MIDImon MIDIMON_Init(0); // start uIP task UIP_TASK_Init(0); // initialize status LED MIOS32_BOARD_LED_Init(0xffffffff); MIOS32_BOARD_LED_Set(1, 0); led_pwm_counter[0] = LED_PWM_PERIOD; led_trigger[0] = LED_PWM_PERIOD; // trigger LED on startup for complete PWM cycle // initialize additional LEDs connected to J5A for(i=1; i<NUM_LED_TRIGGERS; ++i) { led_pwm_counter[i] = LED_PWM_PERIOD; led_trigger[i] = LED_PWM_PERIOD; // trigger LED on startup for complete PWM cycle MIOS32_BOARD_J5_PinInit(i-1, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinSet(i-1, 0); } // initialize J5B/J5C pins as inputs with pull-up enabled // these pins control diagnostic options of the MIDI monitor for(i=4; i<12; ++i) MIOS32_BOARD_J5_PinInit(i, MIOS32_BOARD_PIN_MODE_INPUT_PU); // install timer function which is called each 100 uS MIOS32_TIMER_Init(0, 100, APP_Periodic_100uS, MIOS32_IRQ_PRIO_MID); // print welcome message on MIOS terminal MIOS32_MIDI_SendDebugMessage("\n"); MIOS32_MIDI_SendDebugMessage("=====================\n"); MIOS32_MIDI_SendDebugMessage("%s\n", MIOS32_LCD_BOOT_MSG_LINE1); MIOS32_MIDI_SendDebugMessage("=====================\n"); MIOS32_MIDI_SendDebugMessage("\n"); }
///////////////////////////////////////////////////////////////////////////// // This hook is called before an AIN channel scan // It has been installed in APP_Init() ///////////////////////////////////////////////////////////////////////////// s32 AIN_ServicePrepare(void) { // increment counter, skip on the first 9 invocations (= 9 mS setup time) if( ++setup_time_ctr < 10 ) return 1; // skip scan (see documentation of MIOS32_AIN_ServicePrepareCallback_Init()) // scan with the 10th invocation if( setup_time_ctr++ == 10 ) return 0; // allow scan, value changes will be forwarded to APP_AIN_NotifyChange() // reset counter setup_time_ctr = 0; // toggle scan direction scan_x ^= 1; // re-initialize AIN pins at J5A (Pin C0..C3) // Touchpanel connections: // J5.A0: Right // J5.A1: Top // J5.A2: Left // J5.A3: Bottom if( scan_x ) { // X Scan // A2 (Left) = 0V MIOS32_BOARD_J5_PinInit(2, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinSet(2, 0); // A0 (Right) = 3.3V MIOS32_BOARD_J5_PinInit(0, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinSet(0, 1); // A1 (Top) used as ADC Input MIOS32_BOARD_J5_PinInit(1, MIOS32_BOARD_PIN_MODE_ANALOG); // switch A3 (Bottom) to high impedance state MIOS32_BOARD_J5_PinInit(3, MIOS32_BOARD_PIN_MODE_ANALOG); } else { // Y Scan // A1 (Top) = 0V MIOS32_BOARD_J5_PinInit(1, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinSet(1, 0); // A3 (Bottom) = 3.3V MIOS32_BOARD_J5_PinInit(3, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); MIOS32_BOARD_J5_PinSet(3, 1); // A0 (Right) used as ADC Input MIOS32_BOARD_J5_PinInit(0, MIOS32_BOARD_PIN_MODE_ANALOG); // switch A2 (Left) to high impedance state MIOS32_BOARD_J5_PinInit(2, MIOS32_BOARD_PIN_MODE_ANALOG); } return 1; // skip conversion }
///////////////////////////////////////////////////////////////////////////// //! 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 }
///////////////////////////////////////////////////////////////////////////// // This hook is called after startup to initialize the application ///////////////////////////////////////////////////////////////////////////// void APP_Init(void) { // initialize all LEDs MIOS32_BOARD_LED_Init(0xffffffff); // initialize all pins of J5A, J5B and J5C as outputs in Push-Pull Mode int pin; for(pin=0; pin<12; ++pin) MIOS32_BOARD_J5_PinInit(pin, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); }
///////////////////////////////////////////////////////////////////////////// // This hook is called after startup to initialize the application ///////////////////////////////////////////////////////////////////////////// void APP_Init(void) { // initialize all LEDs MIOS32_BOARD_LED_Init(0xffffffff); // initialize all pins of J5A, J5B and J5C as inputs with internal Pull-Up int pin; for(pin=0; pin<12; ++pin) MIOS32_BOARD_J5_PinInit(pin, MIOS32_BOARD_PIN_MODE_INPUT_PU); // initialize rotary encoders of the same type (DETENTED2) int enc; for(enc=0; enc<NUM_ENCODERS; ++enc) { mios32_enc_config_t enc_config = MIOS32_ENC_ConfigGet(enc); enc_config.cfg.type = DETENTED2; // see mios32_enc.h for available types enc_config.cfg.sr = 0; // must be 0 if controlled from application enc_config.cfg.pos = 0; // doesn't matter if controlled from application enc_config.cfg.speed = NORMAL; enc_config.cfg.speed_par = 0; MIOS32_ENC_ConfigSet(enc, enc_config); } }