LPC_Vic.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef __LPC_VIC_H
  2. #define __LPC_VIC_H
  3. /*************************************************************************
  4. *
  5. * Used with ICCARM and AARM.
  6. *
  7. * (c) Copyright IAR Systems 2003
  8. *
  9. * File name : LPC_Vic.h
  10. * Description :
  11. *
  12. * History :
  13. * 1. Data: July 8th, 2004
  14. * Author: Wilson Liu
  15. * Description: Create the basic function
  16. *
  17. * 2. Data: August 4th, 2004
  18. * Author: Shawn Zhang
  19. * Description: Clean up the functions. Support nonvector interrupt at first.
  20. *
  21. * 3. Data : Oct 11, 2004
  22. * Author : Stanimir Bonev
  23. * Description : Modify some function and interface
  24. *
  25. * $Revision: 1.1 $
  26. **************************************************************************/
  27. #include <includes.h>
  28. #define IRQ_FLAG 0x80
  29. //#define INT_MAXNUM 32
  30. /* Interrupt Source */
  31. /*
  32. #define INT_WDT 0x1
  33. #define INT_TIMER0 0x10
  34. #define INT_TIMER1 0x20
  35. #define INT_UART0 0x40
  36. #define INT_UART1 0x80
  37. #define INT_PWM0 0x100
  38. #define INT_I2C 0x200
  39. #define INT_SPI0 0x400
  40. #define INT_SPI1 0x800
  41. #define INT_PLL 0x1000
  42. #define INT_RTC 0x2000
  43. #define INT_EINT0 0x4000
  44. #define INT_EINT1 0x8000
  45. #define INT_EINT2 0x10000
  46. #define INT_EINT3 0x20000
  47. #define INT_AD 0x40000
  48. */
  49. #define INT_ALL 0xFFFFFFFF
  50. // Interrupt protection type
  51. typedef enum {
  52. UserandPrivilegedMode=0,
  53. PrivilegedMode
  54. }LPC_Vic_ProtectionMode_t;
  55. typedef enum {
  56. VIC_Slot0 = 0, // high priority
  57. VIC_Slot1,VIC_Slot2,VIC_Slot3,VIC_Slot4,VIC_Slot5,VIC_Slot6,VIC_Slot7,VIC_Slot8,
  58. VIC_Slot9,VIC_Slot10,VIC_Slot11,VIC_Slot12,VIC_Slot13,VIC_Slot14,VIC_Slot15
  59. }LPC_VicIrqSlots_t;
  60. /* Declare API functions */
  61. void VIC_SetProtectionMode(LPC_Vic_ProtectionMode_t ProtectionType);
  62. LPC_Vic_ProtectionMode_t VIC_GetProtectionMode(void);
  63. void VIC_Init(void);
  64. void VIC_EnableInt(unsigned int IntType);
  65. void VIC_DisableInt(unsigned int IntType);
  66. unsigned int VIC_GetIRQStatus(void);
  67. unsigned int VIC_GetFIQStatus(void);
  68. void VIC_EnableNonVectoredIRQ(void(*pIRQSub)());
  69. void VIC_DisableNonVectoredIRQ(void);
  70. void VIC_SetVectoredIRQ(void(*pIRQSub)(), LPC_VicIrqSlots_t VicIrqSlot, unsigned int VicIntSouce);
  71. /*************************************************************************
  72. * Function Name: restore_IRQ
  73. * Parameters: unsigned long IFlag
  74. * Return: void
  75. * Description: Restore I flag state
  76. *
  77. *************************************************************************/
  78. #pragma inline
  79. __arm void restore_IRQ(unsigned long IFlag)
  80. {
  81. unsigned long tmp;
  82. tmp=__get_CPSR();
  83. __set_CPSR(tmp & (IFlag | ~IRQ_FLAG));
  84. }
  85. /*************************************************************************
  86. * Function Name: disable_IRQ
  87. * Parameters:
  88. * Return: unsigned long
  89. * Description: Disable IRQ and return previous state state of flgas I
  90. *
  91. *************************************************************************/
  92. #pragma inline
  93. __arm unsigned long disable_IRQ(void)
  94. {
  95. unsigned long tmp;
  96. tmp=__get_CPSR();
  97. __set_CPSR(tmp | IRQ_FLAG);
  98. return tmp & IRQ_FLAG;
  99. }
  100. #endif // __LPC_VIC_H