mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 22:48:23 +00:00
bsp/tms570: unite code duplication in pinmux and clean SCI close per review remarks.
Signed-off-by: Premysl Houdek <kom541000@gmail.com>
This commit is contained in:
committed by
Gedare Bloom
parent
dec479be26
commit
f8bbbdd531
@@ -525,17 +525,19 @@ static void tms570_sci_interrupt_last_close(
|
||||
{
|
||||
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);
|
||||
|
||||
if ( 0 /* for flush on close */ ) {
|
||||
/* Flush device */
|
||||
while ( ( ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0 ) {
|
||||
;/* Wait until all data has been sent */
|
||||
}
|
||||
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 */
|
||||
|
||||
@@ -111,6 +111,15 @@ void tms570_bsp_pin_set_function(int pin_num, int pin_fnc);
|
||||
|
||||
void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc);
|
||||
|
||||
static inline void
|
||||
tms570_bsp_pin_to_pinmmrx(volatile uint32_t **pinmmrx, unsigned int *pin_shift,
|
||||
int pin_num)
|
||||
{
|
||||
pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT;
|
||||
*pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0 + (pin_num >> 2);
|
||||
*pin_shift = (pin_num & 0x3)*8;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* entries array. Predefined values for pins are in a format
|
||||
* TMS570_BALL_<column><row> (for example TMS570_BALL_N19).
|
||||
* The multiplexer allows to interconnect one pin to multiple
|
||||
* signal sources/sings in the theory but it is usually bad choice.
|
||||
* signal sources/sinks in the theory but it is usually bad choice.
|
||||
* The function sets only specified function and clears all other
|
||||
* connections.
|
||||
*
|
||||
@@ -45,16 +45,12 @@ void
|
||||
tms570_bsp_pin_set_function(int pin_num, int pin_fnc)
|
||||
{
|
||||
unsigned int pin_shift;
|
||||
typeof(TMS570_IOMM.PINMUX.PINMMR0) *pinmmrx;
|
||||
volatile uint32_t *pinmmrx;
|
||||
|
||||
if ( pin_fnc == TMS570_PIN_FNC_AUTO ) {
|
||||
pin_fnc = (pin_num & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT;
|
||||
}
|
||||
pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT;
|
||||
|
||||
pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0;
|
||||
pinmmrx += (pin_num >> 2);
|
||||
pin_shift = (pin_num & 0x3)*8;
|
||||
tms570_bsp_pin_to_pinmmrx(&pinmmrx, &pin_shift, pin_num);
|
||||
*pinmmrx = (*pinmmrx & ~(0xff << pin_shift)) | (1 << (pin_fnc + pin_shift));
|
||||
}
|
||||
|
||||
@@ -74,15 +70,11 @@ void
|
||||
tms570_bsp_pin_clear_function(int pin_num, int pin_fnc)
|
||||
{
|
||||
unsigned int pin_shift;
|
||||
typeof(TMS570_IOMM.PINMUX.PINMMR0) *pinmmrx;
|
||||
volatile uint32_t *pinmmrx;
|
||||
|
||||
if ( pin_fnc == TMS570_PIN_FNC_AUTO ) {
|
||||
pin_fnc = (pin_num & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT;
|
||||
}
|
||||
pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT;
|
||||
|
||||
pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0;
|
||||
pinmmrx += (pin_num >> 2);
|
||||
pin_shift = (pin_num & 0x3)*8;
|
||||
tms570_bsp_pin_to_pinmmrx(&pinmmrx, &pin_shift, pin_num);
|
||||
*pinmmrx = *pinmmrx & ~(1 << (pin_fnc+pin_shift));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user