diff --git a/src/md/CMakeLists.txt b/src/md/CMakeLists.txt index 2cf99497..8776d1c6 100644 --- a/src/md/CMakeLists.txt +++ b/src/md/CMakeLists.txt @@ -1,9 +1,8 @@ upm_mixed_module_init (NAME md DESCRIPTION "I2C Motor Driver" - C_HDR md.h + C_HDR md.h md_defs.h C_SRC md.c CPP_HDR md.hpp CPP_SRC md.cxx -# FTI_SRC md_fti.c CPP_WRAPS_C REQUIRES mraa) diff --git a/src/md/javaupm_md.i b/src/md/javaupm_md.i index fe39565c..2aea9854 100644 --- a/src/md/javaupm_md.i +++ b/src/md/javaupm_md.i @@ -5,7 +5,7 @@ #include "md.hpp" %} -%include "md.h" +%include "md_defs.h" %include "md.hpp" %pragma(java) jniclasscode=%{ diff --git a/src/md/jsupm_md.i b/src/md/jsupm_md.i index 0fad6a15..0c19d26d 100644 --- a/src/md/jsupm_md.i +++ b/src/md/jsupm_md.i @@ -1,7 +1,7 @@ %module jsupm_md %include "../upm.i" -%include "md.h" +%include "md_defs.h" %include "md.hpp" %{ #include "md.hpp" diff --git a/src/md/md.h b/src/md/md.h index 0c4790ca..b9c3d3df 100644 --- a/src/md/md.h +++ b/src/md/md.h @@ -26,11 +26,7 @@ #include #include -#define MD_I2C_BUS 0 -#define MD_DEFAULT_I2C_ADDR 0x0f - -// This is a NOOP value used to pad packets -#define MD_NOOP 0x01 +#include "md_defs.h" #ifdef __cplusplus extern "C" { @@ -44,36 +40,6 @@ extern "C" { * @include md.c */ - // MD registers - typedef enum { - MD_REG_SET_SPEED = 0x82, - MD_REG_SET_PWM_FREQ = 0x84, - MD_REG_SET_DIRECTION = 0xaa, - MD_REG_SET_MOTOR_A = 0xa1, // not documented - MD_REG_SET_MOTOR_B = 0xa5, // not documented - MD_REG_STEPPER_ENABLE = 0x1a, - MD_REG_STEPPER_DISABLE = 0x1b, - MD_REG_STEPPER_NUM_STEPS = 0x1c - } MD_REG_T; - - // legal directions for the stepper - typedef enum { - MD_STEP_DIR_CCW = 0x01, - MD_STEP_DIR_CW = 0x00 - } MD_STEP_DIRECTION_T; - - // legal directions for individual DC motors - typedef enum { - MD_DIR_CCW = 0x02, - MD_DIR_CW = 0x01 - } MD_DC_DIRECTION_T; - - // stepper modes - typedef enum { - MD_STEP_MODE1 = 0x00, - MD_STEP_MODE2 = 0x01 - } MD_STEP_MODE_T; - /** * Device context */ diff --git a/src/md/md_defs.h b/src/md/md_defs.h new file mode 100644 index 00000000..30bfdcdb --- /dev/null +++ b/src/md/md_defs.h @@ -0,0 +1,69 @@ +/* + * Author: Jon Trulson + * Copyright (c) 2016 Intel Corporation. + * + * 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. + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#define MD_I2C_BUS 0 +#define MD_DEFAULT_I2C_ADDR 0x0f + +// This is a NOOP value used to pad packets +#define MD_NOOP 0x01 + + + // MD registers + typedef enum { + MD_REG_SET_SPEED = 0x82, + MD_REG_SET_PWM_FREQ = 0x84, + MD_REG_SET_DIRECTION = 0xaa, + MD_REG_SET_MOTOR_A = 0xa1, // not documented + MD_REG_SET_MOTOR_B = 0xa5, // not documented + MD_REG_STEPPER_ENABLE = 0x1a, + MD_REG_STEPPER_DISABLE = 0x1b, + MD_REG_STEPPER_NUM_STEPS = 0x1c + } MD_REG_T; + + // legal directions for the stepper + typedef enum { + MD_STEP_DIR_CCW = 0x01, + MD_STEP_DIR_CW = 0x00 + } MD_STEP_DIRECTION_T; + + // legal directions for individual DC motors + typedef enum { + MD_DIR_CCW = 0x02, + MD_DIR_CW = 0x01 + } MD_DC_DIRECTION_T; + + // stepper modes + typedef enum { + MD_STEP_MODE1 = 0x00, + MD_STEP_MODE2 = 0x01 + } MD_STEP_MODE_T; + +#ifdef __cplusplus +} +#endif diff --git a/src/md/pyupm_md.i b/src/md/pyupm_md.i index 069b1db3..89e06025 100644 --- a/src/md/pyupm_md.i +++ b/src/md/pyupm_md.i @@ -9,7 +9,7 @@ %include "md_doc.i" #endif -%include "md.h" +%include "md_defs.h" %include "md.hpp" %{ #include "md.hpp"