Lines Matching refs:ep
111 #define NRFX_USBD_ASSERT_EP_VALID(ep) NRFX_ASSERT( \ argument
112 ((NRF_USBD_EPIN_CHECK(ep) && (NRF_USBD_EP_NR_GET(ep) < NRF_USBD_EPIN_CNT )) \
114 (NRF_USBD_EPOUT_CHECK(ep) && (NRF_USBD_EP_NR_GET(ep) < NRF_USBD_EPOUT_CNT))) \
159 #define NRFX_USBD_EP_BITPOS(ep) \ argument
160 ((NRF_USBD_EPIN_CHECK(ep) ? NRFX_USBD_EPIN_BITPOS_0 : NRFX_USBD_EPOUT_BITPOS_0) \
161 + NRF_USBD_EP_NR_GET(ep))
177 .ep = endpont, \
366 static inline nrf_usbd_event_t nrfx_usbd_ep_to_endevent(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_to_endevent() argument
368 NRFX_USBD_ASSERT_EP_VALID(ep); in nrfx_usbd_ep_to_endevent()
395 return (NRF_USBD_EPIN_CHECK(ep) ? epin_endev : epout_endev)[NRF_USBD_EP_NR_GET(ep)]; in nrfx_usbd_ep_to_endevent()
407 static inline uint32_t nrfx_usbd_ep_to_int(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_to_int() argument
409 NRFX_USBD_ASSERT_EP_VALID(ep); in nrfx_usbd_ep_to_int()
436 return 1UL << (NRF_USBD_EPIN_CHECK(ep) ? epin_bitpos : epout_bitpos)[NRF_USBD_EP_NR_GET(ep)]; in nrfx_usbd_ep_to_int()
641 static inline uint8_t ep_to_hal(nrfx_usbd_ep_t ep) in ep_to_hal() argument
643 NRFX_USBD_ASSERT_EP_VALID(ep); in ep_to_hal()
644 return (uint8_t)ep; in ep_to_hal()
654 static inline nrf_usbd_task_t task_start_ep(nrfx_usbd_ep_t ep) in task_start_ep() argument
656 NRFX_USBD_ASSERT_EP_VALID(ep); in task_start_ep()
658 (NRF_USBD_EPIN_CHECK(ep) ? NRF_USBD_TASK_STARTEPIN0 : NRF_USBD_TASK_STARTEPOUT0) + in task_start_ep()
659 (NRF_USBD_EP_NR_GET(ep) * sizeof(uint32_t))); in task_start_ep()
670 static inline usbd_ep_state_t* ep_state_access(nrfx_usbd_ep_t ep) in ep_state_access() argument
672 NRFX_USBD_ASSERT_EP_VALID(ep); in ep_state_access()
673 return ((NRF_USBD_EPIN_CHECK(ep) ? m_ep_state.ep_in : m_ep_state.ep_out) + in ep_state_access()
674 NRF_USBD_EP_NR_GET(ep)); in ep_state_access()
689 static inline uint8_t ep2bit(nrfx_usbd_ep_t ep) in ep2bit() argument
691 NRFX_USBD_ASSERT_EP_VALID(ep); in ep2bit()
692 return (uint8_t)NRFX_USBD_EP_BITPOS(ep); in ep2bit()
751 static inline void usbd_dma_start(nrfx_usbd_ep_t ep) in usbd_dma_start() argument
753 nrf_usbd_task_trigger(NRF_USBD, task_start_ep(ep)); in usbd_dma_start()
779 static inline void usbd_ep_abort(nrfx_usbd_ep_t ep) in usbd_ep_abort() argument
783 usbd_ep_state_t * p_state = ep_state_access(ep); in usbd_ep_abort()
785 if (NRF_USBD_EPOUT_CHECK(ep)) in usbd_ep_abort()
788 if ((~m_ep_dma_waiting) & (1U << ep2bit(ep))) in usbd_ep_abort()
792 nrfx_usbd_transfer_out_drop(ep); in usbd_ep_abort()
797 m_ep_dma_waiting &= ~(1U << ep2bit(ep)); in usbd_ep_abort()
798 m_ep_ready &= ~(1U << ep2bit(ep)); in usbd_ep_abort()
805 if(!NRF_USBD_EPISO_CHECK(ep)) in usbd_ep_abort()
808 if(ep != NRFX_USBD_EPIN0) in usbd_ep_abort()
810 …(volatile uint32_t *)((uint32_t)(NRF_USBD) + 0x800)) = 0x7B6 + (2u * (NRF_USBD_EP_NR_GET(ep) - 1)); in usbd_ep_abort()
825 if ((m_ep_dma_waiting | (~m_ep_ready)) & (1U << ep2bit(ep))) in usbd_ep_abort()
828 m_ep_dma_waiting &= ~(1U << ep2bit(ep)); in usbd_ep_abort()
829 m_ep_ready |= 1U << ep2bit(ep) ; in usbd_ep_abort()
833 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_ABORTED); in usbd_ep_abort()
840 void nrfx_usbd_ep_abort(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_abort() argument
842 usbd_ep_abort(ep); in nrfx_usbd_ep_abort()
916 const nrfx_usbd_ep_t ep = NRFX_USBD_EPIN0; in nrf_usbd_ep0in_dma_handler() local
920 usbd_ep_state_t * p_state = ep_state_access(ep); in nrf_usbd_ep0in_dma_handler()
924 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_ep0in_dma_handler()
928 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_ep0in_dma_handler()
945 static inline void nrf_usbd_epin_dma_handler(nrfx_usbd_ep_t ep) in nrf_usbd_epin_dma_handler() argument
947 NRFX_LOG_DEBUG("USB event: DMA ready IN: %x", ep); in nrf_usbd_epin_dma_handler()
948 NRFX_ASSERT(NRF_USBD_EPIN_CHECK(ep)); in nrf_usbd_epin_dma_handler()
949 NRFX_ASSERT(!NRF_USBD_EPISO_CHECK(ep)); in nrf_usbd_epin_dma_handler()
950 NRFX_ASSERT(NRF_USBD_EP_NR_GET(ep) > 0); in nrf_usbd_epin_dma_handler()
953 usbd_ep_state_t * p_state = ep_state_access(ep); in nrf_usbd_epin_dma_handler()
957 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epin_dma_handler()
961 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epin_dma_handler()
972 static inline void nrf_usbd_epiniso_dma_handler(nrfx_usbd_ep_t ep) in nrf_usbd_epiniso_dma_handler() argument
976 NRFX_LOG_DEBUG("USB event: DMA ready ISOIN: %x", ep); in nrf_usbd_epiniso_dma_handler()
978 NRFX_ASSERT(NRF_USBD_EPIN_CHECK(ep)); in nrf_usbd_epiniso_dma_handler()
979 NRFX_ASSERT(NRF_USBD_EPISO_CHECK(ep)); in nrf_usbd_epiniso_dma_handler()
982 usbd_ep_state_t * p_state = ep_state_access(ep); in nrf_usbd_epiniso_dma_handler()
986 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epiniso_dma_handler()
990 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epiniso_dma_handler()
992 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OK); in nrf_usbd_epiniso_dma_handler()
1009 const nrfx_usbd_ep_t ep = NRFX_USBD_EPOUT0; in nrf_usbd_ep0out_dma_handler() local
1013 usbd_ep_state_t * p_state = ep_state_access(ep); in nrf_usbd_ep0out_dma_handler()
1017 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_ep0out_dma_handler()
1021 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_ep0out_dma_handler()
1023 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OK); in nrf_usbd_ep0out_dma_handler()
1039 static inline void nrf_usbd_epout_dma_handler(nrfx_usbd_ep_t ep) in nrf_usbd_epout_dma_handler() argument
1041 NRFX_LOG_DEBUG("DMA ready OUT: %x", ep); in nrf_usbd_epout_dma_handler()
1042 NRFX_ASSERT(NRF_USBD_EPOUT_CHECK(ep)); in nrf_usbd_epout_dma_handler()
1043 NRFX_ASSERT(!NRF_USBD_EPISO_CHECK(ep)); in nrf_usbd_epout_dma_handler()
1044 NRFX_ASSERT(NRF_USBD_EP_NR_GET(ep) > 0); in nrf_usbd_epout_dma_handler()
1047 usbd_ep_state_t * p_state = ep_state_access(ep); in nrf_usbd_epout_dma_handler()
1051 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epout_dma_handler()
1055 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epout_dma_handler()
1057 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OK); in nrf_usbd_epout_dma_handler()
1074 static inline void nrf_usbd_epoutiso_dma_handler(nrfx_usbd_ep_t ep) in nrf_usbd_epoutiso_dma_handler() argument
1078 NRFX_LOG_DEBUG("DMA ready ISOOUT: %x", ep); in nrf_usbd_epoutiso_dma_handler()
1080 NRFX_ASSERT(NRF_USBD_EPISO_CHECK(ep)); in nrf_usbd_epoutiso_dma_handler()
1083 usbd_ep_state_t * p_state = ep_state_access(ep); in nrf_usbd_epoutiso_dma_handler()
1090 (void)(NRFX_ATOMIC_FETCH_AND(&m_ep_dma_waiting, ~(1U << ep2bit(ep)))); in nrf_usbd_epoutiso_dma_handler()
1092 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OK); in nrf_usbd_epoutiso_dma_handler()
1147 static void usbd_ep_data_handler(nrfx_usbd_ep_t ep, uint8_t bitpos) in usbd_ep_data_handler() argument
1149 NRFX_LOG_DEBUG("USBD event: EndpointData: %x", ep); in usbd_ep_data_handler()
1153 if (NRF_USBD_EPIN_CHECK(ep)) in usbd_ep_data_handler()
1163 if (nrf_usbd_event_get_and_clear(NRF_USBD, nrfx_usbd_ep_to_endevent(ep))) in usbd_ep_data_handler()
1165 if (ep != NRFX_USBD_EPIN0) in usbd_ep_data_handler()
1167 nrf_usbd_epin_dma_handler(ep); in usbd_ep_data_handler()
1179 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OK); in usbd_ep_data_handler()
1190 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_WAITING); in usbd_ep_data_handler()
1291 nrfx_usbd_ep_t ep = bit2ep(bitpos); in ev_epdata_handler() local
1294 (void)(usbd_ep_data_handler(ep, bitpos)); in ev_epdata_handler()
1333 static inline size_t usbd_ep_iso_capacity(nrfx_usbd_ep_t ep) in usbd_ep_iso_capacity() argument
1335 (void)ep; in usbd_ep_iso_capacity()
1367 nrfx_usbd_ep_t ep = bit2ep(pos); in usbd_dmareq_process() local
1368 usbd_ep_state_t * p_state = ep_state_access(ep); in usbd_dmareq_process()
1377 if (NRF_USBD_EPIN_CHECK(ep)) in usbd_dmareq_process()
1393 const size_t rx_size = nrfx_usbd_epout_size_get(ep); in usbd_dmareq_process()
1407 … NRFX_LOG_DEBUG("Endpoint %x overload (r: %u, e: %u)", ep, rx_size, transfer.size); in usbd_dmareq_process()
1410 NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OVERLOAD); in usbd_dmareq_process()
1429 if (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep))) in usbd_dmareq_process()
1433 ep, in usbd_dmareq_process()
1439 nrf_usbd_ep_easydma_set(NRF_USBD, ep, transfer.p_data.addr, (uint32_t)transfer.size); in usbd_dmareq_process()
1441 usbd_dma_start(ep); in usbd_dmareq_process()
1445 while (!nrf_usbd_event_check(NRF_USBD, nrfx_usbd_ep_to_endevent(ep))) in usbd_dmareq_process()
1450 m_dma_odd ^= nrf_usbd_ep_amount_get(NRF_USBD, ep) & 1; in usbd_dmareq_process()
1686 nrfx_usbd_ep_t ep = NRFX_USBD_EPIN(n); in nrfx_usbd_init() local
1687 nrfx_usbd_ep_max_packet_size_set(ep, NRF_USBD_EPISO_CHECK(ep) ? in nrfx_usbd_init()
1689 usbd_ep_state_t * p_state = ep_state_access(ep); in nrfx_usbd_init()
1696 nrfx_usbd_ep_t ep = NRFX_USBD_EPOUT(n); in nrfx_usbd_init() local
1697 nrfx_usbd_ep_max_packet_size_set(ep, NRF_USBD_EPISO_CHECK(ep) ? in nrfx_usbd_init()
1699 usbd_ep_state_t * p_state = ep_state_access(ep); in nrfx_usbd_init()
1969 void nrfx_usbd_ep_max_packet_size_set(nrfx_usbd_ep_t ep, uint16_t size) in nrfx_usbd_ep_max_packet_size_set() argument
1972 NRFX_ASSERT((((size & (size - 1)) == 0) || (NRF_USBD_EP_NR_GET(ep) != 0))); in nrfx_usbd_ep_max_packet_size_set()
1974 NRFX_ASSERT((size != 0) || (NRF_USBD_EP_NR_GET(ep) != 0)); in nrfx_usbd_ep_max_packet_size_set()
1976 NRFX_ASSERT((NRF_USBD_EPISO_CHECK(ep) && (size <= usbd_ep_iso_capacity(ep))) || in nrfx_usbd_ep_max_packet_size_set()
1977 (!NRF_USBD_EPISO_CHECK(ep) && (size <= NRFX_USBD_EPSIZE))); in nrfx_usbd_ep_max_packet_size_set()
1979 usbd_ep_state_t * p_state = ep_state_access(ep); in nrfx_usbd_ep_max_packet_size_set()
1983 uint16_t nrfx_usbd_ep_max_packet_size_get(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_max_packet_size_get() argument
1985 usbd_ep_state_t const * p_state = ep_state_access(ep); in nrfx_usbd_ep_max_packet_size_get()
1989 bool nrfx_usbd_ep_enable_check(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_enable_check() argument
1991 return nrf_usbd_ep_enable_check(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_ep_enable_check()
1994 void nrfx_usbd_ep_enable(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_enable() argument
1996 nrf_usbd_int_enable(NRF_USBD, nrfx_usbd_ep_to_int(ep)); in nrfx_usbd_ep_enable()
1998 if (nrf_usbd_ep_enable_check(NRF_USBD, ep)) in nrfx_usbd_ep_enable()
2002 nrf_usbd_ep_enable(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_ep_enable()
2003 if ((NRF_USBD_EP_NR_GET(ep) != 0) && in nrfx_usbd_ep_enable()
2004 NRF_USBD_EPOUT_CHECK(ep) && in nrfx_usbd_ep_enable()
2005 !NRF_USBD_EPISO_CHECK(ep)) in nrfx_usbd_ep_enable()
2008 nrfx_usbd_transfer_out_drop(ep); in nrfx_usbd_ep_enable()
2009 m_ep_dma_waiting &= ~(1U << ep2bit(ep)); in nrfx_usbd_ep_enable()
2014 void nrfx_usbd_ep_disable(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_disable() argument
2016 usbd_ep_abort(ep); in nrfx_usbd_ep_disable()
2017 nrf_usbd_ep_disable(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_ep_disable()
2018 nrf_usbd_int_disable(NRF_USBD, nrfx_usbd_ep_to_int(ep)); in nrfx_usbd_ep_disable()
2045 nrfx_usbd_ep_t ep, in nrfx_usbd_ep_transfer() argument
2049 const uint8_t ep_bitpos = ep2bit(ep); in nrfx_usbd_ep_transfer()
2058 if ((NRF_USBD_EP_NR_GET(ep) == 0) && (ep != m_last_setup_dir)) in nrfx_usbd_ep_transfer()
2069 usbd_ep_state_t * p_state = ep_state_access(ep); in nrfx_usbd_ep_transfer()
2072 if (NRF_USBD_EPIN_CHECK(ep)) in nrfx_usbd_ep_transfer()
2074 p_context = m_ep_feeder_state + NRF_USBD_EP_NR_GET(ep); in nrfx_usbd_ep_transfer()
2082 if (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep))) in nrfx_usbd_ep_transfer()
2092 if (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep))) in nrfx_usbd_ep_transfer()
2106 if (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep))) in nrfx_usbd_ep_transfer()
2116 if (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep))) in nrfx_usbd_ep_transfer()
2126 p_context = m_ep_consumer_state + NRF_USBD_EP_NR_GET(ep); in nrfx_usbd_ep_transfer()
2142 (NRFX_USBD_ISO_DEBUG || !NRF_USBD_EPISO_CHECK(ep))) in nrfx_usbd_ep_transfer()
2145 …NRFX_LOG_DEBUG("Transfer called on endpoint %x, size: %u, mode: %s", ep, p_transfer->size, p_mode); in nrfx_usbd_ep_transfer()
2149 (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep)))) in nrfx_usbd_ep_transfer()
2165 nrfx_usbd_ep_t ep, in nrfx_usbd_ep_handled_transfer() argument
2169 const uint8_t ep_bitpos = ep2bit(ep); in nrfx_usbd_ep_handled_transfer()
2174 if ((NRF_USBD_EP_NR_GET(ep) == 0) && (ep != m_last_setup_dir)) in nrfx_usbd_ep_handled_transfer()
2186 usbd_ep_state_t * p_state = ep_state_access(ep); in nrfx_usbd_ep_handled_transfer()
2200 (NRFX_USBD_ISO_DEBUG || !NRF_USBD_EPISO_CHECK(ep))) in nrfx_usbd_ep_handled_transfer()
2202 NRFX_LOG_DEBUG("Transfer called on endpoint %x, mode: Handler", ep); in nrfx_usbd_ep_handled_transfer()
2205 (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep)))) in nrfx_usbd_ep_handled_transfer()
2225 nrfx_usbd_ep_status_t nrfx_usbd_ep_status_get(nrfx_usbd_ep_t ep, size_t * p_size) in nrfx_usbd_ep_status_get() argument
2229 usbd_ep_state_t const * p_state = ep_state_access(ep); in nrfx_usbd_ep_status_get()
2237 size_t nrfx_usbd_epout_size_get(nrfx_usbd_ep_t ep) in nrfx_usbd_epout_size_get() argument
2239 return nrf_usbd_epout_size_get(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_epout_size_get()
2242 bool nrfx_usbd_ep_is_busy(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_is_busy() argument
2244 …return (0 != ((m_ep_dma_waiting | ((~m_ep_ready) & NRFX_USBD_EPIN_BIT_MASK)) & (1U << ep2bit(ep)))… in nrfx_usbd_ep_is_busy()
2247 void nrfx_usbd_ep_stall(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_stall() argument
2249 NRFX_LOG_DEBUG("USB: EP %x stalled.", ep); in nrfx_usbd_ep_stall()
2250 nrf_usbd_ep_stall(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_ep_stall()
2253 void nrfx_usbd_ep_stall_clear(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_stall_clear() argument
2255 if (NRF_USBD_EPOUT_CHECK(ep) && nrfx_usbd_ep_stall_check(ep)) in nrfx_usbd_ep_stall_clear()
2257 nrfx_usbd_transfer_out_drop(ep); in nrfx_usbd_ep_stall_clear()
2259 nrf_usbd_ep_unstall(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_ep_stall_clear()
2262 bool nrfx_usbd_ep_stall_check(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_stall_check() argument
2264 return nrf_usbd_ep_is_stall(NRF_USBD, ep_to_hal(ep)); in nrfx_usbd_ep_stall_check()
2267 void nrfx_usbd_ep_dtoggle_clear(nrfx_usbd_ep_t ep) in nrfx_usbd_ep_dtoggle_clear() argument
2269 nrf_usbd_dtoggle_set(NRF_USBD, ep, NRF_USBD_DTOGGLE_DATA0); in nrfx_usbd_ep_dtoggle_clear()
2304 void nrfx_usbd_transfer_out_drop(nrfx_usbd_ep_t ep) in nrfx_usbd_transfer_out_drop() argument
2306 NRFX_ASSERT(NRF_USBD_EPOUT_CHECK(ep)); in nrfx_usbd_transfer_out_drop()
2309 m_ep_ready &= ~(1U << ep2bit(ep)); in nrfx_usbd_transfer_out_drop()
2310 if (!NRF_USBD_EPISO_CHECK(ep)) in nrfx_usbd_transfer_out_drop()
2312 nrf_usbd_epout_clear(NRF_USBD, ep); in nrfx_usbd_transfer_out_drop()