Skip to content

Commit

Permalink
Merge pull request #105 from MikroElektronika/improvement/logger-erro…
Browse files Browse the repository at this point in the history
…r-reporting

LOGGER - Improved status reporting
  • Loading branch information
StrahinjaJacimovic authored Oct 17, 2024
2 parents 9dd349b + f0470da commit 84e0360
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 10 deletions.
13 changes: 12 additions & 1 deletion api/log/lib/include/std_out/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ extern "C"{
* @{
*/

/*!
* \brief Return values.
*/
typedef enum
{
LOG_SUCCESS = 0, /*!< Success. */
LOG_ERROR = (-1) /*!< Error. */
} log_err_t;

/*!
* \brief Log level values
*/
Expand Down Expand Up @@ -113,8 +122,10 @@ typedef struct
*
* @param[in] log LOG context object.
* @param[in] cfg LOG configuration structure.
*
* @return Returns a value from @ref log_err_t.
*/
void log_init ( log_t *log, log_cfg_t *cfg );
log_err_t log_init ( log_t *log, log_cfg_t *cfg );

/**
* @brief Printf function.
Expand Down
13 changes: 12 additions & 1 deletion api/log/lib/include/uart/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ extern "C"{
* @{
*/

/*!
* \brief Return values.
*/
typedef enum
{
LOG_SUCCESS = 0, /*!< Success. */
LOG_ERROR = (-1) /*!< Error. */
} log_err_t;

/*!
* \brief Log level values
*/
Expand Down Expand Up @@ -133,8 +142,10 @@ typedef struct
*
* @param[in] log LOG context object.
* @param[in] cfg LOG configuration structure.
*
* @return Returns a value from @ref log_err_t.
*/
void log_init ( log_t *log, log_cfg_t *cfg );
log_err_t log_init ( log_t *log, log_cfg_t *cfg );

/**
* @brief Printf function.
Expand Down
4 changes: 3 additions & 1 deletion api/log/lib/src/std_out/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ static void api_log ( log_t *log, char * prefix, const code char * __generic_ptr
printf_me( "\n" );
}

void log_init ( log_t *log, log_cfg_t *cfg )
log_err_t log_init ( log_t *log, log_cfg_t *cfg )
{
log->log_level = cfg->level;

return LOG_SUCCESS;
}

void log_printf ( log_t *log, const code char * __generic_ptr f,... )
Expand Down
22 changes: 16 additions & 6 deletions api/log/lib/src/uart/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@
static uint8_t uart_tx_buf[ 256 ];
static uint8_t uart_rx_buf[ 256 ];

#define LOG_ASSERT_EQUAL(expected, actual) if (expected != actual) { return LOG_ERROR; } else { }

static void api_log ( log_t *log, char * prefix, const code char * __generic_ptr f, va_list ap )
{
uart_print( &log->uart, prefix );
log_implementation_do_prntf( log, f, ap );
uart_print( &log->uart, "\r\n" );
}

void log_init ( log_t *log, log_cfg_t *cfg )
log_err_t log_init ( log_t *log, log_cfg_t *cfg )
{
uart_config_t uart_cfg;
log_err_t status = LOG_SUCCESS;

// Default config
uart_configure_default( &uart_cfg );
Expand All @@ -67,14 +70,21 @@ void log_init ( log_t *log, log_cfg_t *cfg )
uart_cfg.tx_ring_size = sizeof( uart_tx_buf );
uart_cfg.rx_ring_size = sizeof( uart_rx_buf );

uart_open( &log->uart, &uart_cfg );
uart_set_baud( &log->uart, cfg->baud );
uart_set_parity( &log->uart, UART_PARITY_DEFAULT );
uart_set_stop_bits( &log->uart, UART_STOP_BITS_DEFAULT );
uart_set_data_bits( &log->uart, UART_DATA_BITS_DEFAULT );
status = uart_open( &log->uart, &uart_cfg );
LOG_ASSERT_EQUAL(status, LOG_SUCCESS);
status = uart_set_baud( &log->uart, cfg->baud );
LOG_ASSERT_EQUAL(status, LOG_SUCCESS);
status = uart_set_parity( &log->uart, UART_PARITY_DEFAULT );
LOG_ASSERT_EQUAL(status, LOG_SUCCESS);
status = uart_set_stop_bits( &log->uart, UART_STOP_BITS_DEFAULT );
LOG_ASSERT_EQUAL(status, LOG_SUCCESS);
status = uart_set_data_bits( &log->uart, UART_DATA_BITS_DEFAULT );
LOG_ASSERT_EQUAL(status, LOG_SUCCESS);
uart_set_blocking( &log->uart, true );

log->log_level = cfg->level;

return status;
}

void log_printf ( log_t *log, const code char * __generic_ptr f,... )
Expand Down
77 changes: 77 additions & 0 deletions changelog/v2.11.4/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<p align="center">
<img src="http://www.mikroe.com/img/designs/beta/logo_small.png?raw=true" alt="MikroElektronika"/>
</p>

---

**[BACK TO MAIN FILE](../../changelog.md)**

---

# `v2.11.4`

+ released: 2024-10-18

## Changes

+ [`v2.11.4`](#v2114)
+ [Changes](#changes)
+ [Improvements](#improvements)
+ [mikroSDK](#mikrosdk)
+ [CORE](#core)
+ [Fixes](#fixes)
+ [mikroSDK](#mikrosdk-1)
+ [CORE](#core-1)

### Improvements

#### mikroSDK

+ Updated logger library error handling
+ `log_init` now returns an error (`-1`) if any of the configuration API calls used in it failed

#### CORE

+ Removed `READONLY` option from linker scripts for following MCUs (CLANG)
+ `stm32h7s3a8.ld`
+ `stm32h7s3i8.ld`
+ `stm32h7s3l8.ld`
+ `stm32h7s3r8.ld`
+ `stm32h7s3v8.ld`
+ `stm32h7s3z8.ld`
+ `stm32h7s7a8.ld`
+ `stm32h7s7i8.ld`
+ `stm32h7s7l8.ld`
+ `stm32h7s7z8.ld`
+ `stm32u083cc.ld`
+ `stm32u083hc.ld`
+ `stm32u083kc.ld`
+ `stm32u083mc.ld`
+ `stm32u083rc.ld`
+ Updated project templates to report better errors
+ Case when openning designer project without a setup with TFT
+ Now reports error in the output

### Fixes

#### mikroSDK

+ Fixed following MCU cards to have correct TFT pinout definitions
+ [mcu_card_3_for_pic32](../../bsp/board/include/mcu_cards/mcu_card_3_for_pic32/mcu_card.h)
+ [mcu_card_4_for_kinetis](../../bsp/board/include/mcu_cards/mcu_card_4_for_kinetis/mcu_card.h)
+ [mcu_card_for_pic32](../../bsp/board/include/mcu_cards/mcu_card_for_pic32/mcu_card.h)
+ [sibrain_for_dspic33ep512mu814](../../bsp/board/include/mcu_cards/sibrain_for_dspic33ep512mu814/mcu_card.h)
+ [sibrain_for_dspic33fj256gp710a](../../bsp/board/include/mcu_cards/sibrain_for_dspic33fj256gp710a/mcu_card.h)
+ [sibrain_for_pic24ep512gu814](../../bsp/board/include/mcu_cards/sibrain_for_pic24ep512gu814/mcu_card.h)
+ [sibrain_for_pic24hj256gp610](../../bsp/board/include/mcu_cards/sibrain_for_pic24hj256gp610/mcu_card.h)

#### CORE

+ Removed `CAN` schema file (clock configuration) for `PIC32MZ1024EFE144`
+ Added by mistake initially

---

**[BACK TO MAIN FILE](../../changelog.md)**

---
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"display-name": "mikroSDK",
"description": "MikroSDK 2.0 is an embedded software development framework designed to simplify and accelerate application development on Mikroe hardware platform, specifically for Click Boards and other extension board drivers, on a broad range of microcontroller vendors and architectures. It includes peripheral libraries and drivers, middleware, board support, and application layer libraries among others.",
"icon": "images/icon-mikroSDK.png",
"manifest-version": "1.0.17"
"manifest-version": "1.0.18"
}

0 comments on commit 84e0360

Please sign in to comment.