Watchdog Timer

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Jul 31 15:00:09 2015 +0100
Revision:
602:248b0d2dd755
Parent:
558:0880f51c4036
Synchronized with git revision 9d276ebad7fd567e170326b8ba3f5ecbf2b021a3

Full URL: https://github.com/mbedmicro/mbed/commit/9d276ebad7fd567e170326b8ba3f5ecbf2b021a3/

Wiznet - I2c -> gpio

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 558:0880f51c4036 1 #include "W7500x.h"
mbed_official 558:0880f51c4036 2
mbed_official 558:0880f51c4036 3
mbed_official 558:0880f51c4036 4
mbed_official 558:0880f51c4036 5 void HAL_GPIO_DeInit(GPIO_TypeDef* GPIOx)
mbed_official 558:0880f51c4036 6 {
mbed_official 558:0880f51c4036 7 uint32_t i, loop =16;
mbed_official 558:0880f51c4036 8 P_Port_Def *px_pcr;
mbed_official 558:0880f51c4036 9 P_Port_Def *px_afsr;
mbed_official 558:0880f51c4036 10
mbed_official 558:0880f51c4036 11 /* Check the parameters */
mbed_official 558:0880f51c4036 12 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 13
mbed_official 558:0880f51c4036 14 /* DeInit GPIOx Registers */
mbed_official 558:0880f51c4036 15 GPIOx->DATA = 0x0000;
mbed_official 558:0880f51c4036 16 GPIOx->DATAOUT = 0x0000;
mbed_official 558:0880f51c4036 17 //GPIOx->OUTENSET = 0x0000;
mbed_official 558:0880f51c4036 18 GPIOx->OUTENCLR = 0xFFFF;
mbed_official 558:0880f51c4036 19 //GPIOx->INTENSET = 0x0000;
mbed_official 558:0880f51c4036 20 GPIOx->INTENCLR = 0xFFFF;
mbed_official 558:0880f51c4036 21 //GPIOx->INTTYPESET = 0x0000;
mbed_official 558:0880f51c4036 22 GPIOx->INTTYPECLR = 0xFFFF;
mbed_official 558:0880f51c4036 23 //GPIOx->INTPOLSET = 0x0000;
mbed_official 558:0880f51c4036 24 GPIOx->INTPOLCLR = 0xFFFF;
mbed_official 558:0880f51c4036 25
mbed_official 558:0880f51c4036 26
mbed_official 558:0880f51c4036 27 /* DeInit GPIOx
mbed_official 558:0880f51c4036 28 * Pad Control Register
mbed_official 558:0880f51c4036 29 * Pad Extern interrupt Enable Register
mbed_official 558:0880f51c4036 30 * Pad Alternate Function Select Register
mbed_official 558:0880f51c4036 31 */
mbed_official 558:0880f51c4036 32 if (GPIOx == GPIOA)
mbed_official 558:0880f51c4036 33 {
mbed_official 558:0880f51c4036 34 px_pcr = PA_PCR;
mbed_official 558:0880f51c4036 35 px_afsr = PA_AFSR;
mbed_official 558:0880f51c4036 36 }
mbed_official 558:0880f51c4036 37 else if (GPIOx == GPIOB)
mbed_official 558:0880f51c4036 38 {
mbed_official 558:0880f51c4036 39 px_pcr = PB_PCR;
mbed_official 558:0880f51c4036 40 px_afsr = PB_AFSR;
mbed_official 558:0880f51c4036 41 }
mbed_official 558:0880f51c4036 42 else if (GPIOx == GPIOC)
mbed_official 558:0880f51c4036 43 {
mbed_official 558:0880f51c4036 44 px_pcr = PC_PCR;
mbed_official 558:0880f51c4036 45 px_afsr = PC_AFSR;
mbed_official 558:0880f51c4036 46 }
mbed_official 558:0880f51c4036 47 else // if (GPIOx == GPIOD)
mbed_official 558:0880f51c4036 48 {
mbed_official 558:0880f51c4036 49 px_pcr = (P_Port_Def*)PD_PCR;
mbed_official 558:0880f51c4036 50 px_afsr = (P_Port_Def*)PD_AFSR;
mbed_official 558:0880f51c4036 51 loop = 5;
mbed_official 558:0880f51c4036 52 }
mbed_official 558:0880f51c4036 53
mbed_official 558:0880f51c4036 54 for(i=0; i<loop; i++)
mbed_official 558:0880f51c4036 55 {
mbed_official 558:0880f51c4036 56 px_pcr->Port[i] = 0x60;
mbed_official 558:0880f51c4036 57 px_afsr->Port[i] = PAD_AF0;
mbed_official 558:0880f51c4036 58
mbed_official 558:0880f51c4036 59 }
mbed_official 558:0880f51c4036 60 }
mbed_official 558:0880f51c4036 61
mbed_official 558:0880f51c4036 62 void HAL_GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
mbed_official 558:0880f51c4036 63 {
mbed_official 558:0880f51c4036 64 uint32_t pinpos = 0x00, pos = 0x00, currentpin = 0x00, loop = 16;
mbed_official 558:0880f51c4036 65 P_Port_Def *px_pcr;
mbed_official 558:0880f51c4036 66
mbed_official 558:0880f51c4036 67 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 68 assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
mbed_official 558:0880f51c4036 69 // assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
mbed_official 558:0880f51c4036 70
mbed_official 558:0880f51c4036 71 if (GPIOx == GPIOA) px_pcr = PA_PCR;
mbed_official 558:0880f51c4036 72 else if (GPIOx == GPIOB) px_pcr = PB_PCR;
mbed_official 558:0880f51c4036 73 else if (GPIOx == GPIOC) px_pcr = PC_PCR;
mbed_official 558:0880f51c4036 74 else
mbed_official 558:0880f51c4036 75 {
mbed_official 558:0880f51c4036 76 px_pcr = (P_Port_Def*)PD_PCR;
mbed_official 558:0880f51c4036 77 loop = 5;
mbed_official 558:0880f51c4036 78 }
mbed_official 558:0880f51c4036 79
mbed_official 558:0880f51c4036 80 for(pinpos = 0x00; pinpos < loop; pinpos++)
mbed_official 558:0880f51c4036 81 {
mbed_official 558:0880f51c4036 82 pos = ((uint32_t)0x01) << pinpos;
mbed_official 558:0880f51c4036 83
mbed_official 558:0880f51c4036 84 currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
mbed_official 558:0880f51c4036 85
mbed_official 558:0880f51c4036 86 if(currentpin == pos)
mbed_official 558:0880f51c4036 87 {
mbed_official 558:0880f51c4036 88 if(GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT)
mbed_official 558:0880f51c4036 89 {
mbed_official 558:0880f51c4036 90 GPIOx->OUTENSET |= pos;
mbed_official 558:0880f51c4036 91 }
mbed_official 558:0880f51c4036 92 else // GPIO_Mode_In
mbed_official 558:0880f51c4036 93 {
mbed_official 558:0880f51c4036 94 GPIOx->OUTENCLR = pos;
mbed_official 558:0880f51c4036 95 }
mbed_official 558:0880f51c4036 96
mbed_official 558:0880f51c4036 97 // Configure pull-up pull-down bits
mbed_official 558:0880f51c4036 98 if(GPIO_InitStruct->GPIO_Pad & Px_PCR_PUPD_UP)
mbed_official 558:0880f51c4036 99 {
mbed_official 558:0880f51c4036 100 px_pcr->Port[pinpos] &= ~(Px_PCR_PUPD_UP | Px_PCR_PUPD_DOWN);
mbed_official 558:0880f51c4036 101 px_pcr->Port[pinpos] |= Px_PCR_PUPD_UP;
mbed_official 558:0880f51c4036 102 }
mbed_official 558:0880f51c4036 103 else
mbed_official 558:0880f51c4036 104 {
mbed_official 558:0880f51c4036 105 px_pcr->Port[pinpos] &= ~(Px_PCR_PUPD_UP | Px_PCR_PUPD_DOWN);
mbed_official 558:0880f51c4036 106 px_pcr->Port[pinpos] |= Px_PCR_PUPD_DOWN;
mbed_official 558:0880f51c4036 107 }
mbed_official 558:0880f51c4036 108
mbed_official 558:0880f51c4036 109 // Configure Driving stregnth selections bit
mbed_official 558:0880f51c4036 110 if(GPIO_InitStruct->GPIO_Pad & Px_PCR_DS_HIGH)
mbed_official 558:0880f51c4036 111 {
mbed_official 558:0880f51c4036 112 px_pcr->Port[pinpos] |= Px_PCR_DS_HIGH;
mbed_official 558:0880f51c4036 113 }
mbed_official 558:0880f51c4036 114 else
mbed_official 558:0880f51c4036 115 {
mbed_official 558:0880f51c4036 116 px_pcr->Port[pinpos] &= ~(Px_PCR_DS_HIGH);
mbed_official 558:0880f51c4036 117 }
mbed_official 558:0880f51c4036 118
mbed_official 558:0880f51c4036 119 // Configure Open Drain selections bit
mbed_official 558:0880f51c4036 120 if(GPIO_InitStruct->GPIO_Pad & Px_PCR_OD)
mbed_official 558:0880f51c4036 121 {
mbed_official 558:0880f51c4036 122 px_pcr->Port[pinpos] |= Px_PCR_OD;
mbed_official 558:0880f51c4036 123 }
mbed_official 558:0880f51c4036 124 else
mbed_official 558:0880f51c4036 125 {
mbed_official 558:0880f51c4036 126 px_pcr->Port[pinpos] &= ~(Px_PCR_OD);
mbed_official 558:0880f51c4036 127 }
mbed_official 558:0880f51c4036 128
mbed_official 558:0880f51c4036 129 // Configure Input buffer enable selection bit
mbed_official 558:0880f51c4036 130 if(GPIO_InitStruct->GPIO_Pad & Px_PCR_IE)
mbed_official 558:0880f51c4036 131 {
mbed_official 558:0880f51c4036 132 px_pcr->Port[pinpos] |= Px_PCR_IE;
mbed_official 558:0880f51c4036 133 }
mbed_official 558:0880f51c4036 134 else
mbed_official 558:0880f51c4036 135 {
mbed_official 558:0880f51c4036 136 px_pcr->Port[pinpos] &= ~(Px_PCR_IE);
mbed_official 558:0880f51c4036 137 }
mbed_official 558:0880f51c4036 138
mbed_official 558:0880f51c4036 139 // Configure input type (CMOS input or Summit trigger input) select bit
mbed_official 558:0880f51c4036 140 if(GPIO_InitStruct->GPIO_Pad & Px_PCR_CS_SUMMIT)
mbed_official 558:0880f51c4036 141 {
mbed_official 558:0880f51c4036 142 px_pcr->Port[pinpos] |= Px_PCR_CS_SUMMIT;
mbed_official 558:0880f51c4036 143 }
mbed_official 558:0880f51c4036 144 else
mbed_official 558:0880f51c4036 145 {
mbed_official 558:0880f51c4036 146 px_pcr->Port[pinpos] &= ~(Px_PCR_CS_SUMMIT);
mbed_official 558:0880f51c4036 147 }
mbed_official 558:0880f51c4036 148 }
mbed_official 558:0880f51c4036 149 }
mbed_official 558:0880f51c4036 150 }
mbed_official 558:0880f51c4036 151
mbed_official 558:0880f51c4036 152 void HAL_GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
mbed_official 558:0880f51c4036 153 {
mbed_official 558:0880f51c4036 154 GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
mbed_official 558:0880f51c4036 155 GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
mbed_official 558:0880f51c4036 156 GPIO_InitStruct->GPIO_Pad = (GPIOPad_TypeDef)(GPIO_PuPd_UP);
mbed_official 558:0880f51c4036 157 }
mbed_official 558:0880f51c4036 158
mbed_official 558:0880f51c4036 159
mbed_official 558:0880f51c4036 160 uint8_t HAL_GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 558:0880f51c4036 161 {
mbed_official 558:0880f51c4036 162 uint8_t bitstatus = 0x00;
mbed_official 558:0880f51c4036 163
mbed_official 558:0880f51c4036 164 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 165 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
mbed_official 558:0880f51c4036 166
mbed_official 558:0880f51c4036 167 if((GPIOx->DATA & GPIO_Pin) != (uint32_t)Bit_RESET)
mbed_official 558:0880f51c4036 168 {
mbed_official 558:0880f51c4036 169 bitstatus = (uint8_t)Bit_SET;
mbed_official 558:0880f51c4036 170 }
mbed_official 558:0880f51c4036 171 else
mbed_official 558:0880f51c4036 172 {
mbed_official 558:0880f51c4036 173 bitstatus = (uint8_t)Bit_RESET;
mbed_official 558:0880f51c4036 174 }
mbed_official 558:0880f51c4036 175
mbed_official 558:0880f51c4036 176 return bitstatus;
mbed_official 558:0880f51c4036 177 }
mbed_official 558:0880f51c4036 178
mbed_official 602:248b0d2dd755 179 uint16_t HAL_GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
mbed_official 558:0880f51c4036 180 {
mbed_official 558:0880f51c4036 181 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 182 return ((uint16_t)GPIOx->DATA);
mbed_official 558:0880f51c4036 183 }
mbed_official 558:0880f51c4036 184
mbed_official 558:0880f51c4036 185 uint8_t HAL_GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 558:0880f51c4036 186 {
mbed_official 558:0880f51c4036 187 uint8_t bitstatus = 0x00;
mbed_official 558:0880f51c4036 188
mbed_official 558:0880f51c4036 189
mbed_official 558:0880f51c4036 190
mbed_official 558:0880f51c4036 191 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 192 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
mbed_official 558:0880f51c4036 193
mbed_official 558:0880f51c4036 194 if((GPIOx->DATAOUT & GPIO_Pin) != (uint32_t)Bit_RESET)
mbed_official 558:0880f51c4036 195 {
mbed_official 558:0880f51c4036 196 bitstatus = (uint8_t)Bit_SET;
mbed_official 558:0880f51c4036 197 }
mbed_official 558:0880f51c4036 198 else
mbed_official 558:0880f51c4036 199 {
mbed_official 558:0880f51c4036 200 bitstatus = (uint8_t)Bit_RESET;
mbed_official 558:0880f51c4036 201 }
mbed_official 558:0880f51c4036 202
mbed_official 558:0880f51c4036 203 return bitstatus;
mbed_official 558:0880f51c4036 204 }
mbed_official 558:0880f51c4036 205 uint16_t HAL_GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
mbed_official 558:0880f51c4036 206 {
mbed_official 558:0880f51c4036 207 /* Check the parameters */
mbed_official 558:0880f51c4036 208 assert_param(IS_GPIO_ALLPERIPH(GPIOx));
mbed_official 558:0880f51c4036 209 return ((uint16_t)GPIOx->DATAOUT);
mbed_official 558:0880f51c4036 210 }
mbed_official 558:0880f51c4036 211
mbed_official 558:0880f51c4036 212 void HAL_GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 558:0880f51c4036 213 {
mbed_official 558:0880f51c4036 214 /* Check the parameters */
mbed_official 558:0880f51c4036 215 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 216 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 558:0880f51c4036 217
mbed_official 558:0880f51c4036 218 (GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = GPIO_Pin;
mbed_official 558:0880f51c4036 219 (GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = GPIO_Pin;
mbed_official 558:0880f51c4036 220 }
mbed_official 558:0880f51c4036 221
mbed_official 558:0880f51c4036 222 void HAL_GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 558:0880f51c4036 223 {
mbed_official 558:0880f51c4036 224 /* Check the parameters */
mbed_official 558:0880f51c4036 225 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 226 assert_param(IS_GPIO_PIN(GPIO_Pin));
mbed_official 558:0880f51c4036 227
mbed_official 558:0880f51c4036 228 (GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = ~(GPIO_Pin);
mbed_official 558:0880f51c4036 229 (GPIOx->UB_MASKED[(uint8_t)(GPIO_Pin>>8)]) = ~(GPIO_Pin);
mbed_official 558:0880f51c4036 230 }
mbed_official 558:0880f51c4036 231
mbed_official 558:0880f51c4036 232 void HAL_GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
mbed_official 558:0880f51c4036 233 {
mbed_official 558:0880f51c4036 234 /* Check the parameters */
mbed_official 558:0880f51c4036 235 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 236 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
mbed_official 558:0880f51c4036 237 assert_param(IS_GPIO_BIT_ACTION(BitVal));
mbed_official 558:0880f51c4036 238
mbed_official 558:0880f51c4036 239 (GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = BitVal;
mbed_official 558:0880f51c4036 240 (GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = BitVal;
mbed_official 558:0880f51c4036 241 }
mbed_official 558:0880f51c4036 242
mbed_official 558:0880f51c4036 243 void HAL_GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
mbed_official 558:0880f51c4036 244 {
mbed_official 558:0880f51c4036 245 /* Check the parameters */
mbed_official 558:0880f51c4036 246 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
mbed_official 558:0880f51c4036 247
mbed_official 558:0880f51c4036 248 GPIOx->DATAOUT = PortVal;
mbed_official 558:0880f51c4036 249 }
mbed_official 558:0880f51c4036 250
mbed_official 558:0880f51c4036 251 void HAL_PAD_AFConfig(PAD_Type Px, uint16_t GPIO_Pin, PAD_AF_TypeDef P_AF)
mbed_official 558:0880f51c4036 252 {
mbed_official 558:0880f51c4036 253 int i;
mbed_official 558:0880f51c4036 254 uint16_t idx =0x1;
mbed_official 558:0880f51c4036 255 assert_param(IS_PAD_Type(Px));
mbed_official 558:0880f51c4036 256
mbed_official 558:0880f51c4036 257 for(i=0;i<16;i++)
mbed_official 558:0880f51c4036 258 {
mbed_official 558:0880f51c4036 259 if(GPIO_Pin & (idx<<i))
mbed_official 558:0880f51c4036 260 {
mbed_official 558:0880f51c4036 261 if(Px == PAD_PA)
mbed_official 558:0880f51c4036 262 {
mbed_official 558:0880f51c4036 263 assert_param(IS_PA_NUM(i));
mbed_official 558:0880f51c4036 264 PA_AFSR->Port[i] &= ~(0x03ul);
mbed_official 558:0880f51c4036 265 PA_AFSR->Port[i] |= P_AF;
mbed_official 558:0880f51c4036 266 }
mbed_official 558:0880f51c4036 267 else if(Px == PAD_PB)
mbed_official 558:0880f51c4036 268 {
mbed_official 558:0880f51c4036 269 assert_param(IS_PB_NUM(i));
mbed_official 558:0880f51c4036 270 PB_AFSR->Port[i] &= ~(0x03ul);
mbed_official 558:0880f51c4036 271 PB_AFSR->Port[i] |= P_AF;
mbed_official 558:0880f51c4036 272 }
mbed_official 558:0880f51c4036 273 else if(Px == PAD_PC)
mbed_official 558:0880f51c4036 274 {
mbed_official 558:0880f51c4036 275 assert_param(IS_PC_NUM(i));
mbed_official 558:0880f51c4036 276 PC_AFSR->Port[i] &= ~(0x03ul);
mbed_official 558:0880f51c4036 277 PC_AFSR->Port[i] |= P_AF;
mbed_official 558:0880f51c4036 278 }
mbed_official 558:0880f51c4036 279 else
mbed_official 558:0880f51c4036 280 {
mbed_official 558:0880f51c4036 281 assert_param(IS_PD_NUM(i));
mbed_official 558:0880f51c4036 282 PD_AFSR->Port[i] &= ~(0x03ul);
mbed_official 558:0880f51c4036 283 PD_AFSR->Port[i] |= P_AF;
mbed_official 558:0880f51c4036 284 }
mbed_official 558:0880f51c4036 285 }
mbed_official 558:0880f51c4036 286 }
mbed_official 558:0880f51c4036 287 }
mbed_official 558:0880f51c4036 288
mbed_official 602:248b0d2dd755 289 void GPIO_OutEnClr(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 602:248b0d2dd755 290 {
mbed_official 602:248b0d2dd755 291 GPIOx->OUTENCLR = GPIO_Pin;
mbed_official 602:248b0d2dd755 292 }
mbed_official 602:248b0d2dd755 293
mbed_official 602:248b0d2dd755 294 void GPIO_OutEnSet(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
mbed_official 602:248b0d2dd755 295 {
mbed_official 602:248b0d2dd755 296 GPIOx->OUTENSET = GPIO_Pin;
mbed_official 602:248b0d2dd755 297 }
mbed_official 602:248b0d2dd755 298