vic.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /**
  14. * @file LPC214x/vic.c
  15. * @brief LPC214x VIC peripheral support code.
  16. *
  17. * @addtogroup LPC214x_VIC
  18. * @{
  19. */
  20. #include "hal.h"
  21. /**
  22. * @brief VIC Initialization.
  23. * @note Better reset everything in the VIC, it is a HUGE source of trouble.
  24. *
  25. * @notapi
  26. */
  27. void vic_init(void) {
  28. int i;
  29. VIC *vic = VICBase;
  30. vic->VIC_IntSelect = 0; /* All sources assigned to IRQ. */
  31. vic->VIC_SoftIntClear = ALLINTMASK; /* No interrupts enforced */
  32. vic->VIC_IntEnClear = ALLINTMASK; /* All sources disabled. */
  33. for (i = 0; i < 16; i++) {
  34. vic->VIC_VectCntls[i] = 0;
  35. vic->VIC_VectAddrs[i] = 0;
  36. vic->VIC_VectAddr = 0;
  37. }
  38. }
  39. /**
  40. * @brief Initializes a VIC vector.
  41. * @details Set a vector for an interrupt source and enables it.
  42. *
  43. * @param[in] handler the pointer to the IRQ service routine
  44. * @param[in] vector the vector number
  45. * @param[in] source the IRQ source to be associated to the vector
  46. *
  47. * @api
  48. */
  49. void SetVICVector(void *handler, int vector, int source) {
  50. VIC *vicp = VICBase;
  51. vicp->VIC_VectAddrs[vector] = (IOREG32)handler;
  52. vicp->VIC_VectCntls[vector] = (IOREG32)(source | 0x20);
  53. }
  54. /** @} */