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 CAN pins use the same AF
57#define EFI_CAN_RX_AF 9
58#define EFI_CAN_TX_AF 9
59
60#ifndef GPIO_AF_TIM1
61#define GPIO_AF_TIM1 1
62#endif
63
64#ifndef GPIO_AF_TIM2
65#define GPIO_AF_TIM2 1
66#endif
67
68#ifndef GPIO_AF_TIM3
69#define GPIO_AF_TIM3 2
70#endif
71
72#ifndef GPIO_AF_TIM4
73#define GPIO_AF_TIM4 2
74#endif
75
76#ifndef GPIO_AF_TIM5
77#define GPIO_AF_TIM5 2
78#endif
79
80#ifndef GPIO_AF_TIM8
81#define GPIO_AF_TIM8 3
82#endif
83
84#ifndef GPIO_AF_TIM9
85#define GPIO_AF_TIM9 3
86#endif
87
88#ifndef GPIO_AF_TIM12
89#define GPIO_AF_TIM12 9
90#endif
91
92#ifndef GPIO_AF_TIM13
93#define GPIO_AF_TIM13 9
94#endif
95
96#ifndef GPIO_AF_TIM14
97#define GPIO_AF_TIM14 9
98#endif
99
100#ifndef ADC_CR2_SWSTART
101#define ADC_CR2_SWSTART ((uint32_t)0x40000000)
102#endif
103
104#ifdef __cplusplus
105uint32_t getMcuSerial();
106
107void stm32_standby();
108
109// Called just before the MCU is put in stop mode
111
112// Called just before the MCU is put in standby mode
114#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.