Skip to content

Commit c4b32cd

Browse files
authored
Merge pull request #10617 from Wiznet/wiznet_develop
Change W7500 GPIO Driver
2 parents 77ca32d + 2a69c6d commit c4b32cd

File tree

1 file changed

+18
-10
lines changed
  • targets/TARGET_WIZNET/TARGET_W7500x/W7500x_Peripheral_Library

1 file changed

+18
-10
lines changed

targets/TARGET_WIZNET/TARGET_W7500x/W7500x_Peripheral_Library/W7500x_gpio.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void HAL_GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
8181
{
8282
if(GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT)
8383
{
84-
GPIOx->OUTENSET |= pos;
84+
GPIOx->OUTENSET = pos;
8585
}
8686
else // GPIO_Mode_In
8787
{
@@ -199,8 +199,10 @@ void HAL_GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
199199
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
200200
assert_param(IS_GPIO_PIN(GPIO_Pin));
201201

202-
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = GPIO_Pin;
203-
(GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = GPIO_Pin;
202+
if (GPIO_Pin < 256)
203+
(GPIOx->LB_MASKED[(uint8_t) (GPIO_Pin)]) = 0xFFFF;
204+
else
205+
(GPIOx->UB_MASKED[(uint8_t) ((GPIO_Pin) >> 8)]) = 0xFFFF;
204206
}
205207

206208
void HAL_GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
@@ -209,8 +211,10 @@ void HAL_GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
209211
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
210212
assert_param(IS_GPIO_PIN(GPIO_Pin));
211213

212-
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = ~(GPIO_Pin);
213-
(GPIOx->UB_MASKED[(uint8_t)(GPIO_Pin>>8)]) = ~(GPIO_Pin);
214+
if (GPIO_Pin < 256)
215+
(GPIOx->LB_MASKED[(uint8_t) (GPIO_Pin)]) = 0x0;
216+
else
217+
(GPIOx->UB_MASKED[(uint8_t) (GPIO_Pin >> 8)]) = 0x0;
214218
}
215219

216220
void HAL_GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
@@ -226,15 +230,19 @@ void HAL_GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
226230
temp_gpio_lb = (GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]);
227231
temp_gpio_ub = (GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]);
228232

229-
if( BitVal == Bit_SET)
233+
if (GPIO_Pin < 256)
230234
{
231-
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = (temp_gpio_lb | GPIO_Pin);
232-
(GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = (temp_gpio_ub | GPIO_Pin);
235+
if(BitVal)
236+
(GPIOx->LB_MASKED[(uint8_t) (GPIO_Pin)]) = 0xFFFF;
237+
else
238+
(GPIOx->LB_MASKED[(uint8_t) (GPIO_Pin)]) = 0x0;
233239
}
234240
else
235241
{
236-
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = (temp_gpio_lb & ~(GPIO_Pin));
237-
(GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = (temp_gpio_ub & ~(GPIO_Pin));
242+
if(BitVal)
243+
(GPIOx->UB_MASKED[(uint8_t) (GPIO_Pin)]) = 0xFFFF;
244+
else
245+
(GPIOx->UB_MASKED[(uint8_t) (GPIO_Pin)]) = 0x0;
238246
}
239247
}
240248

0 commit comments

Comments
 (0)