Skip to content

Commit 9bff82c

Browse files
silabs-bozontleonardocavagnisfacchinm
authored
Release 2.1.0
* 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]>
1 parent 65a739a commit 9bff82c

File tree

6,943 files changed

+1708536
-918
lines changed

Some content is hidden

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

6,943 files changed

+1708536
-918
lines changed

boards.txt

100644100755
+242-72
Large diffs are not rendered by default.

bootloaders/lyra24p20-bootloader-storage-internal-single-512k.hex

+680
Large diffs are not rendered by default.

cores/silabs/Arduino.h

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern "C" {
5555
#endif // SL_CATALOG_BLUETOOTH_PRESENT
5656

5757
#include "em_common.h"
58+
#include "em_rmu.h"
5859
#include "app_assert.h"
5960
#include "em_gpio.h"
6061
#include "app_log.h"
@@ -103,4 +104,8 @@ typedef enum _dac_channel_t dac_channel_t;
103104
void analogWrite(dac_channel_t dac_channel, int value);
104105
void analogWriteResolution(int resolution);
105106

107+
bool get_system_init_finished();
108+
uint32_t get_system_reset_cause();
109+
void escape_hatch();
110+
106111
#endif // ARDUINO_H

cores/silabs/Interrupt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void attachInterruptParam(PinName interruptNumber, voidFuncPtrParam callback, Pi
9696

9797
void attachInterrupt(PinName interruptNumber, voidFuncPtr callback, PinStatus mode)
9898
{
99-
if (interruptNumber >= PIN_NAME_MAX || callback == nullptr || mode < LOW || mode > RISING || !system_init_finished) {
99+
if (interruptNumber >= PIN_NAME_MAX || callback == nullptr || mode < LOW || mode > RISING || !get_system_init_finished()) {
100100
return;
101101
}
102102

cores/silabs/Serial.cpp

+27-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ UARTClass::UARTClass(sl_iostream_t* stream,
4040
void(*deinit_fn)(void),
4141
void(*serial_event_fn)(void)) :
4242
serial_mutex(nullptr),
43-
initialized(true)
43+
initialized(true),
44+
baudrate(115200),
45+
suspended(false)
4446
{
4547
this->serial_mutex = xSemaphoreCreateMutexStatic(&this->serial_mutex_buf);
4648
configASSERT(this->serial_mutex);
@@ -57,11 +59,10 @@ void UARTClass::begin(unsigned long baudrate)
5759
if (this->initialized) {
5860
return;
5961
}
60-
//#ifndef ARDUINO_MATTER
6162
this->init_fn();
6263
this->baud_rate_set_fn(baudrate);
6364
this->initialized = true;
64-
//#endif // ARDUINO_MATTER
65+
this->baudrate = baudrate;
6566
}
6667

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

7374
void UARTClass::end()
7475
{
76+
if (!this->initialized) {
77+
return;
78+
}
7579
this->deinit_fn();
7680
this->initialized = false;
7781
}
@@ -122,6 +126,26 @@ void UARTClass::printf(const char *fmt, ...)
122126
this->write((uint8_t*)message, strlen(message));
123127
}
124128

129+
void UARTClass::suspend()
130+
{
131+
if (!this->initialized) {
132+
return;
133+
}
134+
// The small delay is here to allow the last bytes to be transmitted
135+
delay(1);
136+
this->end();
137+
this->suspended = true;
138+
}
139+
140+
void UARTClass::resume()
141+
{
142+
if (!this->suspended) {
143+
return;
144+
}
145+
this->begin(this->baudrate);
146+
this->suspended = false;
147+
}
148+
125149
UARTClass::operator bool()
126150
{
127151
return true;

cores/silabs/Serial.h

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class UARTClass : public HardwareSerial
6363
void task();
6464
void handleSerialEvent();
6565
void printf(const char* fmt, ...);
66+
void suspend();
67+
void resume();
6668
private:
6769
static const uint8_t printf_buffer_size = 128u;
6870

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

8284
bool initialized;
85+
unsigned long baudrate;
86+
bool suspended;
8387
};
8488
} // namespace arduino
8589

cores/silabs/Tone.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
3333
if (pin_name == PIN_NAME_NC) {
3434
return;
3535
}
36-
Serial.println("qui tutto ok");
3736
tone(pin_name, frequency, duration);
3837
}
3938

cores/silabs/adc.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ AdcClass::AdcClass() :
4040

4141
void AdcClass::init(PinName pin, uint8_t reference)
4242
{
43+
// Set up the ADC pin as an input
44+
pinMode(pin, INPUT);
45+
4346
// Create ADC init structs with default values
4447
IADC_Init_t init = IADC_INIT_DEFAULT;
4548
IADC_AllConfigs_t all_configs = IADC_ALLCONFIGS_DEFAULT;

cores/silabs/main.cpp

+26-1
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,25 @@ static const uint32_t arduino_task_priority = 1u;
3333
static StackType_t arduino_task_stack[arduino_task_stack_size] = { 0 };
3434
static StaticTask_t arduino_task_buffer;
3535
static TaskHandle_t arduino_task_handle;
36-
bool system_init_finished = false;
36+
static bool system_init_finished = false;
37+
static uint32_t system_reset_cause = 0u;
3738

3839
int main()
3940
{
41+
// Save the reset cause
42+
system_reset_cause = RMU_ResetCauseGet();
43+
// The Matter SDK also gets the reset cause and clears it after, so we need to avoid clearing it here on Matter
44+
#ifndef ARDUINO_MATTER
45+
RMU_ResetCauseClear();
46+
#endif
47+
4048
// Board specific init - in most cases it's just a call to sl_system_init(),
4149
// but when using the Matter stack it needs a more complex init process
4250
init_arduino_variant();
4351
system_init_finished = true;
4452

53+
escape_hatch();
54+
4555
arduino_task_handle = xTaskCreateStatic(arduino_task,
4656
"arduino_task",
4757
arduino_task_stack_size,
@@ -76,3 +86,18 @@ inline static void handle_serial_events()
7686
Serial1.handleSerialEvent();
7787
#endif // #if (NUM_HW_SERIAL > 1)
7888
}
89+
90+
bool get_system_init_finished()
91+
{
92+
return system_init_finished;
93+
}
94+
95+
uint32_t get_system_reset_cause()
96+
{
97+
return system_reset_cause;
98+
}
99+
100+
SL_WEAK void escape_hatch()
101+
{
102+
;
103+
}

cores/silabs/silabs_additional.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void setCPUClock(cpu_clock_t clock)
7070
{
7171
CMU_DPLLInit_TypeDef pll_init;
7272
switch (clock) {
73-
case CPU_40MHZ:
73+
case CPU_39MHZ:
7474
CMU_CLOCK_SELECT_SET(SYSCLK, HFXO);
7575
return;
7676
case CPU_76MHZ:

cores/silabs/silabs_additional.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "em_common.h"
3434

3535
typedef enum {
36-
CPU_40MHZ,
36+
CPU_39MHZ,
3737
CPU_76MHZ,
3838
CPU_80MHZ
3939
} cpu_clock_t;

cores/silabs/silabs_eeprom.cpp

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* This file is part of the Silicon Labs Arduino Core
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright 2024 Silicon Laboratories Inc. www.silabs.com
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "silabs_eeprom.h"
28+
29+
#include "nvm3.h"
30+
#include "nvm3_hal_flash.h"
31+
#include "nvm3_default_config.h"
32+
33+
// The NVM3 key space is divided into several domains, the usable user domain is 0x00000 - 0x0FFFF
34+
#define NVM3_USER_KEY_SPACE_END 0x0FFFFu
35+
36+
#define NVM3_OBJECT_SIZE (NVM3_DEFAULT_MAX_OBJECT_SIZE)
37+
#define NVM3_MAX_SIZE 10240u
38+
39+
uint8_t eeprom_read_byte(uint32_t addr)
40+
{
41+
if (addr >= NVM3_MAX_SIZE) {
42+
return 0xFFu;
43+
}
44+
45+
uint32_t object_idx = addr / NVM3_OBJECT_SIZE;
46+
uint32_t data_idx = addr % NVM3_OBJECT_SIZE;
47+
48+
if (object_idx > NVM3_USER_KEY_SPACE_END) {
49+
return 0xFFu;
50+
}
51+
52+
uint8_t object_cache[NVM3_OBJECT_SIZE];
53+
Ecode_t status = nvm3_readData(nvm3_defaultHandle, object_idx, (void*)object_cache, NVM3_OBJECT_SIZE);
54+
55+
if (status != ECODE_NVM3_OK) {
56+
return 0xFFu;
57+
}
58+
return object_cache[data_idx];
59+
}
60+
61+
void eeprom_write_byte(uint32_t addr, uint8_t value)
62+
{
63+
if (addr >= NVM3_MAX_SIZE) {
64+
return;
65+
}
66+
67+
uint32_t object_idx = addr / NVM3_OBJECT_SIZE;
68+
uint32_t data_idx = addr % NVM3_OBJECT_SIZE;
69+
70+
if (object_idx > NVM3_USER_KEY_SPACE_END) {
71+
return;
72+
}
73+
74+
// Read the object from NVM3
75+
uint8_t object_cache[NVM3_OBJECT_SIZE];
76+
Ecode_t status = nvm3_readData(nvm3_defaultHandle, object_idx, (void*)object_cache, NVM3_OBJECT_SIZE);
77+
if (status != ECODE_NVM3_OK && status != ECODE_NVM3_ERR_KEY_NOT_FOUND) {
78+
return;
79+
}
80+
81+
// Initialize the object if it's currently non-existent
82+
if (status == ECODE_NVM3_ERR_KEY_NOT_FOUND) {
83+
memset(object_cache, 0xFFu, NVM3_OBJECT_SIZE);
84+
}
85+
86+
// Update the requested value
87+
object_cache[data_idx] = value;
88+
89+
// Write the object back to NVM3
90+
nvm3_writeData(nvm3_defaultHandle, object_idx, object_cache, NVM3_OBJECT_SIZE);
91+
92+
// Do repacking if needed
93+
if (nvm3_repackNeeded(nvm3_defaultHandle)) {
94+
nvm3_repack(nvm3_defaultHandle);
95+
}
96+
}
97+
98+
uint16_t eeprom_get_length()
99+
{
100+
return NVM3_MAX_SIZE;
101+
}

cores/silabs/silabs_eeprom.h

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* This file is part of the Silicon Labs Arduino Core
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright 2024 Silicon Laboratories Inc. www.silabs.com
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "Arduino.h"
28+
29+
/**
30+
* @brief Reads a byte from the EEPROM at the specified address.
31+
*
32+
* This function reads and returns the byte stored in the EEPROM at the given address.
33+
*
34+
* @param addr The address in the EEPROM from which to read the byte.
35+
* @return The byte read from the EEPROM.
36+
*/
37+
uint8_t eeprom_read_byte(uint32_t addr);
38+
39+
/**
40+
* @brief Writes a byte to the EEPROM at the specified address.
41+
*
42+
* This function writes the given byte to the EEPROM at the specified address.
43+
*
44+
* @param addr The address in the EEPROM where the byte will be written.
45+
* @param value The byte value to be written to the EEPROM.
46+
*/
47+
void eeprom_write_byte(uint32_t addr, uint8_t value);
48+
49+
/**
50+
* @brief Gets the length of the EEPROM.
51+
*
52+
* This function returns the total number of bytes available in the EEPROM.
53+
*
54+
* @return The total number of bytes in the EEPROM.
55+
*/
56+
uint16_t eeprom_get_length();

cores/silabs/wiring_digital.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void pinMode(pin_size_t pinNumber, PinMode mode)
3939

4040
void pinMode(PinName pinNumber, PinMode pinMode)
4141
{
42-
if (!system_init_finished || pinNumber >= PIN_NAME_MAX) {
42+
if (!get_system_init_finished() || pinNumber >= PIN_NAME_MAX) {
4343
return;
4444
}
4545
GPIO_Port_TypeDef hw_port = getSilabsPortFromArduinoPin(pinNumber);
@@ -73,7 +73,7 @@ PinStatus digitalRead(pin_size_t pinNumber)
7373

7474
PinStatus digitalRead(PinName pinNumber)
7575
{
76-
if (!system_init_finished || pinNumber >= PIN_NAME_MAX) {
76+
if (!get_system_init_finished() || pinNumber >= PIN_NAME_MAX) {
7777
return PinStatus::LOW;
7878
}
7979
GPIO_Port_TypeDef hw_port = getSilabsPortFromArduinoPin(pinNumber);
@@ -93,7 +93,7 @@ void digitalWrite(pin_size_t pinNumber, PinStatus status)
9393

9494
void digitalWrite(PinName pinNumber, PinStatus status)
9595
{
96-
if (!system_init_finished || pinNumber >= PIN_NAME_MAX) {
96+
if (!get_system_init_finished() || pinNumber >= PIN_NAME_MAX) {
9797
return;
9898
}
9999
GPIO_Port_TypeDef out_port = getSilabsPortFromArduinoPin(pinNumber);

cores/silabs/wiring_private.h

-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@ extern "C" {
3131
#include "em_gpio.h"
3232
}
3333

34-
extern bool system_init_finished;
35-
3634
#endif // WIRING_PRIVATE_H

doc/bgm220explorerkit_pinout.png

11.9 KB
Loading

doc/lyra24p20.png

37 KB
Loading

doc/lyra24p20_pinout.png

164 KB
Loading
-13.8 KB
Loading

0 commit comments

Comments
 (0)