/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.h * @brief : Header for main.c file. * This file contains the common defines of the application. ****************************************************************************** * @attention * *

© Copyright (c) 2021 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32g0xx.h" #include "stm32g0xx_ll_dma.h" #include "stm32g0xx_ll_i2c.h" #include "stm32g0xx_ll_rcc.h" #include "stm32g0xx_ll_bus.h" #include "stm32g0xx_ll_system.h" #include "stm32g0xx_ll_exti.h" #include "stm32g0xx_ll_cortex.h" #include "stm32g0xx_ll_utils.h" #include "stm32g0xx_ll_pwr.h" #include "stm32g0xx_ll_spi.h" #include "stm32g0xx_ll_tim.h" #include "stm32g0xx_ll_gpio.h" #include "stm32g0xx_ll_usart.h" #if defined(USE_FULL_ASSERT) #include "stm32_assert.h" #endif /* USE_FULL_ASSERT */ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "gpio.h" #include "i2c.h" #include "ds3231.h" #include "bme280.h" #include "rtos.h" #include "event-system.h" #include "list_event.h" /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */ typedef enum { DOWN = 0, UP = 1 } updown_t; typedef enum { OFF = 0, ON = 1 } onoff_t; typedef struct { uint32_t RTC_IRQ: 1; uint32_t SPI_TX_End: 1; uint32_t I2C_TX_End: 1; uint32_t I2C_RX_End: 1; uint32_t I2C_TX_Err: 1; uint32_t I2C_RX_Err: 1; uint32_t BME280: 1; uint32_t Blink_1: 1; uint32_t Blink_2: 1; uint32_t Blink_3: 1; uint32_t Blink_4: 1; uint32_t Blink_5: 1; uint32_t _reserv: 20; } flag_t; extern volatile flag_t Flag; typedef union { uint16_t u16; // element specifier for accessing whole u16 int16_t i16; // element specifier for accessing whole i16 struct { #ifdef LITTLE_ENDIAN // Byte-order is little endian uint8_t u8L; // element specifier for accessing low u8 uint8_t u8H; // element specifier for accessing high u8 #else // Byte-order is big endian uint8_t u8H; // element specifier for accessing low u8 uint8_t u8L; // element specifier for accessing high u8 #endif } s16; // element spec. for acc. struct with low or high u8 } nt16_t; typedef union { uint32_t u32; // element specifier for accessing whole u32 int32_t i32; // element specifier for accessing whole i32 struct { #ifdef LITTLE_ENDIAN // Byte-order is little endian uint16_t u16L; // element specifier for accessing low u16 uint16_t u16H; // element specifier for accessing high u16 #else // Byte-order is big endian uint16_t u16H; // element specifier for accessing low u16 uint16_t u16L; // element specifier for accessing high u16 #endif } s32; // element spec. for acc. struct with low or high u16 } nt32_t; /* USER CODE END ET */ /* Exported constants --------------------------------------------------------*/ /* USER CODE BEGIN EC */ /* USER CODE END EC */ /* Exported macro ------------------------------------------------------------*/ /* USER CODE BEGIN EM */ #define LATCH_DOWN GPIOC->BRR = 0x40 #define LATCH_UP GPIOC->BSRR = 0x40 #define TUBE_PWR_ON GPIOA->BRR = 0x10 #define TUBE_PWR_OFF GPIOA->BSRR = 0x10 #define TUBE_A_ON TIM1->CCER |= (TIM_CCER_CC1E) #define TUBE_B_ON TIM3->CCER |= (TIM_CCER_CC4E) #define TUBE_C_ON TIM3->CCER |= (TIM_CCER_CC3E) #define TUBE_D_ON TIM3->CCER |= (TIM_CCER_CC2E) #define TUBE_E_ON TIM3->CCER |= (TIM_CCER_CC1E) #define TUBE_A_OFF TIM1->CCER &= ~(TIM_CCER_CC1E) #define TUBE_B_OFF TIM3->CCER &= ~(TIM_CCER_CC4E) #define TUBE_C_OFF TIM3->CCER &= ~(TIM_CCER_CC3E) #define TUBE_D_OFF TIM3->CCER &= ~(TIM_CCER_CC2E) #define TUBE_E_OFF TIM3->CCER &= ~(TIM_CCER_CC1E) #define IN15_P GPIOA->BSRR = 0x1 #define IN15_Plus GPIOA->BSRR = 0x2 #define IN15_Minus GPIOA->BSRR = 0x4 #define IN15_Percent GPIOA->BSRR = 0x8 #define IN15_OFF GPIOA->BRR = 0xF #define COLOR_R(x) TIM1->CCR2 = x #define COLOR_G(x) TIM1->CCR3 = x #define COLOR_B(x) TIM1->CCR4 = x /* USER CODE END EM */ /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ #define BTN1_GPIO_Port GPIOB #define BTN1_Pin LL_GPIO_PIN_2 #define BTN2_GPIO_Port GPIOA #define BTN2_Pin LL_GPIO_PIN_12 #define BTN3_GPIO_Port GPIOB #define BTN3_Pin LL_GPIO_PIN_4 #define BTN4_GPIO_Port GPIOA #define BTN4_Pin LL_GPIO_PIN_5 #define IRQ_EXTI_IRQn EXTI4_15_IRQn #define IRQ_GPIO_Port GPIOC #define IRQ_Pin LL_GPIO_PIN_14 #define Latch_GPIO_Port GPIOC #define Latch_Pin LL_GPIO_PIN_6 #define LC0_GPIO_Port GPIOA #define LC0_Pin LL_GPIO_PIN_0 #define LC1_GPIO_Port GPIOA #define LC1_Pin LL_GPIO_PIN_1 #define LC2_GPIO_Port GPIOA #define LC2_Pin LL_GPIO_PIN_2 #define LC3_GPIO_Port GPIOA #define LC3_Pin LL_GPIO_PIN_3 #define PWM_1_GPIO_Port GPIOA #define PWM_1_Pin LL_GPIO_PIN_8 #define PWM_2_GPIO_Port GPIOB #define PWM_2_Pin LL_GPIO_PIN_1 #define PWM_3_GPIO_Port GPIOB #define PWM_3_Pin LL_GPIO_PIN_0 #define PWM_4_GPIO_Port GPIOA #define PWM_4_Pin LL_GPIO_PIN_7 #define PWM_5_GPIO_Port GPIOA #define PWM_5_Pin LL_GPIO_PIN_6 #define PWM_B_GPIO_Port GPIOA #define PWM_B_Pin LL_GPIO_PIN_10 #define PWM_G_GPIO_Port GPIOA #define PWM_G_Pin LL_GPIO_PIN_11 #define PWM_R_GPIO_Port GPIOA #define PWM_R_Pin LL_GPIO_PIN_9 #define SHDN_GPIO_Port GPIOA #define SHDN_Pin LL_GPIO_PIN_4 #define SWCLK_GPIO_Port GPIOA #define SWCLK_Pin LL_GPIO_PIN_14 #define SWDIO_GPIO_Port GPIOA #define SWDIO_Pin LL_GPIO_PIN_13 #define UART_EN_GPIO_Port GPIOC #define UART_EN_Pin LL_GPIO_PIN_15 #define UART_ST_GPIO_Port GPIOA #define UART_ST_Pin LL_GPIO_PIN_15 /* USER CODE BEGIN Private defines */ /* BTNs */ #define BTN_NUM 4 #define BTN1_PIN GPIO_IDR_ID2 #define BTN2_PIN GPIO_IDR_ID12 #define BTN3_PIN GPIO_IDR_ID4 #define BTN4_PIN GPIO_IDR_ID5 #define BTN1_STATE (BTN1_GPIO_Port->IDR & BTN1_PIN) #define BTN2_STATE (BTN2_GPIO_Port->IDR & BTN2_PIN) #define BTN3_STATE (BTN3_GPIO_Port->IDR & BTN3_PIN) #define BTN4_STATE (BTN4_GPIO_Port->IDR & BTN4_PIN) #define BTNS1_STATE (GPIOB->IDR & (BTN1_PIN | BTN3_PIN)) #define BTNS2_STATE (GPIOA->IDR & (BTN2_PIN | BTN4_PIN)) #define BTNS_STATE (BTNS1_STATE | BTNS2_STATE) /* time constant in ms */ #define BTN_SCAN_PERIOD 10 #define BTN_SCAN_PAUSE 200 #define BTN_TIME_PRESSED 30 #define BTN_TIME_HOLDED 500 #define BTN_TIME_REPEATED 50 typedef struct { uint8_t time; es_event_t pressed; es_event_t holded; uint32_t pin; //(GPIO_TypeDef *) GPIOA; // ?->IDR } btn_t; /* USER CODE END Private defines */ #ifdef __cplusplus } #endif #endif /* __MAIN_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/