Latest commits (Ultibo core 1.2.047)

Releases, updates and announcements from the Ultibo team.
User avatar
Ultibo
Site Admin
Posts: 2081
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Latest commits (Ultibo core 1.2.047)

Postby Ultibo » Mon Jun 27, 2016 7:48 am

The latest commits for Ultibo core are now available on GitHub. Changes include I2C driver, SPI driver, MCP230XX I/O expander driver and much much more.

Brief list of changes:

  • Add I2C device unit and I2C master drivers for Raspberry Pi
  • Add SPI device unit and SPI master driver for Raspberry Pi
  • Add Real time clock (RTC) unit
  • Update ClockGetTime/ClockSetTime to use RTC if available
  • Fix incorrect return value type for ClockSetTime/RTCSetTime
  • Fix incorrect clock ID for UART1 in Raspberry Pi
  • Add driver for Maxim DS1307 (and similar) real time clock device (I2C versions)
  • Add missing GPIODeviceRead/GPIODeviceWrite to Raspberry Pi GPIO driver
  • Update NTP client to only set local clock on changed
  • Add GPIO driver for Microchip MCP23008 and MCP23017 I/O expander devices (I2C versions)
  • Add Console driver for Hitachi HD44780 LCD controller
  • Add mini driver to support Adafruit 16x2 LCD + Keypad kit for Raspberry Pi
  • Update console unit to support character devices such as 2 line LCD
  • Rewrite TCP socket timer for improved ACK and Retry handling
  • Fix several deadlock issues in the file system

I2C driver:

The new I2C driver implementation includes the generic I2C device unit and the Raspberry Pi specific driver. The driver currently supports the I2C master devices in the Raspberry Pi and provides full interrupt driven handling of I2C requests.

The I2C API is available by including the I2C unit in your project, for many standard I2C device functions there are a set of generic I2C functions provided in the Platform unit.

Generic I2C functions include:

  • I2CAvailable - Check if an I2C device is available
  • I2CStart - Start the default I2C device and set the clock rate
  • I2CStop - Stop the default I2C device and terminate all requests
  • I2CRead - Read from the slave address specified using the default I2C device
  • I2CWrite - Read to the slave address specified using the default I2C device
  • I2CWriteRead - Perform a write then read operation to an I2C slave
  • I2CWriteWrite - Perform a write then write in a single transaction to an I2C slave address
See the comments in the header of each function for details of the required parameters, the functions in the I2C unit include additional options for finer control.


SPI driver:

As with all other devices the SPI support includes a generic SPI unit to provide the API and a Raspberry Pi specific driver for the hardware. The driver currently supports interrupt driven transfers, DMA support will be added once the final details have been confirmed.

The SPI support is currently considered beta mainly due to the large number of devices on the market and a lack of devices on hand to test. The only SPI device so far tested is an ILITEK ILI9340 TFT screen and as yet only initialization and some lines on the screen are working.

The API is largely complete and SPI transfers work correctly in the limited testing possible, if you have SPI devices and are able to undertake testing with them it will help to finalize the driver and validate its correctness.

Some of the SPI functions available in the Platform unit are:

  • SPIAvailable - Check if an SPI device is available for use
  • SPIStart - Start the default SPI device setting the mode, clock rate, phase and polarity
  • SPIStop - Stop the default SPI device
  • SPIRead - Read from the default SPI device, sending dummy writes for each read
  • SPIWrite - Write to the default SPI device, discarding any data reads
  • SPIWriteRead - Write then read to and from the default SPI device
As usual the SPI unit contains additional functions with further options, see the comments in the header of each function for details of the required parameters.


DS1307 RTC driver:

This driver supports a number of chips in the Maxim DS1307 RTC family which use I2C for communication. The unit will auto start when included in a project and look for a suitable RTC on the configured address.

The driver can be configured via a number of parameters in the GlobalConfig unit, all of which can also be specified on the command line.

  • DS1307_CHIP_TYPE - Set the chip type for RTC (See the DS1307 unit for available types)
  • DS1307_I2C_ADDRESS - Set the I2C slave address to use for communication
  • DS1307_I2C_DEVICE - Set the I2C device name to use for communication (Default on the Raspberry Pi is I2C0)

Microchip MCP230XX driver:

This is a generic driver for the MCP23008 and MCP23017 I/O expander chips which use I2C for communication, the driver presents the chip to Ultibo as a GPIO device and allows the standard GPIO API to be used for control.

The driver cannot be used standalone and is intended to be used in conjunction with a wrapper that provides the required parameters and creates an instance of the MCP230XX driver.

For an example of using this driver see the AF16x2LCD unit.


Hitachi HD44780 driver:

As with the MCP230XX, this is a generic driver that presents the LCD controller to Ultibo as a Console device to allow standard console functions (eg ConsoleWindowWriteLn) to be used.

The HD44780 driver is also used by the AF16x2LCD unit which gives an example of creating a wrapper to create and configure the device.


Adafruit 16x2 LCD + Keypad driver:

This is an example of a "mini driver", the unit itself contains only a small amount of code and instead uses the MCP230XX and HD44780 drivers to create a complete console interface to the 2 line LCD as well as GPIO handling of the keypad buttons.

If you have one of the supported devices, creating an Ultibo project to use it is as simple as including the AF16x2LCD unit which will auto start on boot and configure the required information.

You can then write text to the LCD like this:

Code: Select all

 WindowHandle:=ConsoleWindowCreate(PConsoleDevice(DeviceFindByDescription('Adafruit 16x2 LCD')),CONSOLE_POSITION_FULLSCREEN,True);
 ConsoleWindowWriteLn(WindowHandle,'Hello Ultibo!!');

The unit also includes some functions to turn on or off the backlight, set the backlight color and read from the keypad buttons.


For details of how to apply the latest source to your Ultibo core installation and rebuild your run time library see the wiki page Building from Source.
Ultibo.org | Make something amazing
https://ultibo.org
markokrajnc
Posts: 40
Joined: Sat Feb 06, 2016 11:50 pm
Location: Slovenia
Contact:

Re: Latest commits (Ultibo core 1.2.047)

Postby markokrajnc » Mon Jun 27, 2016 11:28 am

GREAT!

Question: You mentioned "2 important TCP timing issues" in forum: are these issues solved in 1.2.047? Can now Ultibo be used for HTTP servers with frequent requests?
User avatar
Ultibo
Site Admin
Posts: 2081
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Latest commits (Ultibo core 1.2.047)

Postby Ultibo » Tue Jun 28, 2016 1:46 am

Hi Marko,

markokrajnc wrote:You mentioned "2 important TCP timing issues" in forum: are these issues solved in 1.2.047?

Yes, the fixes for these are included in the 1.2.047 commit. The two issues referred to were:

  • Incorrect handling of negative delta value during socket dequeue (which caused some unwanted extra delays in acknowledging packets)
  • Failure to correctly read remaining bytes from the buffer of socket that is closing (resulted in read failures when the data had actually been received)
All of our testing shows that these issues are resolved and the rewriting of the socket timer resolves issues with TCP transfer failures. We have a small list of further improvements for future work, most of these relate to performance rather than incorrect behavior.

markokrajnc wrote:Can now Ultibo be used for HTTP servers with frequent requests?

I wouldn't say Ultibo is capable of serving a million requests a minute (not much would be on a Raspberry Pi) but it should handle continuous frequent requests without any problems.

If you find cases that do not work or don't behave correctly please open a forum topic with the details and we'll work through resolving it.
Ultibo.org | Make something amazing
https://ultibo.org
markokrajnc
Posts: 40
Joined: Sat Feb 06, 2016 11:50 pm
Location: Slovenia
Contact:

Re: Latest commits (Ultibo core 1.2.047)

Postby markokrajnc » Tue Jul 05, 2016 8:06 am

Thanks for your answer and time!

Return to “Ultibo”

Who is online

Users browsing this forum: No registered users and 1 guest