diff --git a/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.cpp b/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.cpp index d564f2d3a66bdf9a388232a46e4dd65114c415e9..05fed1f4020e73b22114aac00d68dc374b1f7d3c 100644 --- a/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.cpp +++ b/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 LAAS-CNRS + * Copyright (c) 2023 LAAS-CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -19,7 +19,7 @@ /** * @brief Owntech GPIO API - * @date 2022 + * @date 2023 * * @author Clément Foucher <clement.foucher@laas.fr> */ @@ -34,6 +34,11 @@ const struct device* const GPIO_B = DEVICE_DT_GET(DT_NODELABEL(gpiob)); const struct device* const GPIO_C = DEVICE_DT_GET(DT_NODELABEL(gpioc)); const struct device* const GPIO_D = DEVICE_DT_GET(DT_NODELABEL(gpiod)); +const gpio_flags_t INPUT = GPIO_INPUT; +const gpio_flags_t INPUT_PULLUP = GPIO_INPUT | GPIO_PULL_UP; +const gpio_flags_t OUTPUT = GPIO_OUTPUT; + + void GpioApi::configurePin(pin_t pin, gpio_flags_t flags) { gpio_pin_t pin_number = this->getPinNumber(pin); diff --git a/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.h b/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.h index fb073ea51370a1588a9ed93f8e3110664e61b7f6..78375e3b40e4273a8b29b80debd1c517fa623273 100644 --- a/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.h +++ b/zephyr/modules/owntech_gpio_api/zephyr/public_api/GpioApi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 LAAS-CNRS + * Copyright (c) 2022-2023 LAAS-CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -19,7 +19,7 @@ /** * @brief Owntech GPIO API - * @date 2022 + * @date 2023 * * @author Clément Foucher <clement.foucher@laas.fr> */ @@ -34,31 +34,31 @@ extern const struct device* const GPIO_B; extern const struct device* const GPIO_C; extern const struct device* const GPIO_D; -const gpio_flags_t INPUT = GPIO_INPUT; -const gpio_flags_t INPUT_PULLUP = GPIO_INPUT | GPIO_PULL_UP; -const gpio_flags_t OUTPUT = GPIO_OUTPUT; - -const uint8_t PA = 0x00; -const uint8_t PB = 0x10; -const uint8_t PC = 0x20; -const uint8_t PD = 0x30; - -const uint8_t P1 = 0x0; -const uint8_t P2 = 0x1; -const uint8_t P3 = 0x2; -const uint8_t P4 = 0x3; -const uint8_t P5 = 0x4; -const uint8_t P6 = 0x5; -const uint8_t P7 = 0x6; -const uint8_t P8 = 0x7; -const uint8_t P9 = 0x8; -const uint8_t P10 = 0x9; -const uint8_t P11 = 0xA; -const uint8_t P12 = 0xB; -const uint8_t P13 = 0xC; -const uint8_t P14 = 0xD; -const uint8_t P15 = 0xE; -const uint8_t P16 = 0xF; +extern const gpio_flags_t INPUT; +extern const gpio_flags_t INPUT_PULLUP; +extern const gpio_flags_t OUTPUT; + +static const uint8_t PA = 0x00; +static const uint8_t PB = 0x10; +static const uint8_t PC = 0x20; +static const uint8_t PD = 0x30; + +static const uint8_t P1 = 0x0; +static const uint8_t P2 = 0x1; +static const uint8_t P3 = 0x2; +static const uint8_t P4 = 0x3; +static const uint8_t P5 = 0x4; +static const uint8_t P6 = 0x5; +static const uint8_t P7 = 0x6; +static const uint8_t P8 = 0x7; +static const uint8_t P9 = 0x8; +static const uint8_t P10 = 0x9; +static const uint8_t P11 = 0xA; +static const uint8_t P12 = 0xB; +static const uint8_t P13 = 0xC; +static const uint8_t P14 = 0xD; +static const uint8_t P15 = 0xE; +static const uint8_t P16 = 0xF; typedef enum { @@ -118,16 +118,68 @@ typedef enum class GpioApi { public: + + /** + * @brief Configure an I/O pin. This must be done + * prior to accessing any other function + * from this API on the pin. + * + * @param pin STM32-style name of the pin, + * e.g. PA1, PB10, etc. See pin_t type for + * the full list of existing pins on + * Spin board. + * @param flags Pin configuration flags. + * Authorized values: + * - INPUT + * - INPUT_PULLUP + * - OUTPUT + */ void configurePin(pin_t pin, gpio_flags_t flags); + + /** + * @brief Set the value of a pin configured as output to 1. + * + * @param pin STM32-style name of the pin. + */ void setPin(pin_t pin); + + /** + * @brief Reset the value of a pin configured as output to 0. + * + * @param pin STM32-style name of the pin. + */ void resetPin(pin_t pin); + + /** + * @brief Toggle the value of a pin configured as output: + * - if pin value is 1, it will be set to 0 + * - if pin value is 0, it will be set to 1. + * + * @param pin STM32-style name of the pin. + */ void togglePin(pin_t pin); + + /** + * @brief Set the value of a pin configured as output + * to a given value. + * + * @param pin STM32-style name of the pin. + * @param value Value (0 or 1) to assign to the pin. + */ void writePin(pin_t pin, uint8_t value); + + /** + * @brief Get the current value of a pin configured as input. + * + * @param pin STM32-style name of the pin. + * @return Current value (0 or 1) of the pin. + */ uint8_t readPin(pin_t pin); private: gpio_pin_t getPinNumber(pin_t pin); const struct device* getGpioDevice(pin_t pin); + }; extern GpioApi gpio; diff --git a/zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/hrtim_voltage_mode.c b/zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/hrtim_voltage_mode.c index 7966256aef625c446b91ab5d0834d5409d260819..9365addd5e036a3933ef84112678c62cb48eff4a 100644 --- a/zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/hrtim_voltage_mode.c +++ b/zephyr/modules/owntech_hrtim_driver/zephyr/src/voltage_mode/hrtim_voltage_mode.c @@ -41,7 +41,7 @@ #include "assert.h" -static const struct soc_gpio_pinctrl tim_pinctrl[] = ST_STM32_DT_INST_PINCTRL(0, 0); +//static const struct soc_gpio_pinctrl tim_pinctrl[] = ST_STM32_DT_INST_PINCTRL(0, 0); static uint8_t _TU_num1(hrtim_tu_t tu) /* Return the number associated to the timing unit */ {