Skip to content

Commit 206e1fa

Browse files
committed
Fix Artemis Module variant
1 parent 626129b commit 206e1fa

File tree

3 files changed

+318
-1
lines changed

3 files changed

+318
-1
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*
2+
Copyright (c) 2019 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
23+
#include "variant.h"
24+
25+
// This is the actual pinmap.
26+
// For a variant pin X the corresponding Apollo3 pad Y is stored in ap3_variant_pinmap[X]
27+
// X [0, (AP3_VARIANT_NUM_PINS - 1)]
28+
// Y [0, 49]
29+
// If you have an unused *pin* number use AP3_GPIO_PAD_UNUSED as the *pad* number
30+
//
31+
// Because the Artemis Module variant is meant to replicate the Apollo3 microcontroller
32+
// this pinmap will be a direct mapping. An example of an indirect mapping is provided at the bottom of this file (commented out)
33+
const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS] = {
34+
//On the Artemis Mega, what you see is what you get pin-to-pad on the Apollo3
35+
0,
36+
1,
37+
2,
38+
3,
39+
4,
40+
5,
41+
6,
42+
7,
43+
8,
44+
9,
45+
10,
46+
11,
47+
12,
48+
13,
49+
14,
50+
15,
51+
16,
52+
17,
53+
18,
54+
19,
55+
20,
56+
21,
57+
22,
58+
23,
59+
24,
60+
25,
61+
26,
62+
27,
63+
28,
64+
29,
65+
AP3_GPIO_PAD_UNUSED, //The one pad not broken out of the Apollo3 on the Artemis
66+
31,
67+
32,
68+
33,
69+
34,
70+
35,
71+
36,
72+
37,
73+
38,
74+
39,
75+
40,
76+
41,
77+
42,
78+
43,
79+
44,
80+
45,
81+
46,
82+
47,
83+
48,
84+
49,
85+
};
86+
87+
// Uart Definitions
88+
//Serial(instance, RX, TX)
89+
//
90+
// Commented out because we don't know which pins should be used on the Artemis module
91+
//
92+
// Uart Serial(0, 23, 22); // Declares a Uart object called Serial using instance 0 of Apollo3 UART peripherals with RX on variant pin 23 and TX on pin 24 (note, you specify *pins* not Apollo3 pads. This uses the variant's pin map to determine the Apollo3 pad)
93+
// Uart Serial1(1, 0, 1); // Declares a Uart object called Serial1 using instance 1 of Apollo3 UART peripherals with RX on pin 0 and TX on pin 1 (note, you specify *pins* not Apollo3 pads. This uses the variant's pin map to determine the Apollo3 pad)
94+
95+
96+
// Pin aliasing using the const uint8_t approach
97+
//
98+
// const uint8_t A0 = 16; // means that "A0" is equivalent to saying *pin* 16 (which culd map to any Apollo3 *pad*)
99+
// const uint8_t A1 = 17;
100+
// const uint8_t A2 = 18;
101+
// const uint8_t A3 = 19;
102+
// const uint8_t A4 = 20;
103+
// const uint8_t A5 = 21;
104+
105+
106+
// Indirect pinmap example
107+
//
108+
// const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS] = {
109+
// // AP3_GPIO_PAD_UNUSED // use when the user should not try to use a given *pin* number
110+
111+
// //~ = PWM, A = ADC
112+
// //Apollo Pad, //Silkscreen indicator - Pin functions
113+
// 25, //0 - ~RX1/SDA2/MISO2
114+
// 24, //1 - ~TX1/32kHz/SWO
115+
// 35, //2/A6 - ~A/TX1/I2SDAT/PDMCLK
116+
// 4, //3 - ~RX1/SLINT
117+
// 22, //4 - ~PDMCLK/SWO
118+
// 23, //5 - ~I2SWCLK/CMPOUT
119+
// 27, //6 - ~SCL2/SCK2
120+
// 28, //7 - ~MOSI2/I2SWCLK
121+
// 32, //8/A8 - ~A/SCCIO
122+
// 12, //9/A9 - ~A/PDMCLK/TX1
123+
// 13, //10/A10 - ~A/I2SBCLK/RX1
124+
// 7, //11 - ~MOSI0/CLKOUT
125+
// 6, //12 - ~MISO0/SDA0/I2SDAT
126+
// 5, //13 - ~LED/SCK0/SCL0
127+
// 40, //14 - SDA4/MISO4/RX1
128+
// 39, //15 - ~SCL4/SCK4/TX1
129+
// 29, //16/A0 - ~A/PDMDATA
130+
// 11, //17/A1 - ~A/PDMDATA
131+
// 34, //18/A2 - A/CMPRF2/PDMDATA
132+
// 33, //19/A3 - ~A/SWO/32kHz
133+
// 16, //20/A4 - A/TRIG0/SCCRST
134+
// 31, //21/A5 - ~A/SCCCLK
135+
// 48, //22 - ~TX0/SCL5/SCK5
136+
// 49, //23 - ~RX0/SDA5/MISO5
137+
// AP3_GPIO_PAD_UNUSED, //24 - Demonstrates what to do if the user should not try to access a *pin* called 24
138+
// 9, //25 - Solder pad, SDA1/MISO1/RX1/SCCIO
139+
// 10, //26 - Solder pad, MOSI1/TX1/PDMCLK
140+
// 38, //27 - Solder pad, MOSI3/TX1
141+
// 42, //28 - Solder pad, ~SCL3/SCK3/TX1
142+
// 43, //29 - Solder pad, ~SDA3/MISO3/RX1
143+
// 36, //30 - Not exposed, PDMDATA of Mic
144+
// 37, //31 - Not exposed, PDMCLK of Mic
145+
// AP3_ADC_DIFF0_PAD, //32 - Not a real pad, ADC_DIFF0
146+
// AP3_ADC_DIFF1_PAD, //33 - Not a real pad, ADC_DIFF1
147+
// AP3_ADC_TEMP_PAD, //34 - Not a real pad, ADC_TEMP
148+
// AP3_ADC_DIV3_PAD, //35 - Not a real pad, ADC_DIV3
149+
// AP3_ADC_VSS_PAD, //36 - Not a real pad, ADC_VSS
150+
// };
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
Copyright (c) 2019 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
23+
/*
24+
25+
This is an example variant file for use with the SparkFun Apollo3 Arduino core.
26+
27+
This file is for the 'Artemis Module' variant. The Artemis module is intended to
28+
be used as an Apollo3 microcontroller that conveniently includes most necessary
29+
support circuitry. Due to that fact many of the standard features of a variant.h
30+
file are unecessary. Such features will be commented out but retained and
31+
explained so that this file can serve as a starting point for creating new variants
32+
33+
*/
34+
35+
36+
#ifndef _AP3_VARIANT_H_
37+
#define _AP3_VARIANT_H_
38+
39+
#include "Arduino.h"
40+
41+
// In the Apollo3 Arduino core *pins* refer to the connections that can be accessed
42+
// via Arduino code. This may be, for example, an exposed connection that the user could
43+
// utilize directly or it may be a connection to an onboard sensor.
44+
//
45+
// *pads* on the other hand refer directly to the pad numbers of the Apollo3 microcontroller
46+
//
47+
// When developing a variant you might connect *pin* x of your board to *pad* y on the
48+
// Apollo3. When a user asks to write to *pin* x the core will use a map to determine which
49+
// *pad* to control.
50+
//
51+
// AP3_VARIANT_NUM_PINS determines the size of this map and its value must be N+1 where N
52+
// is the largest _pin_id_ of your variant. Let's try an example:
53+
//
54+
// Variant has four *pins* to use in the Arduino core named: 0, 1, 2, and 3
55+
// - in this case AP3_VARIANT_NUM_PINS is 4 (N+1, N=3)
56+
// - this is good because there are no unused pin spaces in the map
57+
//
58+
// Variant has four *pins* to use in Arduino named: 7, 13, 15, 48
59+
// - in this case AP3_VARIANT_NUM_PINS is 49 (N+1, N=48)
60+
// - this is less ideal because there are 45 unused spaces (bytes) in the map
61+
#define AP3_VARIANT_NUM_PINS (50)
62+
63+
// Pin map declaration
64+
// The pinmap converts Arduino *pins* to Apollo3 *pads*
65+
// The *pin* is the index into the array and the *pad* is the value at that index
66+
extern const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS];
67+
68+
// Uart declarations
69+
// - "HardwareSerial" is the class that is built into Arduino to allow "Serial.print()"
70+
// and related functions to work.
71+
// - The "Uart" class inherits from HardwareSerial and contains Apollo3-specific code
72+
// - Declaring your Uart objects here makes them available in any Arduino code and you
73+
// can give them extra descriptive names
74+
// - The maximum number of Uarts is 2 (instances 0 and 1)
75+
//
76+
// In this case the declarations are commented out because we don't know which pins of
77+
// the Artemis module you would like to use
78+
class Uart; // Forward declaration of Uart class
79+
// extern Uart Serial;
80+
// extern Uart Serial1;
81+
82+
// A note about IOMaster peripherals:
83+
// - IOMaster peripherals are used to provide either SPI or I2C communications. The pads
84+
// of the Apollo3 that a given IOMaster [0,5] use are not configurable
85+
86+
// Wire defines
87+
// - Wire is the I2C class for Arduino.
88+
// - Wire is handled differently than HardwareSerial/Uart because Wire is a library that
89+
// you have to include manually (saves space if you won't be using I2C)
90+
// - In this case we rely on communication between the variant.h file and the Wire library
91+
// through the use of #define statements
92+
//
93+
// - Define the total number of TwoWire class objects that you will allow the user on the board.
94+
// - The maximum number is 6 because the Apollo3 incudes 6 IOMaster peripherals
95+
#define WIRE_INTERFACES_COUNT 6
96+
//
97+
// - Define settings for as many Wire objects as you defined above, the only required value AP3_Wire[X]_IOM
98+
// - Note: in this example each Wire object uses the same number IOMaster but that is not required.
99+
// Any "#define AP3_Wire[X]_IOM Y" statement is valid for Y [0,5] and X [1,5] (or no X for the first "Wire")
100+
// - Note: Wire objects will appear in order, so if WIRE_INTERFACES_COUNT = 3 then you must define the IOM #
101+
// for Wire, Wire1, and Wire2
102+
#define AP3_Wire_IOM 0 // Secify that Wire uses IOMaster instance 0
103+
#define AP3_Wire1_IOM 1 // Secify that Wire1 uses IOMaster instance 1
104+
#define AP3_Wire2_IOM 2 // Secify that Wire2 uses IOMaster instance 2
105+
#define AP3_Wire3_IOM 3 // Secify that Wire3 uses IOMaster instance 3
106+
#define AP3_Wire4_IOM 4 // Secify that Wire4 uses IOMaster instance 4
107+
#define AP3_Wire5_IOM 5 // Secify that Wire5 uses IOMaster instance 5
108+
// This is also a convenient location to provide some aliased names for certain Wire objects
109+
// For example: (examples commented out because they aren't real)
110+
//
111+
// #define WireQwiic Wire // Giving Wire an alias of "WireQwiic" to indicat that it is the I2C controller for the Qwiic bus
112+
// #define WireAccel Wire1 // Useful if the variant has an onboard accelerometer connected to the Wire1 bus
113+
114+
// SPI Defines
115+
// Like Wire SPI is an optional library so we have to rely on #define statements
116+
// - Define the total number of SPI class objects that you will allow the user on the board.
117+
// - The maximum number is 6 because the Apollo3 incudes 6 IOMaster peripherals
118+
#define SPI_INTERFACES_COUNT 6
119+
//
120+
// - For each defined SPI interface (SPI, SPI1, SPI2, SPI3, SPI4, SPI5) in order up to SPI_INTERFACES_COUNT
121+
// you need to specify two settings:
122+
// - - AP3_SPI_IOM - which IOMaster peripher the SPI object will use
123+
// - - AP3_SPI_DUP - which duplex mode the SPI object will use (full duplex is the most common, ap3_spi_tx_only and ap3_spi_rx_only are the other options )
124+
#define AP3_SPI_IOM 0
125+
#define AP3_SPI_DUP ap3_spi_full_duplex
126+
#define AP3_SPI1_IOM 1
127+
#define AP3_SPI1_DUP ap3_spi_full_duplex
128+
#define AP3_SPI2_IOM 2
129+
#define AP3_SPI2_DUP ap3_spi_full_duplex
130+
#define AP3_SPI3_IOM 3
131+
#define AP3_SPI3_DUP ap3_spi_full_duplex
132+
#define AP3_SPI4_IOM 4
133+
#define AP3_SPI4_DUP ap3_spi_full_duplex
134+
#define AP3_SPI5_IOM 5
135+
#define AP3_SPI5_DUP ap3_spi_full_duplex
136+
137+
138+
// Additional Pin Aliasing
139+
// - It is required that every pin is accessible by a number between 0 and (AP3_VARIANT_NUM_PINS - 1)
140+
// - You are optionally allowed to provide other ways to refer to those pin #s
141+
// - - One way is to use a #define. This is good because it takes no program space, but you should be
142+
// careful of name conflicts
143+
// - - Another way is to use a const uint8_t variable. This will allow the compiler to warn you about
144+
// name conflicts but it will use a byte of program space
145+
// - You should alias Arduino *pin* numbers, not Apollo3 *pad* numbers
146+
//
147+
// Here is an example of how the #define technique is used to match the available pins of an Arduino Uno
148+
//
149+
// // Mapping of analog pins to digital pins of variant
150+
// #define A0 16 // means that "A0" is equivalent to saying *pin* 16 (which culd map to any Apollo3 *pad*)
151+
// #define A1 17
152+
// #define A2 18
153+
// #define A3 19
154+
// #define A4 20
155+
// #define A5 21
156+
//
157+
// When using the const uint8_t method you'll need to use 'extern'
158+
// extern const uint8_t A0;
159+
// extern const uint8_t A1;
160+
// extern const uint8_t A2;
161+
// extern const uint8_t A3;
162+
// extern const uint8_t A4;
163+
// extern const uint8_t A5;
164+
165+
// Many Arduino cores provide a built-in LED for quick verification, like in the Blink sketch
166+
#define LED_BUILTIN 13
167+
168+
#endif // _AP3_VARIANT_H_

variants/SparkFun_Artemis/startup/startup_gcc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
#include <stdint.h>
4848
#include "am_mcu_apollo.h" // Defines AM_CMSIS_REGS
49-
#include "Arduino.h"
5049

5150
//*****************************************************************************
5251
//

0 commit comments

Comments
 (0)