From b42ef802b1f40d217e963dfabcab27427dba4d59 Mon Sep 17 00:00:00 2001 From: Pierre Le Meur Date: Mon, 25 Nov 2024 11:13:41 +0100 Subject: [PATCH] drivers/digit7seg: add asset in init --- drivers/digit7seg/digit7seg.c | 21 ++------------------- drivers/digit7seg/doc.txt | 7 +------ drivers/include/digit7seg.h | 14 +------------- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/drivers/digit7seg/digit7seg.c b/drivers/digit7seg/digit7seg.c index 4a30048f79..c03dd67c17 100644 --- a/drivers/digit7seg/digit7seg.c +++ b/drivers/digit7seg/digit7seg.c @@ -13,6 +13,7 @@ * @author Pierre Le Meur */ +#include #include "digit7seg.h" #define ENABLE_DEBUG 0 @@ -94,25 +95,8 @@ int digit7seg_init(digit7seg_t *dev, const digit7seg_params_t *params) PIN_DIG1, PIN_DIG2, PIN_DIG3, PIN_DIG4 }; - const int pin_errs[] = - { - DIGIT7SEG_ERR_A_GPIO, DIGIT7SEG_ERR_B_GPIO, DIGIT7SEG_ERR_C_GPIO, DIGIT7SEG_ERR_D_GPIO, - DIGIT7SEG_ERR_E_GPIO, DIGIT7SEG_ERR_F_GPIO, DIGIT7SEG_ERR_G_GPIO, DIGIT7SEG_ERR_DP_GPIO, - DIGIT7SEG_ERR_DIG1_GPIO, DIGIT7SEG_ERR_DIG2_GPIO, DIGIT7SEG_ERR_DIG3_GPIO, - DIGIT7SEG_ERR_DIG4_GPIO - }; - for (int i = 0; i < NB_PIN; i++) { - if (!gpio_is_valid(pins[i])) { - DEBUG("[Error] GPIO isn't valid.\n"); - return -pin_errs[i]; - } - - if (gpio_init(pins[i], GPIO_OUT) < 0) { - DEBUG("[Error] Initializing gpio error.\n"); - return -pin_errs[i]; - } - + assert(gpio_init(pins[i], GPIO_OUT)); gpio_clear(pins[i]); } @@ -142,7 +126,6 @@ int digit7seg_set_value(digit7seg_t *dev, int index, uint8_t value) int digit7seg_poweron(digit7seg_t *dev) { - if (timer_init(dev->params.timer, DIGIT7SEG_TIMER_HZ, _shift_display, dev) != 0) { DEBUG("[Error] Not possible to init timer.\n"); return -1; diff --git a/drivers/digit7seg/doc.txt b/drivers/digit7seg/doc.txt index 6f07d8e331..a5755de26b 100644 --- a/drivers/digit7seg/doc.txt +++ b/drivers/digit7seg/doc.txt @@ -174,12 +174,7 @@ else { ... -if (digit7seg_poweroff(&dev) == 0) { - puts("...Stopped"); -} -else { - puts("Error"); -} +digit7seg_poweroff(&dev) ``` */ diff --git a/drivers/include/digit7seg.h b/drivers/include/digit7seg.h index 9dd29b4642..c063372cff 100644 --- a/drivers/include/digit7seg.h +++ b/drivers/include/digit7seg.h @@ -44,19 +44,7 @@ extern "C" { * @brief Return codes for @ref digit7seg_init */ typedef enum { - DIGIT7SEG_OK = 0, /**< All ok */ - DIGIT7SEG_ERR_A_GPIO, /**< Something went wrong with A GPIO */ - DIGIT7SEG_ERR_B_GPIO, /**< Something went wrong with B GPIO */ - DIGIT7SEG_ERR_C_GPIO, /**< Something went wrong with C GPIO */ - DIGIT7SEG_ERR_D_GPIO, /**< Something went wrong with D GPIO */ - DIGIT7SEG_ERR_E_GPIO, /**< Something went wrong with E GPIO */ - DIGIT7SEG_ERR_F_GPIO, /**< Something went wrong with F GPIO */ - DIGIT7SEG_ERR_G_GPIO, /**< Something went wrong with G GPIO */ - DIGIT7SEG_ERR_DP_GPIO, /**< Something went wrong with DP GPIO */ - DIGIT7SEG_ERR_DIG1_GPIO, /**< Something went wrong with DIG1 GPIO */ - DIGIT7SEG_ERR_DIG2_GPIO, /**< Something went wrong with DIG2 GPIO */ - DIGIT7SEG_ERR_DIG3_GPIO, /**< Something went wrong with DIG3 GPIO */ - DIGIT7SEG_ERR_DIG4_GPIO, /**< Something went wrong with DIG4 GPIO */ + DIGIT7SEG_OK = 0, DIGIT7SEG_ERR_DIGITS, /**< Something went wrong with digits value */ } digit7seg_error_codes;