Naze32 clone with Frysky receiver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.c 783B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * main() method
  3. */
  4. #include <avr/interrupt.h>
  5. #include <avr/wdt.h>
  6. #include "spi.h"
  7. #include "timer.h"
  8. #include "cppm.h"
  9. #include "rx.h"
  10. #ifdef DEBUG
  11. #include "serial.h"
  12. #endif
  13. void watchdogBoot(void) __attribute__((naked)) __attribute__((section(".init3")));
  14. void watchdogBoot(void) {
  15. MCUSR = 0;
  16. wdt_disable();
  17. }
  18. void main(void) {
  19. cppmInit();
  20. timerInit();
  21. #ifdef DEBUG
  22. serialInit(0, BAUD(19200, F_CPU));
  23. #endif
  24. sei(); // Enable interrupts (required for timer)
  25. wdt_enable(WDTO_250MS); // Trigger Watchdog after 250ms
  26. #ifdef DEBUG
  27. serialWriteString(0, "RX reset.\n");
  28. #endif
  29. spiInit();
  30. rxInit();
  31. #ifdef DEBUG
  32. serialWriteString(0, "RX ready!\n");
  33. #endif
  34. for(;;) {
  35. wdt_reset();
  36. rxReceivePacket();
  37. }
  38. }