MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / pinMode

Method pinMode

libraries/AP_HAL_ChibiOS/GPIO.cpp:212–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211
212void GPIO::pinMode(uint8_t pin, uint8_t output)
213{
214 struct gpio_entry *g = gpio_by_pin_num(pin);
215 if (g) {
216 if (!output && g->is_input &&
217 (g->mode == PAL_MODE_INPUT_PULLUP ||
218 g->mode == PAL_MODE_INPUT_PULLDOWN)) {
219 // already set
220 return;
221 }
222 g->mode = output?PAL_MODE_OUTPUT_PUSHPULL:PAL_MODE_INPUT;
223#if defined(STM32F7) || defined(STM32H7) || defined(STM32F4) || defined(STM32G4) || defined(STM32L4) || defined(STM32L4PLUS)
224 if (g->mode == PAL_MODE_OUTPUT_PUSHPULL) {
225 // retain OPENDRAIN if already set
226 iomode_t old_mode = palReadLineMode(g->pal_line);
227 if ((old_mode & PAL_MODE_OUTPUT_OPENDRAIN) == PAL_MODE_OUTPUT_OPENDRAIN) {
228 g->mode = PAL_MODE_OUTPUT_OPENDRAIN;
229 }
230 }
231#endif
232 palSetLineMode(g->pal_line, g->mode);
233 g->is_input = !output;
234 }
235}
236
237
238uint8_t GPIO::read(uint8_t pin)

Callers 2

initMethod · 0.45
serial_setup_outputMethod · 0.45

Calls 2

palReadLineModeFunction · 0.85
gpio_by_pin_numFunction · 0.70

Tested by

no test coverage detected