stm32f103rb_hal_blink

Non-blocking, event triggered blink example using HAL library
Index Commits Files Refs README
app/inc/logger.h (1086B)
   1 /*
   2  * Copyright (c) 2023 Sebastian Bedin <sebabedin@gmail.com>.
   3  *
   4  * See file `LICENSE` for full details
   5  */
   6 
   7 #ifndef INC_LOGGER_H_
   8 #define INC_LOGGER_H_
   9 
  10 #ifdef __cplusplus
  11 extern "C" {
  12 #endif
  13 
  14 #include <stdio.h>
  15 #include <stdint.h>
  16 #include <stdbool.h>
  17 #include <string.h>
  18 
  19 #define LOGGER_CONFIG_ENABLE                    (1)
  20 #define LOGGER_CONFIG_MAXLEN                    (64)
  21 #define LOGGER_CONFIG_USE_SEMIHOSTING           (1)
  22 
  23 #if 1 == LOGGER_CONFIG_ENABLE
  24 #define LOGGER_LOG(...)\
  25     __asm("CPSID i");    /* disable interrupts*/\
  26     {\
  27         logger_msg_len = snprintf(logger_msg, (LOGGER_CONFIG_MAXLEN - 1), __VA_ARGS__);\
  28         logger_log_print_(logger_msg);\
  29     }\
  30     __asm("CPSIE i");    /* enable interrupts*/
  31 #else
  32 #define LOGGER_LOG(...)
  33 #endif
  34 
  35 #define LOGGER_INFO(...)\
  36     LOGGER_LOG("[INFO] ");\
  37     LOGGER_LOG(__VA_ARGS__);\
  38     LOGGER_LOG("\n");
  39 
  40 #define GET_NAME(var)  #var
  41 
  42 extern char* const logger_msg;
  43 extern int logger_msg_len; // only for debug information
  44 
  45 void logger_log_print_(char* const msg);
  46 
  47 #ifdef __cplusplus
  48 }
  49 #endif
  50 
  51 #endif /* INC_LOGGER_H_ */