/** * @brief closes sci peripheral of interrupt driven driver * * calls tms570_sci_poll_last_close and disables interrupts * * @param[in] tty Termios control * @param[in] base context of the driver * @param[in] args * @retval false Error occured during initialization * @retval true Driver is open and ready */ static void tms570_sci_interrupt_last_close( rtems_termios_tty *tty, rtems_termios_device_context *base, rtems_libio_open_close_args_t *args ) { tms570_sci_context *ctx = (tms570_sci_context *) base; rtems_interrupt_lock_context lock_context; rtems_interval tw; int32_t baudrate; /* Turn off RX interrupts */ rtems_termios_device_lock_acquire(base, &lock_context); tms570_sci_disable_interrupts(ctx); rtems_termios_device_lock_release(base, &lock_context); tw = rtems_clock_get_ticks_per_second(); baudrate = rtems_termios_baud_to_number(cfgetospeed(&tty->termios)); tw = tw * 10 / baudrate + 1; while ( ( ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0 ) { rtems_task_wake_after(tw); } /* uninstall ISR */ rtems_interrupt_handler_remove(ctx->irq, tms570_sci_interrupt_handler, tty); tms570_sci_poll_last_close(tty, base, args); }
/** * @brief closes sci peripheral of interrupt driven driver * * calls tms570_sci_poll_last_close and disables interrupts * * @param[in] tty Termios control * @param[in] base context of the driver * @param[in] args * @retval false Error occured during initialization * @retval true Driver is open and ready */ static void tms570_sci_interrupt_last_close( rtems_termios_tty *tty, rtems_termios_device_context *base, rtems_libio_open_close_args_t *args ) { tms570_sci_context *ctx = (tms570_sci_context *) base; rtems_interrupt_lock_context lock_context; /* Turn off RX interrupts */ rtems_termios_device_lock_acquire(base, &lock_context); tms570_sci_disable_interrupts(ctx); rtems_termios_device_lock_release(base, &lock_context); /* Flush device */ while ( ( ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) > 0 ) { ;/* Wait until all data has been sent */ } /* uninstall ISR */ rtems_interrupt_handler_remove(ctx->irq, tms570_sci_interrupt_handler, tty); tms570_sci_poll_last_close(tty, base, args); }