Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	pid_t pid;

	/* do some ready work before start the distributed system */
	GetReady();

	if ((pid = fork()) < 0)
	{
	   printf("fork error\n");
	}

	else if(pid == 0)
	{
		int i;
		/* storage process */
		InitStorage();
		ExitSys();
		printf("storage process finished.\n");
	}

	else
	{
	   /* transaction process */
	   InitTransaction();
       dataLoading();
       /* wait other slave nodes until all of them have loaded data. */
       WaitDataReady();
       /* begin run the benchmark. */
       RunTerminals(THREADNUM);

	   printf("transaction process finished.\n");
	}
	return 0;
}
Ejemplo n.º 2
0
boolean Adafruit_STMPE610::begin() {
    // hardware SPI
	InitTransaction();

//    SPI = mraa_spi_init(0);   // which buss?   will experment here...
    SPI = mraa_spi_init_software_cs(0);   // which buss?   will experment here...
    mraa_spi_frequency(SPI, 1000000);
    mraa_spi_lsbmode(SPI, false);  
    mraa_spi_mode(SPI, MRAA_SPI_MODE0);

    m_spiMode = MRAA_SPI_MODE0;

    _gpioCS = mraa_gpio_init(_cs);
    mraa_gpio_dir(_gpioCS, MRAA_GPIO_OUT);
    CSHigh();

    mraa_spi_write(SPI, 0x00);

    // try mode0
    if (getVersion() != 0x811) {
        //Serial.println("try MODE1");
        mraa_spi_frequency(SPI, 1000000);
        mraa_spi_lsbmode(SPI, false);  
        mraa_spi_mode(SPI, MRAA_SPI_MODE1);
        m_spiMode = MRAA_SPI_MODE1;

        if (getVersion() != 0x811) {
            return false;
        }
    }
    writeRegister8(STMPE_SYS_CTRL1, STMPE_SYS_CTRL1_RESET);
    delay(10);
  
    for (uint8_t i=0; i<65; i++) {
        readRegister8(i);
    }
  
    writeRegister8(STMPE_SYS_CTRL2, 0x0); // turn on clocks!
    writeRegister8(STMPE_TSC_CTRL, STMPE_TSC_CTRL_XYZ | STMPE_TSC_CTRL_EN); // XYZ and enable!
    //Serial.println(readRegister8(STMPE_TSC_CTRL), HEX);
    writeRegister8(STMPE_INT_EN, STMPE_INT_EN_TOUCHDET);
    writeRegister8(STMPE_ADC_CTRL1, STMPE_ADC_CTRL1_10BIT | (0x6 << 4)); // 96 clocks per conversion
    writeRegister8(STMPE_ADC_CTRL2, STMPE_ADC_CTRL2_6_5MHZ);
    writeRegister8(STMPE_TSC_CFG, STMPE_TSC_CFG_4SAMPLE | STMPE_TSC_CFG_DELAY_1MS | STMPE_TSC_CFG_SETTLE_5MS);
    writeRegister8(STMPE_TSC_FRACTION_Z, 0x6);
    writeRegister8(STMPE_FIFO_TH, 1);
    writeRegister8(STMPE_FIFO_STA, STMPE_FIFO_STA_RESET);
    writeRegister8(STMPE_FIFO_STA, 0);    // unreset
    writeRegister8(STMPE_TSC_I_DRIVE, STMPE_TSC_I_DRIVE_50MA);
    writeRegister8(STMPE_INT_STA, 0xFF); // reset all ints
    writeRegister8(STMPE_INT_CTRL, STMPE_INT_CTRL_POL_HIGH | STMPE_INT_CTRL_ENABLE);

    return true;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	pid_t pid;

	GetReady();

    if ((pid = fork()) < 0)
    {
    	printf("fork error\n");
    }

    else if(pid == 0)
    {
    	/* shmget the shared memory address*/
    	BindShmem();

    	InitStorage();

    	printf("storage process finished.\n");
    }

    else
    {
    	InitTransaction();

    	/* load the benchmark data */
    	dataLoading();
    	/* wait other nodes in the distributed system prepare the data */
    	WaitDataReady();
    	/* run the benchmark */
    	RunTerminals(THREADNUM);

    	printf("transaction process finished.\n");
    }
	return 0;
}