bsp_hal.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef __PLAT_HAL_H_
  2. #define __PLAT_HAL_H_
  3. #include "inttypes.h"
  4. /********************************
  5. * INTC HAL DEFINE
  6. ********************************/
  7. #define IRQ_EDGE_TRIGGER 1
  8. #define IRQ_LEVEL_TRIGGER 0
  9. #define IRQ_ACTIVE_HIGH 1
  10. #define IRQ_ACTIVE_LOW 0
  11. void hal_intc_init();
  12. void hal_intc_swi_enable();
  13. void hal_intc_swi_disable();
  14. void hal_intc_swi_clean();
  15. void hal_intc_swi_trigger();
  16. /* Call by HISR.
  17. * Since our mask/unmask are not atomic.
  18. * And HISR is task level ISR in RTOS, we need make sure it is atomic.
  19. *
  20. * TODO remove gie if atomic
  21. */
  22. #define HAL_INTC_IRQ_ATOMIC_DISABLE(_irq_) \
  23. do \
  24. { \
  25. unsigned long _gie_; \
  26. GIE_SAVE(&_gie_); \
  27. hal_intc_irq_disable(_irq_); \
  28. GIE_RESTORE(_gie_); \
  29. } while(0)
  30. #define HAL_INTC_IRQ_ATOMIC_ENABLE(_irq_) \
  31. do \
  32. { \
  33. unsigned long _gie_; \
  34. GIE_SAVE(&_gie_); \
  35. hal_intc_irq_enable(_irq_); \
  36. GIE_RESTORE(_gie_); \
  37. } while(0)
  38. uint32_t hal_intc_irq_mask(int _irqs_);
  39. void hal_intc_irq_unmask(int _irqs_);
  40. void hal_intc_irq_clean(int _irqs_);
  41. void hal_intc_irq_clean_all();
  42. void hal_intc_irq_enable(uint32_t _irqs_);
  43. void hal_intc_irq_disable(uint32_t _irqs_);
  44. void hal_intc_irq_disable_all();
  45. void hal_intc_irq_set_priority(uint32_t _prio_ );
  46. void hal_intc_irq_config(uint32_t _irqs_, uint32_t _edge_, uint32_t _falling_);
  47. uint32_t hal_intc_get_all_pend();
  48. /********************************
  49. * TIMER HAL DEFINE
  50. ********************************/
  51. uint32_t hal_timer_irq_mask(uint32_t _tmr_ );
  52. void hal_timer_irq_unmask(uint32_t _msk_ );
  53. void hal_timer_irq_clear(uint32_t _tmr_ );
  54. void hal_timer_start(uint32_t _tmr_);
  55. void hal_timer_stop(uint32_t _tmr_ );
  56. uint32_t hal_timer_read(uint32_t _tmr_ );
  57. void hal_timer_set_period(uint32_t _tmr_, uint32_t _period_ );
  58. void hal_timer_set_upward(uint32_t _tmr_ ,uint32_t up);
  59. void hal_timer_init(uint32_t _tmr_ );
  60. void hal_timer_irq_control(uint32_t _tmr_, uint32_t enable );
  61. uint32_t hal_timer_irq_status(uint32_t _tmr_);
  62. void hal_timer_set_match1(uint32_t _tmr_ , uint32_t match );
  63. uint32_t hal_timer_count_read(uint32_t _tmr_);
  64. #endif