board.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __BOARD_H
  2. #define __BOARD_H
  3. /* MACROs for SET, RESET or TOGGLE Output port */
  4. #define GPIO_HIGH(a,b) a->ODR |= b
  5. #define GPIO_LOW(a,b) a->ODR &= ~b
  6. #define GPIO_TOGGLE(a,b) a->ODR ^= b
  7. /* LED
  8. AAA
  9. F B
  10. F B
  11. GGG
  12. E C
  13. E C
  14. DDD P
  15. */
  16. #define LED_SEG1_PORT GPIOA
  17. #define LED_SEG1_PINS GPIO_PIN_3
  18. #define LED_SEG_DP GPIO_PIN_3
  19. #define LED_SEG3_PORT GPIOC
  20. #define LED_SEG3_PINS (GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_3 | GPIO_PIN_5)
  21. #define LED_SEG_A GPIO_PIN_3
  22. #define LED_SEG_F GPIO_PIN_4
  23. #define LED_SEG_B GPIO_PIN_5
  24. #define LED_SEG_E GPIO_PIN_6
  25. #define LED_SEG_G GPIO_PIN_7
  26. #define LED_SEG2_PORT GPIOD
  27. #define LED_SEG2_PINS (GPIO_PIN_1 | GPIO_PIN_4)
  28. #define LED_SEG_C GPIO_PIN_1
  29. #define LED_SEG_D GPIO_PIN_4
  30. #define LED_OUT_OFF {LED_SEG1_PORT->ODR |= LED_SEG1_PINS; LED_SEG2_PORT->ODR |= LED_SEG2_PINS; LED_SEG3_PORT->ODR |= LED_SEG3_PINS;}
  31. #define LED_OUT_DP GPIOA->ODR &= ~LED_SEG_DP
  32. #define LED_OUT_MM GPIOC->ODR &= ~LED_SEG_G
  33. #define LED_OUT_0 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_F); GPIOD->ODR &= ~(LED_SEG2_PINS)
  34. #define LED_OUT_1 GPIOC->ODR &= ~(LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C)
  35. #define LED_OUT_2 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_E|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_D)
  36. #define LED_OUT_3 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  37. #define LED_OUT_4 GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
  38. #define LED_OUT_5 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  39. #define LED_OUT_6 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  40. #define LED_OUT_7 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B); GPIOD->ODR &= ~(LED_SEG_C)
  41. #define LED_OUT_8 GPIOC->ODR &= ~(LED_SEG3_PINS); GPIOD->ODR &= ~(LED_SEG2_PINS)
  42. #define LED_OUT_9 GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
  43. /* shift register control pins */
  44. #define SPI_PORT GPIOA
  45. #define SPI_SCK GPIO_PIN_1
  46. #define SPI_DATA GPIO_PIN_2
  47. /* ADC */
  48. #define ADC_PORT GPIOD
  49. #define ADC_PINU GPIO_PIN_2
  50. #define ADC_CHNLU ADC1_CHANNEL_3
  51. #define ADC_SCHTU ADC1_SCHMITTTRIG_CHANNEL3
  52. #define ADC_PINI GPIO_PIN_3
  53. #define ADC_CHNLI ADC1_CHANNEL_4
  54. #define ADC_SCHTI ADC1_SCHMITTTRIG_CHANNEL4
  55. #define ADC_SMPLS 64
  56. // Supply voltage in mili volts
  57. #define ADC_VREF 3335
  58. // Сопротивление резисторов ОУ усилителя сигнала шунта
  59. #define CURRENT_MULT_TOP 3600
  60. #define CURRENT_MULT_BOT 680
  61. // shunt resistance in mili Ohms
  62. #define ADC_SHUNT 50
  63. #endif /* __BOARD_H */