main.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #ifndef __MAIN_H__
  3. #define __MAIN_H__
  4. #include "buttons.h"
  5. /* Private defines */
  6. #define TOP_INFO_1_X 0
  7. #define TOP_INFO_1_Y 0
  8. #define TOP_INFO_2_X 120
  9. #define TOP_INFO_2_Y 0
  10. #define LCD_LINE_1 23
  11. #define LCD_LINE_2 33
  12. #define LCD_LINE_3 43
  13. #define LCD_LINE_4 53
  14. #define LCD_LINE_5 63
  15. #define LCD_LINE_6 73
  16. #define LCD_LINE_7 83
  17. #define LCD_LINE_8 93
  18. #define LCD_LINE_9 103
  19. #define ADC_GRP1_NUM_CHANNELS 1
  20. #define ADC_GRP1_BUF_DEPTH 10
  21. #define ADC_CHANNEL_NUM ADC_CHANNEL_IN9
  22. #define ADC_REF_VOLTAGE 3300
  23. /* Private variables */
  24. /*
  25. * SPI configuration structure.
  26. * Speed 12 MHz, CPHA=0, CPOL=0, 8bits frames, MSb transmitted first.
  27. * Soft slave select.
  28. */
  29. static const SPIConfig spi1cfg = {
  30. .circular = false,
  31. .slave = false,
  32. .data_cb = NULL,
  33. .error_cb = NULL,
  34. .cr1 = 0U,
  35. .cr2 = 0U
  36. };
  37. static adcsample_t ADC_Data[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
  38. //static adcsample_t ADC_Data;
  39. static uint32_t Voltage;
  40. /* Private function prototypes */
  41. static void btn1_handler(const button_state_t);
  42. static void btn2_handler(const button_state_t);
  43. static void btn3_handler(const button_state_t);
  44. static void btn4_handler(const button_state_t);
  45. static btn_hndlr bha[Button_Num] = {
  46. btn1_handler,
  47. btn2_handler,
  48. btn3_handler,
  49. btn4_handler
  50. };
  51. static void lcd_MainScreen(void);
  52. static void lcd_ClearMain(void);
  53. static uint8_t X_centered(const uint8_t len, const uint8_t pix);
  54. static void ADC_cb(ADCDriver *adcp);
  55. /* Perephireal */
  56. static const ADCConversionGroup adcgrpcfg1 = {
  57. TRUE, // circular
  58. ADC_GRP1_NUM_CHANNELS,
  59. ADC_cb,
  60. NULL,
  61. 0, /* CR1 */
  62. 0, //(ADC_CR2_EXTTRIG|ADC_CR2_EXTSEL_2), /* CR2, Timer 1 CC1 event, Timer 3 TRGO event */
  63. ADC_SMPR2_SMP_AN9(ADC_SAMPLE_71P5), /* smpr1 */
  64. 0, /* SMPR2 */
  65. ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),/* sqr1 */
  66. 0, /* SQR2 */
  67. ADC_SQR3_SQ1_N(ADC_CHANNEL_NUM) /* sqr3 */
  68. };
  69. static const GPTConfig gptcfg1 = {
  70. .frequency = 1000000U,
  71. .callback = NULL,
  72. .cr2 = TIM_CR2_MMS_1, /* MMS = 010 - TRGO on Update Event. */
  73. .dier = 0U
  74. };
  75. #endif /* __MAIN_H__ */