You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
6.5 KiB

1 year ago
1 year ago
1 year ago
  1. //----------------------------------------------------------------------------
  2. // Description: This file contains definitions specific to the ADS1293.
  3. // All the ADS1293 registers are defined as well as some common masks
  4. // for these registers.
  5. //
  6. // MSP430/ADS1293 Interface Code Library v1.0
  7. //
  8. // Vishy Natarajan
  9. // Texas Instruments Inc.
  10. // April 2013
  11. // Built with IAR Embedded Workbench Version: 5.5x
  12. //------------------------------------------------------------------------------
  13. // Change Log:
  14. //------------------------------------------------------------------------------
  15. // Version: 1.00
  16. // Comments: Initial Release Version
  17. //------------------------------------------------------------------------------
  18. #ifndef HEADER_FILE_TI_ADS1293_H
  19. #define HEADER_FILE_TI_ADS1293_H
  20. #include <stdint.h>
  21. /************************************************************
  22. * TI ADS1293 REGISTER SET ADDRESSES
  23. ************************************************************/
  24. #define TI_ADS1293_CONFIG_REG (0x00) /* Main Configuration */
  25. #define TI_ADS1293_FLEX_CH1_CN_REG (0x01) /* Flex Routing Swich Control for Channel 1 */
  26. #define TI_ADS1293_FLEX_CH2_CN_REG (0x02) /* Flex Routing Swich Control for Channel 2 */
  27. #define TI_ADS1293_FLEX_CH3_CN_REG (0x03) /* Flex Routing Swich Control for Channel 3 */
  28. #define TI_ADS1293_FLEX_PACE_CN_REG (0x04) /* Flex Routing Swich Control for Pace Channel */
  29. #define TI_ADS1293_FLEX_VBAT_CN_REG (0x05) /* Flex Routing Swich Control for Battery Monitoriing */
  30. #define TI_ADS1293_LOD_CN_REG (0x06) /* Lead Off Detect Control */
  31. #define TI_ADS1293_LOD_EN_REG (0x07) /* Lead Off Detect Enable */
  32. #define TI_ADS1293_LOD_CURRENT_REG (0x08) /* Lead Off Detect Current */
  33. #define TI_ADS1293_LOD_AC_CN_REG (0x09) /* AC Lead Off Detect Current */
  34. #define TI_ADS1293_CMDET_EN_REG (0x0A) /* Common Mode Detect Enable */
  35. #define TI_ADS1293_CMDET_CN_REG (0x0B) /* Commond Mode Detect Control */
  36. #define TI_ADS1293_RLD_CN_REG (0x0C) /* Right Leg Drive Control */
  37. #define TI_ADS1293_WILSON_EN1_REG (0x0D) /* Wilson Reference Input one Selection */
  38. #define TI_ADS1293_WILSON_EN2_REG (0x0E) /* Wilson Reference Input two Selection */
  39. #define TI_ADS1293_WILSON_EN3_REG (0x0F) /* Wilson Reference Input three Selection */
  40. #define TI_ADS1293_WILSON_CN_REG (0x10) /* Wilson Reference Input Control */
  41. #define TI_ADS1293_REF_CN_REG (0x11) /* Internal Reference Voltage Control */
  42. #define TI_ADS1293_OSC_CN_REG (0x12) /* Clock Source and Output Clock Control */
  43. #define TI_ADS1293_AFE_RES_REG (0x13) /* Analog Front-End Frequency and Resolution */
  44. #define TI_ADS1293_AFE_SHDN_CN_REG (0x14) /* Analog Front-End Shutdown Control */
  45. #define TI_ADS1293_AFE_FAULT_CN_REG (0x15) /* Analog Front-End Fault Detection Control */
  46. #define TI_ADS1293_AFE_DITHER_EN_REG (0x16) /* Enable Dithering in Signma-Delta */
  47. #define TI_ADS1293_AFE_PACE_CN_REG (0x17) /* Analog Pace Channel Output Routing Control */
  48. #define TI_ADS1293_ERROR_LOD_REG (0x18) /* Lead Off Detect Error Status */
  49. #define TI_ADS1293_ERROR_STATUS_REG (0x19) /* Other Error Status */
  50. #define TI_ADS1293_ERROR_RANGE1_REG (0x1A) /* Channel 1 Amplifier Out of Range Status */
  51. #define TI_ADS1293_ERROR_RANGE2_REG (0x1B) /* Channel 1 Amplifier Out of Range Status */
  52. #define TI_ADS1293_ERROR_RANGE3_REG (0x1C) /* Channel 1 Amplifier Out of Range Status */
  53. #define TI_ADS1293_ERROR_SYNC_REG (0x1D) /* Synchronization Error */
  54. #define TI_ADS1293_R2_RATE_REG (0x21) /* R2 Decimation Rate */
  55. #define TI_ADS1293_R3_RATE1_REG (0x22) /* R3 Decimation Rate for Channel 1 */
  56. #define TI_ADS1293_R3_RATE2_REG (0x23) /* R3 Decimation Rate for Channel 2 */
  57. #define TI_ADS1293_R3_RATE3_REG (0x24) /* R3 Decimation Rate for Channel 3 */
  58. #define TI_ADS1293_P_DRATE_REG (0x25) /* 2x Pace Data Rate */
  59. #define TI_ADS1293_DIS_EFILTER_REG (0x26) /* ECG Filter Disable */
  60. #define TI_ADS1293_DRDYB_SRC_REG (0x27) /* Data Ready Pin Source */
  61. #define TI_ADS1293_SYNCOUTB_SRC_REG (0x28) /* Sync Out Pin Source */
  62. #define TI_ADS1293_MASK_DRDYB_REG (0x29) /* Optional Mask Control for DRDYB Output */
  63. #define TI_ADS1293_MASK_ERR_REG (0x2A) /* Mask Error on ALARMB Pin */
  64. #define TI_ADS1293_ALARM_FILTER_REG (0x2E) /* Digital Filter for Analog Alarm Signals */
  65. #define TI_ADS1293_CH_CNFG_REG (0x2F) /* Configure Channel for Loop Read Back Mode */
  66. #define TI_ADS1293_DATA_STATUS_REG (0x30) /* ECG and Pace Data Ready Status */
  67. #define TI_ADS1293_DATA_CH1_PACE_H_REG (0x31) /* Channel1 Pace Data High [15:8] */
  68. #define TI_ADS1293_DATA_CH1_PACE_L_REG (0x32) /* Channel1 Pace Data Low [7:0] */
  69. #define TI_ADS1293_DATA_CH2_PACE_H_REG (0x33) /* Channel2 Pace Data High [15:8] */
  70. #define TI_ADS1293_DATA_CH2_PACE_L_REG (0x34) /* Channel2 Pace Data Low [7:0] */
  71. #define TI_ADS1293_DATA_CH3_PACE_H_REG (0x35) /* Channel3 Pace Data High [15:8] */
  72. #define TI_ADS1293_DATA_CH3_PACE_L_REG (0x36) /* Channel3 Pace Data Low [7:0] */
  73. #define TI_ADS1293_DATA_CH1_ECG_H_REG (0x37) /* Channel1 ECG Data High [23:16] */
  74. #define TI_ADS1293_DATA_CH1_ECG_M_REG (0x38) /* Channel1 ECG Data Medium [15:8] */
  75. #define TI_ADS1293_DATA_CH1_ECG_L_REG (0x39) /* Channel1 ECG Data Low [7:0] */
  76. #define TI_ADS1293_DATA_CH2_ECG_H_REG (0x3A) /* Channel2 ECG Data High [23:16] */
  77. #define TI_ADS1293_DATA_CH2_ECG_M_REG (0x3B) /* Channel2 ECG Data Medium [15:8] */
  78. #define TI_ADS1293_DATA_CH2_ECG_L_REG (0x3C) /* Channel2 ECG Data Low [7:0] */
  79. #define TI_ADS1293_DATA_CH3_ECG_H_REG (0x3D) /* Channel3 ECG Data High [23:16] */
  80. #define TI_ADS1293_DATA_CH3_ECG_M_REG (0x3E) /* Channel3 ECG Data Medium [15:8] */
  81. #define TI_ADS1293_DATA_CH3_ECG_L_REG (0x3F) /* Channel3 ECG Data Low [7:0] */
  82. #define TI_ADS1293_REVID_REG (0x40) /* Revision ID */
  83. #define TI_ADS1293_DATA_LOOP_REG (0x50) /* Loop Read Back Address */
  84. // Useful definitions
  85. #define ADS1293_READ_BIT (0x80)
  86. #define ADS1293_WRITE_BIT (0x7F)
  87. typedef void (*ads1293_spi_tx_rx_t)(uint8_t* tx, uint8_t* rx, uint8_t len);
  88. typedef struct {
  89. ads1293_spi_tx_rx_t spi_tx_rx;
  90. } ads1293_t;
  91. void ads1293_spi_init(ads1293_t* ads, ads1293_spi_tx_rx_t spi_tx_rx);
  92. void ads1293_spi_writereg(ads1293_t* ads, uint8_t addr, uint8_t data);
  93. uint8_t ads1293_spi_readreg(ads1293_t* ads, uint8_t addr);
  94. void ads1293_spi_autoinc_writereg(ads1293_t* ads, uint8_t addr, uint8_t* data, uint8_t len);
  95. void ads1293_spi_autoinc_readreg(ads1293_t* ads, uint8_t addr, uint8_t* data, uint8_t len);
  96. void ads1293_spi_stream_readreg(ads1293_t* ads, uint8_t* data, uint8_t len);
  97. void ads1293_read_ecg(ads1293_t* ads, uint32_t ch, uint32_t* data);
  98. uint8_t ads1293_read_error_lod(ads1293_t* ads);
  99. #endif // HEADER_FILE_TI_ADS1293_H