Skip to content

Merge upstream. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 9, 2024
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
2 changes: 1 addition & 1 deletion extras/fsp
17 changes: 11 additions & 6 deletions libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,19 @@ class ArduinoLEDMatrix
void off(size_t pin) {
turnLed(pin, false);
}
int begin() {
bool begin() {
bool rv = true;
uint8_t type;
uint8_t ch = FspTimer::get_available_timer(type);
int8_t ch = FspTimer::get_available_timer(type);
if(ch == -1) {
return false;
}
// TODO: avoid passing "this" argument to remove autoscroll
_ledTimer.begin(TIMER_MODE_PERIODIC, type, ch, 10000.0, 50.0, turnOnLedISR, this);
_ledTimer.setup_overflow_irq();
_ledTimer.open();
_ledTimer.start();
rv &= _ledTimer.begin(TIMER_MODE_PERIODIC, type, ch, 10000.0, 50.0, turnOnLedISR, this);
rv &= _ledTimer.setup_overflow_irq();
rv &= _ledTimer.open();
rv &= _ledTimer.start();
return rv;
}
void next() {
uint32_t frame[3];
Expand Down
10 changes: 7 additions & 3 deletions libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ int CEthernet::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway
int CEthernet::begin(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet) {
/* -------------------------------------------------------------------------- */

ni = CLwipIf::getInstance().get(NI_ETHERNET, local_ip, gateway, subnet);
if(ni == nullptr) {
return 0;
if (ni != nullptr) {
ni->config(local_ip, gateway, subnet);
} else {
ni = CLwipIf::getInstance().get(NI_ETHERNET, local_ip, gateway, subnet);
if (ni == nullptr) {
return 0;
}
}

/* If there is a local DHCP informs it of our manual IP configuration to prevent IP conflict */
Expand Down
7 changes: 2 additions & 5 deletions libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void CWifi::config(IPAddress local_ip) {
_gw[3] = 1;

_config(local_ip, _gw, _nm);
setDNS(_gw);
}

extern uint8_t *IpAddress2uint8(IPAddress a);
Expand All @@ -98,11 +99,7 @@ void CWifi::_config(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
/* -------------------------------------------------------------------------- */
_useStaticIp = local_ip != INADDR_NONE;
if(ni != nullptr) {
ni->DhcpStop();
ni->DhcpNotUsed();
IP_ADDR4(&ni->ip, local_ip[0], local_ip[1], local_ip[2], local_ip[3]);
IP_ADDR4(&ni->gw, gateway[0], gateway[1], gateway[2], gateway[3]);
IP_ADDR4(&ni->nm, subnet[0], subnet[1], subnet[2], subnet[3]);
ni->config(local_ip, gateway, subnet);
}
else {
CNetIf::default_ip = local_ip;
Expand Down
5 changes: 5 additions & 0 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ uint8_t TwoWire::read_from(uint8_t address, uint8_t* data, uint8_t length, unsig
if(bus_status == WIRE_STATUS_RX_COMPLETED) {
return length;
}

if(bus_status == WIRE_STATUS_UNSET) {
m_abort(&m_i2c_ctrl);
}

return 0; /* ???????? return value ??????? */
}
Expand Down Expand Up @@ -518,6 +522,7 @@ uint8_t TwoWire::write_to(uint8_t address, uint8_t* data, uint8_t length, unsign
}
else if(bus_status == WIRE_STATUS_UNSET) {
rv = END_TX_TIMEOUT;
m_abort(&m_i2c_ctrl);
}
/* as far as I know is impossible to distinguish between NACK on ADDRESS and
NACK on DATA */
Expand Down
18 changes: 18 additions & 0 deletions libraries/lwIpWrapper/src/CNetIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,24 @@ void CNetIf::setLinkDown()
netif_set_down(&ni);
}

/* -------------------------------------------------------------------------- */
void CNetIf::config(IPAddress _ip, IPAddress _gw, IPAddress _nm)
{
DhcpStop();
DhcpNotUsed();

IP_ADDR4(&ip, _ip[0], _ip[1], _ip[2], _ip[3]);
IP_ADDR4(&nm, _nm[0], _nm[1], _nm[2], _nm[3]);
IP_ADDR4(&gw, _gw[0], _gw[1], _gw[2], _gw[3]);

netif_set_addr(&ni, &ip, &nm, &gw);

if (netif_is_link_up(&ni)) {
netif_set_down(&ni);
netif_set_up(&ni);
}
}

/* ########################################################################## */
/* ETHERNET NETWORK INTERFACE CLASS */
/* ########################################################################## */
Expand Down
2 changes: 2 additions & 0 deletions libraries/lwIpWrapper/src/CNetIf.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class CNetIf {
uint32_t getNmAdd() { return ip4_addr_get_u32(&(ni.netmask)); }
uint32_t getGwAdd() { return ip4_addr_get_u32(&(ni.gw)); }

void config(IPAddress _ip, IPAddress _gw, IPAddress _nm);

void setHostname(const char* name)
{
memset(hostname, 0x00, MAX_HOSTNAME_DIM);
Expand Down
Binary file modified variants/MINIMA/libs/libfsp.a
Binary file not shown.
Binary file modified variants/PORTENTA_C33/libs/libfsp.a
Binary file not shown.
Binary file modified variants/UNOWIFIR4/libs/libfsp.a
Binary file not shown.