libyggdrasil  v1.0.0
interfaces.h
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 
30 #include <c/midgard/core/cortex.h>
31 
32 #include <c/midgard/driver/gpio.h>
33 #include <c/midgard/driver/adc.h>
34 #include <c/midgard/driver/dac.h>
35 #include <c/midgard/driver/can.h>
36 #include <c/midgard/driver/spi.h>
37 #include <c/midgard/driver/i2c.h>
38 #include <c/midgard/driver/uart.h>
39 #include <c/midgard/driver/timer.h>
41 #include <c/midgard/driver/hash.h>
42 #include <c/midgard/driver/rng.h>
43 
44 #if defined(YGGDRASIL_PERIPHERAL_DEFS)
45 
50  extern I2C_HandleTypeDef hi2c1;
51  extern I2C_HandleTypeDef hi2c2;
52  extern I2C_HandleTypeDef hi2c3;
53  extern I2C_HandleTypeDef hi2c4;
54 
55  extern SPI_HandleTypeDef hspi2;
56  extern SPI_HandleTypeDef hspi4;
57  extern SPI_HandleTypeDef hspi5;
58 
59  extern TIM_HandleTypeDef htim2;
60  extern TIM_HandleTypeDef htim3;
61  extern TIM_HandleTypeDef htim4;
62  extern TIM_HandleTypeDef htim5;
63  extern TIM_HandleTypeDef htim8;
64  extern TIM_HandleTypeDef htim11;
65  extern TIM_HandleTypeDef htim12;
66 
67  extern ADC_HandleTypeDef hadc1;
68  extern ADC_HandleTypeDef hadc2;
69  extern ADC_HandleTypeDef hadc3;
70 
71  extern DAC_HandleTypeDef hdac;
72 
73  extern LTDC_HandleTypeDef hltdc;
74  extern DSI_HandleTypeDef hdsi;
75  extern DMA2D_HandleTypeDef hdma2d;
76 
77  extern CAN_HandleTypeDef hcan1;
78  extern CAN_HandleTypeDef hcan2;
79 
80  extern UART_HandleTypeDef huart4;
81  extern UART_HandleTypeDef huart8;
82  extern UART_HandleTypeDef huart2;
90  const static gpio_t LD1 = { GPIOJ, 0 };
91  const static gpio_t LDA = LD1;
92  const static gpio_t LedBlue = LD1;
93  const static gpio_t LD2 = { GPIOJ, 1 };
94  const static gpio_t LDB = LD2;
95  const static gpio_t LedRed = LD2;
96  const static gpio_t LD3 = { GPIOJ, 2 };
97  const static gpio_t LDC = LD3;
98  const static gpio_t LedYellow = LD3;
99  const static gpio_t LD4 = { GPIOJ, 3 };
100  const static gpio_t LDD = LD4;
101  const static gpio_t LedGreen = LD4;
102 
103  const static gpio_t Heartbeat = { GPIOA, 10 };
104 
105  const static gpio_t EncoderButton = { GPIOK, 3, LOW_ACTIVE };
106 
107  const static gpio_t LeftJoyStickButton = { GPIOG, 10, LOW_ACTIVE };
108  const static gpio_t ButtonJoystickA = LeftJoyStickButton;
109  const static gpio_t RightJoyStickButton = { GPIOG, 11, LOW_ACTIVE };
110  const static gpio_t ButtonJoystickB = RightJoyStickButton;
111 
112  const static gpio_t ButtonA = { GPIOK, 4, LOW_ACTIVE };
113  const static gpio_t ButtonB = { GPIOK, 5, LOW_ACTIVE };
114  const static gpio_t ButtonC = { GPIOK, 6, LOW_ACTIVE };
115  const static gpio_t ButtonD = { GPIOK, 7, LOW_ACTIVE };
116 
117  const static gpio_t DriverA = { GPIOC, 13 };
118  const static gpio_t LD5 = DriverA;
119  const static gpio_t LDE = DriverA;
120  const static gpio_t DriverB = { GPIOI, 8 };
121  const static gpio_t LD6 = DriverB;
122  const static gpio_t LDF = DriverB;
123  const static gpio_t DriverC = { GPIOB, 0 };
124  const static gpio_t LD7 = DriverC;
125  const static gpio_t LDG = DriverC;
126  const static gpio_t DriverD = { GPIOB, 1 };
127  const static gpio_t LD8 = DriverD;
128  const static gpio_t LDH = DriverD;
129 
135  const static adc_t ADCA = { &hadc1, 3, 0, 1 << 12 };
136  const static adc_t ADCB = { &hadc1, 10, 0, 1 << 12 };
137  const static adc_t ADCC = { &hadc3, 14, 0, 1 << 12 };
138  const static adc_t ADCD = { &hadc3, 15, 0, 1 << 12 };
139  const static adc_t ADCPotentiometer = { &hadc2, 13, 0, 1 << 12 };
140  const static adc_t ADCTemperature = { &hadc1, 18, 0, 1 << 12 };
141 
147  const static dac_t DACA = { &hdac, 1, 0, 1 << 12 };
148  const static dac_t DACB = { &hdac, 2, 0, 1 << 12 };
149 
155  const static gpio_t SevenSegment_A = { GPIOG, 0 };
156  const static gpio_t SevenSegment_B = { GPIOG, 1 };
157  const static gpio_t SevenSegment_C = { GPIOG, 2 };
158  const static gpio_t SevenSegment_D = { GPIOG, 3 };
159  const static gpio_t SevenSegment_E = { GPIOG, 4 };
160  const static gpio_t SevenSegment_F = { GPIOG, 5 };
161  const static gpio_t SevenSegment_G = { GPIOG, 6 };
162  const static gpio_t SevenSegment_DP = { GPIOG, 7 };
163 
164  const static gpio_t SevenSegment_Select0 = { GPIOJ, 12 };
165  const static gpio_t SevenSegment_Select1 = { GPIOJ, 13 };
166  const static gpio_t SevenSegment_Select2 = { GPIOJ, 14 };
167  const static gpio_t SevenSegment_Select3 = { GPIOJ, 15 };
168 
174  const static i2c_t I2CA = { &hi2c2 };
175  const static i2c_t I2CB = { &hi2c4 };
176  const static i2c_t I2CC = { &hi2c3 };
177  const static i2c_t I2CD = { &hi2c1 };
178 
184  const static spi_t SPIA = { &hspi2 };
185  const static spi_t SPIB = { &hspi4 };
186  const static spi_t SPIC = { &hspi5 };
187 
188  const static gpio_t SPIACE = { GPIOI, 0, LOW_ACTIVE };
189  const static gpio_t SK9822_EN = { GPIOD, 9 };
190  const static gpio_t SPIBCE = { GPIOE, 11, LOW_ACTIVE };
191  const static gpio_t SPICCE = { GPIOH, 5, LOW_ACTIVE };
192 
198  const static uart_t UARTA = { &huart2 };
199  const static uart_t UARTB = { &huart8 };
200  const static uart_t UARTC = { &huart4 };
201  const static uart_t UASRTST = UARTC;
202 
208  const static can_t CANA = { &hcan1 };
209  const static can_t CANB = { &hcan2 };
210 
216  const static tim_t TimerA = { &htim12, sizeof(u16) };
217  const static tim_t TimerB = { &htim4, sizeof(u16) };
218  const static tim_t TimerC = { &htim5, sizeof(u32) };
219  const static tim_t TimerD = { &htim3, sizeof(u16) };
220  const static tim_t TimerE = { &htim11, sizeof(u16) };
221  const static tim_t TimerF = { &htim8, sizeof(u16) };
222  const static tim_t TimerG = { &htim2, sizeof(u32) };
223 
224  const static tim_t SinkDriverTimerA = TimerD;
225  const static tim_t SinkDriverTimerB = TimerD;
226  const static tim_t SinkDriverTimerC = TimerD;
227  const static tim_t SinkDriverTimerD = TimerD;
228 
234  const static tim_channel_t TimerACHA = { TimerA, 1 };
235 
236  const static tim_channel_t TimerBCHA = { TimerB, 1 };
237  const static tim_channel_t TimerBCHB = { TimerB, 2 };
238  const static tim_channel_t TimerBCHC = { TimerB, 3 };
239  const static tim_channel_t TimerBCHD = { TimerB, 4 };
240 
241  const static tim_channel_t TimerCCHA = { TimerC, 1 };
242 
243  const static tim_channel_t TimerDCHA = { SinkDriverTimerA, 2 };
244  const static tim_channel_t TimerDCHB = { SinkDriverTimerB, 1 };
245  const static tim_channel_t TimerDCHC = { SinkDriverTimerC, 3 };
246  const static tim_channel_t TimerDCHD = { SinkDriverTimerD, 4 };
247 
248  const static tim_t Encoder = TimerF;
249 
250  const static tim_t ProfileCounter = TimerG;
251 
257  const static gpio_t TC78Mode = { GPIOI, 12 };
258  const static gpio_t TC78Err = { GPIOI, 13, LOW_ACTIVE };
259  const static gpio_t TC78Stby = { GPIOI, 14, LOW_ACTIVE };
260 
266  const static rng_t Random = { };
267 
269  #endif
u16
uint16_t u16
Definition: types.h:37
dac_t
DAC handle type.
Definition: dac.h:33
gpio.h
GPIO Pin abstraction implementation for Midgard.
tim_t
Timer handle type.
Definition: timer.h:33
spi.h
SPI abstraction implementation for Midgard.
can_t
CAN handle type.
Definition: can.h:33
display.h
Display abstraction implementation for Midgard.
adc.h
ADC abstraction implementation for Midgard.
adc_t
ADC handle type.
Definition: adc.h:33
cortex.h
Core control functions.
rng.h
RNG abstraction implementation for Midgard.
u32
uint32_t u32
Definition: types.h:38
uart.h
UART abstraction implementation for Midgard.
hdsi
DSI_HandleTypeDef hdsi
timer.h
Timer abstraction implementation for Midgard.
uart_t
UART handle type.
Definition: uart.h:33
tim_channel_t
Timer channel handle type.
Definition: timer.h:41
dac.h
DAC abstraction implementation for Midgard.
i2c_t
I2C handle type.
Definition: i2c.h:31
gpio_t
GPIO handle type.
Definition: gpio.h:34
LOW_ACTIVE
#define LOW_ACTIVE
Definition: gpio.h:28
rng_t
RNG handle type.
Definition: rng.h:33
spi_t
SPI handle type.
Definition: spi.h:33
hash.h
Hash abstraction implementation for Midgard.
i2c.h
I2C abstraction implementation for Midgard.
can.h
CAN abstraction implementation for Midgard.