skrupellos

main.h

Aug 29th, 2011
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <avr/io.h>        // this contains all the IO port definitions
  2. #include <avr/interrupt.h> // definitions for interrupts
  3. #include <avr/sleep.h>     // definitions for power-down modes
  4. #include <stdio.h>
  5. #include <stdbool.h>
  6. #include "config.h"
  7.  
  8. // ==== Self-Configuration =====================================================
  9. // CPU Frequency
  10. #ifndef F_CPU
  11. #   error "F_CPU is not defined."
  12. #endif
  13.  
  14. // UART
  15. #define UBRR_VAL   (F_CPU/BAUD/16)
  16.  
  17.  
  18. // Global variable declarations
  19. volatile uint8_t discharging;
  20.  
  21.  
  22. // Prototypes
  23. static int sendUart(char c, FILE *stream);
  24. uint16_t accuireCap(uint8_t samples);
  25.  
  26.  
  27. // Constants
  28. #define theory true
  29. #define experience false
  30.  
  31.  
  32. // Macros
  33. #define enableTimer() { TCCR0B |= PRESCALER; }
  34.  
  35. #define disableTimer() { TCCR0B &= ~PRESCALER; }
  36.  
  37. #define SBI(port, bit) \
  38.     {asm volatile("sbi %0, %1" \
  39.         : \
  40.         : "I" (_SFR_IO_ADDR(port)), "I" (bit));}
  41.  
  42. #define CBI(port, bit) \
  43.     {asm volatile("cbi %0, %1" \
  44.         : \
  45.         : "I" (_SFR_IO_ADDR(port)), "I" (bit));}
  46.  
  47. #define sleep() \
  48.     {sleep_enable(); \
  49.     sleep_cpu(); \
  50.     sleep_disable();}
RAW Paste Data