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
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
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
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);
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.