Advertisement
Guest User

Untitled

a guest
May 9th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.60 KB | None | 0 0
  1. ------ArduSlave.h-----
  2. #pragma once
  3.  
  4. // Includes
  5. #include "CModule.h"
  6. #include "CPin.h"
  7. #include "SysConfig.h"
  8.  
  9. class ArduSlave : public CModule
  10. {
  11. public:
  12.     void Initialize();
  13.     void Update( CCommand& commandIn );
  14. };
  15.  
  16.  
  17.  
  18. -------ArduSlave.cpp------
  19.  
  20. #include "SysConfig.h"
  21. #if(HASArduSlave)
  22. #include "NDataManager.h"
  23. #include "CPin.h"
  24. #include "ArduSlave.h"
  25.  
  26. #include "NConfigManager.h"
  27.  
  28. namespace {
  29.  
  30. void ArduSlave::Initialize()
  31. {
  32.     /* Serial.begin(9600); */
  33. }
  34.  
  35. void ArduSlave::Update( CCommand& commandIn )
  36. {
  37.     Serial.print(F("ArduSlaveTEST:"));
  38.     Serial.println(';');
  39. }
  40.  
  41. }  //end namespace
  42.  
  43. #endif
  44.  
  45.  
  46. -----OpenROV2x.ino-------
  47. // Includes
  48. #include "NArduinoManager.h"
  49. #include "NVehicleManager.h"
  50. #include "NDataManager.h"
  51. #include "NCommManager.h"
  52. #include "NModuleManager.h"
  53. #include "ArduSlave.h"
  54.  
  55. // TODO: Verify the data type of "command". I don't believe that it should be a string, so this is just a place-holder
  56. //  for right now. Once you determine the proper type, come back and change it here. In fact compilation will likely fail
  57. //  because you're passing a String into your Update() function, and it's expecting a CCommand type--as specified in
  58. //  the CCommand.h header file.
  59. const String command = "test";
  60.  
  61. void setup()
  62. {
  63.     // Initialize main subsystems
  64.     NArduinoManager::Initialize();
  65.     NCommManager::Initialize();
  66.     NVehicleManager::Initialize();
  67.     NModuleManager::Initialize();
  68.     NDataManager::Initialize();
  69.     ArduSlave::Initialize();
  70.  
  71.     ArduSlave::Update(command);
  72.  
  73.     // Set timer 5 divisor to 8 for PWM frequency of 3921.16Hz (D44, D45, D46)
  74.     TCCR5B = ( TCCR5B & B11111000 ) | B00000010;
  75.  
  76.     // Boot complete
  77.     Serial.println( F( "boot:1;" ) );
  78. }
  79.  
  80. void loop()
  81. {
  82.     // Reset the watchdog timer
  83.     wdt_reset();
  84.  
  85.     // Attempt to read a current command off of the command line
  86.     NCommManager::GetCurrentCommand();
  87.  
  88.     // Handle any config change requests
  89.     NVehicleManager::HandleMessages( NCommManager::m_currentCommand );
  90.  
  91.     // Handle update loops for each module
  92.     NModuleManager::HandleModuleUpdates( NCommManager::m_currentCommand );
  93.  
  94.     // Handle update loops that send data back to the beaglebone
  95.     NDataManager::HandleOutputLoops();
  96. }
  97.  
  98. -------SysModules.h-----
  99. #pragma once
  100. #include "SysConfig.h"
  101.  
  102. #include "Plugins.h"
  103. #include "PinDefinitions.h"
  104.  
  105. // ---------------------------------------
  106. // Conditional module definitions
  107. // -------------------------------
  108. // Once these objects are instantiated, they will register themselves as modules in the module manager.
  109. // They can also be accessed individually as namespace members.
  110. // ---------------------------------------
  111.  
  112. #if( HASOROV_CONTROLLERBOARD_25 )
  113. #include "CControllerBoard.h"
  114. CControllerBoard mcontrollerBoard;
  115. #endif
  116.  
  117. #if(HASSTD_LIGHTS)
  118. #include "CLights.h"
  119. CLights mlights( PIN_STANDARD_LIGHTS );
  120. #endif
  121.  
  122. #if(HASEXT_LIGHTS )
  123. #include "CExternalLights.h"
  124. CExternalLights melights( PIN_PWM_3 );
  125. #endif
  126.  
  127. #if(HASSTD_CALIBRATIONLASERS)
  128. #include "CCalibrationLaser.h"
  129. CCalibrationLaser mcalibrationLaser( PIN_LASERS );
  130. #endif
  131.  
  132. #if(THRUSTERCONFIGURATION != THRUSTER_CONFIG_NONE )
  133. #include "CThrusters.h"
  134. CThrusters mthrusters;
  135. #endif
  136.  
  137. #if(HASSTD_AUTOPILOT)
  138. #include "CAutopilot.h"
  139. CAutopilot mautopilot;
  140. #endif
  141.  
  142. #if(HASCAMERASERVO)
  143. #include "CCameraServo.h"
  144. CCameraServo mcameraServo;
  145. #endif
  146.  
  147. #if(HASALT_SERVO)
  148. #include "CAltServo.h"
  149. CAltServo altservo1;
  150. #endif
  151.  
  152. #if(DEADMANSWITCHON)
  153. #include "CDeadManSwitch.h"
  154. CDeadManSwitch mdeadManSwitch;
  155. #endif
  156.  
  157. // IMU1
  158. #if( HASMPU9150 )
  159. #include "CMPU9150.h"
  160. CMPU9150 mmpu9150( mpu9150::EAddress::ADDRESS_B );
  161. #endif
  162.  
  163. #if(HASMS5803_14BA)
  164. #include "CMS580314BA.h"
  165. CMS580314BA m_ms5803( &I2C0, ms5803_14ba::EAddress::ADDRESS_A );
  166. #endif
  167.  
  168. // IMU2
  169. #if(HASBNO055)
  170. #include "CBNO055.h"
  171. CBNO055 mbno055( &I2C0, bno055::EAddress::ADDRESS_A );
  172. #endif
  173.  
  174. #if(HASMS5837_30BA)_
  175. #include "CMS583730BA.h"
  176. CMS583730BA m_ms5837( &I2C0, ms5837_30ba::EAddress::ADDRESS_A );
  177. #endif
  178.  
  179. #if(HASArduSlave)
  180. #include "ArduSlave.h"
  181. ArduSlave marduslave;
  182. #endif
  183.  
  184. -----SysConfig.h-----
  185. #pragma once
  186.  
  187. #include "PinDefinitions.h"
  188. #include "CompileOptions.h"
  189.  
  190. // TODO: The MCU ARCH and Board Type should eventually be passed in solely from the build script.
  191.  
  192. // ---------------------------------------------------------
  193. // MCU Architecture Selection
  194. // ---------------------------------------------------------
  195.  
  196. #ifndef ARDUINOARCH_AVR
  197. _   #error "This sketch is only supported on for ARDUINO_ARCH_AVR!"
  198. #endif
  199.  
  200. // Configuration
  201. #define HASOROV_CONTROLLERBOARD_25 (1)
  202. #define HASSTD_LIGHTS (1)
  203. #define HASSTD_CALIBRATIONLASERS (1)
  204. #define HASCAMERASERVO (1)
  205. #define HASSTD_AUTOPILOT (1)
  206. #define DEADMANSWITCHON (0)
  207.  
  208. // Thrusters configurations (These appear depricated and replaced by the THRUSTERCONFIGURATION below)
  209. #define THRUSTERCONFIG_NONE (0)
  210. #define THRUSTERCONFIG_2X1 (1)
  211. #define THRUSTERCONFIG_2Xv2 (2)
  212. #define THRUSTERCONFIG_v2X1Xv2 (3)
  213.  
  214. // Selected Thruster Configuration
  215. #define THRUSTERCONFIGURATION THRUSTER_CONFIG_2X1
  216. //#define THRUSTERCONFIGURATION THRUSTER_CONFIG_2Xv2
  217. //#define THRUSTERCONFIGURATION THRUSTER_CONFIG_v2X1Xv2
  218.  
  219. // ---------------------------------------------------------
  220. // After Market Modules
  221. // ---------------------------------------------------------
  222.  
  223. // External Lights
  224. #define HASEXT_LIGHTS (1)
  225.  
  226. // AltServo
  227. #define HASALT_SERVO (0)
  228.  
  229. // MS580314BA Depth Sensor
  230. #define HASMS5803_14BA (1)
  231.  
  232. // MS583730BA Depth Sensor
  233. #define HASMS5837_30BA (1)
  234.  
  235. // MPU9150
  236. #define HASMPU9150 (1)
  237.  
  238. // BNO055 IMU
  239. #define HASBNO055 (1)
  240.  
  241. #define HASArduSlave (1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement