Пример #1
0
static PyObject *
PyBCM2835_gpio_set_pad(PyObject *self, PyObject *args)
{
	uint8_t group;
	uint32_t control;

	if (!PyArg_ParseTuple(args,"ii",&group,&control)) {
		return NULL;
	}

	bcm2835_gpio_set_pad(group,control);

	Py_RETURN_NONE;
}
Пример #2
0
//------------------------------------------------------------------------------
// Global Functions
int drvGPIO_start(void)
{
    int retVal;

    CHECK_NOT_STARTED_INT(&sInstDscr, 0);

    initInst();
    retVal = bcm2835_init();
    if (retVal)
    {
        // Set the pin to be an output
        bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP);
        bcm2835_gpio_set_pad(BCM2835_PAD_GROUP_GPIO_0_27,
                BCM2835_PAD_DRIVE_10mA);

        sInstDscr.started = TRUE;
        return R_SUCCESS;
    }
    else {
        PRINT_ERROR("bcm2835_init() returned %i", retVal);
    }
    return R_ERROR;
}
Пример #3
0
// this is a simple test program that prints out what it will do rather than 
// actually doing it
int main(int argc, char **argv)
{
    // Be non-destructive
    bcm2835_set_debug(1);

    if (!bcm2835_init())
	return 1;

    // Configure some GPIO pins fo some testing
    // Set RPI pin P1-11 to be an output
    bcm2835_gpio_fsel(RPI_GPIO_P1_11, BCM2835_GPIO_FSEL_OUTP);
    // Set RPI pin P1-15 to be an input
    bcm2835_gpio_fsel(RPI_GPIO_P1_15, BCM2835_GPIO_FSEL_INPT);
    //  with a pullup
    bcm2835_gpio_set_pud(RPI_GPIO_P1_15, BCM2835_GPIO_PUD_UP);
    // And a low detect enable
    bcm2835_gpio_len(RPI_GPIO_P1_15);
    // and input hysteresis disabled on GPIOs 0 to 27
    bcm2835_gpio_set_pad(BCM2835_PAD_GROUP_GPIO_0_27, BCM2835_PAD_SLEW_RATE_UNLIMITED|BCM2835_PAD_DRIVE_8mA);

#if 1
    // Blink
    while (1)
    {
	// Turn it on
	bcm2835_gpio_write(RPI_GPIO_P1_11, HIGH);
	
	// wait a bit
	bcm2835_delay(500);
	
	// turn it off
	bcm2835_gpio_write(RPI_GPIO_P1_11, LOW);
	
	// wait a bit
	bcm2835_delay(500);
    }
#endif

#if 0
    // Read input
    while (1)
    {
	// Read some data
	uint8_t value = bcm2835_gpio_lev(RPI_GPIO_P1_15);
	printf("read from pin 15: %d\n", value);
	
	// wait a bit
	bcm2835_delay(500);
    }
#endif

#if 0
    // Look for a low event detection
    // eds will be set whenever pin 15 goes low
    while (1)
    {
	if (bcm2835_gpio_eds(RPI_GPIO_P1_15))
	{
	    // Now clear the eds flag by setting it to 1
	    bcm2835_gpio_set_eds(RPI_GPIO_P1_15);
	    printf("low event detect for pin 15\n");
	}

	// wait a bit
	bcm2835_delay(500);
    }
#endif

    if (!bcm2835_close())
	return 1;

    return 0;
}
//void bcm2835_gpio_set_pad(uint8_t group, uint32_t control);
/// Call bcm2835_gpio_set_pad with 2 parameter
/// \par            Refer
/// \par            Modify
void ope_gpio_set_pad(void)
{
    get_byte_code();
    get_int_code();
    bcm2835_gpio_set_pad( *((uint8_t *)(buff+1)), *((uint32_t *)(buff+2)) );
}