Skip to content
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
1 change: 1 addition & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ nano_matter.menu.link_mode.static.upload.extension=bin-zsk.bin
nano_matter.build.zephyr_target=arduino_nano_matter
nano_matter.build.zephyr_args=
nano_matter.build.zephyr_hals=hal_silabs
nano_matter.build.artifact=zephyr_main
nano_matter.build.variant=arduino_nano_matter_mgm240sd22vna
nano_matter.build.mcu=cortex-m33
nano_matter.build.fpu=-mfpu=fpv4-sp-d16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "stdint.h"

__attribute__((packed)) struct bootanimation_user_data {
struct bootanimation_user_data {
size_t magic; // must be 0xBA for bootanimation
size_t len_loop;
size_t len_end;
size_t empty;
uint8_t *buf_loop;
};
} __attribute__((packed));

unsigned int bootanimation_end_len = 3120;
unsigned int bootanimation_len = 18720;
Expand Down
2 changes: 1 addition & 1 deletion libraries/Arduino_LED_Matrix/library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=This library provides a simple interface for controlling the LED matri
category=Communication
url=https://www.arduino.cc/
architectures=*
depends=
depends=ArduinoGraphics
10 changes: 7 additions & 3 deletions libraries/Camera/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ uint32_t FrameBuffer::getBufferSize() {
if (this->vbuf) {
return this->vbuf->bytesused;
}

return 0;
}

uint8_t *FrameBuffer::getBuffer() {
if (this->vbuf) {
return this->vbuf->buffer;
}

return NULL;
}

Camera::Camera() : vdev(NULL), byte_swap(false), yuv_to_gray(false) {
Camera::Camera() : byte_swap(false), yuv_to_gray(false), vdev(NULL) {
for (size_t i = 0; i < ARRAY_SIZE(this->vbuf); i++) {
this->vbuf[i] = NULL;
}
Expand Down Expand Up @@ -74,13 +78,13 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
return false;
}

for (size_t i = 0; caps.format_caps[i].pixelformat != NULL; i++) {
for (size_t i = 0; caps.format_caps[i].pixelformat != 0; i++) {
const struct video_format_cap *fcap = &caps.format_caps[i];
if (fcap->width_min == width && fcap->height_min == height &&
fcap->pixelformat == pixformat) {
break;
}
if (caps.format_caps[i + 1].pixelformat == NULL) {
if (caps.format_caps[i + 1].pixelformat == 0) {
Serial.println("The specified format is not supported");
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/Ethernet/examples/WebClient/WebClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ void loop() {
Serial.print("Received ");
Serial.print(byteCount);
Serial.print(" bytes in ");
float seconds = (float)(endMicros - beginMicros) / 1000000.0;
float seconds = (endMicros - beginMicros) / 1000000.0f;
Serial.print(seconds, 4);
float rate = (float)byteCount / seconds / 1000.0;
Serial.print(", rate = ");
float rate = byteCount / 1000.0f / seconds;
Serial.print(rate);
Serial.print(" kbytes/second");
Serial.println();
Expand Down
21 changes: 15 additions & 6 deletions libraries/SocketWrapper/SocketHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ void NetworkInterface::event_handler(struct net_mgmt_event_callback *cb, uint64_
struct net_if *iface) {
int i = 0;

ARG_UNUSED(cb);

if (mgmt_event != NET_EVENT_IPV4_ADDR_ADD) {
return;
}
Expand Down Expand Up @@ -38,6 +40,10 @@ void NetworkInterface::option_handler(struct net_dhcpv4_option_callback *cb, siz
enum net_dhcpv4_msg_type msg_type, struct net_if *iface) {
char buf[NET_IPV4_ADDR_LEN];

ARG_UNUSED(length);
ARG_UNUSED(msg_type);
ARG_UNUSED(iface);

LOG_INF("DHCP Option %d: %s", cb->option, net_addr_ntop(AF_INET, cb->data, buf, sizeof(buf)));
}

Expand All @@ -58,7 +64,7 @@ int NetworkInterface::dhcp() {
return 0;
}

void NetworkInterface::enable_dhcpv4_server(struct net_if *netif, char *_netmask) {
void NetworkInterface::enable_dhcpv4_server(struct net_if *netif, const char *_netmask) {
static struct in_addr addr;
static struct in_addr netmaskAddr;

Expand Down Expand Up @@ -140,7 +146,7 @@ void NetworkInterface::setMACAddress(const uint8_t *mac) {
net_if_up(netif); // Bring the interface back up after changing the MAC address
}

int NetworkInterface::begin(bool blocking, uint32_t additional_event_mask) {
int NetworkInterface::begin(bool blocking, uint64_t additional_event_mask) {
dhcp();
int ret = net_mgmt_event_wait_on_iface(netif, NET_EVENT_IPV4_ADDR_ADD | additional_event_mask,
NULL, NULL, NULL, blocking ? K_FOREVER : K_SECONDS(1));
Expand All @@ -157,7 +163,6 @@ void NetworkInterface::config(const IPAddress ip, const IPAddress dns_server,
setDnsServerIP(dns_server);
setGatewayIP(gateway);
setSubnetMask(subnet);
return;
}

void NetworkInterface::setLocalIP(const IPAddress ip) {
Expand All @@ -169,13 +174,17 @@ void NetworkInterface::setLocalIP(const IPAddress ip) {
return;
}
LOG_INF("Local IP address set: %s", ip.toString().c_str());
return;
}

void NetworkInterface::setSubnetMask(const IPAddress subnet) {
struct in_addr netmask_addr;
netmask_addr.s_addr = subnet;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// TODO: store the address that was manually set and replace this call
// with net_if_ipv4_set_netmask_by_addr
net_if_ipv4_set_netmask(netif, &netmask_addr);
#pragma GCC diagnostic pop
LOG_INF("Subnet mask set: %s", subnet.toString().c_str());
return;
}
Expand All @@ -185,9 +194,9 @@ void NetworkInterface::setGatewayIP(const IPAddress gateway) {
gw_addr.s_addr = gateway;
net_if_ipv4_set_gw(netif, &gw_addr);
LOG_INF("Gateway IP set: %s", gateway.toString().c_str());
return;
}

void NetworkInterface::setDnsServerIP(const IPAddress dns_server) {
return; // DNS server dynamic configuration is not supported
// DNS server dynamic configuration is not supported
ARG_UNUSED(dns_server);
}
4 changes: 2 additions & 2 deletions libraries/SocketWrapper/SocketHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NetworkInterface {
protected:
struct net_if *netif = nullptr;
int dhcp();
void enable_dhcpv4_server(struct net_if *netif, char *_netmask = "255.255.255.0");
void enable_dhcpv4_server(struct net_if *netif, const char *_netmask = "255.255.255.0");

public:
NetworkInterface() {
Expand All @@ -57,7 +57,7 @@ class NetworkInterface {
void setGatewayIP(const IPAddress gateway);
void setDnsServerIP(const IPAddress dns_server);

int begin(bool blocking = true, uint32_t additional_event_mask = 0);
int begin(bool blocking = true, uint64_t additional_event_mask = 0);

bool disconnect();
};
2 changes: 2 additions & 0 deletions libraries/SocketWrapper/ZephyrServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class ZephyrServer : public arduino::Server, ZephyrSocketWrapper {
}

ZephyrClient accept(uint8_t *status = nullptr) {
ARG_UNUSED(status);

ZephyrClient client;
int sock = ZephyrSocketWrapper::accept();
client.setSocket(sock);
Expand Down
2 changes: 1 addition & 1 deletion libraries/SocketWrapper/ZephyrUDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class ZephyrUDP : public arduino::UDP {
IPAddress _send_to_ip;
uint16_t _send_to_port;
std::vector<uint8_t> _tx_data;
int _rx_pkt_list_size = 10;
size_t _rx_pkt_list_size = 10;

/* UDP RECEPTION */
class UdpRxPacket {
Expand Down
3 changes: 3 additions & 0 deletions libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ String WiFiClass::firmwareVersion() {

int WiFiClass::begin(const char *ssid, const char *passphrase, wl_enc_type security,
bool blocking) {
ARG_UNUSED(security); // currently unsupported

sta_iface = net_if_get_wifi_sta();
netif = sta_iface;
sta_config.ssid = (const uint8_t *)ssid;
Expand Down Expand Up @@ -82,6 +84,7 @@ int WiFiClass::status() {

int8_t WiFiClass::scanNetworks() {
// TODO: borrow code from mbed core for scan results handling
return 0;
}

char *WiFiClass::SSID() {
Expand Down
20 changes: 18 additions & 2 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

// Helper function to get ZephyrI2C instance from config pointer.
static arduino::ZephyrI2C *getInstance(struct i2c_target_config *config) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
return reinterpret_cast<arduino::ZephyrI2C *>(reinterpret_cast<char *>(config) -
offsetof(arduino::ZephyrI2C, i2c_cfg));
#pragma GCC diagnostic pop
}

static int i2c_target_stop_cb(struct i2c_target_config *config) {
Expand Down Expand Up @@ -48,7 +51,7 @@ static struct i2c_target_callbacks target_callbacks = {
.stop = i2c_target_stop_cb,
};

arduino::ZephyrI2C::ZephyrI2C(const struct device *i2c) : i2c_dev(i2c), i2c_cfg({0}) {
arduino::ZephyrI2C::ZephyrI2C(const struct device *i2c) : i2c_cfg({0}), i2c_dev(i2c) {
ring_buf_init(&txRingBuffer.rb, sizeof(txRingBuffer.buffer), txRingBuffer.buffer);
ring_buf_init(&rxRingBuffer.rb, sizeof(rxRingBuffer.buffer), rxRingBuffer.buffer);
}
Expand Down Expand Up @@ -100,6 +103,8 @@ uint8_t arduino::ZephyrI2C::endTransmission(bool stopBit) {
size_t max = ring_buf_capacity_get(&txRingBuffer.rb);
size_t len = ring_buf_get_claim(&txRingBuffer.rb, &buf, max);

ARG_UNUSED(stopBit);

ret = i2c_write(i2c_dev, buf, len, _address);

// Must be called even if 0 bytes claimed.
Expand All @@ -115,8 +120,11 @@ uint8_t arduino::ZephyrI2C::endTransmission(void) {
size_t arduino::ZephyrI2C::requestFrom(uint8_t address, size_t len_in, bool stopBit) {
int ret = -EIO;
uint8_t *buf = NULL;
size_t len = ring_buf_put_claim(&rxRingBuffer.rb, &buf, len_in);
size_t len;

ARG_UNUSED(stopBit);

len = ring_buf_put_claim(&rxRingBuffer.rb, &buf, len_in);
if (len && buf) {
ret = i2c_read(i2c_dev, buf, len, address);
}
Expand Down Expand Up @@ -171,6 +179,8 @@ void arduino::ZephyrI2C::onRequest(voidFuncPtr cb) {
}

int arduino::ZephyrI2C::writeRequestedCallback(struct i2c_target_config *config) {
ARG_UNUSED(config);

// Reset the buffer on write requests.
ring_buf_reset(&rxRingBuffer.rb);
return 0;
Expand All @@ -180,6 +190,8 @@ int arduino::ZephyrI2C::writeReceivedCallback(struct i2c_target_config *config,
size_t len = ring_buf_size_get(&rxRingBuffer.rb);
size_t max = ring_buf_capacity_get(&rxRingBuffer.rb);

ARG_UNUSED(config);

// If the buffer is about to overflow, invoke the callback
// with the current length.
if (onReceiveCb && ((len + 1) > max)) {
Expand All @@ -201,6 +213,8 @@ int arduino::ZephyrI2C::readRequestedCallback(struct i2c_target_config *config,
}

int arduino::ZephyrI2C::readProcessedCallback(struct i2c_target_config *config, uint8_t *val) {
ARG_UNUSED(config);

*val = 0xFF;
ring_buf_get(&txRingBuffer.rb, val, 1);
// Returning a negative value here is not handled gracefully and
Expand All @@ -209,6 +223,8 @@ int arduino::ZephyrI2C::readProcessedCallback(struct i2c_target_config *config,
}

int arduino::ZephyrI2C::stopCallback(struct i2c_target_config *config) {
ARG_UNUSED(config);

// If the RX buffer is not empty invoke the callback with the
// remaining data length.
if (onReceiveCb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ void frameBuffer() {
// simply initialize the memory as

SDRAM.begin(SDRAM_START_ADDRESS + 2 * 1024 * 1024);
// 2MB of contiguous memory available at the beginning

// 2MB of contiguous memory available at the beginning
uint32_t* framebuffer = (uint32_t*)SDRAM_START_ADDRESS;

// We can't allocate anymore the huge 7MB array

// We can't allocate the huge 7MB array anymore
uint8_t* myVeryBigArray = (uint8_t*)SDRAM.malloc(7 * 1024 * 1024);
if (myVeryBigArray == NULL) {
Serial.println("Oops, too big :)");
}

ARG_UNUSED(framebuffer); // suppress unused variable warning
}

void setup() {
Expand All @@ -65,4 +65,4 @@ void setup() {

void loop() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
# Host number of completed commands does not follow normal flow control.
CONFIG_BT_BUF_CMD_TX_COUNT=10

#CONFIG_ADC=y
CONFIG_ADC=y
#CONFIG_PWM=y

CONFIG_LLEXT_STORAGE_WRITABLE=n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@

builtin-led-gpios = <&gpio0 10 0>; // TODO: fixme: use real i2c led (will need some magic like PureAnalog)

adc-pin-gpios = <&gpio0 2 0>, // 10: A0 (AIN0)
<&gpio0 30 0>; // 11: A1 (AIN6)

io-channels = <&adc 0>,
<&adc 6>;

serials = <&uart0>;
i2cs = <&i2c1>;
spis = <&spi1>;
};
};
};
Loading