LabArm.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #pragma once
  2. #if !defined(__LAB_ARM_H__)
  3. #define __LAB_ARM_H__
  4. #include "n3310.h"
  5. #include "event.h"
  6. #define Delay(tick) \
  7. { \
  8. __IO int i = tick; \
  9. while ( i != 0 ) \
  10. i--; \
  11. }
  12. #define ADC_ARRAY_SIZE 256
  13. extern uint32_t ADCVoltage;
  14. extern uint32_t ADCCurrent;
  15. #define AUTO_APPLY_FLAG 0x8000
  16. #define BACKUP_SAVE_FLAG 0x4000
  17. #define IMEDDIATE_APPLY_FLAG 0x2000
  18. extern uint16_t Flags;
  19. extern uint8_t Contrast;
  20. extern MenuFunction_t AfterContrast;
  21. extern uint8_t MenuPos;
  22. void ContrastMenu(void);
  23. void LcdBlank(void);
  24. #define DAC_V (DAC->DHR12R1)
  25. #define DAC_I (DAC->DHR12R2)
  26. void CalibrationMenu(void);
  27. void StartFunction(void);
  28. void SaveMenu(void); /* Save settings to flash menu */
  29. #if defined(CLOCK_ENABLED)
  30. int SwitchOnTheClock(void);
  31. void SetupTheClock(void);
  32. /*
  33. RTCVal - seconds to display
  34. InvPos - position that has to be inverted. If the first bit is 1 - display seconds also? else - onlu hours and minutes
  35. Position - start coordinated to display the clock. It can have size 5 or 8 characters depend on InPos 1-st bit */
  36. void DisplayClock(uint32_t RTCVal, uint16_t InvPos, uint32_t Position);
  37. #define IS_ON_CLOCK ((RCC->BDCR & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL_0)
  38. void TimerSetup(void);
  39. extern uint16_t TimerValue;
  40. extern uint16_t RemainTimerValue;
  41. #endif
  42. typedef struct
  43. {
  44. uint16_t VoltageDAC; // & Contrast
  45. uint16_t CurrentDAC; // & Flafs
  46. }Settings_t;
  47. typedef struct
  48. {
  49. float ADCRamp;
  50. float ADCOffset;
  51. float DACRamp;
  52. float DACOffset;
  53. int8_t DotPosition;
  54. int8_t Res[3];
  55. }
  56. SubConfig_t;
  57. typedef struct
  58. {
  59. uint16_t Value;
  60. int8_t DotPosition;
  61. #define MENU_I_FLAG 1
  62. #define MENU_V_FLAG 2
  63. int8_t IVFlag;
  64. char Text[4];
  65. }
  66. UserMenu_t;
  67. typedef struct
  68. {
  69. SubConfig_t V;
  70. SubConfig_t I;
  71. UserMenu_t Menu[14];
  72. int32_t Crc;
  73. }Config_t;
  74. #define SAVED_SETTINGS_COUNT (1024 - sizeof(Config_t))/sizeof(Settings_t)
  75. //#define SAVED_SETTINGS_COUNT 4
  76. typedef struct
  77. {
  78. Settings_t Settings[SAVED_SETTINGS_COUNT];
  79. Config_t Config;
  80. // char res[1024-sizeof(Config_t) - SAVED_SETTINGS_COUNT*sizeof(Settings_t)];
  81. } SavedDomain_t;
  82. void OutValue(uint8_t Y, uint8_t X, uint16_t Num, uint8_t DotPosition, uint8_t SelectPos);
  83. void OutValueSmall(uint8_t Y, uint8_t X, uint16_t Num, uint8_t DotPosition, uint8_t InverseFlag);
  84. #if defined(GRAPH)
  85. #undef RAW
  86. #endif
  87. #if defined(RAW)
  88. extern uint8_t DisplayRaw;
  89. #endif
  90. //uint32_t Crc(const void* Pointer, int Len);
  91. void SaveConfig(void);
  92. int RestoreConfig(void); /* Return !0 if failed */
  93. void SaveSettings(uint16_t AndFlash);
  94. extern Config_t CurrentConfig;
  95. extern Settings_t CurrentSettings;
  96. int16_t VoltageFromAdc(void);
  97. int16_t CurrentFromAdc(void);
  98. int16_t VoltageFromDac(void);
  99. int16_t CurrentFromDac(void);
  100. extern int16_t HumanV;
  101. extern int16_t HumanI;
  102. #if defined(GRAPH)
  103. #define GRAPH_SIZE 80
  104. typedef struct
  105. {
  106. int16_t Min;
  107. int16_t Max;
  108. }
  109. Graph_t;
  110. extern Graph_t IGraphArray[GRAPH_SIZE];
  111. extern Graph_t VGraphArray[GRAPH_SIZE];
  112. extern uint8_t GraphCurrentPoint;
  113. typedef struct
  114. {
  115. Graph_t* GraphArray;
  116. int8_t DotPosition;
  117. } GraphData_t;
  118. extern GraphData_t GraphData;
  119. extern uint16_t TimeInterval;
  120. void DisplayGraph(void);
  121. void ClearGraph(void);
  122. #endif /*FRAPH*/
  123. #endif /*__LAB_ARM_H__*/