1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

tests/external_module_dirs: add auto-init function

This commit is contained in:
Fabian Hüßler 2021-11-08 12:43:20 +01:00
parent 8d7a7593e8
commit cd93e42deb
4 changed files with 30 additions and 3 deletions

View File

@ -8,5 +8,4 @@ It demonstrates:
* Adding a module with source code
* Setting a header include directory
* Adding dependencies, which are evaluated before other modules dependencies
If the application compiles, everything is ok.
* Registering a module for auto-initialization

View File

@ -20,5 +20,16 @@
*/
#include "external_module.h"
#include "auto_init_utils.h"
#define PRIO 1111
AUTO_INIT(auto_init_external_module, PRIO);
bool external_module_initialized = false;
char *external_module_message = "Linking worked";
void auto_init_external_module(void)
{
external_module_initialized = true;
}

View File

@ -20,15 +20,28 @@
#ifndef EXTERNAL_MODULE_H
#define EXTERNAL_MODULE_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief true: this module hase been initialized
* false: this module has not been initialized
*/
extern bool external_module_initialized;
/**
* @brief A simple string message
*/
extern char *external_module_message;
/**
* @brief Auto-init function of this module to be called on system start up
*/
void auto_init_external_module(void);
#ifdef __cplusplus
}
#endif

View File

@ -32,7 +32,11 @@
int main(void)
{
puts("If it compiles, it works!");
printf("Message: %s\n", external_module_message);
if (!external_module_initialized) {
puts("External module has not been initialized.");
return 1;
}
puts("Initialization worked!");
return 0;
}