I want to thank you for exploring, porting, and advertising these RTOS and RTOS-like utilities.I don't know whether I'll ever be in a position to want to use them, but it's providing a lot of "warm fuzzies" to know that they're out there, that someone has made them work, and found them to be usable!

Hello fat16lib,First of all I want to thank you for your effort of porting these RTOS to Arduino; it will help many people like myself to learn about them.

I have some questions I'd like to answer if you could:

Regarding your FreeRTOS port: * Did you have to leave out any original full FreeRTOS characteristic on the Arduino port you built? If any, what were they?

Regarding how to port these RTOS: I would like to port FreeRTOS or other RTOS to my PIC32MX250F128 Pinguino platform, that is similar to arduino but running on PIC32MX (http://wiki.pinguino.cc/index.php/PIC32MX).

* Could you tell me the basic steps you took to port FreeRTOS?* What hardware specific files did you have to modify and was left untouched?* Do you consider I should start from your port (considering pinguino platform is similar to arduino), or from scratch downloading a FreeRTOS folder structure?* Is ChibiOS/RT easier to port than FreeRTOS?

It would be very helpful to be able to understand the porting process and to have these tools running on Pinguino, because its processors are powerful, cheap, and come in DIP packages too.

This version has a new I2C library, TwiMaster, and mods for Arduino 1.5.2 beta.

TwiMaster is an I2C master mode library that operates at 100 kHz or 400 kHz. The native API allows any size transfer, Wire has a 32 byte limit. TwiMaster has a class wrapper to provide a Wire compatible API.

The TwiMaster library is very efficient in RTOS threads since the calling thread sleeps during the I2C transfer. At 100 kHz, 85% of the transfer time is available to other threads.

TwiMaster can be used standalone, without an RTOS, in regular Arduino sketches. Several examples demonstrate standalone use.

It seems it crashes with 1284p (1.5.1r2). The BMP085 logger works fine with original Wire. When replacing Wire.h with the TwiMaster.h it compiles w/o error, but crashes. It does not show the initial "type any...", the bmp.begin() crashes (adafruit's BPM085 driver):

Data transfers follow the format shown in Figure 9. After the START condition (S), a slaveaddress is sent. This address is seven bits long followed by an eighth bit which is a datadirection bit (R/W) -- a 'zero' indicates a transmission (WRITE), a 'one' indicates arequest for data (READ) (refer to Figure 10). A data transfer is always terminated by aSTOP condition (P) generated by the master. However, if a master still wishes tocommunicate on the bus, it can generate a repeated START condition (Sr) and addressanother slave without first generating a STOP condition. Various combinations ofread/write formats are then possible within such a transfer.

..there are dozens of i2c devices and drivers which are not rtos friendly.. so it has no sense to mess with bmp085 alone.. the CSF for an rtos deployment in such ecosystem as the arduino is the ability to write the drivers, though..

I just want to understand the problem so I know the the TwiMaster I2C library works and so I can write a "How To" for making existing libraries more RTOS friendly.

The BMP085 is an good example since its ADC is so slow that it needs delay loops.

Other I2C libraries I have tried automatically work better since TwiMaster sleeps while the actual I2C transfer takes place. All you need to do is change the include from Wire.h to TwiMaster.h.

I hope most device libraries improve a lot if you change delay calls to sleep and change the include from Wire to the new library.

Edit: I decided to write new software(bit-bang) I2C libraries since I have my logic analyzer and scope setup for I2C testing.

I clear the PORT bit for sda and scl. I then set the DDR bit to pull either scl or sda low and clear the DDR bit to put scl or sda in high Z mode.

So it acts like an open drain/collector bus. I never drive a line high. I have a 100 kHz and 400 kHz version that runs using any pins for scl sda. The 400 kHz version will only run at full speed on "low address" pins since it uses bit set and bit clear which doesn't work for ports H - L on a Mega.