動作確認済み

Committer:
inst
Date:
Fri Jul 01 06:29:36 2016 +0000
Revision:
0:010c6f6ac7c0
Child:
1:9d066dbe1893
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
inst 0:010c6f6ac7c0 1 #include "GMD.hpp"
inst 0:010c6f6ac7c0 2
inst 0:010c6f6ac7c0 3 const float GMD::_frequency_to_tick_coeff = 3300.0f;
inst 0:010c6f6ac7c0 4 const uint32_t GMD::_default_frequency_kHz = 50;
inst 0:010c6f6ac7c0 5 const float GMD::_duty_lower_limit = 0.0f;
inst 0:010c6f6ac7c0 6 const float GMD::_duty_upper_limit = 1.0f;
inst 0:010c6f6ac7c0 7
inst 0:010c6f6ac7c0 8 GMD::GMD(PinName p0, PinName p1, PinName shut_down) : _shut_down(shut_down, 1) {
inst 0:010c6f6ac7c0 9 _pwm[0] = new FastPWM(p0);
inst 0:010c6f6ac7c0 10 _pwm[1] = new FastPWM(p1);
inst 0:010c6f6ac7c0 11
inst 0:010c6f6ac7c0 12 //
inst 0:010c6f6ac7c0 13 //_pwm[0]->period_ticks(40);
inst 0:010c6f6ac7c0 14 //_pwm[1]->period_ticks(40);
inst 0:010c6f6ac7c0 15 //
inst 0:010c6f6ac7c0 16
inst 0:010c6f6ac7c0 17 set_frequency_kHz(_default_frequency_kHz);
inst 0:010c6f6ac7c0 18 }
inst 0:010c6f6ac7c0 19
inst 0:010c6f6ac7c0 20 void GMD::set_frequency_kHz(float f_kHz) {
inst 0:010c6f6ac7c0 21 _pwm[0]->period_ticks(_frequency_to_tick_coeff / f_kHz);
inst 0:010c6f6ac7c0 22 _pwm[1]->period_ticks(_frequency_to_tick_coeff / f_kHz);
inst 0:010c6f6ac7c0 23 }
inst 0:010c6f6ac7c0 24
inst 0:010c6f6ac7c0 25 float GMD::set(float p) {
inst 0:010c6f6ac7c0 26 if (p < 0.0f) {
inst 0:010c6f6ac7c0 27 _pwm[0]->write(p);
inst 0:010c6f6ac7c0 28 _pwm[1]->write(0.0f);
inst 0:010c6f6ac7c0 29 } else {
inst 0:010c6f6ac7c0 30 _pwm[0]->write(0.0f);
inst 0:010c6f6ac7c0 31 _pwm[1]->write(p);
inst 0:010c6f6ac7c0 32 }
inst 0:010c6f6ac7c0 33 _shut_down = 1;
inst 0:010c6f6ac7c0 34 return p;
inst 0:010c6f6ac7c0 35 }
inst 0:010c6f6ac7c0 36
inst 0:010c6f6ac7c0 37 void GMD::release() {
inst 0:010c6f6ac7c0 38 _shut_down = 0;
inst 0:010c6f6ac7c0 39 }
inst 0:010c6f6ac7c0 40
inst 0:010c6f6ac7c0 41 float GMD::operator=(float p) {
inst 0:010c6f6ac7c0 42 return set(p);
inst 0:010c6f6ac7c0 43 }
inst 0:010c6f6ac7c0 44