minor changes
This commit is contained in:
@@ -3,58 +3,39 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Select one of the 16 multiplexed channels.
|
||||
*
|
||||
* @param dev CD74HC4067 device instance.
|
||||
* @param channel Channel number to route (0-15).
|
||||
*
|
||||
* @retval 0 If the channel was selected.
|
||||
* @retval -EINVAL If the channel number is out of range.
|
||||
* @retval -ENODEV If one of the selection GPIOs is not ready.
|
||||
* @retval other Negative errno value from the GPIO driver.
|
||||
*/
|
||||
|
||||
// struct cd74hc4067_api {
|
||||
// int (*enable)(const struct device *dev);
|
||||
// int (*disable)(const struct device *dev);
|
||||
// int (*select_channel)(const struct device *dev, uint8_t channel);
|
||||
// };
|
||||
|
||||
struct cd74hc4067_data {
|
||||
struct k_mutex lock;
|
||||
uint8_t current_channel;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
#define CD74HC4067_SELECT_CHANNEL_COUNT 16U
|
||||
#define CD74HC4067_SELECT_PIN_COUNT 4U
|
||||
struct cd74hc4067_cfg {
|
||||
struct gpio_dt_spec select[CD74HC4067_SELECT_PIN_COUNT];
|
||||
struct gpio_dt_spec enable;
|
||||
bool has_enable;
|
||||
};
|
||||
|
||||
int cd74hc4067_enable(const struct device *dev);
|
||||
int cd74hc4067_disable(const struct device *dev);
|
||||
int cd74hc4067_select_channel(const struct device *dev, uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Enable the multiplexer output (drives the /EN pin low).
|
||||
*
|
||||
* If the instance does not provide an enable GPIO, this call is a no-op.
|
||||
*
|
||||
* @param dev CD74HC4067 device instance.
|
||||
*
|
||||
* @retval 0 On success.
|
||||
* @retval -ENODEV If the enable GPIO is not ready.
|
||||
* @retval negative errno on GPIO failures.
|
||||
*/
|
||||
int cd74hc4067_enable(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Disable the multiplexer output (drives the /EN pin high).
|
||||
*
|
||||
* @param dev CD74HC4067 device instance.
|
||||
*
|
||||
* @retval 0 On success.
|
||||
* @retval -ENOTSUP If the instance does not expose an enable GPIO.
|
||||
* @retval -ENODEV If the enable GPIO is not ready.
|
||||
* @retval negative errno on GPIO failures.
|
||||
*/
|
||||
int cd74hc4067_disable(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Return the last channel value written to the device.
|
||||
*
|
||||
* @param dev CD74HC4067 device instance.
|
||||
*
|
||||
* @return Channel number in the range [0, 15].
|
||||
*/
|
||||
uint8_t cd74hc4067_get_current_channel(const struct device *dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user