Library that allows for higher resolution and speed than standard mbed PWM library using same syntax (drop-in replacement).

Dependencies:   RGBLed

Dependents:   Widgets

Files at this revision

API Documentation at this revision

Comitter:
blaze
Date:
Wed Oct 30 03:00:00 2019 +0000
Parent:
34:c0b2265cff9c
Child:
36:53def94fd96a
Commit message:
Replace new/delete with malloc/free for void *. Deleting void pointer is undefined behavior in C++.

Changed in this revision

Device/FastPWM_KSDK.cpp Show annotated file Show diff for this revision Revisions of this file
Device/FastPWM_LPC11XX.cpp Show annotated file Show diff for this revision Revisions of this file
Device/FastPWM_STM_TIM.cpp Show annotated file Show diff for this revision Revisions of this file
FastPWM_common.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Device/FastPWM_KSDK.cpp	Sun Sep 03 19:40:01 2017 +0000
+++ b/Device/FastPWM_KSDK.cpp	Wed Oct 30 03:00:00 2019 +0000
@@ -20,7 +20,7 @@
 static FTM_Type *const ftm_addrs[] = FTM_BASE_PTRS;
 
 void FastPWM::initFastPWM( void ) {
-    fast_obj = new fastpwm_struct;
+    fast_obj = malloc(sizeof(fastpwm_struct));
     bits = 16;
 
     pwm_prescaler = SystemCoreClock / CLOCK_GetFreq(kCLOCK_BusClk);;
--- a/Device/FastPWM_LPC11XX.cpp	Sun Sep 03 19:40:01 2017 +0000
+++ b/Device/FastPWM_LPC11XX.cpp	Wed Oct 30 03:00:00 2019 +0000
@@ -51,7 +51,7 @@
 
 
 void FastPWM::initFastPWM( void ) {
-    fast_obj = new fastpwm_struct;
+    fast_obj = malloc(sizeof(fastpwm_struct));
     timer_mr tid = pwm_timer_map[_pwm.pwm];
     PWM_TIMER = Timers[tid.timer];
     (((fastpwm_struct*)fast_obj)->MR) = &PWM_TIMER->MR[tid.mr];
--- a/Device/FastPWM_STM_TIM.cpp	Sun Sep 03 19:40:01 2017 +0000
+++ b/Device/FastPWM_STM_TIM.cpp	Wed Oct 30 03:00:00 2019 +0000
@@ -20,7 +20,7 @@
 #endif
 
 void FastPWM::initFastPWM( void ) {
-    fast_obj = new fastpwm_struct;
+    fast_obj = malloc(sizeof(fastpwm_struct));
     #if defined(TARGET_STM32F0) || defined (TARGET_STM32F1) || defined (TARGET_STM32L1)
     PWM_CHANNEL = getChannel(PWM_TIMER, _pwm.pin);
     #else
--- a/FastPWM_common.cpp	Sun Sep 03 19:40:01 2017 +0000
+++ b/FastPWM_common.cpp	Wed Oct 30 03:00:00 2019 +0000
@@ -14,7 +14,7 @@
 
 FastPWM::~FastPWM( void ) {
     if (fast_obj != NULL)
-        delete(fast_obj);
+        free(fast_obj);
 } 
 
 void FastPWM::period(double seconds) {