int main(void) { /* Set up the system clocks */ SystemInit(); SystemCoreClockUpdate(); GPIOD_Init(); // USTAWIANIE ZEGARA RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseStructure.TIM_Period = 2000; TIM_TimeBaseStructure.TIM_Prescaler = 1400; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up ; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); NVIC_InitTypeDef NVIC_InitStructure; // numer przerwania NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; // priorytet g³ówny NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00; // subpriorytet NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00; // uruchom dany kana³ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // zapisz wype³nion¹ strukturê do rejestrów NVIC_Init(&NVIC_InitStructure); // wyczyszczenie przerwania od timera 3 (wyst¹pi³o przy konfiguracji timera) TIM_ClearITPendingBit(TIM3, TIM_IT_Update); // zezwolenie na przerwania od przepe³nienia dla timera 3 TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); TIM_Cmd(TIM3, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; // USTAWIANIA PRZYCISKU GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Initialize USB, IO, SysTick, and all those other things you do in the morning */ init(); while (1) { } return 0; }
int main(void) { /* Initialize GPIOA PIN8 */ GPIOD_Init(); /* Initialize USART1 */ USART1_Init(); while(1) { USART_SendData(USART1, 'a'); /* Do nothing, all happens in ISR */ } }
void Peripherals_Init(void) { #ifdef NVIC_AUTOINIT NVIC_Init(); #endif /* NVIC_AUTOINIT */ #ifdef SIM_AUTOINIT SIM_Init(); #endif /* SIM_AUTOINIT */ #ifdef MCM_AUTOINIT MCM_Init(); #endif /* MCM_AUTOINIT */ #ifdef PMC_AUTOINIT PMC_Init(); #endif /* PMC_AUTOINIT */ #ifdef PORTA_AUTOINIT PORTA_Init(); #endif /* PORTA_AUTOINIT */ #ifdef PORTB_AUTOINIT PORTB_Init(); #endif /* PORTB_AUTOINIT */ #ifdef PORTC_AUTOINIT PORTC_Init(); #endif /* PORTC_AUTOINIT */ #ifdef PORTD_AUTOINIT PORTD_Init(); #endif /* PORTD_AUTOINIT */ #ifdef PORTE_AUTOINIT PORTE_Init(); #endif /* PORTE_AUTOINIT */ #ifdef ADC0_AUTOINIT ADC0_Init(); #endif /* ADC0_AUTOINIT */ #ifdef ADC1_AUTOINIT ADC1_Init(); #endif /* ADC1_AUTOINIT */ #ifdef CMP0_AUTOINIT CMP0_Init(); #endif /* CMP0_AUTOINIT */ #ifdef CMP1_AUTOINIT CMP1_Init(); #endif /* CMP1_AUTOINIT */ #ifdef CRC_AUTOINIT CRC_Init(); #endif /* CRC_AUTOINIT */ #ifdef DAC0_AUTOINIT DAC0_Init(); #endif /* DAC0_AUTOINIT */ #ifdef DMAMUX_AUTOINIT DMAMUX_Init(); #endif /* DMAMUX_AUTOINIT */ #ifdef DMA_AUTOINIT DMA_Init(); #endif /* DMA_AUTOINIT */ #ifdef EWM_AUTOINIT EWM_Init(); #endif /* EWM_AUTOINIT */ #ifdef FTFA_AUTOINIT FTFA_Init(); #endif /* FTFA_AUTOINIT */ #ifdef FTM0_AUTOINIT FTM0_Init(); #endif /* FTM0_AUTOINIT */ #ifdef FTM1_AUTOINIT FTM1_Init(); #endif /* FTM1_AUTOINIT */ #ifdef FTM2_AUTOINIT FTM2_Init(); #endif /* FTM2_AUTOINIT */ #ifdef GPIOA_AUTOINIT GPIOA_Init(); #endif /* GPIOA_AUTOINIT */ #ifdef GPIOB_AUTOINIT GPIOB_Init(); #endif /* GPIOB_AUTOINIT */ #ifdef GPIOC_AUTOINIT GPIOC_Init(); #endif /* GPIOC_AUTOINIT */ #ifdef GPIOD_AUTOINIT GPIOD_Init(); #endif /* GPIOD_AUTOINIT */ #ifdef GPIOE_AUTOINIT GPIOE_Init(); #endif /* GPIOE_AUTOINIT */ #ifdef I2C0_AUTOINIT I2C0_Init(); #endif /* I2C0_AUTOINIT */ #ifdef LLWU_AUTOINIT LLWU_Init(); #endif /* LLWU_AUTOINIT */ #ifdef LPTMR0_AUTOINIT LPTMR0_Init(); #endif /* LPTMR0_AUTOINIT */ #ifdef PDB0_AUTOINIT PDB0_Init(); #endif /* PDB0_AUTOINIT */ #ifdef RCM_AUTOINIT RCM_Init(); #endif /* RCM_AUTOINIT */ #ifdef SMC_AUTOINIT SMC_Init(); #endif /* SMC_AUTOINIT */ #ifdef SPI0_AUTOINIT SPI0_Init(); #endif /* SPI0_AUTOINIT */ #ifdef SystemControl_AUTOINIT SystemControl_Init(); #endif /* SystemControl_AUTOINIT */ #ifdef SysTick_AUTOINIT SysTick_Init(); #endif /* SysTick_AUTOINIT */ #ifdef UART0_AUTOINIT UART0_Init(); #endif /* UART0_AUTOINIT */ #ifdef UART1_AUTOINIT UART1_Init(); #endif /* UART1_AUTOINIT */ #ifdef WDOG_AUTOINIT WDOG_Init(); #endif /* WDOG_AUTOINIT */ }