Tripple Controller for the TLE5206 H Bridge motor controller

inc/SimpleTLE5206.h

Committer:
AjK
Date:
2011-07-05
Revision:
0:e2433ca2ce59
Child:
2:c5fbe0cb8a97

File content as of revision 0:e2433ca2ce59:

/*
    Copyright (c) 2011 Andy Kirkham
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/

#ifndef AJK_SIMPLETLE5206_H
#define AJK_SIMPLETLE5206_H

#include "LPC17xx.h"
#include "SimpleTLE5206Output.h"

namespace AjK {

class SimpleTLE5206 {

public:
    enum PwmCh { NoPwm0, Pwm1, Pwm2, Pwm3, Pwm4, Pwm5, Pwm6, NumOfPwms  };

protected:
    uint32_t _duty;
    
    SimpleTLE5206Output *_in1;
    SimpleTLE5206Output *_in2;
    
    void setDuty(uint32_t u);
    
    void setMRx(PwmCh ch, uint32_t value);
    
    void init(void);
    
public:

    SimpleTLE5206() { error("We require two pins!\n"); }
        
    SimpleTLE5206(SimpleTLE5206Output *in1, SimpleTLE5206Output *in2);

    void setSpeed(double d);
    
}; /* class SimpleTLE5206 ends. */

}; /* namespace AjK ends. */

using namespace AjK;

#endif