COSA
An Object-Oriented Platform for Arduino Programming
CPU.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_CPU_HH
22 #define COSA_CPU_HH
23 
24 #include "Cosa/Types.h"
25 
29 class CPU {
30 public:
38  static uint8_t clock_prescale(uint8_t factor)
39  {
40  if (UNLIKELY(factor > 4)) factor = 4;
41  uint8_t res = CLKPR;
42  synchronized {
43  CLKPR = _BV(CLKPCE);
44  CLKPR = factor;
45  }
46  return (res);
47  }
48 
54  static uint32_t clock_freq()
55  {
56  return (F_CPU >> CLKPR);
57  }
58 
59 private:
63  CPU() {}
64 };
65 
66 #endif
static uint32_t clock_freq()
Definition: CPU.hh:54
static uint8_t clock_prescale(uint8_t factor)
Definition: CPU.hh:38
Definition: CPU.hh:29
#define UNLIKELY(x)
Definition: Types.h:153