Example #1
0
    def ADS1256_Read_data(self, reg):
        config.digital_write(self.cs_pin, GPIO.LOW)  #cs  0
        config.spi_writebyte([CMD['CMD_RREG'] | reg, 0x00])
        data = config.spi_readbytes(1)
        config.digital_write(self.cs_pin, GPIO.HIGH)  #cs 1

        return data
Example #2
0
    def ADS1256_ConfigADC(self, gain, drate):
        self.ADS1256_WaitDRDY()
        buf = [0, 0, 0, 0]
        buf[0] = (0 << 3) | (1 << 2) | (0 << 1)
        buf[1] = 0x08
        buf[2] = (0 << 5) | (0 << 3) | (gain << 0)
        buf[3] = drate

        config.digital_write(self.cs_pin, GPIO.LOW)  #cs  0
        config.spi_writebyte([CMD['CMD_WREG'] | 0, 0x03])
        config.spi_writebyte(buf)

        config.digital_write(self.cs_pin, GPIO.HIGH)  #cs 1
        config.delay_ms(1)
Example #3
0
    def ADS1256_Read_ADC_Data(self):
        self.ADS1256_WaitDRDY()
        config.digital_write(self.cs_pin, GPIO.LOW)  #cs  0
        config.spi_writebyte([CMD['CMD_RDATA']])
        buf = config.spi_readbytes(3)

        read = 0
        read = (buf[0] << 16) & 0xff0000
        read |= (buf[1] << 8) & 0xff00
        read |= (buf[2]) & 0xff
        config.digital_write(self.cs_pin, GPIO.HIGH)  #cs 1
        if (read & 0x800000):
            read |= 0xFF000000

        return read
Example #4
0
 def ADS1256_WriteReg(self, reg, data):
     config.digital_write(self.cs_pin, GPIO.LOW)  #cs  0
     config.spi_writebyte([CMD['CMD_WREG'] | reg, 0x00, data])
     config.digital_write(self.cs_pin, GPIO.HIGH)  #cs 1
Example #5
0
 def ADS1256_WriteCmd(self, reg):
     config.digital_write(self.cs_pin, GPIO.LOW)  #cs  0
     config.spi_writebyte([reg])
     config.digital_write(self.cs_pin, GPIO.HIGH)  #cs 1
Example #6
0
 def ADS1256_reset(self):
     config.digital_write(self.rst_pin, GPIO.HIGH)
     config.delay_ms(200)
     config.digital_write(self.rst_pin, GPIO.LOW)
     config.delay_ms(200)
     config.digital_write(self.rst_pin, GPIO.HIGH)