Skip to content

Commit

Permalink
sys/config: Make floating point support optional
Browse files Browse the repository at this point in the history
Adding CONF_FLOAT support could increase code size significantly
if floating point are not used otherwise.

This makes float support optional (enabled by default when HARDFLOAT is present).

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
  • Loading branch information
kasjer committed Apr 16, 2024
1 parent ae9af15 commit 0375f04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sys/config/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen)
{
int64_t val;
uint64_t uval;
#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT)
float fval;
#endif
char *eptr;

if (!val_str) {
Expand Down Expand Up @@ -223,13 +225,15 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen)
*(uint64_t *)vp = uval;
}
break;
#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT)
case CONF_FLOAT:
fval = strtof(val_str, &eptr);
if (*eptr != '\0') {
goto err;
}
*(float *)vp = fval;
break;
#endif
case CONF_STRING:
val = strlen(val_str);
if (val + 1 > maxlen) {
Expand Down
9 changes: 9 additions & 0 deletions sys/config/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ syscfg.defs:
description: >
Max length of a value stored in the config FCB.
value: 256
CONFIG_FLOAT_SUPPORT:
description: >
Enable float support in config.
For MCU without hardware support for enabling this if no other
function use floating point may increase image size 20kB or more.
value: 0

syscfg.vals.HARDFLOAT:
value: 1

syscfg.defs.(CONFIG_FCB || CONFIG_FCB2):
CONFIG_FCB_FLASH_AREA:
Expand Down

0 comments on commit 0375f04

Please sign in to comment.