PRU driver for the ADS131EXX ADC/AFE IC from Texas Instrument
Includes:
- PRU SPI driver driver (
spi.inc
) that can be used independently (follow steps 1 and 2 below) - Main definitions of the ADS131EXX IC (
ads131_defs.inc
) - Driver for the ADS131E08 (8 channels version of the IC,
ads131e08.inc
)
- Define
SPI_SCLK
,SPI_MOSI
,SPI_MISO
, andSPI_CS
pins. For instance,
SPI_SCLK .set 5 ; PRU1_5 GPIO2_11 P8_42
SPI_MOSI .set 0 ; PRU1_0 GPIO2_6 P8_45
SPI_MISO .set 3 ; PRU1_3 GPIO2_9 P8_44
SPI_CS .set 7 ; PRU1_7 GPIO2_13 P8_40
- Define
SPI_SCLK_DELAY
to set the SPI clock frequency using the formulaSPI_SCLK_DELAY = floor( (t_SCLK / 5 ns) / 4 )
andSPI_SCLK_DELAY >= 3
, wheret_SCLK
is the SPI clock period. For instance,
SPI_SCLK_DELAY .set 9
- Define
ADS_START
,ADS_RESET
, andADS_DRDY
pins. For instance,
ADS_START .set 4 ; PRU1_4 GPIO2_10 P8_41
ADS_RESET .set 2 ; PRU1_2 GPIO2_8 P8_43
ADS_DRDY .set 1 ; PRU1_1 GPIO2_7 P8_46
- Include the
ads131e08.inc
:
.include "ads131e08.inc"
SPI_TX
: Transmit byte fromspi_tx_reg
- Arguments:
spi_tx_reg
(input, register): register holding the byte to transmit (e.g.,r1.b0
)
- Side effects:
- Modifies
r29
- Modifies
- Arguments:
SPI_RX
: Receive byte intospi_rx_reg
- Arguments:
spi_rx_reg
(output, register): register byte in which to record received data (e.g.,r1.b0
)
- Side effects:
- Modifies
r29
- Modifies
- Arguments:
NOP
: No operation (not in the PRU assembly language)- Arguments: none
- Side effects: none
SPI_WAIT
: Pauses for2*spi_wait_delay - spi_wait_stop_early
instructions (5 ns each)- Arguments:
spi_wait_delay
(input, immediate)spi_wait_stop_early
(input, immediate)
- Side effects:
- Modifies
r29
- Modifies
- Arguments:
LBIT
: Load bitlbit_bit1
of registerlbit_reg1
to bitlbit_bit2
of registerlbit_reg2
- Arguments:
lbit_reg1
(input, register): Source registerlbit_bit1
(input, immediate): Source register bitlbit_reg2
(output, register): Destination registerlbit_bit2
(output, immediate): Destination register bit
- Side effects: none
- Arguments:
SPI_TX_CLK
: SPI clock pulse during data transmission- Arguments: none
- Side effects:
- Modifies
r29
- Modifies
SPI_RX_CLK
: SPI clock pulse during data reception- Arguments: none
- Side effects:
- Modifies
r29
- Modifies
ADS_WAIT
: Pauses for2*ads_wait_n
instructions (5 ns each)- Arguments:
ads_wait_n
(input, immediate)
- Side effects:
- Modifies
r28
- Modifies
- Arguments:
ADS_STARTUP
: Start up routine of the ADS131 IC (stops conversion, resets IC, stop continuous data conversion)- Arguments: none
- Side effects:
- Modifies
r28
- Modifies
ADS_SEND_CMD
: Send commandads_send_cmd_command
to ADS131- Arguments
ads_send_cmd_command
(input, immediate):
- Side effects:
- Modifies
r28
- Modifies
- Arguments
ADS_WRITE_REG
: Writeads_write_reg_data
to ADS131 registerads_write_reg_addr
- Arguments:
ads_write_reg_addr
(input, immediate): ADS131 register addressads_write_reg_data
(input, immediate): Data to be written in ADS131 register
- Side effects:
- Modifies
r28
- Modifies
- Arguments:
ADS_READ_REG
: Read ADS131 registerads_read_reg_addr
intoads_read_reg_data
- Arguments:
ads_read_reg_addr
(input, immediate): ADS131 register addressads_read_reg_data
(output, register byte): Register byte to save ADS131 register data (e.g.,r1.b0
)
- Side effects:
- Modifies
r28
- Modifies
- Arguments:
ADS_GET_DATA16
: Receive data packet from ADS131- Arguments:
ads_get_data16_reg1
(output, register): Register containingSTATUS
packet (24 bits)ads_get_data16_reg2
(output, register): Register containing data from channel 1 (.b3
and.b2
) and channel 2 (.b1
and.b0
)ads_get_data16_reg3
(output, register): Register containing data from channel 3 (.b3
and.b2
) and channel 4 (.b1
and.b0
)ads_get_data16_reg4
(output, register): Register containing data from channel 5 (.b3
and.b2
) and channel 6 (.b1
and.b0
)ads_get_data16_reg5
(output, register): Register containing data from channel 7 (.b3
and.b2
) and channel 8 (.b1
and.b0
)
- Side effects:
- Modifies
r28
- Modifies
- Arguments:
ADS_READ_ALL
: Read in all ADS131 registers in a single call- Arguments:
ads_read_all_id (output, register)
: Register byte containing ADS131 registerID
ads_read_all_config1 (output, register)
: Register byte containing ADS131 registerCONFIG1
ads_read_all_config2 (output, register)
: Register byte containing ADS131 registerCONFIG2
ads_read_all_config3 (output, register)
: Register byte containing ADS131 registerCONFIG3
ads_read_all_fault (output, register)
: Register byte containing ADS131 registerFAULT
ads_read_all_ch1set (output, register)
: Register byte containing ADS131 registerCH1SET
ads_read_all_ch2set (output, register)
: Register byte containing ADS131 registerCH2SET
ads_read_all_ch3set (output, register)
: Register byte containing ADS131 registerCH3SET
ads_read_all_ch4set (output, register)
: Register byte containing ADS131 registerCH4SET
ads_read_all_ch5set (output, register)
: Register byte containing ADS131 registerCH5SET
ads_read_all_ch6set (output, register)
: Register byte containing ADS131 registerCH6SET
ads_read_all_ch7set (output, register)
: Register byte containing ADS131 registerCH7SET
ads_read_all_ch8set (output, register)
: Register byte containing ADS131 registerCH8SET
ads_read_all_fault_statp (output, register)
: Register byte containing ADS131 registerSTAT_P
ads_read_all_fault_statn (output, register)
: Register byte containing ADS131 registerSTAT_N
ads_read_all_gpio (output, register)
: Register byte containing ADS131 registerGPIO
- Side effects:
- Modifies
r28
- Modifies
- Arguments:
ADS_INIT
: Initializes the SPI driver interface. To save memory, the ADS131 driver uses jumps (JMP) to callSPI_RX
andSPI_TX
as if they were functions instead of using inline code. The input toSPI_TX
and the output ofSPI_RX
must be saved inr28.b0
and the return address must be inr28.w2
- Arguments: none
- Side effects:
- Modifies
r28
- Modifies