Contiki 3.x
cpu.h
1 /*-----------------------------------------------------------------------------------------------------------------------------------*/
2 /* cpu.h
3  *
4  * Initialisation & Interrupt handler for CPU on the Freescale FRDM-KL25z Freedom Board
5  *
6  * Author: Graeme Bragg
7  * ARM-ECS / Pervasive Systems Centre
8  * School of Electronics & Computer Science
9  * University of Southampton
10  *
11  *
12  * 27/2/2012 Rev.01 Configures CPU for 20.97152MHz Bus, Core and MCG Clock sources from the internal 32K reference oscillator.
13  * CPU runs in FEI. MGCIRCLK source is set to the slow internal oscillator.
14  * VLPM, LLS and VLLS are "allowed". NMI Interrupt is enabled on PTA4, Reset is PTA20.
15  * 5/3/2013 Rev.02 Functions to enter low power modes.
16  * 12/3/2013 Rev.03 Added definitions for clock values.
17  * 18/2/2014 Rev.04 Options for 21MHz (from 32k internal) or 48MHz (from 8MHz external) clocks.
18  *
19  *
20  * ***NB*** This file is intended for use with a new "Bareboard" project (with no rapid-development) in Code Warrior.
21  * If this is not the case, you MUST ensure that an appropriate entry of "NMI_Handler" exists in entry 2
22  * (address 0x00000008) of the VectorTable.
23  *
24  * Appropriate entries for the interrupt handler exist in the vector table contained in the generated
25  * kinetis_sysinit.c file
26  */
27 /*-----------------------------------------------------------------------------------------------------------------------------------*/
28 
29 #ifndef __CPU_H
30 #define __CPU_H
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 
35 #define PORTB_EN_MASK 0x01
36 #define PORTC_EN_MASK 0x02
37 #define PORTD_EN_MASK 0x04
38 #define PORTE_EN_MASK 0x08
39 
40 #if defined(__21mhzIR)
41  #define CORECLK 20971520
42  #define BUSCLK 20971520
43 #else
44  #define CORECLK 48000000
45  #define BUSCLK 24000000
46 #endif
47 
48 #if defined(OSCK32KSEL_RTCIN)
49  #define MCGIRCLK 32768
50 #else
51  #define MCGIRCLK 1000
52 #endif
53 
54 /* SCR Bit Fields */
55 #define SCB_SCR_SLEEPONEXIT_MASK 0x2u
56 #define SCB_SCR_SLEEPONEXIT_SHIFT 1
57 #define SCB_SCR_SLEEPDEEP_MASK 0x4u
58 #define SCB_SCR_SLEEPDEEP_SHIFT 2
59 #define SCB_SCR_SEVONPEND_MASK 0x10u
60 #define SCB_SCR_SEVONPEND_SHIFT 4
61 
62 
63 typedef enum {
64  Mode_Stop,
65  Mode_PStop1,
66  Mode_PStop2,
67  Mode_LLS,
68  Mode_VLPS,
69  Mode_VLLS0,
70  Mode_VLLS1,
71  Mode_VLLS3
72 } Type_StopMode; /* Stop Mode selection. */
73 
74 void port_enable(uint8_t PortMask); /* Enable clock to used ports. This is required before configuring the port. */
75 
76 void cpu_init(void); /* Configure CPU for 20MHz clock from 32K internal oscillator */
77 
78 /* Power Control Functions */
79 void cpu_run(void); /* Enter run mode. */
80 void cpu_wait(void); /* Enter wait mode. */
81 void cpu_stop(Type_StopMode StopMode); /* Enter stop mode. */
82 
83 
84 /** \brief Disables all CPU interrupts */
85 unsigned long cpu_cpsid(void);
86 #define INTERRUPTS_DISABLE() cpu_cpsid()
87 
88 /** \brief Enables all CPU interrupts */
89 unsigned long cpu_cpsie(void);
90 #define INTERRUPTS_ENABLE() cpu_cpsie()
91 
92 
93 #if (DISABLE_WDOG == 0)
94 uint8_t CPU_Watchdog_Disabled(void);
95 void CPU_Watchdog_Disable(void);
96 void CPU_Watchdog_Enable(void);
97 #endif
98 
99 void cpu_reboot_src(void);
100 
101 void NMI_Handler(void); /* NMI Interrupt Handler */
102 void SysTick_Handler(void);
103 
104 /*
105 ** ===================================================================
106 ** Method : Default_Handler
107 **
108 ** Description :
109 ** The default interrupt handlers.
110 ** ===================================================================
111 */
112 void Default_Handler_NMI();
113 void Default_Handler_HardFault();
114 void Default_Handler_SVC();
115 void Default_Handler_PendSV();
116 void Default_Handler_SysTick();
117 void Default_Handler_DMA0();
118 void Default_Handler_DMA1();
119 void Default_Handler_DMA2();
120 void Default_Handler_DMA3();
121 void Default_Handler_MCM();
122 void Default_Handler_FTFL();
123 void Default_Handler_PMC();
124 void Default_Handler_LLW();
125 void Default_Handler_I2C0();
126 void Default_Handler_I2C1();
127 void Default_Handler_SPI0();
128 void Default_Handler_SPI1();
129 void Default_Handler_UART0();
130 void Default_Handler_UART1();
131 void Default_Handler_UART2();
132 void Default_Handler_ADC0();
133 void Default_Handler_CMP0();
134 void Default_Handler_TPM0();
135 void Default_Handler_TPM1();
136 void Default_Handler_TPM2();
137 void Default_Handler_RTC_Alarm();
138 void Default_Handler_RTC_Seconds();
139 void Default_Handler_PIT();
140 void Default_Handler_USBOTG();
141 void Default_Handler_DAC0();
142 void Default_Handler_TSI0();
143 void Default_Handler_MCG();
144 void Default_Handler_LPTimer();
145 void Default_Handler_PORTA();
146 void Default_Handler_PORTD();
147 
148 #endif /* __CPU_H */
unsigned long cpu_cpsid(void)
Disables all CPU interrupts.
Definition: cpu.c:168
unsigned long cpu_cpsie(void)
Enables all CPU interrupts.
Definition: cpu.c:152