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.

Revision:
441:d2c15dda23c1
Parent:
437:0b72c0f86db6
Child:
500:04797f1feae2
--- a/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/pwmout_api.c	Tue Dec 16 08:15:08 2014 +0000
+++ b/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/pwmout_api.c	Tue Jan 06 16:15:36 2015 +0000
@@ -73,6 +73,8 @@
 
 static uint16_t init_period_ch1 = 0;
 static uint16_t init_period_ch2 = 0;
+static int32_t  period_ch1 = 1;
+static int32_t  period_ch2 = 1;
 
 void pwmout_init(pwmout_t* obj, PinName pin) {
     // determine the channel
@@ -207,6 +209,9 @@
 
         // Counter Start
         PWMPWCR_2_BYTE_L |= 0x08;
+
+        // Save for future use
+        period_ch2 = us;
     } else {
         wk_last_cycle    = PWMPWCYR_1 & 0x03ff;
         PWMPWCR_1_BYTE_L = 0xc0 | wk_cks;
@@ -220,10 +225,10 @@
 
         // Counter Start
         PWMPWCR_1_BYTE_L |= 0x08;
+
+        // Save for future use
+        period_ch1 = us;
     }
-
-    // Save for future use
-    obj->period = us;
 }
 
 void pwmout_pulsewidth(pwmout_t* obj, float seconds) {
@@ -235,6 +240,17 @@
 }
 
 void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
-    float value = (float)us / (float)obj->period;
+    float value = 0;
+
+    if (obj->ch == 2) {
+        if (period_ch2 != 0) {
+            value = (float)us / (float)period_ch2;
+        }
+    } else {
+        if (period_ch1 != 0) {
+            value = (float)us / (float)period_ch1;
+        }
+    }
+
     pwmout_write(obj, value);
 }