drivers: udc: add helper functions to set/check endpoint busy state

Add helper functions to set and check endpoint busy state.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2022-12-29 01:42:49 +01:00 committed by Carles Cufí
commit baef621bed
3 changed files with 41 additions and 0 deletions

View file

@ -46,6 +46,25 @@ struct udc_ep_config *udc_get_ep_cfg(const struct device *dev, const uint8_t ep)
return data->ep_lut[USB_EP_LUT_IDX(ep)];
}
bool udc_ep_is_busy(const struct device *dev, const uint8_t ep)
{
struct udc_ep_config *ep_cfg;
ep_cfg = udc_get_ep_cfg(dev, ep);
__ASSERT(ep_cfg != NULL, "ep 0x%02x is not available", ep);
return ep_cfg->stat.busy;
}
void udc_ep_set_busy(const struct device *dev, const uint8_t ep, const bool busy)
{
struct udc_ep_config *ep_cfg;
ep_cfg = udc_get_ep_cfg(dev, ep);
__ASSERT(ep_cfg != NULL, "ep 0x%02x is not available", ep);
ep_cfg->stat.busy = busy;
}
int udc_register_ep(const struct device *dev, struct udc_ep_config *const cfg)
{
struct udc_data *data = dev->data;

View file

@ -58,6 +58,26 @@ void udc_set_suspended(const struct device *dev, const bool value);
struct udc_ep_config *udc_get_ep_cfg(const struct device *dev,
const uint8_t ep);
/**
* @brief Checks if the endpoint is busy
*
* @param[in] dev Pointer to device struct of the driver instance
* @param[in] ep Endpoint address
*
* @return true if endpoint is busy
*/
bool udc_ep_is_busy(const struct device *dev, const uint8_t ep);
/**
* @brief Helper function to set endpoint busy state
*
* @param[in] dev Pointer to device struct of the driver instance
* @param[in] ep Endpoint address
* @param[in] busy Busy state
*/
void udc_ep_set_busy(const struct device *dev, const uint8_t ep,
const bool busy);
/**
* @brief Get UDC request from endpoint FIFO.
*

View file

@ -80,6 +80,8 @@ struct udc_ep_stat {
uint32_t data1 : 1;
/** If double buffering is supported, last used buffer is odd */
uint32_t odd : 1;
/** Endpoint is busy */
uint32_t busy : 1;
};
/**