|
| 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 | +-- This file provides declarations for devices on the STM32 F4VE board |
| 33 | +-- manufactured by DevEBox. |
| 34 | + |
| 35 | +with Ada.Interrupts.Names; use Ada.Interrupts; |
| 36 | + |
| 37 | +with System; |
| 38 | + |
| 39 | +with STM32.Device; use STM32.Device; |
| 40 | +with STM32.DMA; use STM32.DMA; |
| 41 | +with STM32.DMA.Interrupts; use STM32.DMA.Interrupts; |
| 42 | +with STM32.GPIO; use STM32.GPIO; |
| 43 | +with STM32.SPI; use STM32.SPI; |
| 44 | + |
| 45 | +with SDCard; |
| 46 | +with W25Q16; |
| 47 | + |
| 48 | +package STM32.Board is |
| 49 | + pragma Elaborate_Body; |
| 50 | + |
| 51 | + subtype User_LED is GPIO_Point; |
| 52 | + |
| 53 | + D1_LED : User_LED renames PA6; |
| 54 | + D2_LED : User_LED renames PA7; |
| 55 | + |
| 56 | + All_LEDs : GPIO_Points := (D1_LED, D2_LED); |
| 57 | + LCH_LED : GPIO_Point renames D1_LED; |
| 58 | + |
| 59 | + procedure Initialize_LEDs; |
| 60 | + -- MUST be called prior to any use of the LEDs |
| 61 | + |
| 62 | + procedure Turn_On (This : in out User_LED) renames STM32.GPIO.Clear; |
| 63 | + procedure Turn_Off (This : in out User_LED) renames STM32.GPIO.Set; |
| 64 | + procedure Toggle (This : in out User_LED) renames STM32.GPIO.Toggle; |
| 65 | + |
| 66 | + procedure All_LEDs_Off with Inline; |
| 67 | + procedure All_LEDs_On with Inline; |
| 68 | + procedure Toggle_LEDs (These : in out GPIO_Points) |
| 69 | + renames STM32.GPIO.Toggle; |
| 70 | + |
| 71 | + -------------------------- |
| 72 | + -- micro SD card reader -- |
| 73 | + -------------------------- |
| 74 | + |
| 75 | + SD_Detect_Pin : STM32.GPIO.GPIO_Point renames PC11; |
| 76 | + -- There is no dedicated pin for card detection, reuse DAT3 pin |
| 77 | + |
| 78 | + SD_DMA : DMA_Controller renames DMA_2; |
| 79 | + SD_DMA_Rx_Stream : DMA_Stream_Selector renames Stream_3; |
| 80 | + SD_DMA_Rx_Channel : DMA_Channel_Selector renames Channel_4; |
| 81 | + SD_DMA_Tx_Stream : DMA_Stream_Selector renames Stream_6; |
| 82 | + SD_DMA_Tx_Channel : DMA_Channel_Selector renames Channel_4; |
| 83 | + SD_Pins : constant GPIO_Points := |
| 84 | + (PC8, PC9, PC10, PC11, PC12, PD2); |
| 85 | + SD_Pins_AF : constant GPIO_Alternate_Function := GPIO_AF_SDIO_12; |
| 86 | + SD_Pins_2 : constant GPIO_Points := (1 .. 0 => <>); |
| 87 | + SD_Pins_AF_2 : constant GPIO_Alternate_Function := GPIO_AF_SDIO_12; |
| 88 | + SD_Interrupt : Ada.Interrupts.Interrupt_ID renames |
| 89 | + Ada.Interrupts.Names.SDIO_Interrupt; |
| 90 | + |
| 91 | + DMA2_Stream3 : aliased DMA_Interrupt_Controller |
| 92 | + (DMA_2'Access, Stream_3, |
| 93 | + Ada.Interrupts.Names.DMA2_Stream3_Interrupt, |
| 94 | + System.Interrupt_Priority'Last); |
| 95 | + |
| 96 | + DMA2_Stream6 : aliased DMA_Interrupt_Controller |
| 97 | + (DMA_2'Access, Stream_6, |
| 98 | + Ada.Interrupts.Names.DMA2_Stream6_Interrupt, |
| 99 | + System.Interrupt_Priority'Last); |
| 100 | + |
| 101 | + SD_Rx_DMA_Int : DMA_Interrupt_Controller renames DMA2_Stream3; |
| 102 | + SD_Tx_DMA_Int : DMA_Interrupt_Controller renames DMA2_Stream6; |
| 103 | + |
| 104 | + SDCard_Device : aliased SDCard.SDCard_Controller (SDIO'Access); |
| 105 | + |
| 106 | + --------------- |
| 107 | + -- SPI2 Pins -- |
| 108 | + --------------- |
| 109 | + |
| 110 | + -- External TFT connector |
| 111 | + |
| 112 | + TFT_RS : GPIO_Point renames PC5; |
| 113 | + TFT_BLK : GPIO_Point renames PB1; -- LCD backlight |
| 114 | + TFT_CS : GPIO_Point renames PB12; |
| 115 | + SPI2_SCK : GPIO_Point renames PB13; |
| 116 | + SPI2_MISO : GPIO_Point renames PB14; |
| 117 | + SPI2_MOSI : GPIO_Point renames PB15; |
| 118 | + |
| 119 | + TFT_SPI : SPI_Port renames SPI_2; |
| 120 | + |
| 121 | + ------------------ |
| 122 | + -- User buttons -- |
| 123 | + ------------------ |
| 124 | + |
| 125 | + K0_Button_Point : GPIO_Point renames PE4; |
| 126 | + K1_Button_Point : GPIO_Point renames PE3; |
| 127 | + Wake_Up_Button_Point : GPIO_Point renames PA0; |
| 128 | + User_Button_Point : GPIO_Point renames Wake_Up_Button_Point; |
| 129 | + User_Button_Interrupt : constant Interrupt_ID := Names.EXTI0_Interrupt; |
| 130 | + |
| 131 | + All_Buttons : GPIO_Points := |
| 132 | + (K0_Button_Point, K1_Button_Point, Wake_Up_Button_Point); |
| 133 | + |
| 134 | + procedure Configure_User_Button_GPIO; |
| 135 | + -- Configures the GPIO port/pin for user buttons. Sufficient |
| 136 | + -- for polling the button, and necessary for having the button generate |
| 137 | + -- interrupts. |
| 138 | + |
| 139 | + ------------------ |
| 140 | + -- Flash memory -- |
| 141 | + ------------------ |
| 142 | + |
| 143 | + Flash : W25Q16.Flash_Memory |
| 144 | + (SPI => STM32.Device.SPI_1'Access, |
| 145 | + CS => STM32.Device.PA15'Access); |
| 146 | + |
| 147 | + procedure Initialize_Flash_Memory; |
| 148 | + -- MUST be called prior to any use of the Flash |
| 149 | + |
| 150 | +end STM32.Board; |
0 commit comments