mbed library sources

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Wed May 07 11:45:52 2014 +0100
Parent:
179:fdae7a0cf091
Child:
181:a4cbdfbbd2f4
Commit message:
Synchronized with git revision 37b8ad8063bc41a763db96f6e13be9a36ec9e4e7

Full URL: https://github.com/mbedmicro/mbed/commit/37b8ad8063bc41a763db96f6e13be9a36ec9e4e7/

Changed in this revision

targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c	Wed May 07 11:30:07 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c	Wed May 07 11:45:52 2014 +0100
@@ -68,6 +68,11 @@
 
     pinmap_pinout(sda, PinMap_I2C_SDA);
     pinmap_pinout(scl, PinMap_I2C_SCL);
+    /* enable open drain for I2C pins, only port b available */
+    uint32_t pin_n  = (uint32_t)(sda & 0x7C) >> 2;
+    PORTB->PCR[pin_n] |= PORT_PCR_ODE_MASK;
+    pin_n  = (uint32_t)(scl & 0x7C) >> 2;
+    PORTB->PCR[pin_n] |= PORT_PCR_ODE_MASK;
 }
 
 int i2c_start(i2c_t *obj) {
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c	Wed May 07 11:30:07 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c	Wed May 07 11:45:52 2014 +0100
@@ -20,6 +20,8 @@
 #include "error.h"
 #include "fsl_clock_manager.h"
 #include "fsl_i2c_hal.h"
+#include "fsl_port_hal.h"
+#include "fsl_sim_hal.h"
 
 static const PinMap PinMap_I2C_SDA[] = {
     {PTE25, I2C_0, 5},
@@ -53,11 +55,15 @@
     }
 
     clock_manager_set_gate(kClockModuleI2C, obj->instance, true);
+    clock_manager_set_gate(kClockModulePORT, sda >> GPIO_PORT_SHIFT, true);
+    clock_manager_set_gate(kClockModulePORT, scl >> GPIO_PORT_SHIFT, true);
     i2c_hal_enable(obj->instance);
     i2c_frequency(obj, 100000);
 
     pinmap_pinout(sda, PinMap_I2C_SDA);
     pinmap_pinout(scl, PinMap_I2C_SCL);
+    port_hal_configure_open_drain(sda >> GPIO_PORT_SHIFT, sda & 0xFF, true);
+    port_hal_configure_open_drain(scl >> GPIO_PORT_SHIFT, scl & 0xFF, true);
 }
 
 int i2c_start(i2c_t *obj) {