Skip to content

Commit f34e945

Browse files
authored
Merge pull request #4 from arduino/main
Merge upstream.
2 parents de98096 + 923feca commit f34e945

File tree

10 files changed

+46
-15
lines changed

10 files changed

+46
-15
lines changed

extras/fsp

libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,19 @@ class ArduinoLEDMatrix
169169
void off(size_t pin) {
170170
turnLed(pin, false);
171171
}
172-
int begin() {
172+
bool begin() {
173+
bool rv = true;
173174
uint8_t type;
174-
uint8_t ch = FspTimer::get_available_timer(type);
175+
int8_t ch = FspTimer::get_available_timer(type);
176+
if(ch == -1) {
177+
return false;
178+
}
175179
// TODO: avoid passing "this" argument to remove autoscroll
176-
_ledTimer.begin(TIMER_MODE_PERIODIC, type, ch, 10000.0, 50.0, turnOnLedISR, this);
177-
_ledTimer.setup_overflow_irq();
178-
_ledTimer.open();
179-
_ledTimer.start();
180+
rv &= _ledTimer.begin(TIMER_MODE_PERIODIC, type, ch, 10000.0, 50.0, turnOnLedISR, this);
181+
rv &= _ledTimer.setup_overflow_irq();
182+
rv &= _ledTimer.open();
183+
rv &= _ledTimer.start();
184+
return rv;
180185
}
181186
void next() {
182187
uint32_t frame[3];

libraries/Ethernet/src/Ethernet.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ int CEthernet::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway
5656
int CEthernet::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) {
5757
/* -------------------------------------------------------------------------- */
5858

59-
ni = CLwipIf::getInstance().get(NI_ETHERNET, local_ip, gateway, subnet);
60-
if(ni == nullptr) {
61-
return 0;
59+
if (ni != nullptr) {
60+
ni->config(local_ip, gateway, subnet);
61+
} else {
62+
ni = CLwipIf::getInstance().get(NI_ETHERNET, local_ip, gateway, subnet);
63+
if (ni == nullptr) {
64+
return 0;
65+
}
6266
}
6367

6468
/* If there is a local DHCP informs it of our manual IP configuration to prevent IP conflict */

libraries/WiFi/src/WiFi.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void CWifi::config(IPAddress local_ip) {
8989
_gw[3] = 1;
9090

9191
_config(local_ip, _gw, _nm);
92+
setDNS(_gw);
9293
}
9394

9495
extern uint8_t *IpAddress2uint8(IPAddress a);
@@ -98,11 +99,7 @@ void CWifi::_config(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
9899
/* -------------------------------------------------------------------------- */
99100
_useStaticIp = local_ip != INADDR_NONE;
100101
if(ni != nullptr) {
101-
ni->DhcpStop();
102-
ni->DhcpNotUsed();
103-
IP_ADDR4(&ni->ip, local_ip[0], local_ip[1], local_ip[2], local_ip[3]);
104-
IP_ADDR4(&ni->gw, gateway[0], gateway[1], gateway[2], gateway[3]);
105-
IP_ADDR4(&ni->nm, subnet[0], subnet[1], subnet[2], subnet[3]);
102+
ni->config(local_ip, gateway, subnet);
106103
}
107104
else {
108105
CNetIf::default_ip = local_ip;

libraries/Wire/Wire.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ uint8_t TwoWire::read_from(uint8_t address, uint8_t* data, uint8_t length, unsig
486486
if(bus_status == WIRE_STATUS_RX_COMPLETED) {
487487
return length;
488488
}
489+
490+
if(bus_status == WIRE_STATUS_UNSET) {
491+
m_abort(&m_i2c_ctrl);
492+
}
489493

490494
return 0; /* ???????? return value ??????? */
491495
}
@@ -518,6 +522,7 @@ uint8_t TwoWire::write_to(uint8_t address, uint8_t* data, uint8_t length, unsign
518522
}
519523
else if(bus_status == WIRE_STATUS_UNSET) {
520524
rv = END_TX_TIMEOUT;
525+
m_abort(&m_i2c_ctrl);
521526
}
522527
/* as far as I know is impossible to distinguish between NACK on ADDRESS and
523528
NACK on DATA */

libraries/lwIpWrapper/src/CNetIf.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,24 @@ void CNetIf::setLinkDown()
12711271
netif_set_down(&ni);
12721272
}
12731273

1274+
/* -------------------------------------------------------------------------- */
1275+
void CNetIf::config(IPAddress _ip, IPAddress _gw, IPAddress _nm)
1276+
{
1277+
DhcpStop();
1278+
DhcpNotUsed();
1279+
1280+
IP_ADDR4(&ip, _ip[0], _ip[1], _ip[2], _ip[3]);
1281+
IP_ADDR4(&nm, _nm[0], _nm[1], _nm[2], _nm[3]);
1282+
IP_ADDR4(&gw, _gw[0], _gw[1], _gw[2], _gw[3]);
1283+
1284+
netif_set_addr(&ni, &ip, &nm, &gw);
1285+
1286+
if (netif_is_link_up(&ni)) {
1287+
netif_set_down(&ni);
1288+
netif_set_up(&ni);
1289+
}
1290+
}
1291+
12741292
/* ########################################################################## */
12751293
/* ETHERNET NETWORK INTERFACE CLASS */
12761294
/* ########################################################################## */

libraries/lwIpWrapper/src/CNetIf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ class CNetIf {
189189
uint32_t getNmAdd() { return ip4_addr_get_u32(&(ni.netmask)); }
190190
uint32_t getGwAdd() { return ip4_addr_get_u32(&(ni.gw)); }
191191

192+
void config(IPAddress _ip, IPAddress _gw, IPAddress _nm);
193+
192194
void setHostname(const char* name)
193195
{
194196
memset(hostname, 0x00, MAX_HOSTNAME_DIM);

variants/MINIMA/libs/libfsp.a

-1.65 MB
Binary file not shown.

variants/PORTENTA_C33/libs/libfsp.a

-4.05 MB
Binary file not shown.

variants/UNOWIFIR4/libs/libfsp.a

-1.65 MB
Binary file not shown.

0 commit comments

Comments
 (0)