//We always start with all the DIOs as inputs (safest state) void init_dio(void) { GPIO_InitTypeDef GPIO_InitStructure; // Enable GPIO Peripheral clocks __GPIOD_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); // Configure pins as inputs GPIO_InitStructure.Pin = GPIO_PIN_8 | GPIO_PIN_9; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_8 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); //All inputs: dio_direction = 0b111111111; }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pins : PF0 MMA__INTR_Pin */ GPIO_InitStruct.Pin = GPIO_PIN_0|MMA__INTR_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : CHRG_EN_Pin DCDC_EN_Pin GPS_PWR_Pin GPS_SOS_Pin Kimenet_Pin CS_Pin */ GPIO_InitStruct.Pin = GPS_PWR_Pin|GPS_SOS_Pin |/*Kimenet_Pin|*/CS_Pin | GPS_SOS_Pin | DCDC_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : GPS_ON_Pin *///open drain GPIO_InitStruct.Pin = DCDC_PWR_Pin | GPS_ON_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPS_ON_GPIO_Port, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pin : PC13 */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* Enable and set EXTI line 4_15 Interrupt to the lowest priority */ HAL_NVIC_SetPriority(EXTI4_15_IRQn, 2, 0); HAL_NVIC_EnableIRQ(EXTI4_15_IRQn); /*Configure GPIO pin : PA5 */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); /*Configure GPIO pin : B1_Pin */ GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LD2_Pin */ GPIO_InitStruct.Pin = LD2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); /*Configure GPIOC pin8 */ GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pin : PA0 */ GPIO_InitStruct.Pin = MORSE_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(MORSE_PORT, &GPIO_InitStruct); /*Configure GPIO pins : SEL0, SEL1, SEL2 --- autorun select pins */ GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Pin = AUTORUN_SEL0PIN; HAL_GPIO_Init(AUTORUN_SEL0PORT, &GPIO_InitStruct); GPIO_InitStruct.Pin = AUTORUN_SEL1PIN; HAL_GPIO_Init(AUTORUN_SEL1PORT, &GPIO_InitStruct); GPIO_InitStruct.Pin = AUTORUN_SEL2PIN; HAL_GPIO_Init(AUTORUN_SEL2PORT, &GPIO_InitStruct); /*Configure GPIO pin : PB1 --- Slave Select for SPI */ GPIO_InitStruct.Pin = GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
// Enable GPIO clock and return GPIO base address uint32_t Set_GPIO_Clock(uint32_t port_idx) { uint32_t gpio_add = 0; switch (port_idx) { case PortA: gpio_add = GPIOA_BASE; __GPIOA_CLK_ENABLE(); break; case PortB: gpio_add = GPIOB_BASE; __GPIOB_CLK_ENABLE(); break; case PortC: gpio_add = GPIOC_BASE; __GPIOC_CLK_ENABLE(); break; case PortD: gpio_add = GPIOD_BASE; __GPIOD_CLK_ENABLE(); break; case PortF: gpio_add = GPIOF_BASE; __GPIOF_CLK_ENABLE(); break; default: error("Pinmap error: wrong port number."); break; } return gpio_add; }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); //debug pio: PA10 PA8 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_WritePin(GPIOA,GPIO_PIN_10,GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_SET); //debug pio: PC8 PC6 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6,GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOC,GPIO_PIN_8,GPIO_PIN_SET); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); /*Configure GPIO pin : PC13 */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : LD2_Pin */ GPIO_InitStruct.Pin = LD2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI4_15_IRQn); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_RESET); /*Configure GPIO pin : PC13 */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : PE8 */ GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE() ; __GPIOH_CLK_ENABLE() ; __GPIOA_CLK_ENABLE() ; __GPIOB_CLK_ENABLE() ; __GPIOI_CLK_ENABLE() ; __GPIOC_CLK_ENABLE() ; /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOF, LED1_Pin | LED2_Pin | LED3_Pin | LED4_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(DS3234_CS_GPIO_Port, DS3234_CS_Pin, GPIO_PIN_SET); /*Configure GPIO pins : LED1_Pin LED2_Pin LED3_Pin LED4_Pin */ GPIO_InitStruct.Pin = LED1_Pin | LED2_Pin | LED3_Pin | LED4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pin : SPI_CS_Pin */ GPIO_InitStruct.Pin = SPI_CS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(SPI_CS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ONEHZ_EXTI_Pin */ GPIO_InitStruct.Pin = ONEHZ_EXTI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ONEHZ_EXTI_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : DS3234_CS_Pin */ GPIO_InitStruct.Pin = DS3234_CS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(DS3234_CS_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); }
/** * @brief Configure all GPIO's to AN to reduce the power consumption * @param None * @retval None */ static void GPIO_ConfigAN(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /* Disable GPIOs clock */ __GPIOA_CLK_DISABLE(); __GPIOB_CLK_DISABLE(); __GPIOC_CLK_DISABLE(); __GPIOD_CLK_DISABLE(); __GPIOE_CLK_DISABLE(); __GPIOF_CLK_DISABLE(); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOA_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); /*Configure GPIO pin : LED_Pin */ GPIO_InitStruct.Pin = LED_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : RS485_DE_Pin RS485_RE_Pin */ GPIO_InitStruct.Pin = RS485_DE_Pin|RS485_RE_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pins : S_MODE_Pin PWRV1_Pin PWRG1_Pin C_PWM_Pin */ GPIO_InitStruct.Pin = S_MODE_Pin|PWRV1_Pin|PWRG1_Pin|C_PWM_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI PB6 ------> I2C1_SCL PB7 ------> I2C1_SDA */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOE_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pins : PE2 PE4 PE5 PE0 PE1 */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_0 |GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pins : PE3 PE8 PE9 PE10 PE11 PE12 PE13 PE14 PE15 */ GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pin : PA0 */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : PA5 PA6 PA7 */ GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : PB6 PB7 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI PA11 ------> USB_DM PA12 ------> USB_DP PB6 ------> I2C1_SCL PB7 ------> I2C1_SDA */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOE_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pins : DRDY_Pin MEMS_INT3_Pin MEMS_INT4_Pin MEMS_INT1_Pin MEMS_INT2_Pin */ GPIO_InitStruct.Pin = DRDY_Pin|MEMS_INT3_Pin|MEMS_INT4_Pin|MEMS_INT1_Pin |MEMS_INT2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pins : CS_I2C_SPI_Pin LD4_Pin LD3_Pin LD5_Pin LD7_Pin LD9_Pin LD10_Pin LD8_Pin LD6_Pin */ GPIO_InitStruct.Pin = CS_I2C_SPI_Pin|LD4_Pin|LD3_Pin|LD5_Pin |LD7_Pin|LD9_Pin|LD10_Pin|LD8_Pin |LD6_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pin : B1_Pin */ GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : DM_Pin DP_Pin */ GPIO_InitStruct.Pin = DM_Pin|DP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF14_USB; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : PB6 PB7 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
void MX_GPIO_Init(void) { __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); }
/************************************************************************************************************** * Function Name : bsp_GPIOxClockEnable * Description : Enable specific GPIO Port clock * Input Variable : GPIO Port * Return Variable : None * Author : Bryant * Create Date : Sep-29-2015 * Call : Outside ****************************************************************************************************************/ void bsp_GPIOxClockEnable(GPIO_TypeDef* gpioPort) { if(gpioPort==GPIOA) __GPIOA_CLK_ENABLE(); if(gpioPort==GPIOB) __GPIOB_CLK_ENABLE(); if(gpioPort==GPIOC) __GPIOC_CLK_ENABLE(); if(gpioPort==GPIOD) __GPIOD_CLK_ENABLE(); if(gpioPort==GPIOE) __GPIOE_CLK_ENABLE(); if(gpioPort==GPIOF) __GPIOF_CLK_ENABLE(); if(gpioPort==GPIOG) __GPIOG_CLK_ENABLE(); if(gpioPort==GPIOH) __GPIOH_CLK_ENABLE(); if(gpioPort==GPIOI) __GPIOI_CLK_ENABLE(); if(gpioPort==GPIOJ) __GPIOJ_CLK_ENABLE(); if(gpioPort==GPIOK) __GPIOK_CLK_ENABLE(); }
/** * @brief This function configures the system to enter Sleep mode for * current consumption measurement purpose. * Sleep Mode * ========== * - System Running at PLL (72 MHz) * - Flash 2 wait state * - Prefetch ON * - Code running from Internal FLASH * - All peripherals disabled. * - Wakeup using EXTI Line (User push-button PA.00 pin) * @param None * @retval None */ void SleepMode_Measure(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ /* Warning : Reconfiguring all GPIO will close the connexion with the debugger */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /* Disable GPIOs clock */ __GPIOA_CLK_DISABLE(); __GPIOB_CLK_DISABLE(); __GPIOC_CLK_DISABLE(); __GPIOD_CLK_DISABLE(); __GPIOE_CLK_DISABLE(); __GPIOF_CLK_DISABLE(); /* Configure User push-button as external interrupt generator */ BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI); /*Suspend Tick increment to prevent wakeup by Systick interrupt. Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base)*/ HAL_SuspendTick(); /* Request to enter SLEEP mode */ HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* Resume Tick interrupt if disabled prior to sleep mode entry*/ HAL_ResumeTick(); /* Initialize led */ BSP_LED_Init(LED3); }
/** * @brief ADC_MspInit * @param None * @retval None */ void HAL_ADC_MspInit(ADC_HandleTypeDef *heth) { GPIO_InitTypeDef GPIO_InitStructure; __GPIOF_CLK_ENABLE(); /* Configure ADC Channel 7 as analog input */ GPIO_InitStructure.Pin = GPIO_PIN_9;/**/ GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL ; HAL_GPIO_Init(GPIOF, &GPIO_InitStructure); /* ADC3 Periph clock enable */ __ADC3_CLK_ENABLE(); }
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) { if (0) { #ifdef __GPIOA_CLK_ENABLE } else if (gpio == GPIOA) { __GPIOA_CLK_ENABLE(); #endif #ifdef __GPIOB_CLK_ENABLE } else if (gpio == GPIOB) { __GPIOB_CLK_ENABLE(); #endif #ifdef __GPIOC_CLK_ENABLE } else if (gpio == GPIOC) { __GPIOC_CLK_ENABLE(); #endif #ifdef __GPIOD_CLK_ENABLE } else if (gpio == GPIOD) { __GPIOD_CLK_ENABLE(); #endif #ifdef __GPIOE_CLK_ENABLE } else if (gpio == GPIOE) { __GPIOE_CLK_ENABLE(); #endif #ifdef __GPIOF_CLK_ENABLE } else if (gpio == GPIOF) { __GPIOF_CLK_ENABLE(); #endif #ifdef __GPIOG_CLK_ENABLE } else if (gpio == GPIOG) { __GPIOG_CLK_ENABLE(); #endif #ifdef __GPIOH_CLK_ENABLE } else if (gpio == GPIOH) { __GPIOH_CLK_ENABLE(); #endif #ifdef __GPIOI_CLK_ENABLE } else if (gpio == GPIOI) { __GPIOI_CLK_ENABLE(); #endif #ifdef __GPIOJ_CLK_ENABLE } else if (gpio == GPIOJ) { __GPIOJ_CLK_ENABLE(); #endif #ifdef __GPIOK_CLK_ENABLE } else if (gpio == GPIOK) { __GPIOK_CLK_ENABLE(); #endif } }
F7GPIO::F7GPIO(GPIO_TypeDef* GPIOx,uint32_t GPIO_Pin) { __GPIOE_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); this->GPIOx = GPIOx; this->GPIO_Pin = GPIO_Pin; }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pins : PB0 PB1 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
void ClockEnable (void) { __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __ADC1_CLK_ENABLE(); __ADC2_CLK_ENABLE(); __DAC_CLK_ENABLE(); __FSMC_CLK_ENABLE(); __SPI2_CLK_ENABLE(); __DMA2_CLK_ENABLE(); __TIM1_CLK_ENABLE(); __TIM2_CLK_ENABLE(); }
/** * @brief Initializes FSMC_BANK3 MSP. * @param None * @retval None */ static void FSMC_BANK3_MspInit(void) { GPIO_InitTypeDef GPIO_Init_Structure; /* Enable FSMC clock */ __FSMC_CLK_ENABLE(); /* Enable GPIOs clock */ __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); /* Common GPIO configuration */ GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_PULLUP; GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; GPIO_Init_Structure.Alternate = GPIO_AF12_FSMC; /* GPIOD configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 |\ GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |\ GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); /* GPIOE configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | GPIO_PIN_7 |\ GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 |\ GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); /* GPIOF configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ GPIO_PIN_5 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); /* GPIOG configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ GPIO_PIN_5 | GPIO_PIN_10; HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); #ifdef TICKLESS_MODE /*Configure GPIO pin : B1_Pin */ GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_NOPULL; #else /*Configure GPIO pin : B1_Pin */ GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; #endif HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LD2_Pin */ GPIO_InitStruct.Pin = LD2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PA8 */ GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF0_MCO; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); #ifdef TICKLESS_MODE /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI4_15_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY, 0); HAL_NVIC_EnableIRQ(EXTI4_15_IRQn); #endif }
void HAL_MspInit(void) { /* Set the system clock */ SystemClock_Config(); /* Config Systick */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); /* Enable GPIO clocks */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); #ifdef OPENMV2 __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); #endif /* Enable DMA clocks */ __DMA2_CLK_ENABLE(); /* Conigure DCMI GPIO */ GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.Pull = GPIO_PULLDOWN; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Pin = DCMI_RESET_PIN; HAL_GPIO_Init(DCMI_RESET_PORT, &GPIO_InitStructure); GPIO_InitStructure.Pin = DCMI_PWDN_PIN; HAL_GPIO_Init(DCMI_PWDN_PORT, &GPIO_InitStructure); /* Configure SD CD PIN */ GPIO_InitStructure.Pin = SD_CD_PIN; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Speed = GPIO_SPEED_LOW; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; HAL_GPIO_Init(SD_CD_PORT, &GPIO_InitStructure); }
GPIOPins::GPIOPins(GPIO_TypeDef *peripheral, std::initializer_list<Pin> pins, Mode mode, Pull pull, Speed speed, AlternateFunction alternate /*= AlternateFunction::None*/) { this->peripheral = peripheral; for (const auto &pin : pins) { pins_bitmask |= std::bitset<16>(static_cast<uint16_t>(pin)); } //if (std::find(initialized_peripherals.begin(), initialized_peripherals.end(), peripheral) == initialized_peripherals.end()) { if (peripheral == GPIOA) __GPIOA_CLK_ENABLE(); else if (peripheral == GPIOB) __GPIOB_CLK_ENABLE(); else if (peripheral == GPIOC) __GPIOC_CLK_ENABLE(); else if (peripheral == GPIOD) __GPIOD_CLK_ENABLE(); else if (peripheral == GPIOE) __GPIOE_CLK_ENABLE(); else if (peripheral == GPIOF) __GPIOF_CLK_ENABLE(); else if (peripheral == GPIOG) __GPIOG_CLK_ENABLE(); else if (peripheral == GPIOH) __GPIOH_CLK_ENABLE(); else if (peripheral == GPIOI) __GPIOI_CLK_ENABLE(); //} //initialized_peripherals.push_back(peripheral); auto init_configuration = GPIO_InitTypeDef(); init_configuration.Pin = pins_bitmask.to_ulong(); init_configuration.Mode = static_cast<uint32_t>(mode); init_configuration.Pull = static_cast<uint32_t>(pull); init_configuration.Speed = static_cast<uint32_t>(speed); if (alternate != AlternateFunction::None) init_configuration.Alternate = static_cast<uint8_t>(alternate); HAL_GPIO_Init(peripheral, &init_configuration); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); /*Configure GPIO pin : PPM_PIN_Pin */ GPIO_InitStruct.Pin = PPM_PIN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(PPM_PIN_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : nRF_IRQ_Pin */ GPIO_InitStruct.Pin = nRF_IRQ_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(nRF_IRQ_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LED_PIN_Pin */ GPIO_InitStruct.Pin = LED_PIN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(LED_PIN_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : nRF_CE_Pin nRF_CSN_Pin */ GPIO_InitStruct.Pin = nRF_CE_Pin|nRF_CSN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI0_1_IRQn); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOC_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); /*Configure GPIO pin : PC13 */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : PA4 */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : PE9 */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pin : PF6 */ GPIO_InitStruct.Pin = GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); }
//------------------------------------------------------------------------------------------------------------------------------------------------------ void Hardware_Init(void) { HAL_Init(); SystemClock_Config(); __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __DMA1_CLK_ENABLE(); // Для DAC1 (бикалка) __TIM7_CLK_ENABLE(); // Для DAC1 (бикалка) __DAC_CLK_ENABLE(); // Для бикалки __PWR_CLK_ENABLE(); __SYSCFG_CLK_ENABLE(); HAL_NVIC_SetPriority(SysTick_IRQn, PRIORITY_SYS_TICK); // Timer ///////////////////////////////////////////////////////////////// //RCC_PCLK1Config(RCC_HCLK_Div1); // Таймер для мс HAL_NVIC_SetPriority(TIM6_DAC_IRQn, PRIORITY_TIMER_TIM6); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); Timer_Init(); Panel_Init(); FSMC_Init(); FSMC_SetMode(ModeFSMC_FPGA); FDrive_Init(); }