diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..46c3766 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Tilen Majerle +Tilen Majerle +Brian +Peter Maxwell Warasila \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d5f4639..ce9f236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Develop +## v1.0.5 + +- Fix building the library with `LWPRINTF_CFG_OS=1` and `LWPRINTF_CFG_OS_MANUAL_PROTECT=0` options + ## v1.0.4 - Fix calculation for NULL terminated string and precision with 0 as an input diff --git a/CMakeLists.txt b/CMakeLists.txt index e977349..46e7c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ else() ) # Add subdir with lwprintf and link to the project + set(LWPRINTF_OPTS_DIR ${CMAKE_CURRENT_LIST_DIR}/dev) add_subdirectory(lwprintf) target_link_libraries(${PROJECT_NAME} lwprintf) endif() diff --git a/dev/lwprintf_opts.h b/dev/lwprintf_opts.h index 7b370e9..7a563f3 100644 --- a/dev/lwprintf_opts.h +++ b/dev/lwprintf_opts.h @@ -29,7 +29,7 @@ * This file is part of Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #ifndef LWPRINTF_HDR_OPTS_H #define LWPRINTF_HDR_OPTS_H @@ -42,10 +42,10 @@ * Open "include/lwprintf/lwprintf_opt.h" and * copy & replace here settings you want to change values */ -#define LWPRINTF_CFG_OS 1 -#define LWPRINTF_CFG_OS_MUTEX_HANDLE HANDLE +#define LWPRINTF_CFG_OS 1 +#define LWPRINTF_CFG_OS_MUTEX_HANDLE HANDLE -#define LWPRINTF_CFG_SUPPORT_LONG_LONG 1 -#define LWPRINTF_CFG_OS_MANUAL_PROTECT 1 +#define LWPRINTF_CFG_SUPPORT_LONG_LONG 1 +#define LWPRINTF_CFG_OS_MANUAL_PROTECT 1 #endif /* OW_HDR_OPTS_H */ diff --git a/docs/authors/index.rst b/docs/authors/index.rst new file mode 100644 index 0000000..4031a8c --- /dev/null +++ b/docs/authors/index.rst @@ -0,0 +1,8 @@ +.. _authors: + +Authors +======= + +List of authors and contributors to the library + +.. literalinclude:: ../../AUTHORS \ No newline at end of file diff --git a/docs/get-started/index.rst b/docs/get-started/index.rst index 5e8cead..b6c07d0 100644 --- a/docs/get-started/index.rst +++ b/docs/get-started/index.rst @@ -58,7 +58,17 @@ Add library to project ^^^^^^^^^^^^^^^^^^^^^^ At this point it is assumed that you have successfully download library, either cloned it or from releases page. -Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path +Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path. + +*CMake* is the main supported build system. Package comes with the ``CMakeLists.txt`` and ``library.cmake`` files, both located in the ``lwprintf`` directory: + +* ``CMakeLists.txt``: Is a wrapper and only includes ``library.cmake`` file. It is used if target application uses ``add_subdirectory`` and then uses ``target_link_libraries`` to include the library in the project +* ``library.cmake``: It is a fully configured set of variables. User must use ``include(path/to/library.cmake)`` to include the library and must manually add files/includes to the final target + +.. tip:: + Open ``library.cmake`` file and manually analyze all the possible variables you can set for full functionality. + +If you do not use the *CMake*, you can do the following: * Copy ``lwprintf`` folder to your project, it contains library files * Add ``lwprintf/src/include`` folder to `include path` of your toolchain. This is where `C/C++` compiler can find the files during compilation process. Usually using ``-I`` flag @@ -78,7 +88,11 @@ and it should be copied (or simply renamed in-place) and named ``lwprintf_opts.h File must be renamed to ``lwprintf_opts.h`` first and then copied to the project directory where compiler include paths have access to it by using ``#include "lwprintf_opts.h"``. -List of configuration options are available in the :ref:`api_lwprintf_opt` section. +.. tip:: + If you are using *CMake* build system, define the variable ``LWPRINTF_OPTS_DIR`` before adding library's directory to the *CMake* project. + Variable must set the output directory path. CMake will copy the template file there, and name it as required. + +Configuration options list is available available in the :ref:`api_lwprintf_opt` section. If any option is about to be modified, it should be done in configuration file .. literalinclude:: ../../lwprintf/src/include/lwprintf/lwprintf_opts_template.h diff --git a/docs/index.rst b/docs/index.rst index 54ce149..d56cbbe 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -67,6 +67,7 @@ Table of contents test-results/index examples/index changelog/index + authors/index .. toctree:: :maxdepth: 2 diff --git a/examples/stm32/lwprintf_stm32l432kc_nucleo/Core/Inc/lwprintf_opts.h b/examples/stm32/lwprintf_stm32l432kc_nucleo/Core/Inc/lwprintf_opts.h index a6d5d2d..3427d08 100644 --- a/examples/stm32/lwprintf_stm32l432kc_nucleo/Core/Inc/lwprintf_opts.h +++ b/examples/stm32/lwprintf_stm32l432kc_nucleo/Core/Inc/lwprintf_opts.h @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #ifndef LWPRINTF_HDR_OPTS_H #define LWPRINTF_HDR_OPTS_H diff --git a/library.json b/library.json index e3f9727..3546559 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "LwPRINTF", - "version": "1.0.4", + "version": "1.0.5", "description": "Lightweight printf and sprintf library for embedded systems", "keywords": "printf, lightweight, lwprintf, sprintf, snprintf, embedded, stdio, manager, library", "repository": { diff --git a/lwprintf/CMakeLists.txt b/lwprintf/CMakeLists.txt index fa33ed4..f05f91d 100644 --- a/lwprintf/CMakeLists.txt +++ b/lwprintf/CMakeLists.txt @@ -1,11 +1,3 @@ cmake_minimum_required(VERSION 3.22) -# Register core library -add_library(lwprintf INTERFACE) -target_sources(lwprintf PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src/lwprintf/lwprintf.c) -target_include_directories(lwprintf INTERFACE ${CMAKE_CURRENT_LIST_DIR}/src/include) - -if (DEFINED LWPRINTF_SYS_PORT) -target_sources(lwprintf PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/src/system/lwprintf_sys_${LWPRINTF_SYS_PORT}.c) -endif() +include(${CMAKE_CURRENT_LIST_DIR}/library.cmake) \ No newline at end of file diff --git a/lwprintf/library.cmake b/lwprintf/library.cmake new file mode 100644 index 0000000..5be9023 --- /dev/null +++ b/lwprintf/library.cmake @@ -0,0 +1,41 @@ +# +# This file provides set of variables for end user +# and also generates one (or more) libraries, that can be added to the project using target_link_libraries(...) +# +# Before this file is included to the root CMakeLists file (using include() function), user can set some variables: +# +# LWPRINTF_SYS_PORT: If defined, it will include port source file from the library. +# LWPRINTF_OPTS_DIR: If defined, it should set the folder path where options file shall be generated. +# LWPRINTF_COMPILE_OPTIONS: If defined, it provide compiler options for generated library. +# LWPRINTF_COMPILE_DEFINITIONS: If defined, it provides "-D" definitions to the library build +# + +# Library core sources +set(lwprintf_core_SRCS + ${CMAKE_CURRENT_LIST_DIR}/src/lwprintf/lwprintf.c +) + +# Add system port +if(DEFINED LWPRINTF_SYS_PORT) + set(lwprintf_core_SRCS + ${lwprintf_core_SRCS} + ${CMAKE_CURRENT_LIST_DIR}/src/system/lwprintf_sys_${LWPRINTF_SYS_PORT}.c + ) +endif() + +# Setup include directories +set(lwprintf_include_DIRS + ${CMAKE_CURRENT_LIST_DIR}/src/include +) + +# Register library to the system +add_library(lwprintf INTERFACE) +target_sources(lwprintf INTERFACE ${lwprintf_core_SRCS}) +target_include_directories(lwprintf INTERFACE ${lwprintf_include_DIRS}) +target_compile_options(lwprintf PRIVATE ${LWPRINTF_COMPILE_OPTIONS}) +target_compile_definitions(lwprintf PRIVATE ${LWPRINTF_COMPILE_DEFINITIONS}) + +# Create config file +if(DEFINED LWPRINTF_OPTS_DIR AND NOT EXISTS ${LWPRINTF_OPTS_DIR}/lwprintf_opts.h) + configure_file(${CMAKE_CURRENT_LIST_DIR}/src/include/lwprintf/lwprintf_opts_template.h ${LWPRINTF_OPTS_DIR}/lwprintf_opts.h COPYONLY) +endif() \ No newline at end of file diff --git a/lwprintf/src/include/lwprintf/lwprintf.h b/lwprintf/src/include/lwprintf/lwprintf.h index 1d002fb..477c8e9 100644 --- a/lwprintf/src/include/lwprintf/lwprintf.h +++ b/lwprintf/src/include/lwprintf/lwprintf.h @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #ifndef LWPRINTF_HDR_H #define LWPRINTF_HDR_H diff --git a/lwprintf/src/include/lwprintf/lwprintf_opt.h b/lwprintf/src/include/lwprintf/lwprintf_opt.h index cc0b79a..a67628e 100644 --- a/lwprintf/src/include/lwprintf/lwprintf_opt.h +++ b/lwprintf/src/include/lwprintf/lwprintf_opt.h @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #ifndef LWPRINTF_OPT_HDR_H #define LWPRINTF_OPT_HDR_H diff --git a/lwprintf/src/include/lwprintf/lwprintf_opts_template.h b/lwprintf/src/include/lwprintf/lwprintf_opts_template.h index 6237e50..b609c5d 100644 --- a/lwprintf/src/include/lwprintf/lwprintf_opts_template.h +++ b/lwprintf/src/include/lwprintf/lwprintf_opts_template.h @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #ifndef LWPRINTF_OPTS_HDR_H #define LWPRINTF_OPTS_HDR_H diff --git a/lwprintf/src/include/system/lwprintf_sys.h b/lwprintf/src/include/system/lwprintf_sys.h index d087b5f..9b55206 100644 --- a/lwprintf/src/include/system/lwprintf_sys.h +++ b/lwprintf/src/include/system/lwprintf_sys.h @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #ifndef LWPRINTF_SYS_HDR_H #define LWPRINTF_SYS_HDR_H diff --git a/lwprintf/src/lwprintf/lwprintf.c b/lwprintf/src/lwprintf/lwprintf.c index 4d64d8d..6435f03 100644 --- a/lwprintf/src/lwprintf/lwprintf.c +++ b/lwprintf/src/lwprintf/lwprintf.c @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #include "lwprintf/lwprintf.h" #include @@ -838,7 +838,7 @@ prv_format(lwprintf_int_t* lwi, va_list arg) { const char* fmt = lwi->fmt; #if LWPRINTF_CFG_OS && !LWPRINTF_CFG_OS_MANUAL_PROTECT - if (IS_PRINT_MODE(p) && /* OS protection only for print */ + if (IS_PRINT_MODE(lwi) && /* OS protection only for print */ (!lwprintf_sys_mutex_isvalid(&lwi->lwobj->mutex) /* Invalid mutex handle */ || !lwprintf_sys_mutex_wait(&lwi->lwobj->mutex))) { /* Cannot acquire mutex */ return 0; @@ -1112,7 +1112,7 @@ prv_format(lwprintf_int_t* lwi, va_list arg) { } lwi->out_fn(lwi, '\0'); /* Output last zero number */ #if LWPRINTF_CFG_OS && !LWPRINTF_CFG_OS_MANUAL_PROTECT - if (IS_PRINT_MODE(p)) { /* Mutex only for print operation */ + if (IS_PRINT_MODE(lwi)) { /* Mutex only for print operation */ lwprintf_sys_mutex_release(&lwi->lwobj->mutex); } #endif /* LWPRINTF_CFG_OS && !LWPRINTF_CFG_OS_MANUAL_PROTECT */ diff --git a/lwprintf/src/system/lwprintf_sys_cmsis_os.c b/lwprintf/src/system/lwprintf_sys_cmsis_os.c index fffe721..e85735c 100644 --- a/lwprintf/src/system/lwprintf_sys_cmsis_os.c +++ b/lwprintf/src/system/lwprintf_sys_cmsis_os.c @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #include "system/lwprintf_sys.h" diff --git a/lwprintf/src/system/lwprintf_sys_threadx.c b/lwprintf/src/system/lwprintf_sys_threadx.c index 3c40224..191afad 100644 --- a/lwprintf/src/system/lwprintf_sys_threadx.c +++ b/lwprintf/src/system/lwprintf_sys_threadx.c @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #include "system/lwprintf_sys.h" diff --git a/lwprintf/src/system/lwprintf_sys_win32.c b/lwprintf/src/system/lwprintf_sys_win32.c index 547fccc..50a7195 100644 --- a/lwprintf/src/system/lwprintf_sys_win32.c +++ b/lwprintf/src/system/lwprintf_sys_win32.c @@ -29,7 +29,7 @@ * This file is part of LwPRINTF - Lightweight stdio manager library. * * Author: Tilen MAJERLE - * Version: v1.0.4 + * Version: v1.0.5 */ #include "system/lwprintf_sys.h"