mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Jun 30 09:45:08 2015 +0100
Parent:
575:30f9462b5296
Child:
577:15494b56c2f3
Commit message:
Synchronized with git revision 1c13bc80fedd0fdfaedfab5c33183dc2b6f9b1bb

Full URL: https://github.com/mbedmicro/mbed/commit/1c13bc80fedd0fdfaedfab5c33183dc2b6f9b1bb/

Wiznet - Update and bug fix.

Changed in this revision

targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_gpio.h Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_i2c.c Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_i2c.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/gpio_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_WIZNET/TARGET_W7500x/us_ticker.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_gpio.h	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_gpio.h	Tue Jun 30 09:45:08 2015 +0100
@@ -67,7 +67,7 @@
     GPIO_NO_PUPD = 0x0ul,
     GPIO_PuPd_UP = Px_PCR_PUPD_UP,
     GPIO_PuPd_DOWN = Px_PCR_PUPD_DOWN,
-    GPIO_OD = Px_PCR_OD,
+    GPIO_PuPd_Default = 0x0ul,
 }GPIOPad_TypeDef;
 
 typedef struct
--- a/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_i2c.c	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_i2c.c	Tue Jun 30 09:45:08 2015 +0100
@@ -4,6 +4,13 @@
   * @{
   */
 
+GPIO_InitTypeDef GPIO_InitDef;
+void i2c_loop_us(int us);
+
+#define SCL GPIO_Pin_9
+#define SDA GPIO_Pin_10
+uint16_t buf[] ={0x00,0x01};
+
 /**
   * @brief  Initializes the I2Cx peripheral according to the specified 
   *   parameters in the I2C_InitStruct.
@@ -12,10 +19,6 @@
   *   contains the configuration information for the specified I2C peripheral.
   * @retval None
   */
-void I2C_Delay(uint32_t nCount)
-{
-    for(; nCount != 0; nCount--);
-}
 
 uint32_t I2C_Init(I2C_TypeDef* I2Cx, I2C_ConfigStruct conf)
 {
@@ -67,7 +70,7 @@
 ErrorStatus I2C_Start(I2C_TypeDef* I2Cx, uint16_t slave_address, I2C_CTR ctr)
 {
     ErrorStatus ret;
-
+          
     I2C_GenerateSTART(I2Cx,ENABLE);
     I2C_SendSlaveAddress(I2Cx,slave_address,(I2C_CTR)ctr);
     I2C_GenerateSTART(I2Cx,DISABLE);
@@ -81,6 +84,10 @@
 {
     I2C_GenerateSTOP(I2Cx,ENABLE);
     I2C_GenerateSTOP(I2Cx,DISABLE);
+    GPIO_InitDef.GPIO_Pin = GPIO_Pin_9; // Set to Pin_9 (SCL0))
+    GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output
+    HAL_GPIO_Init(GPIOA, &GPIO_InitDef);
+    HAL_PAD_AFConfig(PAD_PA,GPIO_Pin_9, PAD_AF0); // PAD Config - LED used 2nd Function
 }
 
 void I2C_Reset(I2C_TypeDef* I2Cx)
@@ -97,28 +104,38 @@
 
 int8_t I2C_SendDataAck(I2C_TypeDef* I2Cx,uint16_t Data)
 {
-    I2Cx -> TXR = (uint16_t)Data;
-    if(I2C_CheckEvent(I2Cx,I2C_ACKR) == ERROR)
+    buf[0] = Data;
+    if(buf[0] == buf[1])
     {
-        return ERROR;
-    }           
+        I2C_GPIO();
+        WriteByte(Data);     
+        i2c_loop_us(1);
+        GPIO_I2C();
+    }
+    else
+    {
+        I2Cx -> TXR = (uint16_t)Data;
+        if(I2C_CheckEvent(I2Cx,I2C_ACKR) == ERROR)
+        {
+            return ERROR;
+        }           
+    }
+    buf[1] = buf[0];
     return SUCCESS;
 }
 
 int I2C_ReceiveData(I2C_TypeDef* I2Cx, int last)    
 {
-    if( I2C_CheckEvent(I2Cx,I2C_ACKT) == ERROR )
-        return -1;    
-     
     if(last)
     {   
         I2C_AcknowledgeConfig(I2Cx,DISABLE);
-        if( I2C_CheckEvent(I2Cx,I2C_ACKT) == ERROR )
+        if( I2C_CheckEvent(I2Cx,I2C_ACKT) == ERROR ) {
             return -1; 
-
-        I2C_Stop(I2Cx);
-    }   
-
+        }
+    }
+    else if( I2C_CheckEvent(I2Cx,I2C_ACKT) == ERROR ) {
+            return -1;    
+    }
      
     return (uint8_t)I2Cx -> RXR;    
 }
@@ -177,8 +194,14 @@
   */
 void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState)
 {
-    if(NewState != DISABLE)     I2Cx->CMDR = I2C_CMDR_STA;
-    else                        I2Cx->CMDR = I2C_CMDR_STA;
+    if(NewState != DISABLE)     
+    {    
+        I2Cx->CMDR = I2C_CMDR_STA;  
+    }
+    else                        
+    {
+        I2Cx->CMDR = I2C_CMDR_STA;
+    }
  }
 /**
   * @brief  Generates I2Cx communication STOP condition.
@@ -189,8 +212,16 @@
   */
 void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState)
 {
-    if(NewState != DISABLE)     I2Cx->CMDR = I2C_CMDR_STO;
-    else                        I2Cx->CMDR = I2C_CMDR_STO;
+    if(NewState != DISABLE)     
+    {   
+
+        I2Cx->CMDR = I2C_CMDR_STO;
+
+    }
+    else               
+    {
+        I2Cx->CMDR = I2C_CMDR_STO;
+    }
 }
 
 /**
@@ -408,81 +439,6 @@
 }
 
 
-/*
-void I2C_MasterInit(I2C_TypeDef *  I2Cx,uint8_t Prescale,uint16_t Timeout,I2C_CTR Ctr)       
-{
-    switch(Ctr)
-    {
-        case(I2C_WRITE_SA7):     //000
-        case(I2C_READ_SA7):      //001
-            I2C_CoreEn(I2Cx,ENABLE);
-        break;
-        
-        case(I2C_WRITE_SA10):     //010
-        case(I2C_READ_SA10):      //011
-            I2C_CoreEn(I2Cx,ENABLE);
-            I2C_SlaveAddressLength(I2Cx,ENABLE);
-        break;
-        
-        case(I2C_CTRWRITE_SA7):     //100
-            I2C_CoreEn(I2Cx,ENABLE);
-            I2C_ControlEn(I2Cx,ENABLE);
-        break;
-    
-        case(I2C_CTRREAD_SA7):      //101
-            I2C_CoreEn(I2Cx,ENABLE);
-            I2C_ControlRW(I2Cx,ENABLE);
-            I2C_ControlEn(I2Cx,ENABLE);
-        break;
-
-        case(I2C_CTRWRITE_SA10):    //110
-            I2C_CoreEn(I2Cx,ENABLE);
-            I2C_ControlRW(I2Cx,DISABLE);
-            I2C_ControlEn(I2Cx,ENABLE);
-            I2C_SlaveAddressLength(I2Cx,ENABLE);
-        break;
-        case(I2C_CTRREAD_SA10):     //111
-            I2C_CoreEn(I2Cx,ENABLE);
-            I2C_ControlRW(I2Cx,ENABLE);
-            I2C_ControlEn(I2Cx,ENABLE);
-            I2C_SlaveAddressLength(I2Cx,ENABLE);
-        break;
-        
-        default:
-            return;
-        
-     }     
-
-    I2C_MasterSlave(I2Cx,ENABLE);
-    I2C_MasterSlave(I2Cx,DISABLE);
-    I2C_MasterSlave(I2Cx,ENABLE);
-    
-    I2C_Prescale(I2Cx,Prescale);            // 0x61         //When PLL clk is 20MHz and Prescale value set 0x61, SCL is 100KHz
-  	I2C_TimeoutSet(I2Cx,Timeout);          // 0xFFFF        
-  	 
-#if defined(I2C_INT)
-    I2C_CoreEn(I2Cx,DISABLE);
-    I2C_InterEn(I2Cx,ENABLE);
-#else
-    I2C_CoreEn(I2Cx,DISABLE);
-  
-#endif
-
-}	
- 
-void I2C_SlaveInit(I2C_TypeDef * I2Cx, FunctionalState NewState,uint16_t data)
-{
-    if(NewState != DISABLE)
-    {
-        I2C_SlaveAddressLength(I2Cx,ENABLE);
-    }   
-    else
-        I2C_AcknowledgeConfig(I2Cx,ENABLE);
-
-    I2C_SetSlavAddress(I2Cx,data);
-}
-*/	
- 
 void I2C_SendSlaveAddress(I2C_TypeDef* I2Cx, uint8_t SlaveAddress,I2C_CTR Ctr)
 {
     switch(Ctr)
@@ -495,19 +451,9 @@
         case(I2C_WRITE_SA7):
             I2C_SendData(I2Cx,SlaveAddress|I2C_WRITE);
         break;
-        
-//        case(I2C_READ_SA10):
-//            I2C_SendData(I2Cx,SlaveAddress|I2C_READ);
-//        break;
-//
-//        case(I2C_WRITE_SA10):
-//            I2C_SendData(I2Cx,SlaveAddress|I2C_WRITE);
-//        break;
-        
+ 
         case(I2C_CTRWRITE_SA7):
         case(I2C_CTRREAD_SA7):
-//        case(I2C_CTRWRITE_SA10):
-//        case(I2C_CTRREAD_SA10):
              I2C_SendData(I2Cx,SlaveAddress);
         break;
         
@@ -561,3 +507,83 @@
   return (*(__IO uint16_t *) tmp);
 }
 
+    
+void I2C_GPIO(void )
+{
+        GPIO_InitDef.GPIO_Pin = GPIO_Pin_9; // Set to Pin_9 (SCL0))
+        GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output
+        HAL_GPIO_Init(GPIOA, &GPIO_InitDef);
+        HAL_PAD_AFConfig(PAD_PA,GPIO_Pin_9, PAD_AF1); // PAD Config - LED used 2nd Function
+        
+        GPIO_InitDef.GPIO_Pin = GPIO_Pin_10; // Set to Pin_9 (SCL0))
+        GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output
+        HAL_GPIO_Init(GPIOA, &GPIO_InitDef);
+        HAL_PAD_AFConfig(PAD_PA,GPIO_Pin_10, PAD_AF1); // PAD Config - LED used 2nd Function
+ 
+}
+void GPIO_I2C(void )
+{
+       GPIO_InitDef.GPIO_Pin = GPIO_Pin_9; // Set to Pin_9 (SCL0))
+       GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output
+       HAL_GPIO_Init(GPIOA, &GPIO_InitDef);
+       HAL_PAD_AFConfig(PAD_PA,GPIO_Pin_9, PAD_AF0); // PAD Config - LED used 2nd Function
+        
+       GPIO_InitDef.GPIO_Pin = GPIO_Pin_10; // Set to Pin_10 (SDA0))
+       GPIO_InitDef.GPIO_Mode = GPIO_Mode_IN; // Set to Mode Output
+       HAL_GPIO_Init(GPIOA, &GPIO_InitDef);
+       HAL_PAD_AFConfig(PAD_PA,GPIO_Pin_10, PAD_AF0); // PAD Config - LED used 2nd Functio
+
+}
+
+
+void WriteByte(uint8_t val)
+{
+    int  i;
+    GPIO_TypeDef* GPIOx;
+    GPIOx = GPIOA;
+
+	for(i=0;i<8;i++)
+	{
+		if((val << i) & 0x80){
+			digitalWrite(GPIOx,SDA, Bit_SET);
+		}else{
+			digitalWrite(GPIOx,SDA, Bit_RESET);
+		}
+        i2c_loop_us(1);
+		digitalWrite(GPIOx,SCL, Bit_SET);
+        i2c_loop_us(2);
+		digitalWrite(GPIOx,SCL, Bit_RESET);
+	}
+	digitalWrite(GPIOx,SDA, Bit_SET);
+    i2c_loop_us(1);
+	digitalWrite(GPIOx,SCL, Bit_SET);
+	i2c_loop_us(2);
+    digitalWrite(GPIOx,SCL, Bit_RESET);
+}
+
+
+void digitalWrite(GPIO_TypeDef* GPIOx,uint16_t pin, uint16_t val)
+{
+    
+    if(val == Bit_SET)
+    {
+        GPIOx -> OUTENCLR = pin;
+    }
+    else
+    {
+        GPIOx -> OUTENSET |= pin;
+        
+    }
+}
+
+
+void i2c_loop_us(int us)
+{
+    volatile uint32_t delay = us; // approximate loops per ms at 24 MHz, Debug config
+    for(; delay != 0; delay--)
+        __NOP();
+}
+void i2c_loop_ms(int count) {
+    i2c_loop_us(count*1000);
+}
+
--- a/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_i2c.h	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/cmsis/TARGET_WIZNET/TARGET_W7500x/W7500x_i2c.h	Tue Jun 30 09:45:08 2015 +0100
@@ -1,18 +1,41 @@
+/* mbed Microcontroller Library 
+ *******************************************************************************
+ * Copyright (c) 2015 WIZnet Co.,Ltd. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of ARM Limited nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************
+ */
+
 #include "W7500x.h"
 
-/**
-*   @defgroup I2C_Public_Types I2X Public Types
-*/
 typedef enum
 {
     I2C_WRITE_SA7=0,
     I2C_READ_SA7,
-    //I2C_WRITE_SA10,
-    //I2C_READ_SA10,
     I2C_CTRWRITE_SA7,
     I2C_CTRREAD_SA7,
-    //I2C_CTRWRITE_SA10,
-    //I2C_CTRREAD_SA10,
 } I2C_CTR;
 
 typedef enum
@@ -64,32 +87,6 @@
                                    ((REGISTER) == I2C_Register_ISR)|| \
                                    ((REGISTER) == I2C_Register_ISCR)| \
                                    ((REGISTER) == I2C_Register_ISMR))
-/**
-  * @}
-  */
-/** @addtogroup Peripheral_registers_structures
-  * @{
-  */     
-  
-
-  
-  
-
-
-/**
-  * @}
-  */
-  
-/** 
-  * @brief  I2C Interrput Status Register Mask flags  
-  */
-//------------------------------------------------
-// I2C_ISMR_BIT
-//------------------------------------------------
-
-/**
-  * @}
-  */
   
 /** @defgroup I2C_Private_Defines
   * @{
@@ -196,8 +193,6 @@
 int     I2C_Burst_Read  (I2C_TypeDef* I2Cx, uint16_t address, uint8_t *data, int length, int stop);
 int     I2C_Burst_Write (I2C_TypeDef* I2Cx, uint16_t address, uint8_t *data, int length, int stop);
 
-void    I2C_Delay       (uint32_t nCount);
-
 void I2C_GenerateSTART  (I2C_TypeDef* I2Cx, FunctionalState NewState);
 void I2C_GenerateSTOP   (I2C_TypeDef* I2Cx, FunctionalState NewState);
 
@@ -225,6 +220,16 @@
 int8_t I2C_Restart_Structure(I2C_TypeDef * I2Cx,uint32_t SlaveAddress,I2C_CTR Ctr);
 uint16_t I2C_ReadRegister   (I2C_TypeDef* I2Cx, uint8_t I2C_Register);
 
+void I2C_GPIO(void);
+void GPIO_I2C(void );
+
+void WriteByte(uint8_t val);
+
+void digitalWrite(GPIO_TypeDef* GPIOx,uint16_t pin, uint16_t val);
+uint16_t digitalRead(GPIO_TypeDef* GPIOx,uint16_t pin);
+void i2c_loop_us(int us);
+void i2c_loop_ms(int count) ;
+
 /**
   * @}
  */
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/TARGET_WIZwiki_W7500/PeripheralPins.c	Tue Jun 30 09:45:08 2015 +0100
@@ -47,25 +47,25 @@
 
 //*** SERIAL ***
 const PinMap PinMap_UART_TX[] = {
-    {PA_14, UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PA_13, UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
     {PC_2,  UART_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
     {NC,    NC,     0}
 };
 
 const PinMap PinMap_UART_RX[] = {
-    {PA_13, UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
+    {PA_14, UART_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
     {PC_3,  UART_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_PULLUP, Px_AFSR_AF0)},
     {NC,    NC,     0}
 };
 
 //*** I2C ***
 const PinMap PinMap_I2C_SDA[] = {
-    {PA_10, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
+    {PA_10, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF1)},
     {NC,    NC,    0}
 };
 
 const PinMap PinMap_I2C_SCL[] = {
-    {PA_9,  I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
+    {PA_9, I2C_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF1)},
     {NC,    NC,    0}
 };
 
@@ -107,21 +107,16 @@
     {PA_0 , PWM_6, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PA_1 , PWM_7, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PA_5 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
-    {PA_6 , PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_7 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_8 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_9 , PWM_6, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PA_10, PWM_7, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF3)},
     {PC_0 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_1 , PWM_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PC_2 , PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_3 , PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PC_4 , PWM_4, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PC_5 , PWM_5, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {PC_8 , PWM_0, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
-    {PC_9 , PWM_1, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)},
     {PC_10, PWM_2, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
-    {PC_11, PWM_3, WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF2)},
     {NC   , NC   , WIZ_PIN_DATA(WIZ_MODE_AF, WIZ_GPIO_NOPULL, Px_AFSR_AF0)}
 };
 
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/gpio_api.c	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/gpio_api.c	Tue Jun 30 09:45:08 2015 +0100
@@ -34,14 +34,14 @@
 
 extern uint32_t Get_GPIO_BaseAddress(uint32_t port_idx);
 
-//uint32_t gpio_set(PinName pin)
-//{
-//    MBED_ASSERT(pin != (PinName)NC);
+uint32_t gpio_set(PinName pin)
+{
+    MBED_ASSERT(pin != (PinName)NC);
 
-//    //pin_function(pin, WIZ_PIN_DATA(WIZ_MODE_INPUT, WIZ_GPIO_NOPULL, 1));
+    pin_function(pin, WIZ_PIN_DATA(WIZ_MODE_INPUT, WIZ_GPIO_NOPULL, Px_AFSR_AF1));
 
-//    return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask
-//}
+    return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask
+}
 
 void gpio_init(gpio_t *obj, PinName pin)
 {
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/i2c_api.c	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/i2c_api.c	Tue Jun 30 09:45:08 2015 +0100
@@ -31,12 +31,16 @@
 #include "mbed_assert.h"
 #include "i2c_api.h"
 
+
 #if DEVICE_I2C
 
 #include "cmsis.h"
 #include "pinmap.h"
 #include "PeripheralPins.h"
 
+#include "wait_api.h"
+#include "us_ticker_api.h"
+
 /* Timeout values for flags and events waiting loops. These timeouts are
    not based on accurate values, they just guarantee that the application will
    not remain stuck if the I2C communication is corrupted. */
@@ -87,7 +91,8 @@
 
 void i2c_frequency(i2c_t *obj, int hz)
 {
-    MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000));
+    //MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000));
+    MBED_ASSERT((hz == 100000));
     I2cHandle = (I2C_TypeDef *)(obj->i2c);
 
     // wait before init
@@ -95,19 +100,20 @@
 
     conf.mode = I2C_Master;
     conf.master.timeout = LONG_TIMEOUT;
+    conf.master.prescale  = 0x61;      // Standard mode with Rise Time = 400ns and Fall Time = 100ns
 
     // Common settings: I2C clock = 48 MHz, Analog filter = ON, Digital filter coefficient = 0
-    switch (hz) {
-        case 100000:
-            conf.master.prescale  = 0x61;      // Standard mode with Rise Time = 400ns and Fall Time = 100ns
-            break;
-        case 400000:
-            break;
-        case 1000000:
-            break;
-        default:
-            break;
-    }
+//    switch (hz) {
+//        case 100000:
+//            conf.master.prescale  = 0x61;      // Standard mode with Rise Time = 400ns and Fall Time = 100ns
+//            break;
+//        case 400000:
+//            break;
+//        case 1000000:
+//            break;
+//        default:
+//            break;
+//    }
 
     // I2C configuration
     I2C_Init(I2cHandle, conf);
@@ -127,8 +133,9 @@
     // Generate the STOP condition
     I2C_Stop(I2cHandle);
     I2C_Reset(I2cHandle);
+    
     obj->is_setAddress = 0;
-
+   
     return 0;
 }
 
@@ -137,12 +144,12 @@
     I2cHandle = (I2C_TypeDef *)(obj->i2c);
     int count;
     int value;
-
+    
     if(!obj->is_setAddress)
     {
        if( I2C_Start(I2cHandle, address, I2C_READ_SA7) == ERROR )
         {
-            return -1;
+              return -1;
         }
        obj->is_setAddress = 1;
        obj->ADDRESS = address;
@@ -155,52 +162,78 @@
 
     // Read all bytes
     for (count = 0; count < (length-1); count++) {
-        if( (value = i2c_byte_read(obj, 0)) == -1) return value;
+        if( (value = i2c_byte_read(obj, 0)) == -1) {
+              return value;
+        }
         data[count] = (char)value;
     }
 
     if(stop){
-        if( (value = i2c_byte_read(obj, 1)) == -1) return value;
+        if( (value = i2c_byte_read(obj, 1)) == -1) {
+            return value;
+        }
         data[count] = (char)value;
-    }
+      
+        i2c_stop(obj);
+        obj->is_setAddress =1;
+        count++;
+      }
     else{
-        if( (value = i2c_byte_read(obj, 0)) == -1) return value;
+        if( (value = i2c_byte_read(obj, 0)) == -1) {
+     
+            return value;
+        }
         data[count] = (char)value;
+        count++;
     }
-
+    
     return count;
+    
 }
 
 int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
 {
     I2cHandle = (I2C_TypeDef *)(obj->i2c);
-    int count;
-
+    int count =0;
+    
     if(!obj->is_setAddress)
     {
        if( I2C_Start(I2cHandle, address, I2C_WRITE_SA7) == ERROR )
         {
-            return -1;
+                    return -1;
         }
        obj->is_setAddress = 1;
        obj->ADDRESS = address;
-    }
+      }
     else
     {
         I2C_Restart_Structure(I2cHandle, address, I2C_WRITE_SA7);
         obj->ADDRESS = address;
+      
     }
 
     for (count = 0; count < length; count++) {
         i2c_byte_write(obj, data[count]);
+        wait_us(1);
     }
 
+    
+    if(length == 0x00)
+    {
+        I2C_GPIO();
+        i2c_byte_write(obj, 0xff);
+        GPIO_I2C();
+    }
     // If not repeated start, send stop
     if (stop) {
         i2c_stop(obj);
+      }
+    else
+    {
+        i2c_reset(obj);
+        
     }
-
-    return count;
+        return count;
 }
 
 int i2c_byte_read(i2c_t *obj, int last)
--- a/targets/hal/TARGET_WIZNET/TARGET_W7500x/us_ticker.c	Wed Jun 24 09:45:13 2015 +0100
+++ b/targets/hal/TARGET_WIZNET/TARGET_W7500x/us_ticker.c	Tue Jun 30 09:45:08 2015 +0100
@@ -33,13 +33,9 @@
 #include "PeripheralNames.h"
 #include "system_W7500x.h"
 
-// 32-bit timer selection
-#define TIM_MST7    PWM_CH7
-#define TIM_MST6    PWM_CH6
-#define IRQn_PWM6   PWM6_IRQn
 
-static PWM_TimerModeInitTypeDef TimMasterHandle_CH7;
-static PWM_TimerModeInitTypeDef TimMasterHandle_CH6;
+static PWM_TimerModeInitTypeDef TimMasterHandle_CH3;
+static PWM_TimerModeInitTypeDef TimMasterHandle_CH2;
 
 static int us_ticker_inited = 0;
 
@@ -47,17 +43,17 @@
 #ifdef __cplusplus
 extern "C"{
 #endif
-void PWM6_Handler(void)
+void PWM2_Handler(void)
 {
     uint32_t IntFlag = 0;
 
-    IntFlag = PWM_CHn_GetIntFlagStatus(TIM_MST6);
+    IntFlag = PWM_CHn_GetIntFlagStatus(PWM_CH2);
 
     /* If overflow interrupt is occurred */
     if( (IntFlag & PWM_CHn_IER_OI_Msk) != 0 )
     {
         /* Clear overflow interrupt */
-        PWM_CH6_ClearOverflowInt();
+        PWM_CH2_ClearOverflowInt();
         us_ticker_irq_handler();
     }
 }
@@ -72,12 +68,12 @@
     us_ticker_inited = 1;
 
     SystemCoreClockUpdate();
-    TimMasterHandle_CH7.PWM_CHn_PR = (GetSystemClock() / 1000000) -1;
-    TimMasterHandle_CH7.PWM_CHn_LR = 0xFFFFFFFF;
-    TimMasterHandle_CH7.PWM_CHn_PDMR = 1;
+    TimMasterHandle_CH3.PWM_CHn_PR = (GetSystemClock() / 1000000) -1;
+    TimMasterHandle_CH3.PWM_CHn_LR = 0xFFFFFFFF;
+    TimMasterHandle_CH3.PWM_CHn_PDMR = 1;
 
-    PWM_TimerModeInit(TIM_MST7, &TimMasterHandle_CH7);
-    PWM_CHn_Start(TIM_MST7);
+    PWM_TimerModeInit(PWM_CH3, &TimMasterHandle_CH3);
+    PWM_CHn_Start(PWM_CH3);
 }
 
 
@@ -85,7 +81,7 @@
 {
     if (!us_ticker_inited) us_ticker_init();
 
-    return (TIM_MST7->TCR);
+    return (PWM_CH3->TCR);
 }
 
 
@@ -105,33 +101,33 @@
     	return;
     }
 
-    PWM_CHn_Stop(TIM_MST6);
+    PWM_CHn_Stop(PWM_CH2);
 
     SystemCoreClockUpdate();
-    TimMasterHandle_CH6.PWM_CHn_PR = (GetSystemClock() / 1000000) -1;
-    TimMasterHandle_CH6.PWM_CHn_LR = dev;
+    TimMasterHandle_CH2.PWM_CHn_PR = (GetSystemClock() / 1000000) -1;
+    TimMasterHandle_CH2.PWM_CHn_LR = dev;
 
-    TimMasterHandle_CH6.PWM_CHn_UDMR = 0;
-    TimMasterHandle_CH6.PWM_CHn_PDMR = 0;
+    TimMasterHandle_CH2.PWM_CHn_UDMR = 0;
+    TimMasterHandle_CH2.PWM_CHn_PDMR = 0;
 
-    NVIC_EnableIRQ(IRQn_PWM6);
+    NVIC_EnableIRQ(PWM2_IRQn);
 
-    PWM_CHn_IntConfig(TIM_MST6, PWM_CHn_IER_OIE, ENABLE);
-    PWM_IntConfig(TIM_MST6, ENABLE);
-    PWM_TimerModeInit(TIM_MST6, &TimMasterHandle_CH6);
+    PWM_CHn_IntConfig(PWM_CH2, PWM_CHn_IER_OIE, ENABLE);
+    PWM_IntConfig(PWM_CH2, ENABLE);
+    PWM_TimerModeInit(PWM_CH2, &TimMasterHandle_CH2);
 
-    PWM_CHn_Start(TIM_MST6);
+    PWM_CHn_Start(PWM_CH2);
 }
 
 void us_ticker_disable_interrupt(void)
 {
-    NVIC_DisableIRQ(IRQn_PWM6);
+    NVIC_DisableIRQ(PWM2_IRQn);
 
-    PWM_CHn_IntConfig(TIM_MST6, PWM_CHn_IER_OIE, DISABLE);
-    PWM_IntConfig(TIM_MST6, DISABLE);
+    PWM_CHn_IntConfig(PWM_CH2, PWM_CHn_IER_OIE, DISABLE);
+    PWM_IntConfig(PWM_CH2, DISABLE);
 }
 
 void us_ticker_clear_interrupt(void)
 {
-    PWM_CHn_ClearInt(TIM_MST6, PWM_CHn_IER_OIE);
+    PWM_CHn_ClearInt(PWM_CH2, PWM_CHn_IER_OIE);
 }