Skip to content

Commit 4dcbf6a

Browse files
author
Nathan Seidle
committed
Exposing Serial on Artemis variant
1 parent 9384386 commit 4dcbf6a

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

variants/SparkFun_Artemis/config/variant.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SOFTWARE.
2222

2323
#include "variant.h"
2424

25-
// This is the actual pinmap.
25+
// This is the actual pinmap.
2626
// For a variant pin X the corresponding Apollo3 pad Y is stored in ap3_variant_pinmap[X]
2727
// X [0, (AP3_VARIANT_NUM_PINS - 1)]
2828
// Y [0, 49]
@@ -86,12 +86,9 @@ const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS] = {
8686

8787
// Uart Definitions
8888
//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-
89+
//We default Serial to 22/23 but can be moved to any TX0/RX0 pin
90+
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)
91+
// 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)
9592

9693
// Pin aliasing using the const uint8_t approach
9794
//
@@ -102,7 +99,6 @@ const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS] = {
10299
// const uint8_t A4 = 20;
103100
// const uint8_t A5 = 21;
104101

105-
106102
// Indirect pinmap example
107103
//
108104
// const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS] = {

variants/SparkFun_Artemis/config/variant.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,21 @@ explained so that this file can serve as a starting point for creating new varia
3232
3333
*/
3434

35-
3635
#ifndef _AP3_VARIANT_H_
3736
#define _AP3_VARIANT_H_
3837

3938
#include "Arduino.h"
4039

41-
// In the Apollo3 Arduino core *pins* refer to the connections that can be accessed
40+
// In the Apollo3 Arduino core *pins* refer to the connections that can be accessed
4241
// 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-
//
42+
// utilize directly or it may be a connection to an onboard sensor.
43+
//
4544
// *pads* on the other hand refer directly to the pad numbers of the Apollo3 microcontroller
4645
//
4746
// When developing a variant you might connect *pin* x of your board to *pad* y on the
4847
// Apollo3. When a user asks to write to *pin* x the core will use a map to determine which
49-
// *pad* to control.
50-
//
48+
// *pad* to control.
49+
//
5150
// AP3_VARIANT_NUM_PINS determines the size of this map and its value must be N+1 where N
5251
// is the largest _pin_id_ of your variant. Let's try an example:
5352
//
@@ -67,25 +66,25 @@ extern const ap3_gpio_pad_t ap3_variant_pinmap[AP3_VARIANT_NUM_PINS];
6766

6867
// Uart declarations
6968
// - "HardwareSerial" is the class that is built into Arduino to allow "Serial.print()"
70-
// and related functions to work.
69+
// and related functions to work.
7170
// - The "Uart" class inherits from HardwareSerial and contains Apollo3-specific code
7271
// - Declaring your Uart objects here makes them available in any Arduino code and you
7372
// can give them extra descriptive names
74-
// - The maximum number of Uarts is 2 (instances 0 and 1)
73+
// - The maximum number of Uarts is 2 (instances 0 and 1)
7574
//
7675
// In this case the declarations are commented out because we don't know which pins of
7776
// the Artemis module you would like to use
7877
class Uart; // Forward declaration of Uart class
79-
// extern Uart Serial;
78+
extern Uart Serial;
8079
// extern Uart Serial1;
8180

8281
// A note about IOMaster peripherals:
8382
// - IOMaster peripherals are used to provide either SPI or I2C communications. The pads
8483
// of the Apollo3 that a given IOMaster [0,5] use are not configurable
8584

8685
// Wire defines
87-
// - Wire is the I2C class for Arduino.
88-
// - Wire is handled differently than HardwareSerial/Uart because Wire is a library that
86+
// - Wire is the I2C class for Arduino.
87+
// - Wire is handled differently than HardwareSerial/Uart because Wire is a library that
8988
// you have to include manually (saves space if you won't be using I2C)
9089
// - In this case we rely on communication between the variant.h file and the Wire library
9190
// through the use of #define statements
@@ -107,7 +106,7 @@ class Uart; // Forward declaration of Uart class
107106
#define AP3_Wire5_IOM 5 // Secify that Wire5 uses IOMaster instance 5
108107
// This is also a convenient location to provide some aliased names for certain Wire objects
109108
// For example: (examples commented out because they aren't real)
110-
//
109+
//
111110
// #define WireQwiic Wire // Giving Wire an alias of "WireQwiic" to indicat that it is the I2C controller for the Qwiic bus
112111
// #define WireAccel Wire1 // Useful if the variant has an onboard accelerometer connected to the Wire1 bus
113112

@@ -121,19 +120,18 @@ class Uart; // Forward declaration of Uart class
121120
// you need to specify two settings:
122121
// - - AP3_SPI_IOM - which IOMaster peripher the SPI object will use
123122
// - - 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-
123+
#define AP3_SPI_IOM 0
124+
#define AP3_SPI_DUP ap3_spi_full_duplex
125+
#define AP3_SPI1_IOM 1
126+
#define AP3_SPI1_DUP ap3_spi_full_duplex
127+
#define AP3_SPI2_IOM 2
128+
#define AP3_SPI2_DUP ap3_spi_full_duplex
129+
#define AP3_SPI3_IOM 3
130+
#define AP3_SPI3_DUP ap3_spi_full_duplex
131+
#define AP3_SPI4_IOM 4
132+
#define AP3_SPI4_DUP ap3_spi_full_duplex
133+
#define AP3_SPI5_IOM 5
134+
#define AP3_SPI5_DUP ap3_spi_full_duplex
137135

138136
// Additional Pin Aliasing
139137
// - It is required that every pin is accessible by a number between 0 and (AP3_VARIANT_NUM_PINS - 1)

0 commit comments

Comments
 (0)