mbed official / mbed-src

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Revision:
227:7bd0639b8911
Parent:
155:8435094ec241
--- a/targets/hal/TARGET_STM/TARGET_STM32F3XX/i2c_api.c	Wed Jun 11 09:45:09 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F3XX/i2c_api.c	Wed Jun 11 16:00:09 2014 +0100
@@ -27,13 +27,13 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *******************************************************************************
  */
+#include "mbed_assert.h"
 #include "i2c_api.h"
 
 #if DEVICE_I2C
 
 #include "cmsis.h"
 #include "pinmap.h"
-#include "error.h"
 
 /* Timeout values for flags and events waiting loops. These timeouts are
    not based on accurate values, they just guarantee that the application will
@@ -68,10 +68,7 @@
     I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
 
     obj->i2c = (I2CName)pinmap_merge(i2c_sda, i2c_scl);
-
-    if (obj->i2c == (I2CName)NC) {
-        error("I2C pin mapping failed");
-    }
+    MBED_ASSERT(obj->i2c != (I2CName)NC);
 
     // Enable I2C clock
     if (obj->i2c == I2C_1) {
@@ -98,6 +95,7 @@
 }
 
 void i2c_frequency(i2c_t *obj, int hz) {
+    MBED_ASSERT((hz == 100000) || (hz == 200000) || (hz == 400000) || (hz == 1000000));
     I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c);
     I2C_InitTypeDef I2C_InitStructure;
     uint32_t tim;
@@ -140,7 +138,6 @@
             }
             break;
         default:
-            error("Only 100kHz, 200kHz, 400kHz and 1MHz I2C frequencies are supported.");
             break;
     }