Просмотр исходного кода

Fixed GPIO unlocking for SPI sensors

Victor 3 лет назад
Родитель
Сommit
c42ed4c8a3
1 измененных файлов с 2 добавлено и 0 удалено
  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(2), &SPI);
     unitemp_gpio_lock(unitemp_gpio_getFromInt(3), &SPI);
     unitemp_gpio_lock(unitemp_gpio_getFromInt(3), &SPI);
     unitemp_gpio_lock(unitemp_gpio_getFromInt(5), &SPI);
     unitemp_gpio_lock(unitemp_gpio_getFromInt(5), &SPI);
+    unitemp_gpio_lock(instance->CS_pin, &SPI);
     return status;
     return status;
 }
 }
 
 
 bool unitemp_spi_sensor_free(Sensor* sensor) {
 bool unitemp_spi_sensor_free(Sensor* sensor) {
     bool status = sensor->type->mem_releaser(sensor);
     bool status = sensor->type->mem_releaser(sensor);
+    unitemp_gpio_unlock(((SPISensor*)sensor->instance)->CS_pin);
     free(((SPISensor*)(sensor->instance))->spi);
     free(((SPISensor*)(sensor->instance))->spi);
     free(sensor->instance);
     free(sensor->instance);