@@ -200,6 +200,8 @@ int rp1_pio_sm_enable_sync(struct rp1_pio_client *client, void *param);
200
200
int rp1_pio_sm_put (struct rp1_pio_client * client , void * param );
201
201
int rp1_pio_sm_get (struct rp1_pio_client * client , void * param );
202
202
int rp1_pio_sm_set_dmactrl (struct rp1_pio_client * client , void * param );
203
+ int rp1_pio_sm_fifo_state (struct rp1_pio_client * client , void * param );
204
+ int rp1_pio_sm_drain_tx (struct rp1_pio_client * client , void * param );
203
205
int rp1_pio_gpio_init (struct rp1_pio_client * client , void * param );
204
206
int rp1_pio_gpio_set_function (struct rp1_pio_client * client , void * param );
205
207
int rp1_pio_gpio_set_pulls (struct rp1_pio_client * client , void * param );
@@ -551,6 +553,15 @@ static inline int pio_sm_set_dmactrl(struct rp1_pio_client *client, uint sm, boo
551
553
return rp1_pio_sm_set_dmactrl (client , & args );
552
554
};
553
555
556
+ static inline int pio_sm_drain_tx_fifo (struct rp1_pio_client * client , uint sm )
557
+ {
558
+ struct rp1_pio_sm_clear_fifos_args args = { .sm = sm };
559
+
560
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
561
+ return - EINVAL ;
562
+ return rp1_pio_sm_drain_tx (client , & args );
563
+ };
564
+
554
565
static inline int pio_sm_put (struct rp1_pio_client * client , uint sm , uint32_t data )
555
566
{
556
567
struct rp1_pio_sm_put_args args = { .sm = (uint16_t )sm , .blocking = false, .data = data };
@@ -587,6 +598,84 @@ static inline uint32_t pio_sm_get_blocking(struct rp1_pio_client *client, uint s
587
598
return args .data ;
588
599
}
589
600
601
+ static inline int pio_sm_is_rx_fifo_empty (struct rp1_pio_client * client , uint sm )
602
+ {
603
+ struct rp1_pio_sm_fifo_state_args args = { .sm = sm , .tx = false };
604
+ int ret ;
605
+
606
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
607
+ return - EINVAL ;
608
+ ret = rp1_pio_sm_fifo_state (client , & args );
609
+ if (ret == sizeof (args ))
610
+ ret = args .empty ;
611
+ return ret ;
612
+ };
613
+
614
+ static inline int pio_sm_is_rx_fifo_full (struct rp1_pio_client * client , uint sm )
615
+ {
616
+ struct rp1_pio_sm_fifo_state_args args = { .sm = sm , .tx = false };
617
+ int ret ;
618
+
619
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
620
+ return - EINVAL ;
621
+ ret = rp1_pio_sm_fifo_state (client , & args );
622
+ if (ret == sizeof (args ))
623
+ ret = args .full ;
624
+ return ret ;
625
+ };
626
+
627
+ static inline int pio_sm_rx_fifo_level (struct rp1_pio_client * client , uint sm )
628
+ {
629
+ struct rp1_pio_sm_fifo_state_args args = { .sm = sm , .tx = false };
630
+ int ret ;
631
+
632
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
633
+ return - EINVAL ;
634
+ ret = rp1_pio_sm_fifo_state (client , & args );
635
+ if (ret == sizeof (args ))
636
+ ret = args .level ;
637
+ return ret ;
638
+ };
639
+
640
+ static inline int pio_sm_is_tx_fifo_empty (struct rp1_pio_client * client , uint sm )
641
+ {
642
+ struct rp1_pio_sm_fifo_state_args args = { .sm = sm , .tx = true };
643
+ int ret ;
644
+
645
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
646
+ return - EINVAL ;
647
+ ret = rp1_pio_sm_fifo_state (client , & args );
648
+ if (ret == sizeof (args ))
649
+ ret = args .empty ;
650
+ return ret ;
651
+ };
652
+
653
+ static inline int pio_sm_is_tx_fifo_full (struct rp1_pio_client * client , uint sm )
654
+ {
655
+ struct rp1_pio_sm_fifo_state_args args = { .sm = sm , .tx = true };
656
+ int ret ;
657
+
658
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
659
+ return - EINVAL ;
660
+ ret = rp1_pio_sm_fifo_state (client , & args );
661
+ if (ret == sizeof (args ))
662
+ ret = args .full ;
663
+ return ret ;
664
+ };
665
+
666
+ static inline int pio_sm_tx_fifo_level (struct rp1_pio_client * client , uint sm )
667
+ {
668
+ struct rp1_pio_sm_fifo_state_args args = { .sm = sm , .tx = true };
669
+ int ret ;
670
+
671
+ if (bad_params_if (client , sm >= NUM_PIO_STATE_MACHINES ))
672
+ return - EINVAL ;
673
+ ret = rp1_pio_sm_fifo_state (client , & args );
674
+ if (ret == sizeof (args ))
675
+ ret = args .level ;
676
+ return ret ;
677
+ };
678
+
590
679
static inline void sm_config_set_out_pins (pio_sm_config * c , uint out_base , uint out_count )
591
680
{
592
681
if (bad_params_if (NULL , out_base >= RP1_PIO_GPIO_COUNT ||
0 commit comments