rbuf_msg_sc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*******************************************************************************
  2. * @file rbuf_msg_sc.h
  3. * @author MEMS Application Team
  4. * @version V1.0
  5. * @date 2020-10-15
  6. * @brief message for sensorhub
  7. *******************************************************************************/
  8. #ifndef _RBUF_MSG_SC_H
  9. #define _RBUF_MSG_SC_H
  10. /******************************************************************************/
  11. //includes
  12. /******************************************************************************/
  13. #include <rbuf/rbuf_msg.h>
  14. #include <drivers/i2cmt.h>
  15. #include <drivers/spimt.h>
  16. /******************************************************************************/
  17. //message define
  18. /******************************************************************************/
  19. typedef enum sc_msg {
  20. MSG_SC_START = MSG_SC_BASE,
  21. // sc init msg
  22. MSG_SC_INIT, // ACK=[major+minor]
  23. // log init
  24. MSG_SC_LOG_ON, // REQ=[size], ACK=[rbuf]
  25. MSG_SC_LOG_OFF, // REQ=[rbuf], ACK=[ret]
  26. // spi normal msg
  27. MSG_SC_SPI_NML, // REQ=[id+op+buf+len], ACK=[id+ret]
  28. // i2c normal msg
  29. MSG_SC_I2C_NML, // REQ=[id+op+i2c_xfer], ACK=[id+ret]
  30. // spi task msg
  31. MSG_SC_SPI_TASK_START, // REQ=[id+task_id+attr], ACK=[id+task_id+irq]
  32. MSG_SC_SPI_TASK_STOP, // REQ=[id+task_id]
  33. // i2c task msg
  34. MSG_SC_I2C_TASK_START, // REQ=[id+task_id+attr], ACK=[id+task_id+irq]
  35. MSG_SC_I2C_TASK_STOP, // REQ=[id+task_id]
  36. MSG_SC_END,
  37. } sc_msg_e;
  38. /******************************************************************************/
  39. //constants
  40. /******************************************************************************/
  41. /* MAIN <--> SENSOR Address Mapping */
  42. #define MAP_SC_FR_CPU(x) ((unsigned int)(x) - INTER_RAM_ADDR + 0x00188000)
  43. #define MAP_SC_TO_CPU(x) ((unsigned int)(x) - 0x00188000 + INTER_RAM_ADDR)
  44. /******************************************************************************/
  45. //typedef
  46. /******************************************************************************/
  47. /* Message data for sensorhub */
  48. typedef struct sc_spi_msg {
  49. unsigned short type; // Message type
  50. unsigned short flag; // Message flag
  51. unsigned short id; // Bus id
  52. unsigned short op; // (0-wr,1-rd,2-cs)
  53. unsigned char* buf; // Data buffer
  54. unsigned short len; // Data length
  55. } sc_spi_msg_t;
  56. typedef struct sc_i2c_msg {
  57. unsigned short type; // Message type
  58. unsigned short flag; // Message flag
  59. unsigned short id; // Bus id
  60. unsigned short op; // (0-wr,1-rd,2-probe)
  61. i2c_xfer_t xfer; // I2C transfer
  62. } sc_i2c_msg_t;
  63. typedef struct sc_spi_task_msg {
  64. unsigned short type; // Message type
  65. unsigned short flag; // Message flag
  66. unsigned short id; // Bus id
  67. unsigned short task_id; // Task id
  68. spi_task_t task_attr; // Task attribute
  69. } sc_spi_task_msg_t;
  70. typedef struct sc_i2c_task_msg {
  71. unsigned short type; // Message type
  72. unsigned short flag; // Message flag
  73. unsigned short id; // Bus id
  74. unsigned short task_id; // Task id
  75. i2c_task_t task_attr; // Task attribute
  76. } sc_i2c_task_msg_t;
  77. typedef struct sc_task_irq_msg {
  78. unsigned short type; // Message type
  79. unsigned short flag; // Message flag
  80. unsigned short id; // Bus id
  81. unsigned short task_id; // Task id
  82. unsigned short irq_type; // Irq type
  83. } sc_task_irq_msg_t;
  84. /******************************************************************************/
  85. //macros
  86. /******************************************************************************/
  87. /******************************************************************************/
  88. //functions
  89. /******************************************************************************/
  90. #endif /* _RBUF_MSG_SC_H */