Coder Social home page Coder Social logo

compilation error about ethernet_stm32 HOT 6 CLOSED

stevstrong avatar stevstrong commented on July 26, 2024
compilation error

from ethernet_stm32.

Comments (6)

stevstrong avatar stevstrong commented on July 26, 2024

It seems that you use PlatformIO.
That IDE is not supported. It may work, but not officially supported.

Which board have you installed in PlaformIO? And which core?

from ethernet_stm32.

jmcastillejo avatar jmcastillejo commented on July 26, 2024

I tried to do it with the arduino ide and the recommended core and I get this error

In file included from /home/jose/Arduino/libraries/Ethernet_STM32-master/src/socket.h:10:0,
                 from /home/jose/Arduino/libraries/Ethernet_STM32-master/src/EthernetClient.h:7,
                 from /home/jose/Arduino/libraries/Ethernet_STM32-master/src/Ethernet_STM32.h:10,
                 from /tmp/arduino_modified_sketch_32503/WebServer.ino:2:
/home/jose/Arduino/libraries/Ethernet_STM32-master/src/w5500.h: In member function 'void W5500Class::initSS(uint8_t)':
/home/jose/Arduino/libraries/Ethernet_STM32-master/src/w5500.h:303:15: error: invalid conversion from 'volatile uint32_t* {aka volatile long unsigned int*}' to 'volatile uint32* {aka volatile unsigned int*}' [-fpermissive]
     ssPortReg = (volatile uint32_t *)portSetRegister(SS);
               ^
exit status 1
Error compilando para la tarjeta Generic STM32F407V series.

And this is te sketch:

#include <SPI.h>
#include <Ethernet_STM32.h>
#include <Streaming.h>

#define LED_PIN PF10

SPIClass mSpi(2); // you can use 1..2 for STM32F1, 1..3 for STM32F4)

// 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, 15); //(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);
EthernetClient client;

// A UDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

/*****************************************************************************/
void setup()
{
	// Open serial communications and wait for port to open:
	Serial.begin(115200);
	while ( !Serial ); delay(100);

	Serial.println(("*************************************************************"));
	Serial.println(("***** Web server example combined with getting NTP time *****"));
	Serial.println(("*************************************************************"));

	// init Ethernet interface
   Ethernet.init(mSpi, PB12); // alternatively it is possible use the default SPI object


  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
}

/*****************************************************************************/
void loop()
{
	// listen for incoming clients
	ListenForClient();
	// give the web browser time to receive the data
	delay(1);
}

uint32_t time;
uint8_t hour, minute, second;

/*****************************************************************************/
void ListenForClient(void)
{
	client = server.available();
	if ( !client ) return;
  
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;

    if (client.connected()) {

		GetNTPTime();

		Serial.println("\n--> Client connected:");
		while (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) {
				Serial.print("sending standard response to the client in ");
				time = millis();
				// 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 << ("<!DOCTYPE HTML>\n<html>\n");
				client << ("The UTC time is ") << _TIME(hour, minute, second) << ("<br />\n<br />\n");
				// output the value of each analog input pin
				for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
					int sensorReading = analogRead(analogChannel);
					client << ("analog input ") << (analogChannel) << (" is ")<< (sensorReading) << ("<br />\n");
				}
				client.println("</html>");
				Serial.println(millis()-time);
				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;
			}
		}
		// close the connection:
		client.stop();
		Serial.println("<-- client disconnected.\n");
   }
}

/*****************************************************************************/
const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message
byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets 
//IPAddress timeServer(132, 163, 4, 101); // time-a.timefreq.bldrdoc.gov NTP server
IPAddress timeServer(192, 168, 100, 1); // local router/modem
/*****************************************************************************/
void GetNTPTime(void)
{
	unsigned int localPort = 8888;      // local port to listen for UDP packets
	Udp.begin(localPort);

    Serial.println("Sending NTP packet...");
	sendNTPpacket(timeServer); // send an NTP packet to a time server

	// wait to see if a reply is available
	while ( !Udp.parsePacket() );
	// We've received a packet, read the data from it
	Udp.read(packetBuffer,NTP_PACKET_SIZE);  // read the packet into the buffer
	Udp.stop();

	//the timestamp starts at byte 40 of the received packet and is four bytes,
	// or two words, long. First, esxtract the two words:

	unsigned long highWord = (packetBuffer[40]<<8) | packetBuffer[41];
	unsigned long lowWord = (packetBuffer[42]<<8) | packetBuffer[43];  
	// combine the four bytes (two words) into a long integer
	// this is NTP time (seconds since Jan 1 1900):
	unsigned long secsSince1900 = (highWord << 16) | lowWord;  
	Serial.print("Seconds since Jan 1 1900 = " );
	Serial.println(secsSince1900);               

	// now convert NTP time into everyday time:
	// Unix time starts on Jan 1 1970. In seconds, that's 2208988800:
	const unsigned long seventyYears = 2208988800UL;     
	// subtract seventy years:
	unsigned long epoch = secsSince1900 - seventyYears;  
	// print Unix time:
	Serial << ("Unix time = ") << (epoch) << endl;
	// print the hour, minute and second:
    // UTC is the time at Greenwich Meridian (GMT)
	hour = (epoch  % 86400L) / 3600;
	minute = (epoch % 3600) / 60;
	second = (epoch % 60);
	Serial << ("The UTC time is ") << _TIME(hour, minute, second) << endl;
}

/*****************************************************************************/
// send an NTP request to the time server at the given address 
/*****************************************************************************/
void sendNTPpacket(IPAddress& address)
{
	// set all bytes in the buffer to 0
	memset(packetBuffer, 0, NTP_PACKET_SIZE); 
	// Initialize values needed to form NTP request
	// (see URL above for details on the packets)
	packetBuffer[0] = 0b11100011;   // LI, Version, Mode
	packetBuffer[1] = 0;     // Stratum, or type of clock
	packetBuffer[2] = 6;     // Polling Interval
	packetBuffer[3] = 0xEC;  // Peer Clock Precision
	// 8 bytes of zero for Root Delay & Root Dispersion
	packetBuffer[12]  = 49; 
	packetBuffer[13]  = 0x4E;
	packetBuffer[14]  = 49;
	packetBuffer[15]  = 52;

	// all NTP fields have been given values, now
	// you can send a packet requesting a timestamp: 		   
	Udp.beginPacket(address, 123); //NTP requests are to port 123
	Udp.write(packetBuffer,NTP_PACKET_SIZE);
	Udp.endPacket(); 
}

from ethernet_stm32.

stevstrong avatar stevstrong commented on July 26, 2024

Thanks for reporting.
I just committed a fix for that, please update the file: https://github.com/stevstrong/Ethernet_STM32/blob/master/src/w5500.h

from ethernet_stm32.

jmcastillejo avatar jmcastillejo commented on July 26, 2024

the error persists, although it is another....

In file included from /home/jose/Arduino/hardware/Arduino_STM32-master/STM32F4/system/libmaple/Arduino.h:43:0,
                 from sketch/WebServer.ino.cpp:1:
/home/jose/Arduino/libraries/Ethernet_STM32-master/src/w5500.h: In member function 'void W5500Class::initSS(uint8_t)':
/home/jose/Arduino/hardware/Arduino_STM32-master/STM32F4/variants/generic_f407v/variant.h:10:67: error: 'gpio_reg_map' has no member named 'BSRR'
 #define portSetRegister(pin)  ( &(PIN_MAP[pin].gpio_device->regs->BSRR) )
                                                                   ^
/home/jose/Arduino/libraries/Ethernet_STM32-master/src/w5500.h:303:36: note: in expansion of macro 'portSetRegister'
     ssPortReg = (volatile uint32 *)portSetRegister(SS);
                                    ^
exit status 1
Error compilando para la tarjeta Generic STM32F407V series.

from ethernet_stm32.

stevstrong avatar stevstrong commented on July 26, 2024

I think you should use my Ardunio_STM32 core, because this error should not be there.
In particular, the BSRR register is defined here: https://github.com/stevstrong/Arduino_STM32/blob/master/STM32F4/cores/maple/libmaple/gpio_def.h#L56, so it should not generate any error.

from ethernet_stm32.

jmcastillejo avatar jmcastillejo commented on July 26, 2024

with fix compile without any errors, thanks for your assistance

regards

from ethernet_stm32.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.