rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
cypress_common.cpp File Reference

Detailed Description

Low level common Cypress code.

Date
Jan 28, 2020
Author
andreika prome.nosp@m.theu.nosp@m.s.pcb.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition in file cypress_common.cpp.

Functions

brain_pin_e getAdcChannelBrainPin (const char *msg, adc_channel_e hwChannel)
 
adc_channel_e getAdcChannel (brain_pin_e pin)
 
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)
 
int getRemainingStack (thread_t *otp)
 

Function Documentation

◆ adcIsMuxedInput()

bool adcIsMuxedInput ( adc_channel_e  hwChannel)

Definition at line 150 of file cypress_common.cpp.

150 {
151 return false;
152}

◆ adcMuxedGetParent()

adc_channel_e adcMuxedGetParent ( adc_channel_e  hwChannel)

Definition at line 154 of file cypress_common.cpp.

155{
156 return hwChannel;
157}

◆ 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}

◆ getRemainingStack()

int getRemainingStack ( thread_t *  otp)

Of note is that interrupts are NOT serviced on the stack of the thread that was running when the interrupt occurred. The only thing that happens on that thread's stack is that its registers are pushed (by hardware) when an interrupt occurs, just before swapping the stack pointer out for the main stack (currently 0x400=1024 bytes), where the ISR actually runs. see also main_stack_size see also process_stack_size

see also http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:stacks

In the firmware we are using 'extern *Engine' - in the firmware Engine is a singleton

On the other hand, in order to have a meaningful unit test we are passing Engine * engine as a parameter

Definition at line 184 of file cypress_common.cpp.

184 {
185 // todo: would stm32 code actually work here since similar Cortex?
186 return 888888;
187}

Go to the source code of this file.