mbed library sources that still uses the stm standard peripheral library

Fork of mbed-src by Reinhold Schaefer

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Thu Dec 04 07:30:08 2014 +0000
Parent:
427:712edee6295a
Child:
429:4ddf7f7eabbb
Commit message:
Synchronized with git revision e815194b578628edb5746650abfdde926be5e3fe

Full URL: https://github.com/mbedmicro/mbed/commit/e815194b578628edb5746650abfdde926be5e3fe/

Targets: RZ_A1H - Fix bugs that I2C freq become fixed 100kHz and a static value will be indefiniteness.

Changed in this revision

targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/gpio_irq_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/objects.h Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/gpio_irq_api.c	Wed Dec 03 13:15:07 2014 +0000
+++ b/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/gpio_irq_api.c	Thu Dec 04 07:30:08 2014 +0000
@@ -67,17 +67,15 @@
 static void handle_interrupt_in(void) {
     int i;
     uint16_t irqs;
-    int irq_num;
     
     irqs = INTCIRQRR;
     for(i = 0; i< 8; i++) {
         if (channel_ids[i] && (irqs & (1 << i))) {
             irq_handler(channel_ids[i], irq_event);
             INTCIRQRR &= ~(1 << i);
-            irq_num = i;
+            GIC_EndInterrupt((IRQn_Type)(nIRQn_h + i));
         }
     }
-    GIC_EndInterrupt((IRQn_Type)(nIRQn_h + irq_num));
 }
 
 int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
--- a/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/i2c_api.c	Wed Dec 03 13:15:07 2014 +0000
+++ b/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/i2c_api.c	Thu Dec 04 07:30:08 2014 +0000
@@ -72,8 +72,10 @@
     REG(MR1.UINT8[0])  =  0x08;  // P_phi /8  9bit (including Ack)
     REG(SER.UINT8[0])  =  0x00;  // no slave addr enabled
 
-    // set default frequency at 100k
-    i2c_frequency(obj, 100000);
+    // set frequency
+    REG(MR1.UINT8[0]) |=  obj->pclk_bit;
+    REG(BRL.UINT32)    =  obj->width;
+    REG(BRH.UINT32)    =  obj->width;
 
     REG(MR2.UINT8[0])  =  0x07;
     REG(MR3.UINT8[0])  =  0x00;
@@ -130,6 +132,9 @@
     // enable power
     i2c_power_enable(obj);
 
+    // set default frequency at 100k
+    i2c_frequency(obj, 100000);
+
     // full reset
     i2c_reg_reset(obj);
 
@@ -209,15 +214,14 @@
     uint32_t width = 0;
     uint8_t count;
     uint8_t pclk_bit = 0;
-    
+
     /* set PCLK */
-    if (false == RZ_A1_IsClockMode0())
-    {
+    if (false == RZ_A1_IsClockMode0()) {
         pclk_base = (uint32_t)CM1_RENESAS_RZ_A1_P0_CLK;
     } else {
         pclk_base = (uint32_t)CM0_RENESAS_RZ_A1_P0_CLK;
     }
-    
+
     /* Min 10kHz, Max 400kHz */
     if (hz < 10000) {
         freq = 10000;
@@ -226,7 +230,7 @@
     } else {
         freq = hz;
     }
-    
+
     for (count = 0; count < 7; count++) {
         // IIC phi = P0 phi / rate
         pclk = pclk_base / (2 << count);
@@ -250,15 +254,12 @@
 
     if (width != 0) {
         // I2C Rate
-        REG(MR1.UINT8[0])  |=  pclk_bit;  // P_phi / xx
-        width |= 0x000000E0;
-        REG(BRL.UINT32) = width;
-        REG(BRH.UINT32) = width;
+        obj->pclk_bit = pclk_bit;  // P_phi / xx
+        obj->width    = (width | 0x000000E0);
     } else {
         // Default 
-        REG(MR1.UINT8[0])  |=  0x00;  // P_phi / 1
-        REG(BRL.UINT32) = 0x000000FF;
-        REG(BRH.UINT32) = 0x000000FF;
+        obj->pclk_bit = 0x00;      // P_phi / 1
+        obj->width    = 0x000000FF;
     }
 }
 
--- a/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/objects.h	Wed Dec 03 13:15:07 2014 +0000
+++ b/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/objects.h	Thu Dec 04 07:30:08 2014 +0000
@@ -30,6 +30,8 @@
 struct i2c_s {
     uint32_t i2c;
     uint32_t dummy;
+    uint8_t  pclk_bit;
+    uint32_t width;
 };
 
 struct spi_s {