// // Created by macheng on 2018/5/2. // #ifndef _INSTANCE_EVENT_H #define _INSTANCE_EVENT_H #include "deca_types.h" #include "message.h" //size of the event queue, in this application there should be at most 2 unprocessed events, //i.e. if there is a transmission with wait for response then the TX callback followed by RX callback could be executed //in turn and the event queued up before the instance processed the TX event. #define MAX_EVENT_NUMBER (128) typedef struct { uint8_t type; // event type - if 0 there is no event in the queue uint8_t typeSave; // holds the event type - does not clear (used to show what event has been processed) uint8_t typePend; // set if there is a pending event uint16_t rxLength ; // length of RX data (does not apply to TX events) uint64_t timeStamp ; // last timestamp (Tx or Rx) - 40 bit DW1000 time uint32_t timeStamp32l ; // last tx/rx timestamp - low 32 bits of the 40 bit DW1000 time uint32_t timeStamp32h ; // last tx/rx timestamp - high 32 bits of the 40 bit DW1000 time uint32_t uTimeStamp ; //32 bit system counter (ms) - STM32 tick time (at time of IRQ) union { //holds received frame (after a good RX frame event) uint8_t frame[STANDARD_FRAME_SIZE]; srd_msg_dlsl rxMsg_ll ; //64 bit addresses srd_msg_dssl rxMsg_sl ; srd_msg_dlss rxMsg_ls ; srd_msg_dsss rxMsg_ss ; //16 bit addresses }msgUnion; //uint32_t eventtime ; //uint32_t eventtimeclr ; uint8_t gotIt; //stores the instance function which processed the event (used for debug) }event_data_t ; extern event_data_t dw_event_g; typedef struct { event_data_t stEvents[MAX_EVENT_NUMBER]; //this holds any TX/RX events and associated message data event_data_t stSavedEvent; //holds an RX event while the ACK is being sent uint8_t dwEvtIdxOut; uint8_t dwEvtIdxIn; uint8_t dwEvtPeek; }event_queue; int peekEvent(const event_queue* evtQueue); void saveEvent(event_queue* evtQueue, event_data_t newEvent, uint8_t eType); event_data_t getSavedEvent(event_queue* evtQueue); void putEvent(event_queue* evtQueue, event_data_t newEvent, uint8_t eType); event_data_t* getEvent(event_queue* evtQueue, int x); void clearEvents(event_queue* evtQueue); #endif //HSS200ANC1701_REFACTOR_EVENT_H