no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
adas1000.h
Go to the documentation of this file.
1/***************************************************************************/
35
36#ifndef _ADAS1000_H_
37#define _ADAS1000_H_
38
39#include <stdint.h>
40#include <stdbool.h>
41#include "no_os_spi.h"
42
43/******************************************************************************/
44/* ADAS1000 SPI Registers Memory Map */
45/******************************************************************************/
46
47#define ADAS1000_COMM_WRITE 0x80 /* SPI Write command */
48#define ADAS1000_RDY_MASK 0x40 /* READY bit mask */
49#define ADAS1000_ALL_CH_MASK 0x00 /* Word mask for activating all channels */
50#define ADAS1000_WD_CNT_MASK 0x01 /* Word count mask */
51
52#define ADAS1000_NOP 0x00 /* NOP (No operation) */
53#define ADAS1000_ECGCTL 0x01 /* ECG Setting Register */
54#define ADAS1000_LOFFCTL 0x02 /* Leads off Control Register */
55#define ADAS1000_RESPCTL 0x03 /* Respiration Control Register */
56#define ADAS1000_PACECTL 0x04 /* Pace Detection Control Register */
57#define ADAS1000_CMREFCTL 0x05 /* Common Mode Reference and Shield Drive Control Register */
58#define ADAS1000_GPIOCTL 0x06 /* GPIO Control Register */
59#define ADAS1000_PACEAMPTH 0x07 /* Pace Amplitude Threshold2 */
60#define ADAS1000_TESTTONE 0x08 /* Test Tone */
61#define ADAS1000_CALDAC 0x09 /* Calibration DAC */
62#define ADAS1000_FRMCTL 0x0A /* Frame Control Register */
63#define ADAS1000_FILTCTL 0x0B /* Filter Control Register */
64#define ADAS1000_LOFFUTH 0x0C /* Leads off Upper Threshold */
65#define ADAS1000_LOFFLTH 0x0D /* Leads off Lower Threshold */
66#define ADAS1000_PACEEDGETH 0x0E /* Pace Edge Threshold */
67#define ADAS1000_PACELVLTH 0x0F /* Pace Level Threshold */
68#define ADAS1000_LADATA 0x11 /* LA or LEAD I Data */
69#define ADAS1000_LLDATA 0x12 /* LL or LEAD II Data */
70#define ADAS1000_RADATA 0x13 /* RA or LEAD III Data */
71#define ADAS1000_V1DATA 0x14 /* V1 or V1 Data */
72#define ADAS1000_V2DATA 0x15 /* V2 or V2 Data */
73#define ADAS1000_PACEDATA 0x1A /* Read Pace Detection Data */
74#define ADAS1000_RESPMAG 0x1B /* Read Respiration Data Magnitude */
75#define ADAS1000_RESPPH 0x1C /* Read Respiration Data Phase */
76#define ADAS1000_LOFF 0x1D /* Leads Off Status */
77#define ADAS1000_DCLEADSOFF 0x1E /* DC Leads off Register */
78#define ADAS1000_EXTENDSW 0x20 /* Extended Switch for respiration inputs */
79#define ADAS1000_CALLA 0x21 /* User gain calibration LA */
80#define ADAS1000_CALLL 0x22 /* User gain calibration LL */
81#define ADAS1000_CALRA 0x23 /* User gain calibration RA */
82#define ADAS1000_CALV1 0x24 /* User gain calibration V1 */
83#define ADAS1000_CALV2 0x25 /* User gain calibration V2 */
84#define ADAS1000_LOAMLA 0x31 /* Leads off Amplitude for LA */
85#define ADAS1000_LOAMLL 0x32 /* Leads off Amplitude for LL */
86#define ADAS1000_LOAMRA 0x33 /* Leads off Amplitude for RA */
87#define ADAS1000_LOAMV1 0x34 /* Leads off Amplitude for V1 */
88#define ADAS1000_LOAMV2 0x35 /* Leads off Amplitude for V2 */
89#define ADAS1000_PACE1_DATA 0x3A /* Pace1 Width & Amplitude2 */
90#define ADAS1000_PACE2_DATA 0x3B /* Pace2 Width & Amplitude2 */
91#define ADAS1000_PACE3_DATA 0x3C /* Pace3 Width & Amplitude2 */
92#define ADAS1000_FRAMES 0x40 /* Frame Header - Read Data Frames */
93#define ADAS1000_CRC 0x41 /* Frame CRC */
94
95/******************************************************************************/
96/* ECG Setting Register */
97/******************************************************************************/
98/* ECG Channel Enable, shuts down power to the channel, the input is
99 now HiZ : 1 = enabled, 0 = disabled */
100#define ADAS1000_ECGCTL_LAEN (1ul << 23)
101/* ECG Channel Enable, shuts down power to the channel, the input is
102 now HiZ : 1 = enabled, 0 = disabled */
103#define ADAS1000_ECGCTL_LLEN (1ul << 22)
104/* ECG Channel Enable, shuts down power to the channel, the input is
105 now HiZ : 1 = enabled, 0 = disabled */
106#define ADAS1000_ECGCTL_RAEN (1ul << 21)
107/* ECG Channel Enable, shuts down power to the channel, the input is
108 now HiZ : 1 = enabled, 0 = disabled */
109#define ADAS1000_ECGCTL_V1EN (1ul << 20)
110/* ECG Channel Enable, shuts down power to the channel, the input is
111 now HiZ : 1 = enabled, 0 = disabled */
112#define ADAS1000_ECGCTL_V2EN (1ul << 19)
113/* Setting this bit selects the differential AFE input:
114 0 = Single Ended Input Digital Lead Mode or Electrode Mode,
115 1 = Differential Input Analog Lead Mode */
116#define ADAS1000_ECGCTL_CHCONFIG (1ul << 10)
117/* Pre-Amp & Anti-Aliasing Filter Overall Gain:
118 00 = GAIN 0 = x1.4, 01 = GAIN 1 = x2.1,
119 10 = GAIN 2 = x2.8, 11 = GAIN 3 = x4.2 */
120#define ADAS1000_ECGCTL_GAIN (1ul << 8)
121/* VREF Buffer Enable: 0 = Disabled, 1 = Enabled (when using internal
122 VREF, the VREFBUF must be enabled) */
123#define ADAS1000_ECGCTL_VREFBUF (1ul << 7)
124/* Use external clock instead of crystal oscillator. The crystal oscillator
125 is automatically disabled if configured as SLAVE in Gang mode and the
126 Slave device should receive the CLK from the Master device:
127 0 = XTAL is CLK source, 1 = CLK_IO is CLK source. */
128#define ADAS1000_ECGCTL_CLKEXT (1ul << 6)
129/* In gang mode, this bit selects the master (SYNC_GANG pin is configured
130 as an output). When in Single Channel Mode (GANG = 0), this bit is ignored:
131 0 = Slave, 1 = Master */
132#define ADAS1000_ECGCTL_MASTER (1ul << 5)
133/* Enable gang mode. Setting this bit causes the CLK_IO and to be activated:
134 0 = Single Channel mode, 1 = Gang Mode */
135#define ADAS1000_ECGCTL_GANG (1ul << 4)
136/* Selects the noise/power performance, this bit controls the ADC sampling
137 frequency. See specifications for further details:
138 0 = 1MSPS - low power, 1 = 2 MSPS - High performance/low noise */
139#define ADAS1000_ECGCTL_HP (1ul << 3)
140/* Convert Enable - Setting this bit enables the ADC conversion and filters:
141 0 = Idle, 1 = Conversion Enable */
142#define ADAS1000_ECGCTL_CNVEN (1ul << 2)
143/* Power Enable - clearing this bit powers down the device. All analog blocks
144 are powered down and the external crystal is disabled:
145 0 = Power Down, 1 = Power Enable */
146#define ADAS1000_ECGCTL_PWREN (1ul << 1)
147/* Software Reset - setting this bit clears all registers to their reset value.
148 This bit automatically clears itself. The software reset requires a NOP
149 command to complete the reset: 0 = NOP, 1 = Reset */
150
151#define ADAS1000_ECGCTL_SWRST (1ul << 0)
152/******************************************************************************/
153/* Leads off Control Register */
154/******************************************************************************/
155/* AC Leads Off Phase: 0 = in phase, 1 = 180deg out of phase */
156#define ADAS1000_LOFFCTL_LAPH (1ul << 23)
157/* AC Leads Off Phase: 0 = in phase, 1 = 180deg out of phase */
158#define ADAS1000_LOFFCTL_LLPH (1ul << 22)
159/* AC Leads Off Phase: 0 = in phase, 1 = 180deg out of phase */
160#define ADAS1000_LOFFCTL_RAPH (1ul << 21)
161/* AC Leads Off Phase: 0 = in phase, 1 = 180deg out of phase */
162#define ADAS1000_LOFFCTL_V1PH (1ul << 20)
163/* AC Leads Off Phase: 0 = in phase, 1 = 180deg out of phase */
164#define ADAS1000_LOFFCTL_V2PH (1ul << 19)
165/* AC Leads Off Phase: 0 = in phase, 1 = 180deg out of phase */
166#define ADAS1000_LOFFCTL_CEPH (1ul << 18)
167/* Individual electrode AC Leads off enable. AC Leads off enables are
168 the OR of ACSEL and the individual AC Leads off Channel enables.
169 0 = AC Leads off disabled, 1 = AC Leads off enabled */
170#define ADAS1000_LOFFCTL_LAACLOEN (1ul << 17)
171/* Individual electrode AC Leads off enable. AC Leads off enables are
172 the OR of ACSEL and the individual AC Leads off Channel enables.
173 0 = AC Leads off disabled, 1 = AC Leads off enabled */
174#define ADAS1000_LOFFCTL_LLACLOEN (1ul << 16)
175/* Individual electrode AC Leads off enable. AC Leads off enables are
176 the OR of ACSEL and the individual AC Leads off Channel enables.
177 0 = AC Leads off disabled, 1 = AC Leads off enabled */
178#define ADAS1000_LOFFCTL_RAACLOEN (1ul << 15)
179/* Individual electrode AC Leads off enable. AC Leads off enables are
180 the OR of ACSEL and the individual AC Leads off Channel enables.
181 0 = AC Leads off disabled, 1 = AC Leads off enabled */
182#define ADAS1000_LOFFCTL_V1ACLOEN (1ul << 14)
183/* Individual electrode AC Leads off enable. AC Leads off enables are
184 the OR of ACSEL and the individual AC Leads off Channel enables.
185 0 = AC Leads off disabled, 1 = AC Leads off enabled */
186#define ADAS1000_LOFFCTL_V2ACLOEN (1ul << 13)
187/* Individual electrode AC Leads off enable. AC Leads off enables are
188 the OR of ACSEL and the individual AC Leads off Channel enables.
189 0 = AC Leads off disabled, 1 = AC Leads off enabled */
190#define ADAS1000_LOFFCTL_CEACLOEN (1ul << 12)
191/* Set Current level for AC leads off (only active for ACSEL = 1).
192 00 = 12.5nA rms, 01 = 25nA rms,
193 10 = 50nA rms, 11 = 100nA rms */
194#define ADAS1000_LOFFCTL_ACCURREN (1ul << 7)
195/* Set Current level for DC leads off (only active for ACSEL = 0)
196 000 = 0nA, 001 = 10nA, 010 = 20nA, 011 = 30nA,
197 100 = 40nA, 101 = 50nA, 110 = 60nA, 111 = 70nA */
198#define ADAS1000_LOFFCTL_DCCURRENT (1ul << 2)
199/* DC or AC (out of band) Leads Off Detection. If LOFFEN = 0, this bit
200 is don't care. If LOFFEN = 1, 0 = DC Leads Off Detection enabled.
201 (Individual AC leads off may be enabled through bits 12-17),
202 1 = DC Leads off Detection disabled. AC Leads Off Detection enabled
203 (all electrodes except CE electrode). */
204#define ADAS1000_LOFFCTL_ACSEL (1ul << 1)
205/* Enable Leads Off Detection:
206 0 = Leads Off Disabled, 1 = Leads Off Enabled */
207#define ADAS1000_LOFFCTL_LOFFEN (1ul << 0)
208
209/******************************************************************************/
210/* Respiration Control Register */
211/******************************************************************************/
212/* Set to one to enable the MSB of the respiration DAC to be driven
213 out onto the GPIO[3] pin. This 64kHz signal can be used to
214 synchronize an external generator to the respiration carrier.
215 0 = normal GPIO3 function, 1 = MSB of RESPDAC driven onto GPIO[3] */
216#define ADAS1000_RESPCTL_RESPEXTSYNC (1ul << 15)
217/* For use with external instrumentation amplifier with respiration
218 circuit. Bypasses the on chip amplifier stage and input directly
219 to the ADC. */
220#define ADAS1000_RESPCTL_RESPEXTAMP (1ul << 14)
221/* Selects external respiration drive output. RESPDAC_RA is
222 automatically selected when RESPCAP = 1, 0 = RESPDAC _LL, 1 = RESPDAC_LA */
223#define ADAS1000_RESPCTL_RESPOUT (1ul << 13)
224/* Selects source of Respiration Capacitors.
225 0 = Use internal capacitors, 1 = Use external capacitors */
226#define ADAS1000_RESPCTL_RESPCAP (1ul << 12)
227/* Respiration Inamp Gain (saturates at 10):
228 0000 = x1 gain, 0001 = x2 gain, 0010 = x3 gain,
229 ...
230 1000 = x9 gain, 1001 = x10 gain, 11xx = x10 gain */
231#define ADAS1000_RESPCTL_RESPGAIN (1ul << 8)
232/* Selects between EXT_RESP _LA or EXT_RESP_LL paths. Only applies
233 if External Respiration is selected in RESPSEL. EXT_RESP_RA
234 automatically gets enabled. 0 = EXT_RESP_LL, 1 = EXT_RESP _LA */
235#define ADAS1000_RESPCTL_RESPEXTSEL (1ul << 7)
236/* Set Leads for Respiration Measurement:
237 00 = Lead I, 01 = Lead II,
238 10 = Lead III, 11 = External Respiration path */
239#define ADAS1000_RESPCTL_RESPSEL (1ul << 5)
240/* Set the test tone amplitude for respiration:
241 00 = Amplitude/8, 01 = Amplitude/4,
242 10 = Amplitude/2, 11 = Amplitude */
243#define ADAS1000_RESPCTL_RESPAMP (1ul << 3)
244/* Set Frequency for Respiration:
245 00 = 56kHz, 01 = 54kHz, 10 = 52kHz, 11 = 50kHz */
246#define ADAS1000_RESPCTL_RESPFREQ (1ul << 1)
247/* Enable Respiration:
248 0 = Respiration Disabled, 1 = Respiration Enabled */
249#define ADAS1000_RESPCTL_RESPEN (1ul << 0)
250
251#define ADAS1000_RESPCTL_RESPGAIN_MASK (0x0000000Ful << 8)
252#define ADAS1000_RESPCTL_RESPSEL_MASK (0x00000003ul << 5)
253
254/******************************************************************************/
255/* Pace Detection Control Register */
256/******************************************************************************/
257/* Pace width Filter:
258 0 = Filter Disabled, 1 = Filter Enabled */
259#define ADAS1000_PACECTL_PACEFILTW (1ul << 11)
260/* Pace validation filter 2:
261 0 = Filter Disabled, 1 = Filter Enabled */
262#define ADAS1000_PACECTL_PACETFILT2 (1ul << 10)
263/* Pace validation filter 1:
264 0 = Filter Disabled, 1 = Filter Enabled */
265#define ADAS1000_PACECTL_PACETFILT1 (1ul << 9)
266/* Set Lead for Pace Detection Measurement:
267 00 = Lead I, 01 = Lead II, 10 = Lead III, 11 = Lead aVF */
268#define ADAS1000_PACECTL_PACE3SEL (1ul << 7)
269/* Set Lead for Pace Detection Measurement:
270 00 = Lead I, 01 = Lead II, 10 = Lead III, 11 = Lead aVF */
271#define ADAS1000_PACECTL_PACE2SEL (1ul << 5)
272/* Set Lead for Pace Detection Measurement:
273 00 = Lead I, 01 = Lead II, 10 = Lead III, 11 = Lead aVF */
274#define ADAS1000_PACECTL_PACE1SEL (1ul << 3)
275/* Enable Pace Detection Algorithm:
276 0 = Pace Detection Disabled, 1 = Pace Detection Enabled */
277#define ADAS1000_PACECTL_PACE3EN (1ul << 2)
278/* Enable Pace Detection Algorithm:
279 0 = Pace Detection Disabled, 1 = Pace Detection Enabled */
280#define ADAS1000_PACECTL_PACE2EN (1ul << 1)
281/* Enable Pace Detection Algorithm:
282 0 = Pace Detection Disabled, 1 = Pace Detection Enabled */
283#define ADAS1000_PACECTL_PACE1EN (1ul << 0)
284#define ADAS1000_PACECTL_PACE3SEL_MASK (0x00000003ul << 7)
285#define ADAS1000_PACECTL_PACE2SEL_MASK (0x00000003ul << 5)
286#define ADAS1000_PACECTL_PACE1SEL_MASK (0x00000003ul << 3)
287
288/******************************************************************************/
289/* Common Mode Reference and Shield Drive Control Register */
290/******************************************************************************/
291/* Common Mode Electrode Select */
292#define ADAS1000_CMREFCTL_LACM (1ul << 23)
293/* Any combination of the 5 input electrodes can be used to create the */
294#define ADAS1000_CMREFCTL_LLCM (1ul << 22)
295/* Common Mode signal, or the Common Mode signal can be driven from the */
296#define ADAS1000_CMREFCTL_RACM (1ul << 21)
297/* internal reference. Bits 23:19 are ignored when bit 2 is selected. */
298#define ADAS1000_CMREFCTL_V1CM (1ul << 20)
299/* The Common Mode is the average of the selected electrodes. When a */
300/* single electrode is selected, the Common Mode is the signal level of */
301/* that electrode alone. */
302/* 0 = does not contribute to the common mode */
303/* 1 = contributes to the common mode */
304#define ADAS1000_CMREFCTL_V2CM (1ul << 19)
305/* RLD Summing Junction
306 0 = does not contribute to RLD input
307 1 = contributes to RLD input */
308#define ADAS1000_CMREFCTL_LARLD (1ul << 14)
309/* RLD Summing Junction
310 0 = does not contribute to RLD input
311 1 = contributes to RLD input */
312#define ADAS1000_CMREFCTL_LLRLD (1ul << 13)
313/* RLD Summing Junction
314 0 = does not contribute to RLD input
315 1 = contributes to RLD input */
316#define ADAS1000_CMREFCTL_RARLD (1ul << 12)
317/* RLD Summing Junction
318 0 = does not contribute to RLD input
319 1 = contributes to RLD input */
320#define ADAS1000_CMREFCTL_V1RLD (1ul << 11)
321/* RLD Summing Junction
322 0 = does not contribute to RLD input
323 1 = contributes to RLD input */
324#define ADAS1000_CMREFCTL_V2RLD (1ul << 10)
325/* RLD Summing Junction
326 0 = does not contribute to RLD input
327 1 = contributes to RLD input */
328#define ADAS1000_CMREFCTL_CERLD (1ul << 9)
329/* Common Electrode Reference
330 0 = Common Electrode disabled
331 1 = Common Electrode enabled */
332#define ADAS1000_CMREFCTL_CEREFEN (1ul << 8)
333/* Select electrode for reference drive
334 0000 = RL, 0001 = LA, 0010 = LL,
335 0011 = RA, 0100 = V1, 0101 = V2,
336 0110 to 1111 = Reserved */
337#define ADAS1000_CMREFCTL_RLDSEL (1ul << 4)
338/* Common mode output - when set, the internally derived common mode
339 signal is driven out the common mode pin. This bit has no effect
340 if external common mode is selected.
341 0 = common mode is not driven out
342 1 = common mode is driven out the external common mode pin */
343#define ADAS1000_CMREFCTL_DRVCM (1ul << 3)
344/* Select the source of Common Mode
345 (use when operating multiple devices together)
346 0 = Internal Common Mode selected
347 1 = External Common Mode selected */
348#define ADAS1000_CMREFCTL_EXTCM (1ul << 2)
349/* Enable Right Leg Drive Reference Electrode
350 0 = Disabled
351 1 = Enabled */
352#define ADAS1000_CMREFCTL_RLD_EN (1ul << 1)
353/* Enable Shield Drive
354 0 = Shield Drive Disabled
355 1 = Shield Drive Enabled */
356#define ADAS1000_CMREFCTL_SHLDEN (1ul << 0)
357
358#define ADAS1000_CMREFCTL_RLDSEL_MASK (0x0000000Ful << 4)
359
360/******************************************************************************/
361/* GPIO Control Register */
362/******************************************************************************/
363/* Frame secondary SPI words with chip select
364 0 = MCS asserted for entire frame
365 1 = MCS asserted for individual word */
366#define ADAS1000_GPIOCTL_SPIFW (1ul << 18)
367/* Secondary SPI Enable (ADAS1000 and ADAS1000-2 only) (SPI interface
368 providing ECG data at 128kHz data rate for external digital pace
369 algorithm detection � uses GPIO0, GPIO1, GPIO2 pins)
370 0 = Disabled
371 1 = Enabled. The individual control bits for GPIO0, GPIO1,
372 GPIO2 are ignored. GPIO3 is not affected by SPIEN */
373#define ADAS1000_GPIOCTL_SPIEN (1ul << 16)
374/* State of GPIO<3>
375 00 = High Impedance, 01 = Input,
376 10 = Output, 11 = Open Drain */
377#define ADAS1000_GPIOCTL_G3CTL (1ul << 14)
378/* Output Value to be written to GPIO<3> when pad is configured as an
379 output or open drain
380 0 = Low Value
381 1 = High Value */
382#define ADAS1000_GPIOCTL_G3OUT (1ul << 13)
383/* (Read Only) Input Value read from GPIO<3> when pad is configured as an input
384 0 = Low Value
385 1 = High Value */
386#define ADAS1000_GPIOCTL_G3IN (1ul << 12)
387/* State of GPIO<2>
388 00 = High Impedance, 01 = Input,
389 10 = Output, 11 = Open Drain */
390#define ADAS1000_GPIOCTL_G2CTL (1ul << 10)
391/* Output Value to be written to GPIO<2> when pad is configured as an
392 output or open drain
393 0 = Low Value
394 1 = High Value */
395#define ADAS1000_GPIOCTL_G2OUT (1ul << 9)
396/* (Read Only) Input Value read from GPIO<2> when pad is configured as an input.
397 0 = Low Value
398 1 = High Value */
399#define ADAS1000_GPIOCTL_G2IN (1ul << 8)
400/* State of GPIO<1>
401 00 = High Impedance, 01 = Input,
402 10 = Output, 11 = Open Drain */
403#define ADAS1000_GPIOCTL_G1CTL (1ul << 6)
404/* Output Value to be written to GPIO<1> when pad is configured as an
405 output or open drain.
406 0 = Low Value
407 1 = High Value */
408#define ADAS1000_GPIOCTL_G1OUT (1ul << 5)
409/* (Read Only) Input Value read from GPIO<1> when pad is configured as an input.
410 0 = Low Value
411 1 = High Value */
412#define ADAS1000_GPIOCTL_G1IN (1ul << 4)
413/* State of GPIO<0>
414 00 = High Impedance, 01 = Input,
415 10 = Output, 11 = Open Drain */
416#define ADAS1000_GPIOCTL_G0CTL (1ul << 2)
417/* Output Value to be written to GPIO<0> when pad is configured as an
418 output or open drain.
419 0 = Low Value
420 1 = High Value */
421#define ADAS1000_GPIOCTL_G0OUT (1ul << 1)
422/* (Read Only) Input Value read from GPIO<0> when pad is configured
423 as an input
424 0 = Low Value
425 1 = High Value */
426#define ADAS1000_GPIOCTL_G0IN (1ul << 0)
427#define ADAS1000_GPIOCTL_G3CTL_MASK (0x00000003ul << 14)
428#define ADAS1000_GPIOCTL_G2CTL_MASK (0x00000003ul << 10)
429#define ADAS1000_GPIOCTL_G1CTL_MASK (0x00000003ul << 6)
430#define ADAS1000_GPIOCTL_G0CTL_MASK (0x00000003ul << 2)
431
432/******************************************************************************/
433/* Pace Amplitude Threshold2 Register */
434/******************************************************************************/
435/* Pace Amplitude Thresold */
436#define ADAS1000_PACEAMPTH_PACE3AMPTH (1ul << 16)
437/* Threshold = N - VREF/GAIN/216 */
438#define ADAS1000_PACEAMPTH_PACE2AMPTH (1ul << 8)
439#define ADAS1000_PACEAMPTH_PACE1AMPTH (1ul << 0)
440
441#define ADAS1000_PACEAMPTH_PACE3AMPTH_MASK (0x000000FFul << 16)
442#define ADAS1000_PACEAMPTH_PACE2AMPTH_MASK (0x000000FFul << 8)
443#define ADAS1000_PACEAMPTH_PACE1AMPTH_MASK (0x000000FFul << 0)
444
445/******************************************************************************/
446/* Test Tone Register */
447/******************************************************************************/
448/* Tone Select */
449#define ADAS1000_TESTTONE_TONLA (1ul << 23)
450/* 0 = 1.3V VCM_REF */
451#define ADAS1000_TESTTONE_TONLL (1ul << 22)
452/* 1 = 1mV sinewave or squarewave for toneint, no connect for tonext */
453#define ADAS1000_TESTTONE_TONRA (1ul << 21)
454#define ADAS1000_TESTTONE_TONV1 (1ul << 20)
455#define ADAS1000_TESTTONE_TONV2 (1ul << 19)
456/* 00 = 10Hz Sine Wave
457 01 = 150Hz Sine Wave
458 1x = 1Hz 1mV Square Wave */
459#define ADAS1000_TESTTONE_TONTYPE (1ul << 3)
460/* Test Tone Internal or External
461 0 = External Test Tone
462 1 = Internal Test Tone */
463#define ADAS1000_TESTTONE_TONINT (1ul << 2)
464/* Test Tone out Enable
465 0 = disconnects test tone from CAL_DAC_IO during internal mode only
466 1 = Connects CAL_DAC_IO to test tone during internal mode. */
467#define ADAS1000_TESTTONE_TONOUT (1ul << 1)
468/* Enables an internal test tone to drive entire signal chain, from
469 pre-amp to SPI interface. This tone comes from the CAL DAC and goes
470 to the pre-amps through the internal mux. When TONEN (CALDAC) is
471 enabled, AC Leads off is disabled.
472 0 = Disable the test tone
473 1 = Enable the CALDAC 1mV SineWave test tone (Cal Mode has priority) */
474#define ADAS1000_TESTTONE_TONEN (1ul << 0)
475
476#define ADAS1000_TESTTONE_TONTYPE_MASK (0x00000003ul << 3)
477
478/******************************************************************************/
479/* Calibration DAC Register */
480/******************************************************************************/
481/* Calibration Chop Clock Enable. The CALDAC output can be chopped to
482 lower 1/f noise. Chopping is done at 256kHz.
483 0 = Disabled
484 1 = Enabled. */
485#define ADAS1000_CALDAC_CALCHPEN (1ul << 13)
486/* Calibration Mode Enable
487 0 = Disable Calibration mode
488 1 = Enable Calibration mode - connect CAL DAC_IO,
489 begin data acquisition on ECG channels. */
490#define ADAS1000_CALDAC_CALMODEEN (1ul << 12)
491/* Calibration Internal or External
492 0 = External Cal - calibration to be performed externally by
493 looping CAL_DAC_IO around into ECG channels.
494 1 = Internal Cal - disconnects external switches for all ECG
495 channels and connects CALDAC internally to all ECG channels. */
496#define ADAS1000_CALDAC_CALINT (1ul << 11)
497/* Enable 10-bit calibration DAC for cal mode or external use.
498 0 = Disable CALDAC
499 1 = Enable CALDAC, if a master device and not in calibration
500 mode then also connects CAL_DAC out to its_IO pin for
501 external use, if in Slave mode, the CALDAC will disable to
502 allow master to drive CAL_DAC_IO pin. When CALDAC is enabled,
503 AC Leads off is disabled. */
504#define ADAS1000_CALDAC_CALDACEN (1ul << 10)
505/* Set the CAL DAC value */
506#define ADAS1000_CALDAC_CALDATA (1ul << 0)
507
508#define ADAS1000_CALDAC_CALDATA_MASK (0x000003FFul << 0)
509
510/******************************************************************************/
511/* Frame Control Register */
512/******************************************************************************/
513/* Include/Exclude word from ECG data frame, if electrode/lead is
514 included in the data word and the electrode falls off, then the
515 data word will be undefined.
516 0 = Included in Frame
517 1 = Exclude from Frame */
518#define ADAS1000_FRMCTL_LEAD_I_LADIS (1ul << 23)
519#define ADAS1000_FRMCTL_LEAD_II_LLDIS (1ul << 22)
520#define ADAS1000_FRMCTL_LEAD_III_RADIS (1ul << 21)
521#define ADAS1000_FRMCTL_V1DIS (1ul << 20)
522#define ADAS1000_FRMCTL_V2DIS (1ul << 19)
523/* Include/Exclude word from ECG data frame
524 0 = Included in Frame
525 1 = Exclude from Frame */
526#define ADAS1000_FRMCTL_PACEDIS (1ul << 14)
527/* Respiration Magnitude
528 0 = Included in Frame
529 1 = Exclude from Frame */
530#define ADAS1000_FRMCTL_RESPMDIS (1ul << 13)
531/* Respiration Phase
532 0 = Included in Frame
533 1 = Exclude from Frame */
534#define ADAS1000_FRMCTL_RESPPHDIS (1ul << 12)
535/* Leads Off Status
536 0 = Included in Frame
537 1 = Exclude from Frame */
538#define ADAS1000_FRMCTL_LOFFDIS (1ul << 11)
539/* GPIO Word disable
540 0 = Included in Frame
541 1 = Exclude from Frame */
542#define ADAS1000_FRMCTL_GPIODIS (1ul << 10)
543/* CRC Word disable
544 0 = Included in Frame
545 1 = Exclude from Frame */
546#define ADAS1000_FRMCTL_CRCDIS (1ul << 9)
547/* In a master device configured for Lead Mode, the ECG data will
548 be signed. When in slave mode (electrode format), the ECG data
549 format is unsigned. Use this bit when using multiple devices to
550 make the slave device signed data.
551 0 = unsigned data (default)
552 1 = signed data */
553#define ADAS1000_FRMCTL_SIGNEDEN (1ul << 8)
554/* Automatically disable PACE, RESP, LOFF words if their flags are
555 not set in the header.
556 0 = fixed frame format
557 1 = auto disable words */
558#define ADAS1000_FRMCTL_ADIS (1ul << 7)
559/* Ready Repeat � if this bit is set and the frame header indicates
560 data is not ready, the frame header is continuously sent until
561 data is ready.
562 0 = always send entire frame
563 1 = repeat frame header until ready */
564#define ADAS1000_FRMCTL_RDYRPT (1ul << 6)
565/* Sets the Output Data Format
566 0 = Lead/Vector Format
567 (only available in 2kHz & 16kHz data rates)
568 1 = Electrode Format */
569#define ADAS1000_FRMCTL_DATAFMT (1ul << 4)
570/* Skip interval - this field provides a way to decimate the data
571 00 = output every frame
572 01 = output every other frame
573 1x = output every 4th frame */
574#define ADAS1000_FRMCTL_SKIP (1ul << 2)
575/* Sets the Output Data Rate to 2 kHz */
576#define ADAS1000_FRMCTL_FRMRATE_2KHZ 0x00
577/* Sets the Output Data Rate to 16 kHz */
578#define ADAS1000_FRMCTL_FRMRATE_16KHZ 0x01
579/* Sets the Output Data Rate to 128 kHz */
580#define ADAS1000_FRMCTL_FRMRATE_128KHZ 0x10
581/* Sets the Output Data Rate to 31.25 Hz */
582#define ADAS1000_FRMCTL_FRMRATE_31_25HZ 0x11
583
584#define ADAS1000_FRMCTL_WORD_MASK (ADAS1000_FRMCTL_LEAD_I_LADIS | \
585 ADAS1000_FRMCTL_LEAD_II_LLDIS | \
586 ADAS1000_FRMCTL_LEAD_III_RADIS | \
587 ADAS1000_FRMCTL_V1DIS | \
588 ADAS1000_FRMCTL_V2DIS | \
589 ADAS1000_FRMCTL_PACEDIS | \
590 ADAS1000_FRMCTL_RESPMDIS | \
591 ADAS1000_FRMCTL_RESPPHDIS | \
592 ADAS1000_FRMCTL_LOFFDIS | \
593 ADAS1000_FRMCTL_GPIODIS | \
594 ADAS1000_FRMCTL_CRCDIS)
595#define ADAS1000_FRMCTL_SKIP_MASK (0x00000003ul << 2)
596#define ADAS1000_FRMCTL_FRMRATE_MASK (0x00000003ul << 0)
597
598/******************************************************************************/
599/* Filter Control Register */
600/******************************************************************************/
601/* 2kHz notch bypass for SPI Master
602 0 = notch filter bypassed
603 1 = notch filter present */
604#define ADAS1000_FILTCTL_MN2K (1ul << 5)
605/* 2kHz notch bypass
606 0 = notch filter present
607 1 = notch filter bypassed */
608#define ADAS1000_FILTCTL_N2KBP (1ul << 4)
609/* 00 = 40Hz
610 01 = 150Hz
611 10 = 250 Hz
612 11 = 450Hz */
613#define ADAS1000_FILTCTL_LPF (1ul << 2)
614
615#define ADAS1000_FILTCTL_LPF_MASK (0x00000003ul << 2)
616
617/******************************************************************************/
618/* Leads off Upper Threshold Register */
619/******************************************************************************/
620/* ADC over range threshold. An ADC out-of-range error will be flagged
621 if the ADC output is greater than the over range threshold.
622 The over range threshold is offset from the maximum value.
623 Threshold = max_value � ADCOVER*2^6
624 0000 = max value (disabled)
625 0001 = max_value - 64
626 0010 = max_value - 128
627 ...
628 1111: max_value - 960 */
629#define ADAS1000_LOFFUTH_ADCOVER (1ul << 16)
630/* AC Leads off upper Threshold. Leads off will be detected if the DC
631 or AC output is = N * 2 * VREF/GAIN/2^16. 0 = 0V */
632#define ADAS1000_LOFFUTH_LOFFUTH (1ul << 0)
633
634#define ADAS1000_LOFFUTH_ADCOVER_MASK (0x0000000Ful << 16)
635#define ADAS1000_LOFFUTH_LOFFUTH_MASK (0x0000FFFFul << 0)
636
637/******************************************************************************/
638/* Leads off Lower Threshold Register */
639/******************************************************************************/
640/* ADC under range threshold. An ADC out-of-range error will be flagged
641 if the ADC output is less than the under range threshold.
642 Threshold = min_value + ADCUNDR�2^6
643 0000 = min value (disabled)
644 0001 = min_value + 64
645 0010 = min _value + 128
646 ...
647 1111: min _value + 960 */
648#define ADAS1000_LOFFLTH_ADCUNDR (1ul << 16)
649/* AC Leads off lower Threshold. Leads off will be detected if the DC
650 or AC output is = N * 2 * VREF/GAIN/2^16. 0 = 0V */
651#define ADAS1000_LOFFLTH_LOFFLTH (1ul << 0)
652
653#define ADAS1000_LOFFLTH_ADCUNDR_MASK (0x0000000Ful << 16)
654#define ADAS1000_LOFFLTH_LOFFLTH_MASK (0x0000FFFFul << 0)
655
656/******************************************************************************/
657/* Pace Edge Threshold Register */
658/******************************************************************************/
659/* Pace edge trigger threshold */
660#define ADAS1000_PACEEDGETH_PACE3EDGTH (1ul << 16)
661/* 0 = PACEAMPTH/2 */
662#define ADAS1000_PACEEDGETH_PACE2EDGTH (1ul << 8)
663/* 1 = VREF/GAIN/2^16 */
664#define ADAS1000_PACEEDGETH_PACE1EDGTH (1ul << 0)
665/* N = N * VREF/GAIN/2^16 */
666
667#define ADAS1000_PACEEDGETH_PACE3EDGTH_MASK (0x000000FFul << 16)
668#define ADAS1000_PACEEDGETH_PACE2EDGTH_MASK (0x000000FFul << 8)
669#define ADAS1000_PACEEDGETH_PACE1EDGTH_MASK (0x000000FFul << 0)
670
671/******************************************************************************/
672/* Pace Level Threshold Register */
673/******************************************************************************/
674/* Pace level threshold. This is a signed value. */
675#define ADAS1000_PACELVLTH_PACE3LVLTH (1ul << 16)
676/* -1 = 0xFFF = -VREF/GAIN/2^16 */
677#define ADAS1000_PACELVLTH_PACE2LVLTH (1ul << 8)
678/* 0 = 0x0000 = 0V */
679#define ADAS1000_PACELVLTH_PACE1LVLTH (1ul << 0)
680/* +1 = 0x001 = +VREF/GAIN/2^16 */
681/* N = N * VREF/GAIN/2^16 */
682
683#define ADAS1000_PACELVLTH_PACE3LVLTH_MASK (0x000000FFul << 16)
684#define ADAS1000_PACELVLTH_PACE2LVLTH_MASK (0x000000FFul << 8)
685#define ADAS1000_PACELVLTH_PACE1LVLTH_MASK (0x000000FFul << 0)
686
687/***********************************************************************************/
688/* LA or LEAD I, LL or LEAD II, RA or LEAD III, V1 or V1�, V2 or V2� Data Register */
689/***********************************************************************************/
690/* 0x11 : LA or LEAD I
691 0x12 : LL or LEAD II
692 0x13 : RA or LEAD II
693 0x14 : V1 or V1
694 0x15 : V2 or V2 */
695#define ADAS1000_LADATA_ADDRESS (1ul << 24)
696/* Channel Data Value. Data left justified (MSB) irrespective of data
697 rate. In electrode format, the value is an unsigned integer.
698 In Vector format, the value is a signed 2�s complement integer format.
699 Vector format had 2x range compared to electrode format since it can
700 swing from +VREF to -VREF, therefore the LSB size is double.
701 Electrode Format:
702 Min value (000...) = 0V
703 Max value (1111...) = VREF/GAIN
704 LSB = (VREF/GAIN)/2N
705 Lead/Vector Format
706 Min value (1000...) = -(VREF/GAIN)
707 Max value (0111...) = +VREF/GAIN
708 LSB = 2^(VREF/GAIN)/2N
709 Where N = # of data bits, 16 for 128kHz data rate or 24 for
710 2kHz/16kHz data rate. */
711
712#define ADAS1000_LADATA_ECG_DATA (1ul << 0)
713#define ADAS1000_LADATA_ADDRESS_MASK (0x000000FFul << 24)
714#define ADAS1000_LADATA_ECG_DATA_MASK (0x00FFFFFFul << 0)
715
716/******************************************************************************/
717/* Read Pace Detection Data Register */
718/******************************************************************************/
719/* 0001 1010 = Pace Detection */
720#define ADAS1000_PACEDATA_ADDRESS (1ul << 24)
721/* Pace 3 detected. This bit will be set once a pace pulse is
722 detected. This bit is set on the trailing edge of the pace pulse.
723 0 = Pace pulse not detected in current frame
724 1 = Pace pulse detected in this frame */
725#define ADAS1000_PACEDATA_PACE3_DETECTED (1ul << 23)
726/* This is the log2(height) of the pace pulse
727 N: height = 2^N * VREF / GAIN / 2^16 */
728#define ADAS1000_PACEDATA_PACE_CH3_HEIGHT (1ul << 16)
729/* This is log2(Width)-1 of the pace pulse.
730 N: Width = 2^(N+1) / 128kHz */
731#define ADAS1000_PACEDATA_PACE_CH3_WIDTH (1ul << 20)
732/* Pace 2 detected. This bit will be set once a pace pulse is
733 detected. This bit is set on the trailing edge of the pace pulse.
734 0 = Pace pulse not detected in current frame
735 1 = Pace pulse detected in this frame*/
736#define ADAS1000_PACEDATA_PACE2_DETECTED (1ul << 15)
737/* This is log2(Width)-1 of the pace pulse.
738 N: Width = 2^(N+1) / 128kHz */
739#define ADAS1000_PACEDATA_PACE_CH2_WIDTH (1ul << 12)
740/* This is the log2(height) of the pace pulse
741 N: height = 2^N * VREF / GAIN / 2^16 */
742#define ADAS1000_PACEDATA_PACE_CH2_HEIGHT (1ul << 8)
743/* Pace 1 detected. This bit will be set once a pace pulse is
744 detected. This bit is set on the trailing edge of the pace pulse.
745 0 = Pace pulse not detected in current frame
746 1 = Pace pulse detected in this frame */
747#define ADAS1000_PACEDATA_PACE1_DETECTED (1ul << 7)
748/* "This is log2(Width)-1 of the pace pulse.
749 N: Width = 2^(N+1) / 128kHz */
750#define ADAS1000_PACEDATA_PACE_CH1_WIDTH (1ul << 4)
751/* This is the log2(height) of the pace pulse
752 N: height = 2^N * VREF / GAIN / 2^16 */
753#define ADAS1000_PACEDATA_CH1_HEIGHT (1ul << 0)
754
755#define ADAS1000_PACEDATA_ADDRESS_MASK (0x000000FFul << 24)
756#define ADAS1000_PACEDATA_PACE_CH3_WIDTH_MASK (0x00000007ul << 20)
757#define ADAS1000_PACEDATA_PACE_CH3_HEIGHT_MASK (0x0000000Ful << 16)
758#define ADAS1000_PACEDATA_PACE_CH2_WIDTH_MASK (0x00000007ul << 12)
759#define ADAS1000_PACEDATA_PACE_CH2_HEIGHT_MASK (0x0000000Ful << 8)
760#define ADAS1000_PACEDATA_PACE_CH1_WIDTH_MASK (0x00000007ul << 4)
761#define ADAS1000_PACEDATA_PACE_CH1_HEIGHT_MASK (0x0000000Ful << 0)
762
763/******************************************************************************/
764/* Read Respiration Data Magnitude Register */
765/******************************************************************************/
766/* 0001 1011 = Respiration Magnitude */
767#define ADAS1000_RESPMAG_ADDRESS (1ul << 24)
768/* Magnitude of respiration signal. This is an unsigned value. */
769#define ADAS1000_RESPMAG_MAGNITUDE (1ul << 0)
770
771#define ADAS1000_RESPMAG_ADDRESS_MASK (0x000000FFul << 24)
772#define ADAS1000_RESPMAG_MAGNITUDE_MASK (0x00FFFFFFul << 0)
773
774/******************************************************************************/
775/* Read Respiration Data Phase Register */
776/******************************************************************************/
777/* 0001 1100 = Respiration Phase */
778#define ADAS1000_RESPPH_ADDRESS (1ul << 24)
779/* Phase of respiration signal. Can be interpreted as either signed or
780 unsigned value. If unsigned, the range is from 0 to 2pi. If as a
781 signed value, the range is from �pi to +pi.
782 0x000000 = 0
783 0x000001 = 2pi / 2^24
784 0x400000 = pi/2
785 0x800000 = +pi = -pi
786 0xC00000 = +3pi/2 = -pi/2
787 0xFFFFFF = +2pi(1 - 2^(-24)) = -2p / 2^24 */
788#define ADAS1000_RESPPH_PHASE (1ul << 0)
789
790#define ADAS1000_RESPPH_ADDRESS_MASK (0x000000FFul << 24)
791#define ADAS1000_RESPPH_PHASE_MASK (0x00FFFFFFul << 0)
792
793/******************************************************************************/
794/* Leads Off Status Register */
795/******************************************************************************/
796/* Address bits define the word data 0001 1101 = Leads Off */
797#define ADAS1000_LOFF_ADDRESS (1ul << 24)
798/* Electrode Connection Status. If either DC or AC leads off
799 If both DC and AC leads off are enabled, these bits reflect
800 only the AC leads off status. DC leads off is available in
801 the DCLEADSOFF register. The common electrodes only have DC
802 leads off detection. An AC leads off signal can be injected
803 into the common electrode, but there is no ADC input to measure
804 its amplitude. If the common electrode is off, it will affect
805 the AC leads off amplitude of the other electrodes. These bits
806 accumulate in the frame buffer and are cleared when the frame
807 buffer is loaded into the SPI buffer.
808 0 = Electrode is connected
809 1 = Electrode is disconnected*/
810#define ADAS1000_LOFF_RL_LEADS_OFF_STATUS (1ul << 23)
811#define ADAS1000_LOFF_LA_LEADS_OFF_STATUS (1ul << 22)
812#define ADAS1000_LOFF_LL_LEADS_OFF_STATUS (1ul << 21)
813#define ADAS1000_LOFF_RA_LEADS_OFF_STATUS (1ul << 20)
814#define ADAS1000_LOFF_V1_LEADS_OFF_STATUS (1ul << 19)
815#define ADAS1000_LOFF_V2_LEADS_OFF_STATUS (1ul << 18)
816#define ADAS1000_LOFF_CELO (1ul << 13)
817/* ADC out of range error.
818 These status bits indicate the resulting ADC code is out of
819 range. These bits accumulate in the frame buffer and are
820 cleared when the frame buffer is loaded into the SPI buffer. */
821#define ADAS1000_LOFF_LAADCOR (1ul << 12)
822#define ADAS1000_LOFF_LLADCOR (1ul << 11)
823#define ADAS1000_LOFF_RAADCOR (1ul << 10)
824#define ADAS1000_LOFF_V1ADCOR (1ul << 9)
825#define ADAS1000_LOFF_V2ADCOR (1ul << 8)
826
827#define ADAS1000_LOFF_ADDRESS_MASK (0x000000FFul << 24)
828
829/******************************************************************************/
830/* DC Leads off Register */
831/******************************************************************************/
832/* Address bits define the word data 0001 1110 = DC Leads Off */
833#define ADAS1000_DCLEADSOFF_ADDRESS (1ul << 24)
834/* The DC leads off detection is comparator based and compares
835 to a fixed level. Per electrode bits flag if the DC leads off
836 comparator threshold level has been exceeded.
837 0 = electrode < overrange threshold, 2.4 V
838 1 = electrode > overrange threshold, 2.4 V */
839#define ADAS1000_DCLEADSOFF_RL_INPUT_OVERRANGE (1ul << 23)
840#define ADAS1000_DCLEADSOFF_LA_INPUT_OVERRANGE (1ul << 22)
841#define ADAS1000_DCLEADSOFF_LL_INPUT_OVERRANGE (1ul << 21)
842#define ADAS1000_DCLEADSOFF_RA_INPUT_OVERRANGE (1ul << 20)
843#define ADAS1000_DCLEADSOFF_CE_INPUT_OVERRANGE (1ul << 13)
844
845/* The DC leads off detection is comparator based and compares
846 to a fixed level. Per electrode bits flag if the DC leads off
847 comparator threshold level has been exceeded.
848 0 = electrode > underrange threshold, 0.2 V
849 1 = electrode < underrange threshold, 0.2 V */
850#define ADAS1000_DCLEADSOFF_RL_INPUT_UNDERRANGE (1ul << 12)
851#define ADAS1000_DCLEADSOFF_LA_INPUT_UNDERRANGE (1ul << 11)
852#define ADAS1000_DCLEADSOFF_LL_INPUT_UNDERRANGE (1ul << 10)
853#define ADAS1000_DCLEADSOFF_RA_INPUT_UNDERRANGE (1ul << 9)
854#define ADAS1000_DCLEADSOFF_CE_INPUT_UNDERRANGE (1ul << 2)
855
856#define ADAS1000_DCLEADSOFF_ADDRESS_MASK (0x000000FFul << 24)
857
858/******************************************************************************/
859/* Extended Switch for Respiration Inputs Register */
860/******************************************************************************/
861/* External Respiration electrode input switch to channel
862 electrode input.
863 0 = switch open
864 1 = switch closed */
865#define ADAS1000_EXTENDSW_EXTRESP_RA_LA (1ul << 23)
866#define ADAS1000_EXTENDSW_EXTRESP_RA_LL (1ul << 22)
867#define ADAS1000_EXTENDSW_EXTRESP_RA_RA (1ul << 21)
868#define ADAS1000_EXTENDSW_EXTRESP_RA_V1 (1ul << 20)
869#define ADAS1000_EXTENDSW_EXTRESP_RA_V2 (1ul << 19)
870#define ADAS1000_EXTENDSW_EXTRESP_LL_LA (1ul << 18)
871#define ADAS1000_EXTENDSW_EXTRESP_LL_LL (1ul << 17)
872#define ADAS1000_EXTENDSW_EXTRESP_LL_RA (1ul << 16)
873#define ADAS1000_EXTENDSW_EXTRESP_LL_V1 (1ul << 15)
874#define ADAS1000_EXTENDSW_EXTRESP_LL_V2 (1ul << 14)
875#define ADAS1000_EXTENDSW_EXTRESP_LA_LA (1ul << 13)
876#define ADAS1000_EXTENDSW_EXTRESP_LA_LL (1ul << 12)
877#define ADAS1000_EXTENDSW_EXTRESP_LA_RA (1ul << 11)
878#define ADAS1000_EXTENDSW_EXTRESP_LA_V1 (1ul << 10)
879#define ADAS1000_EXTENDSW_EXTRESP_LA_V2 (1ul << 9)
880
881/* V1 and V2 electrodes may be used for measurement purposes
882 other than ECG. To achieve this, they need to be disconnected
883 from the patient VCM voltage provided from the internal common
884 mode buffer and instead connected to the internal VCM_REF level
885 of 1.3V. Set FREE_Vx bits high to connect negative input of V1
886 channel will be tied to internal VCM_REF level. This allows user
887 to make alternative measurements on V1 channel relative to the
888 VCM_REF level. If using Digital lead mode, uses these bits in
889 conjunction with NO_MATH_Vx bits [6:5]. */
890#define ADAS1000_EXTENDSW_FREE_V1 (1ul << 8)
891#define ADAS1000_EXTENDSW_FREE_V2 (1ul << 7)
892/* In Digital Lead Mode, the digital core calculates the math on V1
893 and V2 with respect to WCT (LA+LL+RA)/3 providing V1 and V2.
894 Where V1 or V2 are used for measurement of something other than
895 ECG, then the math calculation needs to be disabled. These bits
896 are most likely used in conjunction with bits FREE_Vx [8:7].
897 Set NOMATH_Vx bits high to disable the math calculation in V1
898 and V2 respectively. */
899#define ADAS1000_EXTENDSW_NOMATH_V1 (1ul << 6)
900#define ADAS1000_EXTENDSW_NOMATH_V2 (1ul << 5)
901
902/******************************************************************************/
903/* User gain calibration LA, LL, RA, V1, V2 Register */
904/******************************************************************************/
905/* 0x21 : CAL LA */
906/* 0x22 : CAL LL */
907/* 0x23 : CAL RA */
908/* 0x24 : CAL V1 */
909/* 0x25 : CAL V2 */
910#define ADAS1000_CAL_ADDRESS (1ul << 24)
911/* User can choose between:
912 0 = default calibration values
913 1 = user calibration values */
914#define ADAS1000_CAL_USRCAL (1ul << 23)
915/* Gain Calibration value.
916 Result = data * (1 + GAIN * 2^(-17))
917 The value read from this register is the current gain calibration value.
918 If the USRCAL bit is clear, this register returns the default value for
919 the current gain setting.
920 0x7FF (+2047) = *1.00000011111111111b
921 0x001 (+1) = *1.00000000000000001b
922 0x000 (0) = *1.00000000000000000b
923 0xFFF (-1) = *0.11111111111111111b
924 0x800 (-2048) = *0.11111100000000000b */
925#define ADAS1000_CAL_CALVALUE (1ul << 0)
926
927#define ADAS1000_CAL_ADDRESS_MASK (0x000000FFul << 24)
928#define ADAS1000_CAL_CALVALUE_MASK (0x00000FFFul << 0)
929
930/******************************************************************************/
931/* Leads off Amplitude for LA, LL, RA, V1, V2 Register */
932/******************************************************************************/
933/* 0x31 : LA AC Leads off Magnitude
934 0x32 : LL AC Leads off Magnitude
935 0x33 : RA AC Leads off Magnitude
936 0x34 : V1 AC Leads off Magnitude
937 0x35 : V2 AC Leads off Magnitude */
938#define ADAS1000_LOAM_ADDRESS (1ul << 24)
939/* Measured Amplitude.
940 When AC leads off is selected, the data is the average of the rectified
941 2kHz bandpass filter with an update rate of 8Hz and cutoff frequency at
942 2Hz. The output is the amplitude of the 2kHz signal scaled by 2/pi
943 approximately = 0.6 (average of rectified sine wave). To convert to RMS,
944 scale the output by pi / (2*sqrt(2)).
945 Leads off (unsigned):
946 Min 0x0000 = 0V
947 LSB 0x0001= VREF / GAIN / 2^16
948 Max 0xFFFF = VREF / GAIN */
949#define ADAS1000_LOAM_LOFFAM (1ul << 0)
950
951#define ADAS1000_LOAM_ADDRESS_MASK (0x000000FFul << 24)
952#define ADAS1000_LOAM_LOFFAM_MASK (0x0000FFFFul << 0)
953
954/******************************************************************************/
955/* Pace1, Pace2, Pace3 Width & Amplitude2 Register */
956/******************************************************************************/
957/* 0x3A : PACE1DATA
958 0x3B : PACE2DATA
959 0x3C : PACE3DATA */
960#define ADAS1000_PACE_DATA_ADDRESS (1ul << 24)
961/* Measured pace height in signed 2�s complement value
962 0 = 0
963 1 = VREF / GAIN / 2^16
964 N = N * VREF / GAIN / 2^16 */
965#define ADAS1000_PACE_DATA_HEIGHT (1ul << 8)
966/* Measured pace width in 128kHz samples
967 N: N / 128kHz = width
968 12: 12 / 128kHz = 93us
969 255: 255 / 128kHz = 2.0ms */
970#define ADAS1000_PACE_DATA_WIDTH (1ul << 0)
971
972#define ADAS1000_PACE_DATA_ADDRESS_MASK (0x000000FFul << 24)
973#define ADAS1000_PACE_DATA_HEIGHT_MASK (0x0000FFFFul << 8)
974#define ADAS1000_PACE_DATA_WIDTH_MASK (0x000000FFul << 0)
975
976/******************************************************************************/
977/* Frame Header - Read Data Frames Register */
978/******************************************************************************/
979/* Header marker, set to 1 for the header */
980#define ADAS1000_FRAMES_MARKER (1ul << 31)
981/* Ready bit indicates if ECG frame data is calculated and
982 ready for reading.
983 0 = Ready, data frame follows
984 1 = Busy */
985#define ADAS1000_FRAMES_READY_BIT (1ul << 30)
986/* Overflow bits indicate that since the last frame read,
987 a number of frames have been missed. This field saturates
988 at the maximum count. The data in the frame including
989 this header word is valid but old if the overflow bits
990 are > 0. When using Skip mode (FRMCTL register (0x0A)[3:2]),
991 the Overflow bit acts as a flag, where a non-zero value
992 indicates an overflow.
993 00 = 0 missed
994 01 = 1 frame missed
995 10 = 2 frames missed
996 11 = 3 or more frames missed */
997#define ADAS1000_FRAMES_OVERFLOW (1ul << 28)
998/* Internal device error detected.
999 0 = normal operation
1000 1 = error condition */
1001#define ADAS1000_FRAMES_FAULT (1ul << 27)
1002/* PACE 3 Indicates Pacing Artifact was qualified at most
1003 recent point.
1004 0 = No Pacing Artifact
1005 1 = Pacing Artifact Present */
1006#define ADAS1000_FRAMES_PACE3_DETECTED (1ul << 26)
1007/* PACE 2 Indicates Pacing Artifact was qualified at most
1008 recent point.
1009 0 = No Pacing Artifact
1010 1 = Pacing Artifact Present */
1011#define ADAS1000_FRAMES_PACE2_DETECTED (1ul << 25)
1012/* PACE 1 Indicates Pacing Artifact was qualified at most
1013 recent point.
1014 0 = No Pacing Artifact
1015 1 = Pacing Artifact Present */
1016#define ADAS1000_FRAMES_PACE1_DETECTED (1ul << 24)
1017/* 0 = no new respiration data
1018 1 = respiration data updated */
1019#define ADAS1000_FRAMES_RESPIRATION (1ul << 23)
1020/* If both DC & AC leads off are enabled, this bit is the
1021 OR of all the AC leads off detect flags. If only AC or
1022 DC leads off is enabled (but not both, this bit reflects
1023 the OR of all DC & AC leads off flags.
1024 0 = all leads connected
1025 1 = one or more leads off detected */
1026#define ADAS1000_FRAMES_LEADS_OFF_DETECTED (1ul << 22)
1027/* 0 = all leads connected
1028 1 = one or more leads off detected */
1029#define ADAS1000_FRAMES_DC_LEADS_OFF_DETECTED (1ul << 21)
1030/* 0 = ADC within range
1031 1 = ADC out of range */
1032#define ADAS1000_FRAMES_ADC_OUT_OF_RANGE (1ul << 20)
1033/******************************************************************************/
1034/* Frame CRC Register */
1035/******************************************************************************/
1036/* Cyclic Redundancy Check */
1037#define ADAS1000_CRC_MASK (0x00FFFFFF << 0)
1038
1039/******************************************************************************/
1040/* ADAS1000 data rates, word sizes and frame size */
1041/******************************************************************************/
1042#define ADAS1000_31_25HZ_FRAME_RATE 3125
1043#define ADAS1000_2KHZ_FRAME_RATE 2000
1044#define ADAS1000_16KHZ_FRAME_RATE 16000
1045#define ADAS1000_128KHZ_FRAME_RATE 128000
1046
1047#define ADAS1000_31_25HZ_WORD_SIZE 32
1048#define ADAS1000_2KHZ_WORD_SIZE 32
1049#define ADAS1000_16KHZ_WORD_SIZE 32
1050#define ADAS1000_128KHZ_WORD_SIZE 16
1051
1052#define ADAS1000_31_25HZ_FRAME_SIZE 12
1053#define ADAS1000_2KHZ_FRAME_SIZE 12
1054#define ADAS1000_16KHZ_FRAME_SIZE 12
1055#define ADAS1000_128KHZ_FRAME_SIZE 15
1056
1057/******************************************************************************/
1058/* ADAS1000 CRC constants */
1059/******************************************************************************/
1060#define CRC_POLY_2KHZ_16KHZ 0x005D6DCBul
1061#define CRC_CHECK_CONST_2KHZ_16KHZ 0x0015A0BAul
1062
1063#define CRC_POLY_128KHZ 0x00001021ul
1064#define CRC_CHECK_CONST_128KHz 0x00001D0Ful
1065
1076
1083
1097
1100 uint32_t *spi_freq);
1101
1102/* Initializes the communication with ADAS1000 and checks if the device is present.*/
1103int32_t adas1000_init(struct adas1000_dev **device,
1104 const struct adas1000_init_param *init_param);
1105
1106/* Reads the value of a ADAS1000 register */
1107int32_t adas1000_read(struct adas1000_dev *device, uint8_t reg_addr,
1108 uint32_t *reg_data);
1109
1110/* Writes a value into a ADAS1000 register */
1111int32_t adas1000_write(struct adas1000_dev *device, uint8_t reg_addr,
1112 uint32_t reg_data);
1113
1114/* Performs a software reset of the ADAS1000 */
1115int32_t adas1000_soft_reset(struct adas1000_dev *device);
1116
1117/* Compute frame size. */
1119
1120/* Selects which words are not included in a data frame */
1122 uint32_t words_mask);
1123
1124/* Sets the frame rate */
1125int32_t adas1000_set_frame_rate(struct adas1000_dev *device, uint32_t rate);
1126
1127/* Reads the specified number of frames */
1128int32_t adas1000_read_data(struct adas1000_dev *device, uint8_t *data_buff,
1129 uint32_t frame_cnt, struct read_param *read_data_param);
1130
1131/* Computes the CRC for a frame */
1133 uint8_t *buff);
1134
1135#endif /* _ADAS1000_H_ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int32_t adas1000_set_inactive_framewords(struct adas1000_dev *device, uint32_t words_mask)
Selects which words are not included in a data frame.
Definition adas1000.c:232
int32_t adas1000_read_data(struct adas1000_dev *device, uint8_t *data_buff, uint32_t frame_cnt, struct read_param *read_data_param)
Reads the specified number of frames.
Definition adas1000.c:318
int32_t adas1000_read(struct adas1000_dev *device, uint8_t reg_addr, uint32_t *reg_data)
Read device register.
Definition adas1000.c:134
int32_t adas1000_write(struct adas1000_dev *device, uint8_t reg_addr, uint32_t reg_data)
Write device register.
Definition adas1000.c:163
int32_t adas1000_init(struct adas1000_dev **device, const struct adas1000_init_param *init_param)
Initializes the SPI communication with ADAS1000. The ADAS1000 is configured with the specified frame ...
Definition adas1000.c:87
int32_t adas1000_soft_reset(struct adas1000_dev *device)
Software reset of the device.
Definition adas1000.c:182
int32_t adas1000_set_frame_rate(struct adas1000_dev *device, uint32_t rate)
Sets the frame rate.
Definition adas1000.c:270
int32_t adas1000_compute_spi_freq(struct adas1000_init_param *init_param, uint32_t *spi_freq)
Preliminary function which computes the spi frequency based on the frame rate value passed input para...
Definition adas1000.c:49
uint32_t adas1000_compute_frame_crc(struct adas1000_dev *device, uint8_t *buff)
Computes the CRC for a frame.
Definition adas1000.c:395
int32_t adas1000_compute_frame_size(struct adas1000_dev *device)
Compute frame size.
Definition adas1000.c:199
Header file of SPI Interface.
Definition adas1000.h:1066
struct no_os_spi_desc * spi_desc
Definition adas1000.h:1068
uint32_t inactive_words_no
Definition adas1000.h:1074
uint32_t frame_size
Definition adas1000.h:1070
uint32_t frame_rate
Definition adas1000.h:1072
Definition adas1000.h:1077
struct no_os_spi_init_param spi_init
Definition adas1000.h:1079
uint32_t frame_rate
Definition adas1000.h:1081
Definition ad9361_util.h:63
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128
Definition adas1000.h:1084
bool stop_read
Definition adas1000.h:1089
bool start_read
Definition adas1000.h:1086
bool ready_repeat
Definition adas1000.h:1095
bool wait_for_ready
Definition adas1000.h:1092