| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- // SPDX-License-Identifier: BSD-2-Clause
- // Copyright (c) 2023 KBEmbedded
- #ifndef __GBLINK_PINCONF_H__
- #define __GBLINK_PINCONF_H__
- #pragma once
- #include <furi.h>
- #include <furi_hal.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- /**
- * Set one of the pre-configured pinouts
- *
- * @param handle Pointer to gblink handle
- * @param pinout Which pinout to use
- *
- * @note The gblink instance must not be gblink_start()'ed!
- *
- * @returns 0 on success, -1 if gblink instance is not gblink_stop()'ed.
- */
- int gblink_pin_set_default(void *handle, gblink_pinouts pinout);
- /**
- * Check if the pinout set matches a pre-configured one
- *
- * @param handle Pointer to gblink handle
- *
- * @returns The index of the pre-configured pinout or -1 on error
- */
- int gblink_pin_get_default(void *handle);
- /**
- * Set a GPIO pin to a specific pin mode for the EXT interface
- *
- * @param handle Pointer to gblink handle
- * @param pin Pin mode to assign to the gpio pin
- * @param pinnum GPIO pin number to assign pin mode to
- *
- * @note The gblink instance must not be gblink_start()'ed!
- *
- * @returns 0 on success, -1 if gblink instance is not gblink_stop()ed
- */
- int gblink_pin_set(void *handle, gblink_bus_pins pin, unsigned int pinum);
- /**
- * Get the pin number associated with the requested pin mode
- *
- *
- * @param handle Pointer to gblink handle
- * @param pin Pin mode to inquire about
- *
- * @returns Pin number of the requested pin or -1 on error
- */
- int gblink_pin_get(void *handle, gblink_bus_pins pin);
- /**
- * Set a gpio pin to a specific pin mode via GpioPin
- *
- * @param handle Pointer to gblink handle
- * @param pin Pin mode to assign to the gpio pin
- * @param gpio Which gpio pin to assign the pin mode
- *
- * @note The gblink instance must not be gblink_start()'ed!
- * @note There is no sane way to do bounds checking with this function, so be
- * careful when passing pointers to ensure they are actually Flipper GpioPin
- * references.
- *
- * @returns 0 on success, -1 if gblink instance is not gblink_stop()'ed.
- */
- int gblink_pin_set_by_gpiopin(void *handle, gblink_bus_pins pin, const GpioPin *gpio);
- /**
- * Get the GpioPin associated with the requested pin mode
- *
- * @param handle Pointer to gblink handle
- * @param pin Pin mode to inquire about
- *
- * @returns GpioPin pointer
- */
- const GpioPin *gblink_pin_get_by_gpiopin(void *handle, gblink_bus_pins pin);
- /**
- * Returns the pinnum of the highest usable, non-debug pin.
- *
- * @returns count of highest usable, non-debug pin or -1 on error
- */
- int gblink_pin_count_max(void);
- /**
- * Get the next usable, non-debug GPIO pin by number.
- *
- * The return value is the next usable, non-debug pin starting from pinnum and
- * will include pinnum if it is a valid pin.
- *
- * @param pinnum GPIO pin number to check if it is a valid pin.
- *
- * @returns -1 on error or no more valid pins. Any other value is the next usable
- * pin which can include pinnum if it is usable. If pinnum is not usable, the next
- * numbered pin which is will be returned or -1 if there are no further pins.
- */
- int gblink_pin_get_next(unsigned int pinnum);
- /**
- * Get the previous usable, non-debug GPIO pin by number.
- *
- * The return value is the previous usable, non-debug pin starting from pinnum and
- * will include pinnum if it is a valid pin.
- *
- * @param pinnum GPIO pin number to check if it is a valid pin.
- *
- * @returns -1 on error or no more valid pins. Any other value is the previous usable
- * pin which can include pinnum if it is usable. If pinnum is not usable, the previous
- * numbered pin which is will be returned or -1 if there are no further pins.
- */
- int gblink_pin_get_prev(unsigned int pinnum);
- /**
- * Load pin configuration from file automatically
- * Loads from .gblink_pinconf in app data folder
- *
- * @param gblink Pointer to gblink instance to set pins configurations
- *
- * @returns true on success, false on error
- *
- * @note This function should be called from the context of the application and
- * not any other threads as it uses the app data folder to load data from
- */
- bool gblink_pinconf_load(void *gblink);
- /**
- * Save current pin configuration to file automatically
- * Saves to .gblink_pinconf in app data folder
- *
- * @param gblink Pointer to gblink instance to save pins configurations
- *
- * @returns true on success, false on error
- *
- * @note This function should be called from the context of the application and
- * not any other threads as it uses the app data folder to save data to.
- */
- bool gblink_pinconf_save(void *gblink);
- #ifdef __cplusplus
- }
- #endif
- #endif // __GBLINK_PINCONF_H__
|