Contiki 3.x
K60.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, Eistec AB.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * This file is part of the Mulle platform port of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * K60 hardware register header wrapper.
36  * \author
37  * Joakim Gebart <joakim.gebart@eistec.se>
38  */
39 
40 #ifndef K60_H_
41 #define K60_H_
42 
43 #include "config-board.h"
44 
45 #ifdef __cplusplus
46 /* MK60D10.h or MK60DZ10.h will be included within extern "C", this is OK. */
47 extern "C" {
48 #endif
49 
50 #if K60_CPU_REV == 2
51 
52 /* K60 CPU silicon version 2.x */
53 #include "MK60D10.h"
54 
55 /** The expected CPUID value, can be used to implement a check that we are
56  * running on the right hardware */
57 #define K60_EXPECTED_CPUID 0x410fc241u
58 
59 #elif K60_CPU_REV == 1
60 
61 /* K60 CPU silicon version 1.x */
62 
63 #include "MK60DZ10.h"
64 
65 /** The expected CPUID value, can be used to implement a check that we are
66  * running on the right hardware */
67 #define K60_EXPECTED_CPUID 0x410fc240u
68 
69 /* Some compatibility defines to minimize the ifdefs needed for the register
70  * name changes */
71 
72 #define SIM_SCGC6_SPI0_MASK SIM_SCGC6_DSPI0_MASK
73 #define SIM_SCGC6_SPI0_SHIFT SIM_SCGC6_DSPI0_SHIFT
74 
75 #define MCG_C2_RANGE0_MASK MCG_C2_RANGE_MASK
76 #define MCG_C5_PRDIV0_MASK MCG_C5_PRDIV_MASK
77 #define MCG_C6_VDIV0_MASK MCG_C6_VDIV_MASK
78 
79 /* The base array initializers are missing from the older MK60DZ10.h header. */
80 /* Copy and paste from MK60D10.h: */
81 #define ADC_BASES { ADC0, ADC1 }
82 #define AIPS_BASES { AIPS0, AIPS1 }
83 #define AXBS_BASES { AXBS }
84 #define CAN_BASES { CAN0, CAN1 }
85 #define CAU_BASES { CAU }
86 #define CMP_BASES { CMP0, CMP1, CMP2 }
87 #define CMT_BASES { CMT }
88 #define CRC_BASES { CRC0 }
89 #define DAC_BASES { DAC0, DAC1 }
90 #define DMA_BASES { DMA0 }
91 #define DMAMUX_BASES { DMAMUX }
92 #define ENET_BASES { ENET }
93 #define EWM_BASES { EWM }
94 #define FB_BASES { FB }
95 #define FMC_BASES { FMC }
96 #define FTFL_BASES { FTFL }
97 #define FTM_BASES { FTM0, FTM1, FTM2 }
98 #define GPIO_BASES { PTA, PTB, PTC, PTD, PTE }
99 #define I2C_BASES { I2C0, I2C1 }
100 #define I2S_BASES { I2S0 }
101 #define LLWU_BASES { LLWU }
102 #define LPTMR_BASES { LPTMR0 }
103 #define MCG_BASES { MCG }
104 #define MCM_BASES { MCM }
105 #define MPU_BASES { MPU }
106 #define NV_BASES { FTFL_FlashConfig }
107 #define OSC_BASES { OSC }
108 #define PDB_BASES { PDB0 }
109 #define PIT_BASES { PIT }
110 #define PMC_BASES { PMC }
111 #define PORT_BASES { PORTA, PORTB, PORTC, PORTD, PORTE }
112 /* No RCM in MK60DZ10.h */
113 /* #define RCM_BASES { RCM } */
114 #define RFSYS_BASES { RFSYS }
115 #define RFVBAT_BASES { RFVBAT }
116 #define RNG_BASES { RNG }
117 #define RTC_BASES { RTC }
118 #define SDHC_BASES { SDHC }
119 #define SIM_BASES { SIM }
120 /* MC->SMC in rev.1 to rev.2 conversion */
121 #define MC_BASES { MC }
122 #define SPI_BASES { SPI0, SPI1, SPI2 }
123 #define TSI_BASES { TSI0 }
124 #define UART_BASES { UART0, UART1, UART2, UART3, UART4, UART5 }
125 #define USB_BASES { USB0 }
126 #define USBDCD_BASES { USBDCD }
127 #define VREF_BASES { VREF }
128 #define WDOG_BASES { WDOG }
129 
130 #else
131 #error K60_CPU_REV must be set to the correct CPU revision!
132 #endif
133 
134 extern ADC_Type * const ADC[];
135 extern AIPS_Type * const AIPS[];
136 extern CAN_Type * const CAN[];
137 extern CMP_Type * const CMP[];
138 extern CRC_Type * const CRC[];
139 extern DAC_Type * const DAC[];
140 extern DMA_Type * const DMA[];
141 extern FTM_Type * const FTM[];
142 extern GPIO_Type * const GPIO[]; /* 0 = A, 1 = B ... */
143 extern I2C_Type * const I2C[];
144 extern I2S_Type * const I2S[];
145 extern LPTMR_Type * const LPTMR[];
146 extern PDB_Type * const PDB[];
147 extern PORT_Type * const PORT[]; /* 0 = A, 1 = B ... */
148 extern SPI_Type * const SPI[];
149 extern TSI_Type * const TSI[];
150 extern UART_Type * const UART[];
151 extern USB_Type * const USB[];
152 
153 #define K60_RUNNING_CPU_REVISION (SCB_CPUID & SCB_CPUID_REVISION_MASK)
154 
155 /* Helpers for the below macro, used to expand the sig variable to a numeric
156  * string, even if it is defined as a macro constant. */
157 #define K60_H_EXPAND_AND_STRINGIFY(s) K60_H_STRINGIFY(s)
158 #define K60_H_STRINGIFY(s) #s
159 
160 /**
161  * Make the CPU signal to the debugger and break execution by issuing a bkpt
162  * instruction.
163  */
164 #define DEBUGGER_BREAK(sig) asm volatile ("bkpt #" K60_H_EXPAND_AND_STRINGIFY(sig) "\n")
165 
166 /*
167  * These are constants that can be used to identify the signal to
168  * DEBUGGER_BREAK(). These can not be converted to an enum because
169  * DEBUGGER_BREAK() is a macro and not a function
170  */
171 #define BREAK_FAULT_HANDLER 0
172 #define BREAK_INVALID_PARAM 1
173 #define BREAK_EXIT 2
174 #define BREAK_MEMORY_CORRUPTION 3
175 #define BREAK_WRONG_K60_CPU_REV 99
176 /* Do not use 0xAB, it is reserved for ARM semihosting environment. */
177 #define BREAK_SEMIHOSTING 0xAB
178 
179 #ifdef __cplusplus
180 } /* extern "C" */
181 #endif
182 
183 #endif /* K60_H_ */
USB - Register Layout Typedef.
Definition: MK60D10.h:8702
CRC - Register Layout Typedef.
Definition: MK60D10.h:2176
CMSIS Peripheral Access Layer for MK60D10.
UART - Register Layout Typedef.
Definition: MK60D10.h:8221
SPI - Register Layout Typedef.
Definition: MK60D10.h:7742
Board configuration defines for Mulle platform.
DAC - Register Layout Typedef.
Definition: MK60D10.h:2344
TSI - Register Layout Typedef.
Definition: MK60D10.h:8011
CMP - Register Layout Typedef.
Definition: MK60D10.h:1950
GPIO - Register Layout Typedef.
Definition: MK60D10.h:4605
I2S - Register Layout Typedef.
Definition: MK60D10.h:4849
ADC - Register Layout Typedef.
Definition: MK60D10.h:266
DMA - Register Layout Typedef.
Definition: MK60D10.h:2447
LPTMR - Register Layout Typedef.
Definition: MK60D10.h:5340
CMSIS Peripheral Access Layer for MK60DZ10.
PORT - Register Layout Typedef.
Definition: MK60D10.h:6332
CAN - Register Layout Typedef.
Definition: MK60D10.h:1488
FTM - Register Layout Typedef.
Definition: MK60D10.h:4126
PDB - Register Layout Typedef.
Definition: MK60D10.h:6044
I2C - Register Layout Typedef.
Definition: MK60D10.h:4692
AIPS - Register Layout Typedef.
Definition: MK60D10.h:487