1 #ifndef _BFLB_IRQ_H 2 #define _BFLB_IRQ_H 3 4 #include "stdint.h" 5 6 /** @addtogroup LHAL 7 * @{ 8 */ 9 10 /** @addtogroup IRQ 11 * @{ 12 */ 13 14 typedef void (*irq_callback)(int irq, void *arg); 15 16 /** 17 * @brief IRQ configuration structure 18 * 19 * @param handler Address of the interrupt handler 20 * @param arg The argument provided to the interrupt handler 21 */ 22 struct bflb_irq_info_s { 23 irq_callback handler; 24 void *arg; 25 }; 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /** 32 * @brief Interrupt initialize. 33 * 34 */ 35 void bflb_irq_initialize(void); 36 37 /** 38 * @brief Disable global irq and save the previous status. 39 * 40 * @return last status 41 */ 42 uintptr_t bflb_irq_save(void); 43 44 /** 45 * @brief Enable global irq by the previous status. 46 * 47 * @param [in] flags previous status by bflb_irq_save 48 */ 49 void bflb_irq_restore(uintptr_t flags); 50 51 /** 52 * @brief Attach interrupt with callback. 53 * 54 * @param [in] irq irq number 55 * @param [in] isr interrupt callback 56 * @param [in] arg user data 57 * @return A negated errno value on failure. 58 */ 59 int bflb_irq_attach(int irq, irq_callback isr, void *arg); 60 61 /** 62 * @brief Detach interrupt, reset interrupt callback. 63 * 64 * @param [in] irq irq number 65 * @return A negated errno value on failure. 66 */ 67 int bflb_irq_detach(int irq); 68 69 /** 70 * @brief Enable interrupt. 71 * 72 * @param [in] irq irq number 73 */ 74 void bflb_irq_enable(int irq); 75 76 /** 77 * @brief Disable interrupt. 78 * 79 * @param [in] irq irq number 80 */ 81 void bflb_irq_disable(int irq); 82 83 /** 84 * @brief Set interrupt with pending. 85 * 86 * @param [in] irq irq number 87 */ 88 void bflb_irq_set_pending(int irq); 89 90 /** 91 * @brief Clear interrupt pending status. 92 * 93 * @param [in] irq irq number 94 */ 95 void bflb_irq_clear_pending(int irq); 96 97 /** 98 * @brief Set interrupt group. 99 * 100 * @param [in] nlbits 101 */ 102 void bflb_irq_set_nlbits(uint8_t nlbits); 103 104 /** 105 * @brief Set interrupt priority. 106 * 107 * @param [in] irq irq number 108 * @param [in] preemptprio preempt priority 109 * @param [in] subprio sub priority 110 */ 111 void bflb_irq_set_priority(int irq, uint8_t preemptprio, uint8_t subprio); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 /** 118 * @} 119 */ 120 121 /** 122 * @} 123 */ 124 125 #endif