adc_buffers.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. ADC1LastData,
  23. };
  24. typedef enum _ADC1_DataInfo ADC1_DataInfo;
  25. struct _ADC1_Data {
  26. uint16_t adcDataBuffer[ADC1LastData];
  27. uint16_t dummy[(__SCB_DCACHE_LINE_SIZE / sizeof (uint16_t)) - ADC1LastData];
  28. };
  29. enum _ADC2_DataInfo { IL1 = 0, IL2, IL3, ADC2LastData };
  30. typedef enum _ADC2_DataInfo ADC2_DataInfo;
  31. struct _ADC2_Data {
  32. uint16_t adcDataBuffer[ADC2LastData];
  33. uint16_t dummy[(__SCB_DCACHE_LINE_SIZE / sizeof (uint16_t)) - ADC2LastData];
  34. };
  35. enum _ADC3_DataInfo { pvTemp1 = 0, pvTemp2, motorXSense, motorYSense, VrefInt, ADC3LastData };
  36. typedef enum _ADC3_DataInfo ADC3_DataInfo;
  37. struct _ADC3_Data {
  38. uint16_t adcDataBuffer[ADC3LastData];
  39. uint16_t dummy[(__SCB_DCACHE_LINE_SIZE / sizeof (uint16_t)) - ADC3LastData];
  40. };
  41. typedef struct _ADC1_Data ADC1_Data;
  42. typedef struct _ADC2_Data ADC2_Data;
  43. typedef struct _ADC3_Data ADC3_Data;
  44. extern ADC1_Data adc1Data;
  45. extern ADC2_Data adc2Data;
  46. extern ADC3_Data adc3Data;
  47. #define DEFAULT_U_GAIN 1.0
  48. #define DEFAULT_U_OFFSET 0.0
  49. #define DEFAULT_I_GAIN 1.0
  50. #define DEFAULT_I_OFFSET 0.0
  51. struct _EletricalMeasCorrectionData
  52. {
  53. float gain;
  54. float offset;
  55. };
  56. typedef struct _EletricalMeasCorrectionData EletricalMeasCorrectionData;
  57. extern EletricalMeasCorrectionData U_MeasCorrectionData[3];
  58. extern EletricalMeasCorrectionData I_MeasCorrectionData[3];
  59. #endif /* INC_ADC_BUFFERS_H_ */