rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions | Variables
mpu_util.h File Reference

Detailed Description

Date
Jul 27, 2014
Author
Andrey Belomutskiy, (c) 2012-2020
andreika prome.nosp@m.theu.nosp@m.s.pcb.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition in file mpu_util.h.

Data Structures

struct  hardware_pwm
 

Enumerations

enum  BOR_Result_t { BOR_Result_Ok = 0x00 , BOR_Result_Error }
 
enum  Reset_Cause_t {
  Reset_Cause_Unknown = 0 , Reset_Cause_IWatchdog , Reset_Cause_WWatchdog , Reset_Cause_Soft_Reset ,
  Reset_Cause_NRST_Pin , Reset_Cause_POR , Reset_Cause_Illegal_Mode , Reset_Cause_BOR ,
  Reset_Cause_Firewall , Reset_Cause_Option_Byte
}
 

Functions

void baseMCUInit ()
 
void jump_to_bootloader ()
 
void jump_to_openblt ()
 
void causeHardFault ()
 
bool mcuCanFlashWhileRunning ()
 
bool isStm32F42x ()
 
adc_channel_e getAdcChannel (brain_pin_e pin)
 
brain_pin_e getAdcChannelBrainPin (const char *msg, adc_channel_e hwChannel)
 
bool adcIsMuxedInput (adc_channel_e hwChannel)
 
adc_channel_e adcMuxedGetParent (adc_channel_e hwChannel)
 
int getAdcInternalChannel (ADC_TypeDef *adc, adc_channel_e hwChannel)
 
adc_channel_e getHwChannelForAdcInput (ADC_TypeDef *adc, size_t hwIndex)
 
ioportid_t getAdcChannelPort (const char *msg, adc_channel_e hwChannel)
 
int getAdcChannelPin (adc_channel_e hwChannel)
 
void portInitAdc ()
 
float getMcuTemperature ()
 
float getMcuVrefVoltage ()
 
bool readSlowAnalogInputs (adcsample_t *convertedSamples)
 
bool isValidCanTxPin (brain_pin_e pin)
 
bool isValidCanRxPin (brain_pin_e pin)
 
CANDriver * detectCanDevice (brain_pin_e pinRx, brain_pin_e pinTx)
 
void canHwInfo (CANDriver *cand)
 
bool isValidSerialTxPin (brain_pin_e pin)
 
bool isValidSerialRxPin (brain_pin_e pin)
 
void initSpiModule (SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, brain_pin_e mosi, int sckMode, int mosiMode, int misoMode)
 
void initSpiCsNoOccupy (SPIConfig *spiConfig, brain_pin_e csPin)
 
void initSpiCs (SPIConfig *spiConfig, brain_pin_e csPin)
 
void turnOnSpi (spi_device_e device)
 
int spiGetBaseClock (SPIDriver *spip)
 
int spiCalcClockDiv (SPIDriver *spip, SPIConfig *spiConfig, unsigned int clk)
 
bool getIcuParams (brain_pin_e hwPin, iomode_t *af_ptr, ICUDriver **icu_ptr, icuchannel_t *channel_ptr, uint32_t *clock_ptr)
 
BOR_Level_t BOR_Get (void)
 
BOR_Result_t BOR_Set (BOR_Level_t BORValue)
 
Reset_Cause_t getMCUResetCause ()
 
const chargetMCUResetCause (Reset_Cause_t cause)
 
int at32GetMcuType (uint32_t id, const char **pn, const char **package, uint32_t *flashSize)
 
int at32GetRamSizeKb (void)
 
void DebugMonitorVector (void)
 
void UsageFaultVector (void)
 
void BusFaultVector (void)
 
void HardFaultVector (void)
 

Variables

SPIConfig mmc_hs_spicfg
 
SPIConfig mmc_ls_spicfg
 

Enumeration Type Documentation

◆ BOR_Result_t

Enumerator
BOR_Result_Ok 
BOR_Result_Error 

Definition at line 95 of file mpu_util.h.

95 {
96 BOR_Result_Ok = 0x00,
BOR_Result_t
Definition mpu_util.h:95
@ BOR_Result_Ok
Definition mpu_util.h:96
@ BOR_Result_Error
Definition mpu_util.h:97

◆ Reset_Cause_t

Enumerator
Reset_Cause_Unknown 
Reset_Cause_IWatchdog 
Reset_Cause_WWatchdog 
Reset_Cause_Soft_Reset 
Reset_Cause_NRST_Pin 
Reset_Cause_POR 
Reset_Cause_Illegal_Mode 
Reset_Cause_BOR 
Reset_Cause_Firewall 
Reset_Cause_Option_Byte 

Definition at line 104 of file mpu_util.h.

104 {
106 Reset_Cause_IWatchdog, // Independent hardware watchdog (we use it)
107 Reset_Cause_WWatchdog, // Window watchdog
108 Reset_Cause_Soft_Reset, // NVIC_SystemReset or by debugger
109 Reset_Cause_NRST_Pin, // Reset from NRST pin
110 Reset_Cause_POR, // POR/PDR reset
111 Reset_Cause_Illegal_Mode, // Reset after illegal Stop, Standby or Shutdown mode entry
112 Reset_Cause_BOR, // BOR reset
113 Reset_Cause_Firewall, // Firewall reset
114 Reset_Cause_Option_Byte, // Option byte load reset
Reset_Cause_t
Definition mpu_util.h:104
@ Reset_Cause_WWatchdog
Definition mpu_util.h:107
@ Reset_Cause_Firewall
Definition mpu_util.h:113
@ Reset_Cause_Soft_Reset
Definition mpu_util.h:108
@ Reset_Cause_Illegal_Mode
Definition mpu_util.h:111
@ Reset_Cause_NRST_Pin
Definition mpu_util.h:109
@ Reset_Cause_Unknown
Definition mpu_util.h:105
@ Reset_Cause_POR
Definition mpu_util.h:110
@ Reset_Cause_IWatchdog
Definition mpu_util.h:106
@ Reset_Cause_BOR
Definition mpu_util.h:112
@ Reset_Cause_Option_Byte
Definition mpu_util.h:114

Function Documentation

◆ adcIsMuxedInput()

bool adcIsMuxedInput ( adc_channel_e  hwChannel)

Definition at line 150 of file cypress_common.cpp.

150 {
151 return false;
152}

Referenced by adcMuxedGetParent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adcMuxedGetParent()

adc_channel_e adcMuxedGetParent ( adc_channel_e  hwChannel)

Definition at line 154 of file cypress_common.cpp.

155{
156 return hwChannel;
157}

Referenced by getAdcChannelBrainPin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at32GetMcuType()

int at32GetMcuType ( uint32_t  id,
const char **  pn,
const char **  package,
uint32_t *  flashSize 
)

Definition at line 12 of file at32_common.cpp.

13{
14 const struct {
15 uint32_t uid;
16 const char *pn;
17 uint32_t flashSize;
18 const char *package;
19 } at32f43x_types[] = {
20 { 0x70084540, "AT32F435ZMT7", 4032, "LQFP144" },
21 { 0x70083341, "AT32F435ZGT7", 1024, "LQFP144" },
22 { 0x70084598, "AT32F435ZDT7", 448, "LQFP144" },
23 { 0x70083242, "AT32F435ZCT7", 256, "LQFP144" },
24 { 0x70084543, "AT32F435VMT7", 4032, "LQFP100" },
25 { 0x70083344, "AT32F435VGT7", 1024, "LQFP100" },
26 { 0x70084599, "AT32F435VDT7", 448, "LQFP100" },
27 { 0x70083245, "AT32F435VCT7", 256, "LQFP100" },
28 { 0x70084546, "AT32F435RMT7", 4032, "LQFP64" },
29 { 0x70083347, "AT32F435RGT7", 1024, "LQFP64" },
30 { 0x7008459A, "AT32F435RDT7", 448, "LQFP64" },
31 { 0x70083248, "AT32F435RCT7", 256, "LQFP64" },
32 { 0x70084549, "AT32F435CMT7", 4032, "LQFP48" },
33 { 0x7008334A, "AT32F435CGT7", 1024, "LQFP48" },
34 { 0x7008459B, "AT32F435CDT7", 448, "LQFP48" },
35 { 0x7008324B, "AT32F435CCT7", 256, "LQFP48" },
36 { 0x7008454C, "AT32F435CMU7", 4032, "QFN48" },
37 { 0x7008334D, "AT32F435CGU7", 1024, "QFN48" },
38 { 0x7008459C, "AT32F435CDU7", 448, "QFN48" },
39 { 0x7008324E, "AT32F435CCU7", 256, "QFN48" },
40 { 0x7008454F, "AT32F437ZMT7", 4032, "LQFP144" },
41 { 0x70083350, "AT32F437ZGT7", 1024, "LQFP144" },
42 { 0x7008459D, "AT32F437ZDT7", 448, "LQFP144" },
43 { 0x70083251, "AT32F437ZCT7", 256, "LQFP144" },
44 { 0x70084552, "AT32F437VMT7", 4032, "LQFP100" },
45 { 0x70083353, "AT32F437VGT7", 1024, "LQFP100" },
46 { 0x7008459E, "AT32F437VDT7", 448, "LQFP100" },
47 { 0x70083254, "AT32F437VCT7", 256, "LQFP100" },
48 { 0x70084555, "AT32F437RMT7", 4032, "LQFP64" },
49 { 0x70083356, "AT32F437RGT7", 1024, "LQFP64" },
50 { 0x7008459F, "AT32F437RDT7", 448, "LQFP64" },
51 { 0x70083257, "AT32F437RCT7", 256, "LQFP64" },
52 };
53
54 for (size_t i = 0; i < efi::size(at32f43x_types); i++) {
55 if (id == at32f43x_types[i].uid) {
56 if (pn)
57 *pn = at32f43x_types[i].pn;
58 if (package)
59 *package = at32f43x_types[i].package;
60 if (flashSize)
61 *flashSize = at32f43x_types[i].flashSize;
62 return 0;
63 }
64 }
65
66 /* unknown */
67 return -1;
68}
static uint16_t flashSize()
Definition mpu_util.cpp:21

Referenced by sayHello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at32GetRamSizeKb()

int at32GetRamSizeKb ( void  )

Definition at line 70 of file at32_common.cpp.

71{
72 uint8_t EOPB0 = *(__IO uint16_t *) (0x1FFFC010);
73 /* TODO: check inverted value */
74
75 switch ((*(__IO uint16_t *) (FLASHSIZE_BASE))) {
76 case 256:
77 EOPB0 &= 0x03;
78 if (EOPB0 == 3)
79 EOPB0 = 2;
80 return 512 - (64 * EOPB0);
81 case 448:
82 EOPB0 &= 0x07;
83 if (EOPB0 > 5)
84 EOPB0 = 5;
85 return 512 - (64 * EOPB0);
86 case 1024:
87 case 4032:
88 EOPB0 &= 0x07;
89 if (EOPB0 > 6)
90 EOPB0 = 6;
91 return 512 - (64 * EOPB0);
92 default:
93 return 0;
94 }
95 return 0;
96}

Referenced by sayHello().

Here is the caller graph for this function:

◆ baseMCUInit()

void baseMCUInit ( )

Definition at line 146 of file at32_common.cpp.

146 {
147 // looks like this holds a random value on start? Let's set a nice clean zero
148 DWT->CYCCNT = 0;
149
150 BOR_Set(BOR_Level_1); // one step above default value
151}
BOR_Result_t BOR_Set(BOR_Level_t BORValue)
@ BOR_Level_1

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BOR_Get()

BOR_Level_t BOR_Get ( void  )

Definition at line 126 of file at32_common.cpp.

126 {
127 /* TODO: Artery */
128 /* Fake */
129 return BOR_Level_None;
130}
@ BOR_Level_None

Referenced by BOR_Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BOR_Set()

BOR_Result_t BOR_Set ( BOR_Level_t  BORValue)

Definition at line 132 of file at32_common.cpp.

132 {
133 /* NOP */
134 return BOR_Result_Ok;
135}

Referenced by baseMCUInit(), and setBor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BusFaultVector()

void BusFaultVector ( void  )

Definition at line 56 of file mpu_util.cpp.

56 {
57 chDbgPanic3("BusFaultVector", __FILE__, __LINE__);
58 while (TRUE) {
59 }
60}
void chDbgPanic3(const char *, const char *, int)
Here is the call graph for this function:

◆ canHwInfo()

void canHwInfo ( CANDriver *  cand)

Definition at line 129 of file at32_can.cpp.

130{
131 /* TODO: */
132 (void)cand;
133}

Referenced by canInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ causeHardFault()

void causeHardFault ( )

Definition at line 16 of file arm_common.cpp.

16 {
17#if EFI_PROD_CODE
18 // Set the function pointer to an invalid address
19 void (*invalidFunction)() = (void(*)())0xDEADBEEF;
20 // Calling the invalid function will trigger a hard fault
21 invalidFunction();
22#endif /* EFI_PROD_CODE */
23}

Referenced by errorHandlerInit().

Here is the caller graph for this function:

◆ DebugMonitorVector()

void DebugMonitorVector ( void  )

Definition at line 44 of file mpu_util.cpp.

44 {
45 chDbgPanic3("DebugMonitorVector", __FILE__, __LINE__);
46 while (TRUE)
47 ;
48}
Here is the call graph for this function:

◆ detectCanDevice()

CANDriver * detectCanDevice ( brain_pin_e  pinRx,
brain_pin_e  pinTx 
)

Definition at line 93 of file at32_can.cpp.

93 {
94 if (pinRx == Gpio::Unassigned || pinTx == Gpio::Unassigned) {
95 return nullptr;
96 }
97#if STM32_CAN_USE_CAN1 || STM32_CAN_USE_FDCAN1
98 if (isValidCan1RxPin(pinRx) && isValidCan1TxPin(pinTx))
99 return &CAND1;
100#endif
101#if STM32_CAN_USE_CAN2 || STM32_CAN_USE_FDCAN2
102 if (isValidCan2RxPin(pinRx) && isValidCan2TxPin(pinTx))
103 return &CAND2;
104#endif
105 criticalError("invalid CAN pins tx %s and rx %s", hwPortname(pinTx), hwPortname(pinRx));
106 return nullptr;
107}
static bool isValidCan2RxPin(brain_pin_e pin)
Definition at32_can.cpp:77
static bool isValidCan1RxPin(brain_pin_e pin)
Definition at32_can.cpp:69
static bool isValidCan2TxPin(brain_pin_e pin)
Definition at32_can.cpp:81
static bool isValidCan1TxPin(brain_pin_e pin)
Definition at32_can.cpp:73
@ Unassigned
const char * hwPortname(brain_pin_e brainPin)

Referenced by canInfo(), and initCan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdcChannel()

adc_channel_e getAdcChannel ( brain_pin_e  pin)

Definition at line 103 of file cypress_common.cpp.

103 {
104 switch (pin) {
105 case Gpio::B0:
106 return EFI_ADC_0;
107 case Gpio::B1:
108 return EFI_ADC_1;
109 case Gpio::B2:
110 return EFI_ADC_2;
111 case Gpio::B3:
112 return EFI_ADC_3;
113 case Gpio::B4:
114 return EFI_ADC_4;
115 case Gpio::B5:
116 return EFI_ADC_5;
117 case Gpio::B8:
118 return EFI_ADC_8;
119 case Gpio::B9:
120 return EFI_ADC_9;
121 case Gpio::B12:
122 return EFI_ADC_12;
123 case Gpio::B13:
124 return EFI_ADC_13;
125 case Gpio::B14:
126 return EFI_ADC_14;
127 case Gpio::B15:
128 return EFI_ADC_15;
129 case Gpio::C10:
130 return EFI_ADC_24;
131 case Gpio::C9:
132 return EFI_ADC_25;
133 case Gpio::C8:
134 return EFI_ADC_26;
135 case Gpio::C7:
136 return EFI_ADC_27;
137 case Gpio::C5:
138 return EFI_ADC_28;
139 case Gpio::C4:
140 return EFI_ADC_29;
141 case Gpio::C3:
142 return EFI_ADC_30;
143 case Gpio::C2:
144 return EFI_ADC_31;
145 default:
146 return EFI_ADC_ERROR;
147 }
148}
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by getAdcChannelForTrigger(), and setAnalogInputPin().

Here is the caller graph for this function:

◆ getAdcChannelBrainPin()

brain_pin_e getAdcChannelBrainPin ( const char msg,
adc_channel_e  hwChannel 
)

Definition at line 30 of file cypress_common.cpp.

30 {
31 // todo: replace this with an array :)
32 switch (hwChannel) {
33 case EFI_ADC_0:
34 return Gpio::B0;
35 case EFI_ADC_1:
36 return Gpio::B1;
37 case EFI_ADC_2:
38 return Gpio::B2;
39 case EFI_ADC_3:
40 return Gpio::B3;
41 case EFI_ADC_4:
42 return Gpio::B4;
43 case EFI_ADC_5:
44 return Gpio::B5;
45 case EFI_ADC_6:
46 return Gpio::Invalid;
47 case EFI_ADC_7:
48 return Gpio::Invalid;
49 case EFI_ADC_8:
50 return Gpio::B8;
51 case EFI_ADC_9:
52 return Gpio::B9;
53 case EFI_ADC_10:
54 return Gpio::Invalid;
55 case EFI_ADC_11:
56 return Gpio::Invalid;
57 case EFI_ADC_12:
58 return Gpio::B12;
59 case EFI_ADC_13:
60 return Gpio::B13;
61 case EFI_ADC_14:
62 return Gpio::B14;
63 case EFI_ADC_15:
64 return Gpio::B15;
65 case EFI_ADC_16:
66 return Gpio::Invalid;
67 case EFI_ADC_17:
68 return Gpio::Invalid;
69 case EFI_ADC_18:
70 return Gpio::Invalid;
71 case EFI_ADC_19:
72 return Gpio::Invalid;
73 case EFI_ADC_20:
74 return Gpio::Invalid;
75 case EFI_ADC_21:
76 return Gpio::Invalid;
77 case EFI_ADC_22:
78 return Gpio::Invalid;
79 case EFI_ADC_23:
80 return Gpio::Invalid;
81 case EFI_ADC_24:
82 return Gpio::C10;
83 case EFI_ADC_25:
84 return Gpio::C9;
85 case EFI_ADC_26:
86 return Gpio::C8;
87 case EFI_ADC_27:
88 return Gpio::C7;
89 case EFI_ADC_28:
90 return Gpio::C5;
91 case EFI_ADC_29:
92 return Gpio::C4;
93 case EFI_ADC_30:
94 return Gpio::C3;
95 case EFI_ADC_31:
96 return Gpio::C2;
97 default:
98 firmwareError(ObdCode::CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
99 return Gpio::Invalid;
100 }
101}
@ Invalid
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_ADC_UNKNOWN_CHANNEL

Referenced by deInitIfValid(), getAdcChannelPin(), getAdcChannelPort(), and initIfValid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdcChannelPin()

int getAdcChannelPin ( adc_channel_e  hwChannel)

Definition at line 178 of file cypress_common.cpp.

178 {
179 return getHwPin("get_pin", getAdcChannelBrainPin("get_pin", hwChannel));
180}
brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)

Referenced by adcPrintChannelReport(), and getPinNameByAdcChannel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdcChannelPort()

ioportid_t getAdcChannelPort ( const char msg,
adc_channel_e  hwChannel 
)

Definition at line 173 of file cypress_common.cpp.

173 {
174 return getHwPort(msg, getAdcChannelBrainPin(msg, hwChannel));
175}
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)

Referenced by adcPrintChannelReport(), and getPinNameByAdcChannel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdcInternalChannel()

int getAdcInternalChannel ( ADC_TypeDef *  adc,
adc_channel_e  hwChannel 
)

Definition at line 159 of file cypress_common.cpp.

159 {
160 (void)adc;
161
162 return (hwChannel - EFI_ADC_0);
163}
uint16_t adc
Definition adc_inputs.h:103

◆ getHwChannelForAdcInput()

adc_channel_e getHwChannelForAdcInput ( ADC_TypeDef *  adc,
size_t  hwIndex 
)

Definition at line 165 of file cypress_common.cpp.

166{
167 (void)adc;
168
169 return (EFI_ADC_0 + hwIndex);
170}

◆ getIcuParams()

bool getIcuParams ( brain_pin_e  hwPin,
iomode_t af_ptr,
ICUDriver **  icu_ptr,
icuchannel_t *  channel_ptr,
uint32_t *  clock_ptr 
)

ChibiOS limitation is that only channels #1 and #2 could be used for input capture Could this be unified with getConfigForPin() method?

Definition at line 122 of file stm32_icu.cpp.

122 {
123 switch (hwPin) {
124 case Gpio::A0:
125 RETURN_ICU5(ICU_CHANNEL_1);
126 return false;
127 case Gpio::A1:
128 RETURN_ICU2(ICU_CHANNEL_2);
129 RETURN_ICU5(ICU_CHANNEL_2);
130 return false;
131 case Gpio::A2:
132 RETURN_ICU9(ICU_CHANNEL_1);
133 return false;
134 case Gpio::A3:
135 RETURN_ICU9(ICU_CHANNEL_2);
136 return false;
137 case Gpio::A5:
138 RETURN_ICU2(ICU_CHANNEL_1);
139 return false;
140 case Gpio::A6:
141 RETURN_ICU3(ICU_CHANNEL_1);
142 RETURN_ICU13(ICU_CHANNEL_1);
143 return false;
144 case Gpio::A7:
145 RETURN_ICU3(ICU_CHANNEL_2);
146 RETURN_ICU14(ICU_CHANNEL_1);
147 return false;
148 case Gpio::A8:
149 RETURN_ICU1(ICU_CHANNEL_1);
150 return false;
151 case Gpio::A9:
152 RETURN_ICU1(ICU_CHANNEL_2);
153 return false;
154 case Gpio::A15:
155 RETURN_ICU2(ICU_CHANNEL_1);
156 return false;
157 case Gpio::B3:
158 RETURN_ICU2(ICU_CHANNEL_2);
159 return false;
160 case Gpio::B4:
161 RETURN_ICU3(ICU_CHANNEL_1);
162 return false;
163 case Gpio::B5:
164 RETURN_ICU3(ICU_CHANNEL_2);
165 return false;
166 case Gpio::B6:
167 RETURN_ICU4(ICU_CHANNEL_1);
168 return false;
169 case Gpio::B7:
170 RETURN_ICU4(ICU_CHANNEL_2);
171 return false;
172 case Gpio::B8:
173 RETURN_ICU10(ICU_CHANNEL_1);
174 return false;
175 case Gpio::B9:
176 RETURN_ICU11(ICU_CHANNEL_1);
177 return false;
178 case Gpio::B14:
179 RETURN_ICU12(ICU_CHANNEL_1);
180 return false;
181 case Gpio::B15:
182 RETURN_ICU12(ICU_CHANNEL_2);
183 return false;
184 case Gpio::C6:
185 RETURN_ICU3(ICU_CHANNEL_1);
186 RETURN_ICU8(ICU_CHANNEL_1);
187 return false;
188 case Gpio::C7:
189 RETURN_ICU3(ICU_CHANNEL_2);
190 RETURN_ICU8(ICU_CHANNEL_2);
191 return false;
192 case Gpio::D12:
193 RETURN_ICU4(ICU_CHANNEL_1);
194 return false;
195 case Gpio::D13:
196 RETURN_ICU4(ICU_CHANNEL_2);
197 return false;
198 case Gpio::E5:
199 RETURN_ICU9(ICU_CHANNEL_1);
200 return false;
201 case Gpio::E6:
202 RETURN_ICU9(ICU_CHANNEL_2);
203 return false;
204 case Gpio::E9:
205 RETURN_ICU1(ICU_CHANNEL_1);
206 return false;
207 case Gpio::E11:
208 RETURN_ICU1(ICU_CHANNEL_2);
209 return false;
210 case Gpio::E14:
211 RETURN_ICU1(ICU_CHANNEL_4);
212 return false;
213 case Gpio::F6:
214 RETURN_ICU10(ICU_CHANNEL_1);
215 return false;
216 case Gpio::F7:
217 RETURN_ICU11(ICU_CHANNEL_1);
218 return false;
219 case Gpio::F8:
220 RETURN_ICU13(ICU_CHANNEL_1);
221 return false;
222 case Gpio::F9:
223 RETURN_ICU14(ICU_CHANNEL_1);
224 return false;
225 case Gpio::H6:
226 RETURN_ICU12(ICU_CHANNEL_1);
227 return false;
228 case Gpio::H9:
229 RETURN_ICU12(ICU_CHANNEL_2);
230 return false;
231 case Gpio::H10:
232 RETURN_ICU5(ICU_CHANNEL_1);
233 return false;
234 case Gpio::H11:
235 RETURN_ICU5(ICU_CHANNEL_2);
236 return false;
237 case Gpio::I5:
238 RETURN_ICU8(ICU_CHANNEL_1);
239 return false;
240 case Gpio::I6:
241 RETURN_ICU8(ICU_CHANNEL_2);
242 return false;
243
244 default:
245 return false;
246 }
247
248 return false;
249}

Referenced by startSent(), and stopSent().

Here is the caller graph for this function:

◆ getMCUResetCause() [1/2]

Reset_Cause_t getMCUResetCause ( )

Definition at line 189 of file at32_common.cpp.

189 {
190 return Reset_Cause_Unknown;
191}

Referenced by checkIfResetLoop(), errorHandlerInit(), and errorHandlerWriteReportFile().

Here is the caller graph for this function:

◆ getMCUResetCause() [2/2]

const char * getMCUResetCause ( Reset_Cause_t  cause)

Definition at line 193 of file at32_common.cpp.

193 {
194 return "Unknown";
195}

◆ getMcuTemperature()

float getMcuTemperature ( )

Definition at line 264 of file mpu_util.cpp.

264 {
265 // TODO: implement me!
266 return 0;
267}

Referenced by adcOnchipSlowUpdate().

Here is the caller graph for this function:

◆ getMcuVrefVoltage()

float getMcuVrefVoltage ( )

Definition at line 269 of file mpu_util.cpp.

269 {
270 // TODO: implement me!
272}
static constexpr engine_configuration_s * engineConfiguration

Referenced by adcOnchipSlowUpdate().

Here is the caller graph for this function:

◆ HardFaultVector()

void HardFaultVector ( void  )

Definition at line 62 of file mpu_util.cpp.

62 {
63 while (TRUE) {
64 }
65}

◆ initSpiCs()

void initSpiCs ( SPIConfig *  spiConfig,
brain_pin_e  csPin 
)

Definition at line 241 of file at32_spi.cpp.

241 {
242 /* TODO: why this is here? */
243#if !defined(HAL_LLD_SELECT_SPI_V2)
244 spiConfig->end_cb = nullptr;
245#else
246 spiConfig->data_cb = nullptr;
247 spiConfig->error_cb = nullptr;
248#endif
249
250 initSpiCsNoOccupy(spiConfig, csPin);
251 efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
252}
void initSpiCsNoOccupy(SPIConfig *spiConfig, brain_pin_e csPin)
Definition at32_spi.cpp:234
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)

Referenced by initPotentiometer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initSpiCsNoOccupy()

void initSpiCsNoOccupy ( SPIConfig *  spiConfig,
brain_pin_e  csPin 
)

Definition at line 234 of file at32_spi.cpp.

234 {
235 ioportid_t port = getHwPort("spi", csPin);
236 ioportmask_t pin = getHwPin("spi", csPin);
237 spiConfig->ssport = port;
238 spiConfig->sspad = pin;
239}
uint32_t ioportmask_t
Digital I/O port sized unsigned type.
Definition hal_pal_lld.h:78
GPIO_TypeDef * ioportid_t
Port Identifier.

Referenced by initSpiCs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initSpiModule()

void initSpiModule ( SPIDriver *  driver,
brain_pin_e  sck,
brain_pin_e  miso,
brain_pin_e  mosi,
int  sckMode,
int  mosiMode,
int  misoMode 
)

See https://github.com/rusefi/rusefi/pull/664/

Info on the silicon defect can be found in this document, section 2.5.2: https://www.st.com/content/ccc/resource/technical/document/errata_sheet/0a/98/58/84/86/b6/47/a2/DM00037591.pdf/files/DM00037591.pdf/jcr:content/translations/en.DM00037591.pdf

See https://github.com/rusefi/rusefi/pull/664/

Info on the silicon defect can be found in this document, section 2.5.2: https://www.st.com/content/ccc/resource/technical/document/errata_sheet/0a/98/58/84/86/b6/47/a2/DM00037591.pdf/files/DM00037591.pdf/jcr:content/translations/en.DM00037591.pdf

See https://github.com/rusefi/rusefi/pull/664/

Info on the silicon defect can be found in this document, section 2.5.2: https://www.st.com/content/ccc/resource/technical/document/errata_sheet/0a/98/58/84/86/b6/47/a2/DM00037591.pdf/files/DM00037591.pdf/jcr:content/translations/en.DM00037591.pdf

Definition at line 206 of file at32_spi.cpp.

210 {
211
212 int sckAf = getSpiSckAf(driver, sck);
213 int mosiAf = getSpiMosiAf(driver, mosi);
214 int misoAf = getSpiMisoAf(driver, miso);
215
216 if ((sckAf < 0) || (mosiAf < 0) || (misoAf < 0)) {
217 criticalError("Incorrect SPI pin configuration");
218 }
219
220 efiSetPadMode("SPI CLK ", sck,
221 PAL_MODE_ALTERNATE(sckAf) | sckMode | PAL_STM32_OSPEED_HIGHEST);
222
223 efiSetPadMode("SPI MOSI", mosi,
224 PAL_MODE_ALTERNATE(mosiAf) | mosiMode | PAL_STM32_OSPEED_HIGHEST);
225
226 // Activate the internal pullup on MISO: SD cards indicate "busy" by holding MOSI low,
227 // so in case there is no SD card installed, the line could float low and indicate that
228 // the (non existent) card is busy. We pull the line high to indicate "not busy" in case
229 // of a missing card.
230 efiSetPadMode("SPI MISO ", miso,
231 PAL_MODE_ALTERNATE(misoAf) | misoMode | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP);
232}
static int getSpiSckAf(SPIDriver *driver, brain_pin_e pin)
Definition at32_spi.cpp:121
static int getSpiMosiAf(SPIDriver *driver, brain_pin_e pin)
Definition at32_spi.cpp:141
static int getSpiMisoAf(SPIDriver *driver, brain_pin_e pin)
Definition at32_spi.cpp:131

Referenced by turnOnSpi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isStm32F42x()

bool isStm32F42x ( )

Definition at line 156 of file at32_common.cpp.

156 {
157 return false;
158}

Referenced by luaHeapInit(), and sayHello().

Here is the caller graph for this function:

◆ isValidCanRxPin()

bool isValidCanRxPin ( brain_pin_e  pin)

Definition at line 89 of file at32_can.cpp.

89 {
91}

Referenced by startCanPins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidCanTxPin()

bool isValidCanTxPin ( brain_pin_e  pin)

Definition at line 85 of file at32_can.cpp.

85 {
87}

Referenced by startCanPins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidSerialRxPin()

bool isValidSerialRxPin ( brain_pin_e  pin)

Definition at line 25 of file stm32_serial.cpp.

25 {
26 return isValidUART6RxPin(pin);
27}
static bool isValidUART6RxPin(brain_pin_e pin)
Here is the call graph for this function:

◆ isValidSerialTxPin()

bool isValidSerialTxPin ( brain_pin_e  pin)

Definition at line 21 of file stm32_serial.cpp.

21 {
22 return isValidUART6TxPin(pin);
23}
static bool isValidUART6TxPin(brain_pin_e pin)
Here is the call graph for this function:

◆ jump_to_bootloader()

void jump_to_bootloader ( )

Definition at line 106 of file at32_common.cpp.

106 {
107 // leave DFU breadcrumb which assembly startup code would check, see [rusefi][DFU] section in assembly code
108
109 *((unsigned long *)0x2001FFF0) = 0xDEADBEEF; // End of RAM
110
112}
static void reset_and_jump(void)

Referenced by executeTSCommand(), and runRusEfi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jump_to_openblt()

void jump_to_openblt ( )

Definition at line 115 of file at32_common.cpp.

115 {
116#if EFI_USE_OPENBLT
117 /* safe to call on already inited shares area */
119 /* Store sing to stay in OpenBLT */
121
123#endif
124}
bool SharedParamsWriteByIndex(uint32_t idx, uint8_t value)
Writes a data byte to the shared parameter buffer at the specified index.
void SharedParamsInit(void)
Initializes the shared RAM parameters module.

Referenced by executeTSCommand(), processCanRxMessage(), and runRusEfi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mcuCanFlashWhileRunning()

bool mcuCanFlashWhileRunning ( )

Definition at line 10 of file mpu_util.cpp.

10 {
11 /* TODO: check for actual flash configuration? */
12 /* currently we support only AT32F43X with dual-bank flash, so allow flashing to second bank */
13 /* TODO: Seems AT32 is still freezes even write is happen to second bank, while executing code from first */
14 return true;
15}

Referenced by storageAllowWriteID().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ portInitAdc()

void portInitAdc ( )

Definition at line 256 of file mpu_util.cpp.

256 {
257 // Init slow ADC
258 adcStart(&ADCD1, NULL);
259
260 // Init fast ADC (MAP sensor)
261 adcStart(&ADCD2, NULL);
262}
ADCDriver ADCD2
ADC2 driver identifier.
Definition hal_adc_lld.c:49
ADCDriver ADCD1
ADC1 driver identifier.
Definition hal_adc_lld.c:44

Referenced by initAdcInputs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readSlowAnalogInputs()

bool readSlowAnalogInputs ( adcsample_t convertedSamples)

Definition at line 274 of file mpu_util.cpp.

274 {
275 // TODO: implement me!
276 return true;
277}

Referenced by adcOnchipSlowUpdate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spiCalcClockDiv()

int spiCalcClockDiv ( SPIDriver *  spip,
SPIConfig *  spiConfig,
unsigned int  clk 
)

Definition at line 260 of file at32_spi.cpp.

261{
262 // TODO: implement
263 return -1;
264}

Referenced by initializeMmcBlockDevice().

Here is the caller graph for this function:

◆ spiGetBaseClock()

int spiGetBaseClock ( SPIDriver *  spip)

Definition at line 254 of file at32_spi.cpp.

255{
256 // TODO: implement
257 return 0;
258}

Referenced by sdStatistics().

Here is the caller graph for this function:

◆ turnOnSpi()

void turnOnSpi ( spi_device_e  device)

Definition at line 151 of file at32_spi.cpp.

151 {
153 return; // already initialized
154 isSpiInitialized[device] = true;
155 if (device == SPI_DEVICE_1) {
156// todo: introduce a nice structure with all fields for same SPI
157#if STM32_SPI_USE_SPI1
158// scheduleMsg(&logging, "Turning on SPI1 pins");
165#else
166 criticalError("SPI1 not available in this binary");
167#endif /* STM32_SPI_USE_SPI1 */
168 }
169 if (device == SPI_DEVICE_2) {
170#if STM32_SPI_USE_SPI2
171 //scheduleMsg(&logging, "Turning on SPI2 pins");
178#else
179 criticalError("SPI2 not available in this binary");
180#endif /* STM32_SPI_USE_SPI2 */
181 }
182 if (device == SPI_DEVICE_3) {
183#if STM32_SPI_USE_SPI3
184 //scheduleMsg(&logging, "Turning on SPI3 pins");
191#else
192 criticalError("SPI3 not available in this binary");
193#endif /* STM32_SPI_USE_SPI3 */
194 }
195 if (device == SPI_DEVICE_4) {
196#if STM32_SPI_USE_SPI4
197 //scheduleMsg(&logging, "Turning on SPI4 pins");
198 /* there are no configuration fields for SPI4 in engineConfiguration, rely on board init code
199 * it should set proper functions for SPI4 pins */
200#else
201 criticalError("SPI4 not available in this binary");
202#endif /* STM32_SPI_USE_SPI4 */
203 }
204}
void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, brain_pin_e mosi, int sckMode, int mosiMode, int misoMode)
Definition at32_spi.cpp:206
bool isSpiInitialized[SPI_TOTAL_COUNT+1]
Definition at32_spi.cpp:13
SPIDriver SPID1
SPI0 driver identifier.
Definition hal_spi_lld.c:42
SPIDriver SPID2
SPI1 driver identifier.
Definition hal_spi_lld.c:47
brain_pin_e getSckPin(spi_device_e device)
Definition hardware.cpp:126
brain_pin_e getMosiPin(spi_device_e device)
Definition hardware.cpp:106
brain_pin_e getMisoPin(spi_device_e device)
Definition hardware.cpp:86
static Lps25 device
Definition init_baro.cpp:4
Here is the call graph for this function:

◆ UsageFaultVector()

void UsageFaultVector ( void  )

Definition at line 50 of file mpu_util.cpp.

50 {
51 chDbgPanic3("UsageFaultVector", __FILE__, __LINE__);
52 while (TRUE)
53 ;
54}
Here is the call graph for this function:

Variable Documentation

◆ mmc_hs_spicfg

SPIConfig mmc_hs_spicfg
extern

Definition at line 273 of file at32_spi.cpp.

273 {
274 .circular = false,
275#if !defined(HAL_LLD_SELECT_SPI_V2)
276 .end_cb = NULL,
277#else
278 .slave = false,
279 .data_cb = NULL,
280 .error_cb = NULL,
281#endif
282 .ssport = NULL,
283 .sspad = 0,
284 .cr1 = SPI_BaudRatePrescaler_2,
285 .cr2 = 0
286};

Referenced by initializeMmcBlockDevice(), and sdStatistics().

◆ mmc_ls_spicfg

SPIConfig mmc_ls_spicfg
extern

Definition at line 288 of file at32_spi.cpp.

288 {
289 .circular = false,
290#if !defined(HAL_LLD_SELECT_SPI_V2)
291 .end_cb = NULL,
292#else
293 .slave = false,
294 .data_cb = NULL,
295 .error_cb = NULL,
296#endif
297 .ssport = NULL,
298 .sspad = 0,
299 .cr1 = SPI_BaudRatePrescaler_8,
300 .cr2 = 0
301};

Referenced by initializeMmcBlockDevice(), and sdStatistics().

Go to the source code of this file.