Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 142 | jimmy | 1 | /** |
| 2 | * MCU driver. |
||
| 3 | * |
||
| 4 | * @date 2006-11-19 |
||
| 5 | * |
||
| 6 | * @author Jimmy Myhrman |
||
| 7 | * |
||
| 8 | */ |
||
| 9 | |||
| 10 | /*----------------------------------------------------------------------------- |
||
| 11 | * Includes |
||
| 12 | *---------------------------------------------------------------------------*/ |
||
| 13 | #include <mcu.h> |
||
| 14 | |||
| 15 | |||
| 16 | /*----------------------------------------------------------------------------- |
||
| 17 | * Prerequisites |
||
| 18 | *---------------------------------------------------------------------------*/ |
||
| 19 | #ifndef MCU |
||
| 20 | #error MCU Not defined in mcu_cfg.h |
||
| 21 | #endif |
||
| 22 | |||
| 23 | |||
| 24 | /*----------------------------------------------------------------------------- |
||
| 25 | * Public Functions |
||
| 26 | *---------------------------------------------------------------------------*/ |
||
| 27 | |||
| 28 | /** |
||
| 208 | jimmy | 29 | * Initialize MCU. If the MCU is mega88, the internal clock frequency will be |
| 30 | * set to 8MHz. Interrupts must not be enabled when calling this function! |
||
| 31 | */ |
||
| 32 | void Mcu_Init() { |
||
| 381 | eqlazer | 33 | #if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) |
| 208 | jimmy | 34 | // set the clock speed to 8MHz |
| 35 | // set the clock prescaler. First write CLKPCE to enable setting of clock the |
||
| 36 | // next four instructions. |
||
| 37 | CLKPR=(1<<CLKPCE); |
||
| 38 | CLKPR=0; // 8 MHZ |
||
| 39 | #endif |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 142 | jimmy | 43 | * Enable interrupts. |
| 44 | */ |
||
| 45 | void Mcu_EnableIRQ() { |
||
| 46 | #if MCU == ATMEGA8 |
||
| 47 | sei(); |
||
| 48 | #endif |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Disable interrupts. |
||
| 53 | */ |
||
| 54 | void Mcu_DisableIRQ() { |
||
| 55 | #if MCU == ATMEGA8 |
||
| 56 | cli(); |
||
| 57 | #endif |
||
| 58 | } |