fixed the bug with botched deinig, caused by use of malloc instead of calloc

This commit is contained in:
2018-01-07 00:43:42 +01:00
parent 69fa263f45
commit b5d9d146f9
3 changed files with 9 additions and 4 deletions
+2 -1
View File
@@ -263,8 +263,9 @@ uint16_t port_pack(uint16_t spread, uint16_t mask)
void deinit_unit_pins(Unit *unit)
{
for (uint32_t rsc = R_PA0; rsc <= R_PF0; rsc++) {
for (uint32_t rsc = R_PA0; rsc <= R_PF15; rsc++) {
if (RSC_IS_HELD(unit->resources, rsc)) {
dbg("Freeing pin %s", rsc_get_name((Resource)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);