130 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
137 else if (GPIOx == GPIOB)
142 else if (GPIOx == GPIOC)
147 else if (GPIOx == GPIOD)
152 else if (GPIOx == GPIOE)
157 else if (GPIOx == GPIOF)
162 else if (GPIOx == GPIOG)
167 else if (GPIOx == GPIOH)
173 else if (GPIOx == GPIOI)
178 else if (GPIOx == GPIOJ)
204 uint32_t pinpos = 0x00, pos = 0x00 , currentpin = 0x00;
207 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
208 assert_param(IS_GPIO_PIN(GPIO_InitStruct->
GPIO_Pin));
209 assert_param(IS_GPIO_MODE(GPIO_InitStruct->
GPIO_Mode));
210 assert_param(IS_GPIO_PUPD(GPIO_InitStruct->
GPIO_PuPd));
214 for (pinpos = 0x00; pinpos < 0x10; pinpos++)
216 pos = ((uint32_t)0x01) << pinpos;
218 currentpin = (GPIO_InitStruct->
GPIO_Pin) & pos;
220 if (currentpin == pos)
222 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (pinpos * 2));
223 GPIOx->MODER |= (((uint32_t)GPIO_InitStruct->
GPIO_Mode) << (pinpos * 2));
228 assert_param(IS_GPIO_SPEED(GPIO_InitStruct->
GPIO_Speed));
231 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pinpos * 2));
232 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_InitStruct->
GPIO_Speed) << (pinpos * 2));
235 assert_param(IS_GPIO_OTYPE(GPIO_InitStruct->
GPIO_OType));
238 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pinpos)) ;
239 GPIOx->OTYPER |= (uint16_t)(((uint16_t)GPIO_InitStruct->
GPIO_OType) << ((uint16_t)pinpos));
243 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pinpos * 2));
244 GPIOx->PUPDR |= (((uint32_t)GPIO_InitStruct->
GPIO_PuPd) << (pinpos * 2));
257 GPIO_InitStruct->
GPIO_Pin = GPIO_Pin_All;
259 GPIO_InitStruct->
GPIO_Speed = GPIO_Speed_2MHz;
261 GPIO_InitStruct->
GPIO_PuPd = GPIO_PuPd_NOPULL;
279 __IO uint32_t tmp = 0x00010000;
282 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
283 assert_param(IS_GPIO_PIN(GPIO_Pin));
289 GPIOx->LCKR = GPIO_Pin;
325 uint8_t bitstatus = 0x00;
328 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
329 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
331 if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
333 bitstatus = (uint8_t)Bit_SET;
337 bitstatus = (uint8_t)Bit_RESET;
352 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
354 return ((uint16_t)GPIOx->IDR);
368 uint8_t bitstatus = 0x00;
371 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
372 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
374 if (((GPIOx->ODR) & GPIO_Pin) != (uint32_t)Bit_RESET)
376 bitstatus = (uint8_t)Bit_SET;
380 bitstatus = (uint8_t)Bit_RESET;
395 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
397 return ((uint16_t)GPIOx->ODR);
415 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
416 assert_param(IS_GPIO_PIN(GPIO_Pin));
418 GPIOx->BSRRL = GPIO_Pin;
436 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
437 assert_param(IS_GPIO_PIN(GPIO_Pin));
439 GPIOx->BSRRH = GPIO_Pin;
458 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
459 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
460 assert_param(IS_GPIO_BIT_ACTION(BitVal));
462 if (BitVal != Bit_RESET)
464 GPIOx->BSRRL = GPIO_Pin;
468 GPIOx->BSRRH = GPIO_Pin ;
483 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
485 GPIOx->ODR = PortVal;
499 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
501 GPIOx->ODR ^= GPIO_Pin;
581 uint32_t temp = 0x00;
582 uint32_t temp_2 = 0x00;
585 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
586 assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
587 assert_param(IS_GPIO_AF(GPIO_AF));
589 temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4)) ;
590 GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4)) ;
591 temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
592 GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
This file contains all the functions prototypes for the RCC firmware library.
This file contains all the functions prototypes for the GPIO firmware library.
GPIOOType_TypeDef GPIO_OType
void GPIO_Write(GPIO_TypeDef *GPIOx, uint16_t PortVal)
Writes data to the specified GPIO data port.
void GPIO_ResetBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Clears the selected data port bits.
GPIOSpeed_TypeDef GPIO_Speed
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
Fills each GPIO_InitStruct member with its default value.
GPIOPuPd_TypeDef GPIO_PuPd
void GPIO_SetBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Sets the selected data port bits.
uint16_t GPIO_ReadOutputData(GPIO_TypeDef *GPIOx)
Reads the specified GPIO output data port.
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
Sets or clears the selected data port bit.
GPIOMode_TypeDef GPIO_Mode
GPIO Init structure definition.
void GPIO_PinLockConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Locks GPIO Pins configuration registers.
void GPIO_PinAFConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
Changes the mapping of the specified pin.
void GPIO_DeInit(GPIO_TypeDef *GPIOx)
De-initializes the GPIOx peripheral registers to their default reset values.
uint16_t GPIO_ReadInputData(GPIO_TypeDef *GPIOx)
Reads the specified GPIO input data port.
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
Forces or releases AHB1 peripheral reset.
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified output data port bit.
BitAction
GPIO Bit SET and Bit RESET enumeration.
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified input port pin.
void GPIO_ToggleBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Toggles the specified GPIO pins..