Skip to content

Commit 10787a5

Browse files
authored
Merge pull request #371 from sparkfun/release-candidate
v2.0.6
2 parents fbb2eac + 8230ec1 commit 10787a5

Some content is hidden

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

99 files changed

+364
-74
lines changed

.github/workflows/generate-variants.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ jobs:
2222
with:
2323
jobs: |
2424
[
25-
{"name": "lora-thing-plus-explorable-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "LORA_THING_PLUS_EXPLORABLE", "tool": "GCC_ARM"}, "user": {"variant": {"name": "LoRa_THING_PLUS_expLoRaBLE", "loc": "variants/LoRa_THING_PLUS_expLoRaBLE"}}},
26-
{"name": "artemis-redboard-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_ARTEMIS", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS", "loc": "variants/SFE_ARTEMIS"}}},
27-
{"name": "artemis-redboard-atp-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_ARTEMIS_ATP", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_ATP", "loc": "variants/SFE_ARTEMIS_ATP"}}},
28-
{"name": "artemis-dev-kit-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_ARTEMIS_DK", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_DEV_KIT", "loc": "variants/SFE_ARTEMIS_DK"}}},
29-
{"name": "artemis-redboard-nano-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_ARTEMIS_NANO", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_NANO", "loc": "variants/SFE_ARTEMIS_NANO"}}},
30-
{"name": "artemis-thing-plus-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_ARTEMIS_THING_PLUS", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_THING_PLUS", "loc": "variants/SFE_ARTEMIS_THING_PLUS"}}},
31-
{"name": "edge-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_EDGE", "tool": "GCC_ARM"}, "user": {"variant": {"name": "EDGE", "loc": "variants/SFE_EDGE"}}},
32-
{"name": "edge2-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_EDGE2", "tool": "GCC_ARM"}, "user": {"variant": {"name": "EDGE2", "loc": "variants/SFE_EDGE2"}}}
25+
{"name": "lora-thing-plus-explorable-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "LORA_THING_PLUS_EXPLORABLE", "tool": "GCC_ARM"}, "user": {"variant": {"name": "LoRa_THING_PLUS_expLoRaBLE", "loc": "variants/LoRa_THING_PLUS_expLoRaBLE"}}},
26+
{"name": "artemis-redboard-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS", "loc": "variants/SFE_ARTEMIS"}}},
27+
{"name": "artemis-redboard-atp-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_ATP", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_ATP", "loc": "variants/SFE_ARTEMIS_ATP"}}},
28+
{"name": "artemis-dev-kit-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_DK", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_DEV_KIT", "loc": "variants/SFE_ARTEMIS_DK"}}},
29+
{"name": "artemis-redboard-nano-lib", "config": {"base": "compile --library --source=mbed-os -D ARDUINO_BLE_FIX", "tgt": "SFE_ARTEMIS_NANO", "tool": "GCC_ARM"}, "user": {"variant": {"name": "ARTEMIS_NANO", "loc": "variants/SFE_ARTEMIS_NANO"}}},
30+
{"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"}}},
31+
{"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"}}},
32+
{"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"}}}
3334
]
3435
mbed: |
3536
{"url": "https://github.com/sparkfun/mbed-os-ambiq-apollo3", "branch": "ambiq-apollo3-arduino"}

cores/arduino/sdk/core-implement/CommonAnalog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ float getTempDegF( void ) {
8080
}
8181

8282
float getVCCV( void ){
83-
return ((float)analogReadVCCDiv3() * 6.0) / 16384.0;
83+
return ((float)analogReadVCCDiv3() * 2.0) / 16384.0;
8484
}
8585

8686
int indexAnalogRead(pin_size_t index){
8787
// todo: replace with mbed "AnalogIn" functionality
88-
pin_size_t pinNumber = pinNumberByIndex(index);
88+
pin_size_t pinNumber = pinNameByIndex(index);
8989
if(pinNumber == (pin_size_t)NC){ return 0; }
9090
ap3_adc_channel_config_t* config = NULL;
9191
for(size_t idx = 0; idx < (sizeof(ap3_adc_channel_configs)/sizeof(ap3_adc_channel_config_t)); idx++){

libraries/Apollo3/examples/I2C/I2C.ino

+13-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
#include "Wire.h"
3838

39+
void testPortI2C(TwoWire &i2c);
40+
3941
// This thread will use the pre-defined SPI object if it exists
4042
#if VARIANT_WIRE_INTFCS > 0
4143
rtos::Thread wire_thread;
@@ -55,16 +57,18 @@ void wire1_thread_fn( void ){
5557
delay(100);
5658
Wire1.begin();
5759
while(1){
58-
testPortWire(Wire1);
60+
testPortI2C(Wire1);
5961
delay(1000);
6062
}
6163
}
6264
#endif
6365

6466
// This thread will create its own MbedI2C object using IOM pins
65-
#define mySDA D25
66-
#define mySCL D27
67-
MbedI2C myWire(mySDA, mySCL);
67+
// Define your own pins below to try it
68+
//#define mySDA D25
69+
//#define mySCL D27
70+
#if (defined mySDA) && (defined mySCL)
71+
TwoWire myWire(mySDA, mySCL);
6872
rtos::Thread mywire_thread;
6973
void mywire_thread_fn( void ){
7074
delay(200);
@@ -74,8 +78,9 @@ void mywire_thread_fn( void ){
7478
delay(1000);
7579
}
7680
}
81+
#endif
7782

78-
void testPortI2C(MbedI2C &i2c){
83+
void testPortI2C(TwoWire &i2c){
7984
Serial.printf("Scanning... (port: 0x%08X), time (ms): %d\n", (uint32_t)&i2c, millis());
8085

8186
uint8_t detected = 0;
@@ -111,12 +116,14 @@ void setup() {
111116
wire1_thread.start(wire1_thread_fn);
112117
#endif
113118

119+
#if (defined mySDA) && (defined mySCL)
114120
mywire_thread.start(mywire_thread_fn);
121+
#endif
115122
}
116123

117124
void loop() {
118125
digitalWrite(LED_BUILTIN, LOW);
119126
delay(1000);
120127
digitalWrite(LED_BUILTIN, HIGH);
121128
delay(1000);
122-
}
129+
}

libraries/Apollo3/examples/SPI/SPI.ino

+10-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@
4646
// define pins to create a custom SPI port
4747
// using mbed PinNames or Arduino pin numbers
4848
// (must be all pins from one IOM module)
49-
#define mySDI D25
50-
#define mySDO D28
51-
#define myCLK D27
52-
49+
//#define mySDI D25
50+
//#define mySDO D28
51+
//#define myCLK D27
52+
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
5353
MbedSPI mySPI(mySDI, mySDO, myCLK); // declare the custom MbedSPI object mySPI
54+
#endif
5455

5556
// define a macro to aid testing
5657
#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"))
@@ -68,7 +69,9 @@ void spi_thread_fn( void ){
6869
#endif
6970
}
7071

72+
7173
// this thread tests the custom mySPI object
74+
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
7275
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
7376
rtos::Thread myspi_thread;
7477
void myspi_thread_fn( void ){
@@ -80,6 +83,7 @@ void myspi_thread_fn( void ){
8083
delay(500);
8184
}
8285
}
86+
#endif
8387

8488
int test_byte_transfer( SPIClass &spi ){
8589
uint8_t tx = random(1, 256);
@@ -125,7 +129,9 @@ void setup() {
125129
digitalWrite(CS_PIN, HIGH);
126130

127131
spi_thread.start(spi_thread_fn);
132+
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
128133
myspi_thread.start(myspi_thread_fn);
134+
#endif
129135
}
130136

131137
void loop() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
/*
2+
Reading and writing test of the EEPROM functions on the Artemis
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: June 24th, 2019
6+
This example code is in the public domain.
7+
8+
SparkFun labored with love to create this code. Feel like supporting open source hardware?
9+
Buy a board from SparkFun! https://www.sparkfun.com/products/15376
10+
11+
Page erase takes 15ms
12+
Write byte takes 30ms - This is much longer than Arduino that takes 3.3ms
13+
Float write across two words takes 30ms
14+
Update (no write) takes 1ms
15+
*/
16+
17+
#include <EEPROM.h>
18+
19+
// Give a default if the variant does not define one.
20+
#ifndef A0
21+
#define A0 0
22+
#endif
23+
24+
void setup()
25+
{
26+
Serial.begin(115200);
27+
Serial.println("EEPROM Examples");
28+
29+
randomSeed(analogRead(A0));
30+
31+
EEPROM.init();
32+
33+
// You may choose to enable more or less EEPROM -
34+
// Default length is 1024 bytes (if setLength is not called)
35+
EEPROM.setLength(1024 * 1); // this would make the length 1080 bytes. Max is 4096.
36+
// Note: larger sizes will increase RAM usage and execution time
37+
38+
long startTime;
39+
long endTime;
40+
int randomLocation;
41+
42+
//Test erase time
43+
startTime = millis();
44+
EEPROM.erase();
45+
endTime = millis();
46+
Serial.printf("Time to erase all EEPROM: %dms\n", endTime - startTime);
47+
48+
//Byte sequential test
49+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
50+
Serial.println();
51+
Serial.println("8 bit tests");
52+
uint8_t myValue1 = 200;
53+
byte myValue2 = 23;
54+
randomLocation = random(0, EEPROM.length() - sizeof(myValue1));
55+
56+
startTime = millis();
57+
EEPROM.write(randomLocation, myValue1); //(location, data)
58+
endTime = millis();
59+
EEPROM.put(randomLocation + sizeof(myValue1), myValue2);
60+
61+
Serial.printf("Write byte time: %dms\n", endTime - startTime);
62+
63+
startTime = millis();
64+
EEPROM.write(randomLocation, myValue1); //(location, data)
65+
endTime = millis();
66+
67+
Serial.printf("Write identical byte to same location: %dms\n", endTime - startTime);
68+
69+
byte response1 = EEPROM.read(randomLocation);
70+
byte response2 = EEPROM.read(randomLocation + sizeof(myValue1));
71+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue1, response1);
72+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue1), myValue2, response2);
73+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
74+
75+
Serial.println();
76+
Serial.println("16 bit tests");
77+
78+
//int16_t and uint16_t sequential test
79+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
80+
uint16_t myValue3 = 3411;
81+
int16_t myValue4 = -366;
82+
randomLocation = random(0, EEPROM.length() - sizeof(myValue3));
83+
84+
EEPROM.put(randomLocation, myValue3);
85+
EEPROM.put(randomLocation + sizeof(myValue3), myValue4);
86+
87+
uint16_t response3;
88+
int16_t response4;
89+
EEPROM.get(randomLocation, response3);
90+
EEPROM.get(randomLocation + sizeof(myValue3), response4);
91+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue3, response3);
92+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue3), myValue4, response4);
93+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
94+
95+
Serial.println();
96+
Serial.println("32 bit tests");
97+
98+
//int and unsigned int (32) sequential test
99+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
100+
Serial.printf("Size of int: %d\n", sizeof(int));
101+
int myValue5 = -245000;
102+
unsigned int myValue6 = 400123;
103+
randomLocation = random(0, EEPROM.length() - sizeof(myValue5));
104+
105+
EEPROM.put(randomLocation, myValue5);
106+
EEPROM.put(randomLocation + sizeof(myValue5), myValue6);
107+
108+
int response5;
109+
unsigned int response6;
110+
EEPROM.get(randomLocation, response5);
111+
EEPROM.get(randomLocation + sizeof(myValue5), response6);
112+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue5, response5);
113+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue5), myValue6, response6);
114+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
115+
116+
//int32_t and uint32_t sequential test
117+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
118+
int32_t myValue7 = -341002;
119+
uint32_t myValue8 = 241544;
120+
randomLocation = random(0, EEPROM.length() - sizeof(myValue7));
121+
122+
EEPROM.put(randomLocation, myValue7);
123+
EEPROM.put(randomLocation + sizeof(myValue7), myValue8);
124+
125+
int32_t response7;
126+
uint32_t response8;
127+
EEPROM.get(randomLocation, response7);
128+
EEPROM.get(randomLocation + sizeof(myValue7), response8);
129+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue7, response7);
130+
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue7), myValue8, response8);
131+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
132+
133+
//float (32) sequential test
134+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
135+
Serial.printf("Size of float: %d\n", sizeof(float));
136+
float myValue9 = -7.35;
137+
float myValue10 = 5.22;
138+
randomLocation = random(0, EEPROM.length() - sizeof(myValue9));
139+
140+
EEPROM.put(randomLocation, myValue9);
141+
EEPROM.put(randomLocation + sizeof(myValue9), myValue10);
142+
143+
float response9;
144+
float response10;
145+
EEPROM.get(randomLocation, response9);
146+
EEPROM.get(randomLocation + sizeof(myValue9), response10);
147+
Serial.printf("Location %d should be ", randomLocation);
148+
Serial.print(myValue9);
149+
Serial.print(": ");
150+
Serial.print(response9);
151+
Serial.println();
152+
Serial.printf("Location %d should be ", randomLocation + sizeof(myValue9));
153+
Serial.print(myValue10);
154+
Serial.print(": ");
155+
Serial.print(response10);
156+
Serial.println();
157+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
158+
159+
Serial.println();
160+
Serial.println("64 bit tests");
161+
162+
//double (64) sequential test
163+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
164+
Serial.printf("Size of double: %d\n", sizeof(double));
165+
double myValue11 = -290.3485723409857;
166+
double myValue12 = 384.95734987;
167+
double myValue13 = 917.14159;
168+
double myValue14 = 254.8877;
169+
randomLocation = random(0, EEPROM.length() - sizeof(myValue11));
170+
171+
startTime = millis();
172+
EEPROM.put(randomLocation, myValue11);
173+
endTime = millis();
174+
Serial.printf("Time to record 64-bits: %dms\n", endTime - startTime);
175+
176+
EEPROM.put(randomLocation + sizeof(myValue11), myValue12);
177+
EEPROM.put(EEPROM.length() - sizeof(myValue13), myValue13); //Test end of EEPROM space
178+
179+
double response11;
180+
double response12;
181+
double response13;
182+
EEPROM.get(randomLocation, response11);
183+
EEPROM.get(randomLocation + sizeof(myValue11), response12);
184+
EEPROM.get(EEPROM.length() - sizeof(myValue13), response13);
185+
186+
Serial.printf("Location %d should be ", randomLocation);
187+
Serial.print(myValue11, 13);
188+
Serial.print(": ");
189+
Serial.print(response11, 13);
190+
Serial.println();
191+
Serial.printf("Location %d should be ", randomLocation + sizeof(myValue11));
192+
Serial.print(myValue12, 8);
193+
Serial.print(": ");
194+
Serial.print(response12, 8);
195+
Serial.println();
196+
Serial.printf("Edge of EEPROM %d should be ", EEPROM.length() - sizeof(myValue13));
197+
Serial.print(myValue13, 5);
198+
Serial.print(": ");
199+
Serial.print(response13, 5);
200+
Serial.println();
201+
202+
double response14;
203+
EEPROM.put(EEPROM.length() - sizeof(myValue14), myValue14); //Test the re-write of a spot
204+
EEPROM.get(EEPROM.length() - sizeof(myValue14), response14);
205+
Serial.printf("Rewrite of %d should be ", EEPROM.length() - sizeof(myValue14));
206+
Serial.print(myValue14, 4);
207+
Serial.print(": ");
208+
Serial.print(response14, 4);
209+
Serial.println();
210+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
211+
212+
Serial.println();
213+
Serial.println("String test");
214+
215+
//String write test
216+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
217+
char myString[19] = "How are you today?";
218+
randomLocation = random(0, EEPROM.length() - sizeof(myString));
219+
EEPROM.put(randomLocation, myString);
220+
221+
char readMy[19];
222+
EEPROM.get(randomLocation, readMy);
223+
Serial.printf("Location %d string should read 'How are you today?': ", randomLocation);
224+
Serial.println(readMy);
225+
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
226+
227+
}
228+
229+
void loop()
230+
{
231+
}

0 commit comments

Comments
 (0)