Main-Auszug // Init clock system RCC_Configuration(); // NVIC configuration NVIC_Configuration(); // Config Miscellaneous Misc_Config(); // Config I2C-Bus I2C_Config(); // Config USART2 USART_Config(); - Ab hier ist PA01 high // External Interrupt Lines EXTI_Configuration(); // Config AD-Converter ADC_Config(); Misc_Config (Initialisierung der GPIO´s) gekürzt void Misc_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; // IO-Vorbereitung RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, DISABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); ... weitere Ein-/Ausgänge // DI_TAST1 GPIO_InitStructure.GPIO_Pin = DI_TAST1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(DI_TAST1_PORT, &GPIO_InitStructure); // DI_TAST2 GPIO_InitStructure.GPIO_Pin = DI_TAST2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(DI_TAST2_PORT, &GPIO_InitStructure); // DI_TAST3 GPIO_InitStructure.GPIO_Pin = DI_TAST3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(DI_TAST3_PORT, &GPIO_InitStructure); ... weitere Ein/Ausgänge return; } /* Misc_Config */ USART_Config (Initialisierung USART2 und entsprechenden GPIOs) ungekürzt void USART_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; // USART init // USART Deinit RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); USART_DeInit(USART2); GPIO_PinRemapConfig(GPIO_Remap_USART2,DISABLE); // Initialisiere Portpins // DO_RS232_TXD #if DO_RS232_TXD_FUNC == ALTERNATE GPIO_InitStructure.GPIO_Pin = DO_RS232_TXD; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init (DO_RS232_TXD_PORT, &GPIO_InitStructure); #endif // DI_RS232_RXD #if DI_RS232_RXD_FUNC == ALTERNATE GPIO_InitStructure.GPIO_Pin = DI_RS232_RXD; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init (DI_RS232_RXD_PORT, &GPIO_InitStructure); #endif USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No ; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // Configure the USART2 USART_Init(USART2, &USART_InitStructure); // Enable the USART2 USART_Cmd(USART2, ENABLE); } /* USART_Config */