event.h 2.3 KB

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