EE445M RTOS
Taken at the University of Texas Spring 2015
motorpp.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset: 4; -*- */
2 #ifndef __motorpp__
3 #define __motorpp__
4 
5 #include <stdint.h>
6 
7 #include "blinker.hpp"
8 #include "direction.hpp"
9 #include "criticalpp.hpp"
10 
15 typedef int32_t percent_t;
16 typedef uint32_t memory_address_t;
17 #define DEFAULT_PWM_PERIOD 10000
18 
19 class motor : public critical {
20 private:
30 
31  uint32_t pwm_period;
32  uint32_t duty_period;
35 
37  void motor_init(void);
38  void pwm_init(void);
39 
44 
45  bool enabled;
46 
47 public:
48 
49  motor();
50  motor(memory_address_t ctrl_base, memory_address_t ctrl_pin,
51  memory_address_t pwm_base, memory_address_t pwm_gen,
52  memory_address_t pwm_out, bool motor_installed_backwards = false);
53 
57 
59  void stop(void);
60 
62  void start(void);
63 
65  void set(percent_t speed);
66 
68  void set(percent_t percent_full_speed, Direction dir);
69 
70  percent_t get(void);
71 
73  void reverse(void);
74 
75  const static uint16_t pwm_max_period = DEFAULT_PWM_PERIOD;
76 };
77 
78 #endif
79 
84 /* Local Variables: */
85 /* firestarter: (compile "make -k -j32 -C ~/workspace/ee445m-labs/build/") */
86 /* End: */
percent_t current_speed
Definition: motorpp.hpp:34
uint32_t memory_address_t
Definition: adcpp.hpp:16
memory_address_t ctrl_base
Definition: motorpp.hpp:23
void motor_init(void)
Definition: motorpp.cpp:89
void set_motor_installed_backwards(bool)
Definition: motorpp.cpp:34
Direction adjusted_direction(void)
Definition: motorpp.cpp:39
memory_address_t pwm_gen
Definition: motorpp.hpp:27
static const uint16_t pwm_max_period
Definition: motorpp.hpp:75
motor()
Definition: motorpp.cpp:11
blinker ctrl
Definition: motorpp.hpp:21
int32_t percent_t
Definition: motorpp.hpp:15
bool motor_installed_backwards
Definition: motorpp.hpp:29
uint32_t pwm_period
Definition: motorpp.hpp:31
Direction
Definition: direction.hpp:8
uint32_t memory_address_t
Definition: motorpp.hpp:16
void start(void)
Definition: motorpp.cpp:96
#define DEFAULT_PWM_PERIOD
Definition: motorpp.hpp:17
uint32_t duty_period
Definition: motorpp.hpp:32
void stop(void)
Definition: motorpp.cpp:45
void reverse(void)
Definition: motorpp.cpp:136
memory_address_t pwm_out
Definition: motorpp.hpp:28
bool enabled
Definition: motorpp.hpp:45
blinker pwm
Definition: motorpp.hpp:22
memory_address_t ctrl_pin
Definition: motorpp.hpp:24
void set(percent_t speed)
Definition: motorpp.cpp:67
void pwm_init(void)
Definition: motorpp.cpp:102
Direction direction
Definition: motorpp.hpp:33
memory_address_t pwm_pin
Definition: motorpp.hpp:26
memory_address_t pwm_base
Definition: motorpp.hpp:25