forked from SiliconLabs/arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7200168
commit 956de5d
Showing
12,124 changed files
with
5,145,077 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.a filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_store | ||
package/gen | ||
package/gen_gsdk* | ||
package/install_host* | ||
installed.json |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Arduino Core code owners | ||
* @tajozsi |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
4,260 changes: 4,260 additions & 0 deletions
4,260
bootloaders/bgm220-explorer-kit-ble-bootloader-apploader.hex
Large diffs are not rendered by default.
Oops, something went wrong.
4,455 changes: 4,455 additions & 0 deletions
4,455
bootloaders/sparkfun-thingplus-ble-bootloader-apploader.hex
Large diffs are not rendered by default.
Oops, something went wrong.
680 changes: 680 additions & 0 deletions
680
bootloaders/sparkfun-thingplus-matter-bootloader-storage-internal-single-512k.hex
Large diffs are not rendered by default.
Oops, something went wrong.
4,398 changes: 4,398 additions & 0 deletions
4,398
bootloaders/xg24-explorer-kit-ble-bootloader-apploader.hex
Large diffs are not rendered by default.
Oops, something went wrong.
674 changes: 674 additions & 0 deletions
674
bootloaders/xg24-explorer-kit-bootloader-storage-internal-single-512k.hex
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* This file is part of the Silicon Labs Arduino Core | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
#ifndef ARDUINO_H | ||
#define ARDUINO_H | ||
|
||
#include <cmath> | ||
#include <algorithm> | ||
#include "FreeRTOS.h" | ||
#include "FreeRTOSConfig.h" | ||
#include "task.h" | ||
#include "arduino_variant.h" | ||
|
||
extern "C" { | ||
#include "sl_component_catalog.h" | ||
#include "sl_system_init.h" | ||
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) | ||
#include "sl_power_manager.h" | ||
#endif // SL_CATALOG_POWER_MANAGER_PRESENT | ||
#if defined(SL_CATALOG_KERNEL_PRESENT) | ||
#include "sl_system_kernel.h" | ||
#else // SL_CATALOG_KERNEL_PRESENT | ||
#include "sl_system_process_action.h" | ||
#endif // SL_CATALOG_KERNEL_PRESENT | ||
|
||
#include "em_common.h" | ||
#include "app_assert.h" | ||
#include "sl_bluetooth.h" | ||
#include "em_gpio.h" | ||
#include "app_log.h" | ||
#include "psa_crypto_core.h" | ||
#include "sl_udelay.h" | ||
} | ||
|
||
#ifdef ARDUINO_MATTER | ||
#include "efr32_utils.h" | ||
#endif // ARDUINO_MATTER | ||
|
||
typedef uint16_t word; | ||
typedef uint8_t byte; | ||
typedef bool boolean; | ||
|
||
#include "wiring.h" | ||
#include "wiring_private.h" | ||
#include "pins_arduino.h" | ||
#include "binary.h" | ||
#include "WCharacter.h" | ||
#include "WMath.h" | ||
#include "stdlib_noniso.h" | ||
#include "WString.h" | ||
#include "HardwareSerial.h" | ||
#include "Wire.h" | ||
#include "SPI.h" | ||
#include "adc.h" | ||
#include "pwm.h" | ||
#include "silabs_additional.h" | ||
|
||
#ifdef NUM_DAC_HW | ||
#include "dac.h" | ||
#endif // NUM_DAC_HW | ||
|
||
using std::round; | ||
using std::isinf; | ||
using std::isnan; | ||
using std::min; | ||
using std::max; | ||
using std::abs; | ||
|
||
#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) | ||
#define radians(deg) ((deg) * DEG_TO_RAD) | ||
#define degrees(rad) ((rad) * RAD_TO_DEG) | ||
#define sq(x) ((x) * (x)) | ||
|
||
#define bit(b) (1UL << (b)) | ||
#define lowByte(w) ((uint8_t) ((w) & 0xff)) | ||
#define highByte(w) ((uint8_t) ((w) >> 8)) | ||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01) | ||
#define bitSet(value, bit) ((value) |= (1UL << (bit))) | ||
#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) | ||
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) | ||
|
||
#define interrupts() __enable_irq() | ||
#define noInterrupts() __disable_irq() | ||
|
||
extern HardwareSerial Serial; | ||
extern TwoWire Wire; | ||
extern SPIClass SPI; | ||
extern AdcClass ADC; | ||
extern PwmClass PWM; | ||
|
||
#if (NUM_HW_SERIAL > 1) | ||
extern HardwareSerial Serial1; | ||
#endif // (NUM_HW_SERIAL > 1) | ||
|
||
#if (NUM_HW_SPI > 1) | ||
extern SPIClass SPI1; | ||
#endif // (NUM_HW_SPI > 1) | ||
|
||
#if (NUM_DAC_HW > 0) | ||
extern DacClass DAC_0; | ||
#endif // (NUM_DAC_HW > 0) | ||
|
||
#if (NUM_DAC_HW > 1) | ||
extern DacClass DAC_1; | ||
#endif // (NUM_DAC_HW > 1) | ||
|
||
void setup(); | ||
void loop(); | ||
|
||
#endif // ARDUINO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* This file is part of the Silicon Labs Arduino Core | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright 2023 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 <cstdarg> | ||
#include "HardwareSerial.h" | ||
#include "em_usart.h" | ||
#include "sl_iostream.h" | ||
#include "sl_iostream_init_usart_instances.h" | ||
|
||
HardwareSerial::HardwareSerial(sl_iostream_t* stream, | ||
sl_iostream_uart_t* instance, | ||
void(*baud_rate_set_fn)(uint32_t baudrate), | ||
void(*init_fn)(void), | ||
void(*deinit_fn)(void), | ||
void(*serial_event_fn)(void)) : | ||
serial_mutex(nullptr), | ||
initialized(true) | ||
{ | ||
this->serial_mutex = xSemaphoreCreateMutexStatic(&this->serial_mutex_buf); | ||
configASSERT(this->serial_mutex); | ||
this->baud_rate_set_fn = baud_rate_set_fn; | ||
this->init_fn = init_fn; | ||
this->deinit_fn = deinit_fn; | ||
this->stream_handle = stream; | ||
this->instance_handle = instance; | ||
this->serial_event_fn = serial_event_fn; | ||
} | ||
|
||
void HardwareSerial::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 | ||
} | ||
|
||
void HardwareSerial::begin(unsigned long baudrate, uint16_t config) | ||
{ | ||
(void)config; | ||
this->begin(baudrate); | ||
} | ||
|
||
void HardwareSerial::end() | ||
{ | ||
this->deinit_fn(); | ||
this->initialized = false; | ||
} | ||
|
||
int HardwareSerial::available(void) | ||
{ | ||
task(); | ||
return rx_buf.available(); | ||
} | ||
|
||
int HardwareSerial::peek(void) | ||
{ | ||
return rx_buf.peek(); | ||
} | ||
|
||
int HardwareSerial::read(void) | ||
{ | ||
task(); | ||
return rx_buf.read_char(); | ||
} | ||
|
||
void HardwareSerial::flush(void) | ||
{ | ||
; | ||
} | ||
|
||
size_t HardwareSerial::write(uint8_t data) | ||
{ | ||
return this->write(&data, 1); | ||
} | ||
|
||
size_t HardwareSerial::write(const uint8_t* data, size_t size) | ||
{ | ||
if (!this->initialized) { | ||
return 0; | ||
} | ||
sl_iostream_write(this->stream_handle, data, size); | ||
return size; | ||
} | ||
|
||
void HardwareSerial::printf(const char *fmt, ...) | ||
{ | ||
char message[this->printf_buffer_size]; | ||
va_list args; | ||
va_start(args, fmt); | ||
vsnprintf(message, sizeof(message), fmt, args); | ||
va_end(args); | ||
this->write((uint8_t*)message, strlen(message)); | ||
} | ||
|
||
HardwareSerial::operator bool() | ||
{ | ||
return true; | ||
} | ||
|
||
void HardwareSerial::task() | ||
{ | ||
if (!this->initialized) { | ||
return; | ||
} | ||
xSemaphoreTake(this->serial_mutex, portMAX_DELAY); | ||
|
||
uint8_t buf[64]; | ||
size_t bytes_read = 0; | ||
// Set the iostream read API to non-blocking mode | ||
sl_iostream_uart_set_read_block(this->instance_handle, false); | ||
sl_iostream_read(this->stream_handle, buf, sizeof(buf), &bytes_read); | ||
if (bytes_read > 0) { | ||
for (uint8_t i = 0; i < bytes_read; i++) { | ||
rx_buf.store_char(buf[i]); | ||
} | ||
} | ||
|
||
xSemaphoreGive(this->serial_mutex); | ||
} | ||
|
||
void HardwareSerial::handleSerialEvent() | ||
{ | ||
if (this->available()) { | ||
this->serial_event_fn(); | ||
} | ||
} | ||
|
||
__attribute__((weak)) void serialEvent(void) | ||
{ | ||
; | ||
} | ||
|
||
HardwareSerial Serial(sl_serial_stream_handle, | ||
sl_serial_instance_handle, | ||
sl_serial_set_baud_rate, | ||
sl_serial_init, | ||
sl_serial_deinit, | ||
serialEvent); | ||
|
||
#if (NUM_HW_SERIAL > 1) | ||
__attribute__((weak)) void serialEvent1(void) | ||
{ | ||
; | ||
} | ||
|
||
HardwareSerial Serial1(sl_serial1_stream_handle, | ||
sl_serial1_instance_handle, | ||
sl_serial1_set_baud_rate, | ||
sl_serial1_init, | ||
sl_serial1_deinit, | ||
serialEvent1); | ||
#endif // #if (NUM_HW_SERIAL > 1) |
Oops, something went wrong.