123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #pragma once
- #ifndef __MAIN_H__
- #define __MAIN_H__
- #include "buttons.h"
- /* Private defines */
- #define TOP_INFO_1_X 0
- #define TOP_INFO_1_Y 0
- #define TOP_INFO_2_X 120
- #define TOP_INFO_2_Y 0
- #define LCD_LINE_1 23
- #define LCD_LINE_2 33
- #define LCD_LINE_3 43
- #define LCD_LINE_4 53
- #define LCD_LINE_5 63
- #define LCD_LINE_6 73
- #define LCD_LINE_7 83
- #define LCD_LINE_8 93
- #define LCD_LINE_9 103
- #define ADC_GRP1_NUM_CHANNELS 1
- #define ADC_GRP1_BUF_DEPTH 100
- #define ADC_CHANNEL_NUM ADC_CHANNEL_IN9
- #define ADC_REF_VOLTAGE 3300
- /* Private variables */
- /*
- * SPI configuration structure.
- * Speed 12 MHz, CPHA=0, CPOL=0, 8bits frames, MSb transmitted first.
- * Soft slave select.
- */
- static const SPIConfig spi1cfg = {
- .circular = false,
- .slave = false,
- .data_cb = NULL,
- .error_cb = NULL,
- .cr1 = 0U,
- .cr2 = 0U
- };
- static adcsample_t ADC_Data[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
- //static adcsample_t ADC_Data;
- static uint32_t Voltage;
- /* Private function prototypes */
- static void btn1_handler(const button_state_t);
- static void btn2_handler(const button_state_t);
- static void btn3_handler(const button_state_t);
- static void btn4_handler(const button_state_t);
- static btn_hndlr bha[Button_Num] = {
- btn1_handler,
- btn2_handler,
- btn3_handler,
- btn4_handler
- };
- static void lcd_MainScreen(void);
- static void lcd_ClearMain(void);
- static uint8_t X_centered(const uint8_t len, const uint8_t pix);
- static void ADC_cb(ADCDriver *adcp);
- /* Perephireal */
- static const ADCConversionGroup adcgrpcfg1 = {
- TRUE, // circular
- ADC_GRP1_NUM_CHANNELS,
- ADC_cb,
- NULL,
- 0, /* CR1 */
- (ADC_CR2_EXTTRIG|ADC_CR2_EXTSEL_2), /* CR2, Timer 1 CC1 event, Timer 3 TRGO event */
- ADC_SMPR2_SMP_AN9(ADC_SAMPLE_71P5), /* smpr1 */
- 0, /* SMPR2 */
- ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),/* sqr1 */
- 0, /* SQR2 */
- ADC_SQR3_SQ1_N(ADC_CHANNEL_NUM) /* sqr3 */
- };
- static const GPTConfig gptcfg1 = {
- .frequency = 1000000U,
- .callback = NULL,
- .cr2 = TIM_CR2_MMS_1, /* MMS = 010 - TRGO on Update Event. */
- .dier = 0U
- };
- #endif /* __MAIN_H__ */
|