Revision 1461
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
serial.h | ||
---|---|---|
68 | 68 |
#ifndef _SERIAL_H |
69 | 69 |
#define _SERIAL_H |
70 | 70 |
|
71 |
#include <dragonfly_lib.h> |
|
71 | 72 |
#include <inttypes.h> |
72 | 73 |
#include <avr/pgmspace.h> |
73 | 74 |
|
... | ... | |
87 | 88 |
#endif |
88 | 89 |
|
89 | 90 |
/** @brief Initialize the USB **/ |
90 |
void usb_init(void);
|
|
91 |
int usb_init(void);
|
|
91 | 92 |
/** @brief Print a character to USB **/ |
92 | 93 |
int usb_putc(char c); |
93 | 94 |
/** @brief Read a character from USB **/ |
... | ... | |
97 | 98 |
/** @brief Print a string to USB **/ |
98 | 99 |
int usb_puts(char *s); |
99 | 100 |
/** @brief Print a string from program space to USB **/ |
100 |
void usb_puts_P (PGM_P s);
|
|
101 |
int usb_puts_P (PGM_P s);
|
|
101 | 102 |
/** @brief Print an integer to USB **/ |
102 | 103 |
int usb_puti(int value); |
103 | 104 |
/** @brief Determine a hexadecimal digit **/ |
104 | 105 |
uint8_t hex_digit (uint8_t value); |
105 | 106 |
/** @brief Print a fixed width hexadecimal representation to USB **/ |
106 |
void usb_puth16 (uint16_t value);
|
|
107 |
int usb_puth16 (uint16_t value);
|
|
107 | 108 |
/** @brief Print a fixed width hexadecimal representation to USB **/ |
108 |
void usb_puth8(uint8_t value);
|
|
109 |
int usb_puth8(uint8_t value);
|
|
109 | 110 |
/** @brief Alias for usb_puth16 **/ |
110 | 111 |
static inline void usb_puth (uint16_t value) { usb_puth16 (value); }; |
111 | 112 |
|
... | ... | |
130 | 131 |
#endif |
131 | 132 |
|
132 | 133 |
/** @brief Initialize the XBee **/ |
133 |
void xbee_init(void);
|
|
134 |
int xbee_init(void);
|
|
134 | 135 |
/** @brief Print a character to the XBee **/ |
135 | 136 |
int xbee_putc(char c); |
136 | 137 |
/** @brief Read a character from the XBee **/ |
Also available in: Unified diff