The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 109:9296ab0bfc11 1 /**
Kojto 109:9296ab0bfc11 2 ******************************************************************************
Kojto 109:9296ab0bfc11 3 * @file
Kojto 109:9296ab0bfc11 4 * @author
Kojto 109:9296ab0bfc11 5 * @version
Kojto 109:9296ab0bfc11 6 * @date
Kojto 109:9296ab0bfc11 7 * @brief This file contains all the functions prototypes for the GPIO
Kojto 109:9296ab0bfc11 8 * firmware library.
Kojto 109:9296ab0bfc11 9 ******************************************************************************
Kojto 109:9296ab0bfc11 10 *
Kojto 109:9296ab0bfc11 11 ******************************************************************************
Kojto 109:9296ab0bfc11 12 */
Kojto 109:9296ab0bfc11 13
Kojto 109:9296ab0bfc11 14 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 109:9296ab0bfc11 15 #ifndef __W7500X_HAL_GPIO_H
Kojto 109:9296ab0bfc11 16 #define __W7500X_HAL_GPIO_H
Kojto 109:9296ab0bfc11 17
Kojto 109:9296ab0bfc11 18 #ifdef __cplusplus
Kojto 109:9296ab0bfc11 19 extern "C" {
Kojto 109:9296ab0bfc11 20 #endif
Kojto 109:9296ab0bfc11 21
Kojto 109:9296ab0bfc11 22 /* Includes ------------------------------------------------------------------*/
Kojto 109:9296ab0bfc11 23 #include "W7500x.h"
Kojto 109:9296ab0bfc11 24
Kojto 109:9296ab0bfc11 25 #define GPIO_Pin_0 (uint16_t)(0x01 << 0) // Pin 0 Selected
Kojto 109:9296ab0bfc11 26 #define GPIO_Pin_1 (uint16_t)(0x01 << 1) // Pin 1 Selected
Kojto 109:9296ab0bfc11 27 #define GPIO_Pin_2 (uint16_t)(0x01 << 2) // Pin 2 Selected
Kojto 109:9296ab0bfc11 28 #define GPIO_Pin_3 (uint16_t)(0x01 << 3) // Pin 3 Selected
Kojto 109:9296ab0bfc11 29 #define GPIO_Pin_4 (uint16_t)(0x01 << 4) // Pin 4 Selected
Kojto 109:9296ab0bfc11 30 #define GPIO_Pin_5 (uint16_t)(0x01 << 5) // Pin 5 Selected
Kojto 109:9296ab0bfc11 31 #define GPIO_Pin_6 (uint16_t)(0x01 << 6) // Pin 6 Selected
Kojto 109:9296ab0bfc11 32 #define GPIO_Pin_7 (uint16_t)(0x01 << 7) // Pin 7 Selected
Kojto 109:9296ab0bfc11 33 #define GPIO_Pin_8 (uint16_t)(0x01 << 8) // Pin 8 Selected
Kojto 109:9296ab0bfc11 34 #define GPIO_Pin_9 (uint16_t)(0x01 << 9) // Pin 9 Selected
Kojto 109:9296ab0bfc11 35 #define GPIO_Pin_10 (uint16_t)(0x01 << 10) // Pin 10 Selected
Kojto 109:9296ab0bfc11 36 #define GPIO_Pin_11 (uint16_t)(0x01 << 11) // Pin 11 Selected
Kojto 109:9296ab0bfc11 37 #define GPIO_Pin_12 (uint16_t)(0x01 << 12) // Pin 12 Selected
Kojto 109:9296ab0bfc11 38 #define GPIO_Pin_13 (uint16_t)(0x01 << 13) // Pin 13 Selected
Kojto 109:9296ab0bfc11 39 #define GPIO_Pin_14 (uint16_t)(0x01 << 14) // Pin 14 Selected
Kojto 109:9296ab0bfc11 40 #define GPIO_Pin_15 (uint16_t)(0x01 << 15) // Pin 15 Selected
Kojto 109:9296ab0bfc11 41 #define GPIO_Pin_All (uint16_t)(0xFFFF) // All pins Selected
Kojto 109:9296ab0bfc11 42
Kojto 109:9296ab0bfc11 43
Kojto 109:9296ab0bfc11 44 #define IS_GPIO_PIN(PIN) ((PIN) != (uint16_t)0x00)
Kojto 109:9296ab0bfc11 45 #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || ((PIN) == GPIO_Pin_1) || \
Kojto 109:9296ab0bfc11 46 (((PIN) == GPIO_Pin_2) || ((PIN) == GPIO_Pin_3) || \
Kojto 109:9296ab0bfc11 47 (((PIN) == GPIO_Pin_4) || ((PIN) == GPIO_Pin_5) || \
Kojto 109:9296ab0bfc11 48 (((PIN) == GPIO_Pin_6) || ((PIN) == GPIO_Pin_7) || \
Kojto 109:9296ab0bfc11 49 (((PIN) == GPIO_Pin_8) || ((PIN) == GPIO_Pin_9) || \
Kojto 109:9296ab0bfc11 50 (((PIN) == GPIO_Pin_10) || ((PIN) == GPIO_Pin_11) || \
Kojto 109:9296ab0bfc11 51 (((PIN) == GPIO_Pin_12) || ((PIN) == GPIO_Pin_13) || \
Kojto 109:9296ab0bfc11 52 (((PIN) == GPIO_Pin_14) || ((PIN) == GPIO_Pin_15) )
Kojto 109:9296ab0bfc11 53
Kojto 109:9296ab0bfc11 54
Kojto 109:9296ab0bfc11 55 #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || ((PERIPH) == GPIOB) || \
Kojto 109:9296ab0bfc11 56 ((PERIPH) == GPIOC) || ((PERIPH) == GPIOD) )
Kojto 109:9296ab0bfc11 57
Kojto 109:9296ab0bfc11 58 typedef enum
Kojto 109:9296ab0bfc11 59 {
Kojto 109:9296ab0bfc11 60 GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */
Kojto 109:9296ab0bfc11 61 GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */
Kojto 109:9296ab0bfc11 62 GPIO_Mode_AF = 0x02 /*!< GPIO Alternate function Mode */
Kojto 109:9296ab0bfc11 63 }GPIOMode_TypeDef;
Kojto 109:9296ab0bfc11 64
Kojto 109:9296ab0bfc11 65 typedef enum
Kojto 109:9296ab0bfc11 66 {
Kojto 109:9296ab0bfc11 67 GPIO_NO_PUPD = 0x0ul,
Kojto 109:9296ab0bfc11 68 GPIO_PuPd_UP = Px_PCR_PUPD_UP,
Kojto 109:9296ab0bfc11 69 GPIO_PuPd_DOWN = Px_PCR_PUPD_DOWN,
Kojto 109:9296ab0bfc11 70 GPIO_PuPd_Default = 0x0ul,
AnnaBridge 170:e95d10626187 71 GPIO_DS = Px_PCR_DS_HIGH,
AnnaBridge 170:e95d10626187 72 GPIO_IE = Px_PCR_IE,
AnnaBridge 170:e95d10626187 73 GPIO_SUMMIT = Px_PCR_CS_SUMMIT
Kojto 109:9296ab0bfc11 74 }GPIOPad_TypeDef;
Kojto 109:9296ab0bfc11 75
AnnaBridge 170:e95d10626187 76 #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_UP) || ((PUPD) == GPIO_PuPd_DOWN))
AnnaBridge 170:e95d10626187 77
Kojto 109:9296ab0bfc11 78 typedef struct
Kojto 109:9296ab0bfc11 79 {
Kojto 109:9296ab0bfc11 80 uint32_t GPIO_Pin;
Kojto 109:9296ab0bfc11 81 GPIOMode_TypeDef GPIO_Mode;
Kojto 109:9296ab0bfc11 82 GPIOPad_TypeDef GPIO_Pad;
Kojto 109:9296ab0bfc11 83 }GPIO_InitTypeDef;
Kojto 109:9296ab0bfc11 84
Kojto 109:9296ab0bfc11 85 typedef enum
Kojto 109:9296ab0bfc11 86 {
AnnaBridge 170:e95d10626187 87 Falling = 0,
AnnaBridge 170:e95d10626187 88 Rising = 1
AnnaBridge 170:e95d10626187 89 }GPIOPol_TypeDef;
AnnaBridge 170:e95d10626187 90
AnnaBridge 170:e95d10626187 91 typedef enum
AnnaBridge 170:e95d10626187 92 {
AnnaBridge 170:e95d10626187 93 Reset = 0,
AnnaBridge 170:e95d10626187 94 Set = 1
AnnaBridge 170:e95d10626187 95 }GPIOSet_TypeDef;
AnnaBridge 170:e95d10626187 96
AnnaBridge 170:e95d10626187 97 typedef enum
AnnaBridge 170:e95d10626187 98 {
Kojto 109:9296ab0bfc11 99 Bit_RESET = 0,
Kojto 109:9296ab0bfc11 100 Bit_SET
Kojto 109:9296ab0bfc11 101 }BitAction;
Kojto 109:9296ab0bfc11 102
Kojto 109:9296ab0bfc11 103
AnnaBridge 170:e95d10626187 104 #define IS_PAD_TYPE(Px) (((Px) == PAD_PA) || ((Px) == PAD_PB) || \
Kojto 109:9296ab0bfc11 105 ((Px) == PAD_PC) || ((Px) == PAD_PD))
Kojto 109:9296ab0bfc11 106
Kojto 109:9296ab0bfc11 107 #define IS_PA_NUM(NUM) (((NUM)>=0) && ((NUM)<16))
Kojto 109:9296ab0bfc11 108 #define IS_PB_NUM(NUM) (((NUM)>=0) && ((NUM)<16))
Kojto 109:9296ab0bfc11 109 #define IS_PC_NUM(NUM) (((NUM)>=0) && ((NUM)<16))
Kojto 109:9296ab0bfc11 110 #define IS_PD_NUM(NUM) (((NUM)>=0) && ((NUM)< 5))
Kojto 109:9296ab0bfc11 111
Kojto 109:9296ab0bfc11 112 #define IS_PAD_AF(AF) (((AF) == PAD_AF0) || ((AF) == PAD_AF1) || \
Kojto 109:9296ab0bfc11 113 ((AF) == PAD_AF2) || ((AF) == PAD_AF3))
Kojto 109:9296ab0bfc11 114
Kojto 109:9296ab0bfc11 115
Kojto 109:9296ab0bfc11 116 #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION_ == Bit_RESET) || (ACTION) ==Bit_SET))
Kojto 109:9296ab0bfc11 117
Kojto 109:9296ab0bfc11 118 void HAL_GPIO_DeInit(GPIO_TypeDef* GPIOx);
Kojto 109:9296ab0bfc11 119 void HAL_GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
Kojto 109:9296ab0bfc11 120 void HAL_GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
Kojto 109:9296ab0bfc11 121 uint8_t HAL_GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Kojto 109:9296ab0bfc11 122 uint16_t HAL_GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
Kojto 109:9296ab0bfc11 123 uint8_t HAL_GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Kojto 109:9296ab0bfc11 124 uint16_t HAL_GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
Kojto 109:9296ab0bfc11 125 void HAL_GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Kojto 109:9296ab0bfc11 126 void HAL_GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Kojto 109:9296ab0bfc11 127 void HAL_GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
Kojto 109:9296ab0bfc11 128 void HAL_GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
Kojto 109:9296ab0bfc11 129 void HAL_PAD_AFConfig(PAD_Type Px, uint16_t Pnum, PAD_AF_TypeDef P_AF);
Kojto 109:9296ab0bfc11 130
Kojto 109:9296ab0bfc11 131 void GPIO_OutEnClr(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Kojto 109:9296ab0bfc11 132 void GPIO_OutEnSet(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
Kojto 109:9296ab0bfc11 133
Kojto 109:9296ab0bfc11 134
Kojto 109:9296ab0bfc11 135 #ifdef __cplusplus
Kojto 109:9296ab0bfc11 136 }
Kojto 109:9296ab0bfc11 137 #endif
Kojto 109:9296ab0bfc11 138
Kojto 109:9296ab0bfc11 139 #endif // __W7500X_HAL_GPIO_H