added automatic GPIO teardown, remap support to i2c, force error comments in ini if disabled

This commit is contained in:
2018-01-06 18:45:23 +01:00
parent ce895b3238
commit 6756b79ef4
9 changed files with 98 additions and 91 deletions
+11
View File
@@ -260,3 +260,14 @@ uint16_t port_pack(uint16_t spread, uint16_t mask)
}
return result;
}
void deinit_unit_pins(Unit *unit)
{
for (uint32_t rsc = R_PA0; rsc <= R_PF0; rsc++) {
if (RSC_IS_HELD(unit->resources, rsc)) {
GPIO_TypeDef *port = port_periphs[(rsc-R_PA0) / 16];
uint32_t ll_pin = ll_pins[(rsc-R_PA0)%16];
LL_GPIO_SetPinMode(port, ll_pin, LL_GPIO_MODE_ANALOG);
}
}
}
+7
View File
@@ -68,4 +68,11 @@ uint16_t port_spread(uint16_t packed, uint16_t mask);
*/
uint16_t port_pack(uint16_t spread, uint16_t mask);
/**
* Set all GPIO resources held by unit to analog
*
* @param unit - holding unit
*/
void deinit_unit_pins(Unit *unit);
#endif //GEX_PIN_UTILS_H