I´m using the CubeMx software only to stablish minor settings, I am trying to get PA7 on my F302R8 board as a complementary output, but without writing the following:
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF6_TIM1; // THIS ONE RIGHT HERE
Is there any other way to define it, more like classic C?
This is how I´ve been defining my ports so far, I want to do something similar :
GPIOx->AFR|=2; // 0 for (1 to 7 AFRLy ) and 1 (for 8 to 15 AFRHy)
GPIOx->MODER|=(0<<0)|(1<<1);// Alternate function on Px
GPIOx->OSPEEDR|=(1<<0)|(1<<1); //High speed on Px
Apparently GPIOx->AFR[n]|=X; only defines the High (1) and low (0) part and its function (X=0...7) but I´m not sure because there is also the pin on which the function outputs.