Skip to content

[DM/FEATURE] Update Pin core #9604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions components/drivers/include/drivers/dev_pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ struct rt_pin_irqchip
int irq;
rt_base_t pin_range[2];
};

struct rt_pin_irq_hdr;
#endif /* RT_USING_DM */

/**
Expand All @@ -98,7 +100,13 @@ struct rt_device_pin
{
struct rt_device parent;
#ifdef RT_USING_DM
/* MUST keep the order member after parent */
struct rt_pin_irqchip irqchip;
/* Fill by DM */
rt_base_t pin_start;
rt_size_t pin_nr;
rt_list_t list;
struct rt_pin_irq_hdr *legacy_isr;
#endif /* RT_USING_DM */
const struct rt_pin_ops *ops;
};
Expand Down Expand Up @@ -212,6 +220,7 @@ struct rt_pin_ops
rt_err_t (*pin_detach_irq)(struct rt_device *device, rt_base_t pin);
rt_err_t (*pin_irq_enable)(struct rt_device *device, rt_base_t pin, rt_uint8_t enabled);
rt_base_t (*pin_get)(const char *name);
rt_err_t (*pin_debounce)(struct rt_device *device, rt_base_t pin, rt_uint32_t debounce);
#ifdef RT_USING_DM
rt_err_t (*pin_irq_mode)(struct rt_device *device, rt_base_t pin, rt_uint8_t mode);
rt_ssize_t (*pin_parse)(struct rt_device *device, struct rt_ofw_cell_args *args, rt_uint32_t *flags);
Expand Down Expand Up @@ -284,6 +293,14 @@ rt_err_t rt_pin_detach_irq(rt_base_t pin);
*/
rt_err_t rt_pin_irq_enable(rt_base_t pin, rt_uint8_t enabled);

/**
* @brief set the pin's debounce time
* @param pin the pin number
* @param debounce time
* @return rt_err_t error code
*/
rt_err_t rt_pin_debounce(rt_base_t pin, rt_uint32_t debounce);

#ifdef RT_USING_DM
rt_ssize_t rt_pin_get_named_pin(struct rt_device *dev, const char *propname, int index,
rt_uint8_t *out_mode, rt_uint8_t *out_value);
Expand Down
4 changes: 4 additions & 0 deletions components/drivers/pin/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
menuconfig RT_USING_PIN
bool "Using Generic GPIO device drivers"
default y

if RT_USING_PIN
osource "$(SOC_DM_PIN_DIR)/Kconfig"
endif
10 changes: 10 additions & 0 deletions components/drivers/pin/dev_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ rt_err_t rt_pin_irq_enable(rt_base_t pin, rt_uint8_t enabled)
return -RT_ENOSYS;
}

rt_err_t rt_pin_debounce(rt_base_t pin, rt_uint32_t debounce)
{
RT_ASSERT(_hw_pin.ops != RT_NULL);
if (_hw_pin.ops->pin_debounce)
{
return _hw_pin.ops->pin_debounce(&_hw_pin.parent, pin, debounce);
}
return -RT_ENOSYS;
}

/* RT-Thread Hardware PIN APIs */
void rt_pin_mode(rt_base_t pin, rt_uint8_t mode)
{
Expand Down
Loading
Loading