upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
md_defs.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define MD_I2C_BUS 0
31 #define MD_DEFAULT_I2C_ADDR 0x0f
32 
33 // This is a NOOP value used to pad packets
34 #define MD_NOOP 0x01
35 
36 
37  // MD registers
38  typedef enum {
39  MD_REG_SET_SPEED = 0x82,
40  MD_REG_SET_PWM_FREQ = 0x84,
41  MD_REG_SET_DIRECTION = 0xaa,
42  MD_REG_SET_MOTOR_A = 0xa1, // not documented
43  MD_REG_SET_MOTOR_B = 0xa5, // not documented
44  MD_REG_STEPPER_ENABLE = 0x1a,
45  MD_REG_STEPPER_DISABLE = 0x1b,
46  MD_REG_STEPPER_NUM_STEPS = 0x1c
47  } MD_REG_T;
48 
49  // legal directions for the stepper
50  typedef enum {
51  MD_STEP_DIR_CCW = 0x01,
52  MD_STEP_DIR_CW = 0x00
53  } MD_STEP_DIRECTION_T;
54 
55  // legal directions for individual DC motors
56  typedef enum {
57  MD_DIR_CCW = 0x02,
58  MD_DIR_CW = 0x01
59  } MD_DC_DIRECTION_T;
60 
61  // stepper modes
62  typedef enum {
63  MD_STEP_MODE1 = 0x00,
64  MD_STEP_MODE2 = 0x01
65  } MD_STEP_MODE_T;
66 
67 #ifdef __cplusplus
68 }
69 #endif