mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-19 12:47:52 -06:00
initial_pins: Add ability to configure output pins at mcu startup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
0af89e4766
commit
4a35f927fc
5 changed files with 103 additions and 4 deletions
|
@ -88,6 +88,15 @@ config STEP_DELAY
|
|||
The default for AVR is -1, for all other micro-controllers it
|
||||
is 2us.
|
||||
|
||||
config INITIAL_PINS
|
||||
string "GPIO pins to set at micro-controller startup"
|
||||
depends on LOW_LEVEL_OPTIONS
|
||||
help
|
||||
One may specify a comma separated list of gpio pins to set
|
||||
during the micro-controller startup sequence. By default the
|
||||
pins will be set to output high - preface a pin with a '!'
|
||||
character to set that pin to output low.
|
||||
|
||||
# The HAVE_GPIO_x options allow boards to disable support for some
|
||||
# commands if the hardware does not support the feature.
|
||||
config HAVE_GPIO
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Main code build rules
|
||||
|
||||
src-y += sched.c command.c basecmd.c debugcmds.c
|
||||
src-y += sched.c command.c basecmd.c debugcmds.c initial_pins.c
|
||||
src-$(CONFIG_HAVE_GPIO) += gpiocmds.c stepper.c endstop.c
|
||||
src-$(CONFIG_HAVE_GPIO_ADC) += adccmds.c
|
||||
src-$(CONFIG_HAVE_GPIO_SPI) += spicmds.c thermocouple.c
|
||||
|
|
25
src/initial_pins.c
Normal file
25
src/initial_pins.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Support setting gpio pins at mcu start
|
||||
//
|
||||
// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include "autoconf.h" // CONFIG_INITIAL_PINS
|
||||
#include "board/gpio.h" // gpio_out_setup
|
||||
#include "board/pgm.h" // READP
|
||||
#include "ctr.h" // DECL_CTR
|
||||
#include "initial_pins.h" // initial_pins
|
||||
#include "sched.h" // DECL_INIT
|
||||
|
||||
DECL_CTR("DECL_INITIAL_PINS " __stringify(CONFIG_INITIAL_PINS));
|
||||
|
||||
void
|
||||
initial_pins_setup(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<initial_pins_size; i++) {
|
||||
const struct initial_pin_s *ip = &initial_pins[i];
|
||||
gpio_out_setup(READP(ip->pin), READP(ip->flags) & IP_OUT_HIGH);
|
||||
}
|
||||
}
|
||||
DECL_INIT(initial_pins_setup);
|
15
src/initial_pins.h
Normal file
15
src/initial_pins.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef __INITIAl_PINS_H
|
||||
#define __INITIAl_PINS_H
|
||||
|
||||
struct initial_pin_s {
|
||||
int pin;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
enum { IP_OUT_HIGH = 1 };
|
||||
|
||||
// out/compile_time_request.c (auto generated file)
|
||||
extern const struct initial_pin_s initial_pins[];
|
||||
extern const int initial_pins_size;
|
||||
|
||||
#endif // initial_pins.h
|
Loading…
Add table
Add a link
Reference in a new issue