Explorar o código

Fixed GPIO unlocking for SPI sensors

Victor %!s(int64=3) %!d(string=hai) anos
pai
achega
c42ed4c8a3
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      interfaces/SPISensor.c

+ 2 - 0
interfaces/SPISensor.c

@@ -55,11 +55,13 @@ bool unitemp_spi_sensor_alloc(Sensor* sensor, char* args) {
     unitemp_gpio_lock(unitemp_gpio_getFromInt(2), &SPI);
     unitemp_gpio_lock(unitemp_gpio_getFromInt(3), &SPI);
     unitemp_gpio_lock(unitemp_gpio_getFromInt(5), &SPI);
+    unitemp_gpio_lock(instance->CS_pin, &SPI);
     return status;
 }
 
 bool unitemp_spi_sensor_free(Sensor* sensor) {
     bool status = sensor->type->mem_releaser(sensor);
+    unitemp_gpio_unlock(((SPISensor*)sensor->instance)->CS_pin);
     free(((SPISensor*)(sensor->instance))->spi);
     free(sensor->instance);