board.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #ifndef _BOARD_H
  3. #define _BOARD_H
  4. /* Includes */
  5. #include "main.h"
  6. #include "gpio.h"
  7. /* Type Defs */
  8. /* Exported macros */
  9. /* Constants */
  10. #define USE_SERVO_1 true
  11. #define USE_SERVO_2 true
  12. /* PWM Timers for 50 Hz */
  13. #define TIM1_PSC (24 - 1)
  14. #define TIM1_ARR (20000 - 1)
  15. #define SERVO_INIT_VAL 0
  16. #define SERVO1_OPEN_VAL 1000
  17. #define SERVO2_OPEN_VAL 2000
  18. #define TIM3_PSC (24000 - 1)
  19. #define TIM3_ARR (100 - 1)
  20. /* Defines */
  21. #define Select_Pin GPIO_PIN_3
  22. #define Select_Port GPIOA
  23. #define Photo_Pin GPIO_PIN_7
  24. #define Photo_Port GPIOB
  25. #ifdef USE_SERVO_1
  26. #define Servo_1_Pin GPIO_PIN_3
  27. #define Servo_1_Port GPIOB
  28. #define Servo_1_CHNL TIM1->CCR2
  29. // #define Servo_1_ON TIM1->CCER |= (TIM_CCER_CC2E | TIM_CCER_CC2P)
  30. // #define Servo_1_OFF TIM1->CCER &= ~(TIM_CCER_CC2E | TIM_CCER_CC2P)
  31. #endif
  32. #ifdef USE_SERVO_2
  33. #define Servo_2_Pin GPIO_PIN_8
  34. #define Servo_2_Port GPIOA
  35. #define Servo_2_CHNL TIM1->CCR1
  36. // #define Servo_2_ON TIM1->CCER |= (TIM_CCER_CC1E | TIM_CCER_CC1P)
  37. // #define Servo_2_OFF TIM1->CCER &= ~(TIM_CCER_CC1E | TIM_CCER_CC1P)
  38. #endif
  39. #define Servo_1_ON
  40. #define Servo_1_OFF
  41. #define Servo_2_ON
  42. #define Servo_2_OFF
  43. /* Variables */
  44. /* Exported funcions */
  45. void SystemClock_Config(void);
  46. void Board_Init(void);
  47. void delay_ms(uint32_t msek);
  48. void SysTick_Handler(void);
  49. #endif /* _BPARD_H */