libyggdrasil  v1.0.0
interfaces.hpp
Go to the documentation of this file.
1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * _____.___. .___ .__.__ *
3  * \__ | | ____ ____ __| _/___________ _____|__| | *
4  * / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5  * \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6  * / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7  * \/ /_____//_____/ \/ \/ \/ *
8  * - Midgard - *
9  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10  * This software can be used by students and other personal of the *
11  * Bern University of Applied Sciences under the terms of the MIT *
12  * license. *
13  * For other persons this software is under the terms of the GNU *
14  * General Public License version 2. *
15  * *
16  * Copyright © 2021, Bern University of Applied Sciences. *
17  * All rights reserved. *
18  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 #pragma once
27 
28 #include <stm32f7xx_hal.h>
29 
41 
45 
46 #include <tuple>
47 
48 #if defined(YGGDRASIL_PERIPHERAL_DEFS)
49 
54  extern I2C_HandleTypeDef hi2c1;
55  extern I2C_HandleTypeDef hi2c2;
56  extern I2C_HandleTypeDef hi2c3;
57  extern I2C_HandleTypeDef hi2c4;
58 
59  extern SPI_HandleTypeDef hspi2;
60  extern SPI_HandleTypeDef hspi4;
61  extern SPI_HandleTypeDef hspi5;
62 
63  extern TIM_HandleTypeDef htim2;
64  extern TIM_HandleTypeDef htim3;
65  extern TIM_HandleTypeDef htim4;
66  extern TIM_HandleTypeDef htim5;
67  extern TIM_HandleTypeDef htim8;
68  extern TIM_HandleTypeDef htim11;
69  extern TIM_HandleTypeDef htim12;
70 
71  extern ADC_HandleTypeDef hadc1;
72  extern ADC_HandleTypeDef hadc2;
73  extern ADC_HandleTypeDef hadc3;
74 
75  extern DAC_HandleTypeDef hdac;
76 
77  extern LTDC_HandleTypeDef hltdc;
78  extern DSI_HandleTypeDef hdsi;
79  extern DMA2D_HandleTypeDef hdma2d;
80 
81  extern CAN_HandleTypeDef hcan1;
82  extern CAN_HandleTypeDef hcan2;
85  namespace bsp {
86 
102 
108  static constexpr auto& LD1 = GPIOPortJ::Pin<0>;
109  static constexpr auto& LDA = LD1;
110  static constexpr auto& LedBlue = LD1;
111  static constexpr auto& LD2 = GPIOPortJ::Pin<1>;
112  static constexpr auto& LDB = LD2;
113  static constexpr auto& LedRed = LD2;
114  static constexpr auto& LD3 = GPIOPortJ::Pin<2>;
115  static constexpr auto& LDC = LD3;
116  static constexpr auto& LedYellow = LD3;
117  static constexpr auto& LD4 = GPIOPortJ::Pin<3>;
118  static constexpr auto& LDD = LD4;
119  static constexpr auto& LedGreen = LD4;
120 
121  static constexpr auto& Heartbeat = GPIOPortA::Pin<10>;
122 
123  static constexpr auto& EncoderButton = GPIOPortK::Pin<3, drv::Active::Low>;
124 
125  static constexpr auto& LeftJoyStickButton = GPIOPortG::Pin<10, drv::Active::Low>;
126  static constexpr auto& ButtonJoystickA = LeftJoyStickButton;
127  static constexpr auto& RightJoyStickButton = GPIOPortG::Pin<11, drv::Active::Low>;
128  static constexpr auto& ButtonJoystickB = RightJoyStickButton;
129 
130  static constexpr auto& ButtonA = GPIOPortK::Pin<4, drv::Active::Low>;
131  static constexpr auto& ButtonB = GPIOPortK::Pin<5, drv::Active::Low>;
132  static constexpr auto& ButtonC = GPIOPortK::Pin<6, drv::Active::Low>;
133  static constexpr auto& ButtonD = GPIOPortK::Pin<7, drv::Active::Low>;
134 
135  static constexpr auto& DriverA = GPIOPortC::Pin<13>;
136  static constexpr auto& LD5 = DriverA;
137  static constexpr auto& LDE = DriverA;
138  static constexpr auto& DriverB = GPIOPortI::Pin<8>;
139  static constexpr auto& LD6 = DriverB;
140  static constexpr auto& LDF = DriverB;
141  static constexpr auto& DriverC = GPIOPortB::Pin<0>;
142  static constexpr auto& LD7 = DriverC;
143  static constexpr auto& LDG = DriverC;
144  static constexpr auto& DriverD = GPIOPortB::Pin<1>;
145  static constexpr auto& LD8 = DriverD;
146  static constexpr auto& LDH = DriverD;
147 
156 
162  static constexpr auto& ADCA = ADConverter1::Channel<3>;
163  static constexpr auto& ADCB = ADConverter1::Channel<10>;
164  static constexpr auto& ADCC = ADConverter3::Channel<14>;
165  static constexpr auto& ADCD = ADConverter3::Channel<15>;
166  static constexpr auto& ADCPotentiometer = ADConverter2::Channel<13>;
167  static constexpr auto& ADCTemperature = ADConverter1::Channel<18>;
168 
175 
181  static constexpr auto& DACA = DAConverter::Channel<1>;
182  static constexpr auto& DACB = DAConverter::Channel<2>;
183 
189  namespace seven_segment {
190 
191  static constexpr auto& A = GPIOPortG::Pin<0>;
192  static constexpr auto& B = GPIOPortG::Pin<1>;
193  static constexpr auto& C = GPIOPortG::Pin<2>;
194  static constexpr auto& D = GPIOPortG::Pin<3>;
195  static constexpr auto& E = GPIOPortG::Pin<4>;
196  static constexpr auto& F = GPIOPortG::Pin<5>;
197  static constexpr auto& G = GPIOPortG::Pin<6>;
198  static constexpr auto& DP = GPIOPortG::Pin<7>;
199 
200  static constexpr auto& All = GPIOPortG::Out<0,7>;
201 
202  static constexpr auto& Select0 = GPIOPortJ::Pin<12>;
203  static constexpr auto& Select1 = GPIOPortJ::Pin<13>;
204  static constexpr auto& Select2 = GPIOPortJ::Pin<14>;
205  static constexpr auto& Select3 = GPIOPortJ::Pin<15>;
206 
207  static constexpr auto& SelectAll = GPIOPortJ::Out<12,15>;
208 
209  }
220 
229 
230  static constexpr auto& SPIACE = GPIOPortI::Pin<0, drv::Active::Low>;
231  static constexpr auto& SK9822_EN = GPIOPortD::Pin<9>;
232  static constexpr auto& SPIBCE = GPIOPortE::Pin<11, drv::Active::Low>;
233  static constexpr auto& SPICCE = GPIOPortH::Pin<5, drv::Active::Low>;
234 
243  using UARTST = UARTC;
244 
252 
265 
266  using SinkDriverTimerA = TimerD;
267  using SinkDriverTimerB = TimerD;
268  using SinkDriverTimerC = TimerD;
269  using SinkDriverTimerD = TimerD;
270 
276  static constexpr auto& TimerACHA = TimerA::Channel<1>;
277 
278  static constexpr auto& TimerBCHA = TimerB::Channel<1>;
279  static constexpr auto& TimerBCHB = TimerB::Channel<2>;
280  static constexpr auto& TimerBCHC = TimerB::Channel<3>;
281  static constexpr auto& TimerBCHD = TimerB::Channel<4>;
282 
283  static constexpr auto& TimerCCHA = TimerC::Channel<1>;
284 
285  static constexpr auto& SinkDriverTimerCHA = SinkDriverTimerA::Channel<1>;
286  static constexpr auto& SinkDriverTimerCHB = SinkDriverTimerB::Channel<2>;
287  static constexpr auto& SinkDriverTimerCHC = SinkDriverTimerC::Channel<3>;
288  static constexpr auto& SinkDriverTimerCHD = SinkDriverTimerD::Channel<4>;
289 
290  static constexpr auto& Encoder = TimerF::Encoder;
291 
292  static constexpr auto& ProfileCounter = TimerG::ProfileCounter;
293 
299  static constexpr auto& TC78Mode = GPIOPortI::Pin<12>;
300  static constexpr auto& TC78Err = GPIOPortI::Pin<13, drv::Active::Low>;
301  static constexpr auto& TC78Stby = GPIOPortI::Pin<14, drv::Active::Low>;
302 
309 
316 
322  using Display = bsp::drv::Display<std::make_tuple(&hltdc, &hdsi, &hdma2d), bsp::mid::drv::Display>;
323 
325  }
326 
327 #endif
bsp::drv::SPI
Base class for SPI abstraction.
Definition: spi.hpp:51
display.hpp
Display abstraction implementation for Midgard.
cortex.hpp
Core control functions for Midgard.
bsp::drv::I2C
Base class for I2C abstraction.
Definition: i2c.hpp:43
gpio.hpp
GPIO Pin abstraction implementation for Midgard.
instructions.hpp
Assembly instruction wrapper functions for Midgard.
hash.hpp
HASH/CRC abstraction implementation for Midgard.
uart.hpp
UART abstraction implementation for Midgard.
bsp::drv::Hash
Base class for the Hash abstraction.
Definition: hash.hpp:42
can.hpp
CAN abstraction implementation for Midgard.
i2c.hpp
I2C abstraction implementation for Midgard.
timer.hpp
Timer Channel abstraction implementation for Midgard.
hdsi
DSI_HandleTypeDef hdsi
bsp::drv::GPIOPort
Base class for GPIO port abstraction.
Definition: gpio.hpp:48
bsp::drv::ADConverter
Base class for ADC abstraction.
Definition: adc.hpp:39
bsp::drv::CAN
Base class for CAN abstraction.
Definition: can.hpp:53
bsp::drv::Display
Base class for Display abstraction.
Definition: display.hpp:45
dac.hpp
DAC Channel abstraction implementation for Midgard.
spi.hpp
SPI abstraction implementation for Midgard.
bsp::drv::Random
Base class for the RNG abstraction.
Definition: rng.hpp:42
bsp::mid::drv::Display
Display implementation for Midgard.
Definition: display.hpp:68
rng.hpp
RNG abstraction implementation for Midgard.
bsp::drv::Timer
Base class for Timer abstraction.
Definition: timer.hpp:41
bsp
Definition: cortex.hpp:33
adc.hpp
ADC Channel abstraction implementation for Midgard.
bsp::drv::UART
Base class for UART abstraction.
Definition: uart.hpp:43
cache.hpp
Cache related constants and functions for Midgard.
bsp::drv::DAConverter
Base class for DAC abstraction.
Definition: dac.hpp:40