libyggdrasil  v1.0.0
interfaces.hpp
Go to the documentation of this file.
1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * _____.___. .___ .__.__ *
3  * \__ | | ____ ____ __| _/___________ _____|__| | *
4  * / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5  * \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6  * / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7  * \/ /_____//_____/ \/ \/ \/ *
8  * - Asgard - *
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 <stm32mp1xx_hal.h>
29 
40 
41 
44 
45 #include <tuple>
46 
47 #if defined(YGGDRASIL_PERIPHERAL_DEFS)
48 
53  extern I2C_HandleTypeDef hi2c1;
54  extern I2C_HandleTypeDef hi2c2;
55  extern I2C_HandleTypeDef hi2c5;
56 
57  extern SPI_HandleTypeDef hspi2;
58  extern SPI_HandleTypeDef hspi4;
59  extern SPI_HandleTypeDef hspi5;
60 
61  extern TIM_HandleTypeDef htim1;
62  extern TIM_HandleTypeDef htim2;
63  extern TIM_HandleTypeDef htim3;
64  extern TIM_HandleTypeDef htim4;
65  extern TIM_HandleTypeDef htim5;
66  extern TIM_HandleTypeDef htim6;
67  extern TIM_HandleTypeDef htim12;
68  extern TIM_HandleTypeDef htim16;
69 
70  extern ADC_HandleTypeDef hadc1;
71  extern ADC_HandleTypeDef hadc2;
72 
73  extern DAC_HandleTypeDef hdac1;
74 
75  extern FDCAN_HandleTypeDef hfdcan1;
76  extern FDCAN_HandleTypeDef hfdcan2;
79  namespace bsp {
80 
96 
102  static constexpr auto& LD1 = GPIOPortJ::Pin<0>;
103  static constexpr auto& LDA = LD1;
104  static constexpr auto& LedBlue = LD1;
105  static constexpr auto& LD2 = GPIOPortJ::Pin<1>;
106  static constexpr auto& LDB = LD2;
107  static constexpr auto& LedRed = LD2;
108  static constexpr auto& LD3 = GPIOPortJ::Pin<2>;
109  static constexpr auto& LDC = LD3;
110  static constexpr auto& LedYellow = LD3;
111  static constexpr auto& LD4 = GPIOPortJ::Pin<3>;
112  static constexpr auto& LDD = LD4;
113  static constexpr auto& LedGreen = LD4;
114 
115  static constexpr auto& Heartbeat = GPIOPortD::Pin<11>;
116 
117  static constexpr auto& EncoderButton = GPIOPortK::Pin<3, drv::Active::Low>;
118 
119  static constexpr auto& LeftJoyStickButton = GPIOPortE::Pin<9, drv::Active::Low>;
120  static constexpr auto& ButtonJoystickA = LeftJoyStickButton;
121  static constexpr auto& RightJoyStickButton = GPIOPortE::Pin<7, drv::Active::Low>;
122  static constexpr auto& ButtonJoystickB = RightJoyStickButton;
123 
124  static constexpr auto& ButtonA = GPIOPortJ::Pin<4, drv::Active::Low>;
125  static constexpr auto& ButtonB = GPIOPortJ::Pin<5, drv::Active::Low>;
126  static constexpr auto& ButtonC = GPIOPortJ::Pin<6, drv::Active::Low>;
127  static constexpr auto& ButtonD = GPIOPortJ::Pin<7, drv::Active::Low>;
128 
129  static constexpr auto& DriverA = GPIOPortB::Pin<3>;
130  static constexpr auto& LD5 = DriverA;
131  static constexpr auto& LDE = DriverA;
132  static constexpr auto& DriverB = GPIOPortB::Pin<4>;
133  static constexpr auto& LD6 = DriverB;
134  static constexpr auto& LDF = DriverB;
135  static constexpr auto& DriverC = GPIOPortB::Pin<14>;
136  static constexpr auto& LD7 = DriverC;
137  static constexpr auto& LDG = DriverC;
138  static constexpr auto& DriverD = GPIOPortB::Pin<15>;
139  static constexpr auto& LD8 = DriverD;
140  static constexpr auto& LDH = DriverD;
141 
149 
155  static constexpr auto& ADCA = ADConverter1::Channel<0>;
156  static constexpr auto& ADCB = ADConverter1::Channel<1>;
157  static constexpr auto& ADCC = ADConverter1::Channel<2>;
158  static constexpr auto& ADCD = ADConverter1::Channel<6>;
159  static constexpr auto& ADCPotentiometer = ADConverter1::Channel<15>;
160  static constexpr auto& ADCTemperature = ADConverter2::Channel<12>;
161 
168 
174  static constexpr auto& DACA = DAConverter1::Channel<1>;
175  static constexpr auto& DACB = DAConverter1::Channel<2>;
176 
182  namespace seven_segment {
183 
184  static constexpr auto& A = GPIOPortK::Pin<0>;
185  static constexpr auto& B = GPIOPortK::Pin<1>;
186  static constexpr auto& C = GPIOPortK::Pin<2>;
187  static constexpr auto& D = GPIOPortK::Pin<3>;
188  static constexpr auto& E = GPIOPortK::Pin<4>;
189  static constexpr auto& F = GPIOPortK::Pin<5>;
190  static constexpr auto& G = GPIOPortK::Pin<6>;
191  static constexpr auto& DP = GPIOPortK::Pin<7>;
192 
193  static constexpr auto& All = GPIOPortK::Out<0,7>;
194 
195  static constexpr auto& Select0 = GPIOPortJ::Pin<12>;
196  static constexpr auto& Select1 = GPIOPortJ::Pin<13>;
197  static constexpr auto& Select2 = GPIOPortJ::Pin<14>;
198  static constexpr auto& Select3 = GPIOPortJ::Pin<15>;
199 
200  static constexpr auto& SelectAll = GPIOPortJ::Out<12,15>;
201 
202  }
212 
221 
222  static constexpr auto& SPIACE = GPIOPortI::Pin<0, drv::Active::Low>;
223  static constexpr auto& SK9822_EN = GPIOPortE::Pin<10>;
224  static constexpr auto& SPIBCE = GPIOPortF::Pin<5, drv::Active::Low>;
225  static constexpr auto& SPICCE = GPIOPortH::Pin<5, drv::Active::Low>;
226 
235  using UARTST = UARTC;
236 
244 
257 
258  using SinkDriverTimerA = TimerA;
259  using SinkDriverTimerB = TimerE;
260  using SinkDriverTimerC = TimerD;
261  using SinkDriverTimerD = TimerD;
262 
268  static constexpr auto& TimerACHA = TimerA::Channel<3>;
269 
270  static constexpr auto& TimerBCHA = TimerB::Channel<1>;
271  static constexpr auto& TimerBCHB = TimerB::Channel<2>;
272  static constexpr auto& TimerBCHC = TimerB::Channel<3>;
273  static constexpr auto& TimerBCHD = TimerB::Channel<4>;
274 
275  static constexpr auto& TimerCCHA = TimerC::Channel<1>;
276 
277  static constexpr auto& SinkDriverTimerCHA = SinkDriverTimerA::Channel<2>;
278  static constexpr auto& SinkDriverTimerCHB = SinkDriverTimerB::Channel<1>;
279  static constexpr auto& SinkDriverTimerCHC = SinkDriverTimerC::Channel<1>;
280  static constexpr auto& SinkDriverTimerCHD = SinkDriverTimerD::Channel<2>;
281 
282  static constexpr auto& Encoder = TimerF::Encoder;
283 
284  static constexpr auto& ProfileCounter = TimerG::ProfileCounter;
285 
291  static constexpr auto& TC78Mode = GPIOPortF::Pin<3>;
292  static constexpr auto& TC78Err = GPIOPortG::Pin<9, drv::Active::Low>;
293  static constexpr auto& TC78Stby = GPIOPortI::Pin<10, drv::Active::Low>;
294 
301 
308 
313  }
314 
315 #endif
bsp::drv::SPI
Base class for SPI abstraction.
Definition: spi.hpp:51
timer.hpp
Timer Channel abstraction implementation for Asgard.
instructions.hpp
Assembly instruction wrapper functions.
bsp::drv::I2C
Base class for I2C abstraction.
Definition: i2c.hpp:43
uart.hpp
UART abstraction implementation for Asgard.
hash.hpp
HASH/CRC abstraction implementation for Asgard.
spi.hpp
SPI abstraction implementation for Asgard.
i2c.hpp
I2C abstraction implementation for Asgard.
bsp::drv::Hash
Base class for the Hash abstraction.
Definition: hash.hpp:42
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::Random
Base class for the RNG abstraction.
Definition: rng.hpp:42
adc.hpp
ADC Channel abstraction implementation for Asgard.
rng.hpp
RNG abstraction implementation for Asgard.
bsp::drv::Timer
Base class for Timer abstraction.
Definition: timer.hpp:41
can.hpp
CAN abstraction implementation for Asgard.
bsp
Definition: cortex.hpp:33
cortex.hpp
Core control functions for Asgard coprocessor.
bsp::drv::UART
Base class for UART abstraction.
Definition: uart.hpp:43
gpio.hpp
GPIO Pin abstraction implementation for Asgard.
bsp::drv::DAConverter
Base class for DAC abstraction.
Definition: dac.hpp:40
dac.hpp
DAC Channel abstraction implementation for Asgard.