int main(void) { // Set clock to 168MHz CLOCK_SetClockTo168MHz(); // Delay initialization DELAY_Init(); // Enable clock for GPIOD RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // Initialize PD13 and PD15 as output for orange and blue LED GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_15; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOD, &GPIO_InitStruct); // External interrupt initialization EXTI0_Init(); while (1) { // Toggle blue LED (PD15) every 5s GPIO_ToggleBits(GPIOD, GPIO_Pin_15); DELAY_Ms(5000); } }
int main(void) { ///-----Inicjalizacja funkcji---- SystemInit(); DELAY_Init(); LCD_Init(); DAC_Conf(); EXTILine0_Config(); EXTILine3_Config(); Timer(); LCD_Clear(); LCD_GoTo(0,0); LCD_SendText("Probkowanie co:"); LCD_GoTo(1,0); LCD_SendInt(z); DAC_Cmd(DAC_Channel_1, ENABLE); //wlacz przetwornik while (1) { int timerValue = TIM_GetCounter(TIM2); //sprawdzanie wartosci timera if(timerValue >=z-1) { TIM_ClearITPendingBit(TIM3, TIM_IT_Update); DAC_SetChannel1Data(DAC_Align_12b_R, k); k++; if(k >= 4000) { k=0; } } } }
int main(void) { RCC_ClocksTypeDef RCC_Clocks; RCC_GetClocksFreq(&RCC_Clocks); /* SysTick event each 1ms */ SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000); DELAY_Init(); USB_Init(0); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_Init(GPIOB, &GPIO_InitStructure); //buttons RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init(GPIOC, &GPIO_InitStructure); buttonsInitialized=1; int loopcount = 0; while(1) { midi_package_t rpack; int recv = USB_MIDI_PackageReceive(&rpack); if(recv != -1) { if(rpack.velocity > 50) { GPIOB->ODR |= 1<<13; } else { GPIOB->ODR &= ~(1<<13); } } loopcount++; if((loopcount == 50)||(loopcount == 150)) { if(USB_MIDI_CheckAvailable(0)) { GPIOB->ODR &= ~(1<<12); } } if((loopcount == 100)||(loopcount == 200)) { if(USB_MIDI_CheckAvailable(0)) { GPIOB->ODR |= 1<<12; } if(loopcount==200) loopcount = 0; } if(get_key_press(KEY_A)) { midi_package_t package; package.type = CC; package.event = CC; package.note = 7; package.velocity = 100; USB_MIDI_PackageSend_NonBlocking(package); } if(get_key_press(KEY_B)) { midi_package_t package; package.type = CC; package.event = CC; package.note = 7; package.velocity = 50; USB_MIDI_PackageSend_NonBlocking(package); } DELAY_Wait_uS(1000); } }