Skip to content
Snippets Groups Projects
Select Git revision
  • 132cea3e09a04ff01561a37b367c9e394fb61609
  • MCCS-163 default
  • main
  • sar-277-update-docs-with-examples-for-lrc
  • st-946-automate
  • sar_302-log-fix
  • sar-287_subarray_commands_to_lrc
  • sar_302-POC_await_sub_device_state
  • sat_302_fix_pipelines
  • sar-286_lrc_one_subarry_command
  • sar-286_lrc_improvements
  • sar-288-async-controller
  • sar-276-combine-tango-queue
  • sar-255_remove_nexus_reference
  • sar-275-add-LRC
  • sar-273-add-lrc-attributes
  • sar-272
  • sp-1106-marvin-1230525148-ska-tango-base
  • sp-1106-marvin-813091765-ska-tango-base
  • sar-255/Publish-package-to-CAR
  • mccs-661-device-under-test-fixture
  • mccs-659-pep257-docstring-linting
  • 0.11.3
  • 0.11.2
  • 0.11.1
  • 0.11.0
  • 0.10.1
  • 0.10.0
  • 0.9.1
  • 0.9.0
  • 0.8.1
  • 0.8.0
  • 0.7.2
  • 0.7.1
  • 0.7.0
  • 0.6.6
  • 0.6.5
  • 0.6.4
  • 0.6.3
  • 0.6.2
  • 0.6.1
  • 0.6.0
42 results

task_queue_manager.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    spibitbang1.cpp 1.90 KiB
    #include "spibitbang1.h"
    #include "../apsctl/conf.h"
    #include <iostream>
    
    
    c_spibitbang1::c_spibitbang1(const t_driver config1) : drvbase (config1){
      CLK=config1.devreg[0];
      SDIO=config1.devreg[1];
      SDIOdir=config1.devreg[2];
      CS=config1.devreg[3];
      CLKpin=config1.parameters[0];
      SDIOpin=config1.parameters[1];
      CSpin=config1.parameters[2];
    };
    
    bool c_spibitbang1::I2Csend(int addr,int reg,int len,t_buffer* data,int direction){
      t_buffer bit[1]={0};
      if (direction==0) {  //Send
        int data2 = ( 0x00 << 23 ) + ( 0x00 << 21 ) + ( reg << 8 ) + data[0];
        std::cout << "SPI send" << data2 << "\n";          
        bit[0]={0};parent->seti2c(CS,1,CSpin,bit);
        for (int x=0;x<32;x++)
        {
          bit[0]=(data2>>(31-x)) & 1;  //Not that efficient, but works
          parent->seti2c(SDIO,1,SDIOpin,bit);
          bit[0]={1};parent->seti2c(CLK,1,CLKpin,bit);
          bit[0]={0};parent->seti2c(CLK,1,CLKpin,bit);
        }
        bit[0]={1};parent->seti2c(CS,1,CSpin,bit);
        bit[0]={1};parent->seti2c(SDIO,1,SDIOpin,bit);
      } else {
        int data2 = ( 0x01 << 15) + ( 0x00 << 13 ) + reg;
        bit[0]={0};parent->seti2c(CLK,1,CLKpin,bit);
        bit[0]={0};parent->seti2c(CS,1,CSpin,bit);//enable
        for (int x=0;x<16;x++){
          bit[0]={0};parent->seti2c(CLK,1,CLKpin,bit);
          bit[0]=(data2>>(15-x)) & 1;  //Not that efficient, but works
          parent->seti2c(SDIO,1,SDIOpin,bit);
          bit[0]={1};parent->seti2c(CLK,1,CLKpin,bit);
        }
        bit[0]=1;parent->seti2c(SDIOdir,1,SDIOpin,bit);
        bit[0]=0;parent->seti2c(CLK,1,CLKpin,bit);
    
        data2=0;
        for (int x=0;x<8;x++){
            parent->geti2c(SDIO,1,SDIOpin,bit);
            data2<<=2;
            data2+=bit[0];
            bit[0]=1;parent->seti2c(CLK,1,CLKpin,bit);
            bit[0]=0;parent->seti2c(CLK,1,CLKpin,bit);
          }
    
        bit[0]=1;parent->seti2c(CS,1,CSpin,bit);//disable
        bit[0]=1;parent->seti2c(SDIO,1,SDIOpin,bit);
        bit[0]=0;parent->seti2c(SDIOdir,1,SDIOpin,bit);
    
      }
      return true;
    }