board.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include "hal.h"
  14. /**
  15. * @brief PAL setup.
  16. * @details Digital I/O ports static configuration as defined in @p board.h.
  17. * This variable is used by the HAL when initializing the PAL driver.
  18. */
  19. #if HAL_USE_PAL || defined(__DOXYGEN__)
  20. const PALConfig pal_default_config =
  21. {
  22. #if defined(__MSP430_HAS_PORT1__) || defined(__MSP430_HAS_PORT1_R__)
  23. {VAL_P1OUT, VAL_P1DIR},
  24. #endif
  25. #if defined(__MSP430_HAS_PORT2__) || defined(__MSP430_HAS_PORT2_R__)
  26. {VAL_P2OUT, VAL_P2DIR},
  27. #endif
  28. #if defined(__MSP430_HAS_PORT3__) || defined(__MSP430_HAS_PORT3_R__)
  29. {VAL_P3OUT, VAL_P3DIR},
  30. #endif
  31. #if defined(__MSP430_HAS_PORT4__) || defined(__MSP430_HAS_PORT4_R__)
  32. {VAL_P4OUT, VAL_P4DIR},
  33. #endif
  34. #if defined(__MSP430_HAS_PORT5__) || defined(__MSP430_HAS_PORT5_R__)
  35. {VAL_P5OUT, VAL_P5DIR},
  36. #endif
  37. #if defined(__MSP430_HAS_PORT6__) || defined(__MSP430_HAS_PORT6_R__)
  38. {VAL_P6OUT, VAL_P6DIR},
  39. #endif
  40. };
  41. #endif
  42. CH_IRQ_HANDLER(TIMERA0) {
  43. CH_IRQ_PROLOGUE();
  44. chSysLockFromIsr();
  45. chSysTimerHandlerI();
  46. chSysUnlockFromIsr();
  47. CH_IRQ_EPILOGUE();
  48. }
  49. /*
  50. * Board-specific initialization code.
  51. */
  52. void boardInit(void) {
  53. #if USE_MSP430_USART0
  54. P3SEL |= (1 << 4) | (1 << 5);
  55. #endif
  56. #if USE_MSP430_USART1
  57. P3SEL |= (1 << 6) | (1 << 7);
  58. #endif
  59. /*
  60. * Timer 0 setup, uses SMCLK as source.
  61. */
  62. TACCR0 = SMCLK / 4 / CH_FREQUENCY - 1;/* Counter limit. */
  63. TACTL = TACLR; /* Clean start. */
  64. TACTL = TASSEL_2 | ID_2 | MC_1; /* Src=SMCLK, ID=4, cmp=TACCR0. */
  65. TACCTL0 = CCIE; /* Interrupt on compare. */
  66. }