Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions arch/arm/src/stm32f0l0g0/stm32_serial_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ struct up_dev_s
const uint32_t rs485_dir_gpio; /* U[S]ART RS-485 DIR GPIO pin configuration */
const bool rs485_dir_polarity; /* U[S]ART RS-485 DIR pin state for TX enabled */
#endif
spinlock_t lock;
};

/****************************************************************************
Expand Down Expand Up @@ -285,6 +286,7 @@ static struct up_dev_s g_usart1priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -339,6 +341,7 @@ static struct up_dev_s g_usart2priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -393,6 +396,7 @@ static struct up_dev_s g_usart3priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -447,6 +451,7 @@ static struct up_dev_s g_usart4priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -534,11 +539,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{
irqstate_t flags;

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);

up_setusartint(priv, ie);

spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);
}

/****************************************************************************
Expand All @@ -549,7 +554,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{
irqstate_t flags;

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);

if (ie)
{
Expand Down Expand Up @@ -593,7 +598,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)

up_setusartint(priv, 0);

spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);
}

/****************************************************************************
Expand Down
11 changes: 9 additions & 2 deletions arch/arm/src/stm32f7/stm32_qencoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ struct stm32_lowerhalf_s
#ifdef HAVE_16BIT_TIMERS
volatile int32_t position; /* The current position offset */
#endif
spinlock_t lock;
};

/****************************************************************************
Expand Down Expand Up @@ -296,6 +297,7 @@ static struct stm32_lowerhalf_s g_tim1lower =
.ops = &g_qecallbacks,
.config = &g_tim1config,
.inuse = false,
.lock = SP_UNLOCKED,
};

#endif
Expand All @@ -321,6 +323,7 @@ static struct stm32_lowerhalf_s g_tim2lower =
.ops = &g_qecallbacks,
.config = &g_tim2config,
.inuse = false,
.lock = SP_UNLOCKED,
};

#endif
Expand All @@ -346,6 +349,7 @@ static struct stm32_lowerhalf_s g_tim3lower =
.ops = &g_qecallbacks,
.config = &g_tim3config,
.inuse = false,
.lock = SP_UNLOCKED,
};

#endif
Expand All @@ -371,6 +375,7 @@ static struct stm32_lowerhalf_s g_tim4lower =
.ops = &g_qecallbacks,
.config = &g_tim4config,
.inuse = false,
.lock = SP_UNLOCKED,
};

#endif
Expand All @@ -396,6 +401,7 @@ static struct stm32_lowerhalf_s g_tim5lower =
.ops = &g_qecallbacks,
.config = &g_tim5config,
.inuse = false,
.lock = SP_UNLOCKED,
};

#endif
Expand All @@ -421,6 +427,7 @@ static struct stm32_lowerhalf_s g_tim8lower =
.ops = &g_qecallbacks,
.config = &g_tim8config,
.inuse = false,
.lock = SP_UNLOCKED,
};

#endif
Expand Down Expand Up @@ -1034,15 +1041,15 @@ static int stm32_position(struct qe_lowerhalf_s *lower, int32_t *pos)

/* Loop until we are certain that no interrupt occurred between samples */

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);
do
{
position = priv->position;
count = stm32_getreg32(priv, STM32_GTIM_CNT_OFFSET);
verify = priv->position;
}
while (position != verify);
spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);

/* Return the position measurement */

Expand Down
17 changes: 13 additions & 4 deletions arch/arm/src/stm32f7/stm32_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ struct up_dev_s
const bool rs485_dir_polarity; /* U[S]ART RS-485 DIR pin state for
* TX enabled */
#endif
spinlock_t lock;
};

#ifdef CONFIG_PM
Expand Down Expand Up @@ -832,6 +833,7 @@ static struct up_dev_s g_usart1priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -900,6 +902,7 @@ static struct up_dev_s g_usart2priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -968,6 +971,7 @@ static struct up_dev_s g_usart3priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1036,6 +1040,7 @@ static struct up_dev_s g_uart4priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1104,6 +1109,7 @@ static struct up_dev_s g_uart5priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1172,6 +1178,7 @@ static struct up_dev_s g_usart6priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1240,6 +1247,7 @@ static struct up_dev_s g_uart7priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1308,6 +1316,7 @@ static struct up_dev_s g_uart8priv =
.rs485_dir_polarity = true,
# endif
#endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1408,11 +1417,11 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
{
irqstate_t flags;

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);

up_setusartint(priv, ie);

spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);
}

/****************************************************************************
Expand All @@ -1423,7 +1432,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
{
irqstate_t flags;

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);

if (ie)
{
Expand Down Expand Up @@ -1467,7 +1476,7 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)

up_setusartint(priv, 0);

spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);
}

/****************************************************************************
Expand Down
22 changes: 18 additions & 4 deletions arch/arm/src/stm32h5/stm32_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ struct stm32_serial_s
const bool rs485_dir_polarity; /* U[S]ART RS-485 DIR pin state for TX enabled */
#endif
const bool islpuart; /* Is this device a Low Power UART? */
spinlock_t lock;
};

/****************************************************************************
Expand Down Expand Up @@ -506,6 +507,7 @@ static struct stm32_serial_s g_lpuart1priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -566,6 +568,7 @@ static struct stm32_serial_s g_usart1priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -628,6 +631,7 @@ static struct stm32_serial_s g_usart2priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -690,6 +694,7 @@ static struct stm32_serial_s g_usart3priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -752,6 +757,7 @@ static struct stm32_serial_s g_uart4priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -814,6 +820,7 @@ static struct stm32_serial_s g_uart5priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -876,6 +883,7 @@ static struct stm32_serial_s g_usart6priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -938,6 +946,7 @@ static struct stm32_serial_s g_uart7priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1000,6 +1009,7 @@ static struct stm32_serial_s g_uart8priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1062,6 +1072,7 @@ static struct stm32_serial_s g_uart9priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1124,6 +1135,7 @@ static struct stm32_serial_s g_usart10priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1186,6 +1198,7 @@ static struct stm32_serial_s g_usart11priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1248,6 +1261,7 @@ static struct stm32_serial_s g_uart12priv =
.rs485_dir_polarity = true,
# endif
# endif
.lock = SP_UNLOCKED,
};
#endif

Expand Down Expand Up @@ -1375,11 +1389,11 @@ static void stm32serial_restoreusartint(struct stm32_serial_s *priv,
{
irqstate_t flags;

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);

stm32serial_setusartint(priv, ie);

spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);
}

/****************************************************************************
Expand All @@ -1391,7 +1405,7 @@ static void stm32serial_disableusartint(struct stm32_serial_s *priv,
{
irqstate_t flags;

flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&priv->lock);

if (ie)
{
Expand Down Expand Up @@ -1434,7 +1448,7 @@ static void stm32serial_disableusartint(struct stm32_serial_s *priv,

stm32serial_setusartint(priv, 0);

spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&priv->lock, flags);
}

/****************************************************************************
Expand Down
Loading