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.
Diff: TARGET_WIZwiki_W7500/TARGET_WIZNET/TARGET_W7500x/gpio_object.h
- Revision:
- 102:da0ca467f8b5
- Parent:
- 101:7cff1c4259d7
- Child:
- 107:4f6c30876dfa
--- a/TARGET_WIZwiki_W7500/TARGET_WIZNET/TARGET_W7500x/gpio_object.h Tue Jun 09 14:29:26 2015 +0100 +++ b/TARGET_WIZwiki_W7500/TARGET_WIZNET/TARGET_W7500x/gpio_object.h Wed Jul 08 11:22:30 2015 +0100 @@ -39,8 +39,10 @@ typedef struct { PinName pin; - uint32_t mask; + uint32_t pin_index; + uint32_t port_num; uint32_t direction; + uint32_t mode; __IO uint32_t *reg_data_in; } gpio_t; @@ -51,20 +53,19 @@ static inline void gpio_write(gpio_t *obj, int value) { MBED_ASSERT(obj->pin != (PinName)NC); - uint32_t port_index = WIZ_PORT(obj->pin); - uint32_t pin_index = WIZ_PIN(obj->pin); + uint32_t port_num = WIZ_PORT(obj->pin); + uint32_t pin_index = WIZ_PIN_INDEX(obj->pin); - uint32_t gpio_add = Get_GPIO_BaseAddress(port_index); - GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; - + GPIO_TypeDef *gpio = (GPIO_TypeDef *)Get_GPIO_BaseAddress(port_num); + if (value) { - HAL_GPIO_SetBits(gpio,(0x01 << pin_index)); + HAL_GPIO_SetBits(gpio, pin_index); } else { - HAL_GPIO_ResetBits(gpio,(0x01 << pin_index)); + HAL_GPIO_ResetBits(gpio, pin_index); } } @@ -73,18 +74,17 @@ MBED_ASSERT(obj->pin != (PinName)NC); - uint32_t port_index = WIZ_PORT(obj->pin); + uint32_t port_num = WIZ_PORT(obj->pin); - uint32_t gpio_add = Get_GPIO_BaseAddress(port_index); - GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add; + GPIO_TypeDef *gpio = (GPIO_TypeDef *)Get_GPIO_BaseAddress(port_num); if(obj->direction == PIN_OUTPUT) { - ret = ( HAL_GPIO_ReadOutputData(gpio) & obj->mask ) ? 1 : 0; + ret = ( HAL_GPIO_ReadOutputData(gpio) & obj->pin_index ) ? 1 : 0; } else { - ret = ((*obj->reg_data_in & obj->mask) ? 1 : 0); + ret = ((*obj->reg_data_in & obj->pin_index) ? 1 : 0); } return ret;