Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Update README.md and use allman astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
khoih-prog authored Nov 23, 2022
1 parent 6bc7ee9 commit 5fb6688
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Please ensure to specify the following:
Arduino IDE version: 1.8.19
Arduino SAMDUE Core Version 1.6.12
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while trying to use the Timer Interrupt.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Another way to install is to:

Before using any PWM `Timer` and `channel`, you have to make sure the `Timer` and `channel` has not been used by any other purpose.

```
```cpp
// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
Expand Down Expand Up @@ -291,7 +291,7 @@ https://github.com/khoih-prog/SAMDUE_PWM/blob/a5ac09f989e8377b3ba14c68015edd1851
The following is the sample terminal output when running example [PWM_DynamicDutyCycle](examples/PWM_DynamicDutyCycle) on **SAM_DUE**, to demonstrate the ability to provide high PWM frequencies and ability to change DutyCycle `on-the-fly` using **PWM**


```
```cpp
Starting PWM_DynamicDutyCycle using PWM on SAM_DUE
SAMDUE_PWM v1.0.0
[PWM] setupPWM: _pin = 6 , _pinAttr = 12 , frequency = 5000 , _dutycycle = 0
Expand Down Expand Up @@ -339,7 +339,7 @@ Actual data: pin = 6, PWM DC = 20.00, PWMPeriod = 200.00, PWM Freq (Hz) = 5000.0
The following is the sample terminal output when running example [**PWM_Multi**](examples/PWM_Multi) on **SAM_DUE**, to demonstrate the ability to provide high PWM frequencies on multiple `PWM-capable` pins using **Timer** for PWM
```
```cpp
Starting PWM_Multi using Timer on SAM_DUE
SAMDUE_PWM v1.0.0
[PWM] setupPWM Timer: _pin = 2 , _pinAttr = 20 , frequency = 2000 , dutycycle = 2058
Expand Down Expand Up @@ -381,7 +381,7 @@ Actual data: pin = 11, PWM DC = 90.00, PWMPeriod = 125.00, PWM Freq (Hz) = 8000.

The following is the sample terminal output when running example [**PWM_DynamicFreq**](examples/PWM_DynamicFreq) on **SAM_DUE**, to demonstrate the ability to change dynamically PWM frequencies using **Timer** for PWM

```
```cpp
Starting PWM_DynamicFreq using Timer on SAM_DUE
SAMDUE_PWM v1.0.0
[PWM] setupPWM Timer: _pin = 5 , _pinAttr = 20 , frequency = 10000 , dutycycle = 2108
Expand Down Expand Up @@ -421,7 +421,7 @@ Actual data: pin = 5, PWM DC = 50.00, PWMPeriod = 50.00, PWM Freq (Hz) = 20000.0
The following is the sample terminal output when running example [**PWM_Waveform**](examples/PWM_Waveform) on **SAM_DUE**, to demonstrate how to use the `setPWM_manual()` function in wafeform creation using **PWM** for PWM
```
```cpp
Starting PWM_Waveform using PWM on SAM_DUE
SAMDUE_PWM v1.0.0
[PWM] setupPWM: _pinAttr = 12 , frequency = 2000 , _dutycycle = 0
Expand Down Expand Up @@ -525,7 +525,7 @@ Actual data: pin = 6, PWM DutyCycle = 0.00, PWMPeriod = 500.00, PWM Freq (Hz) =
The following is the sample terminal output when running example [**PWM_Waveform**](examples/PWM_Waveform) on **SAM_DUE**, to demonstrate how to use the `setPWM_manual()` function in wafeform creation using **Timer** for PWM


```
```cpp
Starting PWM_Waveform using Timer on SAM_DUE
SAMDUE_PWM v1.0.0
[PWM] setupPWM Timer: _pin = 5 , _pinAttr = 20 , frequency = 2000 , dutycycle = 0
Expand Down Expand Up @@ -650,6 +650,6 @@ If you want to contribute to this project:

## Copyright

Copyright 2022- Khoi Hoang
Copyright (c) 2022- Khoi Hoang


8 changes: 7 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

[![arduino-library-badge](https://www.ardu-badge.com/badge/SAMDUE_PWM.svg?)](https://www.ardu-badge.com/SAMDUE_PWM)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/SAMDUE_PWM.svg)](https://github.com/khoih-prog/SAMDUE_PWM/releases)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/SAMDUE_PWM/blob/master/LICENSE)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/SAMDUE_PWM/blob/main/LICENSE)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/SAMDUE_PWM.svg)](http://github.com/khoih-prog/SAMDUE_PWM/issues)


<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
<a href="https://profile-counter.glitch.me/khoih-prog-SAMDUE_PWM/count.svg" title="SAMDUE_PWM Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-SAMDUE_PWM/count.svg" style="height: 30px;width: 200px;"></a>

---
---

Expand Down
4 changes: 2 additions & 2 deletions examples/PWM_Basic/PWM_Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin 10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

Expand Down Expand Up @@ -57,7 +57,7 @@ void setup()
if ( (!PWM_Instance) || !PWM_Instance->isPWMEnabled())
{
Serial.print(F("Stop here forever"));

while (true)
delay(10000);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/PWM_DynamicDutyCycle/PWM_DynamicDutyCycle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin 10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

Expand Down Expand Up @@ -73,7 +73,7 @@ void setup()
if ( (!PWM_Instance) || !PWM_Instance->isPWMEnabled())
{
Serial.print(F("Stop here forever"));

while (true)
delay(10000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin 10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

Expand Down Expand Up @@ -73,7 +73,7 @@ void setup()
if ( (!PWM_Instance) || !PWM_Instance->isPWMEnabled())
{
Serial.print(F("Stop here forever"));

while (true)
delay(10000);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/PWM_DynamicFreq/PWM_DynamicFreq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin 10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

Expand Down Expand Up @@ -66,13 +66,13 @@ void setup()
Serial.println(SAMDUE_PWM_VERSION);

frequency = 10000.0f;

PWM_Instance = new SAMDUE_PWM(pinToUse, frequency, 50.0f);

if ( (!PWM_Instance) || !PWM_Instance->isPWMEnabled())
{
Serial.print(F("Stop here forever"));

while (true)
delay(10000);
}
Expand Down
14 changes: 7 additions & 7 deletions examples/PWM_Multi/PWM_Multi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9 ===> must be same frequency
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

#if USING_TIMER
// To select correct pins for different frequencies
uint32_t PWM_Pins[] = { 2, 3, 5, 11 };
float frequency[] = { 2000.0f, 3000.0f, 4000.0f, 8000.0f };
// To select correct pins for different frequencies
uint32_t PWM_Pins[] = { 2, 3, 5, 11 };
float frequency[] = { 2000.0f, 3000.0f, 4000.0f, 8000.0f };
#else
// always same frequency
uint32_t PWM_Pins[] = { 6, 7, 8, 9 };
float frequency[] = { 2000.0f, 2000.0f, 2000.0f, 2000.0f };
// always same frequency
uint32_t PWM_Pins[] = { 6, 7, 8, 9 };
float frequency[] = { 2000.0f, 2000.0f, 2000.0f, 2000.0f };
#endif

#define NUM_OF_PINS ( sizeof(PWM_Pins) / sizeof(uint32_t) )
Expand Down
6 changes: 3 additions & 3 deletions examples/PWM_MultiChannel/PWM_MultiChannel.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin 10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

#if USING_TIMER
uint32_t PWM_Pins[] = { 2, 3, 4, 5 };
uint32_t PWM_Pins[] = { 2, 3, 4, 5 };
#else
uint32_t PWM_Pins[] = { 6, 7, 8, 9 };
uint32_t PWM_Pins[] = { 6, 7, 8, 9 };
#endif

#define NUM_OF_PINS ( sizeof(PWM_Pins) / sizeof(uint32_t) )
Expand Down
4 changes: 2 additions & 2 deletions examples/PWM_Waveform/PWM_Waveform.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// SAM_DUE:
// PWM pins: 6, 7, 8, 9
// Timer pins: 2-5, 10-13.
// Timer pins: 2-5, 10-13.
// pin2: TC0_CHA0, pin3: TC2_CHA7, pin4: TC2_CHB6, pin5: TC2_CHA6
// pin 10: TC2_CHB7, pin11: TC2_CHA8, pin12: TC2_CHB8, pin13: TC0_CHB0

Expand Down Expand Up @@ -137,7 +137,7 @@ void setup()
else
{
Serial.print(F("Stop here forever"));

while (true)
delay(10000);
}
Expand Down
2 changes: 2 additions & 0 deletions platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ upload_speed = 921600

; Checks for the compatibility with frameworks and dev/platforms
lib_compat_mode = strict
lib_ldf_mode = chain+
;lib_ldf_mode = deep+

lib_deps =

Expand Down

0 comments on commit 5fb6688

Please sign in to comment.