Skip to content

Commit d66d36d

Browse files
authored
Merge pull request #413 from sparkfun/release-candidate
Release 1.2.2
2 parents c6c2885 + 015ecff commit d66d36d

File tree

54 files changed

+1038
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1038
-244
lines changed

.github/workflows/generate-variants.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
{"name": "artemis-thing-plus-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_THING_PLUS", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_THING_PLUS", "loc": "variants/SFE_ARTEMIS_THING_PLUS"}}},
3131
{"name": "edge-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_EDGE", "tool": "GCC_ARM"}, "user": {"variant": {"name": "EDGE", "loc": "variants/SFE_EDGE"}}},
3232
{"name": "edge2-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_EDGE2", "tool": "GCC_ARM"}, "user": {"variant": {"name": "EDGE2", "loc": "variants/SFE_EDGE2"}}},
33-
{"name": "artemis-mm-pb-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_MM_PB", "tool": "GCC_ARM"}, "user": {"variant": {"name": "SFE_ARTEMIS_MM_PB", "loc": "variants/SFE_ARTEMIS_MM_PB"}}}
33+
{"name": "artemis-mm-pb-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_MM_PB", "tool": "GCC_ARM"}, "user": {"variant": {"name": "SFE_ARTEMIS_MM_PB", "loc": "variants/SFE_ARTEMIS_MM_PB"}}},
34+
{"name": "artemis-module", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_MODULE", "tool": "GCC_ARM"}, "user": {"variant": {"name": "SFE_ARTEMIS_MODULE", "loc": "variants/SFE_ARTEMIS_MODULE"}}}
3435
]
3536
mbed: |
3637
{"url": "https://github.com/sparkfun/mbed-os-ambiq-apollo3", "branch": "ambiq-apollo3-arduino"}

libraries/Apollo3/examples/DigitalWrite/DigitalWrite.ino

-74
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* Author: Nathan Seidle
2+
Created: October 16th, 2019
3+
License: MIT. See SparkFun Arduino Apollo3 Project for more information
4+
5+
This example demonstrates how to display the revision of the Apollo3.
6+
See the Ambiq website for errata on each revision: https://ambiqmicro.com/mcu/
7+
*/
8+
void setup()
9+
{
10+
Serial.begin(115200);
11+
delay(10); //Wait for any bootloader UART interactions to complete
12+
Serial.println();
13+
Serial.print("Apollo3 IC revision code: ");
14+
15+
if (APOLLO3_A0)
16+
{
17+
Serial.print("A0");
18+
}
19+
else if (APOLLO3_A1)
20+
{
21+
Serial.print("A1");
22+
}
23+
else if (APOLLO3_B0)
24+
{
25+
Serial.print("B0");
26+
}
27+
else if (APOLLO3_GE_B0)
28+
{
29+
Serial.print("Unknown revision but it's greater than B0");
30+
}
31+
else
32+
{
33+
Serial.print("Unknown revision");
34+
}
35+
Serial.println();
36+
Serial.println("All done");
37+
}
38+
39+
void loop()
40+
{
41+
//Do nothing
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
BLEAdvertise
3+
4+
This example creates a BLE peripheral which advertises itself as Artemis.
5+
Central devices may connect with it, but there are no services or
6+
characteristics to interact with.
7+
8+
Based on a stripped down version of the LED example from the ArduinoBLE examples
9+
*/
10+
11+
#include <ArduinoBLE.h> //http://librarymanager/All#ArduinoBLE_IoT
12+
13+
void setup() {
14+
Serial.begin(115200);
15+
while (!Serial);
16+
17+
// begin initialization
18+
if (!BLE.begin()) {
19+
Serial.println("Starting BLE failed!");
20+
while (1);
21+
}
22+
23+
// set advertised local name and service UUID:
24+
BLE.setLocalName("Artemis");
25+
26+
// start advertising
27+
BLE.advertise();
28+
29+
Serial.println("BLE advertising as 'Artemis'");
30+
}
31+
32+
void loop() {
33+
// listen for BLE peripherals to connect:
34+
BLEDevice central = BLE.central();
35+
36+
// if a central is connected to peripheral:
37+
if (central) {
38+
Serial.print("Connected to central: ");
39+
// print the central's MAC address:
40+
Serial.println(central.address());
41+
42+
// while the central is still connected to peripheral...
43+
while (central.connected()) {
44+
//Nothing to do here
45+
}
46+
47+
// when the central disconnects, print it out:
48+
Serial.print(F("Disconnected from central: "));
49+
Serial.println(central.address());
50+
}
51+
}

libraries/Apollo3/examples/I2C/I2C.ino libraries/Apollo3/examples/Example5_Wire_I2C/Example5_Wire_I2C.ino

+15-44
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- declaring your own MbedI2C object using pins that correspond to the correct IOM
2020
2121
Once you have an MbedI2C object to work with you can use all the standard
22-
Arduino SPI API methods on it
22+
Arduino Wire API methods on it
2323
https://www.arduino.cc/en/reference/wire
2424
2525
This example will use threads to organize I2C operations based on board
@@ -33,56 +33,21 @@
3333
GND <--> sensor GND
3434
3535
*/
36-
36+
3737
#include "Wire.h"
3838

3939
void testPortI2C(TwoWire &i2c);
4040

41-
// This thread will use the pre-defined SPI object if it exists
42-
#if VARIANT_WIRE_INTFCS > 0
43-
rtos::Thread wire_thread;
44-
void wire_thread_fn( void ){
45-
Wire.begin();
46-
while(1){
47-
testPortI2C(Wire);
48-
delay(1000);
49-
}
50-
}
51-
#endif
52-
53-
// This thread will use the pre-defined SPI1 object if it exists
54-
#if VARIANT_WIRE_INTFCS > 1
55-
rtos::Thread wire1_thread;
56-
void wire1_thread_fn( void ){
57-
delay(100);
58-
Wire1.begin();
59-
while(1){
60-
testPortI2C(Wire1);
61-
delay(1000);
62-
}
63-
}
64-
#endif
65-
6641
// This thread will create its own MbedI2C object using IOM pins
6742
// Define your own pins below to try it
6843
//#define mySDA D25
6944
//#define mySCL D27
7045
#if (defined mySDA) && (defined mySCL)
7146
TwoWire myWire(mySDA, mySCL);
72-
rtos::Thread mywire_thread;
73-
void mywire_thread_fn( void ){
74-
delay(200);
75-
myWire.begin();
76-
while(1){
77-
testPortI2C(myWire);
78-
delay(1000);
79-
}
80-
}
8147
#endif
8248

8349
void testPortI2C(TwoWire &i2c){
8450
Serial.printf("Scanning... (port: 0x%08X), time (ms): %d\n", (uint32_t)&i2c, millis());
85-
8651
uint8_t detected = 0;
8752
for(uint8_t addr = 1; addr < 127; addr++ ){
8853
// use endTransmission to determine if a device is present at address
@@ -94,11 +59,9 @@ void testPortI2C(TwoWire &i2c){
9459
detected++;
9560
}
9661
}
97-
9862
if(!detected){
9963
Serial.printf("\tNo device detected!\n");
10064
}
101-
10265
Serial.println();
10366
}
10467

@@ -109,19 +72,27 @@ void setup() {
10972
pinMode(LED_BUILTIN, OUTPUT);
11073

11174
#if VARIANT_WIRE_INTFCS > 0
112-
wire_thread.start(wire_thread_fn);
75+
Wire.begin();
11376
#endif
114-
11577
#if VARIANT_WIRE_INTFCS > 1
116-
wire1_thread.start(wire1_thread_fn);
78+
Wire1.begin();
11779
#endif
118-
11980
#if (defined mySDA) && (defined mySCL)
120-
mywire_thread.start(mywire_thread_fn);
81+
myWire.begin();
12182
#endif
12283
}
12384

12485
void loop() {
86+
#if VARIANT_WIRE_INTFCS > 0
87+
testPortI2C(Wire);
88+
#endif
89+
#if VARIANT_WIRE_INTFCS > 1
90+
testPortI2C(Wire1);
91+
#endif
92+
#if (defined mySDA) && (defined mySCL)
93+
testPortI2C(myWire);
94+
#endif
95+
12596
digitalWrite(LED_BUILTIN, LOW);
12697
delay(1000);
12798
digitalWrite(LED_BUILTIN, HIGH);

libraries/Apollo3/examples/SPI/SPI.ino libraries/Apollo3/examples/Example6_SPI/Example6_SPI.ino

+14-33
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,12 @@
5151
//#define myCLK D27
5252
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
5353
MbedSPI mySPI(mySDI, mySDO, myCLK); // declare the custom MbedSPI object mySPI
54+
extern "C" SPIName spi_get_peripheral_name(PinName mosi, PinName miso, PinName sclk); // this mbed internal function determines the IOM module number for a set of pins
5455
#endif
5556

5657
// define a macro to aid testing
5758
#define TEST_SPI_PORT(P) SERIAL_PORT.printf("testing %s\n\ttime (ms): %d\n\tbyte transer: %s\n\tbuffer transfer: %s\n\n", #P, millis(), ((test_byte_transfer(P) == 0) ? "pass" : "fail"), ((test_buffer_transfer(P) == 0) ? "pass" : "fail"))
5859

59-
// this thread will test the pre-defined SPI object if it exists
60-
rtos::Thread spi_thread;
61-
void spi_thread_fn( void ){
62-
#if VARIANT_SPI_INTFCS > 0
63-
delay(100);
64-
SPI.begin();
65-
while(1){
66-
TEST_SPI_PORT(SPI);
67-
delay(500);
68-
}
69-
#endif
70-
}
71-
72-
73-
// this thread tests the custom mySPI object
74-
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
75-
extern "C" SPIName spi_get_peripheral_name(PinName mosi, PinName miso, PinName sclk); // this mbed internal function determines the IOM module number for a set of pins
76-
rtos::Thread myspi_thread;
77-
void myspi_thread_fn( void ){
78-
delay(300);
79-
SERIAL_PORT.printf("starting mySPI on IOM %d\n", spi_get_peripheral_name(mySDO, mySDI, myCLK));
80-
mySPI.begin();
81-
while(1){
82-
TEST_SPI_PORT(mySPI);
83-
delay(500);
84-
}
85-
}
86-
#endif
87-
8860
int test_byte_transfer( SPIClass &spi ){
8961
uint8_t tx = random(1, 256);
9062
uint8_t rx = 0x00;
@@ -128,13 +100,22 @@ void setup() {
128100
pinMode(CS_PIN, OUTPUT);
129101
digitalWrite(CS_PIN, HIGH);
130102

131-
spi_thread.start(spi_thread_fn);
132-
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
133-
myspi_thread.start(myspi_thread_fn);
134-
#endif
103+
SPI.begin();
104+
105+
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
106+
SERIAL_PORT.printf("starting mySPI on IOM %d\n", spi_get_peripheral_name(mySDO, mySDI, myCLK));
107+
mySPI.begin();
108+
#endif
135109
}
136110

137111
void loop() {
112+
Serial.println("test");
113+
TEST_SPI_PORT(SPI);
114+
115+
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
116+
TEST_SPI_PORT(mySPI);
117+
#endif
118+
138119
digitalWrite(LED_BUILTIN, HIGH);
139120
delay(500);
140121
digitalWrite(LED_BUILTIN, LOW);

0 commit comments

Comments
 (0)