Project

General

Profile

Revision 1461

Added by Brad Neuman over 14 years ago

updated all the library code to have sensible _init behavior.
Almost all of the library components have a global variable which gets set after init and the functions inside will fail with an error code if init has not been called. Also, the init functions themselves check this variable and will bail out without doing any damage if that init has already been called

View differences:

encoders.h
51 51
#define MagINCn _BV(1)
52 52
#define MagDECn _BV(0)
53 53

  
54
#ifdef BUFFER_SIZE
55
#error BUFFER_SIZE already defined!
56
#endif
57

  
54 58
/** @brief Buffer size **/
55 59
#define BUFFER_SIZE 46
56 60

  
57 61
#define ERR_VEL 1024
58 62

  
59 63
/** @brief Initialize encoders. **/
60
void encoders_init(void);
64
int encoders_init(void);
61 65
/** @brief Read instantaneous encoder value. **/
62 66
int encoder_read(char encoder);
63 67

  
......
72 76
/** @brief Get total distance traveled. **/
73 77
int encoder_get_dx(char encoder);
74 78
/** @brief Reset distance counter. **/
75
void encoder_rst_dx(char encoder);
79
int encoder_rst_dx(char encoder);
76 80
/** @brief Get time count: The number of encoder reads that have occurred. **/
77 81
int encoder_get_tc(void);
78 82
/** @brief Reset the time count. **/
79
void encoder_rst_tc(void);
83
int encoder_rst_tc(void);
80 84

  
81 85
/** @brief Waits for the next n encoder reading, then returns. **/
82
void encoder_wait( int nReadings );
86
int encoder_wait( int nReadings );
83 87

  
84 88
/**@}**/ //end group
85 89

  

Also available in: Unified diff