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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

|PERIPHERAL |SILK |BREAKOUT |uC PIN |API |NOTES |
|---------------|---------------|---------------|---------------|---------------|---------------|
|ETHERNET | | | |TODO | |
|ETHERNET | | | |Breakout.Ethernet| |
| |D+ |ETHERNET_DP | | |Not available as GPIO|
| |D- |ETHERNET_DN | | |Not available as GPIO|
| |GND | | | | |
Expand Down Expand Up @@ -109,7 +109,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
| |REFN |ANALOG_REFN | | | |
| |REFP |ANALOG_REFP | | | |
| |A0 |ANALOG_A0 |PA_0_C | | |
| |A1 |ANALOG_A1 |PA_1_C | | |
| |A1 |ANALOG_A1 |PA_1_C | |Not available as GPIO if ETHERNET is used|
| |A2 |ANALOG_A2 |PC_2_C | | |
| |A3 |ANALOG_A3 |PC_3_C | | |
| |A4 |ANALOG_A4 |PC_2 | |As GPIO internally connected to A2|
Expand Down
118 changes: 118 additions & 0 deletions examples/BreakoutWebServer/BreakoutWebServer.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
Web Server

A simple web server that shows the value of the analog input pins.
using PortentaBreakout.

Circuit:
* PortetaBreakout

created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
modified 02 Sept 2015
by Arturo Guadalupi

*/

#include <PortentaBreakoutCarrier.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

// PortentaBreakout analogPin table
breakoutPin analogPin[] = {ANALOG_A0, ANALOG_A0, ANALOG_A2, ANALOG_A3,
ANALOG_A4, ANALOG_A5, ANALOG_A6, ANALOG_A7};

void setup() {

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Ethernet WebServer Example");

// start the Ethernet connection and the server:
Breakout.Ethernet.begin(mac);

// Check for Ethernet hardware present
if (Breakout.Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Breakout.Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}

// start the server
server.begin();
Serial.print("server is at ");
Serial.println(Breakout.Ethernet.localIP());
}


void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 8; analogChannel++) {
int sensorReading = Breakout.analogRead(analogPin[analogChannel]);
Serial.println(SYSCFG->PMCR);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
6 changes: 5 additions & 1 deletion src/Arduino_PortentaBreakoutCarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <Wire.h>
#include <SPI.h>
#include <PDM.h>
#include <Portenta_Ethernet.h>
#include <Ethernet.h>
#include "utility/Analog/Analog.h"

#define LAST_ARDUINO_PIN_NUMBER LEDB + 1
Expand Down Expand Up @@ -249,6 +251,7 @@ class BreakoutCarrierClass {
UART UART3;
MbedSPI SPI_0;
PDMClass PDM;
arduino::EthernetClass Ethernet;
BreakoutCarrierClass() : I2C_0(PH_8,PH_7),
I2C_1(PB_7,PB_6),
I2C_2(PH_12,PH_11),
Expand All @@ -257,7 +260,8 @@ class BreakoutCarrierClass {
UART2(PG_14, PG_9, NC, NC),
UART3(PJ_8, PJ_9, NC, NC),
SPI_0(PC_2, PC_3, PI_1),
PDM(PB_2, PE_2, NC)
PDM(PB_2, PE_2, NC),
Ethernet()
{
}
};
Expand Down