Prusa MINI Firmware overview
Main Page
Modules
Classes
Files
File List
File Members
dyn_SWI.h
Go to the documentation of this file.
1
/*
2
* File: dyn_SWI.h
3
* Author: xxxajk@gmail.com
4
*
5
* Created on December 5, 2014, 9:12 AM
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
*/
21
22
#ifndef DYN_SWI_H
23
#define DYN_SWI_H
24
25
26
#if defined(__arm__) || defined(ARDUINO_ARCH_PIC32)
27
#ifdef ARDUINO_ARCH_PIC32
28
#include <p32xxxx.h>
29
#endif
30
#ifdef __cplusplus
31
32
#ifdef true
33
#undef true
34
#endif
35
36
#ifdef false
37
#undef false
38
#endif
39
40
#endif
41
42
#ifdef ARDUINO_spresense_ast
43
#define SWI_IRQ_NUM 666 // because this board is totally evil.
44
#elif defined(ARDUINO_ARCH_PIC32)
45
#ifndef SWI_IRQ_NUM
46
#ifdef _DSPI0_IPL_ISR
47
#define SWI_IPL _DSPI0_IPL_ISR
48
#define SWI_VECTOR _DSPI0_ERR_IRQ
49
#define SWI_IRQ_NUM _DSPI0_ERR_IRQ
50
#elif defined(_PMP_ERROR_IRQ)
51
#define SWI_IRQ_NUM _PMP_ERROR_IRQ
52
#define SWI_VECTOR _PMP_VECTOR
53
#else
54
#error SWI_IRQ_NUM and SWI_VECTOR need a definition
55
#endif
56
#ifdef __cplusplus
57
extern
"C"
58
{
59
void
60
#ifdef __PIC32MZXX__
61
__attribute__
((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL)))
62
#else
63
__attribute__
((interrupt(),nomips16))
64
#endif
65
softISR();
66
}
67
#endif
68
#endif
69
#elif !defined(NVIC_NUM_INTERRUPTS)
70
// Assume CMSIS
71
#define __USE_CMSIS_VECTORS__
72
#ifdef NUMBER_OF_INT_VECTORS
73
#define NVIC_NUM_INTERRUPTS (NUMBER_OF_INT_VECTORS-16)
74
#else
75
#define NVIC_NUM_INTERRUPTS ((int)PERIPH_COUNT_IRQn)
76
#endif
77
#define VECTORTABLE_SIZE (NVIC_NUM_INTERRUPTS+16)
78
#define VECTORTABLE_ALIGNMENT (0x100ul)
79
#define NVIC_GET_ACTIVE(n) NVIC_GetActive((IRQn_Type)n)
80
#define NVIC_GET_PENDING(n) NVIC_GetPendingIRQ((IRQn_Type)n)
81
#define NVIC_SET_PENDING(n) NVIC_SetPendingIRQ((IRQn_Type)n)
82
#define NVIC_ENABLE_IRQ(n) NVIC_EnableIRQ((IRQn_Type)n)
83
#define NVIC_SET_PRIORITY(n ,p) NVIC_SetPriority((IRQn_Type)n, (uint32_t) p)
84
//extern "C" {
85
// extern uint32_t _VectorsRam[VECTORTABLE_SIZE] __attribute__((aligned(VECTORTABLE_ALIGNMENT)));
86
//}
87
88
#ifndef SWI_IRQ_NUM
89
#if defined(__SAM3X8E__) && defined(_VARIANT_ARDUINO_DUE_X_)
90
// DUE
91
// Choices available:
92
// HSMCI_IRQn Multimedia Card Interface (HSMCI)
93
// EMAC_IRQn Ethernet MAC (EMAC)
94
// EMAC is not broken out on the official DUE, but is on clones.
95
// SPI0_IRQn Serial Peripheral Interface (SPI0)
96
// SPI0_IRQn seems to be the best choice, as long as nobody uses an ISR based master
97
#define SWI_IRQ_NUM SPI0_IRQn
98
#elif defined(ARDUINO_SAMD_ZERO)
99
// Just use sercom4's unused IRQ vector.
100
#define SWI_IRQ_NUM I2S_IRQn
101
//#define SWI_IRQ_NUM SERCOM4_IRQn
102
#endif
103
#endif
104
105
#ifndef SWI_IRQ_NUM
106
#error SWI_IRQ_NUM not defined (CMSIS)
107
#endif
108
109
#elif defined(CORE_TEENSY)
110
111
#ifndef NVIC_GET_ACTIVE
112
#define NVIC_GET_ACTIVE(n) (*((volatile uint32_t *)0xE000E300 + ((n) >> 5)) & (1 << ((n) & 31)))
113
#endif
114
#ifndef NVIC_GET_PENDING
115
#define NVIC_GET_PENDING(n) (*((volatile uint32_t *)0xE000E200 + ((n) >> 5)) & (1 << ((n) & 31)))
116
#ifndef SWI_IRQ_NUM
117
#ifdef __MK20DX256__
118
#define SWI_IRQ_NUM 17
119
#elif defined(__MK20DX128__)
120
#define SWI_IRQ_NUM 5
121
#elif defined(__MKL26Z64__)
122
#define SWI_IRQ_NUM 4
123
#elif defined(__MK66FX1M0__)
124
#define SWI_IRQ_NUM 30
125
#elif defined(__MK64FX512__)
126
#define SWI_IRQ_NUM 30
127
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
128
#define SWI_IRQ_NUM 71
129
#else
130
#error Do not know how to relocate IRQ vectors for this pjrc product
131
#endif
132
#endif
133
#endif
134
#else // Not CMSIS or PJRC CORE_TEENSY or PIC32 or SPRESENSE
135
#error Do not know how to relocate IRQ vectors or perform SWI
136
#endif // SWI_IRQ_NUM
137
138
139
#ifndef SWI_IRQ_NUM
140
#error SWI_IRQ_NUM not defined
141
#else
142
/**
143
* Use this class to extend your class, in order to provide
144
* a C++ context callable SWI.
145
*/
146
class
dyn_SWI {
147
public
:
148
149
/**
150
* Override this method with your code.
151
*/
152
virtual
void
dyn_SWISR() {
153
};
154
};
155
156
extern
int
exec_SWI(
const
dyn_SWI* klass);
157
158
#include "
SWI_INLINE.h
"
159
160
// IMPORTANT! Define this so that you do NOT end up with a NULL stub!
161
#define SWI_NO_STUB
162
#endif
/* SWI_IRQ_NUM */
163
#endif
/* __arm__ */
164
165
// if no SWI for CPU (e.g. AVR) make a void stub.
166
#ifndef SWI_NO_STUB
167
#define Init_dyn_SWI() (void(0))
168
#ifndef DDSB
169
#define DDSB() (void(0))
170
#endif
171
#endif
172
#endif
/* DYN_SWI_H */
__attribute__
bool boolean __attribute__((deprecated))
Definition:
wiring_constants.h:110
SWI_INLINE.h
Prusa-Firmware-Buddy-Private1
lib
Marlin
Marlin
src
sd
usb_flashdrive
lib-uhs3
dyn_SWI
dyn_SWI.h
Generated by
1.8.16