fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. static float prv_detector_cur_get_amps(void)
  5. {
  6. const uint32_t dac1 = 2000;
  7. const float Io = (((4096 - (float) dac1) * 3.3f) / 4096) /
  8. 10000.0; /* offset current */
  9. const int32_t a = 0;
  10. const int32_t b = 0;
  11. int32_t iadc = 32768 - a;
  12. const float Ia = Io + ((((float) iadc * 3.3f) / 65536) /
  13. 16000.0);
  14. iadc = 32768 - b;
  15. const float Ib = Io + ((((float) iadc * 3.3f) / 65536) /
  16. 16000.0);
  17. const float Isense = Ia + Ib;
  18. return Isense;
  19. }
  20.  
  21. int main(void) {
  22. // your code goes here
  23. printf("%f", (prv_detector_cur_get_amps() * 1e3) / 28.f);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
0.019428