mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/board_common: add generic board_init() function
This commit is contained in:
parent
38943b7051
commit
4d7a3c1dba
@ -584,6 +584,9 @@ USEMODULE_INCLUDES =
|
|||||||
|
|
||||||
include $(RIOTBASE)/sys/Makefile.include
|
include $(RIOTBASE)/sys/Makefile.include
|
||||||
|
|
||||||
|
# add default board_init()
|
||||||
|
DIRS += $(RIOTBASE)/boards/common/init
|
||||||
|
|
||||||
# include Makefile.includes of each driver modules if they exist
|
# include Makefile.includes of each driver modules if they exist
|
||||||
-include $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)
|
-include $(USEMODULE:%=$(RIOTBASE)/drivers/%/Makefile.include)
|
||||||
|
|
||||||
|
@ -15,3 +15,10 @@ config MODULE_BOARD
|
|||||||
depends on TEST_KCONFIG
|
depends on TEST_KCONFIG
|
||||||
help
|
help
|
||||||
Module which holds all board-specific files.
|
Module which holds all board-specific files.
|
||||||
|
|
||||||
|
config MODULE_BOARD_COMMON_INIT
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
depends on TEST_KCONFIG
|
||||||
|
help
|
||||||
|
Common board initialization module
|
||||||
|
2
boards/common/init/Makefile
Normal file
2
boards/common/init/Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
MODULE = board_common_init
|
||||||
|
include $(RIOTBASE)/Makefile.base
|
60
boards/common/init/board_common.c
Normal file
60
boards/common/init/board_common.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 ML!PA Consulting GmbH
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup boards
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Generic board functions
|
||||||
|
*
|
||||||
|
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "periph/gpio.h"
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
|
#define LED_INIT(x) do { \
|
||||||
|
gpio_init(LED##x##_PIN, GPIO_OUT); \
|
||||||
|
LED##x##_OFF; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
__attribute__((__weak__))
|
||||||
|
void board_init(void)
|
||||||
|
{
|
||||||
|
if (!IS_USED(MODULE_PERIPH_GPIO)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef LED0_PIN
|
||||||
|
LED_INIT(0);
|
||||||
|
#endif
|
||||||
|
#ifdef LED1_PIN
|
||||||
|
LED_INIT(1);
|
||||||
|
#endif
|
||||||
|
#ifdef LED2_PIN
|
||||||
|
LED_INIT(2);
|
||||||
|
#endif
|
||||||
|
#ifdef LED3_PIN
|
||||||
|
LED_INIT(3);
|
||||||
|
#endif
|
||||||
|
#ifdef LED4_PIN
|
||||||
|
LED_INIT(4);
|
||||||
|
#endif
|
||||||
|
#ifdef LED5_PIN
|
||||||
|
LED_INIT(5);
|
||||||
|
#endif
|
||||||
|
#ifdef LED6_PIN
|
||||||
|
LED_INIT(6);
|
||||||
|
#endif
|
||||||
|
#ifdef LED7_PIN
|
||||||
|
LED_INIT(7);
|
||||||
|
#endif
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
DEFAULT_MODULE += board cpu core core_init core_msg core_panic sys
|
DEFAULT_MODULE += board board_common_init cpu core core_init core_msg core_panic sys
|
||||||
|
|
||||||
# Include potentially added default modules by the board
|
# Include potentially added default modules by the board
|
||||||
-include $(BOARDDIR)/Makefile.default
|
-include $(BOARDDIR)/Makefile.default
|
||||||
|
Loading…
Reference in New Issue
Block a user