fixed the bug, caused by partly inited units trying to de-init pins

This commit is contained in:
2018-01-02 16:49:30 +01:00
parent 39ad4a8d28
commit 64592c3bb6
5 changed files with 30 additions and 22 deletions
+11 -8
View File
@@ -156,16 +156,19 @@ static void DO_deInit(Unit *unit)
{
struct priv *priv = unit->data;
bool suc = true;
uint16_t mask = 1;
for (int i = 0; i < 16; i++, mask <<= 1) {
if (priv->pins & mask) {
// de-init the pins only if inited correctly
if (unit->status == E_SUCCESS) {
bool suc = true;
uint16_t mask = 1;
for (int i = 0; i < 16; i++, mask <<= 1) {
if (priv->pins & mask) {
uint32_t ll_pin = pin2ll((uint8_t) i, &suc);
assert_param(suc); // this should never fail if we got this far
uint32_t ll_pin = pin2ll((uint8_t) i, &suc);
assert_param(suc); // this should never fail if we got this far
// configure the pin as analog
LL_GPIO_SetPinMode(priv->port, ll_pin, LL_GPIO_MODE_ANALOG);
// configure the pin as analog
LL_GPIO_SetPinMode(priv->port, ll_pin, LL_GPIO_MODE_ANALOG);
}
}
}