Lines Matching refs:id
38 uint32_t bdma_stm32_id_to_channel(uint32_t id) in bdma_stm32_id_to_channel() argument
51 __ASSERT_NO_MSG(id < ARRAY_SIZE(channel_nr)); in bdma_stm32_id_to_channel()
53 return channel_nr[id]; in bdma_stm32_id_to_channel()
76 void bdma_stm32_clear_ht(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_clear_ht() argument
89 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_clear_ht()
91 func[id](DMAx); in bdma_stm32_clear_ht()
94 void bdma_stm32_clear_tc(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_clear_tc() argument
107 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_clear_tc()
109 func[id](DMAx); in bdma_stm32_clear_tc()
112 bool bdma_stm32_is_ht_active(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_is_ht_active() argument
125 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_is_ht_active()
127 return func[id](DMAx); in bdma_stm32_is_ht_active()
130 bool bdma_stm32_is_tc_active(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_is_tc_active() argument
143 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_is_tc_active()
145 return func[id](DMAx); in bdma_stm32_is_tc_active()
148 void bdma_stm32_clear_te(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_clear_te() argument
161 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_clear_te()
163 func[id](DMAx); in bdma_stm32_clear_te()
166 void bdma_stm32_clear_gi(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_clear_gi() argument
179 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_clear_gi()
181 func[id](DMAx); in bdma_stm32_clear_gi()
184 bool bdma_stm32_is_te_active(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_is_te_active() argument
197 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_is_te_active()
199 return func[id](DMAx); in bdma_stm32_is_te_active()
202 bool bdma_stm32_is_gi_active(BDMA_TypeDef *DMAx, uint32_t id) in bdma_stm32_is_gi_active() argument
215 __ASSERT_NO_MSG(id < ARRAY_SIZE(func)); in bdma_stm32_is_gi_active()
217 return func[id](DMAx); in bdma_stm32_is_gi_active()
220 void stm32_bdma_dump_channel_irq(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_dump_channel_irq() argument
223 bdma_stm32_is_te_active(dma, id), in stm32_bdma_dump_channel_irq()
224 bdma_stm32_is_ht_active(dma, id), in stm32_bdma_dump_channel_irq()
225 bdma_stm32_is_tc_active(dma, id), in stm32_bdma_dump_channel_irq()
226 bdma_stm32_is_gi_active(dma, id)); in stm32_bdma_dump_channel_irq()
229 inline bool stm32_bdma_is_tc_irq_active(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_is_tc_irq_active() argument
231 return LL_BDMA_IsEnabledIT_TC(dma, bdma_stm32_id_to_channel(id)) && in stm32_bdma_is_tc_irq_active()
232 bdma_stm32_is_tc_active(dma, id); in stm32_bdma_is_tc_irq_active()
235 inline bool stm32_bdma_is_ht_irq_active(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_is_ht_irq_active() argument
237 return LL_BDMA_IsEnabledIT_HT(dma, bdma_stm32_id_to_channel(id)) && in stm32_bdma_is_ht_irq_active()
238 bdma_stm32_is_ht_active(dma, id); in stm32_bdma_is_ht_irq_active()
241 static inline bool stm32_bdma_is_te_irq_active(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_is_te_irq_active() argument
243 return LL_BDMA_IsEnabledIT_TE(dma, bdma_stm32_id_to_channel(id)) && in stm32_bdma_is_te_irq_active()
244 bdma_stm32_is_te_active(dma, id); in stm32_bdma_is_te_irq_active()
247 bool stm32_bdma_is_irq_active(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_is_irq_active() argument
249 return stm32_bdma_is_tc_irq_active(dma, id) || in stm32_bdma_is_irq_active()
250 stm32_bdma_is_ht_irq_active(dma, id) || in stm32_bdma_is_irq_active()
251 stm32_bdma_is_te_irq_active(dma, id); in stm32_bdma_is_irq_active()
254 void stm32_bdma_clear_channel_irq(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_clear_channel_irq() argument
256 bdma_stm32_clear_gi(dma, id); in stm32_bdma_clear_channel_irq()
257 bdma_stm32_clear_tc(dma, id); in stm32_bdma_clear_channel_irq()
258 bdma_stm32_clear_ht(dma, id); in stm32_bdma_clear_channel_irq()
259 bdma_stm32_clear_te(dma, id); in stm32_bdma_clear_channel_irq()
262 bool stm32_bdma_is_enabled_channel(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_is_enabled_channel() argument
264 if (LL_BDMA_IsEnabledChannel(dma, bdma_stm32_id_to_channel(id)) == 1) { in stm32_bdma_is_enabled_channel()
270 int stm32_bdma_disable_channel(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_disable_channel() argument
272 LL_BDMA_DisableChannel(dma, bdma_stm32_id_to_channel(id)); in stm32_bdma_disable_channel()
274 if (!LL_BDMA_IsEnabledChannel(dma, bdma_stm32_id_to_channel(id))) { in stm32_bdma_disable_channel()
281 void stm32_bdma_enable_channel(BDMA_TypeDef *dma, uint32_t id) in stm32_bdma_enable_channel() argument
283 LL_BDMA_EnableChannel(dma, bdma_stm32_id_to_channel(id)); in stm32_bdma_enable_channel()
286 static void bdma_stm32_dump_channel_irq(const struct device *dev, uint32_t id) in bdma_stm32_dump_channel_irq() argument
291 stm32_bdma_dump_channel_irq(dma, id); in bdma_stm32_dump_channel_irq()
294 static void bdma_stm32_clear_channel_irq(const struct device *dev, uint32_t id) in bdma_stm32_clear_channel_irq() argument
299 bdma_stm32_clear_tc(dma, id); in bdma_stm32_clear_channel_irq()
300 bdma_stm32_clear_ht(dma, id); in bdma_stm32_clear_channel_irq()
301 stm32_bdma_clear_channel_irq(dma, id); in bdma_stm32_clear_channel_irq()
304 static void bdma_stm32_irq_handler(const struct device *dev, uint32_t id) in bdma_stm32_irq_handler() argument
311 __ASSERT_NO_MSG(id < config->max_channels); in bdma_stm32_irq_handler()
313 channel = &config->channels[id]; in bdma_stm32_irq_handler()
321 bdma_stm32_clear_channel_irq(dev, id); in bdma_stm32_irq_handler()
328 callback_arg = id; in bdma_stm32_irq_handler()
333 if (stm32_bdma_is_ht_irq_active(dma, id)) { in bdma_stm32_irq_handler()
336 bdma_stm32_clear_ht(dma, id); in bdma_stm32_irq_handler()
339 } else if (stm32_bdma_is_tc_irq_active(dma, id)) { in bdma_stm32_irq_handler()
346 bdma_stm32_clear_tc(dma, id); in bdma_stm32_irq_handler()
352 bdma_stm32_dump_channel_irq(dev, id); in bdma_stm32_irq_handler()
353 bdma_stm32_clear_channel_irq(dev, id); in bdma_stm32_irq_handler()
443 static int bdma_stm32_disable_channel(BDMA_TypeDef *bdma, uint32_t id) in bdma_stm32_disable_channel() argument
448 if (stm32_bdma_disable_channel(bdma, id) == 0) { in bdma_stm32_disable_channel()
481 uint32_t id, in bdma_stm32_configure() argument
486 &dev_config->channels[id]; in bdma_stm32_configure()
494 if (id >= dev_config->max_channels) { in bdma_stm32_configure()
495 LOG_ERR("cannot configure the bdma channel %d.", id); in bdma_stm32_configure()
500 LOG_ERR("bdma channel %d is busy.", id); in bdma_stm32_configure()
504 if (bdma_stm32_disable_channel(bdma, id) != 0) { in bdma_stm32_configure()
505 LOG_ERR("could not disable bdma channel %d.", id); in bdma_stm32_configure()
509 bdma_stm32_clear_channel_irq(dev, id); in bdma_stm32_configure()
665 LL_BDMA_Init(bdma, bdma_stm32_id_to_channel(id), &BDMA_InitStruct); in bdma_stm32_configure()
667 LL_BDMA_EnableIT_TC(bdma, bdma_stm32_id_to_channel(id)); in bdma_stm32_configure()
671 LL_BDMA_EnableIT_HT(bdma, bdma_stm32_id_to_channel(id)); in bdma_stm32_configure()
677 BDMA_STM32_EXPORT_API int bdma_stm32_reload(const struct device *dev, uint32_t id, in bdma_stm32_reload() argument
685 if (id >= config->max_channels) { in bdma_stm32_reload()
689 channel = &config->channels[id]; in bdma_stm32_reload()
691 if (bdma_stm32_disable_channel(bdma, id) != 0) { in bdma_stm32_reload()
697 LL_BDMA_SetMemoryAddress(bdma, bdma_stm32_id_to_channel(id), src); in bdma_stm32_reload()
698 LL_BDMA_SetPeriphAddress(bdma, bdma_stm32_id_to_channel(id), dst); in bdma_stm32_reload()
702 LL_BDMA_SetPeriphAddress(bdma, bdma_stm32_id_to_channel(id), src); in bdma_stm32_reload()
703 LL_BDMA_SetMemoryAddress(bdma, bdma_stm32_id_to_channel(id), dst); in bdma_stm32_reload()
710 LL_BDMA_SetDataLength(bdma, bdma_stm32_id_to_channel(id), in bdma_stm32_reload()
713 LL_BDMA_SetDataLength(bdma, bdma_stm32_id_to_channel(id), in bdma_stm32_reload()
720 stm32_bdma_enable_channel(bdma, id); in bdma_stm32_reload()
725 BDMA_STM32_EXPORT_API int bdma_stm32_start(const struct device *dev, uint32_t id) in bdma_stm32_start() argument
732 if (id >= config->max_channels) { in bdma_stm32_start()
737 if (stm32_bdma_is_enabled_channel(bdma, id)) { in bdma_stm32_start()
742 channel = &config->channels[id]; in bdma_stm32_start()
745 bdma_stm32_clear_channel_irq(dev, id); in bdma_stm32_start()
746 stm32_bdma_enable_channel(bdma, id); in bdma_stm32_start()
751 BDMA_STM32_EXPORT_API int bdma_stm32_stop(const struct device *dev, uint32_t id) in bdma_stm32_stop() argument
754 struct bdma_stm32_channel *channel = &config->channels[id]; in bdma_stm32_stop()
757 if (id >= config->max_channels) { in bdma_stm32_stop()
767 if (!stm32_bdma_is_enabled_channel(bdma, id)) { in bdma_stm32_stop()
772 LL_BDMA_DisableIT_TC(bdma, bdma_stm32_id_to_channel(id)); in bdma_stm32_stop()
773 LL_BDMA_DisableIT_HT(bdma, bdma_stm32_id_to_channel(id)); in bdma_stm32_stop()
775 bdma_stm32_disable_channel(bdma, id); in bdma_stm32_stop()
776 bdma_stm32_clear_channel_irq(dev, id); in bdma_stm32_stop()
834 uint32_t id, struct dma_status *stat) in bdma_stm32_get_status() argument
840 if (id >= config->max_channels) { in bdma_stm32_get_status()
844 channel = &config->channels[id]; in bdma_stm32_get_status()
845 stat->pending_length = LL_BDMA_GetDataLength(bdma, bdma_stm32_id_to_channel(id)); in bdma_stm32_get_status()