123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #pragma once
- #ifndef _BOARD_H
- #define _BOARD_H
- /* Includes */
- #include "stm32g0xx.h"
- #include "gpio.h"
- /* Exported macros */
- #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_BCDE_ON TIM3->CCER |= (TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E)
- #define TUBE_ALL_ON TUBE_A_ON; TUBE_BCDE_ON
- #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
- /* Constants */
- #define PWM_LED_INIT_VAL 500
- #define PWM_TUBE_INIT_VAL 500
- #define TIM1_PSC (120 - 1)
- #define TIM1_ARR (1000 - 1)
- #define TIM3_PSC (120 - 1)
- #define TIM3_ARR (1000 - 1)
- #define TIM14_PSC (24000 - 1)
- #define TIM14_ARR (1000 - 1)
- #define TIM14_PULSE_VAL 750
- #define TIM16_PSC (24 - 1)
- #define TIM16_ARR (1000 - 1)
- #define TIM17_PSC (24 - 1)
- #define TIM17_ARR (1000 - 1)
- /* Defines */
- #define BTN1_GPIO_Port GPIOB
- #define BTN1_Pin GPIO_PIN_2
- #define BTN2_GPIO_Port GPIOA
- #define BTN2_Pin GPIO_PIN_12
- #define BTN3_GPIO_Port GPIOB
- #define BTN3_Pin GPIO_PIN_4
- #define BTN4_GPIO_Port GPIOA
- #define BTN4_Pin GPIO_PIN_5
- #define IRQ_EXTI_IRQn EXTI4_15_IRQn
- #define IRQ_GPIO_Port GPIOC
- #define IRQ_Pin GPIO_PIN_14
- #define Latch_GPIO_Port GPIOC
- #define Latch_Pin GPIO_PIN_6
- #define LC0_GPIO_Port GPIOA
- #define LC0_Pin GPIO_PIN_0
- #define LC1_GPIO_Port GPIOA
- #define LC1_Pin GPIO_PIN_1
- #define LC2_GPIO_Port GPIOA
- #define LC2_Pin GPIO_PIN_2
- #define LC3_GPIO_Port GPIOA
- #define LC3_Pin GPIO_PIN_3
- #define PWM_1_GPIO_Port GPIOA
- #define PWM_1_Pin GPIO_PIN_8
- #define PWM_2_GPIO_Port GPIOB
- #define PWM_2_Pin GPIO_PIN_1
- #define PWM_3_GPIO_Port GPIOB
- #define PWM_3_Pin GPIO_PIN_0
- #define PWM_4_GPIO_Port GPIOA
- #define PWM_4_Pin GPIO_PIN_7
- #define PWM_5_GPIO_Port GPIOA
- #define PWM_5_Pin GPIO_PIN_6
- #define PWM_B_GPIO_Port GPIOA
- #define PWM_B_Pin GPIO_PIN_10
- #define PWM_G_GPIO_Port GPIOA
- #define PWM_G_Pin GPIO_PIN_11
- #define PWM_R_GPIO_Port GPIOA
- #define PWM_R_Pin GPIO_PIN_9
- #define SHDN_GPIO_Port GPIOA
- #define SHDN_Pin GPIO_PIN_4
- #define SWCLK_GPIO_Port GPIOA
- #define SWCLK_Pin GPIO_PIN_14
- #define SWDIO_GPIO_Port GPIOA
- #define SWDIO_Pin GPIO_PIN_13
- #define UART_EN_GPIO_Port GPIOC
- #define UART_EN_Pin GPIO_PIN_15
- #define UART_ST_GPIO_Port GPIOA
- #define UART_ST_Pin GPIO_PIN_15
- /* Variables */
- uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
- /* Expoted funcions */
- void SystemClock_Config(void);
- void Board_Init();
- void Blink_Start(void);
- void Blink_Stop(void);
- #endif
|