Skip to content

Commit

Permalink
Release 2.1.0
Browse files Browse the repository at this point in the history
* Add the released 2.0.0 version to the package index JSON

Also add the new and upcoming 2.1.0 version for local installs

* Bump the core version to 2.1.0

* Initialize the ADC input pin correctly

Without setting the ADC pin explicitly as an input we got
strange behavior on some of the pins.
Fixes #96

* remove debug print

* Add AES CCM support to the BLE variants

* Add NVM3 support to the 'no radio' variants

* Generate SDK files for the BLE and 'no radio' variants

* Implement NumberOfPrimaries support for Matter Color Control

* Implement direct copying to the 'variants' folder in the GSDK generator script

Also add wildcard configurations for the different protocol stacks

* Adjust Matter attribute permissions, add new write handlers

The following attributes received a write permission
and a write handler:
 - IdentifyTime (Identify)
 - Options (LevelControl)
 - OnLevel (LevelControl)
 - StartUpCurrentLevel (LevelControl)
 - Options (ColorControl)

* Add FeatureMap and ClusterRevision to the Matter Descriptor cluster

These attributes were previously missing.
Handling of these attributes is taken care of by the
Descriptor cluster implementation in the Matter SDK.

* Add write handler for Matter OnOff cluster GlobalSceneControl

Also change the default value for GlobalSceneControl to 'true'

* Refactor Matter Lightbulb cluster write handling

Also add helping comments to the read handling in the same style

* Use the correct device type for the Matter Color Lightbulb

DEVICE_TYPE_DIMMABLE_LIGHT was used instead of DEVICE_TYPE_EXTENDED_COLOR_LIGHT

* Add option to disable the Matter Bridge endpoint

It's enabled by default - disabling it only works on Google,
Apple and Amazon won't talk to the device if it's disabled

* Implement Groups cluster support for Matter Lightbulb devices

* Make StartUpOnOff a writable Matter Lightbulb attribute

* Add extra constraint protection to Matter LevelControl CurrentLevel

* Make Matter LevelControl CurrentLevel nullable

* Remove the explicit ClusterRevision attribute from all Matter clusters

The ClusterRevision attribute is auto added by
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END, so adding it explicitly
creates a duplicate.

* Remove Matter Groups cluster command responses from the command list

These were added by mistake, their ID collides with the
non-response counterpart.

* Add outgoing commands for the Matter Groups cluster

These commands will populate the GeneratedCommandList

* Make the Matter LevelControl OnLevel attribute nullable

* Allow 255 as a valid Matter LevelControl CurrentLevel value

255 represents NULL, so it should be allowed to be written

* Make Matter LevelControl StartUpCurrentLevel nullable

* Introduce WRITABLE_NULLABLE attribute mask for Matter clusters

This simplifies cluster attribute definitions

* Add lower bound check to Matter LevelControl SetLevel

* Add function to get the Matter onboarding QR code payload

* Correct the default CPU frequency to 39 MHz

* Implement Matter device change callback

 - Add callback handling to the lightbulb classes
 - Add an example showing callback usage

* Integrate the Matter device change callback to all compatible devices

These are: Fan, OnOffPluginUnit, Switch, Thermostat, WindowCovering

* Update the Matter library readme with the callback function description

* Implement Matter decommissioning API

Also add an example showing how to decommission a device

* Add setter/getter for Matter On/Off cluster StartupOnOff

* Change the type of Matter Groups NameSupport attribute to INT8U

* Implement 'Toggle' and 'null' value handling for Matter OnOff StartUpOnOff

Also make the StartupOnOff attribute nullable

* Implement support for Matter Door Lock

* Add device change callback to the Matter Door Lock

* split BLE variants in two: BLE (only bluetooth controller) and BLE Silabs (with bluetooth silabs host stack)

* Update the build tests to work with the new BLE variants

* Update the readme and examples to reflect the BLE variant changes

* Rename the Arduino BLE variants to 'BLE (Arduino)'

* Rework Matter device change callback behavior

Now the callback fires on every change not just changes from the
Matter network. Now all devices will call the callback upon changing
if registered. This change was implemented to ensure a consistent
behavior from the callback.

* Add support for the 'Ezurio Lyra 24P 20' board

* Adjust the section labels in boards.txt

* add EEPROM library (using NVM3 APIs)

* Refactor the EEPROM driver to use 254 byte NVM3 objects

* Add EEPROM calls to the test sketch

* Update the user NVM size to 10k

* Use the global define for NVM3 object sizes in EEPROM lib

* platform.txt: properly escape openocd rules

Fixes upload errors on Nano Matter for Windows users with spaces in their username

* Add docs and pinout diagram for the Ezurio Lyra 24P

* Update the readme with debugging info for the Lyra 24P 20

* Implement 'suspend' and 'resume' for Serial

These functions help us to enter low power saving states

* Add the 'em_rmu' component to all variants

The Reset Management Unit is needed for low power functions

* Fix the Serial mapping on the xG24 Explorer Kit

The VCOM Serial is not exposed on the header - only Serial1

* Decrease NVM3 cache on the BGM220 Explorer Kit variants

The BGM220 has only 32k of RAM - this gives some additional memory
back to the users.

* Add a new Serial to the BGM220 Explorer Kit

Also update the pinout diagram to show Serial mappings correctly

* Remove the 'BLE (Arduino)' variant from the BGM220 Explorer Kit

Unfortunately the BGM220 doesn't have enough RAM to
reliably run the ArduinoBLE stack.

* Regenerate GSDK for the BGM220 Explorer Kit

NVM cache size change and new Serial added

* Fix the upload target in boards.txt for the Lyra24P

* Mark all the EM4 wakeup pins in the variant descriptions

* Mark all the EM4 wakeup pins on the pinout diagrams

* Add the ArduinoLowPower library

* Implement an 'escape_hatch' method to prevent EM4 bricking

This function will keep the devices awake when the on-board
button is pressed to prevent EM4 bricking.
The Silicon Labs boards board controller can handle this
situation however the Nano Matter's can't.
This 'escape_hatch' function will only be present when using the
ArduinoLowPower library.

* Make 'wokeUpFromDeepSleep()' work on all variants

* Fix keywords.txt alignment in ArduinoLowPower

* Mark BLE example compatibility for the 'Lyra 24P 20'

* Mark variables used in ISRs as volatile in BLE examples

* Fix the zero brightness edge case in ezWS2812

We were writing the input variables instead of the output

* Update the Matter readme with the Nano Matter OT RCP description

* Add the 'Arduino Matter Provision' tool

* Update the readme with the bundled libraries

* Make 'system_init_finished' read only with a getter

* Make the versioning of the included libraries consistent

All included libraries inherit the version of the core,
so we know which core release they're included in. Also, this
eliminates the need for separate versioning for each.

* Implement missing fan speed related attributes in MatterFan

This increases compatibility with Home Assistant

* Fix typo in the Matter flow sensor example

---------

Co-authored-by: Leonardo Cavagnis <[email protected]>
Co-authored-by: Leonardo Cavagnis <[email protected]>
Co-authored-by: Martino Facchin <[email protected]>
  • Loading branch information
4 people authored Aug 1, 2024
1 parent 65a739a commit 9bff82c
Show file tree
Hide file tree
Showing 6,943 changed files with 1,708,536 additions and 918 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
314 changes: 242 additions & 72 deletions boards.txt
100644 → 100755

Large diffs are not rendered by default.

680 changes: 680 additions & 0 deletions bootloaders/lyra24p20-bootloader-storage-internal-single-512k.hex

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions cores/silabs/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extern "C" {
#endif // SL_CATALOG_BLUETOOTH_PRESENT

#include "em_common.h"
#include "em_rmu.h"
#include "app_assert.h"
#include "em_gpio.h"
#include "app_log.h"
Expand Down Expand Up @@ -103,4 +104,8 @@ typedef enum _dac_channel_t dac_channel_t;
void analogWrite(dac_channel_t dac_channel, int value);
void analogWriteResolution(int resolution);

bool get_system_init_finished();
uint32_t get_system_reset_cause();
void escape_hatch();

#endif // ARDUINO_H
2 changes: 1 addition & 1 deletion cores/silabs/Interrupt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void attachInterruptParam(PinName interruptNumber, voidFuncPtrParam callback, Pi

void attachInterrupt(PinName interruptNumber, voidFuncPtr callback, PinStatus mode)
{
if (interruptNumber >= PIN_NAME_MAX || callback == nullptr || mode < LOW || mode > RISING || !system_init_finished) {
if (interruptNumber >= PIN_NAME_MAX || callback == nullptr || mode < LOW || mode > RISING || !get_system_init_finished()) {
return;
}

Expand Down
30 changes: 27 additions & 3 deletions cores/silabs/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ UARTClass::UARTClass(sl_iostream_t* stream,
void(*deinit_fn)(void),
void(*serial_event_fn)(void)) :
serial_mutex(nullptr),
initialized(true)
initialized(true),
baudrate(115200),
suspended(false)
{
this->serial_mutex = xSemaphoreCreateMutexStatic(&this->serial_mutex_buf);
configASSERT(this->serial_mutex);
Expand All @@ -57,11 +59,10 @@ void UARTClass::begin(unsigned long baudrate)
if (this->initialized) {
return;
}
//#ifndef ARDUINO_MATTER
this->init_fn();
this->baud_rate_set_fn(baudrate);
this->initialized = true;
//#endif // ARDUINO_MATTER
this->baudrate = baudrate;
}

void UARTClass::begin(unsigned long baudrate, uint16_t config)
Expand All @@ -72,6 +73,9 @@ void UARTClass::begin(unsigned long baudrate, uint16_t config)

void UARTClass::end()
{
if (!this->initialized) {
return;
}
this->deinit_fn();
this->initialized = false;
}
Expand Down Expand Up @@ -122,6 +126,26 @@ void UARTClass::printf(const char *fmt, ...)
this->write((uint8_t*)message, strlen(message));
}

void UARTClass::suspend()
{
if (!this->initialized) {
return;
}
// The small delay is here to allow the last bytes to be transmitted
delay(1);
this->end();
this->suspended = true;
}

void UARTClass::resume()
{
if (!this->suspended) {
return;
}
this->begin(this->baudrate);
this->suspended = false;
}

UARTClass::operator bool()
{
return true;
Expand Down
4 changes: 4 additions & 0 deletions cores/silabs/Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class UARTClass : public HardwareSerial
void task();
void handleSerialEvent();
void printf(const char* fmt, ...);
void suspend();
void resume();
private:
static const uint8_t printf_buffer_size = 128u;

Expand All @@ -80,6 +82,8 @@ class UARTClass : public HardwareSerial
sl_iostream_uart_t* instance_handle;

bool initialized;
unsigned long baudrate;
bool suspended;
};
} // namespace arduino

Expand Down
1 change: 0 additions & 1 deletion cores/silabs/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
if (pin_name == PIN_NAME_NC) {
return;
}
Serial.println("qui tutto ok");
tone(pin_name, frequency, duration);
}

Expand Down
3 changes: 3 additions & 0 deletions cores/silabs/adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ AdcClass::AdcClass() :

void AdcClass::init(PinName pin, uint8_t reference)
{
// Set up the ADC pin as an input
pinMode(pin, INPUT);

// Create ADC init structs with default values
IADC_Init_t init = IADC_INIT_DEFAULT;
IADC_AllConfigs_t all_configs = IADC_ALLCONFIGS_DEFAULT;
Expand Down
27 changes: 26 additions & 1 deletion cores/silabs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,25 @@ static const uint32_t arduino_task_priority = 1u;
static StackType_t arduino_task_stack[arduino_task_stack_size] = { 0 };
static StaticTask_t arduino_task_buffer;
static TaskHandle_t arduino_task_handle;
bool system_init_finished = false;
static bool system_init_finished = false;
static uint32_t system_reset_cause = 0u;

int main()
{
// Save the reset cause
system_reset_cause = RMU_ResetCauseGet();
// The Matter SDK also gets the reset cause and clears it after, so we need to avoid clearing it here on Matter
#ifndef ARDUINO_MATTER
RMU_ResetCauseClear();
#endif

// Board specific init - in most cases it's just a call to sl_system_init(),
// but when using the Matter stack it needs a more complex init process
init_arduino_variant();
system_init_finished = true;

escape_hatch();

arduino_task_handle = xTaskCreateStatic(arduino_task,
"arduino_task",
arduino_task_stack_size,
Expand Down Expand Up @@ -76,3 +86,18 @@ inline static void handle_serial_events()
Serial1.handleSerialEvent();
#endif // #if (NUM_HW_SERIAL > 1)
}

bool get_system_init_finished()
{
return system_init_finished;
}

uint32_t get_system_reset_cause()
{
return system_reset_cause;
}

SL_WEAK void escape_hatch()
{
;
}
2 changes: 1 addition & 1 deletion cores/silabs/silabs_additional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void setCPUClock(cpu_clock_t clock)
{
CMU_DPLLInit_TypeDef pll_init;
switch (clock) {
case CPU_40MHZ:
case CPU_39MHZ:
CMU_CLOCK_SELECT_SET(SYSCLK, HFXO);
return;
case CPU_76MHZ:
Expand Down
2 changes: 1 addition & 1 deletion cores/silabs/silabs_additional.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "em_common.h"

typedef enum {
CPU_40MHZ,
CPU_39MHZ,
CPU_76MHZ,
CPU_80MHZ
} cpu_clock_t;
Expand Down
101 changes: 101 additions & 0 deletions cores/silabs/silabs_eeprom.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* This file is part of the Silicon Labs Arduino Core
*
* The MIT License (MIT)
*
* Copyright 2024 Silicon Laboratories Inc. www.silabs.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "silabs_eeprom.h"

#include "nvm3.h"
#include "nvm3_hal_flash.h"
#include "nvm3_default_config.h"

// The NVM3 key space is divided into several domains, the usable user domain is 0x00000 - 0x0FFFF
#define NVM3_USER_KEY_SPACE_END 0x0FFFFu

#define NVM3_OBJECT_SIZE (NVM3_DEFAULT_MAX_OBJECT_SIZE)
#define NVM3_MAX_SIZE 10240u

uint8_t eeprom_read_byte(uint32_t addr)
{
if (addr >= NVM3_MAX_SIZE) {
return 0xFFu;
}

uint32_t object_idx = addr / NVM3_OBJECT_SIZE;
uint32_t data_idx = addr % NVM3_OBJECT_SIZE;

if (object_idx > NVM3_USER_KEY_SPACE_END) {
return 0xFFu;
}

uint8_t object_cache[NVM3_OBJECT_SIZE];
Ecode_t status = nvm3_readData(nvm3_defaultHandle, object_idx, (void*)object_cache, NVM3_OBJECT_SIZE);

if (status != ECODE_NVM3_OK) {
return 0xFFu;
}
return object_cache[data_idx];
}

void eeprom_write_byte(uint32_t addr, uint8_t value)
{
if (addr >= NVM3_MAX_SIZE) {
return;
}

uint32_t object_idx = addr / NVM3_OBJECT_SIZE;
uint32_t data_idx = addr % NVM3_OBJECT_SIZE;

if (object_idx > NVM3_USER_KEY_SPACE_END) {
return;
}

// Read the object from NVM3
uint8_t object_cache[NVM3_OBJECT_SIZE];
Ecode_t status = nvm3_readData(nvm3_defaultHandle, object_idx, (void*)object_cache, NVM3_OBJECT_SIZE);
if (status != ECODE_NVM3_OK && status != ECODE_NVM3_ERR_KEY_NOT_FOUND) {
return;
}

// Initialize the object if it's currently non-existent
if (status == ECODE_NVM3_ERR_KEY_NOT_FOUND) {
memset(object_cache, 0xFFu, NVM3_OBJECT_SIZE);
}

// Update the requested value
object_cache[data_idx] = value;

// Write the object back to NVM3
nvm3_writeData(nvm3_defaultHandle, object_idx, object_cache, NVM3_OBJECT_SIZE);

// Do repacking if needed
if (nvm3_repackNeeded(nvm3_defaultHandle)) {
nvm3_repack(nvm3_defaultHandle);
}
}

uint16_t eeprom_get_length()
{
return NVM3_MAX_SIZE;
}
56 changes: 56 additions & 0 deletions cores/silabs/silabs_eeprom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of the Silicon Labs Arduino Core
*
* The MIT License (MIT)
*
* Copyright 2024 Silicon Laboratories Inc. www.silabs.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "Arduino.h"

/**
* @brief Reads a byte from the EEPROM at the specified address.
*
* This function reads and returns the byte stored in the EEPROM at the given address.
*
* @param addr The address in the EEPROM from which to read the byte.
* @return The byte read from the EEPROM.
*/
uint8_t eeprom_read_byte(uint32_t addr);

/**
* @brief Writes a byte to the EEPROM at the specified address.
*
* This function writes the given byte to the EEPROM at the specified address.
*
* @param addr The address in the EEPROM where the byte will be written.
* @param value The byte value to be written to the EEPROM.
*/
void eeprom_write_byte(uint32_t addr, uint8_t value);

/**
* @brief Gets the length of the EEPROM.
*
* This function returns the total number of bytes available in the EEPROM.
*
* @return The total number of bytes in the EEPROM.
*/
uint16_t eeprom_get_length();
6 changes: 3 additions & 3 deletions cores/silabs/wiring_digital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void pinMode(pin_size_t pinNumber, PinMode mode)

void pinMode(PinName pinNumber, PinMode pinMode)
{
if (!system_init_finished || pinNumber >= PIN_NAME_MAX) {
if (!get_system_init_finished() || pinNumber >= PIN_NAME_MAX) {
return;
}
GPIO_Port_TypeDef hw_port = getSilabsPortFromArduinoPin(pinNumber);
Expand Down Expand Up @@ -73,7 +73,7 @@ PinStatus digitalRead(pin_size_t pinNumber)

PinStatus digitalRead(PinName pinNumber)
{
if (!system_init_finished || pinNumber >= PIN_NAME_MAX) {
if (!get_system_init_finished() || pinNumber >= PIN_NAME_MAX) {
return PinStatus::LOW;
}
GPIO_Port_TypeDef hw_port = getSilabsPortFromArduinoPin(pinNumber);
Expand All @@ -93,7 +93,7 @@ void digitalWrite(pin_size_t pinNumber, PinStatus status)

void digitalWrite(PinName pinNumber, PinStatus status)
{
if (!system_init_finished || pinNumber >= PIN_NAME_MAX) {
if (!get_system_init_finished() || pinNumber >= PIN_NAME_MAX) {
return;
}
GPIO_Port_TypeDef out_port = getSilabsPortFromArduinoPin(pinNumber);
Expand Down
2 changes: 0 additions & 2 deletions cores/silabs/wiring_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ extern "C" {
#include "em_gpio.h"
}

extern bool system_init_finished;

#endif // WIRING_PRIVATE_H
Binary file modified doc/bgm220explorerkit_pinout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/lyra24p20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/lyra24p20_pinout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/sparkfunthingplusmatter_pinout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9bff82c

Please sign in to comment.