bool hasExpressionPedal(){ /* clearPin(EXPRESSION_PEDAL_TIP_PORT, EXPRESSION_PEDAL_TIP_PIN); */ configureDigitalInput(EXPRESSION_PEDAL_TIP_PORT, EXPRESSION_PEDAL_TIP_PIN, GPIO_PuPd_UP); bool connected = getPin(EXPRESSION_PEDAL_TIP_PORT, EXPRESSION_PEDAL_TIP_PIN); setupExpressionPedal(); return connected; }
/** * Configure EXTI callback */ void setupSwitchB(void (*f)()){ externalInterruptCallbackB = f; EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Enable the clocks */ RCC_AHB1PeriphClockCmd(SWITCH_B_CLOCK, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Configure switch pin */ configureDigitalInput(SWITCH_B_PORT, SWITCH_B_PIN, GPIO_PuPd_UP); /* Connect EXTI Line to GPIO Pin */ SYSCFG_EXTILineConfig(SWITCH_B_PORT_SOURCE, SWITCH_B_PIN_SOURCE); /* Configure EXTI line */ EXTI_StructInit(&EXTI_InitStructure); EXTI_InitStructure.EXTI_Line = SWITCH_B_PIN_LINE; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable and set EXTI Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = SWITCH_B_IRQ; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = SWITCH_B_PRIORITY; NVIC_InitStructure.NVIC_IRQChannelSubPriority = SWITCH_B_SUBPRIORITY; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); }
void setup(){ // NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); // 0 bits for preemption, 4 bits for subpriority /* Set up interrupt controller: 2 bits for priority (0-3), * 2 bits for sub-priority (0-3). Priorities control which * interrupts are allowed to preempt one another. */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); /* Increase SysTick priority to be higher than USB interrupt * priority. USB code stalls inside interrupt and we can't let * this throw off the SysTick timer. */ NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, SYSTICK_PRIORITY, SYSTICK_SUBPRIORITY)); NVIC_SetPriority(DMA1_Stream3_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 0, 0)); NVIC_SetPriority(DMA1_Stream4_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 0, 0)); NVIC_SetPriority(SPI2_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 1, 0)); NVIC_SetPriority(ADC_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 2, 0)); ledSetup(); setLed(RED); /* check if we need to DFU boot */ configureDigitalInput(SWITCH_B_PORT, SWITCH_B_PIN, GPIO_PuPd_UP); if(isPushButtonPressed()) jump_to_bootloader(); adcSetup(); clockSetup(); setupSwitchA(footSwitchCallback); setupSwitchB(pushButtonCallback); settings.init(); midi.init(MIDI_CHANNEL); patches.init(); #ifdef EXPRESSION_PEDAL #ifndef OWLMODULAR setupExpressionPedal(); #endif #endif RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); // DEBUG configureDigitalOutput(GPIOB, GPIO_Pin_1); // PB1, DEBUG LED debugClear(); #ifdef DEBUG_AUDIO RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); // DEBUG configureDigitalOutput(GPIOA, GPIO_Pin_7); // PA7 DEBUG configureDigitalOutput(GPIOC, GPIO_Pin_5); // PC5 DEBUG clearPin(GPIOC, GPIO_Pin_5); // DEBUG clearPin(GPIOA, GPIO_Pin_7); // DEBUG #endif /* DEBUG_AUDIO */ usb_init(); #if SERIAL_PORT == 1 setupSerialPort1(115200); #elif SERIAL_PORT == 2 setupSerialPort2(115200); // expression pedal #warning expression pedal jack configured as serial port #ifdef EXPRESSION_PEDAL #error invalid configuration #endif #endif #ifdef OWLMODULAR configureDigitalInput(GPIOB, GPIO_Pin_6, GPIO_PuPd_NOPULL); // PB6 OWL Modular digital input configureDigitalOutput(GPIOB, GPIO_Pin_7); // PB7 OWL Modular digital output setPin(GPIOB, GPIO_Pin_7); // PB7 OWL Modular digital output #endif codec.setup(); codec.init(settings); printString("startup\n"); updateBypassMode(); codec.start(); }