예제 #1
0
void core2(void){
	// Initialisation(s)
	communicationInit();
	fifoInit(FIFO_Head_broadcastOutput_en__1, 32*sizeof(char), NULL, 0);
	cache_wbInv(FIFO_Head_broadcastOutput_en__1, 32*sizeof(char));

	// Begin the execution loop 
	while(1){
		busy_barrier();
		cache_inv(FIFO_Head_broadcastOutput_en__1, 32*sizeof(char));
		fifoPop(init_out__runningTotal__5, FIFO_Head_broadcastOutput_en__1, 32*sizeof(char), NULL, 0);
		cache_wbInv(accumulateMatrices_0_init_ru__0, 32*sizeof(char));
		sendStart(7); // Core2 > Core7: accumulateMatrices_0_init_ru__0 
		sendEnd(); // Core2 > Core7: accumulateMatrices_0_init_ru__0 
		receiveStart(); // Core5 > Core2: accumulateMatrices_2_init_ru__0 
		receiveEnd(5); // Core5 > Core2: accumulateMatrices_2_init_ru__0 
		cache_inv(accumulateMatrices_2_init_ru__0, 32*sizeof(char));
		receiveStart(); // Core7 > Core2: explode_generateMatrices_sta__0 
		receiveEnd(7); // Core7 > Core2: explode_generateMatrices_sta__0 
		cache_inv(explode_generateMatrices_sta__0, 32*sizeof(char));
		add(8/*rows*/,8/*columns*/,init_out__runningTotal__0,startArray_16__inputArray__0,output__input_16__0); // accumulateMatrices_2
		cache_inv(init_out__runningTotal__0, 8*sizeof(long));
		cache_inv(startArray_16__inputArray__0, 8*sizeof(long));
		cache_wbInv(accumulateMatrices_2__implod__0, 32*sizeof(char));
		sendStart(7); // Core2 > Core7: accumulateMatrices_2__implod__0 
		sendEnd(); // Core2 > Core7: accumulateMatrices_2__implod__0 
		receiveStart(); // Core7 > Core2: broadcastOutput__broadcastOu__3 
		receiveEnd(7); // Core7 > Core2: broadcastOutput__broadcastOu__3 
		cache_inv(broadcastOutput__broadcastOu__3, 32*sizeof(char));
		fifoPush(output1_24__end_in__0, FIFO_Head_broadcastOutput_en__3, 32*sizeof(char), NULL, 0);
		cache_wbInv(FIFO_Head_broadcastOutput_en__3, 32*sizeof(char));
		cache_inv(output1_24__end_in__0, 8*sizeof(long));
	}
}
예제 #2
0
void cmd_write(void) {
  // Аргументы
  recvBin((uint8_t*)&fs_wtotal, 2); 

  // Ответ
  sendStart(ERR_WAIT);
           
  // Конец файла
  if(fs_wtotal==0) {
    fs_write_eof();
    lastError = ERR_OK_CMD;
    return;
  }
  
  // Запись данных
  do {
    if(fs_write_start()) return;

    // Принимаем от компьюетра блок данных
    send(ERR_OK_WRITE);
    sendBin((uint8_t*)&fs_file_wlen, 2);
    recvStart();    
    recvBin(fs_file_wbuf, fs_file_wlen);
    sendStart(ERR_WAIT);

    if(fs_write_end()) return;
  } while(fs_wtotal);

  lastError = ERR_OK_CMD;
}
예제 #3
0
void cmd_move(void) {
  recvString();
  sendStart(ERR_WAIT);
  fs_openany();
  sendStart(ERR_OK_WRITE);
  recvStart();
  recvString();
  sendStart(ERR_WAIT);
  if(!lastError) fs_move0();
  if(!lastError) lastError = ERR_OK_CMD;
}
bool SoftwareI2CPort::_read(uint8_t u8SlaveAddress, void* pData, uint16_t u16Size, bool holdLow)
{
    uint8_t * transfer_data = reinterpret_cast<uint8_t *>(pData);

    m_scl.setDirection(GpioPin::kInput);
    m_sda.setDirection(GpioPin::kInput);

    m_scl.clear();
    m_sda.clear();

    sendStart();

    bool ret = sendByte((u8SlaveAddress << 1) | 0x01, true);
    if (!ret)
    {
        sendStop();
    
        return ret;
    }

    while (u16Size--)
    {
        // The last byte in the transfer must NAK the byte.  This tells
        // the slave device that the transfer is finished.
        bool isLast = (u16Size == 0);
        *transfer_data++ = readByte(!isLast, (isLast && holdLow));
    }

    sendStop();

    return true;
}
예제 #5
0
void cmd_open(void) {
  uint8_t mode;
 
  /* Принимаем режим */
  mode = wrecv();    

  // Принимаем имя файла
  recvString();

  // Режим передачи и подтверждение
  sendStart(ERR_WAIT);

  // Открываем/создаем файл/папку
  if(mode == O_SWAP) {
    fs_swap();
  } else
  if(mode == O_DELETE) {
    fs_delete();
  } else
  if(mode == O_OPEN) {
    fs_open();
  } else 
  if(mode < 3) {
    fs_open0(mode);
  } else {
    lastError = ERR_INVALID_COMMAND;
  }

  // Ок
  if(!lastError) lastError = ERR_OK_CMD;
}
예제 #6
0
파일: main.c 프로젝트: conorpp/school
/*
 Write a value to a register on ADXL345
 */
void accelWriteReg(const Accel *a, int reg, BYTE val){
    int I2C = a->I2C;
    sendStart(I2C);                 // start transaction
    sendByte(I2C, a->write);        // write accel device
    sendByte(I2C, reg);             // accel device register
    sendByte(I2C, val);             // value
    I2CStop(I2C);
}
예제 #7
0
void cmd_ver(void) {
  sendStart(1);
    
  // Версия + Производитель
  //sendBinf(PSTR("V1.0 10-05-2014 "), 16);
  sendBinf(PSTR("V1.1 RK86-SRAM  "), 16);
              //0123456789ABCDEF
}
예제 #8
0
void cmd_exec(void) {     
  // Прием имени файла
  recvString();

  // Режим передачи и подтверждение
  sendStart(ERR_WAIT);
  if(lastError) return; // Переполнение строки
  
  cmd_boot_exec();    
}
예제 #9
0
파일: main.c 프로젝트: conorpp/school
/*
 Reads a value from a ADXL345 register and returns it
 */
unsigned int accelReadReg(const Accel *a, int reg){
    int I2C = a->I2C;
    sendStart(I2C);                 // start transaction
    sendByte(I2C, a->write);        // write accel device
    sendByte(I2C, reg);             // specify device register
    repeatStart(I2C);
    sendByte(I2C, a->read);         // read accel device
    unsigned int d = readByte(I2C);          // grab data
    I2CAcknowledgeByte(I2C, 0);     // Send nack
    while(!I2CAcknowledgeHasCompleted(I2C));
    I2CStop(I2C);                   // end transaction
    return d;
}
int SoftwareI2CPort::send(uint8_t address, uint32_t subaddress, uint32_t subaddressLength, const void * data, uint32_t dataLength)
{
    fillAddressBuffer(address, subaddress, subaddressLength);
    
    m_scl.setDirection(GpioPin::kInput);
    m_sda.setDirection(GpioPin::kInput);

    m_scl.clear();
    m_sda.clear();

    sendStart();

    bool ret = sendByte((address << 1), true);
    if (!ret)
    {
        sendStop();
    
        return I2C_ERROR_NO_SLAVE_ACK;
    }

    const uint8_t * subaddressData = (const uint8_t *)&m_addressBuffer[1];
    while (subaddressLength--)
    {
        ret = sendByte(*subaddressData++, true);
        if (!ret)
        {
            sendStop();
    
            return I2C_ERROR_GOT_NAK;
        }
    }

    const uint8_t * transfer_data = reinterpret_cast<const uint8_t *>(data);
    uint32_t u16Size = dataLength;
    while (u16Size--)
    {
        ret = sendByte(*transfer_data++, true);
        if (!ret)
        {
            sendStop();
    
            return I2C_ERROR_GOT_NAK;
        }
    }

    sendStop();
    
    return I2C_OK;
}
tHandle cJuryTransmitter::CreateView()
{
    QWidget* pWidget = (QWidget*)m_pViewport->VP_GetWindow();
    m_pWidget = new DisplayWidget(pWidget);

    connect(m_pWidget, SIGNAL(sendNotAus()), this, SLOT(OnNotAus()));
    connect(m_pWidget, SIGNAL(sendStart(tInt16)), this, SLOT(OnStart(tInt16)));
    connect(m_pWidget, SIGNAL(sendStop(tInt16)), this, SLOT(OnStop(tInt16)));
    connect(m_pWidget, SIGNAL(sendReadyRequest(tInt16)), this, SLOT(OnRequestReady(tInt16)));
    connect(this, SIGNAL(sendDriverState(int, int)), m_pWidget, SLOT(OnDriverState(int, int)));
    connect(this, SIGNAL(sendMessage(QString)), m_pWidget, SLOT(OnAppendText(QString)));
    
    
    return (tHandle)m_pWidget;
}
예제 #12
0
    void Client::handleConnect( const ConnectionBase* connection )
    {
      if( m_qRef )
      {
        DNSServiceRefDeallocate( m_qRef );
        m_qRef = 0;
        m_currentRef = 0;
      }

      // printf( "LinkLocal::Client::handleConnect()!!!\n" );
      ConnectionBase* cb = const_cast<ConnectionBase*>( connection );
      gloox::Client::setConnectionImpl( cb );
      gloox::Client::connect( false );
      sendStart( m_to );
    }
예제 #13
0
파일: HMC.cpp 프로젝트: felipehfj/Arduino
// note that you need to wait at least 5ms after power on to initialize
void HMC5843::init()
{
  PORTC = 0b00110000; // Use the internal pull up resistors
  
  // Choose 100KHz for the bus.  Formula from 21.5.2 in ATmega168 datasheet.
  TWSR &= ~((1<<TWPS1)&(1<<TWPS0));
	TWBR = (unsigned char)(F_CPU/200000l-8);
	
	// Put the HMC5843 into continuous mode
	sendStart();
	sendByte(0x3C);
	sendByte(0x02);
	sendByte(0x00);
	sendStop();
	// note that you need to wait 100ms after this before first calling recieve
}
예제 #14
0
파일: HMC.cpp 프로젝트: felipehfj/Arduino
// This can be called at 100ms intervals to get new data
void HMC5843::getValues(int *x, int *y, int *z)
{
  unsigned char xin, yin, zin;
  // start the reading
  sendStart();
  sendByte(0x3D);
  // read out the 3 values, 2 bytes each.  lsb first, then msb.
  xin = receiveByte();
  *x = (xin<<8)|receiveByte();
  yin = receiveByte();
  *y = (yin<<8)|receiveByte();
  zin = receiveByte();
  *z = (zin<<8)|receiveByte();
  // wrap back around for the next set of reads and close
  sendByte(0x3D);
  sendStop();
}
bool SoftwareI2CPort::_write(uint8_t u8SlaveAddress, const void* pData, uint16_t u16Size, bool doSendStart, bool bStop, bool holdLow)
{
    const uint8_t * transfer_data = reinterpret_cast<const uint8_t *>(pData);

    if (doSendStart)
    {
        m_scl.setDirection(GpioPin::kInput);
    }
    m_sda.setDirection(GpioPin::kInput);

    m_scl.clear();
    m_sda.clear();

    if (doSendStart)
    {
        sendStart();
    }

    bool ret = sendByte((u8SlaveAddress << 1), true);
    if (!ret)
    {
        sendStop();
    
        return ret;
    }

    while (u16Size--)
    {
        bool isLast = (u16Size == 0);
        ret = sendByte(*transfer_data++, (isLast && holdLow));
        if (!ret)
        {
            sendStop();
    
            return ret;
        }
    }

    if (bStop)
    {
        sendStop();
    }

    return true;
}
예제 #16
0
void cmd_find(void) {
  WORD n;
  FILINFO2 info;              
  
  // Принимаем путь
  recvString();

  // Принимаем макс кол-во элементов
  recvBin((uint8_t*)&n, 2);

  // Режим передачи и подтверждение
  sendStart(ERR_WAIT);
  if(lastError) return;

  // Открываем папку
  if(buf[0] != ':') {
    if(fs_opendir()) return;
  }

  for(; n; --n) {
    /* Читаем очереной описатель */
    if(fs_readdir()) return;

    /* Конец */
    if(FS_DIRENTRY[0] == 0) {
      lastError = ERR_OK_CMD;
      return;
    }

    /* Сжимаем ответ для компьютера */
    memcpy(info.fname, FS_DIRENTRY+DIR_Name, 12);
    memcpy(&info.fsize, FS_DIRENTRY+DIR_FileSize, 4);
    memcpy(&info.ftimedate, FS_DIRENTRY+DIR_WrtTime, 4);
    //memcpy(memcpy(memcpy(info.fname, FS_DIRENTRY+DIR_Name, 12, FS_DIRENTRY+DIR_FileSize, 4), FS_DIRENTRY+DIR_WrtTime, 4);

    /* Отправляем */
    send(ERR_OK_ENTRY);
    sendBin((uint8_t*)&info, sizeof(info));
    send(ERR_WAIT);
  }

  /* Ограничение по размеру */  
  lastError = ERR_MAX_FILES; /*! Надо опеределать, что бы не было ложных ошибок */
}
예제 #17
0
void cmd_read(void) {
  DWORD s;

  // Длина
  recvBin((uint8_t*)&readLength, 2);

  // Режим передачи и подтверждение
  sendStart(ERR_WAIT);

  // Ограничиваем длину длиной файла
  if(fs_getfilesize()) return;
  s = fs_tmp; 
  if(fs_tell()) return;
  s -= fs_tmp;
                    
  if(readLength > s)
    readLength = (WORD)s;

  // Отправляем все блоки файла
  readInt(/*rks*/0);
}
예제 #18
0
void core2(void){
	// Initialisation(s)
	communicationInit();

	// Begin the execution loop 
	while(1){
		busy_barrier();
		receiveStart(); // Core0 > Core2: explode_generateMatrices_arr__6 
		receiveEnd(0); // Core0 > Core2: explode_generateMatrices_arr__6 
		cache_inv(explode_generateMatrices_arr__6, 32*sizeof(char));
		receiveStart(); // Core7 > Core2: explode_generateMatrices_arr__10 
		receiveEnd(7); // Core7 > Core2: explode_generateMatrices_arr__10 
		cache_inv(explode_generateMatrices_arr__10, 32*sizeof(char));
		add(8/*rowsA*/,8/*columnsA*/,arrayA_40__arrayA__0,arrayB_40__arrayB__0,arrayC__arrayC_40__0); // addMatrices_5
		cache_inv(arrayA_40__arrayA__0, 8*sizeof(long));
		cache_inv(arrayB_40__arrayB__0, 8*sizeof(long));
		cache_wbInv(addMatrices_5__implode_displ__0, 32*sizeof(char));
		sendStart(7); // Core2 > Core7: addMatrices_5__implode_displ__0 
		sendEnd(); // Core2 > Core7: addMatrices_5__implode_displ__0 
	}
}
예제 #19
0
void core6(void){
	// Initialisation(s)
	communicationInit();

	// Begin the execution loop 
	while(1){
		busy_barrier();
		receiveStart(); // Core7 > Core6: broadcastArrayB__multiplyMat__2 
		receiveEnd(7); // Core7 > Core6: broadcastArrayB__multiplyMat__2 
		cache_inv(broadcastArrayB__multiplyMat__2, 67108864*sizeof(char));
		receiveStart(); // Core0 > Core6: explode_generateMatricies_ar__4 
		receiveEnd(0); // Core0 > Core6: explode_generateMatricies_ar__4 
		cache_inv(explode_generateMatricies_ar__4, 8388608*sizeof(char));
		multiply(4096/*rowsA*/,4096/*columnsA*/,4096/*rowsB*/,4096/*columnsB*/,arrayA_6291456__arrayA__0,arrayBOut_50331648__arrayB__0,output__arrayC_6291456__0); // multiplyMatricies_3
		cache_inv(arrayA_6291456__arrayA__0, 2097152*sizeof(long));
		cache_inv(arrayBOut_50331648__arrayB__0, 16777216*sizeof(long));
		cache_wbInv(multiplyMatricies_3__implode__0, 8388608*sizeof(char));
		sendStart(7); // Core6 > Core7: multiplyMatricies_3__implode__0 
		sendEnd(); // Core6 > Core7: multiplyMatricies_3__implode__0 
	}
}
예제 #20
0
void cmd_lseek(void) {
  uint8_t mode;
  DWORD off;

  // Принимаем режим и смещение
  mode = wrecv();    
  recvBin((uint8_t*)&off, 4);    

  // Режим передачи и подтверждение
  sendStart(ERR_WAIT);

  // Размер файла
  if(mode==100) {
    if(fs_getfilesize()) return;
  }

  // Размер диска  
  else if(mode==101) {
    if(fs_gettotal()) return;
  }
 
  // Свободное место на диске
  else if(mode==102) {
    if(fs_getfree()) return;
  }

  else {
    /* Устаналиваем смещение. fs_tmp сохраняется */
    if(fs_lseek(off, mode)) return;
  }

  // Передаем результат
  send(ERR_OK_CMD);
  sendBin((uint8_t*)&fs_tmp, 4);  
  lastError = 0; // На всякий случай, результат уже передан
}
예제 #21
0
bool SVT_Soap::_doFunc(const QString &host, const QString &module, const QString &method, quint32 port, const QMap<QString, QString> *paras, QMap<QString, QString> *retmap){
    if((mFlags&IS_CGDG) ||isSetApi(module,method))
    {
        sendStart(host,port);
    }
    if(retmap)
    {
        retmap->clear();
    }
    const char *cHeadMode="POST /soap/server_sa/ HTTP/1.0\r\n"
            "SOAPAction: urn:NETGEAR-ROUTER:service:%1:1#%2\r\n"
            "content-type: text/xml;charset=utf-8\r\n"
            "HOST: www.routerlogin.com\r\n"
            "User-Agent: SOAP Toolkit 3.0\r\n"
            "connection: keep-Alive\r\n"
            "Cache-Control: no-cache\r\n"
            "Pragma: no-cache\r\n"
            "content-length: %3\r\n\r\n";
    const char *cBodyMode=
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
                "<SOAP-ENV:Envelope xmlns:SOAPSDK1=\"http://www.w3.org/2001/XMLSchema\" "
                    "xmlns:SOAPSDK2=\"http://www.w3.org/2001/XMLSchema-instance\" "
                    "xmlns:SOAPSDK3=\"http://schemas.xmlsoap.org/soap/encoding/\" "
                    "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                        "<SOAP-ENV:Header>"
                            "<SessionID>58DEE6006A88A967E89A</SessionID>"
                        "</SOAP-ENV:Header>"
                        "<SOAP-ENV:Body>"
                            "<M1:%2 xmlns:M1=\"urn:NETGEAR-ROUTER:service:%1:1\">"
            "%3"
                            "</M1:%2>"
                        "</SOAP-ENV:Body>"
                "</SOAP-ENV:Envelope>";
    QString s_para="";
    if(paras)
    {
        QMap<QString, QString>::const_iterator i = paras->begin();
        while (i != paras->end()) {
            s_para+=QString("<%1>%2</%1>").arg(i.key(),i.value());
            ++i;
        }
    }

    QString body=QString(cBodyMode).arg(module,method,s_para);
    QString head=QString(cHeadMode).arg(module,method).arg(body.length());

    if(0==module.compare("ParentalControl",Qt::CaseInsensitive))
    {
        cHeadMode="POST /soap/server_sa/ HTTP/1.0\r\n"
                  "SOAPAction: urn:NETGEAR-ROUTER:service:%1:1#%2\r\n"
                  "content-type: text/xml;charset=utf-8\r\n"
                  "HOST: www.routerlogin.com\r\n"
                  "User-Agent: SOAP Toolkit 3.0\r\n"
                  "connection: keep-Alive\r\n"
                  "Cache-Control: no-cache\r\n"
                  "Pragma: no-cache\r\n"
                  "content-length: %3\r\n\r\n";
        cBodyMode="<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                  "<SOAP-ENV:Header>\n"
                  "<SessionID xsi:type=\"xsd:string\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\">E6A88AE69687E58D9A00</SessionID>\n"
                  "</SOAP-ENV:Header>\n"
                  "<SOAP-ENV:Body>\n"
                  "<%1>\n"
          "%2"
                  "</%1>\n"
                  "</SOAP-ENV:Body>\n"
                  "</SOAP-ENV:Envelope>\n";
        const char *cParaString=" xsi:type=\"xsd:string\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\"";
        s_para="";
        if(paras)
        {
            QMap<QString, QString>::const_iterator i = paras->begin();
            while (i != paras->end()) {
                s_para+=QString("<%1%3>%2</%1>\n").arg(i.key(),i.value(),cParaString);
                ++i;
            }
        }
        body=QString(cBodyMode).arg(method,s_para);
        head=QString(cHeadMode).arg(module,method).arg(body.length());

    }

    SVT_Http http(mExitFlag);
    QByteArray &retarray=http.rawRequest(host,head+body,port);

    qDebug()<<retarray;


    int retv=getRetValue(retarray);
    bool retOk=(200==retv);
    if(retOk && retmap)
    {
        qDebug()<<"start parse";
        QDomDocument doc;
        QByteArray body=SVT_Http::getBody(retarray);

        doc.setContent(body,true);
//        QDomNode root=doc.namedItem()
//        doc.
        //QString tagname=method+"Response";
        QDomNode rnode = doc.firstChild();
        if (!rnode.isElement())
            rnode = rnode.nextSibling();
        parseNode(rnode,retmap);



    }
    if((retOk)&&((mFlags&IS_CGDG) ||isSetApi(module,method)))
    {
        sendFinish(host,port);
    }
    if(!retOk && retmap)
    {
        retmap->insert("error",QString::number(retv));
    }

    return retOk;
}
예제 #22
0
 void Client::handleStartNode( const Tag* start )
 {
   // printf( "LinkLocal::Client::handleStartNode()\n" );
   if( start && !m_streamSent )
     sendStart( start->findAttribute( "from" ) );
 }
예제 #23
0
void core7(void){
	// Initialisation(s)
	communicationInit();
	fifoInit(FIFO_Head_generateMatrices_e__0, 4*sizeof(char), NULL, 0);
	cache_wbInv(FIFO_Head_generateMatrices_e__0, 4*sizeof(char));

	// Begin the execution loop 
	while(1){
		busy_barrier();
		receiveStart(); // Core2 > Core7: accumulateMatrices_0_init_ru__0 
		receiveEnd(2); // Core2 > Core7: accumulateMatrices_0_init_ru__0 
		cache_inv(accumulateMatrices_0_init_ru__0, 32*sizeof(char));
		cache_inv(FIFO_Head_generateMatrices_e__0, 4*sizeof(char));
		fifoPop(init_out__countIn__0, FIFO_Head_generateMatrices_e__0, 4*sizeof(char), NULL, 0);
		cache_wbInv(generateMatrices_init_countI__0, 4*sizeof(char));
		sendStart(0); // Core7 > Core0: generateMatrices_init_countI__0 
		sendEnd(); // Core7 > Core0: generateMatrices_init_countI__0 
		receiveStart(); // Core0 > Core7: generateMatrices__explode_ge__0 
		receiveEnd(0); // Core0 > Core7: generateMatrices__explode_ge__0 
		cache_inv(generateMatrices__explode_ge__0, 256*sizeof(char));
		// Fork explode_generateMatrices_startArray
		{
			cache_wb(startArray__inputArray__0, 64*sizeof(long));
			memcpy((void*)(startArray_8__inputArray__0+0),(void*)( startArray__inputArray__0+8), 8*sizeof(long));
			memcpy((void*)(startArray_16__inputArray__0+0),(void*)( startArray__inputArray__0+16), 8*sizeof(long));
			memcpy((void*)(startArray_24__inputArray__0+0),(void*)( startArray__inputArray__0+24), 8*sizeof(long));
			memcpy((void*)(startArray_40__inputArray__0+0),(void*)( startArray__inputArray__0+40), 8*sizeof(long));
			memcpy((void*)(startArray_48__inputArray__0+0),(void*)( startArray__inputArray__0+48), 8*sizeof(long));
			memcpy((void*)(startArray_56__inputArray__0+0),(void*)( startArray__inputArray__0+56), 8*sizeof(long));
		}
		cache_wb(((char*)startArray__inputArray__0) + 0, 32);
		cache_wb(((char*)startArray__inputArray__0) + 128, 32);
		cache_inv(startArray__inputArray__0, 64*sizeof(long));
		cache_wbInv(explode_generateMatrices_sta__7, 32*sizeof(char));
		sendStart(3); // Core7 > Core3: explode_generateMatrices_sta__7 
		sendEnd(); // Core7 > Core3: explode_generateMatrices_sta__7 
		cache_wbInv(explode_generateMatrices_sta__3, 32*sizeof(char));
		sendStart(6); // Core7 > Core6: explode_generateMatrices_sta__3 
		sendEnd(); // Core7 > Core6: explode_generateMatrices_sta__3 
		cache_wbInv(explode_generateMatrices_sta__6, 32*sizeof(char));
		sendStart(0); // Core7 > Core0: explode_generateMatrices_sta__6 
		sendEnd(); // Core7 > Core0: explode_generateMatrices_sta__6 
		cache_wbInv(explode_generateMatrices_sta__1, 32*sizeof(char));
		sendStart(4); // Core7 > Core4: explode_generateMatrices_sta__1 
		sendEnd(); // Core7 > Core4: explode_generateMatrices_sta__1 
		cache_wbInv(explode_generateMatrices_sta__4, 32*sizeof(char));
		sendStart(1); // Core7 > Core1: explode_generateMatrices_sta__4 
		sendEnd(); // Core7 > Core1: explode_generateMatrices_sta__4 
		cache_wbInv(explode_generateMatrices_sta__0, 32*sizeof(char));
		sendStart(2); // Core7 > Core2: explode_generateMatrices_sta__0 
		sendEnd(); // Core7 > Core2: explode_generateMatrices_sta__0 
		cache_wbInv(explode_generateMatrices_sta__5, 32*sizeof(char));
		sendStart(5); // Core7 > Core5: explode_generateMatrices_sta__5 
		sendEnd(); // Core7 > Core5: explode_generateMatrices_sta__5 
		add(8/*rows*/,8/*columns*/,init_out__runningTotal__5,startArray_0__inputArray__0,output__input_0__0); // accumulateMatrices_0
		cache_inv(init_out__runningTotal__5, 8*sizeof(long));
		cache_inv(startArray_0__inputArray__0, 8*sizeof(long));
		receiveStart(); // Core5 > Core7: accumulateMatrices_1__implod__0 
		receiveEnd(5); // Core5 > Core7: accumulateMatrices_1__implod__0 
		cache_inv(accumulateMatrices_1__implod__0, 32*sizeof(char));
		receiveStart(); // Core2 > Core7: accumulateMatrices_2__implod__0 
		receiveEnd(2); // Core2 > Core7: accumulateMatrices_2__implod__0 
		cache_inv(accumulateMatrices_2__implod__0, 32*sizeof(char));
		receiveStart(); // Core1 > Core7: accumulateMatrices_3__implod__0 
		receiveEnd(1); // Core1 > Core7: accumulateMatrices_3__implod__0 
		cache_inv(accumulateMatrices_3__implod__0, 32*sizeof(char));
		receiveStart(); // Core4 > Core7: accumulateMatrices_4__implod__0 
		receiveEnd(4); // Core4 > Core7: accumulateMatrices_4__implod__0 
		cache_inv(accumulateMatrices_4__implod__0, 32*sizeof(char));
		receiveStart(); // Core0 > Core7: accumulateMatrices_5__implod__0 
		receiveEnd(0); // Core0 > Core7: accumulateMatrices_5__implod__0 
		cache_inv(accumulateMatrices_5__implod__0, 32*sizeof(char));
		receiveStart(); // Core6 > Core7: accumulateMatrices_6__implod__0 
		receiveEnd(6); // Core6 > Core7: accumulateMatrices_6__implod__0 
		cache_inv(accumulateMatrices_6__implod__0, 32*sizeof(char));
		receiveStart(); // Core3 > Core7: accumulateMatrices_7__implod__0 
		receiveEnd(3); // Core3 > Core7: accumulateMatrices_7__implod__0 
		cache_inv(accumulateMatrices_7__implod__0, 32*sizeof(char));
		// Join implode_broadcastOutput_input
		{
			cache_wb(output__input_0__0, 8*sizeof(long));
			memcpy((void*)(output__input__0+8),(void*)( output__input_8__0+0), 8*sizeof(long));
			memcpy((void*)(output__input__0+16),(void*)( output__input_16__0+0), 8*sizeof(long));
			memcpy((void*)(output__input__0+24),(void*)( output__input_24__0+0), 8*sizeof(long));
			cache_wb(output__input_32__0, 8*sizeof(long));
			memcpy((void*)(output__input__0+40),(void*)( output__input_40__0+0), 8*sizeof(long));
			memcpy((void*)(output__input__0+48),(void*)( output__input_48__0+0), 8*sizeof(long));
			memcpy((void*)(output__input__0+56),(void*)( output__input_56__0+0), 8*sizeof(long));
		}
		cache_wb(((char*)output__input_0__0) + 0, 32);
		cache_inv(output__input_0__0, 8*sizeof(long));
		cache_inv(output__input_8__0, 8*sizeof(long));
		cache_inv(output__input_16__0, 8*sizeof(long));
		cache_inv(output__input_24__0, 8*sizeof(long));
		cache_wb(((char*)output__input_32__0) + 0, 32);
		cache_inv(output__input_32__0, 8*sizeof(long));
		cache_inv(output__input_40__0, 8*sizeof(long));
		cache_inv(output__input_48__0, 8*sizeof(long));
		cache_inv(output__input_56__0, 8*sizeof(long));
		// Broadcast broadcastOutput
		{
			cache_wb(output__input__0, 64*sizeof(long));
			memcpy((void*)(output1_8__end_in__0+0),(void*)( output__input__0+0), 8*sizeof(long));
			memcpy((void*)(output1_40__end_in__0+0),(void*)( output__input__0+8), 8*sizeof(long));
			memcpy((void*)(output1_32__end_in__0+0),(void*)( output__input__0+16), 8*sizeof(long));
			memcpy((void*)(output1_16__end_in__0+0),(void*)( output__input__0+24), 8*sizeof(long));
			memcpy((void*)(output1_0__end_in__0+0),(void*)( output__input__0+32), 8*sizeof(long));
			memcpy((void*)(output1_24__end_in__0+0),(void*)( output__input__0+40), 8*sizeof(long));
			memcpy((void*)(output1_48__end_in__0+0),(void*)( output__input__0+48), 8*sizeof(long));
			memcpy((void*)(output1_56__end_in__0+0),(void*)( output__input__0+56), 8*sizeof(long));
		}
		cache_wb(((char*)output__input__0) + 0, 256);
		cache_inv(output__input__0, 64*sizeof(long));
		cache_wbInv(broadcastOutput__broadcastOu__0, 32*sizeof(char));
		sendStart(1); // Core7 > Core1: broadcastOutput__broadcastOu__0 
		sendEnd(); // Core7 > Core1: broadcastOutput__broadcastOu__0 
		cache_wbInv(broadcastOutput__broadcastOu__3, 32*sizeof(char));
		sendStart(2); // Core7 > Core2: broadcastOutput__broadcastOu__3 
		sendEnd(); // Core7 > Core2: broadcastOutput__broadcastOu__3 
		cache_wbInv(broadcastOutput__broadcastOu__7, 32*sizeof(char));
		sendStart(5); // Core7 > Core5: broadcastOutput__broadcastOu__7 
		sendEnd(); // Core7 > Core5: broadcastOutput__broadcastOu__7 
		cache_wbInv(broadcastOutput__broadcastOu__5, 32*sizeof(char));
		sendStart(6); // Core7 > Core6: broadcastOutput__broadcastOu__5 
		sendEnd(); // Core7 > Core6: broadcastOutput__broadcastOu__5 
		cache_wbInv(broadcastOutput__broadcastOu__1, 32*sizeof(char));
		sendStart(3); // Core7 > Core3: broadcastOutput__broadcastOu__1 
		sendEnd(); // Core7 > Core3: broadcastOutput__broadcastOu__1 
		cache_wbInv(broadcastOutput__broadcastOu__4, 32*sizeof(char));
		sendStart(4); // Core7 > Core4: broadcastOutput__broadcastOu__4 
		sendEnd(); // Core7 > Core4: broadcastOutput__broadcastOu__4 
		cache_wbInv(broadcastOutput__displayMatr__0, 256*sizeof(char));
		sendStart(0); // Core7 > Core0: broadcastOutput__displayMatr__0 
		sendEnd(); // Core7 > Core0: broadcastOutput__displayMatr__0 
		fifoPush(output1_56__end_in__0, FIFO_Head_broadcastOutput_en__0, 32*sizeof(char), NULL, 0);
		cache_wbInv(FIFO_Head_broadcastOutput_en__0, 32*sizeof(char));
		cache_inv(output1_56__end_in__0, 8*sizeof(long));
		fifoPush(output1_8__end_in__0, FIFO_Head_broadcastOutput_en__6, 32*sizeof(char), NULL, 0);
		cache_wbInv(FIFO_Head_broadcastOutput_en__6, 32*sizeof(char));
		cache_inv(output1_8__end_in__0, 8*sizeof(long));
	}
}
예제 #24
0
const QDomNode &SVT_Fcml::fcmlReqWithRefreshSession(const QString &to
                                                    , const QString &model, const QString &func
                                                    , const QMap<QString, QString> &para
                                                    , int *error)
{
    bool sessionRegeted=false;
    mNode.clear();
    bool sessionOk=mSession.contains(to);
    mMutex.lock();
    bool authOk=mSavedAuth.contains(to);
    mMutex.unlock();
    if(!sessionOk && !authOk)
    {
        if(error)
        {
            *error=FE_WRONG_USER_OR_PWD;
        }
        return mNode;
    }

    //step1 get sessionId
    QString sessionId;
    if(!sessionOk)
    {
        Q_ASSERT(authOk);
        mMutex.lock();
        const QPair<QString,QString> pair=mSavedAuth[to];
        mMutex.unlock();
        int itemp;
        sessionId=getSession(to,pair.first,pair.second,&itemp);
        if(sessionId.isEmpty())
        {
            //有两种可能,1.用户名密码错    2.不在线
            if(error)
            {
                *error=itemp;
            }
            return mNode;
        }
        sessionRegeted=true;

    }
    else
    {
        sessionId=mSession[to];
    }

    //step2 get data
    QDomElement elem;
    QDomDocument doc;
    elem=doc.createElement(QString("%1.%2").arg(model,func));
    elem.setAttribute("_sessionId",sessionId);

    QMap<QString, QString>::const_iterator i = para.constBegin();
    while (i != para.constEnd()) {
        elem.setAttribute(i.key(),i.value());
        ++i;
    }

    doc.appendChild(elem);
//    QString req="<%1.%2 _sessionId=\"%3\"/>";
//    req=req.arg(model,func,sessionId);

    QString req=doc.toString();

    bool needStartFinish=isSetApi(model,func);

    if(needStartFinish)sendStart(to,sessionId);
    elem=fcmlRequest(QString("netrouter@")+to,req).firstChild().toElement();
    if(needStartFinish)sendFinish(to,sessionId);

    if(0==elem.tagName().compare("error"))
    {
        int retvalue=elem.attribute("code").toInt();
        if(retvalue==FE_SESSION_NOTOK && !sessionRegeted && authOk)
        {
            const QPair<QString,QString> pair=mSavedAuth[to];
            sessionId=getSession(to,pair.first,pair.second);
            sessionRegeted=true;
            if(!sessionId.isEmpty())
            {
                elem=fcmlRequest(QString("netrouter@")+to,req).firstChild().toElement();
            }
        }
    }

    if(error)
    {
        if(0==elem.tagName().compare("error"))
        {
            *error=elem.attribute("code").toInt();
        }
        else
        {
            *error=0;
        }
    }
    return mNode;
}
예제 #25
0
void cmd_boot(void) { 
  sendStart(ERR_WAIT);
  buf[0] = 0;
  cmd_boot_exec();  
}
예제 #26
0
bool I2CController::step(I2COp** result) {
	bool processing = true;

	*result = NULL;

	while (processing) {
		switch (state) {
		default:
		case I2C_STATE_ERROR:
			state = I2C_STATE_START;
			return true;
		case I2C_STATE_START_WAIT:
		case I2C_STATE_WRITE_ADDR_WAIT:
		case I2C_STATE_WRITE_DATA_WAIT:
		case I2C_STATE_READ_DATA_WAIT:
			if (intSet()) {
				state = (I2CState) (state + 1);
			} else {
				processing = false;
			}
			break;
		case I2C_STATE_START:
			if (pendingOps.getSize() > 0) {
				sendStart();
				state = I2C_STATE_START_WAIT;
			} else {
				processing = false;
			}
			break;
		case I2C_STATE_START_RESPONSE:
			switch (TW_STATUS) {
			case TW_REP_START:
			case TW_START:
				state = I2C_STATE_WRITE_ADDR;
				break;
			case TW_MT_ARB_LOST:
				state = I2C_STATE_START;
				break;
			default:
				state = I2C_STATE_ERROR;
				break;
			}
			break;
		case I2C_STATE_WRITE_ADDR:
			writeByte(
					(pendingOps.peek()->addr << 1)
							| (pendingOps.peek()->write ? TW_WRITE : TW_READ));
			state = I2C_STATE_WRITE_ADDR_WAIT;
			break;
		case I2C_STATE_WRITE_ADDR_RESPONSE:
			switch (TW_STATUS) {
			case TW_MT_SLA_ACK:
			case TW_MR_SLA_ACK:
				state = pendingOps.peek()->write ?
						I2C_STATE_WRITE_DATA : I2C_STATE_READ_DATA;
				break;
			case TW_MT_SLA_NACK:
			case TW_MR_SLA_NACK:
			case TW_MT_ARB_LOST:
				state = I2C_STATE_START;
				break;
			default:
				state = I2C_STATE_ERROR;
				break;
			}
			break;
		case I2C_STATE_WRITE_DATA:
			if (!pendingOps.getSize()) {
				state = I2C_STATE_START;
			} else if (!pendingOps.peek()->data.getSize()) {
				state = I2C_STATE_DATA_DONE;
			} else {
				writeByte(pendingOps.peek()->data.peek());
				state = I2C_STATE_WRITE_DATA_WAIT;
			}
			break;
		case I2C_STATE_WRITE_DATA_RESPONSE:
			switch (TW_STATUS) {
			case TW_MT_DATA_ACK:
				pendingOps.peek()->data.dequeue();
				state = I2C_STATE_WRITE_DATA;
				break;
			case TW_MT_DATA_NACK:
			case TW_MT_ARB_LOST:
				state = I2C_STATE_DATA_DONE;
				break;
			default:
				state = I2C_STATE_ERROR;
				break;
			}
			break;
		case I2C_STATE_READ_DATA:
			if (pendingOps.peek()->data.full()) {
				state = I2C_STATE_DATA_DONE;
			} else {
				requestByte(
						pendingOps.peek()->data.getSize()
								!= pendingOps.peek()->data.getBufferSize() - 1);
				state = I2C_STATE_READ_DATA_WAIT;
			}
			break;
		case I2C_STATE_READ_DATA_RESPONSE:
			switch (TW_STATUS) {
			case TW_MR_DATA_ACK:
				pendingOps.peek()->data.enqueue(readByte());
				state = I2C_STATE_READ_DATA;
				break;
			case TW_MR_DATA_NACK:
				pendingOps.peek()->data.enqueue(readByte());
				state = I2C_STATE_DATA_DONE;
				break;
			default:
				state = I2C_STATE_ERROR;
				break;
			}
			break;
		case I2C_STATE_DATA_DONE:
			pendingOps.dequeue(result);
		case I2C_STATE_CLOSE:
			if (!pendingOps.getSize())
				sendClose();
			if (state == I2C_STATE_DATA_DONE) {
				state = I2C_STATE_START;
				return true;
			} else {
				state = I2C_STATE_START;
				break;
			}
		}
	}
	return false;
}
예제 #27
0
int main(void) {

  uint8_t c;
    
  DATA_OUT            // Шина данных (DDRD)
  DDRC  = 0b00000000; // Шина адреса
  DDRB  = 0b00101101; // Шина адреса, карта и светодиод
  PORTB = 0b00010001; // Подтягивающий резистор на MISO и светодиод  

  // Пауза, пока не стабилизируется питание
  _delay_ms(100);

//  while(1) {
//     error();
//  }

  // Запуск файловой системы
  if(fs_init()) error();
  strcpy_P((char*)buf, PSTR("boot/boot.rk"));
  if(fs_open()) error();
  if(fs_getfilesize()) error();
  if(fs_tmp < 7) error();
  if(fs_tmp > 128) error();
  if(fs_read0(rom, (WORD)fs_tmp)) error();  
                    
  // Гасим светодиод
  PORTB |= _BV(PB0);
  
  while(1) {

    // Эмуляция ПЗУ
    RomEmu();

    // Зажигаем светодиод
    PORTB |= _BV(PB0);

    // Проверяем наличие карты
    sendStart(ERR_START);
    send(ERR_WAIT);
    if(fs_check()) {
      send(ERR_DISK_ERR);
    } else {
      send(ERR_OK_DISK);
      recvStart();
      c = wrecv();
      
      // Сбрасываем ошибку
      lastError = 0;
    
      // Принимаем аргументы 
      switch(c) {
        case 0:  cmd_boot();         break; 
        case 1:  cmd_ver();          break;
        case 2:  cmd_exec();         break; 
        case 3:  cmd_find();         break;
        case 4:  cmd_open();         break;     
        case 5:  cmd_lseek();        break;     
        case 6:  cmd_read();         break;     
        case 7:  cmd_write();        break; 
        case 8:  cmd_move();         break;
        default: lastError = ERR_INVALID_COMMAND;      
      }
    
      // Вывод ошибки
      if(lastError) sendStart(lastError);
    }

    // Порт рабоатет на выход
    wait();
    DATA_OUT
    
    // Гасим светодиод
    PORTB &=~_BV(PB0);
    
    _delay_ms(500);
  } 
}