Changeset - 9336fdac7c05
[Not reviewed]
cortex-f0
0 2 0
Ethan Zonca - 10 years ago 2015-01-03 00:04:24
ez@ethanzonca.com
Add toggle GPIO func
2 files changed with 18 insertions and 0 deletions:
0 comments (0 inline, 0 general)
libraries/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_gpio.h
Show inline comments
 
@@ -321,38 +321,40 @@ typedef struct
 
 
/* Exported macro ------------------------------------------------------------*/
 
/* Exported functions ------------------------------------------------------- */
 
/* Function used to set the GPIO configuration to the default reset state *****/
 
void GPIO_DeInit(GPIO_TypeDef* GPIOx);
 
 
/* Initialization and Configuration functions *********************************/
 
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
 
void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
 
void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
 
 
/* GPIO Read and Write functions **********************************************/
 
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
 
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
 
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
 
uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
 
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
 
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
 
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
 
void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
 
 
/* GPIO Alternate functions configuration functions ***************************/
 
void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF);
 
 
void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
 
 
#ifdef __cplusplus
 
}
 
#endif
 
 
#endif /* __STM32F0XX_GPIO_H */
 
/**
 
  * @}
 
  */
 
 
/**
 
  * @}
 
  */
 
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
libraries/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_gpio.c
Show inline comments
 
@@ -502,41 +502,57 @@ void GPIO_Write(GPIO_TypeDef* GPIOx, uin
 
  *            @arg GPIO_AF_7: COMP1 OUT, COMP2 OUT 
 
  * @note   The pin should already been configured in Alternate Function mode(AF)
 
  *         using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
 
  * @note   Refer to the Alternate function mapping table in the device datasheet 
 
  *         for the detailed mapping of the system and peripherals'alternate 
 
  *         function I/O pins.
 
  * @retval None
 
  */
 
void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
 
{
 
  uint32_t temp = 0x00;
 
  uint32_t temp_2 = 0x00;
 
 
  /* Check the parameters */
 
  assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
 
  assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
 
  assert_param(IS_GPIO_AF(GPIO_AF));
 
 
  temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
 
  GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
 
  temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
 
  GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
 
}
 
 
 
/**
 
  * @brief  Toggles the specified GPIO pins. NOTE: Imported by EMZ
 
  * @param  GPIOx: where x can be (A..H) to select the GPIO peripheral.
 
  * @param  GPIO_Pin: Specifies the pins to be toggled.
 
  * @retval None
 
  */
 
void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
 
{
 
  /* Check the parameters */
 
  assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
 
 
  GPIOx->ODR ^= GPIO_Pin;
 
}
 
 
 
/**
 
  * @}
 
  */
 
 
/**
 
  * @}
 
  */
 
 
/**
 
  * @}
 
  */
 
 
/**
 
  * @}
 
  */
 
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 comments (0 inline, 0 general)