Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
targets/hal/TARGET_WIZNET/TARGET_W7500x/W7500x_Peripheral_Library/W7500x_exti.c@636:a11c0372f0ba, 2015-09-30 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Sep 30 17:00:09 2015 +0100
- Revision:
- 636:a11c0372f0ba
- Parent:
- 620:034e698bc035
Synchronized with git revision d29c98dae61be0946ddf3a3c641c7726056f9452
Full URL: https://github.com/mbedmicro/mbed/commit/d29c98dae61be0946ddf3a3c641c7726056f9452/
Added support for SAMW25
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 620:034e698bc035 | 1 | #include "W7500x.h" |
mbed_official | 620:034e698bc035 | 2 | #include "W7500x_exti.h" |
mbed_official | 620:034e698bc035 | 3 | #include "W7500x_gpio.h" |
mbed_official | 620:034e698bc035 | 4 | |
mbed_official | 620:034e698bc035 | 5 | |
mbed_official | 620:034e698bc035 | 6 | /** |
mbed_official | 620:034e698bc035 | 7 | * @brief Deinitializes the EXTI peripheral registers to their default reset values. |
mbed_official | 620:034e698bc035 | 8 | * @param None |
mbed_official | 620:034e698bc035 | 9 | * @retval None |
mbed_official | 620:034e698bc035 | 10 | */ |
mbed_official | 620:034e698bc035 | 11 | void EXTI_DeInit(void) |
mbed_official | 620:034e698bc035 | 12 | { |
mbed_official | 620:034e698bc035 | 13 | uint32_t i, loop =16; |
mbed_official | 620:034e698bc035 | 14 | for(i=0; i<loop; i++) |
mbed_official | 620:034e698bc035 | 15 | { |
mbed_official | 620:034e698bc035 | 16 | EXTI_PA->Port[i] = 0x00; |
mbed_official | 620:034e698bc035 | 17 | EXTI_PB->Port[i] = 0x00; |
mbed_official | 620:034e698bc035 | 18 | EXTI_PC->Port[i] = 0x00; |
mbed_official | 620:034e698bc035 | 19 | } |
mbed_official | 620:034e698bc035 | 20 | for(i=0; i<5; i++) |
mbed_official | 620:034e698bc035 | 21 | { |
mbed_official | 620:034e698bc035 | 22 | EXTI_PD->Port[i] = 0x00; |
mbed_official | 620:034e698bc035 | 23 | } |
mbed_official | 620:034e698bc035 | 24 | } |
mbed_official | 620:034e698bc035 | 25 | |
mbed_official | 620:034e698bc035 | 26 | /** |
mbed_official | 620:034e698bc035 | 27 | * @brief Initializes the EXTI peripheral according to the specified |
mbed_official | 620:034e698bc035 | 28 | * parameters in the EXTI_InitStruct. |
mbed_official | 620:034e698bc035 | 29 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure |
mbed_official | 620:034e698bc035 | 30 | * that contains the configuration information for the EXTI peripheral. |
mbed_official | 620:034e698bc035 | 31 | * @retval None |
mbed_official | 620:034e698bc035 | 32 | */ |
mbed_official | 620:034e698bc035 | 33 | void EXTI_Init(PAD_Type Px, EXTI_InitTypeDef* EXTI_InitStruct) |
mbed_official | 620:034e698bc035 | 34 | { |
mbed_official | 620:034e698bc035 | 35 | uint32_t pinpos = 0x00, pos = 0x00, currentpin = 0x00, loop = 16; |
mbed_official | 620:034e698bc035 | 36 | P_Port_Def *px_exti; |
mbed_official | 620:034e698bc035 | 37 | |
mbed_official | 620:034e698bc035 | 38 | assert_param(IS_PAD_TYPE(Px)); |
mbed_official | 620:034e698bc035 | 39 | |
mbed_official | 620:034e698bc035 | 40 | if (Px == PAD_PA) px_exti = EXTI_PA; |
mbed_official | 620:034e698bc035 | 41 | else if (Px == PAD_PB) px_exti = EXTI_PB; |
mbed_official | 620:034e698bc035 | 42 | else if (Px == PAD_PC) px_exti = EXTI_PC; |
mbed_official | 620:034e698bc035 | 43 | else |
mbed_official | 620:034e698bc035 | 44 | { |
mbed_official | 620:034e698bc035 | 45 | px_exti = (P_Port_Def*)EXTI_PD; |
mbed_official | 620:034e698bc035 | 46 | loop = 5; |
mbed_official | 620:034e698bc035 | 47 | } |
mbed_official | 620:034e698bc035 | 48 | |
mbed_official | 620:034e698bc035 | 49 | for(pinpos = 0x00; pinpos < loop; pinpos++) |
mbed_official | 620:034e698bc035 | 50 | { |
mbed_official | 620:034e698bc035 | 51 | pos = ((uint32_t)0x01) << pinpos; |
mbed_official | 620:034e698bc035 | 52 | |
mbed_official | 620:034e698bc035 | 53 | currentpin = (EXTI_InitStruct->EXTI_Line) & pos; |
mbed_official | 620:034e698bc035 | 54 | if(currentpin == pos) |
mbed_official | 620:034e698bc035 | 55 | { |
mbed_official | 620:034e698bc035 | 56 | px_exti->Port[pinpos] |= EXTI_Px_INTEN_ENABLE; |
mbed_official | 620:034e698bc035 | 57 | |
mbed_official | 620:034e698bc035 | 58 | if(EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising) |
mbed_official | 620:034e698bc035 | 59 | px_exti->Port[pinpos] |= EXTI_Px_INTPOR_RISING_EDGE; |
mbed_official | 620:034e698bc035 | 60 | else |
mbed_official | 620:034e698bc035 | 61 | px_exti->Port[pinpos] |= EXTI_Px_INTPOR_FALLING_EDGE; |
mbed_official | 620:034e698bc035 | 62 | } |
mbed_official | 620:034e698bc035 | 63 | } |
mbed_official | 620:034e698bc035 | 64 | |
mbed_official | 620:034e698bc035 | 65 | } |
mbed_official | 620:034e698bc035 | 66 | |
mbed_official | 620:034e698bc035 | 67 | void EXTI_Polarity_Set(PAD_Type Px, uint16_t GPIO_Pin, uint16_t Polarity ) |
mbed_official | 620:034e698bc035 | 68 | { |
mbed_official | 620:034e698bc035 | 69 | uint32_t pinpos = 0x00, pos = 0x00, currentpin = 0x00, loop = 16; |
mbed_official | 620:034e698bc035 | 70 | P_Port_Def *px_exti; |
mbed_official | 620:034e698bc035 | 71 | |
mbed_official | 620:034e698bc035 | 72 | assert_param(IS_PAD_TYPE(Px)); |
mbed_official | 620:034e698bc035 | 73 | |
mbed_official | 620:034e698bc035 | 74 | if (Px == PAD_PA) px_exti = EXTI_PA; |
mbed_official | 620:034e698bc035 | 75 | else if (Px == PAD_PB) px_exti = EXTI_PB; |
mbed_official | 620:034e698bc035 | 76 | else if (Px == PAD_PC) px_exti = EXTI_PC; |
mbed_official | 620:034e698bc035 | 77 | else |
mbed_official | 620:034e698bc035 | 78 | { |
mbed_official | 620:034e698bc035 | 79 | px_exti = (P_Port_Def*)EXTI_PD; |
mbed_official | 620:034e698bc035 | 80 | loop = 5; |
mbed_official | 620:034e698bc035 | 81 | } |
mbed_official | 620:034e698bc035 | 82 | |
mbed_official | 620:034e698bc035 | 83 | for(pinpos = 0x00; pinpos < loop; pinpos++) |
mbed_official | 620:034e698bc035 | 84 | { |
mbed_official | 620:034e698bc035 | 85 | pos = ((uint32_t)0x01) << pinpos; |
mbed_official | 620:034e698bc035 | 86 | |
mbed_official | 620:034e698bc035 | 87 | currentpin = GPIO_Pin & pos; |
mbed_official | 620:034e698bc035 | 88 | if(currentpin == pos) |
mbed_official | 620:034e698bc035 | 89 | { |
mbed_official | 620:034e698bc035 | 90 | if(Polarity == EXTI_Trigger_Rising) |
mbed_official | 620:034e698bc035 | 91 | px_exti->Port[pinpos] |= EXTI_Px_INTPOR_RISING_EDGE; |
mbed_official | 620:034e698bc035 | 92 | else |
mbed_official | 620:034e698bc035 | 93 | px_exti->Port[pinpos] |= EXTI_Px_INTPOR_FALLING_EDGE; |
mbed_official | 620:034e698bc035 | 94 | } |
mbed_official | 620:034e698bc035 | 95 | } |
mbed_official | 620:034e698bc035 | 96 | |
mbed_official | 620:034e698bc035 | 97 | } |
mbed_official | 620:034e698bc035 | 98 | |
mbed_official | 620:034e698bc035 | 99 | /** |
mbed_official | 620:034e698bc035 | 100 | * @brief Fills each EXTI_InitStruct member with its reset value. |
mbed_official | 620:034e698bc035 | 101 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will |
mbed_official | 620:034e698bc035 | 102 | * be initialized. |
mbed_official | 620:034e698bc035 | 103 | * @retval None |
mbed_official | 620:034e698bc035 | 104 | */ |
mbed_official | 620:034e698bc035 | 105 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) |
mbed_official | 620:034e698bc035 | 106 | { |
mbed_official | 620:034e698bc035 | 107 | EXTI_InitStruct->EXTI_Line = 0xFF; |
mbed_official | 620:034e698bc035 | 108 | EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; |
mbed_official | 620:034e698bc035 | 109 | EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; |
mbed_official | 620:034e698bc035 | 110 | } |
mbed_official | 620:034e698bc035 | 111 | |
mbed_official | 620:034e698bc035 | 112 | uint16_t EXTI_Px_GetEXTEN(PAD_Type Px) |
mbed_official | 620:034e698bc035 | 113 | { |
mbed_official | 620:034e698bc035 | 114 | uint32_t i, loop = 16; |
mbed_official | 620:034e698bc035 | 115 | uint16_t ret=0; |
mbed_official | 620:034e698bc035 | 116 | P_Port_Def *px_exti; |
mbed_official | 620:034e698bc035 | 117 | |
mbed_official | 620:034e698bc035 | 118 | assert_param(IS_PAD_TYPE(Px)); |
mbed_official | 620:034e698bc035 | 119 | |
mbed_official | 620:034e698bc035 | 120 | if (Px == PAD_PA) px_exti = EXTI_PA; |
mbed_official | 620:034e698bc035 | 121 | else if (Px == PAD_PB) px_exti = EXTI_PB; |
mbed_official | 620:034e698bc035 | 122 | else if (Px == PAD_PC) px_exti = EXTI_PC; |
mbed_official | 620:034e698bc035 | 123 | else |
mbed_official | 620:034e698bc035 | 124 | { |
mbed_official | 620:034e698bc035 | 125 | px_exti = (P_Port_Def*)EXTI_PD; |
mbed_official | 620:034e698bc035 | 126 | loop = 5; |
mbed_official | 620:034e698bc035 | 127 | } |
mbed_official | 620:034e698bc035 | 128 | |
mbed_official | 620:034e698bc035 | 129 | for(i = 0x00; i < loop; i++) |
mbed_official | 620:034e698bc035 | 130 | { |
mbed_official | 620:034e698bc035 | 131 | ret |= (((px_exti->Port[i]&0x2)>>1)<<i); |
mbed_official | 620:034e698bc035 | 132 | } |
mbed_official | 620:034e698bc035 | 133 | return ret; |
mbed_official | 620:034e698bc035 | 134 | } |
mbed_official | 620:034e698bc035 | 135 | |
mbed_official | 620:034e698bc035 | 136 | uint16_t EXTI_Px_GetEXTINTPOL(PAD_Type Px) |
mbed_official | 620:034e698bc035 | 137 | { |
mbed_official | 620:034e698bc035 | 138 | uint32_t i, loop = 16; |
mbed_official | 620:034e698bc035 | 139 | uint16_t ret=0; |
mbed_official | 620:034e698bc035 | 140 | P_Port_Def *px_exti; |
mbed_official | 620:034e698bc035 | 141 | |
mbed_official | 620:034e698bc035 | 142 | assert_param(IS_PAD_TYPE(Px)); |
mbed_official | 620:034e698bc035 | 143 | |
mbed_official | 620:034e698bc035 | 144 | if (Px == PAD_PA) px_exti = EXTI_PA; |
mbed_official | 620:034e698bc035 | 145 | else if (Px == PAD_PB) px_exti = EXTI_PB; |
mbed_official | 620:034e698bc035 | 146 | else if (Px == PAD_PC) px_exti = EXTI_PC; |
mbed_official | 620:034e698bc035 | 147 | else |
mbed_official | 620:034e698bc035 | 148 | { |
mbed_official | 620:034e698bc035 | 149 | px_exti = (P_Port_Def*)EXTI_PD; |
mbed_official | 620:034e698bc035 | 150 | loop = 5; |
mbed_official | 620:034e698bc035 | 151 | } |
mbed_official | 620:034e698bc035 | 152 | |
mbed_official | 620:034e698bc035 | 153 | for(i = 0x00; i < loop; i++) |
mbed_official | 620:034e698bc035 | 154 | { |
mbed_official | 620:034e698bc035 | 155 | ret |= ((px_exti->Port[i]&0x1)<<i); |
mbed_official | 620:034e698bc035 | 156 | } |
mbed_official | 620:034e698bc035 | 157 | return ret; |
mbed_official | 620:034e698bc035 | 158 | } |