Created
July 20, 2011 05:59
-
-
Save Arachnid/1094426 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flags for the direction register | |
#define FLAG_M1_CCW 0 | |
#define FLAG_M1_CW 1 | |
#define FLAG_M2_CCW 2 | |
#define FLAG_M2_CW 3 | |
// Flags for the inopts register | |
#define FLAG_PULLUP_I1 0 | |
#define FLAG_PULLUP_I2 1 | |
#define FLAG_INVERT_I1 2 | |
#define FLAG_INVERT_I2 3 | |
#define FLAG_LIMIT_I1 4 | |
#define FLAG_LIMIT_I2 5 | |
// Flags for the int_masks register | |
#define IMASK_LIMIT_M1_I1 0 | |
#define IMASK_LIMIT_M1_I2 1 | |
#define IMASK_LIMIT_M2_I1 2 | |
#define IMASK_LIMIT_M2_I2 3 | |
// Flags for the status register | |
#define INPUT_M1_I1 0 | |
#define INPUT_M1_I2 1 | |
#define INPUT_M2_I1 2 | |
#define INPUT_M2_I2 3 | |
#define INT_1 4 | |
#define INT_2 5 | |
union { | |
uint8_t bytes[1]; | |
struct { | |
uint8_t slave_addr; | |
uint8_t direction; // Motor direction register | |
uint8_t speeds[2]; // Motor speeds, 0=off/idle, 255=full speed | |
uint8_t inopts[2]; // Input options/flags registers | |
uint8_t int_masks[2]; // Interrupt masks registers | |
uint8_t status; // Input and interrupt status register | |
} __attribute__((__packed__)) reg; | |
} registers; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment