nfv2.h
Go to the documentation of this file.
00001 #ifndef NFV2_H
00002 #define NFV2_H
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 #include <inttypes.h>                       
00009 #include "../nfv2_config.h"
00010 
00011 /*
00012 * Command codes
00013 */
00014 #define NF_COMMAND_ReadDeviceStatus             0x02
00015 #define NF_COMMAND_ReadDeviceVitals             0x03
00016 
00017 #define NF_COMMAND_SetDrivesMode                0x10
00018 #define NF_COMMAND_SetDrivesSpeed               0x11
00019 #define NF_COMMAND_SetDrivesCurrent             0x12
00020 #define NF_COMMAND_SetDrivesPosition    0x13
00021 #define NF_COMMAND_SetDrivesPWM                 0x14
00022 #define NF_COMMAND_SetDrivesMaxCurrent  0x15
00023 #define NF_COMMAND_SetDrivesMaxSpeed    0x16
00024 #define NF_COMMAND_SetDrivesMinPosition 0x17
00025 #define NF_COMMAND_SetDrivesMaxPosition 0x18
00026 
00027 #define NF_COMMAND_ReadDrivesPosition   0x1A
00028 #define NF_COMMAND_ReadDrivesCurrent    0x1B
00029 #define NF_COMMAND_ReadDrivesSpeed              0x1C
00030 #define NF_COMMAND_SetDrivesMisc                0x1E
00031 #define NF_COMMAND_ReadDrivesStatus             0x1F
00032 
00033 #define NF_COMMAND_SetCurrentRegulator  0x40
00034 #define NF_COMMAND_SetSpeedRegulator    0x41
00035 #define NF_COMMAND_SetPositionRegulator 0x42
00036 
00037 #define NF_COMMAND_SetServosMode                0x20
00038 #define NF_COMMAND_SetServosPosition    0x21
00039 #define NF_COMMAND_SetServosSpeed               0x22
00040 #define NF_COMMAND_SetServosMaxSpeed    0x26
00041 #define NF_COMMAND_SetServosMinPosition 0x27
00042 #define NF_COMMAND_SetServosMaxPosition 0x28
00043 #define NF_COMMAND_SetServosPositionAdj 0x29
00044 
00045 #define NF_COMMAND_ReadServosPosition   0x2A
00046 #define NF_COMMAND_ReadServosCurrent    0x2B
00047 #define NF_COMMAND_SetServosMisc                0x2E
00048 #define NF_COMMAND_ReadServosStatus             0x2F
00049 
00050 #define NF_COMMAND_ReadDigitalInputs    0x30
00051 #define NF_COMMAND_SetDigitalOutputs    0x31
00052 
00053 #define NF_COMMAND_ReadAnalogInputs             0x3E
00054 
00055 #define NF_COMMAND_ReadDistance                 0x3D
00056 
00057 #define NF_COMMAND_SetDisplayMode               0x50
00058 #define NF_COMMAND_SetDisplayText               0x51
00059 #define NF_COMMAND_SetDisplayBacklight  0x52
00060 
00061 #define NF_DEFAULT_SetServosPosition    1500
00062 #define NF_DEFAULT_SetServosMinPosition 1300
00063 #define NF_DEFAULT_SetServosMaxPosition 1700
00064 #define NF_DEFAULT_SetServosPositionAdj 0
00065 
00066 
00067 // ########     Device
00068 // ####         Read Status
00069 #ifdef NF_BUFSZ_ReadDeviceStatus
00070 typedef struct{
00071         #define NF_DATABYTES_ReadDeviceStatus           2
00072         int16_t data[NF_BUFSZ_ReadDeviceStatus];
00073         uint8_t addr[NF_BUFSZ_ReadDeviceStatus];
00074         uint8_t updated;
00075 } NF_STRUCT_ReadDeviceStatus;
00076 #endif
00077 // ####         Read Vitals
00078 #ifdef NF_BUFSZ_ReadDeviceVitals
00079 typedef struct{
00080         #define NF_DATABYTES_ReadDeviceVitals           2
00081         int16_t data[NF_BUFSZ_ReadDeviceVitals];
00082         uint8_t addr[NF_BUFSZ_ReadDeviceVitals];
00083         uint8_t updated;
00084 } NF_STRUCT_ReadDeviceVitals;
00085 #endif
00086 
00087 // ########     Drives
00088 // ####         Set Mode
00089 #ifdef NF_BUFSZ_SetDrivesMode
00090 typedef struct{
00091         #define NF_DATABYTES_SetDrivesMode              1
00092         uint8_t data[NF_BUFSZ_SetDrivesMode];
00093         uint8_t addr[NF_BUFSZ_SetDrivesMode];
00094         uint8_t updated;
00095 } NF_STRUCT_SetDrivesMode;
00096 // ##           Possible Values
00097 #define NF_DrivesMode_ERROR                     0x00
00098 #define NF_DrivesMode_MANUAL            0x01
00099 #define NF_DrivesMode_SPEED                     0x02
00100 #define NF_DrivesMode_CURRENT           0x03
00101 #define NF_DrivesMode_POSITION          0x04
00102 #define NF_DrivesMode_PWM                       0x05
00103 #define NF_DrivesMode_SYNC_PWM0         0x10
00104 #define NF_DrivesMode_SYNC_POS0         0x11
00105 #endif
00106 // ####         Set Speed
00107 #ifdef NF_BUFSZ_SetDrivesSpeed
00108 typedef struct{
00109         #define NF_DATABYTES_SetDrivesSpeed             4
00110         int32_t data[NF_BUFSZ_SetDrivesSpeed];
00111         uint8_t addr[NF_BUFSZ_SetDrivesSpeed];
00112         uint8_t updated;
00113 } NF_STRUCT_SetDrivesSpeed;
00114 #endif
00115 // ####         Set Current
00116 #ifdef NF_BUFSZ_SetDrivesCurrent
00117 typedef struct{
00118         #define NF_DATABYTES_SetDrivesCurrent   2
00119         int16_t data[NF_BUFSZ_SetDrivesCurrent];
00120         uint8_t addr[NF_BUFSZ_SetDrivesCurrent];
00121         uint8_t updated;
00122 } NF_STRUCT_SetDrivesCurrent;
00123 #endif
00124 // ####         Set Position
00125 #ifdef NF_BUFSZ_SetDrivesPosition
00126 typedef struct{
00127         #define NF_DATABYTES_SetDrivesPosition  4
00128         int32_t data[NF_BUFSZ_SetDrivesPosition];
00129         uint8_t addr[NF_BUFSZ_SetDrivesPosition];
00130         uint8_t updated;
00131 } NF_STRUCT_SetDrivesPosition;
00132 #endif
00133 // ####         Set PWM
00134 #ifdef NF_BUFSZ_SetDrivesPWM
00135 typedef struct{
00136         #define NF_DATABYTES_SetDrivesPWM               2
00137         int16_t data[NF_BUFSZ_SetDrivesPWM];
00138         uint8_t addr[NF_BUFSZ_SetDrivesPWM];
00139         uint8_t updated;
00140 } NF_STRUCT_SetDrivesPWM;
00141 #endif
00142 // ####         Set Max Current
00143 #ifdef NF_BUFSZ_SetDrivesMaxCurrent
00144 typedef struct{
00145         #define NF_DATABYTES_SetDrivesMaxCurrent        2
00146         int16_t data[NF_BUFSZ_SetDrivesMaxCurrent];
00147         uint8_t addr[NF_BUFSZ_SetDrivesMaxCurrent];
00148         uint8_t updated;
00149 } NF_STRUCT_SetDrivesMaxCurrent;
00150 #endif
00151 // ####         Set Max Speed
00152 #ifdef NF_BUFSZ_SetDrivesMaxSpeed
00153 typedef struct{
00154         #define NF_DATABYTES_SetDrivesMaxSpeed  2
00155         int16_t data[NF_BUFSZ_SetDrivesMaxSpeed];
00156         uint8_t addr[NF_BUFSZ_SetDrivesMaxSpeed];
00157         uint8_t updated;
00158 } NF_STRUCT_SetDrivesMaxSpeed;
00159 #endif
00160 // ####         Set Min Position
00161 #ifdef NF_BUFSZ_SetDrivesMinPosition
00162 typedef struct{
00163         #define NF_DATABYTES_SetDrivesMinPosition       4
00164         int32_t data[NF_BUFSZ_SetDrivesMinPosition];
00165         uint8_t addr[NF_BUFSZ_SetDrivesMinPosition];
00166         uint8_t updated;
00167 } NF_STRUCT_SetDrivesMinPosition;
00168 #endif
00169 // ####         Set Max Position
00170 #ifdef NF_BUFSZ_SetDrivesMaxPosition
00171 typedef struct{
00172         #define NF_DATABYTES_SetDrivesMaxPosition       4
00173         int32_t data[NF_BUFSZ_SetDrivesMaxPosition];
00174         uint8_t addr[NF_BUFSZ_SetDrivesMaxPosition];
00175         uint8_t updated;
00176 } NF_STRUCT_SetDrivesMaxPosition;
00177 #endif
00178 // ####         Read Position
00179 #ifdef NF_BUFSZ_ReadDrivesPosition
00180 typedef struct{
00181         #define NF_DATABYTES_ReadDrivesPosition 4
00182         int32_t data[NF_BUFSZ_ReadDrivesPosition];
00183         uint8_t addr[NF_BUFSZ_ReadDrivesPosition];
00184         uint8_t updated;
00185 } NF_STRUCT_ReadDrivesPosition;
00186 #endif
00187 // ####         Read Current
00188 #ifdef NF_BUFSZ_ReadDrivesCurrent
00189 typedef struct{
00190         #define NF_DATABYTES_ReadDrivesCurrent  2
00191         int16_t data[NF_BUFSZ_ReadDrivesCurrent];
00192         uint8_t addr[NF_BUFSZ_ReadDrivesCurrent];
00193         uint8_t updated;
00194 } NF_STRUCT_ReadDrivesCurrent;
00195 #endif
00196 // ####         Read Speed
00197 #ifdef NF_BUFSZ_ReadDrivesSpeed
00198 typedef struct{
00199         #define NF_DATABYTES_ReadDrivesSpeed    2
00200         int16_t data[NF_BUFSZ_ReadDrivesSpeed];
00201         uint8_t addr[NF_BUFSZ_ReadDrivesSpeed];
00202         uint8_t updated;
00203 } NF_STRUCT_ReadDrivesSpeed;
00204 #endif
00205 // ####         Set Misc
00206 #ifdef NF_BUFSZ_SetDrivesMisc
00207 typedef struct{
00208         #define NF_DATABYTES_SetDrivesMisc              4
00209         uint32_t data[NF_BUFSZ_SetDrivesMisc];
00210         uint8_t addr[NF_BUFSZ_SetDrivesMisc];
00211         uint8_t updated;
00212 } NF_STRUCT_SetDrivesMisc;
00213 // ##           Possible Values (bitwise OR)
00214 #define NF_DrivesMisc_SetSynchronized           (1 << 0)
00215 #define NF_DrivesMisc_ResetSynchronized         (1 << 1)
00216 #endif
00217 // ####         Read Status
00218 #ifdef NF_BUFSZ_ReadDrivesStatus
00219 typedef struct{
00220         #define NF_DATABYTES_ReadDrivesStatus   2
00221         uint16_t data[NF_BUFSZ_ReadDrivesStatus];
00222         uint8_t addr[NF_BUFSZ_ReadDrivesStatus];
00223         uint8_t updated;
00224 } NF_STRUCT_ReadDrivesStatus;
00225 // ##           Possible Values (bitwise OR)
00226 #define NF_DrivesStatus_LimitSwitchUp           (1 << 0)
00227 #define NF_DrivesStatus_LimitSwitchDown         (1 << 1)
00228 #define NF_DrivesStatus_SynchroSwitch           (1 << 2)
00229 #define NF_DrivesStatus_EncoderIndexSignal      (1 << 3)
00230 #define NF_DrivesStatus_Synchronized            (1 << 4)
00231 #define NF_DrivesStatus_PositionLimit           (1 << 10)
00232 #define NF_DrivesStatus_SpeedLimit                      (1 << 11)
00233 #define NF_DrivesStatus_CurrentLimit            (1 << 12)
00234 #define NF_DrivesStatus_Overcurrent                     (1 << 13)
00235 #define NF_DrivesStatus_PowerStageFault         (1 << 14)
00236 #define NF_DrivesStatus_Error                           (1 << 15)
00237 #endif
00238         
00239 // ########     Regulators
00240 // ####         Set Current Regulator
00241 //#if (defined NF_BUFSZ_SetCurrentRegulator) || (defined NF_BUFSZ_SetSpeedRegulator) || (defined NF_BUFSZ_SetPositionRegulator)
00242 typedef struct{
00243         #define NF_DATABYTES_Regulator  8
00244         uint16_t        p;
00245         uint16_t        i;
00246         uint16_t        d;
00247         uint16_t        t;
00248 } NF_STRUCT_Regulator;
00249 //#endif
00250 #ifdef NF_BUFSZ_SetCurrentRegulator
00251 typedef struct{
00252         #define NF_DATABYTES_SetCurrentRegulator        8
00253         NF_STRUCT_Regulator data[NF_BUFSZ_SetCurrentRegulator];
00254         uint8_t addr[NF_BUFSZ_SetCurrentRegulator];
00255         uint8_t updated;
00256 } NF_STRUCT_SetCurrentRegulator;
00257 #endif
00258 #ifdef NF_BUFSZ_SetSpeedRegulator
00259 typedef struct{
00260         #define NF_DATABYTES_SetSpeedRegulator          8
00261         NF_STRUCT_Regulator data[NF_BUFSZ_SetSpeedRegulator];
00262         uint8_t addr[NF_BUFSZ_SetSpeedRegulator];
00263         uint8_t updated;
00264 } NF_STRUCT_SetSpeedRegulator;
00265 #endif
00266 #ifdef NF_BUFSZ_SetPositionRegulator
00267 typedef struct{
00268         #define NF_DATABYTES_SetPositionRegulator       8
00269         NF_STRUCT_Regulator data[NF_BUFSZ_SetPositionRegulator];
00270         uint8_t addr[NF_BUFSZ_SetPositionRegulator];
00271         uint8_t updated;
00272 } NF_STRUCT_SetPositionRegulator;
00273 #endif
00274         
00275 // ########     Servos
00276 // ####         Set Mode
00277 #ifdef NF_BUFSZ_SetServosMode
00278 typedef struct{
00279         #define NF_DATABYTES_SetServosMode              1
00280         uint8_t data[NF_BUFSZ_SetServosMode];
00281         uint8_t addr[NF_BUFSZ_SetServosMode];
00282         uint8_t updated;
00283 } NF_STRUCT_SetServosMode;
00284 #endif
00285 // ####         Set Position
00286 #ifdef NF_BUFSZ_SetServosPosition
00287 typedef struct{
00288         #define NF_DATABYTES_SetServosPosition  2
00289         int16_t data[NF_BUFSZ_SetServosPosition];
00290         uint8_t addr[NF_BUFSZ_SetServosPosition];
00291         uint8_t updated;
00292 } NF_STRUCT_SetServosPosition;
00293 #endif
00294 // ####         Set Speed
00295 #ifdef NF_BUFSZ_SetServosSpeed
00296 typedef struct{
00297         #define NF_DATABYTES_SetServosSpeed             2
00298         int16_t data[NF_BUFSZ_SetServosSpeed];
00299         uint8_t addr[NF_BUFSZ_SetServosSpeed];
00300         uint8_t updated;
00301 } NF_STRUCT_SetServosSpeed;
00302 #endif
00303 // ####         Set Max Speed
00304 #ifdef NF_BUFSZ_SetServosMaxSpeed
00305 typedef struct{
00306         #define NF_DATABYTES_SetServosMaxSpeed  2
00307         int16_t data[NF_BUFSZ_SetServosMaxSpeed];
00308         uint8_t addr[NF_BUFSZ_SetServosMaxSpeed];
00309         uint8_t updated;
00310 } NF_STRUCT_SetServosMaxSpeed;
00311 #endif
00312 // ####         Set Min Position
00313 #ifdef NF_BUFSZ_SetServosMinPosition
00314 typedef struct{
00315         #define NF_DATABYTES_SetServosMinPosition       2
00316         int16_t data[NF_BUFSZ_SetServosMinPosition];
00317         uint8_t addr[NF_BUFSZ_SetServosMinPosition];
00318         uint8_t updated;
00319 } NF_STRUCT_SetServosMinPosition;
00320 #endif
00321 // ####         Set Max Position
00322 #ifdef NF_BUFSZ_SetServosMaxPosition
00323 typedef struct{
00324         #define NF_DATABYTES_SetServosMaxPosition       2
00325         int16_t data[NF_BUFSZ_SetServosMaxPosition];
00326         uint8_t addr[NF_BUFSZ_SetServosMaxPosition];
00327         uint8_t updated;
00328 } NF_STRUCT_SetServosMaxPosition;
00329 #endif
00330 // ####         Set Position Adjustment
00331 #ifdef NF_BUFSZ_SetServosPositionAdj
00332 typedef struct{
00333         #define NF_DATABYTES_SetServosPositionAdj       2
00334         int16_t data[NF_BUFSZ_SetServosPositionAdj];
00335         uint8_t addr[NF_BUFSZ_SetServosPositionAdj];
00336         uint8_t updated;
00337 } NF_STRUCT_SetServosPositionAdj;
00338 #endif
00339 // ####         Read Position
00340 #ifdef NF_BUFSZ_ReadServosPosition
00341 typedef struct{
00342         #define NF_DATABYTES_ReadServosPosition 2
00343         int16_t data[NF_BUFSZ_ReadServosPosition];
00344         uint8_t addr[NF_BUFSZ_ReadServosPosition];
00345         uint8_t updated;
00346 } NF_STRUCT_ReadServosPosition;
00347 #endif
00348 // ####         Read Current
00349 #ifdef NF_BUFSZ_ReadServosCurrent
00350 typedef struct{
00351         #define NF_DATABYTES_ReadServosCurrent  2
00352         int16_t data[NF_BUFSZ_ReadServosCurrent];
00353         uint8_t addr[NF_BUFSZ_ReadServosCurrent];
00354         uint8_t updated;
00355 } NF_STRUCT_ReadServosCurrent;
00356 #endif
00357 // ####         Set Misc
00358 #ifdef NF_BUFSZ_SetServosMisc
00359 typedef struct{
00360         #define NF_DATABYTES_SetServosMisc              4
00361         uint32_t data[NF_BUFSZ_SetServosMisc];
00362         uint8_t addr[NF_BUFSZ_SetServosMisc];
00363         uint8_t updated;
00364 } NF_STRUCT_SetServosMisc;
00365 // ##           Possible Values (bitwise OR)
00366 #define NF_ServosMisc_LearnMinPosition          (1 << 0)
00367 #define NF_ServosMisc_LearnMaxPosition          (1 << 1)
00368 #endif
00369 // ####         Read Status
00370 #ifdef NF_BUFSZ_ReadServosStatus
00371 typedef struct{
00372         #define NF_DATABYTES_ReadServosStatus   2
00373         uint16_t data[NF_BUFSZ_ReadServosStatus];
00374         uint8_t addr[NF_BUFSZ_ReadServosStatus];
00375         uint8_t updated;
00376 } NF_STRUCT_ReadServosStatus;
00377 // ##           Possible Values (bitwise OR)
00378 #define NF_ServosStatus_PositionLimit           (1 << 10)
00379 #define NF_ServosStatus_Error                           (1 << 15)
00380 #endif
00381 
00382 // ########     Digital IO
00383 // ####         Read Inputs
00384 #ifdef NF_BUFSZ_ReadDigitalInputs
00385 typedef struct{
00386         #define NF_DATABYTES_ReadDigitalInputs  1
00387         int16_t data[NF_BUFSZ_ReadDigitalInputs];
00388         uint8_t addr[NF_BUFSZ_ReadDigitalInputs];
00389 } NF_STRUCT_ReadDigitalInputs;
00390 #endif
00391 // ####         Set Outputs
00392 #ifdef NF_BUFSZ_SetDigitalOutputs
00393 typedef struct{
00394         #define NF_DATABYTES_SetDigitalOutputs  1
00395         int8_t data[NF_BUFSZ_SetDigitalOutputs];
00396         uint8_t addr[NF_BUFSZ_SetDigitalOutputs];
00397         uint8_t updated;
00398 } NF_STRUCT_SetDigitalOutputs;
00399 #endif
00400 
00401 // ########     Analog IO
00402 // ####         Read Inputs
00403 #ifdef NF_BUFSZ_ReadAnalogInputs
00404 typedef struct{
00405         #define NF_DATABYTES_ReadAnalogInputs   2
00406         int16_t data[NF_BUFSZ_ReadAnalogInputs];
00407         uint8_t addr[NF_BUFSZ_ReadAnalogInputs];
00408         uint8_t updated;
00409 } NF_STRUCT_ReadAnalogInputs;
00410 #endif
00411 
00412 // ########     Sensors
00413 // ####         Read Distance
00414 #ifdef NF_BUFSZ_ReadDistance
00415 typedef struct{
00416         #define NF_DATABYTES_ReadDistance       2
00417         uint16_t data[NF_BUFSZ_ReadDistance];
00418         uint8_t addr[NF_BUFSZ_ReadDistance];
00419         uint8_t updated;
00420 } NF_STRUCT_ReadDistance;
00421 #endif
00422 
00423 // ########     Display
00424 // ####         Set Mode
00425 #ifdef NF_BUFSZ_SetDisplayMode
00426 typedef struct{
00427         #define NF_DATABYTES_SetDisplayMode     1
00428         uint8_t data[NF_BUFSZ_SetDisplayMode];
00429         uint8_t addr[NF_BUFSZ_SetDisplayMode];
00430         uint8_t updated;
00431 } NF_STRUCT_SetDisplayMode;
00432 #endif
00433 // ####         Set Text
00434 #ifdef NF_BUFSZ_SetDisplayText
00435 typedef struct{
00436         #define NF_DATABYTES_SetDisplayText     1
00437         uint8_t data[NF_BUFSZ_SetDisplayText];
00438         uint8_t addr[NF_BUFSZ_SetDisplayText];
00439         uint8_t updated;
00440 } NF_STRUCT_SetDisplayText;
00441 #endif
00442 // ####         Set Backlight
00443 #ifdef NF_BUFSZ_SetDisplayBacklight
00444 typedef struct{
00445         #define NF_DATABYTES_SetDisplayBacklight        1
00446         uint8_t data[NF_BUFSZ_SetDisplayBacklight];
00447         uint8_t addr[NF_BUFSZ_SetDisplayBacklight];
00448         uint8_t updated;
00449 } NF_STRUCT_SetDisplayBacklight;
00450 #endif
00451 
00452 typedef struct{
00453         // ########     Device
00454         // ####         Read Status
00455         #ifdef NF_BUFSZ_ReadDeviceStatus
00456                 NF_STRUCT_ReadDeviceStatus      ReadDeviceStatus;
00457         #endif
00458         // ####         Read Vitals
00459         #ifdef NF_BUFSZ_ReadDeviceVitals
00460                 NF_STRUCT_ReadDeviceVitals      ReadDeviceVitals;
00461         #endif
00462         
00463         // ########     Drives
00464         // ####         Set Mode
00465         #ifdef NF_BUFSZ_SetDrivesMode
00466                 NF_STRUCT_SetDrivesMode         SetDrivesMode;
00467         #endif
00468         // ####         Set Speed
00469         #ifdef NF_BUFSZ_SetDrivesSpeed
00470                 NF_STRUCT_SetDrivesSpeed                SetDrivesSpeed;
00471         #endif
00472         // ####         Set Current
00473         #ifdef NF_BUFSZ_SetDrivesCurrent
00474                 NF_STRUCT_SetDrivesCurrent      SetDrivesCurrent;
00475         #endif
00476         // ####         Set Position
00477         #ifdef NF_BUFSZ_SetDrivesPosition
00478                 NF_STRUCT_SetDrivesPosition     SetDrivesPosition;
00479         #endif
00480         // ####         Set PWM
00481         #ifdef NF_BUFSZ_SetDrivesPWM
00482                 NF_STRUCT_SetDrivesPWM  SetDrivesPWM;
00483         #endif
00484         // ####         Set Max Current
00485         #ifdef NF_BUFSZ_SetDrivesMaxCurrent
00486                 NF_STRUCT_SetDrivesMaxCurrent   SetDrivesMaxCurrent;
00487         #endif
00488         // ####         Set Max Speed
00489         #ifdef NF_BUFSZ_SetDrivesMaxSpeed
00490                 NF_STRUCT_SetDrivesMaxSpeed     SetDrivesMaxSpeed;
00491         #endif
00492         // ####         Set Min Position
00493         #ifdef NF_BUFSZ_SetDrivesMinPosition
00494                 NF_STRUCT_SetDrivesMinPosition  SetDrivesMinPosition;
00495         #endif
00496         // ####         Set Max Position
00497         #ifdef NF_BUFSZ_SetDrivesMaxPosition
00498                 NF_STRUCT_SetDrivesMaxPosition  SetDrivesMaxPosition;
00499         #endif
00500         // ####         Read Position
00501         #ifdef NF_BUFSZ_ReadDrivesPosition
00502                 NF_STRUCT_ReadDrivesPosition    ReadDrivesPosition;
00503         #endif
00504         // ####         Read Current
00505         #ifdef NF_BUFSZ_ReadDrivesCurrent
00506                 NF_STRUCT_ReadDrivesCurrent     ReadDrivesCurrent;
00507         #endif
00508         // ####         Read Speed
00509         #ifdef NF_BUFSZ_ReadDrivesSpeed
00510                 NF_STRUCT_ReadDrivesSpeed       ReadDrivesSpeed;
00511         #endif
00512         // ####         Set Misc
00513         #ifdef NF_BUFSZ_SetDrivesMisc
00514                 NF_STRUCT_SetDrivesMisc SetDrivesMisc;
00515         #endif
00516         // ####         Read Status
00517         #ifdef NF_BUFSZ_ReadDrivesStatus
00518                 NF_STRUCT_ReadDrivesStatus      ReadDrivesStatus;
00519         #endif
00520 
00521         // ########     Regulators
00522         // ####         Set Current Regulator
00523         #ifdef NF_BUFSZ_SetCurrentRegulator
00524                 NF_STRUCT_SetCurrentRegulator   SetCurrentRegulator;
00525         #endif
00526         // ####         Set Speed Regulator
00527         #ifdef NF_BUFSZ_SetSpeedRegulator
00528                 NF_STRUCT_SetSpeedRegulator             SetSpeedRegulator;
00529         #endif
00530         // ####         Set Position Regulator
00531         #ifdef NF_BUFSZ_SetPositionRegulator
00532                 NF_STRUCT_SetPositionRegulator  SetPositionRegulator;
00533         #endif
00534 
00535         // ########     Servos
00536         // ####         Set Mode
00537         #ifdef NF_BUFSZ_SetServosMode
00538                 NF_STRUCT_SetServosMode         SetServosMode;
00539         #endif
00540         // ####         Set Position
00541         #ifdef NF_BUFSZ_SetServosPosition
00542                 NF_STRUCT_SetServosPosition     SetServosPosition;
00543         #endif
00544         // ####         Set Speed
00545         #ifdef NF_BUFSZ_SetServosSpeed
00546                 NF_STRUCT_SetServosSpeed                SetServosSpeed;
00547         #endif
00548         // ####         Set Max Speed
00549         #ifdef NF_BUFSZ_SetServosMaxSpeed
00550                 NF_STRUCT_SetServosMaxSpeed     SetServosMaxSpeed;
00551         #endif
00552         // ####         Set Min Position
00553         #ifdef NF_BUFSZ_SetServosMinPosition
00554                 NF_STRUCT_SetServosMinPosition  SetServosMinPosition;
00555         #endif
00556         // ####         Set Max Position
00557         #ifdef NF_BUFSZ_SetServosMaxPosition
00558                 NF_STRUCT_SetServosMaxPosition  SetServosMaxPosition;
00559         #endif
00560         // ####         Set Position Adjustment
00561         #ifdef NF_BUFSZ_SetServosPositionAdj
00562                 NF_STRUCT_SetServosPositionAdj  SetServosPositionAdj;
00563         #endif
00564         // ####         Read Position
00565         #ifdef NF_BUFSZ_ReadServosPosition
00566                 NF_STRUCT_ReadServosPosition    ReadServosPosition;
00567         #endif
00568         // ####         Read Current
00569         #ifdef NF_BUFSZ_ReadServosCurrent
00570                 NF_STRUCT_ReadServosCurrent     ReadServosCurrent;
00571         #endif
00572         // ####         Set Misc
00573         #ifdef NF_BUFSZ_SetServosMisc
00574                 NF_STRUCT_SetServosMisc SetServosMisc;
00575         #endif
00576         // ####         Read Status
00577         #ifdef NF_BUFSZ_ReadServosStatus
00578                 NF_STRUCT_ReadServosStatus      ReadServosStatus;
00579         #endif
00580         
00581         // ########     Digital IO       
00582         // ####         Read Inputs
00583         #ifdef NF_BUFSZ_ReadDigitalInputs
00584                 NF_STRUCT_ReadDigitalInputs     ReadDigitalInputs;
00585         #endif
00586         // ####         Set Outputs
00587         #ifdef NF_BUFSZ_SetDigitalOutputs
00588                 NF_STRUCT_SetDigitalOutputs     SetDigitalOutputs;
00589         #endif
00590         
00591         // ########     Analog IO
00592         // ####         Read Inputs
00593         #ifdef NF_BUFSZ_ReadAnalogInputs
00594                 NF_STRUCT_ReadAnalogInputs      ReadAnalogInputs;
00595         #endif
00596         
00597         // ########     Sensors
00598         // ####         Read Distance
00599         #ifdef NF_BUFSZ_ReadDistance
00600                 NF_STRUCT_ReadDistance  ReadDistance;
00601         #endif
00602         
00603         // ########     Display
00604         // ####         Set Mode
00605         #ifdef NF_BUFSZ_SetDisplayMode
00606                 NF_STRUCT_SetDisplayMode        SetDisplayMode;
00607         #endif
00608         // ####         Set Text
00609         #ifdef NF_BUFSZ_SetDisplayText
00610                 NF_STRUCT_SetDisplayText        SetDisplayText;
00611         #endif
00612         // ####         Set Backlight
00613         #ifdef NF_BUFSZ_SetDisplayBacklight
00614                 NF_STRUCT_SetDisplayBacklight   SetDisplayBacklight;
00615         #endif
00616 
00617         // ########     Common Fields
00618         uint8_t myAddress;
00619 
00620         uint8_t dataReceived                    :1;
00621         uint8_t unknownCommandReceived  :1;
00622         uint8_t unknownCommandRequested :1;
00623         uint8_t error                                   :1;
00624 } NF_STRUCT_ComBuf;
00625 
00626 uint8_t NF_Interpreter(NF_STRUCT_ComBuf *NFComBuf, uint8_t *rxBuf, uint8_t *rxPt, uint8_t *commandArray, uint8_t *commandCnt);
00627 uint8_t NF_MakeCommandFrame(NF_STRUCT_ComBuf *NFComBuf, uint8_t *txBuf, const uint8_t *commandArray, uint8_t commandCnt, uint8_t addr);
00628 void NF_ComBufReset(NF_STRUCT_ComBuf *NFComBuf);
00629 void NFv2_Config(NF_STRUCT_ComBuf *NFComBuf, uint8_t myAddress);
00630 void NFv2_Config2(NF_STRUCT_ComBuf *NFComBuf, uint8_t myAddress, uint8_t slaveAddress);
00631 
00632 
00633 // ########     CRC Calculation
00634 
00635 #define POLYNOMIAL 0xD8  /* 11011 followed by 0's */
00636 #define WIDTH  (8 * sizeof(uint8_t))
00637 #define TOPBIT (1 << (WIDTH - 1))
00638 
00639 void NFv2_CrcInit(void);
00640 uint8_t NFv2_CrcFast(const uint8_t message[], uint8_t nBytes);
00641 
00642 
00643 #ifdef __cplusplus
00644 }
00645 #endif
00646 
00647 #endif //NFV2_H


elektron_base
Author(s): Konrad Banachowicz
autogenerated on Mon Oct 6 2014 10:26:31