mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/bus: add system buses
This commit is contained in:
parent
d9598a0f54
commit
7e069290a0
@ -127,6 +127,7 @@ PSEUDOMODULES += stm32_eth_auto
|
||||
PSEUDOMODULES += stm32_eth_link_up
|
||||
PSEUDOMODULES += suit_transport_%
|
||||
PSEUDOMODULES += suit_storage_%
|
||||
PSEUDOMODULES += sys_bus_%
|
||||
PSEUDOMODULES += wakaama_objects_%
|
||||
PSEUDOMODULES += wifi_enterprise
|
||||
PSEUDOMODULES += xtimer_on_ztimer
|
||||
|
@ -158,6 +158,9 @@ endif
|
||||
ifneq (,$(filter suit%,$(USEMODULE)))
|
||||
DIRS += suit
|
||||
endif
|
||||
ifneq (,$(filter sys_bus,$(USEMODULE)))
|
||||
DIRS += bus
|
||||
endif
|
||||
ifneq (,$(filter tcp,$(USEMODULE)))
|
||||
DIRS += net/transport_layer/tcp
|
||||
endif
|
||||
|
@ -44,6 +44,11 @@ ifneq (,$(filter crypto_%,$(USEMODULE)))
|
||||
USEMODULE += crypto
|
||||
endif
|
||||
|
||||
ifneq (,$(filter sys_bus_%,$(USEMODULE)))
|
||||
USEMODULE += sys_bus
|
||||
USEMODULE += core_msg_bus
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rtt_cmd,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_rtt
|
||||
endif
|
||||
|
@ -58,6 +58,11 @@ void auto_init(void)
|
||||
extern void auto_init_event_thread(void);
|
||||
auto_init_event_thread();
|
||||
}
|
||||
if (IS_USED(MODULE_SYS_BUS)) {
|
||||
LOG_DEBUG("Auto init system buses.\n");
|
||||
extern void auto_init_sys_bus(void);
|
||||
auto_init_sys_bus();
|
||||
}
|
||||
if (IS_USED(MODULE_MCI)) {
|
||||
LOG_DEBUG("Auto init mci.\n");
|
||||
extern void mci_initialize(void);
|
||||
|
3
sys/bus/Makefile
Normal file
3
sys/bus/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = sys_bus
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
29
sys/bus/sys_bus_init.c
Normal file
29
sys/bus/sys_bus_init.c
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 sys_bus
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief System Buses
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "sys/bus.h"
|
||||
|
||||
msg_bus_t _sys_bus[SYS_BUS_NUMOF];
|
||||
|
||||
void auto_init_sys_bus(void)
|
||||
{
|
||||
for (unsigned i = 0; i < SYS_BUS_NUMOF; ++i) {
|
||||
msg_bus_init(&_sys_bus[i]);
|
||||
}
|
||||
}
|
77
sys/include/sys/bus.h
Normal file
77
sys/include/sys/bus.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 sys
|
||||
* @defgroup sys_bus System Buses for common events
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief This provides System Buses for common events.
|
||||
*
|
||||
* @warning Bus Events will be lost if receiver message queue is full.
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
*/
|
||||
|
||||
#ifndef SYS_BUS_H
|
||||
#define SYS_BUS_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "msg_bus.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief System Bus types
|
||||
*/
|
||||
typedef enum {
|
||||
#if MODULE_SYS_BUS_POWER
|
||||
SYS_BUS_POWER, /**< Events related to system power */
|
||||
#endif
|
||||
SYS_BUS_NUMOF /**< Number of enabled system buses */
|
||||
} sys_bus_t;
|
||||
|
||||
/**
|
||||
* @brief Power Bus Events
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* @brief Supply voltage fallen below threshold
|
||||
*/
|
||||
SYS_BUS_POWER_EVENT_LOW_VOLTAGE,
|
||||
|
||||
/* add more if needed, but not more than 32 */
|
||||
} sys_bus_power_event_t;
|
||||
|
||||
/**
|
||||
* @brief The System Bus array - do not use directly
|
||||
*/
|
||||
extern msg_bus_t _sys_bus[SYS_BUS_NUMOF];
|
||||
|
||||
/**
|
||||
* @brief Get a System Bus for a category of events.
|
||||
*
|
||||
* @param[in] bus The event category of the the user
|
||||
* is interested in
|
||||
*
|
||||
* @return The message bus for those events
|
||||
*/
|
||||
static inline msg_bus_t *sys_bus_get(sys_bus_t bus)
|
||||
{
|
||||
return &_sys_bus[bus];
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYS_BUS_H */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user