ClearCore Library
Loading...
Searching...
No Matches
MotorManager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Teknic, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
27#ifndef __MOTORMANAGER_H__
28#define __MOTORMANAGER_H__
29
30#include <stdint.h>
31#include "HardwareMapping.h"
32#include "MotorDriver.h"
33
34namespace ClearCore {
35
47public:
65
87
88#ifndef HIDE_FROM_DOXYGEN
92 static MotorManager &Instance();
93
97 void Initialize();
98#endif
99
119
144
145protected:
146 uint8_t m_gclkIndex;
147 MotorClockRates m_clockRate;
148 ClearCorePorts m_stepPorts[NUM_MOTOR_PAIRS];
149 uint32_t m_stepDataBits[NUM_MOTOR_PAIRS];
151
152private:
153#define CPM_CLOCK_RATE_LOW_HZ \
154 (100000 / _CLEARCORE_SAMPLE_RATE_HZ * _CLEARCORE_SAMPLE_RATE_HZ)
155#define CPM_CLOCK_RATE_NORMAL_HZ \
156 (500000 / _CLEARCORE_SAMPLE_RATE_HZ * _CLEARCORE_SAMPLE_RATE_HZ)
157#define CPM_CLOCK_RATE_HIGH_HZ \
158 (2000000 / _CLEARCORE_SAMPLE_RATE_HZ * _CLEARCORE_SAMPLE_RATE_HZ)
159
160 bool m_initialized;
161
165 MotorManager();
166
167 void PinMuxSet();
168};
169
170} // ClearCore namespace
171
172#endif // __MOTORMANAGER_H__
ClearCorePorts
Definition PeripheralRoute.h:34
ConnectorModes
All possible operational modes for a connector.
Definition Connector.h:74
ClearCore motor-connector manager.
Definition MotorManager.h:46
bool MotorInputClocking(MotorClockRates newRate)
Sets the output step rate for the motor step generators.
bool MotorModeSet(MotorPair motorPair, Connector::ConnectorModes newMode)
Sets the operational mode for the specified MotorDriver connectors.
MotorPair
Definition MotorManager.h:69
@ MOTOR_M0M1
Definition MotorManager.h:73
@ NUM_MOTOR_PAIRS
Definition MotorManager.h:81
@ MOTOR_ALL
Definition MotorManager.h:85
@ MOTOR_M2M3
Definition MotorManager.h:77
MotorClockRates
Definition MotorManager.h:51
@ CLOCK_RATE_LOW
Definition MotorManager.h:55
@ CLOCK_RATE_HIGH
Definition MotorManager.h:63
@ CLOCK_RATE_NORMAL
Definition MotorManager.h:59
Namespace to encompass the ClearCore board API.
Definition AdcManager.h:36