main.c 997 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*********************************************************************
  2. * servo example for Versa1.0
  3. * Output RC servo waveforms to K11 (channel 0) and K12 (channel 1).
  4. *********************************************************************/
  5. #define BOARD Versa1
  6. #include <fruit.h>
  7. #include <servo.h>
  8. //----------- Setup ----------------
  9. void setup(void) {
  10. fruitInit();
  11. servoInit(); // init servo module
  12. servoSelect(0,K11); // assign connector K11 to servo channel 0
  13. servoSelect(1,K12); // assign connector K12 to servo channel 1
  14. }
  15. // ---------- Main loop ------------
  16. void loop() {
  17. fraiseService();// listen to Fraise events
  18. servoService(); // servo management routine
  19. }
  20. // ---------- Interrupts ------------
  21. void highInterrupts()
  22. {
  23. servoHighInterrupt();
  24. }
  25. // ---------- Receiving ------------
  26. void fraiseReceive() // receive raw bytes
  27. {
  28. unsigned char c=fraiseGetChar();
  29. if(c==20) servoReceive(); // if first byte is 20, then call servo receive function.
  30. }