ceedling 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -3
- data/bin/ceedling +2 -1
- data/examples/blinky/project.yml +98 -0
- data/examples/blinky/rakefile.rb +23 -0
- data/examples/blinky/src/BlinkTask.c +21 -0
- data/examples/blinky/src/BlinkTask.h +8 -0
- data/examples/blinky/src/Configure.c +38 -0
- data/examples/blinky/src/Configure.h +6 -0
- data/examples/blinky/src/main.c +51 -0
- data/examples/blinky/src/main.h +9 -0
- data/examples/blinky/test/support/stub_interrupt.h +348 -0
- data/examples/blinky/test/support/stub_io.h +421 -0
- data/examples/blinky/test/support/stub_iom328p.h +883 -0
- data/examples/blinky/test/support/stub_sfr_defs.h +269 -0
- data/examples/blinky/test/test_BlinkTask.c +36 -0
- data/examples/blinky/test/test_Configure.c +28 -0
- data/examples/blinky/test/test_main.c +60 -0
- data/lib/ceedling/version.rb +4 -4
- data/lib/ceedling/version.rb.erb +1 -1
- data/new_project_template/vendor/ceedling/docs/CExceptionSummary.pdf +0 -0
- data/new_project_template/vendor/ceedling/vendor/c_exception/lib/CException.c +7 -3
- data/new_project_template/vendor/ceedling/vendor/c_exception/lib/CException.h +16 -0
- data/new_project_template/vendor/ceedling/vendor/c_exception/release/build.info +1 -1
- data/new_project_template/vendor/ceedling/vendor/cmock/lib/cmock_generator_plugin_callback.rb +1 -1
- data/new_project_template/vendor/ceedling/vendor/cmock/release/build.info +1 -1
- data/new_project_template/vendor/ceedling/vendor/unity/release/build.info +1 -1
- data/new_project_template/vendor/ceedling/vendor/unity/src/unity.c +18 -3
- data/new_project_template/vendor/ceedling/vendor/unity/src/unity_internals.h +3 -3
- metadata +19 -4
data/README.md
CHANGED
@@ -60,7 +60,8 @@ Authors
|
|
60
60
|
=======
|
61
61
|
* Mike Karlesky (michael@karlesky.net)
|
62
62
|
* Mark VanderVoord (mvandervoord@gmail.com)
|
63
|
-
* Greg Williams (williams@
|
63
|
+
* Greg Williams (williams@atomicembedded.com)
|
64
64
|
* Matt Fletcher (fletcher@atomicobject.com)
|
65
|
-
*
|
66
|
-
*
|
65
|
+
* Nick Christensen (nick.christensen@atomicembedded)
|
66
|
+
*
|
67
|
+
* © 2012 [ThrowTheSwitch](http://throwtheswitch.org/
|
data/bin/ceedling
CHANGED
@@ -46,7 +46,8 @@ class CeedlingTasks < Thor
|
|
46
46
|
end
|
47
47
|
|
48
48
|
desc "example PROJ_NAME [DEST]", "create specified example project (in DEST, if specified)"
|
49
|
-
def example(proj_name, dest=
|
49
|
+
def example(proj_name, dest=nil)
|
50
|
+
dest = proj_name if !dest
|
50
51
|
directory Ceedling::NEW_PROJECT_DIR, dest
|
51
52
|
remove_file "#{dest}/project.yml"
|
52
53
|
remove_file "#{dest}/rakefile.rb"
|
@@ -0,0 +1,98 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
# Notes:
|
4
|
+
# This is a fully tested project that demonstrates the use
|
5
|
+
# of a timer ISR to blink the on board LED of an Arduino UNO
|
6
|
+
:project:
|
7
|
+
:use_exceptions: FALSE
|
8
|
+
:use_test_preprocessor: TRUE
|
9
|
+
:use_auxiliary_dependencies: TRUE
|
10
|
+
:build_root: build
|
11
|
+
:release_build: TRUE
|
12
|
+
:test_file_prefix: test_
|
13
|
+
|
14
|
+
#You'll have to specify these
|
15
|
+
:environment:
|
16
|
+
- :mcu: atmega328p
|
17
|
+
- :f_cpu: 16000000UL
|
18
|
+
- :serial_port: COM8 #change this to the serial port you are using!!!
|
19
|
+
- :objcopy: avr-objcopy
|
20
|
+
# Uncomment these lines if you are using windows and don't have these tools in your path
|
21
|
+
# - :path:
|
22
|
+
# - C:\mingw\bin
|
23
|
+
# - C:\WinAVR-20100110\bin
|
24
|
+
# - C:\WinAVR-20100110\utils\bin
|
25
|
+
# - #{ENV['PATH']}
|
26
|
+
|
27
|
+
:extension:
|
28
|
+
:executable: .bin
|
29
|
+
|
30
|
+
:release_build:
|
31
|
+
:output: blinky
|
32
|
+
|
33
|
+
:paths:
|
34
|
+
:test:
|
35
|
+
- +:test/**
|
36
|
+
- -:test/support
|
37
|
+
:source:
|
38
|
+
- src/**
|
39
|
+
:support:
|
40
|
+
- test/support
|
41
|
+
|
42
|
+
:defines:
|
43
|
+
# in order to add common defines:
|
44
|
+
# 1) remove the trailing [] from the :common: section
|
45
|
+
# 2) add entries to the :common: section (e.g. :test: has TEST defined)
|
46
|
+
:commmon: &common_defines []
|
47
|
+
:test:
|
48
|
+
- *common_defines
|
49
|
+
- TEST
|
50
|
+
:test_preprocess:
|
51
|
+
- *common_defines
|
52
|
+
- TEST
|
53
|
+
|
54
|
+
:tools:
|
55
|
+
:release_compiler:
|
56
|
+
:executable: avr-gcc
|
57
|
+
:arguments:
|
58
|
+
- ${1}
|
59
|
+
- -DTARGET
|
60
|
+
- -DF_CPU=#{ENV['F_CPU']}
|
61
|
+
- -mmcu=#{ENV['MCU']}
|
62
|
+
- -Iinclude/
|
63
|
+
- -Wall
|
64
|
+
- -Os
|
65
|
+
- -c
|
66
|
+
- -o ${2}
|
67
|
+
:release_linker:
|
68
|
+
:executable: avr-gcc
|
69
|
+
:arguments:
|
70
|
+
- -mmcu=#{ENV['MCU']}
|
71
|
+
- ${1}
|
72
|
+
- -o ${2}.bin
|
73
|
+
|
74
|
+
:cmock:
|
75
|
+
:mock_prefix: mock_
|
76
|
+
:when_no_prototypes: :warn
|
77
|
+
:enforce_strict_ordering: TRUE
|
78
|
+
:plugins:
|
79
|
+
- :ignore
|
80
|
+
:treat_as:
|
81
|
+
uint8: HEX8
|
82
|
+
uint16: HEX16
|
83
|
+
uint32: UINT32
|
84
|
+
int8: INT8
|
85
|
+
bool: UINT8
|
86
|
+
|
87
|
+
#:tools:
|
88
|
+
# Ceedling defaults to using gcc for compiling, linking, etc.
|
89
|
+
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
|
90
|
+
# See documentation to configure a given toolchain for use
|
91
|
+
|
92
|
+
:plugins:
|
93
|
+
:load_paths:
|
94
|
+
- vendor/ceedling/plugins
|
95
|
+
:enabled:
|
96
|
+
- stdout_pretty_tests_report
|
97
|
+
- module_generator
|
98
|
+
...
|
@@ -0,0 +1,23 @@
|
|
1
|
+
PROJECT_CEEDLING_ROOT = "vendor/ceedling"
|
2
|
+
load "#{PROJECT_CEEDLING_ROOT}/lib/rakefile.rb"
|
3
|
+
|
4
|
+
task :default => %w[ test:all release ]
|
5
|
+
|
6
|
+
# Dummy task to ensure that the SERIAL_PORT environment variable is set.
|
7
|
+
# It can be set on the command line as follows:
|
8
|
+
# $ rake SERIAL_PORT=[serial port name]
|
9
|
+
task :serial_port do
|
10
|
+
unless ENV['SERIAL_PORT']
|
11
|
+
raise "SERIAL_PORT is not defined in the environment!"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Convert the output binary to a hex file for programming to the Arduino"
|
16
|
+
task :convert => :release do
|
17
|
+
sh "#{ENV['objcopy']} -O ihex -R .eeprom build\\release\\#{RELEASE_BUILD_OUTPUT}.bin build\\release\\#{RELEASE_BUILD_OUTPUT}.hex"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Program the Arduino over the serial port."
|
21
|
+
task :program => [:convert, :serial_port] do
|
22
|
+
sh "avrdude -F -V -c arduino -p #{ENV['MCU']} -P #{ENV['SERIAL_PORT']} -b 115200 -U flash:w:build\\release\\#{RELEASE_BUILD_OUTPUT}.hex"
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// #include <stdint.h>
|
2
|
+
|
3
|
+
#include "BlinkTask.h"
|
4
|
+
|
5
|
+
#ifdef TEST
|
6
|
+
#define LOOP
|
7
|
+
#include "stub_io.h"
|
8
|
+
#else
|
9
|
+
#include <avr/interrupt.h>
|
10
|
+
#include <avr/io.h>
|
11
|
+
#define LOOP while(1)
|
12
|
+
#endif // TEST
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
void BlinkTask(void)
|
17
|
+
{
|
18
|
+
/* toggle the LED */
|
19
|
+
PORTB ^= _BV(PORTB5);
|
20
|
+
|
21
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#include "Configure.h"
|
2
|
+
#include "main.h"
|
3
|
+
#ifdef TEST
|
4
|
+
#define LOOP
|
5
|
+
#include "stub_io.h"
|
6
|
+
#include "stub_interrupt.h"
|
7
|
+
#else
|
8
|
+
#include <avr/interrupt.h>
|
9
|
+
#include <avr/io.h>
|
10
|
+
#define LOOP while(1)
|
11
|
+
#endif // TEST
|
12
|
+
|
13
|
+
/* setup timer 0 to divide bus clock by 64.
|
14
|
+
This results in a 1.024ms overflow interrupt
|
15
|
+
16000000/64
|
16
|
+
250000
|
17
|
+
|
18
|
+
0.000 004s *256
|
19
|
+
0.001024
|
20
|
+
*/
|
21
|
+
void Configure(void)
|
22
|
+
{
|
23
|
+
/* disable interrupts */
|
24
|
+
cli();
|
25
|
+
|
26
|
+
/* Configure TIMER0 to use the CLK/64 prescaler. */
|
27
|
+
TCCR0B = _BV(CS00) | _BV(CS01);
|
28
|
+
|
29
|
+
/* enable the TIMER0 overflow interrupt */
|
30
|
+
TIMSK0 = _BV(TOIE0);
|
31
|
+
|
32
|
+
/* confiure PB5 as an output. */
|
33
|
+
DDRB |= _BV(DDB5);
|
34
|
+
|
35
|
+
/* enable interrupts. */
|
36
|
+
sei();
|
37
|
+
}
|
38
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// #include <stdint.h>
|
2
|
+
|
3
|
+
#include "main.h"
|
4
|
+
#include "BlinkTask.h"
|
5
|
+
#include "Configure.h"
|
6
|
+
|
7
|
+
//Most OS's frown upon direct memory access.
|
8
|
+
//So we'll have to use fake registers during testing.
|
9
|
+
#ifdef TEST
|
10
|
+
#define LOOP
|
11
|
+
#include "stub_io.h"
|
12
|
+
#include "stub_interrupt.h"
|
13
|
+
#else
|
14
|
+
#include <avr/interrupt.h>
|
15
|
+
#include <avr/io.h>
|
16
|
+
#define LOOP while(1)
|
17
|
+
//The target will need a main.
|
18
|
+
//Our test runner will provide it's own and call AppMain()
|
19
|
+
int main(void)
|
20
|
+
{
|
21
|
+
return AppMain();
|
22
|
+
}
|
23
|
+
#endif // TEST
|
24
|
+
|
25
|
+
int AppMain(void)
|
26
|
+
{
|
27
|
+
Configure();
|
28
|
+
|
29
|
+
LOOP
|
30
|
+
{
|
31
|
+
if(BlinkTaskReady==0x01)
|
32
|
+
{
|
33
|
+
BlinkTaskReady = 0x00;
|
34
|
+
BlinkTask();
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return 0;
|
38
|
+
}
|
39
|
+
|
40
|
+
ISR(TIMER0_OVF_vect)
|
41
|
+
{
|
42
|
+
/* toggle every thousand ticks */
|
43
|
+
if (tick >= 1000)
|
44
|
+
{
|
45
|
+
/* signal our periodic task. */
|
46
|
+
BlinkTaskReady = 0x01;
|
47
|
+
/* reset the tick */
|
48
|
+
tick = 0;
|
49
|
+
}
|
50
|
+
tick++;
|
51
|
+
}
|
@@ -0,0 +1,348 @@
|
|
1
|
+
/* Copyright (c) 2002,2005,2007 Marek Michalkiewicz
|
2
|
+
Copyright (c) 2007, Dean Camera
|
3
|
+
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in
|
14
|
+
the documentation and/or other materials provided with the
|
15
|
+
distribution.
|
16
|
+
|
17
|
+
* Neither the name of the copyright holders nor the names of
|
18
|
+
contributors may be used to endorse or promote products derived
|
19
|
+
from this software without specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
24
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
25
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
26
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
+
POSSIBILITY OF SUCH DAMAGE. */
|
32
|
+
|
33
|
+
/* $Id: interrupt.h,v 1.25.2.1 2008/01/05 06:33:11 dmix Exp $ */
|
34
|
+
|
35
|
+
#ifndef _AVR_INTERRUPT_H_
|
36
|
+
#define _AVR_INTERRUPT_H_
|
37
|
+
|
38
|
+
// #include <avr/io.h>
|
39
|
+
#include "stub_io.h"
|
40
|
+
#if !defined(__DOXYGEN__) && !defined(__STRINGIFY)
|
41
|
+
/* Auxiliary macro for ISR_ALIAS(). */
|
42
|
+
#define __STRINGIFY(x) #x
|
43
|
+
#endif /* !defined(__DOXYGEN__) */
|
44
|
+
|
45
|
+
/**
|
46
|
+
\file
|
47
|
+
\@{
|
48
|
+
*/
|
49
|
+
|
50
|
+
|
51
|
+
/** \name Global manipulation of the interrupt flag
|
52
|
+
|
53
|
+
The global interrupt flag is maintained in the I bit of the status
|
54
|
+
register (SREG).
|
55
|
+
*/
|
56
|
+
|
57
|
+
// #if defined(__DOXYGEN__)
|
58
|
+
#if 1
|
59
|
+
/** \def sei()
|
60
|
+
\ingroup avr_interrupts
|
61
|
+
|
62
|
+
\code #include <avr/interrupt.h> \endcode
|
63
|
+
|
64
|
+
Enables interrupts by setting the global interrupt mask. This function
|
65
|
+
actually compiles into a single line of assembly, so there is no function
|
66
|
+
call overhead. */
|
67
|
+
#define sei()
|
68
|
+
#else /* !DOXYGEN */
|
69
|
+
# define sei() __asm__ __volatile__ ("sei" ::)
|
70
|
+
#endif /* DOXYGEN */
|
71
|
+
|
72
|
+
// #if defined(__DOXYGEN__)
|
73
|
+
#if 1
|
74
|
+
/** \def cli()
|
75
|
+
\ingroup avr_interrupts
|
76
|
+
|
77
|
+
\code #include <avr/interrupt.h> \endcode
|
78
|
+
|
79
|
+
Disables all interrupts by clearing the global interrupt mask. This function
|
80
|
+
actually compiles into a single line of assembly, so there is no function
|
81
|
+
call overhead. */
|
82
|
+
#define cli()
|
83
|
+
#else /* !DOXYGEN */
|
84
|
+
# define cli() __asm__ __volatile__ ("cli" ::)
|
85
|
+
#endif /* DOXYGEN */
|
86
|
+
|
87
|
+
|
88
|
+
/** \name Macros for writing interrupt handler functions */
|
89
|
+
|
90
|
+
|
91
|
+
// #if defined(__DOXYGEN__)
|
92
|
+
#if 1
|
93
|
+
/** \def ISR(vector [, attributes])
|
94
|
+
\ingroup avr_interrupts
|
95
|
+
|
96
|
+
\code #include <avr/interrupt.h> \endcode
|
97
|
+
|
98
|
+
Introduces an interrupt handler function (interrupt service
|
99
|
+
routine) that runs with global interrupts initially disabled
|
100
|
+
by default with no attributes specified.
|
101
|
+
|
102
|
+
The attributes are optional and alter the behaviour and resultant
|
103
|
+
generated code of the interrupt routine. Multiple attributes may
|
104
|
+
be used for a single function, with a space seperating each
|
105
|
+
attribute.
|
106
|
+
|
107
|
+
Valid attributes are ISR_BLOCK, ISR_NOBLOCK, ISR_NAKED and
|
108
|
+
ISR_ALIASOF(vect).
|
109
|
+
|
110
|
+
\c vector must be one of the interrupt vector names that are
|
111
|
+
valid for the particular MCU type.
|
112
|
+
*/
|
113
|
+
// # define ISR(vector, [attributes])
|
114
|
+
#define ISR void ISR
|
115
|
+
#else /* real code */
|
116
|
+
|
117
|
+
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
118
|
+
# define __INTR_ATTRS used, externally_visible
|
119
|
+
#else /* GCC < 4.1 */
|
120
|
+
# define __INTR_ATTRS used
|
121
|
+
#endif
|
122
|
+
|
123
|
+
#ifdef __cplusplus
|
124
|
+
# define ISR(vector, ...) \
|
125
|
+
extern "C" void vector (void) __attribute__ ((signal,__INTR_ATTRS)) __VA_ARGS__; \
|
126
|
+
void vector (void)
|
127
|
+
#else
|
128
|
+
# define ISR(vector, ...) \
|
129
|
+
void vector (void) __attribute__ ((signal,__INTR_ATTRS)) __VA_ARGS__; \
|
130
|
+
void vector (void)
|
131
|
+
#endif
|
132
|
+
|
133
|
+
#endif /* DOXYGEN */
|
134
|
+
|
135
|
+
#if defined(__DOXYGEN__)
|
136
|
+
/** \def SIGNAL(vector)
|
137
|
+
\ingroup avr_interrupts
|
138
|
+
|
139
|
+
\code #include <avr/interrupt.h> \endcode
|
140
|
+
|
141
|
+
Introduces an interrupt handler function that runs with global interrupts
|
142
|
+
initially disabled.
|
143
|
+
|
144
|
+
This is the same as the ISR macro without optional attributes.
|
145
|
+
\deprecated Do not use SIGNAL() in new code. Use ISR() instead.
|
146
|
+
*/
|
147
|
+
# define SIGNAL(vector)
|
148
|
+
#else /* real code */
|
149
|
+
|
150
|
+
#ifdef __cplusplus
|
151
|
+
# define SIGNAL(vector) \
|
152
|
+
extern "C" void vector(void) __attribute__ ((signal, __INTR_ATTRS)); \
|
153
|
+
void vector (void)
|
154
|
+
#else
|
155
|
+
# define SIGNAL(vector) \
|
156
|
+
void vector (void) __attribute__ ((signal, __INTR_ATTRS)); \
|
157
|
+
void vector (void)
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#endif /* DOXYGEN */
|
161
|
+
|
162
|
+
#if defined(__DOXYGEN__)
|
163
|
+
/** \def EMPTY_INTERRUPT(vector)
|
164
|
+
\ingroup avr_interrupts
|
165
|
+
|
166
|
+
\code #include <avr/interrupt.h> \endcode
|
167
|
+
|
168
|
+
Defines an empty interrupt handler function. This will not generate
|
169
|
+
any prolog or epilog code and will only return from the ISR. Do not
|
170
|
+
define a function body as this will define it for you.
|
171
|
+
Example:
|
172
|
+
\code EMPTY_INTERRUPT(ADC_vect);\endcode */
|
173
|
+
# define EMPTY_INTERRUPT(vector)
|
174
|
+
#else /* real code */
|
175
|
+
|
176
|
+
#ifdef __cplusplus
|
177
|
+
# define EMPTY_INTERRUPT(vector) \
|
178
|
+
extern "C" void vector(void) __attribute__ ((signal,naked,__INTR_ATTRS)); \
|
179
|
+
void vector (void) { __asm__ __volatile__ ("reti" ::); }
|
180
|
+
#else
|
181
|
+
# define EMPTY_INTERRUPT(vector) \
|
182
|
+
void vector (void) __attribute__ ((signal,naked,__INTR_ATTRS)); \
|
183
|
+
void vector (void) { __asm__ __volatile__ ("reti" ::); }
|
184
|
+
#endif
|
185
|
+
|
186
|
+
#endif /* DOXYGEN */
|
187
|
+
|
188
|
+
#if defined(__DOXYGEN__)
|
189
|
+
/** \def ISR_ALIAS(vector, target_vector)
|
190
|
+
\ingroup avr_interrupts
|
191
|
+
|
192
|
+
\code #include <avr/interrupt.h> \endcode
|
193
|
+
|
194
|
+
Aliases a given vector to another one in the same manner as the
|
195
|
+
ISR_ALIASOF attribute for the ISR() macro. Unlike the ISR_ALIASOF
|
196
|
+
attribute macro however, this is compatible for all versions of
|
197
|
+
GCC rather than just GCC version 4.2 onwards.
|
198
|
+
|
199
|
+
\note This macro creates a trampoline function for the aliased
|
200
|
+
macro. This will result in a two cycle penalty for the aliased
|
201
|
+
vector compared to the ISR the vector is aliased to, due to the
|
202
|
+
JMP/RJMP opcode used.
|
203
|
+
|
204
|
+
\deprecated
|
205
|
+
For new code, the use of ISR(..., ISR_ALIASOF(...)) is
|
206
|
+
recommended.
|
207
|
+
|
208
|
+
Example:
|
209
|
+
\code
|
210
|
+
ISR(INT0_vect)
|
211
|
+
{
|
212
|
+
PORTB = 42;
|
213
|
+
}
|
214
|
+
|
215
|
+
ISR_ALIAS(INT1_vect, INT0_vect);
|
216
|
+
\endcode
|
217
|
+
*/
|
218
|
+
# define ISR_ALIAS(vector, target_vector)
|
219
|
+
#else /* real code */
|
220
|
+
|
221
|
+
#ifdef __cplusplus
|
222
|
+
# if defined(__AVR_MEGA__) && __AVR_MEGA__
|
223
|
+
# define ISR_ALIAS(vector, tgt) extern "C" void vector (void) \
|
224
|
+
__attribute__((signal, naked, __INTR_ATTRS)); \
|
225
|
+
void vector (void) { asm volatile ("jmp " __STRINGIFY(tgt) ::); }
|
226
|
+
# else /* !__AVR_MEGA */
|
227
|
+
# define ISR_ALIAS(vector, tgt) extern "C" void vector (void) \
|
228
|
+
__attribute__((signal, naked, __INTR_ATTRS)); \
|
229
|
+
void vector (void) { asm volatile ("rjmp " __STRINGIFY(tgt) ::); }
|
230
|
+
# endif /* __AVR_MEGA__ */
|
231
|
+
#else /* !__cplusplus */
|
232
|
+
# if defined(__AVR_MEGA__) && __AVR_MEGA__
|
233
|
+
# define ISR_ALIAS(vector, tgt) void vector (void) \
|
234
|
+
__attribute__((signal, naked, __INTR_ATTRS)); \
|
235
|
+
void vector (void) { asm volatile ("jmp " __STRINGIFY(tgt) ::); }
|
236
|
+
# else /* !__AVR_MEGA */
|
237
|
+
# define ISR_ALIAS(vector, tgt) void vector (void) \
|
238
|
+
__attribute__((signal, naked, __INTR_ATTRS)); \
|
239
|
+
void vector (void) { asm volatile ("rjmp " __STRINGIFY(tgt) ::); }
|
240
|
+
# endif /* __AVR_MEGA__ */
|
241
|
+
#endif /* __cplusplus */
|
242
|
+
|
243
|
+
#endif /* DOXYGEN */
|
244
|
+
|
245
|
+
#if defined(__DOXYGEN__)
|
246
|
+
/** \def reti()
|
247
|
+
\ingroup avr_interrupts
|
248
|
+
|
249
|
+
\code #include <avr/interrupt.h> \endcode
|
250
|
+
|
251
|
+
Returns from an interrupt routine, enabling global interrupts. This should
|
252
|
+
be the last command executed before leaving an ISR defined with the ISR_NAKED
|
253
|
+
attribute.
|
254
|
+
|
255
|
+
This macro actually compiles into a single line of assembly, so there is
|
256
|
+
no function call overhead.
|
257
|
+
*/
|
258
|
+
# define reti()
|
259
|
+
#else /* !DOXYGEN */
|
260
|
+
# define reti() __asm__ __volatile__ ("reti" ::)
|
261
|
+
#endif /* DOXYGEN */
|
262
|
+
|
263
|
+
#if defined(__DOXYGEN__)
|
264
|
+
/** \def BADISR_vect
|
265
|
+
\ingroup avr_interrupts
|
266
|
+
|
267
|
+
\code #include <avr/interrupt.h> \endcode
|
268
|
+
|
269
|
+
This is a vector which is aliased to __vector_default, the vector
|
270
|
+
executed when an ISR fires with no accompanying ISR handler. This
|
271
|
+
may be used along with the ISR() macro to create a catch-all for
|
272
|
+
undefined but used ISRs for debugging purposes.
|
273
|
+
*/
|
274
|
+
# define BADISR_vect
|
275
|
+
#else /* !DOXYGEN */
|
276
|
+
# define BADISR_vect __vector_default
|
277
|
+
#endif /* DOXYGEN */
|
278
|
+
|
279
|
+
/** \name ISR attributes */
|
280
|
+
|
281
|
+
#if defined(__DOXYGEN__)
|
282
|
+
/** \def ISR_BLOCK
|
283
|
+
\ingroup avr_interrupts
|
284
|
+
|
285
|
+
\code# include <avr/interrupt.h> \endcode
|
286
|
+
|
287
|
+
Identical to an ISR with no attributes specified. Global
|
288
|
+
interrupts are initially disabled by the AVR hardware when
|
289
|
+
entering the ISR, without the compiler modifying this state.
|
290
|
+
|
291
|
+
Use this attribute in the attributes parameter of the ISR macro.
|
292
|
+
*/
|
293
|
+
# define ISR_BLOCK
|
294
|
+
|
295
|
+
/** \def ISR_NOBLOCK
|
296
|
+
\ingroup avr_interrupts
|
297
|
+
|
298
|
+
\code# include <avr/interrupt.h> \endcode
|
299
|
+
|
300
|
+
ISR runs with global interrupts initially enabled. The interrupt
|
301
|
+
enable flag is activated by the compiler as early as possible
|
302
|
+
within the ISR to ensure minimal processing delay for nested
|
303
|
+
interrupts.
|
304
|
+
|
305
|
+
This may be used to create nested ISRs, however care should be
|
306
|
+
taken to avoid stack overflows, or to avoid infinitely entering
|
307
|
+
the ISR for those cases where the AVR hardware does not clear the
|
308
|
+
respective interrupt flag before entering the ISR.
|
309
|
+
|
310
|
+
Use this attribute in the attributes parameter of the ISR macro.
|
311
|
+
*/
|
312
|
+
# define ISR_NOBLOCK
|
313
|
+
|
314
|
+
/** \def ISR_NAKED
|
315
|
+
\ingroup avr_interrupts
|
316
|
+
|
317
|
+
\code# include <avr/interrupt.h> \endcode
|
318
|
+
|
319
|
+
ISR is created with no prologue or epilogue code. The user code is
|
320
|
+
responsible for preservation of the machine state including the
|
321
|
+
SREG register, as well as placing a reti() at the end of the
|
322
|
+
interrupt routine.
|
323
|
+
|
324
|
+
Use this attribute in the attributes parameter of the ISR macro.
|
325
|
+
*/
|
326
|
+
# define ISR_NAKED
|
327
|
+
|
328
|
+
/** \def ISR_ALIASOF(target_vector)
|
329
|
+
\ingroup avr_interrupts
|
330
|
+
|
331
|
+
\code#include <avr/interrupt.h>\endcode
|
332
|
+
|
333
|
+
The ISR is linked to another ISR, specified by the vect parameter.
|
334
|
+
This is compatible with GCC 4.2 and greater only.
|
335
|
+
|
336
|
+
Use this attribute in the attributes parameter of the ISR macro.
|
337
|
+
*/
|
338
|
+
# define ISR_ALIASOF(target_vector)
|
339
|
+
#else /* !DOXYGEN */
|
340
|
+
# define ISR_BLOCK
|
341
|
+
# define ISR_NOBLOCK __attribute__((interrupt))
|
342
|
+
# define ISR_NAKED __attribute__((naked))
|
343
|
+
# define ISR_ALIASOF(v) __attribute__((alias(__STRINGIFY(v))))
|
344
|
+
#endif /* DOXYGEN */
|
345
|
+
|
346
|
+
/* \@} */
|
347
|
+
|
348
|
+
#endif
|