Skip to content

Commit a98a47d

Browse files
committed
Merge remote-tracking branch 'refs/remotes/rogerclarkmelbourne/master'
2 parents efbbe6a + 18f2233 commit a98a47d

53 files changed

Lines changed: 6941 additions & 16 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

STM32F1/boards.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mapleRET6.upload.protocol=maple_dfu
7979
mapleRET6.upload.maximum_size=262144
8080
mapleRET6.upload.use_1200bps_touch=false
8181
mapleRET6.upload.file_type=bin
82-
mapleRET6.upload.ram.maximum_size=492152
82+
mapleRET6.upload.ram.maximum_size=49152
8383
mapleRET6.upload.flash.maximum_size=262144
8484
mapleRET6.upload.usbID=1EAF:0003
8585
mapleRET6.upload.altID=1
@@ -354,7 +354,7 @@ genericSTM32F103V.build.error_led_pin=6
354354
genericSTM32F103V.menu.device_variant.STM32F103VC=STM32F103VC
355355
genericSTM32F103V.menu.device_variant.STM32F103VC.build.cpu_flags=-DMCU_STM32F103VC
356356
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.maximum_size=262144
357-
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.ram.maximum_size=492152
357+
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.ram.maximum_size=49152
358358
genericSTM32F103V.menu.device_variant.STM32F103VC.upload.flash.maximum_size=262144
359359
genericSTM32F103V.menu.device_variant.STM32F103VC.build.ldscript=ld/stm32f103vc.ld
360360

@@ -413,7 +413,7 @@ genericSTM32F103Z.upload.auto_reset=true
413413
genericSTM32F103Z.menu.device_variant.STM32F103ZC=STM32F103ZC
414414
genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.cpu_flags=-DMCU_STM32F103ZC
415415
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.maximum_size=262144
416-
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.ram.maximum_size=492152
416+
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.ram.maximum_size=49152
417417
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.flash.maximum_size=262144
418418
genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.ldscript=ld/stm32f103zc.ld
419419

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ void HardwareSerial::end(void) {
159159
*/
160160

161161
int HardwareSerial::read(void) {
162-
// Block until a byte becomes available, to save user confusion.
163-
while (!this->available())
164-
;
165-
return usart_getc(this->usart_device);
162+
if(usart_data_available(usart_device) > 0) {
163+
return usart_getc(usart_device);
164+
} else {
165+
return -1;
166+
}
166167
}
167168

168169
int HardwareSerial::available(void) {
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
W5x00 ethernet library for STM32F103 micro-controllers
2+
----
3+
4+
That library has been ported from the **WIZnet WIZ_Ethernet_Library**, to STM32F103 microcontrollers.
5+
The library supports **W5100** and **W5500** Ethernet controllers. The source code has been modified to support the **W5200** too, but has not been tested (yet) on a real W5200 controller.
6+
7+
Ported to STM32F103 on 23 Aug 2015 by **Vassilis Serasidis**
8+
9+
Library installation
10+
----
11+
### *Install the library globally* ###
12+
13+
14+
* Unzip the file **Ethernet_STM-master.zip** into your Arduino IDE directory
15+
16+
> arduino\libraries
17+
18+
and rename the folder **Ethernet_STM-master** to **Ethernet_STM**
19+
20+
In this case the library can be used from the 8-bit and 32-bit Arduino boards (UNO, Nano, DUE etc) and from STM32F1 microcontroller series (for example STM32F103).
21+
22+
#### *Install the library for using it only with STM32F1 series* ###
23+
24+
* Unzip the file **Ethernet_STM-master.zip** into your Arduino IDE directory
25+
26+
> ...arduino\hardware\Arduino_STM32\STM32F1\libraries
27+
28+
and rename the folder **Ethernet_STM-master** to **Ethernet_STM**
29+
30+
31+
Selecting the Ethernet type controller (W5100, W5200 or W5500)
32+
----
33+
For selecting among those tree chips edit the file:
34+
`Ethernet_STM\src\utility\w5100.h`
35+
and comment-out only the line with the chip you want to use.
36+
37+
38+
39+
By default the **W5500** ethernet controller is selected.
40+
41+
42+
```
43+
//#define W5100_ETHERNET_SHIELD // Arduino Ethenret Shield and Compatibles ...
44+
//#define W5200_ETHERNET_SHIELD // WIZ820io, W5200 Ethernet Shield
45+
#define W5500_ETHERNET_SHIELD // WIZ550io, ioShield series of WIZnet
46+
```
47+
If you edit the **w5100.h** file, save it and re-compile your sketch.
48+
49+
Selecting W5500 Sockets number and RAM buffer amount
50+
----
51+
For selecting the Sockets number (1-8) and the RAM buffer amount (1-16 kBytes) for each Socket, edit the file:
52+
`Ethernet_STM\src\utility\w5500.h`
53+
and change the values you want.
54+
55+
```
56+
Total RAM buffer is 16 kBytes for Transmitter and 16 kBytes for receiver for 1 Socket.
57+
The Total W5500 RAM buffer is 32 kBytes (16 + 16).
58+
If you use more Sockets then the RAM buffer must be split.
59+
For example: if you use 2 Sockets then all socket must use upto 16 kBytes in total RAM.
60+
So, we have:
61+
62+
#define MAX_SOCK_NUM 2 // Select two Sockets.
63+
#define RXBUF_SIZE 8 // The Receiver buffer size will be 8 kBytes
64+
#define TXBUF_SIZE 8 // The Transmitter buffer size will be 8 kBytes
65+
66+
In total we use (2 Sockets)*(8 kBytes) for transmitter + (2 Sockets)*(8 kBytes) for receiver = 32 kBytes.
67+
68+
I would prefer to use only 1 Socket with 16 kBytes RAM buffer for transmitter and 16 kByte for receiver buffer.
69+
70+
#define MAX_SOCK_NUM 1 // Select only one Socket
71+
#define RXBUF_SIZE 16 // Select 16 kBytes Receiver RAM buffer
72+
#define TXBUF_SIZE 16 // Select 16 kBytes Transmitter RAM buffer
73+
```
74+
75+
Default settings:
76+
77+
```
78+
#define MAX_SOCK_NUM 8 // Select the number of Sockets (1-8)
79+
#define RXBUF_SIZE 2 // Select the Receiver buffer size (1 - 16 kBytes)
80+
#define TXBUF_SIZE 2 // Select the Transmitter buffer size (1 - 16 kBytes)
81+
```
82+
If you edit the **w5500.h** file, save it and re-compile your sketch.
83+
84+
Using the Ethernet_STM library
85+
----
86+
1. Choose the desired ethernet chip you want to use (W5100, W5200 or W5500) from the w5100.h file
87+
2. include this library in your sketch
88+
89+
`#include <Ethernet_STM.h>`
90+
91+
All functions / commands have the same syntax with the stock Arduino Ethernet library.
92+
93+
94+
PIN Connections
95+
----
96+
|W5x00|STM32F103|
97+
|:------:|:-----:|
98+
|SS|PA4|
99+
|SCK|PA5|
100+
|MISO|PA6|
101+
|MOSI|PA7|
102+
103+
104+
105+
**DO NOT FORGET TO ADD A RESISTOR 4k7 BETWEEN RESET AND 3.3V (OR RESET AND 5V) PINS ON ETHERNET SHIELD**
106+
107+
![alt tag](http://www.serasidis.gr/images/w5100_shield_1.jpg)
108+
![alt tag](http://www.serasidis.gr/images/w5100_module_2.jpg)
109+
![alt tag](http://www.serasidis.gr/images/w5100_module_1.jpg)
110+
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
Advanced Chat Server
3+
4+
A more advanced server that distributes any incoming messages
5+
to all connected clients but the client the message comes from.
6+
To use telnet to your device's IP address and type.
7+
You can see the client's input in the serial monitor as well.
8+
Using an Arduino Wiznet Ethernet shield.
9+
10+
Circuit:
11+
* Ethernet shield attached to pins 10, 11, 12, 13
12+
* Analog inputs attached to pins A0 through A5 (optional)
13+
14+
created 18 Dec 2009
15+
by David A. Mellis
16+
modified 9 Apr 2012
17+
by Tom Igoe
18+
redesigned to make use of operator== 25 Nov 2013
19+
by Norbert Truchsess
20+
21+
*/
22+
23+
#include <SPI.h>
24+
#include <Ethernet_STM.h>
25+
26+
#define PORT 23 // telnet defaults to port 23
27+
28+
// Enter a MAC address and IP address for your controller below.
29+
// The IP address will be dependent on your local network.
30+
// gateway and subnet are optional:
31+
byte mac[] = {
32+
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
33+
IPAddress ip(192,168,1, 177);
34+
IPAddress gateway(192,168,1, 1);
35+
IPAddress subnet(255, 255, 255, 0);
36+
37+
38+
EthernetServer server(PORT);
39+
40+
EthernetClient clients[4];
41+
42+
void setup() {
43+
// initialize the ethernet device
44+
Ethernet.begin(mac, ip, gateway, subnet);
45+
// start listening for clients
46+
server.begin();
47+
// Open serial communications and wait for port to open:
48+
Serial.begin(9600);
49+
while (!Serial) {
50+
; // wait for serial port to connect. Needed for Leonardo only
51+
}
52+
53+
54+
55+
Serial.print("Chat server address: ");
56+
for (byte thisByte = 0; thisByte < 4; thisByte++) {
57+
// print the value of each byte of the IP address:
58+
Serial.print(Ethernet.localIP()[thisByte], DEC);
59+
Serial.print(".");
60+
}
61+
Serial.print("\nPort: ");
62+
Serial.print(PORT);
63+
}
64+
65+
void loop() {
66+
// wait for a new client:
67+
EthernetClient client = server.available();
68+
69+
// when the client sends the first byte, say hello:
70+
if (client) {
71+
72+
boolean newClient = true;
73+
for (byte i=0;i<4;i++) {
74+
//check whether this client refers to the same socket as one of the existing instances:
75+
if (clients[i]==client) {
76+
newClient = false;
77+
break;
78+
}
79+
}
80+
81+
if (newClient) {
82+
//check which of the existing clients can be overridden:
83+
for (byte i=0;i<4;i++) {
84+
if (!clients[i] && clients[i]!=client) {
85+
clients[i] = client;
86+
// clead out the input buffer:
87+
client.flush();
88+
Serial.println("We have a new client");
89+
client.print("Hello, client number: ");
90+
client.print(i);
91+
client.println();
92+
break;
93+
}
94+
}
95+
}
96+
97+
if (client.available() > 0) {
98+
// read the bytes incoming from the client:
99+
char thisChar = client.read();
100+
// echo the bytes back to all other connected clients:
101+
for (byte i=0;i<4;i++) {
102+
if (clients[i] && (clients[i]!=client)) {
103+
clients[i].write(thisChar);
104+
}
105+
}
106+
// echo the bytes to the server as well:
107+
Serial.write(thisChar);
108+
}
109+
}
110+
for (byte i=0;i<4;i++) {
111+
if (!(clients[i].connected())) {
112+
// client.stop() invalidates the internal socket-descriptor, so next use of == will allways return false;
113+
clients[i].stop();
114+
}
115+
}
116+
}

0 commit comments

Comments
 (0)