123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
-
- #ifndef MBED_PWMOUT_H
- #define MBED_PWMOUT_H
-
- #include "platform.h"
-
- #if DEVICE_PWMOUT
- #include "pwmout_api.h"
-
- namespace mbed {
-
-
- class PwmOut {
-
- public:
-
-
-
- PwmOut(PinName pin) {
- pwmout_init(&_pwm, pin);
- }
-
-
-
- void write(float value) {
- pwmout_write(&_pwm, value);
- }
-
-
-
- float read() {
- return pwmout_read(&_pwm);
- }
-
-
-
- void period(float seconds) {
- pwmout_period(&_pwm, seconds);
- }
-
-
-
- void period_ms(int ms) {
- pwmout_period_ms(&_pwm, ms);
- }
-
-
-
- void period_us(int us) {
- pwmout_period_us(&_pwm, us);
- }
-
-
-
- void pulsewidth(float seconds) {
- pwmout_pulsewidth(&_pwm, seconds);
- }
-
-
-
- void pulsewidth_ms(int ms) {
- pwmout_pulsewidth_ms(&_pwm, ms);
- }
-
-
-
- void pulsewidth_us(int us) {
- pwmout_pulsewidth_us(&_pwm, us);
- }
-
- #ifdef MBED_OPERATORS
-
-
- PwmOut& operator= (float value) {
- write(value);
- return *this;
- }
-
- PwmOut& operator= (PwmOut& rhs) {
- write(rhs.read());
- return *this;
- }
-
-
-
- operator float() {
- return read();
- }
- #endif
-
- protected:
- pwmout_t _pwm;
- };
-
- }
-
- #endif
-
- #endif
|