Example #1
0
int main(int argc, char **argv)
{
    char src1[4096] = "Hello world.";
    char dst1[4096] = "1111111111111111111111111111111111";

    char src2[4096] = "The whole world spread before you.";
    char dst2[4096] = "2222222222222222222222222222222222";

    // Attach the external interrupt handler for 'intr0'
    int_init();
    int_add(0, (void *)interruptHandler, NULL);
    int_enable(0);

    // Enable external interrupts
    Uns32 spr = MFSPR(17);
    spr |= 0x4;
    MTSPR(17, spr);

    writeReg8(DMA_BASE, DMA_CONFIGURATION, BURST_SIZE);     /* reset */

    LOG("initial dst1 '%s' dst2 '%s'\n", dst1, dst2);

    /* write to DMAC registers to start burst */
    dmaBurst(0, src1, dst1, strlen(src1)+1);
    dmaBurst(1, src2, dst2, strlen(src2)+1);

    /* wait for burst to complete */
	LOG("Waiting for interrupts\n");
    while ( interruptCount < 2 )
    	;
	LOG("%u interrupts received\n", interruptCount);

    /* check results */
	LOG("DMA result dst1 '%s' dst2 '%s'\n", dst1, dst2);
	return 1;
}
Example #2
0
// Returns true if ok.
bool init() {
  const uint8 control_mode = kLtc2943AutomaticMode | kLtc2943PrescalarX1 | kLtc2943DisableAlccPin ;              
  return writeReg8(regs8::kControl, control_mode);
}
Example #3
0
bool HMC5883L::setScale(float gauss)
{
	__u8 regValue = 0x00;
	
	SELECT_DEVICE(*fd, HMC5883L_ADDRESS, deviceName);
	
	if(gauss == 0.88f)
	{				
		regValue 	= 0x00;
		scale 		= 0.73f;
	}
	
	else if(gauss == 1.3f)
	{
		regValue 	= 0x01;
		scale 		= 0.92f;
	}
	
	else if(gauss == 1.9f)
	{
		regValue 	= 0x02;
		scale 		= 1.22;
	}
	
	else if(gauss == 2.5f)
	{
		regValue 	= 0x03;
		scale 		= 1.52f;
	}
	
	else if(gauss == 4.0f)
	{
		regValue 	= 0x04;
		scale 		= 2.27f;
	}
	
	else if(gauss == 4.7f)
	{
		regValue 	= 0x05;
		scale 		= 2.56f;
	}
	
	else if(gauss == 5.6f)
	{
		regValue 	= 0x06;
		scale 		= 3.03f;
	}
	
	else if(gauss == 8.1f)
	{
		regValue 	= 0x07;
		scale 		= 4.35f;
	}
	
	else {
		printf("Switching to default scale values in %s\n", deviceName );
		
		regValue 	= 0x01;
		scale 		= 0.92f;
	}
	
	// Setting is in the top 3 bits of the register.
	regValue = regValue << 5;
		
	return writeReg8(*fd, HMC5883L_CONFIGURATION_REGISTER_B, regValue);
}
Example #4
0
bool HMC5883L::setMeasurementMode(__u8 mode) 
{
	SELECT_DEVICE(*fd, HMC5883L_ADDRESS, deviceName);
	
	return writeReg8(*fd, HMC5883L_MODE_REGISTER, mode);//writeByte(*fd, HMC5883L_MODE_REGISTER, mode);
}