fixed the bug, caused by partly inited units trying to de-init pins
This commit is contained in:
@@ -91,6 +91,7 @@ void LockJumper_Check(void)
|
|||||||
|
|
||||||
if (debo_ticks > 0) {
|
if (debo_ticks > 0) {
|
||||||
if (--debo_ticks == 0) {
|
if (--debo_ticks == 0) {
|
||||||
|
dbg("Debo finished, state %d", (int)state);
|
||||||
// we've reached a change
|
// we've reached a change
|
||||||
#if PLAT_LOCK_BTN
|
#if PLAT_LOCK_BTN
|
||||||
if (state == true) {
|
if (state == true) {
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ void Indicator_Tick(void)
|
|||||||
else if (active_effect == STATUS_DISK_ATTACHED) {
|
else if (active_effect == STATUS_DISK_ATTACHED) {
|
||||||
if (effect_time == 0) led_on();
|
if (effect_time == 0) led_on();
|
||||||
else if (effect_time == 100) led_off();
|
else if (effect_time == 100) led_off();
|
||||||
else if (effect_time == 200) led_on();
|
else if (effect_time == 250) led_on();
|
||||||
else if (effect_time == 700) {
|
else if (effect_time == 750) {
|
||||||
led_off();
|
led_off();
|
||||||
active_effect = STATUS_NONE;
|
active_effect = STATUS_NONE;
|
||||||
}
|
}
|
||||||
@@ -115,8 +115,8 @@ void Indicator_Tick(void)
|
|||||||
else if (active_effect == STATUS_DISK_REMOVED) {
|
else if (active_effect == STATUS_DISK_REMOVED) {
|
||||||
if (effect_time == 0) led_on();
|
if (effect_time == 0) led_on();
|
||||||
else if (effect_time == 500) led_off();
|
else if (effect_time == 500) led_off();
|
||||||
else if (effect_time == 600) led_on();
|
else if (effect_time == 650) led_on();
|
||||||
else if (effect_time == 700) {
|
else if (effect_time == 750) {
|
||||||
led_off();
|
led_off();
|
||||||
active_effect = STATUS_NONE;
|
active_effect = STATUS_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,15 +167,17 @@ static void DI_deInit(Unit *unit)
|
|||||||
{
|
{
|
||||||
struct priv *priv = unit->data;
|
struct priv *priv = unit->data;
|
||||||
|
|
||||||
bool suc = true;
|
if (unit->status == E_SUCCESS) {
|
||||||
uint16_t mask = 1;
|
bool suc = true;
|
||||||
for (int i = 0; i < 16; i++, mask <<= 1) {
|
uint16_t mask = 1;
|
||||||
if (priv->pins & mask) {
|
for (int i = 0; i < 16; i++, mask <<= 1) {
|
||||||
uint32_t ll_pin = pin2ll((uint8_t) i, &suc);
|
if (priv->pins & mask) {
|
||||||
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
|
// configure the pin as analog
|
||||||
LL_GPIO_SetPinMode(priv->port, ll_pin, LL_GPIO_MODE_ANALOG);
|
LL_GPIO_SetPinMode(priv->port, ll_pin, LL_GPIO_MODE_ANALOG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,16 +156,19 @@ static void DO_deInit(Unit *unit)
|
|||||||
{
|
{
|
||||||
struct priv *priv = unit->data;
|
struct priv *priv = unit->data;
|
||||||
|
|
||||||
bool suc = true;
|
// de-init the pins only if inited correctly
|
||||||
uint16_t mask = 1;
|
if (unit->status == E_SUCCESS) {
|
||||||
for (int i = 0; i < 16; i++, mask <<= 1) {
|
bool suc = true;
|
||||||
if (priv->pins & mask) {
|
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);
|
uint32_t ll_pin = pin2ll((uint8_t) i, &suc);
|
||||||
assert_param(suc); // this should never fail if we got this far
|
assert_param(suc); // this should never fail if we got this far
|
||||||
|
|
||||||
// configure the pin as analog
|
// configure the pin as analog
|
||||||
LL_GPIO_SetPinMode(priv->port, ll_pin, LL_GPIO_MODE_ANALOG);
|
LL_GPIO_SetPinMode(priv->port, ll_pin, LL_GPIO_MODE_ANALOG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,8 +125,10 @@ static void Npx_deInit(Unit *unit)
|
|||||||
{
|
{
|
||||||
struct priv *priv = unit->data;
|
struct priv *priv = unit->data;
|
||||||
|
|
||||||
// configure the pin as analog
|
if (unit->status == E_SUCCESS) {
|
||||||
LL_GPIO_SetPinMode(priv->port, priv->ll_pin, LL_GPIO_MODE_ANALOG);
|
// configure the pin as analog
|
||||||
|
LL_GPIO_SetPinMode(priv->port, priv->ll_pin, LL_GPIO_MODE_ANALOG);
|
||||||
|
}
|
||||||
|
|
||||||
// Release all resources
|
// Release all resources
|
||||||
rsc_teardown(unit);
|
rsc_teardown(unit);
|
||||||
|
|||||||
Reference in New Issue
Block a user