Skip to content
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

Release 2.1.1 #413

Merged
merged 21 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/generate-variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
{"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"}}}
{"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"}}},
{"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"}}}
]
mbed: |
{"url": "https://github.com/sparkfun/mbed-os-ambiq-apollo3", "branch": "ambiq-apollo3-arduino"}
Expand Down
74 changes: 0 additions & 74 deletions libraries/Apollo3/examples/DigitalWrite/DigitalWrite.ino

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Author: Nathan Seidle
Created: October 16th, 2019
License: MIT. See SparkFun Arduino Apollo3 Project for more information

This example demonstrates how to display the revision of the Apollo3.
See the Ambiq website for errata on each revision: https://ambiqmicro.com/mcu/
*/
void setup()
{
Serial.begin(115200);
delay(10); //Wait for any bootloader UART interactions to complete
Serial.println();
Serial.print("Apollo3 IC revision code: ");

if (APOLLO3_A0)
{
Serial.print("A0");
}
else if (APOLLO3_A1)
{
Serial.print("A1");
}
else if (APOLLO3_B0)
{
Serial.print("B0");
}
else if (APOLLO3_GE_B0)
{
Serial.print("Unknown revision but it's greater than B0");
}
else
{
Serial.print("Unknown revision");
}
Serial.println();
Serial.println("All done");
}

void loop()
{
//Do nothing
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
BLEAdvertise

This example creates a BLE peripheral which advertises itself as Artemis.
Central devices may connect with it, but there are no services or
characteristics to interact with.

Based on a stripped down version of the LED example from the ArduinoBLE examples
*/

#include <ArduinoBLE.h> //http://librarymanager/All#ArduinoBLE_IoT

void setup() {
Serial.begin(115200);
while (!Serial);

// begin initialization
if (!BLE.begin()) {
Serial.println("Starting BLE failed!");
while (1);
}

// set advertised local name and service UUID:
BLE.setLocalName("Artemis");

// start advertising
BLE.advertise();

Serial.println("BLE advertising as 'Artemis'");
}

void loop() {
// listen for BLE peripherals to connect:
BLEDevice central = BLE.central();

// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());

// while the central is still connected to peripheral...
while (central.connected()) {
//Nothing to do here
}

// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- declaring your own MbedI2C object using pins that correspond to the correct IOM

Once you have an MbedI2C object to work with you can use all the standard
Arduino SPI API methods on it
Arduino Wire API methods on it
https://www.arduino.cc/en/reference/wire

This example will use threads to organize I2C operations based on board
Expand All @@ -33,56 +33,21 @@
GND <--> sensor GND

*/

#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;
void wire_thread_fn( void ){
Wire.begin();
while(1){
testPortI2C(Wire);
delay(1000);
}
}
#endif

// This thread will use the pre-defined SPI1 object if it exists
#if VARIANT_WIRE_INTFCS > 1
rtos::Thread wire1_thread;
void wire1_thread_fn( void ){
delay(100);
Wire1.begin();
while(1){
testPortI2C(Wire1);
delay(1000);
}
}
#endif

// This thread will create its own MbedI2C object using IOM pins
// 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);
myWire.begin();
while(1){
testPortI2C(myWire);
delay(1000);
}
}
#endif

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

uint8_t detected = 0;
for(uint8_t addr = 1; addr < 127; addr++ ){
// use endTransmission to determine if a device is present at address
Expand All @@ -94,11 +59,9 @@ void testPortI2C(TwoWire &i2c){
detected++;
}
}

if(!detected){
Serial.printf("\tNo device detected!\n");
}

Serial.println();
}

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

#if VARIANT_WIRE_INTFCS > 0
wire_thread.start(wire_thread_fn);
Wire.begin();
#endif

#if VARIANT_WIRE_INTFCS > 1
wire1_thread.start(wire1_thread_fn);
Wire1.begin();
#endif

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

void loop() {
#if VARIANT_WIRE_INTFCS > 0
testPortI2C(Wire);
#endif
#if VARIANT_WIRE_INTFCS > 1
testPortI2C(Wire1);
#endif
#if (defined mySDA) && (defined mySCL)
testPortI2C(myWire);
#endif

digitalWrite(LED_BUILTIN, LOW);
delay(1000);
digitalWrite(LED_BUILTIN, HIGH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,12 @@
//#define myCLK D27
#if (defined mySDI) && (defined mySDO) && (defined myCLK)
MbedSPI mySPI(mySDI, mySDO, myCLK); // declare the custom MbedSPI object mySPI
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
#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"))

// this thread will test the pre-defined SPI object if it exists
rtos::Thread spi_thread;
void spi_thread_fn( void ){
#if VARIANT_SPI_INTFCS > 0
delay(100);
SPI.begin();
while(1){
TEST_SPI_PORT(SPI);
delay(500);
}
#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 ){
delay(300);
SERIAL_PORT.printf("starting mySPI on IOM %d\n", spi_get_peripheral_name(mySDO, mySDI, myCLK));
mySPI.begin();
while(1){
TEST_SPI_PORT(mySPI);
delay(500);
}
}
#endif

int test_byte_transfer( SPIClass &spi ){
uint8_t tx = random(1, 256);
uint8_t rx = 0x00;
Expand Down Expand Up @@ -128,13 +100,22 @@ void setup() {
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);

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

#if (defined mySDI) && (defined mySDO) && (defined myCLK)
SERIAL_PORT.printf("starting mySPI on IOM %d\n", spi_get_peripheral_name(mySDO, mySDI, myCLK));
mySPI.begin();
#endif
}

void loop() {
Serial.println("test");
TEST_SPI_PORT(SPI);

#if (defined mySDI) && (defined mySDO) && (defined myCLK)
TEST_SPI_PORT(mySPI);
#endif

digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
Expand Down
Loading