@@ -62,21 +62,21 @@ struct rpi_pico_data {
62
62
* 15..0 for OUT endpoints.
63
63
*/
64
64
struct k_event events ;
65
- struct k_event xfer_new ;
66
- struct k_event xfer_finished ;
65
+ atomic_t xfer_new ;
66
+ atomic_t xfer_finished ;
67
67
struct rpi_pico_ep_data out_ep [USB_NUM_ENDPOINTS ];
68
68
struct rpi_pico_ep_data in_ep [USB_NUM_ENDPOINTS ];
69
69
bool rwu_pending ;
70
70
uint8_t setup [8 ];
71
71
};
72
72
73
- static inline uint32_t udc_ep_to_bmsk (const uint8_t ep )
73
+ static inline int udc_ep_to_bnum (const uint8_t ep )
74
74
{
75
75
if (USB_EP_DIR_IS_IN (ep )) {
76
- return BIT ( 16UL + USB_EP_GET_IDX (ep ) );
76
+ return 16UL + USB_EP_GET_IDX (ep );
77
77
}
78
78
79
- return BIT ( USB_EP_GET_IDX (ep ) );
79
+ return USB_EP_GET_IDX (ep );
80
80
}
81
81
82
82
static inline uint8_t udc_pull_ep_from_bmsk (uint32_t * const bitmap )
@@ -507,7 +507,7 @@ static ALWAYS_INLINE void rpi_pico_thread_handler(void *const arg)
507
507
if (evt & BIT (RPI_PICO_EVT_XFER_FINISHED )) {
508
508
k_event_clear (& priv -> events , BIT (RPI_PICO_EVT_XFER_FINISHED ));
509
509
510
- eps = k_event_clear (& priv -> xfer_finished , UINT32_MAX );
510
+ eps = atomic_clear (& priv -> xfer_finished );
511
511
512
512
while (eps ) {
513
513
ep = udc_pull_ep_from_bmsk (& eps );
@@ -531,7 +531,7 @@ static ALWAYS_INLINE void rpi_pico_thread_handler(void *const arg)
531
531
if (evt & BIT (RPI_PICO_EVT_XFER_NEW )) {
532
532
k_event_clear (& priv -> events , BIT (RPI_PICO_EVT_XFER_NEW ));
533
533
534
- eps = k_event_clear (& priv -> xfer_new , UINT32_MAX );
534
+ eps = atomic_clear (& priv -> xfer_new );
535
535
536
536
while (eps ) {
537
537
ep = udc_pull_ep_from_bmsk (& eps );
@@ -604,7 +604,7 @@ static void rpi_pico_handle_buff_status_in(const struct device *dev, const uint8
604
604
__ASSERT (err == 0 , "Failed to start new IN transaction" );
605
605
udc_ep_buf_clear_zlp (buf );
606
606
} else {
607
- k_event_post (& priv -> xfer_finished , udc_ep_to_bmsk (ep ));
607
+ atomic_set_bit (& priv -> xfer_finished , udc_ep_to_bnum (ep ));
608
608
k_event_post (& priv -> events , BIT (RPI_PICO_EVT_XFER_FINISHED ));
609
609
}
610
610
}
@@ -634,7 +634,7 @@ static void rpi_pico_handle_buff_status_out(const struct device *dev, const uint
634
634
err = rpi_pico_prep_rx (dev , buf , ep_cfg );
635
635
__ASSERT (err == 0 , "Failed to start new OUT transaction" );
636
636
} else {
637
- k_event_post (& priv -> xfer_finished , udc_ep_to_bmsk (ep ));
637
+ atomic_set_bit (& priv -> xfer_finished , udc_ep_to_bnum (ep ));
638
638
k_event_post (& priv -> events , BIT (RPI_PICO_EVT_XFER_FINISHED ));
639
639
}
640
640
}
@@ -828,7 +828,7 @@ static int udc_rpi_pico_ep_enqueue(const struct device *dev,
828
828
udc_buf_put (cfg , buf );
829
829
830
830
if (!cfg -> stat .halted ) {
831
- k_event_post (& priv -> xfer_new , udc_ep_to_bmsk (cfg -> addr ));
831
+ atomic_set_bit (& priv -> xfer_new , udc_ep_to_bnum (cfg -> addr ));
832
832
k_event_post (& priv -> events , BIT (RPI_PICO_EVT_XFER_NEW ));
833
833
}
834
834
@@ -984,7 +984,7 @@ static int udc_rpi_pico_ep_clear_halt(const struct device *dev,
984
984
if (udc_ep_is_busy (cfg )) {
985
985
rpi_pico_handle_xfer_next (dev , cfg );
986
986
} else if (udc_buf_peek (cfg )) {
987
- k_event_post (& priv -> xfer_new , udc_ep_to_bmsk (cfg -> addr ));
987
+ atomic_set_bit (& priv -> xfer_new , udc_ep_to_bnum (cfg -> addr ));
988
988
k_event_post (& priv -> events , BIT (RPI_PICO_EVT_XFER_NEW ));
989
989
}
990
990
@@ -1144,8 +1144,8 @@ static int udc_rpi_pico_driver_preinit(const struct device *dev)
1144
1144
1145
1145
k_mutex_init (& data -> mutex );
1146
1146
k_event_init (& priv -> events );
1147
- k_event_init (& priv -> xfer_new );
1148
- k_event_init (& priv -> xfer_finished );
1147
+ atomic_clear (& priv -> xfer_new );
1148
+ atomic_clear (& priv -> xfer_finished );
1149
1149
1150
1150
data -> caps .rwup = true;
1151
1151
data -> caps .mps0 = UDC_MPS0_64 ;
0 commit comments