@@ -200,6 +200,8 @@ int rp1_pio_sm_enable_sync(struct rp1_pio_client *client, void *param);
200200int rp1_pio_sm_put (struct rp1_pio_client * client , void * param );
201201int rp1_pio_sm_get (struct rp1_pio_client * client , void * param );
202202int 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 );
203205int rp1_pio_gpio_init (struct rp1_pio_client * client , void * param );
204206int rp1_pio_gpio_set_function (struct rp1_pio_client * client , void * param );
205207int 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
551553 return rp1_pio_sm_set_dmactrl (client , & args );
552554};
553555
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+
554565static inline int pio_sm_put (struct rp1_pio_client * client , uint sm , uint32_t data )
555566{
556567 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
587598 return args .data ;
588599}
589600
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+
590679static inline void sm_config_set_out_pins (pio_sm_config * c , uint out_base , uint out_count )
591680{
592681 if (bad_params_if (NULL , out_base >= RP1_PIO_GPIO_COUNT ||
0 commit comments