1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/digit7seg: Add assert on gpio

This commit is contained in:
Pierre Le Meur 2024-12-02 15:31:16 +01:00
parent b42ef802b1
commit d548653def
3 changed files with 10 additions and 17 deletions

View File

@ -49,11 +49,9 @@ static void _set_pin_value(digit7seg_t *dev)
for (int i = 0; i < BYTE_BITS; i++) {
if (current_value & (1 << i)) {
gpio_set(pins[i]);
DEBUG("PIN SET\n");
}
else {
gpio_clear(pins[i]);
DEBUG("PIN CLEAR\n");
}
}
}
@ -73,8 +71,6 @@ static void _shift_display(void *arg, int chan)
dev->current_digit = dev->current_digit % dev->params.digits;
gpio_set(digit_pins[dev->current_digit]);
DEBUG("[INFO] On display %d\n", dev->current_digit);
_set_pin_value(dev);
}
@ -95,9 +91,17 @@ int digit7seg_init(digit7seg_t *dev, const digit7seg_params_t *params)
PIN_DIG1, PIN_DIG2, PIN_DIG3, PIN_DIG4
};
const char* pins_debug[] =
{
"A", "B", "C", "D", "E", "F", "G", "DP",
"DIG1", "DIG2", "DIG3", "DIG4"
};
for (int i = 0; i < NB_PIN; i++) {
assert(gpio_init(pins[i], GPIO_OUT));
DEBUG("[DIGIT7SEG] Trying the pin %s:...", pins_debug[i]);
assert(gpio_init(pins[i], GPIO_OUT) == 0);
gpio_clear(pins[i]);
DEBUG("Worked\n");
}
return DIGIT7SEG_OK;

View File

@ -44,7 +44,7 @@ extern "C" {
* @brief Return codes for @ref digit7seg_init
*/
typedef enum {
DIGIT7SEG_OK = 0,
DIGIT7SEG_OK = 0, /**< All ok */
DIGIT7SEG_ERR_DIGITS, /**< Something went wrong with digits value */
} digit7seg_error_codes;

View File

@ -74,16 +74,5 @@ int main(void)
digit7seg_poweroff(&dev);
ztimer_sleep(ZTIMER_USEC, TEST_DELAY_US * 3);
if (digit7seg_poweron(&dev) == 0) {
puts("Launched.");
}
else {
puts("Error");
}
while (1) {}
return 0;
}