rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
port_mpu_util.h
Go to the documentation of this file.
1/**
2 * @file port_mpu_util.h
3 * @brief Low level common STM32 header
4 *
5 * @date Aug 3, 2019
6 * @author Andrey Belomutskiy, (c) 2012-2020
7 */
8
9#pragma once
10
11#include "device_mpu_util.h"
12
13#define PORT_SIZE 16
14
15#define MCU_SERIAL_NUMBER_BYTES 12
16
17// 4mhz was chosen because it's the GCD of (84, 108, 200), the three speeds of STM32 TIM5 clock currently supported
18// https://www.wolframalpha.com/input/?i=common+factors+of+168+180+216
19#define US_TO_NT_MULTIPLIER (4)
20
21// Scheduler queue timer - use TIM5
22#define SCHEDULER_PWM_DEVICE PWMD5
23#define SCHEDULER_TIMER_DEVICE TIM5
24#define SCHEDULER_TIMER_FREQ (US_TO_NT_MULTIPLIER * 1'000'000)
25
26/* TODO: rename includes to hal_flash_ex.h with no MCU specific? */
27#ifdef STM32F4XX
29#endif
30#ifdef STM32F7XX
32#endif
33#ifdef STM32H7XX
35#endif
36
37#define TM_ID_GetFlashSize() (*(__IO uint16_t *) (FLASHSIZE_BASE))
38
39#ifdef AT32F4XX
40/* TODO: Artery */
41typedef enum {
42 BOR_Level_None = PWR_CR_PLS_LEV0, // 0x0C=12 Supply voltage ranges from 1.62 to 2.10 V
43 BOR_Level_1 = PWR_CR_PLS_LEV1, // 0x08 Supply voltage ranges from 2.10 to 2.40 V
44 BOR_Level_2 = PWR_CR_PLS_LEV3, // 0x04 Supply voltage ranges from 2.40 to 2.70 V
45 BOR_Level_3 = PWR_CR_PLS_LEV7 // 0x00 Supply voltage ranges from 2.70 to 3.60 V
47#else
48typedef enum {
49 BOR_Level_None = OB_BOR_OFF, // 0x0C=12 Supply voltage ranges from 1.62 to 2.10 V
50 BOR_Level_1 = OB_BOR_LEVEL1, // 0x08 Supply voltage ranges from 2.10 to 2.40 V
51 BOR_Level_2 = OB_BOR_LEVEL2, // 0x04 Supply voltage ranges from 2.40 to 2.70 V
52 BOR_Level_3 = OB_BOR_LEVEL3 // 0x00 Supply voltage ranges from 2.70 to 3.60 V
54#endif
55
56// we are lucky - all CAN1/CAN2 pins use the same AF
57#define EFI_CAN_RX_AF 9
58#define EFI_CAN_TX_AF 9
59
60// not lucky with CAN3 and FDCAN3
61#if STM32_CAN_USE_CAN3
62#define EFI_CAN3_RX_AF 11
63#define EFI_CAN3_TX_AF 11
64#endif
65#if STM32_CAN_USE_FDCAN3
66// PD12/PD13
67#define EFI_CAN3_RX_AF 5
68#define EFI_CAN3_TX_AF 5
69// TODO: PG9/PG10 and PF6/PF7
70//#define EFI_CAN3_RX_AF 2
71//#define EFI_CAN3_TX_AF 2
72#endif
73
74#ifndef GPIO_AF_TIM1
75#define GPIO_AF_TIM1 1
76#endif
77
78#ifndef GPIO_AF_TIM2
79#define GPIO_AF_TIM2 1
80#endif
81
82#ifndef GPIO_AF_TIM3
83#define GPIO_AF_TIM3 2
84#endif
85
86#ifndef GPIO_AF_TIM4
87#define GPIO_AF_TIM4 2
88#endif
89
90#ifndef GPIO_AF_TIM5
91#define GPIO_AF_TIM5 2
92#endif
93
94#ifndef GPIO_AF_TIM8
95#define GPIO_AF_TIM8 3
96#endif
97
98#ifndef GPIO_AF_TIM9
99#define GPIO_AF_TIM9 3
100#endif
101
102#ifndef GPIO_AF_TIM12
103#define GPIO_AF_TIM12 9
104#endif
105
106#ifndef GPIO_AF_TIM13
107#define GPIO_AF_TIM13 9
108#endif
109
110#ifndef GPIO_AF_TIM14
111#define GPIO_AF_TIM14 9
112#endif
113
114#ifndef ADC_CR2_SWSTART
115#define ADC_CR2_SWSTART ((uint32_t)0x40000000)
116#endif
117
118#ifdef __cplusplus
119uint32_t getMcuSerial();
120
121void stm32_standby();
122
123// Called just before the MCU is put in stop mode
125
126// Called just before the MCU is put in standby mode
128#endif
BOR_Level_t
@ BOR_Level_None
@ BOR_Level_1
@ BOR_Level_3
@ BOR_Level_2
void boardPrepareForStop()
uint32_t getMcuSerial()
void boardPrepareForStandby()
void stm32_standby()
Definition mpu_util.cpp:18
Header file of FLASH HAL Extension module.
Header file of FLASH HAL Extension module.
Header file of FLASH HAL module.