Skip to content

v2.0.6 #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
577568f
Fix compile error "FlashIAPBlockDevice.h" not found
nseidle Feb 7, 2021
e185bda
Remove printf
nseidle Feb 7, 2021
1dc5e51
Fix memcpy index
nseidle Feb 7, 2021
21ccb0f
Write to EEPROM with any byte size/alignment
nseidle Feb 7, 2021
33fcc68
Fix example name typo
nseidle Feb 7, 2021
369b885
Change scratch to 8bit to avoid alignment corruption
nseidle Feb 7, 2021
d675e41
Remove driver link to avoid SPI conflict.
nseidle Feb 7, 2021
c34a7b9
Merge pull request #345 from sparkfun/master
Wenn0101 Feb 7, 2021
e6b797a
Update Wire.cpp
nseidle Feb 12, 2021
fad6222
Merge pull request #348 from sparkfun/reduceDefaultI2CClock
Wenn0101 Feb 22, 2021
5ad5acf
Merge pull request #344 from sparkfun/refixEEPROM
Wenn0101 Feb 22, 2021
56f654d
update uploader submodules
Wenn0101 Mar 2, 2021
15837c0
update submodules
Wenn0101 Mar 8, 2021
0399f35
update copy-paste error
Wenn0101 Mar 8, 2021
e754e7a
Remove ARDUINO macro from mbed flags, it is set elsewhere
Wenn0101 Mar 8, 2021
5cc4f1c
add comma
Wenn0101 Mar 8, 2021
16b25ce
add ARDUINO to asm blocklist
Wenn0101 Mar 8, 2021
d0236bb
Change macro name name to match mbed and remove nonsense trying to av…
Wenn0101 Mar 8, 2021
1bf2549
update platform.txt to include deprecated arduino API
Wenn0101 Mar 16, 2021
47abc87
update mbed bridge submodule
Wenn0101 Mar 16, 2021
15a14e8
replicate anologWrite fixes for analogRead
Wenn0101 Mar 16, 2021
a494e3f
add serial1 to micromod processor board
Wenn0101 Mar 16, 2021
91441de
update i2c and spi examples to only have built in interfaces by defau…
Wenn0101 Mar 16, 2021
962584f
change getVCCV math
Wenn0101 Mar 16, 2021
1fe1cac
update mbed bridge submodule
Wenn0101 Mar 16, 2021
d22b360
generated variants mbed resources
Feb 7, 2021
be323ec
generated variants mbed resources
Feb 22, 2021
05659cc
generated variants mbed resources
Feb 22, 2021
820205b
generated variants mbed resources
Mar 2, 2021
c2c8807
generated variants mbed resources
Mar 8, 2021
8719f00
generated variants mbed resources
Mar 8, 2021
8e57a1f
generated variants mbed resources
Mar 8, 2021
e531c02
generated variants mbed resources
Mar 8, 2021
63ade4b
generated variants mbed resources
Mar 8, 2021
c743d3d
generated variants mbed resources
Mar 8, 2021
ed99b28
generated variants mbed resources
Mar 16, 2021
16753b1
generated variants mbed resources
Mar 16, 2021
68b5c7a
generated variants mbed resources
Mar 16, 2021
57647ba
generated variants mbed resources
Mar 16, 2021
d98ca40
generated variants mbed resources
Mar 16, 2021
8230ec1
generated variants mbed resources
Mar 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/generate-variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ jobs:
with:
jobs: |
[
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"name": "edge-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_EDGE", "tool": "GCC_ARM"}, "user": {"variant": {"name": "EDGE", "loc": "variants/SFE_EDGE"}}},
{"name": "edge2-lib", "config": {"base": "compile --library --source=mbed-os", "tgt": "SFE_EDGE2", "tool": "GCC_ARM"}, "user": {"variant": {"name": "EDGE2", "loc": "variants/SFE_EDGE2"}}}
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}},
{"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"}}}
]
mbed: |
{"url": "https://github.com/sparkfun/mbed-os-ambiq-apollo3", "branch": "ambiq-apollo3-arduino"}
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/mbed-bridge
4 changes: 2 additions & 2 deletions cores/arduino/sdk/core-implement/CommonAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ float getTempDegF( void ) {
}

float getVCCV( void ){
return ((float)analogReadVCCDiv3() * 6.0) / 16384.0;
return ((float)analogReadVCCDiv3() * 2.0) / 16384.0;
}

int indexAnalogRead(pin_size_t index){
// todo: replace with mbed "AnalogIn" functionality
pin_size_t pinNumber = pinNumberByIndex(index);
pin_size_t pinNumber = pinNameByIndex(index);
if(pinNumber == (pin_size_t)NC){ return 0; }
ap3_adc_channel_config_t* config = NULL;
for(size_t idx = 0; idx < (sizeof(ap3_adc_channel_configs)/sizeof(ap3_adc_channel_config_t)); idx++){
Expand Down
19 changes: 13 additions & 6 deletions libraries/Apollo3/examples/I2C/I2C.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#include "Wire.h"

void testPortI2C(TwoWire &i2c);

// This thread will use the pre-defined SPI object if it exists
#if VARIANT_WIRE_INTFCS > 0
rtos::Thread wire_thread;
Expand All @@ -55,16 +57,18 @@ void wire1_thread_fn( void ){
delay(100);
Wire1.begin();
while(1){
testPortWire(Wire1);
testPortI2C(Wire1);
delay(1000);
}
}
#endif

// This thread will create its own MbedI2C object using IOM pins
#define mySDA D25
#define mySCL D27
MbedI2C myWire(mySDA, mySCL);
// Define your own pins below to try it
//#define mySDA D25
//#define mySCL D27
#if (defined mySDA) && (defined mySCL)
TwoWire myWire(mySDA, mySCL);
rtos::Thread mywire_thread;
void mywire_thread_fn( void ){
delay(200);
Expand All @@ -74,8 +78,9 @@ void mywire_thread_fn( void ){
delay(1000);
}
}
#endif

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

uint8_t detected = 0;
Expand Down Expand Up @@ -111,12 +116,14 @@ void setup() {
wire1_thread.start(wire1_thread_fn);
#endif

#if (defined mySDA) && (defined mySCL)
mywire_thread.start(mywire_thread_fn);
#endif
}

void loop() {
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
}
}
14 changes: 10 additions & 4 deletions libraries/Apollo3/examples/SPI/SPI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@
// define pins to create a custom SPI port
// using mbed PinNames or Arduino pin numbers
// (must be all pins from one IOM module)
#define mySDI D25
#define mySDO D28
#define myCLK D27

//#define mySDI D25
//#define mySDO D28
//#define myCLK D27
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
MbedSPI mySPI(mySDI, mySDO, myCLK); // declare the custom MbedSPI object mySPI
#endif

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


// this thread tests the custom mySPI object
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
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
rtos::Thread myspi_thread;
void myspi_thread_fn( void ){
Expand All @@ -80,6 +83,7 @@ void myspi_thread_fn( void ){
delay(500);
}
}
#endif

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

spi_thread.start(spi_thread_fn);
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
myspi_thread.start(myspi_thread_fn);
#endif
}

void loop() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
/*
Reading and writing test of the EEPROM functions on the Artemis
By: Nathan Seidle
SparkFun Electronics
Date: June 24th, 2019
This example code is in the public domain.

SparkFun labored with love to create this code. Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15376

Page erase takes 15ms
Write byte takes 30ms - This is much longer than Arduino that takes 3.3ms
Float write across two words takes 30ms
Update (no write) takes 1ms
*/

#include <EEPROM.h>

// Give a default if the variant does not define one.
#ifndef A0
#define A0 0
#endif

void setup()
{
Serial.begin(115200);
Serial.println("EEPROM Examples");

randomSeed(analogRead(A0));

EEPROM.init();

// You may choose to enable more or less EEPROM -
// Default length is 1024 bytes (if setLength is not called)
EEPROM.setLength(1024 * 1); // this would make the length 1080 bytes. Max is 4096.
// Note: larger sizes will increase RAM usage and execution time

long startTime;
long endTime;
int randomLocation;

//Test erase time
startTime = millis();
EEPROM.erase();
endTime = millis();
Serial.printf("Time to erase all EEPROM: %dms\n", endTime - startTime);

//Byte sequential test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Serial.println();
Serial.println("8 bit tests");
uint8_t myValue1 = 200;
byte myValue2 = 23;
randomLocation = random(0, EEPROM.length() - sizeof(myValue1));

startTime = millis();
EEPROM.write(randomLocation, myValue1); //(location, data)
endTime = millis();
EEPROM.put(randomLocation + sizeof(myValue1), myValue2);

Serial.printf("Write byte time: %dms\n", endTime - startTime);

startTime = millis();
EEPROM.write(randomLocation, myValue1); //(location, data)
endTime = millis();

Serial.printf("Write identical byte to same location: %dms\n", endTime - startTime);

byte response1 = EEPROM.read(randomLocation);
byte response2 = EEPROM.read(randomLocation + sizeof(myValue1));
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue1, response1);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue1), myValue2, response2);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Serial.println();
Serial.println("16 bit tests");

//int16_t and uint16_t sequential test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
uint16_t myValue3 = 3411;
int16_t myValue4 = -366;
randomLocation = random(0, EEPROM.length() - sizeof(myValue3));

EEPROM.put(randomLocation, myValue3);
EEPROM.put(randomLocation + sizeof(myValue3), myValue4);

uint16_t response3;
int16_t response4;
EEPROM.get(randomLocation, response3);
EEPROM.get(randomLocation + sizeof(myValue3), response4);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue3, response3);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue3), myValue4, response4);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Serial.println();
Serial.println("32 bit tests");

//int and unsigned int (32) sequential test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Serial.printf("Size of int: %d\n", sizeof(int));
int myValue5 = -245000;
unsigned int myValue6 = 400123;
randomLocation = random(0, EEPROM.length() - sizeof(myValue5));

EEPROM.put(randomLocation, myValue5);
EEPROM.put(randomLocation + sizeof(myValue5), myValue6);

int response5;
unsigned int response6;
EEPROM.get(randomLocation, response5);
EEPROM.get(randomLocation + sizeof(myValue5), response6);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue5, response5);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue5), myValue6, response6);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//int32_t and uint32_t sequential test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
int32_t myValue7 = -341002;
uint32_t myValue8 = 241544;
randomLocation = random(0, EEPROM.length() - sizeof(myValue7));

EEPROM.put(randomLocation, myValue7);
EEPROM.put(randomLocation + sizeof(myValue7), myValue8);

int32_t response7;
uint32_t response8;
EEPROM.get(randomLocation, response7);
EEPROM.get(randomLocation + sizeof(myValue7), response8);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation, myValue7, response7);
Serial.printf("Location %d should be %d: %d\n\r", randomLocation + sizeof(myValue7), myValue8, response8);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//float (32) sequential test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Serial.printf("Size of float: %d\n", sizeof(float));
float myValue9 = -7.35;
float myValue10 = 5.22;
randomLocation = random(0, EEPROM.length() - sizeof(myValue9));

EEPROM.put(randomLocation, myValue9);
EEPROM.put(randomLocation + sizeof(myValue9), myValue10);

float response9;
float response10;
EEPROM.get(randomLocation, response9);
EEPROM.get(randomLocation + sizeof(myValue9), response10);
Serial.printf("Location %d should be ", randomLocation);
Serial.print(myValue9);
Serial.print(": ");
Serial.print(response9);
Serial.println();
Serial.printf("Location %d should be ", randomLocation + sizeof(myValue9));
Serial.print(myValue10);
Serial.print(": ");
Serial.print(response10);
Serial.println();
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Serial.println();
Serial.println("64 bit tests");

//double (64) sequential test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Serial.printf("Size of double: %d\n", sizeof(double));
double myValue11 = -290.3485723409857;
double myValue12 = 384.95734987;
double myValue13 = 917.14159;
double myValue14 = 254.8877;
randomLocation = random(0, EEPROM.length() - sizeof(myValue11));

startTime = millis();
EEPROM.put(randomLocation, myValue11);
endTime = millis();
Serial.printf("Time to record 64-bits: %dms\n", endTime - startTime);

EEPROM.put(randomLocation + sizeof(myValue11), myValue12);
EEPROM.put(EEPROM.length() - sizeof(myValue13), myValue13); //Test end of EEPROM space

double response11;
double response12;
double response13;
EEPROM.get(randomLocation, response11);
EEPROM.get(randomLocation + sizeof(myValue11), response12);
EEPROM.get(EEPROM.length() - sizeof(myValue13), response13);

Serial.printf("Location %d should be ", randomLocation);
Serial.print(myValue11, 13);
Serial.print(": ");
Serial.print(response11, 13);
Serial.println();
Serial.printf("Location %d should be ", randomLocation + sizeof(myValue11));
Serial.print(myValue12, 8);
Serial.print(": ");
Serial.print(response12, 8);
Serial.println();
Serial.printf("Edge of EEPROM %d should be ", EEPROM.length() - sizeof(myValue13));
Serial.print(myValue13, 5);
Serial.print(": ");
Serial.print(response13, 5);
Serial.println();

double response14;
EEPROM.put(EEPROM.length() - sizeof(myValue14), myValue14); //Test the re-write of a spot
EEPROM.get(EEPROM.length() - sizeof(myValue14), response14);
Serial.printf("Rewrite of %d should be ", EEPROM.length() - sizeof(myValue14));
Serial.print(myValue14, 4);
Serial.print(": ");
Serial.print(response14, 4);
Serial.println();
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Serial.println();
Serial.println("String test");

//String write test
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
char myString[19] = "How are you today?";
randomLocation = random(0, EEPROM.length() - sizeof(myString));
EEPROM.put(randomLocation, myString);

char readMy[19];
EEPROM.get(randomLocation, readMy);
Serial.printf("Location %d string should read 'How are you today?': ", randomLocation);
Serial.println(readMy);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

}

void loop()
{
}
Loading