|
| 1 | +------------------------------------------------------------------------------ |
| 2 | +-- -- |
| 3 | +-- Copyright (C) 2015-2023, AdaCore -- |
| 4 | +-- -- |
| 5 | +-- Redistribution and use in source and binary forms, with or without -- |
| 6 | +-- modification, are permitted provided that the following conditions are -- |
| 7 | +-- met: -- |
| 8 | +-- 1. Redistributions of source code must retain the above copyright -- |
| 9 | +-- notice, this list of conditions and the following disclaimer. -- |
| 10 | +-- 2. Redistributions in binary form must reproduce the above copyright -- |
| 11 | +-- notice, this list of conditions and the following disclaimer in -- |
| 12 | +-- the documentation and/or other materials provided with the -- |
| 13 | +-- distribution. -- |
| 14 | +-- 3. Neither the name of STMicroelectronics nor the names of its -- |
| 15 | +-- contributors may be used to endorse or promote products derived -- |
| 16 | +-- from this software without specific prior written permission. -- |
| 17 | +-- -- |
| 18 | +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- |
| 19 | +-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- |
| 20 | +-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- |
| 21 | +-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- |
| 22 | +-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- |
| 23 | +-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- |
| 24 | +-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- |
| 25 | +-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- |
| 26 | +-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- |
| 27 | +-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- |
| 28 | +-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- |
| 29 | +-- -- |
| 30 | +------------------------------------------------------------------------------ |
| 31 | + |
| 32 | +with System.Storage_Elements; |
| 33 | + |
| 34 | +with HAL.Framebuffer; |
| 35 | +with ILI9341.Device.Bitmap; |
| 36 | +with ILI9341.Device; |
| 37 | +with ILI9341.B16_Connector; |
| 38 | +with STM32.FSMC; |
| 39 | + |
| 40 | +package Display_ILI9341 is |
| 41 | + |
| 42 | + type Display is tagged limited private; |
| 43 | + |
| 44 | + procedure Initialize (This : in out Display); |
| 45 | + -- Configure FSMC, turn backlight on and initialize the display |
| 46 | + |
| 47 | + procedure Set_Orientation |
| 48 | + (This : in out Display; |
| 49 | + Orientation : HAL.Framebuffer.Display_Orientation); |
| 50 | + |
| 51 | + use System.Storage_Elements; |
| 52 | + |
| 53 | + package ILI9341_Device is new ILI9341.Device |
| 54 | + (ILI9341_Connector => ILI9341.B16_Connector.ILI9341_Connector, |
| 55 | + Send_Command => ILI9341.B16_Connector.Send_Command, |
| 56 | + Connection => ILI9341.Parallel, |
| 57 | + Connector => |
| 58 | + (Command => STM32.FSMC.Bank_1_Start (Subbank => 1), |
| 59 | + RAM => STM32.FSMC.Bank_1_Start (Subbank => 1) + 2 ** 19)); |
| 60 | + -- RAM region starts when A18 = 1, TFT attached with 16 bits bus, so 2**19 |
| 61 | + |
| 62 | + package ILI9341_Bitmap is new ILI9341_Device.Bitmap |
| 63 | + (ILI9341.B16_Connector.Write_Pixels, |
| 64 | + ILI9341.B16_Connector.Read_Pixels); |
| 65 | + |
| 66 | + subtype Bitmap_Buffer is ILI9341_Bitmap.Bitmap_Buffer; |
| 67 | + |
| 68 | + function Buffer (This : in out Display) return Bitmap_Buffer; |
| 69 | + |
| 70 | +private |
| 71 | + |
| 72 | + type Display is tagged limited record |
| 73 | + Device : aliased ILI9341_Device.ILI9341_Device; |
| 74 | + end record; |
| 75 | + |
| 76 | + function Buffer (This : in out Display) return Bitmap_Buffer is |
| 77 | + (ILI9341_Bitmap.Get_Bitmap (This.Device'Access)); |
| 78 | + |
| 79 | +end Display_ILI9341; |
0 commit comments