123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #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
- #define ONEWIRE1_PORT GPIOB
- #define ONEWIRE1_PIN 9
- #define ONEWIRE1_PWM_DRIVER PWMD4
- #define ONEWIRE1_MASTER_CHANNEL 3
- #define ONEWIRE1_SAMPLE_CHANNEL 4
- #define ONEWIRE2_PORT GPIOB
- #define ONEWIRE2_PIN 8
- #define ONEWIRE2_PWM_DRIVER PWMD4
- #define ONEWIRE2_MASTER_CHANNEL 4
- #define ONEWIRE2_SAMPLE_CHANNEL 3
- #define ONWIRE_CHANNELS_NUM 2
- #define ONEWIRE_PAD_MODE_IDLE PAL_MODE_INPUT
- #define ONEWIRE_PAD_MODE_ACTIVE PAL_MODE_STM32_ALTERNATE_OPENDRAIN
- /* 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
- };
- /*
- * Config for underlying PWM driver.
- * Note! It is NOT constant because 1-wire driver needs to change them
- * during functioning.
- */
- static PWMConfig pwm_cfg = {
- 0,
- 0,
- NULL,
- {
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL}
- },
- 0,
- #if STM32_PWM_USE_ADVANCED
- 0,
- #endif
- 0,
- 0
- };
- /*
- * OneWire channel 1
- */
- static const onewireConfig ow_cfg1 = {
- &ONEWIRE1_PWM_DRIVER,
- &pwm_cfg,
- PWM_OUTPUT_ACTIVE_LOW,
- ONEWIRE1_MASTER_CHANNEL,
- ONEWIRE1_SAMPLE_CHANNEL,
- ONEWIRE1_PORT,
- ONEWIRE1_PIN,
- #if defined(STM32F1XX)
- ONEWIRE_PAD_MODE_IDLE,
- #endif
- ONEWIRE_PAD_MODE_ACTIVE,
- #if ONEWIRE_USE_STRONG_PULLUP
- strong_pullup_assert,
- strong_pullup_release
- #endif
- };
- /*
- * OneWire channel 2
- */
- static const onewireConfig ow_cfg2 = {
- &ONEWIRE2_PWM_DRIVER,
- &pwm_cfg,
- PWM_OUTPUT_ACTIVE_LOW,
- ONEWIRE2_MASTER_CHANNEL,
- ONEWIRE2_SAMPLE_CHANNEL,
- ONEWIRE2_PORT,
- ONEWIRE2_PIN,
- #if defined(STM32F1XX)
- ONEWIRE_PAD_MODE_IDLE,
- #endif
- ONEWIRE_PAD_MODE_ACTIVE,
- #if ONEWIRE_USE_STRONG_PULLUP
- strong_pullup_assert,
- strong_pullup_release
- #endif
- };
- #endif /* __MAIN_H__ */
|