board.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #ifndef _BOARD_H_
  14. #define _BOARD_H_
  15. /*
  16. * Setup for STMicroelectronics STM8L-Discovery board.
  17. */
  18. /*
  19. * Board identifiers.
  20. */
  21. #define BOARD_ST_STM8L_DISCOVERY
  22. #define BOARD_NAME "ST STM8L-Discovery"
  23. /*
  24. * Board frequencies and bypass modes.
  25. *
  26. * The bypass must be set to TRUE if the chip is driven by an external
  27. * oscillator rather than a crystal. Frequency must be set to zero if
  28. * the clock source is not used at all.
  29. * The following constants are used by the HAL low level driver for
  30. * correct clock initialization.
  31. */
  32. #define HSECLK 0
  33. #define HSEBYPASS FALSE
  34. #define LSECLK 32768
  35. #define LSEBYPASS FALSE
  36. /*
  37. * MCU model used on the board.
  38. */
  39. #define STM8L152C6
  40. #define STM8L15X_MD
  41. /*
  42. * Pin definitions.
  43. */
  44. #define PA_OSC_IN 2
  45. #define PA_OSC_OUT 3
  46. #define PA_LCD_COM0 4
  47. #define PA_LCD_COM1 5
  48. #define PA_LCD_COM2 6
  49. #define PA_LCD_SEG0 7
  50. #define PB_LCD_SEG10 0
  51. #define PB_LCD_SEG11 1
  52. #define PB_LCD_SEG12 2
  53. #define PB_LCD_SEG13 3
  54. #define PB_LCD_SEG14 4
  55. #define PB_LCD_SEG15 5
  56. #define PB_LCD_SEG16 6
  57. #define PB_LCD_SEG17 7
  58. #define PC_UNUSED 0
  59. #define PC_BUTTON 1
  60. #define PC_LCD_SEG22 2
  61. #define PC_LCD_SEG23 3
  62. #define PC_IDD_CNT_EN 4
  63. #define PC_LED4 7
  64. #define PD_LCD_SEG7 0
  65. #define PD_LCD_COM3 1
  66. #define PD_LCD_SEG8 2
  67. #define PD_LCD_SEG9 3
  68. #define PD_LCD_SEG18 4
  69. #define PD_LCD_SEG19 5
  70. #define PD_LCD_SEG20 6
  71. #define PD_LCD_SEG21 7
  72. #define PE_LCD_SEG1 0
  73. #define PE_LCD_SEG2 1
  74. #define PE_LCD_SEG3 2
  75. #define PE_LCD_SEG4 3
  76. #define PE_LCD_SEG5 4
  77. #define PE_LCD_SEG6 5
  78. #define PE_IDD_WAKEUP 6
  79. #define PE_LED3 7
  80. #define PF0_IDD_MEASUREMENT 0
  81. /*
  82. * Port A initial setup.
  83. */
  84. #define VAL_GPIOAODR 0
  85. #define VAL_GPIOADDR 0 /* All inputs. */
  86. #define VAL_GPIOACR1 0xFF /* All pull-up/push-pull. */
  87. #define VAL_GPIOACR2 0
  88. /*
  89. * Port B initial setup.
  90. */
  91. #define VAL_GPIOBODR 0
  92. #define VAL_GPIOBDDR 0 /* All inputs. */
  93. #define VAL_GPIOBCR1 0xFF /* All pull-up/push-pull. */
  94. #define VAL_GPIOBCR2 0
  95. /*
  96. * Port C initial setup.
  97. */
  98. #define VAL_GPIOCODR 0
  99. #define VAL_GPIOCDDR (1 << PC_LED4)
  100. #define VAL_GPIOCCR1 0xFF /* All pull-up/push-pull. */
  101. #define VAL_GPIOCCR2 0
  102. /*
  103. * Port D initial setup.
  104. */
  105. #define VAL_GPIODODR 0
  106. #define VAL_GPIODDDR 0 /* All inputs. */
  107. #define VAL_GPIODCR1 0xFF /* All pull-up/push-pull. */
  108. #define VAL_GPIODCR2 0
  109. /*
  110. * Port E initial setup.
  111. */
  112. #define VAL_GPIOEODR 0
  113. #define VAL_GPIOEDDR (1 << PE_LED3)
  114. #define VAL_GPIOECR1 0xFF /* All pull-up/push-pull. */
  115. #define VAL_GPIOECR2 0
  116. /*
  117. * Port F initial setup.
  118. */
  119. #define VAL_GPIOFODR 0
  120. #define VAL_GPIOFDDR 0 /* All inputs. */
  121. #define VAL_GPIOFCR1 0xFF /* All pull-up/push-pull. */
  122. #define VAL_GPIOFCR2 0
  123. /*
  124. * TIM2-update ISR segment code. This code is injected into the appropriate
  125. * ISR by the HAL.
  126. */
  127. #define _TIM2_UPDATE_ISR() { \
  128. if (TIM2->SR1 & TIM_SR1_UIF) { \
  129. chSysLockFromIsr(); \
  130. chSysTimerHandlerI(); \
  131. chSysUnlockFromIsr(); \
  132. TIM2->SR1 = 0; \
  133. } \
  134. }
  135. #if !defined(_FROM_ASM_)
  136. #ifdef __cplusplus
  137. extern "C" {
  138. #endif
  139. void boardInit(void);
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* _FROM_ASM_ */
  144. #endif /* _BOARD_H_ */