Julien Kern / mbed

Dependents:   Printf

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Jun 09 14:29:26 2015 +0100
Revision:
101:7cff1c4259d7
Release 101 of the mbed library

Changes:
- new platform: APPNEARME_MICRONFCBOARD, MTS_DRAGONFLY_F411RE, MAX32600MBED, WIZwiki_W7500
- Silabs memory optimization in gpio, pwm fixes
- SPI - ssel documentation fixes and its use

Who changed what in which revision?

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