Rev 213 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
211 | dhylands | 1 | /**************************************************************************** |
2 | * |
||
3 | * Copyright (c) 2009 Dave Hylands <dhylands@gmail.com> |
||
4 | * |
||
5 | * This program is free software; you can redistribute it and/or modify |
||
6 | * it under the terms of the GNU General Public License version 2 as |
||
7 | * published by the Free Software Foundation. |
||
8 | * |
||
9 | * Alternatively, this software may be distributed under the terms of BSD |
||
10 | * license. |
||
11 | * |
||
12 | * See README and COPYING for more details. |
||
13 | * |
||
14 | ****************************************************************************/ |
||
15 | /** |
||
16 | * |
||
17 | * @file BioloidDevice.h |
||
18 | * |
||
19 | * @brief Contains definitions for the bioloid generic command interface. |
||
20 | * |
||
21 | ****************************************************************************/ |
||
22 | |||
23 | #if !defined( BIOLOIDDEVICE_H ) |
||
24 | #define BIOLOIDDEVICE_H /**< Include Guard */ |
||
25 | |||
26 | // ---- Include Files ------------------------------------------------------- |
||
27 | |||
28 | #include <stdint.h> |
||
29 | |||
30 | #include "Bioloid.h" |
||
31 | #include "BioloidBus.h" |
||
32 | |||
33 | /** |
||
34 | * @addtogroup bioloid |
||
35 | * @{ |
||
36 | */ |
||
37 | |||
38 | class BioloidDevice |
||
39 | { |
||
40 | public: |
||
41 | //------------------------------------------------------------------------ |
||
42 | // Default constructor |
||
43 | |||
44 | BioloidDevice(); |
||
45 | |||
46 | //------------------------------------------------------------------------ |
||
47 | // Normal constructor |
||
48 | |||
49 | BioloidDevice( BioloidBus *bus, Bioloid::ID_t id ); |
||
50 | |||
51 | //------------------------------------------------------------------------ |
||
52 | // Destructor |
||
53 | |||
54 | virtual ~BioloidDevice(); |
||
55 | |||
56 | //------------------------------------------------------------------------ |
||
57 | // Sends a ping packet to this device |
||
58 | |||
59 | void SendPing(); |
||
60 | |||
61 | //------------------------------------------------------------------------ |
||
62 | // Sends a request to read data from the devices control table |
||
63 | |||
64 | void SendRead( uint8_t offset, uint8_t numBytes ); |
||
65 | |||
66 | //------------------------------------------------------------------------ |
||
67 | // Sends some data to write into the control table. |
||
68 | |||
69 | void SendWrite( uint8_t offset, uint8_t numBytes, const uint8_t *data ); |
||
70 | |||
71 | //------------------------------------------------------------------------ |
||
72 | // Sends some data to write into the control table. The write into the |
||
73 | // control table will be deferred until the ACTION command is sent. |
||
74 | |||
75 | void SendDeferredWrite( uint8_t offset, uint8_t numBytes, const uint8_t *data ); |
||
76 | |||
77 | //------------------------------------------------------------------------ |
||
78 | // Sends a commands to reset the control table to factory defaults. |
||
79 | |||
80 | void SendReset(); |
||
81 | |||
82 | //------------------------------------------------------------------------ |
||
83 | // Sets the Bus and ID |
||
84 | |||
85 | void SetBusAndID( BioloidBus *bus, Bioloid::ID_t id ) |
||
86 | { |
||
87 | m_bus = bus; |
||
88 | m_id = id; |
||
89 | } |
||
90 | |||
91 | protected: |
||
92 | |||
93 | //------------------------------------------------------------------------ |
||
94 | |||
95 | BioloidBus *m_bus; |
||
96 | Bioloid::ID_t m_id; // The ID of this device |
||
97 | |||
98 | private: |
||
99 | |||
100 | //------------------------------------------------------------------------ |
||
101 | // The copy constructor and assignment operator are not need for this |
||
102 | // class so we declare them private and don't provide an implementation. |
||
103 | |||
104 | BioloidDevice( const BioloidDevice & copy ); |
||
105 | BioloidDevice &operator =( const BioloidDevice &rhs ); |
||
106 | }; |
||
107 | |||
108 | // ---- Inline Functions ---------------------------------------------------- |
||
109 | |||
110 | /** @} */ |
||
111 | |||
112 | #endif /* BIOLOIDDEVICE_H */ |
||
113 |