|
发表于 2018-5-21 16:52:00
|
显示全部楼层
官方库是有的,不过实际能不能我没试过。
- typedef struct {
- __IO uint32_t DR; /**< GPIO data register, offset: 0x0 */
- __IO uint32_t GDIR; /**< GPIO direction register, offset: 0x4 */
- __I uint32_t PSR; /**< GPIO pad status register, offset: 0x8 */
- __IO uint32_t ICR1; /**< GPIO interrupt configuration register1, offset: 0xC */
- __IO uint32_t ICR2; /**< GPIO interrupt configuration register2, offset: 0x10 */
- __IO uint32_t IMR; /**< GPIO interrupt mask register, offset: 0x14 */
- __IO uint32_t ISR; /**< GPIO interrupt status register, offset: 0x18 */
- __IO uint32_t EDGE_SEL; /**< GPIO edge select register, offset: 0x1C */
- uint8_t RESERVED_0[100];
- __O uint32_t DR_SET; /**< GPIO data register SET, offset: 0x84 */
- __O uint32_t DR_CLEAR; /**< GPIO data register CLEAR, offset: 0x88 */
- __O uint32_t DR_TOGGLE; /**< GPIO data register TOGGLE, offset: 0x8C */
- } GPIO_Type;
复制代码- /*!
- * @brief Sets the output level of the multiple GPIO pins to the logic 1.
- *
- * @param base GPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
- * @param mask GPIO pin number macro
- */
- static inline void GPIO_PortSet(GPIO_Type *base, uint32_t mask)
- {
- base->DR_SET = mask;
- }
- /*!
- * @brief Sets the output level of the multiple GPIO pins to the logic 1.
- * @deprecated Do not use this function. It has been superceded by @ref GPIO_PortSet.
- */
- static inline void GPIO_SetPinsOutput(GPIO_Type* base, uint32_t mask)
- {
- GPIO_PortSet(base, mask);
- }
- /*!
- * @brief Sets the output level of the multiple GPIO pins to the logic 0.
- *
- * @param base GPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
- * @param mask GPIO pin number macro
- */
- static inline void GPIO_PortClear(GPIO_Type *base, uint32_t mask)
- {
- base->DR_CLEAR = mask;
- }
- /*!
- * @brief Sets the output level of the multiple GPIO pins to the logic 0.
- * @deprecated Do not use this function. It has been superceded by @ref GPIO_PortClear.
- */
- static inline void GPIO_ClearPinsOutput(GPIO_Type* base, uint32_t mask)
- {
- GPIO_PortClear(base, mask);
- }
- /*!
- * @brief Reverses the current output logic of the multiple GPIO pins.
- *
- * @param base GPIO peripheral base pointer (GPIO1, GPIO2, GPIO3, and so on.)
- * @param mask GPIO pin number macro
- */
- static inline void GPIO_PortToggle(GPIO_Type *base, uint32_t mask)
- {
- base->DR_TOGGLE = mask;
- }
复制代码 |
|