Still not compiling, yield() function cannot be resolved.

This commit is contained in:
Dirk Jahnke 2018-11-05 17:22:27 +01:00
parent 83a5cc0c41
commit 724c622ca4
7 changed files with 54 additions and 25 deletions

View File

@ -23,6 +23,7 @@ cdefs:
MPIDE: 0 MPIDE: 0
TEENSYDUINO: 0 TEENSYDUINO: 0
RH_PLATFORM: RH_PLATFORM_ESP8266 RH_PLATFORM: RH_PLATFORM_ESP8266
MONGOOSE_OS: 1
libs: libs:
# common mgos libs # common mgos libs

View File

@ -144,18 +144,11 @@ void RHGenericDriver::printBuffer(const char* prompt, const uint8_t* buf, uint8_
uint8_t i; uint8_t i;
#ifdef RH_HAVE_SERIAL #ifdef RH_HAVE_SERIAL
Serial.println(prompt); LOG(LL_DEBUG, ("%s", prompt));
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
if (i % 16 == 15) LOG(LL_DEBUG, (" %d: %02x", i, buf[i]));
Serial.println(buf[i], HEX);
else
{
Serial.print(buf[i], HEX);
Serial.print(' ');
}
} }
Serial.println("");
#endif #endif
} }

View File

@ -252,7 +252,7 @@ void RHHardwareSPI::begin()
SPI.begin(frequency, bitOrder, dataMode); SPI.begin(frequency, bitOrder, dataMode);
#elif (RH_PLATFORM == RH_PLATFORM_STM32F2) // Photon #elif (RH_PLATFORM == RH_PLATFORM_STM32F2) // Photon
Serial.println("HERE"); //Serial.println("HERE");
uint8_t dataMode; uint8_t dataMode;
if (_dataMode == DataMode0) if (_dataMode == DataMode0)
dataMode = SPI_MODE0; dataMode = SPI_MODE0;

View File

@ -13,6 +13,38 @@
#include "RHReliableDatagram.h" #include "RHReliableDatagram.h"
#ifdef MONGOOSE_OS
/*
static bool s_randomSeedCalled = false;
static void randomSeed(unsigned long seed) {
if(seed != 0) {
srand(seed);
s_randomSeedCalled = true;
}
}
*/
static long random(long howbig) {
if(howbig == 0) {
return 0;
}
// if randomSeed was called, fall back to software PRNG
// uint32_t val = (s_randomSeedCalled) ? rand() : RANDOM_REG32;
uint32_t val = rand();
return val % howbig;
}
static long random(long howsmall, long howbig) {
if(howsmall >= howbig) {
return howsmall;
}
long diff = howbig - howsmall;
return random(diff) + howsmall;
}
#endif
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Constructors // Constructors
RHReliableDatagram::RHReliableDatagram(RHGenericDriver& driver, uint8_t thisAddress) RHReliableDatagram::RHReliableDatagram(RHGenericDriver& driver, uint8_t thisAddress)

View File

@ -109,13 +109,7 @@ void RHRouter::printRoutingTable()
uint8_t i; uint8_t i;
for (i = 0; i < RH_ROUTING_TABLE_SIZE; i++) for (i = 0; i < RH_ROUTING_TABLE_SIZE; i++)
{ {
Serial.print(i, DEC); LOG(LL_DEBUG, ("%d Dest: %d, Next Hop: %d, State: %d", i, _routes[i].dest, _routes[i].next_hop, _routes[i].state));
Serial.print(" Dest: ");
Serial.print(_routes[i].dest, DEC);
Serial.print(" Next Hop: ");
Serial.print(_routes[i].next_hop, DEC);
Serial.print(" State: ");
Serial.println(_routes[i].state, DEC);
} }
#endif #endif
} }
@ -197,6 +191,8 @@ uint8_t RHRouter::route(RoutedMessage* message, uint8_t messageLen)
// Subclasses may want to override this to peek at messages going past // Subclasses may want to override this to peek at messages going past
void RHRouter::peekAtMessage(RoutedMessage* message, uint8_t messageLen) void RHRouter::peekAtMessage(RoutedMessage* message, uint8_t messageLen)
{ {
(void) message;
(void) messageLen;
// Default does nothing // Default does nothing
} }

View File

@ -236,8 +236,7 @@ bool RH_NRF24::printRegisters()
{ {
if ((r <= RH_NRF24_REG_17_FIFO_STATUS) || (r >= RH_NRF24_REG_1C_DYNPD)) if ((r <= RH_NRF24_REG_17_FIFO_STATUS) || (r >= RH_NRF24_REG_1C_DYNPD))
{ {
Serial.print(r, HEX); LOG(LL_DEBUG, ("%02x: ", r));
Serial.print(": ");
uint8_t len = 1; uint8_t len = 1;
// Address registers are 5 bytes in size // Address registers are 5 bytes in size
if ( (RH_NRF24_REG_0A_RX_ADDR_P0 == r) if ( (RH_NRF24_REG_0A_RX_ADDR_P0 == r)
@ -250,10 +249,8 @@ bool RH_NRF24::printRegisters()
spiBurstReadRegister(r, buf, len); spiBurstReadRegister(r, buf, len);
for (uint8_t j = 0; j < len; ++j) for (uint8_t j = 0; j < len; ++j)
{ {
Serial.print(buf[j], HEX); LOG(LL_DEBUG, (" %d: %02x", j, buf[j]));
Serial.print(" ");
} }
Serial.println("");
} }
} }
#endif #endif

View File

@ -669,6 +669,9 @@
#define RadioHead_h #define RadioHead_h
#include "Arduino.h" #include "Arduino.h"
#if defined(MONGOOSE_OS)
#include "mgos.h"
#endif
// Official version numbers are maintained automatically by Makefile: // Official version numbers are maintained automatically by Makefile:
#define RH_VERSION_MAJOR 1 #define RH_VERSION_MAJOR 1
@ -837,6 +840,16 @@
#error Platform unknown! #error Platform unknown!
#endif #endif
#ifdef MONGOOSE_OS
#ifndef xt_rsil
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;}))
#endif
#ifndef xt_wsr_ps
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
#endif
#endif
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// This is an attempt to make a portable atomic block // This is an attempt to make a portable atomic block
#if (RH_PLATFORM == RH_PLATFORM_ARDUINO) #if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
@ -877,9 +890,6 @@
#define YIELD yield(); #define YIELD yield();
#elif (RH_PLATFORM == RH_PLATFORM_ESP8266) #elif (RH_PLATFORM == RH_PLATFORM_ESP8266)
// ESP8266 also hash it // ESP8266 also hash it
#if defined(MONGOOSE_OS)
extern void yield(void);
#endif
#define YIELD yield(); #define YIELD yield();
#else #else
#define YIELD #define YIELD