Beispiel #1
0
static void set_shaker_off(int nr)
{
  if(shaker_block)
    shaker_block_time = time(NULL);
  
  shaker_block &= ~nr;
  switch (nr)
  {
    case SHAKER_NUM1:
#ifdef USE_PORTEXPANDER  
      mcp23s17_clr_pin(PORT_A, PIN0);
#else
      bcm2835_gpio_clr(SHAKER1);
#endif
      break;
    case SHAKER_NUM2:
#ifdef USE_PORTEXPANDER  
      mcp23s17_clr_pin(PORT_A, PIN1);
#else
      bcm2835_gpio_clr(SHAKER2);
#endif
      break;
    case SHAKER_NUM1_NUM2:
#ifdef USE_PORTEXPANDER  
      mcp23s17_clr_pin(PORT_A, PIN0);
      mcp23s17_clr_pin(PORT_A, PIN1);
#else
      bcm2835_gpio_clr(SHAKER1);
      bcm2835_gpio_clr(SHAKER2);
#endif      
      break;
  }

}
void GSetDir (Environment *env){

	if(env->motors[0].deltaSteps >= 0) bcm2835_gpio_clr(X_DIR);
	else {bcm2835_gpio_set(X_DIR);env->motors[0].deltaSteps*=-1;}
	if(env->motors[1].deltaSteps >= 0) bcm2835_gpio_clr(Y_DIR);
	else {bcm2835_gpio_set(Y_DIR);env->motors[1].deltaSteps*=-1;}
	if(env->motors[2].deltaSteps >= 0) bcm2835_gpio_clr(Z_DIR);
	else {bcm2835_gpio_set(Z_DIR);env->motors[2].deltaSteps*=-1;}
}
void command_1602(unsigned char cmd)
{
	data_1602(cmd);
	bcm2835_gpio_clr(RS_1602);
	bcm2835_gpio_clr(RW_1602);
	bcm2835_gpio_clr(EN_1602);
	udelay(200);
	bcm2835_gpio_set(EN_1602);
	udelay(200);
}
Beispiel #4
0
void motorStart(int direction)
{
  if(direction)
  { // Forward
    bcm2835_gpio_set(MOTOR_A);
    bcm2835_gpio_clr(MOTOR_B);
  } else { // Backward
    bcm2835_gpio_set(MOTOR_B);
    bcm2835_gpio_clr(MOTOR_A);
  }
}
void GStepper(Environment *env)
{
	// X Axis
    if(env->motors[0].step)	bcm2835_gpio_set(X_STEP);
    if(env->motors[1].step)	bcm2835_gpio_set(Y_STEP);
    if(env->motors[2].step)	bcm2835_gpio_set(Z_STEP);
	bcm2835_delayMicroseconds (200);
	bcm2835_gpio_clr(X_STEP);
    bcm2835_gpio_clr(Y_STEP);
    bcm2835_gpio_clr(Z_STEP);
    bcm2835_delayMicroseconds (200);

}
Beispiel #6
0
const void setFakeOutput(bool red, bool yellow, bool green) {
  #ifdef BUILD_RPI
  if (red)    bcm2835_gpio_set(RPI_GPIO_RED);
  else        bcm2835_gpio_clr(RPI_GPIO_RED);
  
  if (yellow) bcm2835_gpio_set(RPI_GPIO_YELLOW);
  else        bcm2835_gpio_clr(RPI_GPIO_YELLOW);
  
  if (green)  bcm2835_gpio_set(RPI_GPIO_GREEN);
  else        bcm2835_gpio_clr(RPI_GPIO_GREEN);
  #endif
  return;
}
void write_1602(unsigned char cmd)
{
	data_1602(cmd);
	bcm2835_gpio_set(RS_1602);
	bcm2835_gpio_clr(RW_1602);
	bcm2835_gpio_clr(EN_1602);
	/*gpio_set_value(RS_1602, 1);
	gpio_set_value(RW_1602, 0);
	gpio_set_value(EN_1602, 0);*/
	udelay(200);
	bcm2835_gpio_set(EN_1602);
	//gpio_set_value(EN_1602, 1);
	udelay(200);
}
Beispiel #8
0
//--------------------------------------------------------------------------------------------------
// Name:    	SpiPutc
// Function:  	Emulate SPI on GPIO (Bitbanging)
//            
// Parameter: 	Databyte to send
// Return:      -
//--------------------------------------------------------------------------------------------------
void SpiPutc(unsigned char d)
{
	int i,n;
	
	for(i=0;i<8;i++)
	{
		if(d & 0x80)	bcm2835_gpio_set(PIN_LCD_MOSI);		// MOSI = 1
			else		bcm2835_gpio_clr(PIN_LCD_MOSI);		// MOSI = 0
		d <<= 1;
		
		for(n=0;n<4;n++) bcm2835_gpio_clr(PIN_LCD_SCLK); 	// CLK = 0
		for(n=0;n<4;n++) bcm2835_gpio_set(PIN_LCD_SCLK);	// CLK = 1
	}
}
Beispiel #9
0
const void setFakeSignal(bool signal) {
  #ifdef BUILD_RPI
  if (signal)   bcm2835_gpio_set(RPI_GPIO_SIGNAL);
  else          bcm2835_gpio_clr(RPI_GPIO_SIGNAL);
  #endif
  return;
}
void lcdscreentimer::switchPower( bool switcherAutoState, bool switcherManuState )
{
  bool update = false;

  if( switcherAutoState!=m_lastSwitcherAutoState )
  {
    m_lastSwitcherAutoState = switcherAutoState;
    update = true;
  }
  if( switcherManuState!=m_lastSwitcherManuState )
  {
    m_lastSwitcherManuState = switcherManuState;
    update = true;
  }

  if( update )
  {
    bool state = m_lastSwitcherAutoState || m_lastSwitcherManuState;
    myprintf("switching %s!\n",state ? "On" : "Off");
    //QMessageBox::warning(0,"",state ? "On" : "Off");
#ifndef QT_EMULATION
    if( state )
    {
      bcm2835_gpio_clr(PIN_SWITCHER_OUT);
    }
    else
    {
      bcm2835_gpio_set(PIN_SWITCHER_OUT);
    }
#endif
  }
}
Beispiel #11
0
// Set the state of an output
void bcm2835_gpio_write(uint8_t pin, uint8_t on)
{
    if (on)
	bcm2835_gpio_set(pin);
    else
	bcm2835_gpio_clr(pin);
}
Beispiel #12
0
//--------------------------------------------------------------------------------------------------
// Name:    	SpiPutc
// Function:  	Emulate SPI on GPIO (Bitbanging)
//            
// Parameter: 	Databyte to send
// Return:      -
//--------------------------------------------------------------------------------------------------
void SpiPutc(unsigned char d)
{
#ifdef QT_EMULATION
  return; // QT-Simul!
#endif
  int i,n;

  for(i=0;i<8;i++)
  {
    if(d & 0x80)	bcm2835_gpio_set(PIN_LCD_MOSI);		// MOSI = 1
    else		bcm2835_gpio_clr(PIN_LCD_MOSI);		// MOSI = 0
    d <<= 1;

    for(n=0;n<4;n++) bcm2835_gpio_clr(PIN_LCD_SCLK); 	// CLK = 0
    for(n=0;n<4;n++) bcm2835_gpio_set(PIN_LCD_SCLK);	// CLK = 1
  }
}
static void leds_exit(void)
{
    bcm2835_gpio_clr(PIN);

    misc_deregister(&misc);

    printk("leds exit\n");
}
Beispiel #14
0
//--------------------------------------------------------------------------------------------------
// Name:    	SetBacklight
// Function:  	Hintergrundbeleuchtung
//            
// Parameter: 	0=Off 1=On
// Return:      -
//--------------------------------------------------------------------------------------------------
void SetBacklight(uint8 light)
{
#ifdef QT_EMULATION
  Qt_SetBacklight(light);
  return; // QT-Simul!
#endif
  if(light)	bcm2835_gpio_set(PIN_LCD_BACKLIGHT);
  else	bcm2835_gpio_clr(PIN_LCD_BACKLIGHT)	;
}
Beispiel #15
0
void _reset(void) {
	bcm2835_gpio_fsel(D_C, BCM2835_GPIO_FSEL_OUTP); // D/C
	bcm2835_gpio_fsel(RES, BCM2835_GPIO_FSEL_OUTP); // Reset
	bcm2835_gpio_set(D_C);

	bcm2835_gpio_clr(RES);   // Reset
	bcm2835_delay(100);
	bcm2835_gpio_set(RES);   // Reset off
	bcm2835_delay(100);
}
Beispiel #16
0
static PyObject *
PyBCM2835_gpio_clr(PyObject *self, PyObject *args)
{
	int pin;

	if (!PyArg_ParseTuple(args,"i",&pin)) {
		return NULL;
	}

	bcm2835_gpio_clr(pin);
	
	Py_RETURN_NONE;
}
Beispiel #17
0
uint8_t SlushMotor::SPIXfer(uint8_t data) {
	char dataPacket[1];

	dataPacket[0] = (char) data;

	bcm2835_spi_chipSelect(BCM2835_SPI_CS_NONE);
	bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_64);
	bcm2835_spi_setDataMode(BCM2835_SPI_MODE3);

	bcm2835_gpio_clr(m_nSpiChipSelect);
	bcm2835_spi_transfern(dataPacket, 1);
	bcm2835_gpio_set(m_nSpiChipSelect);

	return (uint8_t) dataPacket[0];
}
Beispiel #18
0
int notmain(unsigned int earlypc) {
#ifdef ENABLE_FRAMEBUFFER
	fb_init();

	printf("Compiled on %s at %s\n", __DATE__, __TIME__);
	printf("DMX512 Sender\n");
#endif

#ifdef BW_I2C_UI
#endif

	led_init();
	led_set(1);

	bcm2835_gpio_fsel(ANALYZER_CH1, BCM2835_GPIO_FSEL_OUTP); // IDLE
	bcm2835_gpio_fsel(ANALYZER_CH2, BCM2835_GPIO_FSEL_OUTP); // BREAK
	bcm2835_gpio_fsel(ANALYZER_CH3, BCM2835_GPIO_FSEL_OUTP); // DATA
	bcm2835_gpio_fsel(ANALYZER_CH4, BCM2835_GPIO_FSEL_OUTP); // MAB

	bcm2835_gpio_set(ANALYZER_CH1); // IDLE
	bcm2835_gpio_clr(ANALYZER_CH2);	// BREAK
	bcm2835_gpio_clr(ANALYZER_CH3); // DATA
	bcm2835_gpio_clr(ANALYZER_CH4);	// MAB

	bcm2835_pl011_dmx512_begin();
	bcm2835_gpio_fsel(18, BCM2835_GPIO_FSEL_OUTP);
	bcm2835_gpio_set(18);

	events_init();

	for (;;) {
		events_check();
	}

	return (0);
}
Beispiel #19
0
static void write_port(void *arg, long period)
{
  int n;

  for (n = 0; n < npins; n++) {
    if (exclude_map & RTAPI_BIT(n)) 
      continue;
    if (dir_map & RTAPI_BIT(n)) {
      if (*(port_data[n])) { 
	bcm2835_gpio_set(gpios[n]);
      } else {
	bcm2835_gpio_clr(gpios[n]);
      }
    }
  }
}
static int leds_ioctl(struct file *filp,unsigned int cmd, unsigned long arg)
{
    switch(cmd)
    {
	case 0:
	    bcm2835_gpio_clr(PIN);
	    printk("LED OFF\n");
	    break;
	case 1:
	    bcm2835_gpio_set(PIN);
	    printk("LED ON\n");
	    break;
	default:
	    return -EINVAL;
    }
    return 0;
}
void data_1602(unsigned char data_v)
{
	if(data_v & 0x01)	bcm2835_gpio_set(D0_1602);
	else				bcm2835_gpio_clr(D0_1602);
	if(data_v & 0x02)	bcm2835_gpio_set(D1_1602);
	else				bcm2835_gpio_clr(D1_1602);
	if(data_v & 0x04)	bcm2835_gpio_set(D2_1602);
	else				bcm2835_gpio_clr(D2_1602);
	if(data_v & 0x08)	bcm2835_gpio_set(D3_1602);
	else				bcm2835_gpio_clr(D3_1602);
	if(data_v & 0x10)	bcm2835_gpio_set(D4_1602);
	else				bcm2835_gpio_clr(D4_1602);
	if(data_v & 0x20)	bcm2835_gpio_set(D5_1602);
	else				bcm2835_gpio_clr(D5_1602);
	if(data_v & 0x40)	bcm2835_gpio_set(D6_1602);
	else				bcm2835_gpio_clr(D6_1602);
	if(data_v & 0x80)	bcm2835_gpio_set(D7_1602);
	else				bcm2835_gpio_clr(D7_1602);	
	
}
Beispiel #22
0
int max98306_set_volume(int value) {

	int volume;
	int gain_setting,gain_prime_setting;

	/*
				GAIN		GAIN_PRIME
		0 = shutdown
		1 =  6dB	FLOATING	FLOATING
		2 =  9dB	FLOATING	HIGH
		3 = 12dB	HIGH		FLOATING
		4 = 15dB	FLOATING	LOW
		5 = 18dB	LOW		FLOATING
	*/

	if (value<0) volume=0;
	else if (value>5) volume=5;
	else volume=value;

	if (volume==0) {
		max98306_disable();
		return 0;
	}

	/* in case we had been disabled */
	max98306_enable();

	switch(volume) {
		case 1:	/*  6dB	FLOATING	FLOATING	*/
			gain_setting=GAIN_FLOAT;
			gain_prime_setting=GAIN_FLOAT;
			break;
		case 2: /*  9dB	FLOATING	HIGH		*/
			gain_setting=GAIN_FLOAT;
			gain_prime_setting=GAIN_HIGH;
			break;
		case 3: /* 12dB	HIGH		FLOATING	*/
			gain_setting=GAIN_HIGH;
			gain_prime_setting=GAIN_FLOAT;
			break;
		case 4: /* 15dB	FLOATING	LOW		*/
			gain_setting=GAIN_FLOAT;
			gain_prime_setting=GAIN_LOW;
			break;
		case 5: /* 18dB	LOW		FLOATING	*/
			gain_setting=GAIN_LOW;
			gain_prime_setting=GAIN_FLOAT;
			break;
		default:
			fprintf(stderr,"Unknown volume %d\n",volume);
			return -1;
	}

	/* Set GAIN value */
	if (gain_setting==GAIN_FLOAT) {
		/* Set float by setting !OE high*/
		bcm2835_gpio_set(GAIN_GPIO_EN);
	}
	else {
		bcm2835_gpio_clr(GAIN_GPIO_EN);
		if (gain_setting==GAIN_HIGH) {
			bcm2835_gpio_set(GAIN_GPIO);
		}
		else {
			bcm2835_gpio_clr(GAIN_GPIO);
		}
	}

	/* Set GAIN_PRIME value */
	if (gain_prime_setting==GAIN_FLOAT) {
		/* Set float by setting !OE high*/
		bcm2835_gpio_set(GAIN_PRIME_GPIO_EN);
	}
	else {
		bcm2835_gpio_clr(GAIN_PRIME_GPIO_EN);
		if (gain_prime_setting==GAIN_HIGH) {
			bcm2835_gpio_set(GAIN_PRIME_GPIO);
		}
		else {
			bcm2835_gpio_clr(GAIN_PRIME_GPIO);
		}

	}

	return 0;
}
Beispiel #23
0
int max98306_disable(void) {

	 bcm2835_gpio_clr(SHUTDOWN_GPIO);

	return 0;
}
Beispiel #24
0
//--------------------------------------------------------------------------------------------------
// Name:    	SetBacklight
// Function:  	Hintergrundbeleuchtung
//            
// Parameter: 	0=Off 1=On
// Return:      -
//--------------------------------------------------------------------------------------------------
void SetBacklight(uint8 light)
{
	if(light)	bcm2835_gpio_set(PIN_LCD_BACKLIGHT);
		else	bcm2835_gpio_clr(PIN_LCD_BACKLIGHT)	;
}
Beispiel #25
0
void SparkFunDmx::ReadConfigFiles(void) {
	DEBUG_ENTRY;

	m_bIsSpiCsSet = false;
	m_bIsResetSet = false;
	m_bIsBusyPinSet = false;

	ReadConfigFile configfile(SparkFunDmx::staticCallbackFunction, this);

	if (configfile.Read("sparkfun.txt")) {
#ifndef NDEBUG
		printf("\'sparkfun.txt\' (global settings):\n");

		if (m_bIsSpiCsSet) {
			printf("\tSPI CS : %d\n", m_nSpiCs);
		}

		if (m_bIsResetSet) {
			printf("\tReset pin: %d\n", m_nResetPin);
		}

		if (m_bIsBusyPinSet) {
			printf("\tBusy pin: %d\n", m_nBusyPin);
		}
#endif
	}

	if (!m_bIsResetSet) {
		m_nResetPin = GPIO_RESET_OUT;
		m_bIsResetSet = true;
#ifndef NDEBUG
		printf("\tReset pin: %d\n", m_nResetPin);
#endif
	}

	if (m_bIsBusyPinSet) {
		bcm2835_gpio_fsel(m_nBusyPin, BCM2835_GPIO_FSEL_INPT);
	}

	bcm2835_gpio_fsel(m_nResetPin, BCM2835_GPIO_FSEL_OUTP);
	bcm2835_gpio_set(m_nResetPin);

	bcm2835_gpio_clr(m_nResetPin);
	udelay(10000);
	bcm2835_gpio_set(m_nResetPin);
	udelay(10000);

	bcm2835_spi_begin();

	char fileName[] = "motor%.txt";

	for (int i = 0; i < SPARKFUN_DMX_MAX_MOTORS; i++) {

		fileName[5] = (char) i + '0';

		m_bIsPositionSet = false;

		if (configfile.Read(fileName)) {
#ifndef NDEBUG
			printf("Motor %d:\n", i);
#endif
			if (m_bIsPositionSet && m_bIsSpiCsSet) {
#ifndef NDEBUG
				printf("\t%s=%d\n", SPARKFUN_PARAMS_POSITION, m_nPosition);
				printf("\t%s=%d\n", SPARKFUN_PARAMS_SPI_CS, m_nSpiCs);
				printf("\t%s=%d\n", SPARKFUN_PARAMS_RESET_PIN, m_nResetPin);
				if(m_bIsBusyPinSet) {
					printf("\t%s=%d\n", SPARKFUN_PARAMS_BUSY_PIN, m_nBusyPin);
				}
				printf("\t-----------------------------\n");
				printf("\t%s=%d (DMX footprint=%d)\n", PARAMS_DMX_MODE, m_nDmxMode, L6470DmxModes::GetDmxFootPrintMode(m_nDmxMode));
				printf("\t%s=%d\n", PARAMS_DMX_START_ADDRESS, m_nDmxStartAddressMode);
				printf("\t=============================\n");
#endif
				if ((m_nDmxStartAddressMode <= DMX_MAX_CHANNELS) && (L6470DmxModes::GetDmxFootPrintMode(m_nDmxMode) != 0)) {

					if (m_bIsBusyPinSet) {
						m_pAutoDriver[i] = new AutoDriver(m_nPosition, m_nSpiCs, m_nResetPin, m_nBusyPin);
					} else {
						m_pAutoDriver[i] = new AutoDriver(m_nPosition, m_nSpiCs, m_nResetPin);
					}

					assert(m_pAutoDriver[i] != 0);

					if (m_pAutoDriver[i] != 0) {
						if (m_pAutoDriver[i]->IsConnected()) {
							m_pAutoDriver[i]->setMotorNumber(i);
							m_pAutoDriver[i]->Dump();

							m_pMotorParams[i] = new MotorParams(fileName);
							assert(m_pMotorParams[i] != 0);
							m_pMotorParams[i]->Dump();
							m_pMotorParams[i]->Set(m_pAutoDriver[i]);

							L6470Params l6470Params(fileName);
							l6470Params.Dump();
							l6470Params.Set(m_pAutoDriver[i]);

							m_pAutoDriver[i]->Dump();

							m_pModeParams[i] = new ModeParams(fileName);
							assert(m_pModeParams[i] != 0);
							m_pModeParams[i]->Dump();

							m_pL6470DmxModes[i] = new L6470DmxModes((TL6470DmxModes) m_nDmxMode, m_nDmxStartAddressMode, m_pAutoDriver[i], m_pMotorParams[i], m_pModeParams[i]);
							assert(m_pL6470DmxModes[i] != 0);

							if (m_pL6470DmxModes[i] != 0) {
								if (m_nDmxStartAddress == DMX_ADDRESS_INVALID) {
									m_nDmxStartAddress = m_pL6470DmxModes[i]->GetDmxStartAddress();
									m_nDmxFootprint = m_pL6470DmxModes[i]->GetDmxFootPrint();
								} else {
									const uint16_t nDmxChannelLastCurrent = m_nDmxStartAddress + m_nDmxFootprint;
									m_nDmxStartAddress = MIN(m_nDmxStartAddress, m_pL6470DmxModes[i]->GetDmxStartAddress());

									const uint16_t nDmxChannelLastNew = m_nDmxStartAddressMode + m_pL6470DmxModes[i]->GetDmxFootPrint();
									m_nDmxFootprint = MAX(nDmxChannelLastCurrent, nDmxChannelLastNew) - m_nDmxStartAddress;
								}
#ifndef NDEBUG
								printf("DMX Mode: %d, DMX Start Address: %d\n", m_pL6470DmxModes[i]->GetMode(), m_pL6470DmxModes[i]->GetDmxStartAddress());
								printf("DMX Start Address:%d, DMX Footprint:%d\n", (int) m_nDmxStartAddress, (int) m_nDmxFootprint);
#endif
							}
						} else {
							delete m_pAutoDriver[i];
							m_pAutoDriver[i] = 0;
							printf("Communication issues; check SPI configuration and cables\n");
						}
					} else {
						printf("Internal error!\n");
					}
				}
			} else {
				if(!m_bIsPositionSet) {
					printf("Missing %s=\n", SPARKFUN_PARAMS_POSITION);
				}
				if(!m_bIsSpiCsSet) {
					printf("Missing %s=\n", SPARKFUN_PARAMS_SPI_CS);
				}
			}
#ifndef NDEBUG
			printf("Motor %d: --------- end ---------\n", i);
#endif
		} else {
#ifndef NDEBUG
			printf("Configuration file : %s not found\n", fileName);
#endif
		}
	}

	for (int i = 0; i < SPARKFUN_DMX_MAX_MOTORS; i++) {
		if (m_pL6470DmxModes[i] != 0) {
			m_pL6470DmxModes[i]->InitSwitch();
		}
	}

	for (int i = 0; i < SPARKFUN_DMX_MAX_MOTORS; i++) {
		if (m_pAutoDriver[i] != 0) {
			while (m_pAutoDriver[i]->busyCheck())
				;
		}
	}

	for (int i = 0; i < SPARKFUN_DMX_MAX_MOTORS; i++) {
		if (m_pL6470DmxModes[i] != 0) {
			m_pL6470DmxModes[i]->InitPos();
		}
	}

#ifndef NDEBUG
	printf("Motors connected : %d\n", (int) AutoDriver::getNumBoards());
#endif
	DEBUG_EXIT;
}
Beispiel #26
0
int main(int argc, char **argv)
{

    int i;

    if (!bcm2835_init())
        return 1;

    // Set the pins to be an output
    bcm2835_gpio_fsel(PIN0, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN1, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN2, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN3, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN4, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN5, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN6, BCM2835_GPIO_FSEL_OUTP);
    bcm2835_gpio_fsel(PIN7, BCM2835_GPIO_FSEL_OUTP);

    while(1)
    {
        bcm2835_gpio_set(PIN0);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN0);
        bcm2835_delay(500);

        bcm2835_gpio_set(PIN1);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN1);
        bcm2835_delay(500);
        bcm2835_gpio_set(PIN2);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN2);
        bcm2835_delay(500);

        bcm2835_gpio_set(PIN3);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN3);
        bcm2835_delay(500);

        bcm2835_gpio_set(PIN4);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN4);
        bcm2835_delay(500);

        bcm2835_gpio_set(PIN5);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN5);
        bcm2835_delay(500);

        bcm2835_gpio_set(PIN6);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN6);
        bcm2835_delay(500);

        bcm2835_gpio_set(PIN7);
        bcm2835_delay(500);
        bcm2835_gpio_clr(PIN7);
        bcm2835_delay(500);
    }

    bcm2835_close();
    return 0;
}
Beispiel #27
0
void dmx_data_send(const uint8_t *data, const uint16_t length)
{
	BCM2835_PL011->LCRH = PL011_LCRH_WLEN8 | PL011_LCRH_STP2 | PL011_LCRH_BRK;
	// DEBUG
	bcm2835_gpio_clr(ANALYZER_CH1); // IDLE
	bcm2835_gpio_set(ANALYZER_CH2); // BREAK
	bcm2835_gpio_clr(ANALYZER_CH3);	// DATA
	bcm2835_gpio_clr(ANALYZER_CH4); // MAB
	udelay(88);						// Break Time
	BCM2835_PL011->LCRH = PL011_LCRH_WLEN8 | PL011_LCRH_STP2;
	// DEBUG
	bcm2835_gpio_clr(ANALYZER_CH1); // IDLE
	bcm2835_gpio_clr(ANALYZER_CH2); // BREAK
	bcm2835_gpio_clr(ANALYZER_CH3);	// DATA
	bcm2835_gpio_set(ANALYZER_CH4); // MAB
	udelay(8);						// Mark After Break
	// DEBUG
	bcm2835_gpio_clr(ANALYZER_CH1); // IDLE
	bcm2835_gpio_clr(ANALYZER_CH2); // BREAK
	bcm2835_gpio_set(ANALYZER_CH3);	// DATA
	bcm2835_gpio_clr(ANALYZER_CH4); // MAB
	uint16_t i =0;
	BCM2835_PL011->DR = 0;
	for (i = 0; i < length; i++)
	{
		while (1)
		{
			if ((BCM2835_PL011->FR & 0x20) == 0)
				break;
		}
		BCM2835_PL011->DR = data[i];
	}
	// DEBUG
	bcm2835_gpio_clr(ANALYZER_CH1); // IDLE
	bcm2835_gpio_clr(ANALYZER_CH2); // BREAK
	bcm2835_gpio_clr(ANALYZER_CH3);	// DATA
	bcm2835_gpio_clr(ANALYZER_CH4); // MAB
	while (1)
	{
		if ((BCM2835_PL011->FR & 0x20) == 0)
			break;
	}
	udelay(44);
}
//void bcm2835_gpio_clr(uint8_t pin);
/// Call bcm2835_gpio_clr with 1 parameter
/// \par            Refer
/// \par            Modify
void ope_gpio_clr(void)
{
    get_byte_code();
    bcm2835_gpio_clr( *((uint8_t *)(buff+1)) );
//   set_ope_code( OPE_GPIO_CLR );
}
Beispiel #29
0
//----------------------------------------------------------------------------
void main()
{
    unsigned char i,j,h;
	
	if (!bcm2835_init())
		return;
	
    ini_displaypx();
    
    bcm2835_gpio_clr(CS1_DISPLAY);
    

    setx_displaypx(0);
    write_displaypx(0x01);
        
    setx_displaypx(1);
    write_displaypx(0x02);
        
    setx_displaypx(2);
    write_displaypx(0x03);
    
    setx_displaypx(3);
    write_displaypx(0x04);
    
    setx_displaypx(4);
    write_displaypx(0x05);
    
    setx_displaypx(5);
    write_displaypx(0x06);
    
    setx_displaypx(6);
    write_displaypx(0x07);
    
    setx_displaypx(7);
    write_displaypx(0x08);
	

    for(i=0;i<8;i++)
    {
        setx_displaypx(i);
		for(j=0;j<64;j++)
		{
			setx_displaypx(i);
			sety_displaypx(j);

			printf("%X ", (int)read_data_display());
			
			setx_displaypx(i);
			sety_displaypx(j);
			write_displaypx(0x5a);
			
			bcm2835_delayMicroseconds(100);

			setx_displaypx(i);
			sety_displaypx(j);
			printf("%X - ", (int)read_data_display());
		}
	printf("\n");
    }

    bcm2835_gpio_set(CS1_DISPLAY);
    
    bcm2835_gpio_clr(CS2_DISPLAY);
    write_displaypx(0xff);
    bcm2835_gpio_set(CS2_DISPLAY);

    for(i=0;i<10;i++) 
       printf("%d ",(int)read_com_displaypx());

	printf("\n");
    bcm2835_close();

    return;
}
void GDisableMotors(){
    bcm2835_gpio_clr(X_EN);
    bcm2835_gpio_clr(Y_EN);
    bcm2835_gpio_clr(Z_EN);
    return;
}