Skip to content

Commit bfd1361

Browse files
committed
Merge pull request #1178 from Wiznet/master
Wiznet - Change target name and support InterruptIn function.
2 parents bf69fa1 + 60a87d9 commit bfd1361

File tree

14 files changed

+466
-133
lines changed

14 files changed

+466
-133
lines changed

libraries/mbed/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/W7500x.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,15 @@ typedef struct
661661
#define PWM_CH6 ((PWM_CHn_TypeDef *) (W7500x_PWM_BASE + 0x600UL))
662662
#define PWM_CH7 ((PWM_CHn_TypeDef *) (W7500x_PWM_BASE + 0x700UL))
663663

664+
#define PWM_CH0_BASE (W7500x_PWM_BASE)
665+
#define PWM_CH1_BASE (W7500x_PWM_BASE + 0x100UL)
666+
#define PWM_CH2_BASE (W7500x_PWM_BASE + 0x200UL)
667+
#define PWM_CH3_BASE (W7500x_PWM_BASE + 0x300UL)
668+
#define PWM_CH4_BASE (W7500x_PWM_BASE + 0x400UL)
669+
#define PWM_CH5_BASE (W7500x_PWM_BASE + 0x500UL)
670+
#define PWM_CH6_BASE (W7500x_PWM_BASE + 0x600UL)
671+
#define PWM_CH7_BASE (W7500x_PWM_BASE + 0x700UL)
672+
664673
#define RNG ((RNG_TypeDef *) W7500x_RNG_BASE)
665674

666675
#define SSP0 ((SSP_TypeDef*) (SSP0_BASE))

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/PeripheralPins.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ extern const PinMap PinMap_SPI_SCLK[];
5353
extern const PinMap PinMap_SPI_MOSI[];
5454
extern const PinMap PinMap_SPI_MISO[];
5555
extern const PinMap PinMap_SPI_SSEL[];
56+
57+
//*** PWM ***
58+
59+
extern const PinMap PinMap_PWM[];
5660
#endif

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralNames.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ typedef enum {
6060
I2C_1 = (int)I2C1_BASE
6161
} I2CName;
6262

63-
typedef enum {
64-
PWM_1 = 0
65-
// PWM_1 = (int)TIM1_BASE,
66-
// PWM_3 = (int)TIM3_BASE,
67-
// PWM_14 = (int)TIM14_BASE,
68-
// PWM_15 = (int)TIM15_BASE,
69-
// PWM_16 = (int)TIM16_BASE,
70-
// PWM_17 = (int)TIM17_BASE
63+
typedef enum {
64+
PWM_0 = (int)PWM_CH0_BASE,
65+
PWM_1 = (int)PWM_CH1_BASE,
66+
PWM_2 = (int)PWM_CH2_BASE,
67+
PWM_3 = (int)PWM_CH3_BASE,
68+
PWM_4 = (int)PWM_CH4_BASE,
69+
PWM_5 = (int)PWM_CH5_BASE,
70+
PWM_6 = (int)PWM_CH6_BASE,
71+
PWM_7 = (int)PWM_CH7_BASE
7172
} PWMName;
7273

7374
#ifdef __cplusplus

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,56 @@ const PinMap PinMap_I2C_SCL[] = {
7272
//*** SPI ***
7373

7474
const PinMap PinMap_SPI_SCLK[] = {
75-
{PA_6 , SPI_0, 0},
76-
{PB_1 , SPI_1, 0},
77-
{PC_12, SPI_0, 3},
78-
{PA_12, SPI_1, 3},
75+
{PA_6 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
76+
{PB_1 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
77+
{PC_12, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
78+
{PA_12, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
7979
{NC , NC , 0}
8080
};
8181

8282
const PinMap PinMap_SPI_MOSI[] = {
83-
{PA_8 , SPI_0, 0},
84-
{PB_3 , SPI_1, 0},
85-
{PC_10, SPI_0, 3},
86-
{PA_14, SPI_1, 3},
83+
{PA_8 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
84+
{PB_3 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
85+
{PC_10, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
86+
{PA_14, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
8787
{NC , NC , 0}
8888
};
8989

9090
const PinMap PinMap_SPI_MISO[] = {
91-
{PA_7 , SPI_0, 0},
92-
{PB_2 , SPI_1, 0},
93-
{PC_11, SPI_0, 3},
94-
{PA_13, SPI_1, 3},
91+
{PA_7 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
92+
{PB_2 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
93+
{PC_11, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
94+
{PA_13, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
9595
{NC , NC , 0}
9696
};
9797

9898
const PinMap PinMap_SPI_SSEL[] = {
99-
{PA_5 , SPI_0, 0},
100-
{PB_0 , SPI_1, 0},
101-
{PC_13, SPI_0, 3},
102-
{PA_11, SPI_1, 3},
99+
{PA_5 , SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
100+
{PB_0 , SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
101+
{PC_13, SPI_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
102+
{PA_11, SPI_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
103103
{NC , NC , 0}
104104
};
105105

106+
const PinMap PinMap_PWM[] = {
107+
{PA_0 , PWM_6, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
108+
{PA_1 , PWM_7, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
109+
{PA_5 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
110+
{PA_6 , PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
111+
{PA_7 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
112+
{PA_8 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
113+
{PA_9 , PWM_6, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
114+
{PA_10, PWM_7, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
115+
{PC_0 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
116+
{PC_1 , PWM_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
117+
{PC_2 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
118+
{PC_3 , PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
119+
{PC_4 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
120+
{PC_5 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
121+
{PC_8 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
122+
{PC_9 , PWM_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
123+
{PC_10, PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
124+
{PC_11, PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
125+
{NC , NC , WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)}
126+
};
127+

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PinNames.h

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ extern "C" {
3939

4040

4141
// See W7500x_hal_gpio.h for values of MODE, PUPD and AFNUM
42-
#define WIZ_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 8) | ((PUPD) << 4) | ((MODE) << 0)))
43-
#define WIZ_PIN_MODE(X) (((X) >> 0) & 0x0F)
42+
#define WIZ_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((MODE) << 8) | ((PUPD) << 4) | ((AFNUM) << 0)))
4443
#define WIZ_PIN_PUPD(X) (((X) >> 4) & 0x0F)
45-
#define WIZ_PIN_AFNUM(X) (((X) >> 8) & 0x0F)
44+
#define WIZ_PIN_AFNUM(X) (((X) >> 0) & 0x0F)
45+
#define WIZ_PIN_MODE(X) (((X) >> 8) & 0x0F)
4646
#define WIZ_MODE_INPUT (0)
4747
#define WIZ_MODE_OUTPUT (1)
4848
#define WIZ_MODE_AF (2)
@@ -53,9 +53,9 @@ extern "C" {
5353
#define WIZ_GPIO_OPEN_DRAIN (3) /*!< Open Drain activation */
5454

5555

56-
#define WIZ_AFNUM(X)(((uint32_t)(X) >> 8) & 0xF) // AF number (0=AF0, 1=AF1, 2=AF2, 3=AF3)
5756
#define WIZ_PORT(X) (((uint32_t)(X) >> 4) & 0xF) // port number (0=A, 1=B, 2=C, 3=D)
58-
#define WIZ_PIN(X) ((uint32_t)(X) & 0xF) // pin number
57+
#define WIZ_PIN_NUM(X) ((uint32_t)(X) & 0xF) // pin number
58+
#define WIZ_PIN_INDEX(X) (1 << ((uint32_t)(X) & 0xF)) // pin index : flag bit
5959

6060

6161
typedef enum {
@@ -65,8 +65,7 @@ typedef enum {
6565

6666

6767
typedef enum {
68-
// W7500x Pin Names (AF[9:8] + PORT[5:4] + PIN[3:0])
69-
68+
// W7500x PORT[5:4] + PIN[3:0])
7069
PA_0 = 0x000,
7170
PA_1 = 0x001,
7271
PA_2 = 0x002,
@@ -83,7 +82,7 @@ typedef enum {
8382
PA_13 = 0x00D,
8483
PA_14 = 0x00E,
8584
PA_15 = 0x00F,
86-
85+
8786
PB_0 = 0x010, //SSEL1/SD_SEL
8887
PB_1 = 0x011, //SCLK1/SD_CLK
8988
PB_2 = 0x012, //MISO1/SD_MISO
@@ -100,25 +99,25 @@ typedef enum {
10099
PB_13 = 0x01D,
101100
PB_14 = 0x01E,
102101
PB_15 = 0x01F,
103-
104-
PC_0 = 0x120, // 0xx:U_CTS1, 1xx:GPIOC_0, 2xx:PWM0
105-
PC_1 = 0x121, // 0xx:U_RTS1, 1xx:GPIOC_1, 2xx:PWM1
102+
103+
PC_0 = 0x020, // 0xx:U_CTS1, 1xx:GPIOC_0, 2xx:PWM0
104+
PC_1 = 0x021, // 0xx:U_RTS1, 1xx:GPIOC_1, 2xx:PWM1
106105
PC_2 = 0x022,
107106
PC_3 = 0x023,
108-
PC_4 = 0x124, // 0xx:SDA1, 1xx:GPIOC_4, 2xx:PWM4
107+
PC_4 = 0x024, // 0xx:SDA1, 1xx:GPIOC_4, 2xx:PWM4
109108
PC_5 = 0x025,
110109
PC_6 = 0x026,
111110
PC_7 = 0x027,
112-
PC_8 = 0x128, // 0xx:PWM0, 1xx:GPIOC_8, 2xx:SCL0, 3xx:AIN7
113-
PC_9 = 0x129, // 0xx:PWM1, 1xx:GPIOC_9, 2xx:SDA0, 3xx:AIN6
114-
115-
PC_10 = 0x32A, // 0xx:U_TXD2, 1xx:GPIOC_10, 2xx:PWM2, 3xx:AIN5
116-
PC_11 = 0x32B, // 0xx:U_RXD2, 1xx:GPIOC_11, 2xx:PWM3, 3xx:AIN4
117-
PC_12 = 0x32C, // 0xx:AIN3, 1xx:GPIOC_12, 2xx:SSEL0, 3xx:AIN3
118-
PC_13 = 0x32D, // 0xx:AIN2, 1xx:GPIOC_13, 2xx:SCLK0, 3xx:AIN2
119-
PC_14 = 0x32E, // 0xx:AIN1, 1xx:GPIOC_14, 2xx:MISO0, 3xx:AIN1
120-
PC_15 = 0x32F, // 0xx:AIN0, 1xx:GPIOC_15, 2xx:MOSI0, 3xx:AIN0
121-
111+
PC_8 = 0x028, // 0xx:PWM0, 1xx:GPIOC_8, 2xx:SCL0, 3xx:AIN7
112+
PC_9 = 0x029, // 0xx:PWM1, 1xx:GPIOC_9, 2xx:SDA0, 3xx:AIN6
113+
114+
PC_10 = 0x02A, // 0xx:U_TXD2, 1xx:GPIOC_10, 2xx:PWM2, 3xx:AIN5
115+
PC_11 = 0x02B, // 0xx:U_RXD2, 1xx:GPIOC_11, 2xx:PWM3, 3xx:AIN4
116+
PC_12 = 0x02C, // 0xx:AIN3, 1xx:GPIOC_12, 2xx:SSEL0, 3xx:AIN3
117+
PC_13 = 0x02D, // 0xx:AIN2, 1xx:GPIOC_13, 2xx:SCLK0, 3xx:AIN2
118+
PC_14 = 0x02E, // 0xx:AIN1, 1xx:GPIOC_14, 2xx:MISO0, 3xx:AIN1
119+
PC_15 = 0x02F, // 0xx:AIN0, 1xx:GPIOC_15, 2xx:MOSI0, 3xx:AIN0
120+
122121
PD_0 = 0x030,
123122
PD_1 = 0x031,
124123
PD_2 = 0x032,
@@ -185,7 +184,6 @@ typedef enum {
185184
PullNone = 0,
186185
PullDown = 1,
187186
PullUp = 2,
188-
OpenDrain = 3,
189187
PullDefault = PullNone
190188
} PinMode;
191189

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
#define DEVICE_RTC 0
5252

53-
#define DEVICE_PWMOUT 0
53+
#define DEVICE_PWMOUT 1
5454

5555
#define DEVICE_SLEEP 0
5656

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/objects.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ extern "C" {
4343

4444
struct gpio_irq_s {
4545
IRQn_Type irq_n;
46-
uint32_t irq_index;
4746
uint32_t event;
4847
PinName pin;
48+
uint32_t pin_index;
49+
uint32_t pin_num;
50+
uint32_t port_num;
51+
uint32_t rise_null;
52+
uint32_t fall_null;
4953
};
5054

5155
struct port_s {
@@ -83,10 +87,11 @@ struct i2c_s {
8387
};
8488

8589
struct pwmout_s {
86-
PWMName pwm;
90+
PWM_CHn_TypeDef * PWM_CHx;
8791
PinName pin;
8892
uint32_t period;
8993
uint32_t pulse;
94+
uint32_t PrescalerValue;
9095
};
9196

9297
#include "gpio_object.h"

libraries/mbed/targets/hal/TARGET_WIZNET/TARGET_W7500x/gpio_api.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,38 @@
3434

3535
extern uint32_t Get_GPIO_BaseAddress(uint32_t port_idx);
3636

37-
uint32_t gpio_set(PinName pin)
38-
{
39-
MBED_ASSERT(pin != (PinName)NC);
37+
//uint32_t gpio_set(PinName pin)
38+
//{
39+
// MBED_ASSERT(pin != (PinName)NC);
4040

41-
pin_function(pin, WIZ_PIN_DATA(WIZ_MODE_INPUT, WIZ_GPIO_NOPULL, 0));
41+
// //pin_function(pin, WIZ_PIN_DATA(WIZ_MODE_INPUT, WIZ_GPIO_NOPULL, 1));
4242

43-
return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask
44-
}
43+
// return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask
44+
//}
4545

4646
void gpio_init(gpio_t *obj, PinName pin)
4747
{
48-
obj->pin = pin;
4948
if (pin == (PinName)NC) {
5049
return;
5150
}
52-
53-
uint32_t port_index = WIZ_PORT(pin);
54-
55-
GPIO_TypeDef *gpio = (GPIO_TypeDef *)Get_GPIO_BaseAddress(port_index);
56-
57-
// Fill GPIO object structure for future use
58-
obj->mask = gpio_set(pin);
51+
52+
obj->port_num = WIZ_PORT(pin);
53+
obj->pin_index = WIZ_PIN_INDEX(pin);
54+
obj->pin = pin;
55+
GPIO_TypeDef *gpio = (GPIO_TypeDef *)Get_GPIO_BaseAddress(obj->port_num);
5956
obj->reg_data_in = &gpio->DATA;
6057
}
6158

6259
void gpio_mode(gpio_t *obj, PinMode mode)
6360
{
6461
pin_mode(obj->pin, mode);
62+
obj->mode = mode;
6563
}
6664

6765
void gpio_dir(gpio_t *obj, PinDirection direction)
6866
{
6967
MBED_ASSERT(obj->pin != (PinName)NC);
7068
obj->direction = direction;
7169

72-
if (direction == PIN_OUTPUT) {
73-
pin_function(obj->pin, WIZ_PIN_DATA(WIZ_MODE_OUTPUT, WIZ_GPIO_NOPULL, 0));
74-
} else { // PIN_INPUT
75-
pin_function(obj->pin, WIZ_PIN_DATA(WIZ_MODE_INPUT, WIZ_GPIO_NOPULL, 0));
76-
}
70+
pin_function(obj->pin, WIZ_PIN_DATA(obj->direction, obj->mode, 1));
7771
}

0 commit comments

Comments
 (0)