This is a large commit with an extensive number of additions and enhancements which complete many outstanding items. Please read through the information below for further details on what is included and if you need more information about any of the items in this commit post your questions in the forum.
List of changes:
- Add new FramebufferDeviceSetBacklight() API for devices that support controlling the backlight brightness
- Change implementation of SysGetTickCount64 to match the SysUtils unit
- Fix issue with invalid GetTickCount64() value on one or more CPUs when using Raspberry Pi firmware later than May 2016
- Fix ARP handling of update already in cache to prevent duplication of addresses
- Remove old VirtualGPIOOutputSet and VirtualGPIOOutputClear (Replaced in a previous commit)
- Complete Timer (Counter) API to include support for waiting threads and event callbacks
- Add driver for Raspberry Pi ARM timer device with support for all Timer API features
- Rework interrupt (IRQ/FIQ) registration and deregistration functions (Request and ReleaseIRQ or FIQ) to complete the FIQ support and provide additional options
- Add new RegisterSystemCall() / DeregisterSystemCall() functions to allow registering and deregistering custom system calls
- Complete a number of missing ARM local interrupt registrations in Raspberry Pi 2 and 3 platform support
- Add new VectorTableGetEntry() / VectorTableSetEntry() functions to allow replacing any of the interrupt vectors with customized versions
- Add new VECTOR_TABLE_ENTRY_ARM_* constants for use with the new vector table functions
- Reduce the MEMORY_DEVICE_SIZE value to 0 on Raspberry 2 and 3 saving 8MB of memory allocation
- Change the default page table layout to mark all memory above 1GB as no access
- Fix incorrect value of PAGE_TABLE_FLAG_NONE constant
- Implement missing ARMv6 versions of Clean/InvalidateDataCacheRange functions
- Implement missing InvalidateInstructionCacheRange function for ARMv6, ARM7 and ARMv8
- Implement PageTableSetEntry() function to allow modifying the page table layout dynamically
- Add new PAGE_TABLES_USED/PAGE_TABLES_FREE/PAGE_TABLES_NEXT internal variables to track page table allocations and support page table changes
- Fix the assembler versions of SpinLockIRQ() / SpinLockFIQ() / SpinLockIRQFIQ() functions to correctly restore the stack on lock failure
- Finalize changes to startup process to allow the zero page (Address 0x00000000) to be marked as no access and allow an exception to be generated on either a read or write of a nil pointer
- Update assembler versions of MutexLock() and MutexUnlock() to support MUTEX_FLAG_RECURSIVE option
- Rework Platform unit to properly inline the SpinLock and Mutex handlers for performance
- Fix ARMRestoreIRQFIQ function to correctly mask the interrupt bits
- Add new FIQ handler to allow support for fast interrupts, see below for more information
- Adjust IRQ handler to correctly support preemption by the FIQ handler and interrupting a software interrupt
- Add new Tasker API in Platform unit to support deadlock protected transfer of work from FIQ handler to IRQ handler
- Add new FramebufferDeviceGetLine() and FramebufferDeviceGetPoint() APIs to support graphics libraries and units
- Enhance Raspberry Pi framebuffer driver to support color format, rotation and 8, 16, 24 or 32 bit color depth
- Add new CONSOLE_LOGGING_DEVICE global variable to allow specifying which console device logging should output to
- Add new CONSOLE_SHELL_DEVICE global variable to specify which console device the ConsoleShell unit should attach to
- Change all framebuffer functions to request the DMA bulk channel if available
- Refine the set of COLOR_FORMAT_* constants to include all applicable formats and remove some non required ones
- Add new TColorFormat* definitions in GlobalTypes to support color format translations
- Add support functions for color format translation between default format and commonly used formats
- Update framebuffer API to correctly handle all color depths from 8 bit to 32 bit
- Rework the entire implementation of the FramebufferConsole driver to use the new framebuffer API
- Complete FramebufferConsoleDrawImage() and FramebufferConsoleGetImage() functions to support color format translation to and from the framebuffer device
- Complete outstanding functions in GraphicsConsole unit following framebuffer changes
- Add support for setting SPI clock rate per chip select
- Add SPI DMA transfer support
- Add new Touchscreen device API with basic single and multipoint touch support including rotation
- Add GPIO driver for ST Microelectronics STMPE I/O expander chips
- Add Touch driver for ST Microelectronics STMPE touchscreen chips
- Add FocalTech FT5406 Touch driver for official Raspberry Pi 7" touchscreen (display already supported by framebuffer drivers)
- Add new TFT framebuffer support unit for common TFT LCD driver chips
- Add framebuffer driver for Himax HX8357D TFT LCD driver chip
- Add framebuffer driver for Ilitek ILI9340 TFT LCD driver chip
- Add mini drivers for Adafruit piTFT 2.8" LCD and piTFT 3.5" LCD
Framebuffer and Console support for multiple color depths and formats
This commit includes a number of items that bring to completion the support within the framebuffer and console API for multiple color depths (8, 16, 24 and 32 bit) and color formats such as RGB24, RGB16 and RGB15 along with their BGR counterparts.
The completion of this work means that all of the framebuffer and console functions can now work across a range of pixel based devices regardless of the color depth or format and the code will correcly adjust all calculations to account for the differences, in addition console and graphics console functions such as GraphicsWindowDrawImageDrawImage() and GraphicsWindowDrawImageGetImage() will now translate between the format supplied and the format required by the underlying device which makes basic graphics in Ultibo much easier to achieve.
To demonstrate the power of this new functionality we will provide a short example in the next few days that shows just how easy it now is to display a standard bitmap image or to save all or part of the screen to a bitmap file.
Touchscreen support and API
The Touch unit provides generic touchscreen device API that offers a similar model to keyboard and mouse devices but includes enhancements for touch specific concepts. As usual the API includes a number of functions that work with a specified instance of a device and includes the following:
- TouchDeviceStart - Start a touch device and enable receiving of touch data
- TouchDeviceStop - Stop a touch device and cease receiving data
- TouchDevicePeek - Check if touch data is available for a device
- TouchDeviceRead - Read available touch data from a device
- TouchDeviceWrite - Write touch events in to a devices buffer
Fast interrupt (FIQ) support
In addition to the normal interrupt (IRQ) support already provided in Ultibo, this release also enables support for fast interrupts (FIQ) where available. Registering a fast interrupt handler is essentially the same as registering an interrupt handler except that you call the RequestFIQ() instead of RequestIRQ().
On the Raspberry Pi only one device can be registered to use fast interrupts (FIQ) at any time, except in the case of the Raspberry Pi 2 and 3 where a small number of devices that are local to each CPU can also be registered for FIQ handling. Fast interrupt handlers must adhere to strict rules about usage of locks and other functions to avoid possible deadlock cases, many of these are the same rules as a normal interrupt handler but because the FIQ can preempt a normal IRQ there are also some additional restrictions regarding the scheduler as well.
ARM timer driver
This is the first driver provided for a timer or counter device even though much of the timer API has been included for some time. The ARM timer is available in all models of Raspberry Pi and can be configured to run at clock speeds up to the core clock which is 250MHz by default or 400MHz on a Raspberry Pi 3. The timer device can be used either via the counter API functions in the Platform unit or via the timer API functions in the Device unit, the timer API includes the following functions:
- TimerDeviceStart - Start or stop a timer device
- TimerDeviceRead - Read the current value of a timer device
- TimerDeviceWait - Wait for the current interval of the timer to expire
- TimerDeviceEvent - Register an event to be called when the current interval expires
- TimerDeviceGetRate - Get or Set the clock frequency of a timer device
- TimerDeviceGetInterval - Get or Set the interval in clock ticks of a timer device
The ARM timer driver can also be configured to use the fast interrupt (FIQ) support by changing the global variable BCM270XARM_TIMER_FIQ_ENABLED before starting the device.
ST Microelectronics STMPE GPIO driver
This driver provides support for a number of ST Microelectronics STMPE I/O expander devices and exposes them to Ultibo as a GPIO device which can be accessed using the standard GPIO functions. As this is a generic driver it does not automatically register when included in a project, you must call one of the STMPEXXXGPIOCreate() functions in order to define the device to communicate with, see the piTFT28 and piTFT35 units for an example of how to use this driver.
ST Microelectronics STMPE Touch driver
A touch driver for the ST Microelectronics STMPE610 and STMPE811 resistive touchscreen devices, as with the GPIO drivers above the device is created by calling one of the STMPEXXXTouchCreate() functions and specifying the required parameters. Once created the device will be available using the touch API above.
FocalTech FT5406 Touch driver for Raspberry Pi
This is a Raspberry Pi specific version of the FocalTech FT5406 multipoint capacitive touchscreen driver for the official 7" display sold by Raspberry Pi. Because of the design of the display the GPU in the Raspberry Pi communicates with the touchscreen and makes the touch data available via a memory based buffer rather than using the normal I2C interface of the FocalTech chip.
Note: This driver is currently untested and we are asking anyone who has an official 7" display available to test it, a small example will be posted in the forum shortly to provide a test project which can be used to confirm if the touchscreen driver is functioning correctly.
Himax HX8357D TFT LCD Framebuffer driver
This unit provides a framebuffer driver for the Himax HX8357D TFT LCD driver chip which is used in many small TFT displays, as with other drivers this one also requires you to specify appropriate parameters when creating an instance of the device so it can determine how to communicate with the chip, see the piTFT28 and piTFT35 units for an example of how to use this driver.
Ilitek ILI9340 TFT LCD Framebuffer driver
Very similar to the previous driver except this one is for the Ilitek ILI9340 TFT LCD driver chip instead which is also commonly used.
Adafruit piTFT 2.8" LCD and piTFT 3.5" LCD mini drivers
These two units provide mini drivers for the specifics of the Adafruit piTFT 2.8" and 3.5" displays. The units themselves contain very little functionality but utilize some of the other new drivers to create a fully functional device (including framebuffer, GPIO and touch) which you can either use as is or learn from to create your own unit to support similar devices.
The drivers are configured to work with the following Adafruit products:
- piTFT 2.8" - https://www.adafruit.com/products/2298
- piTFT 3.5" - https://www.adafruit.com/products/2441
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 or watch the Building the RTL video on YouTube.