adc_buffers.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * adc_buffers.h
  3. *
  4. * Created on: Sep 5, 2024
  5. * Author: jakubski
  6. */
  7. #ifndef INC_ADC_BUFFERS_H_
  8. #define INC_ADC_BUFFERS_H_
  9. #include "stdint.h"
  10. #include "stm32h7xx_hal.h"
  11. #define EXT_VREF_mV 3000
  12. #define U_CHANNEL_CONST 7.59
  13. #define I_CHANNEL_CONST 7.5758
  14. #define deltaADC 3.0/65535
  15. enum _ADC1_DataInfo {
  16. UL1 = 0,
  17. UL2,
  18. UL3,
  19. IL1Ref,
  20. IL2Ref,
  21. IL3Ref,
  22. FanFB,
  23. IIL1,
  24. IIL2,
  25. IIL3,
  26. ADC1LastData,
  27. };
  28. typedef enum _ADC1_DataInfo ADC1_DataInfo;
  29. struct _ADC1_Data {
  30. uint16_t adcDataBuffer[ADC1LastData];
  31. uint16_t dummy[(__SCB_DCACHE_LINE_SIZE / sizeof (uint16_t)) - ADC1LastData];
  32. };
  33. enum _ADC2_DataInfo { IL1 = 0, IL2, IL3, ADC2LastData };
  34. typedef enum _ADC2_DataInfo ADC2_DataInfo;
  35. struct _ADC2_Data {
  36. uint16_t adcDataBuffer[ADC2LastData];
  37. uint16_t dummy[(__SCB_DCACHE_LINE_SIZE / sizeof (uint16_t)) - ADC2LastData];
  38. };
  39. enum _ADC3_DataInfo { pvTemp1 = 0, pvTemp2, motorXSense, motorYSense, VrefInt, ADC3LastData };
  40. typedef enum _ADC3_DataInfo ADC3_DataInfo;
  41. struct _ADC3_Data {
  42. uint16_t adcDataBuffer[ADC3LastData];
  43. uint16_t dummy[(__SCB_DCACHE_LINE_SIZE / sizeof (uint16_t)) - ADC3LastData];
  44. };
  45. typedef struct _ADC1_Data ADC1_Data;
  46. typedef struct _ADC2_Data ADC2_Data;
  47. typedef struct _ADC3_Data ADC3_Data;
  48. extern ADC1_Data adc1Data;
  49. extern ADC2_Data adc2Data;
  50. extern ADC3_Data adc3Data;
  51. #define DEFAULT_U_GAIN 1.0
  52. #define DEFAULT_U_OFFSET 0.0
  53. #define DEFAULT_I_GAIN 1.0
  54. #define DEFAULT_I_OFFSET 0.0
  55. struct _EletricalMeasCorrectionData
  56. {
  57. float gain;
  58. float offset;
  59. };
  60. typedef struct _EletricalMeasCorrectionData EletricalMeasCorrectionData;
  61. extern EletricalMeasCorrectionData U_MeasCorrectionData[3];
  62. extern EletricalMeasCorrectionData I_MeasCorrectionData[3];
  63. #endif /* INC_ADC_BUFFERS_H_ */