Пример #1
0
int main(int argc, char *argv[])
{
    int counter = 250;
    srand(time(NULL));

    gpio_open(15);
    gpio_open(16);
    gpio_open(17);

    gpio_set_direction(15, "out");
    gpio_set_direction(16, "out");
    gpio_set_direction(17, "out");

    /* blink leds randomly with random delay */
    while (counter > 0) {
        gpio_set(random(15, 17), random(0, 1));
        delay(random(0, random(MIN_DELAY_VALUE, MAX_DELAY_VALUE)));
        counter--;
    }

    /* Turn off all leds */
    gpio_set(17, 1);
    gpio_set(16, 1);
    gpio_set(15, 1);

    gpio_close_all();

    return 0;
}
Пример #2
0
static int jtag_open(struct jtag_state *state) {

	gpio_export(TDI_GPIO);
	gpio_export(TMS_GPIO);
	gpio_export(TCK_GPIO);
	gpio_export(TDO_GPIO);

	gpio_set_direction(TDI_GPIO, 0);
	gpio_set_direction(TMS_GPIO, 1);
	gpio_set_direction(TCK_GPIO, 1);
	gpio_set_direction(TDO_GPIO, 1);

	gpio_set_value(TDO_GPIO, 0);
	gpio_set_value(TMS_GPIO, 0);
	gpio_set_value(TCK_GPIO, 0);

	state->tdi = TDI_GPIO;
	state->tms = TMS_GPIO;
	state->tck = TCK_GPIO;
	state->tdo = TDO_GPIO;

	jtag_reset(state);

	return 0;
}
Пример #3
0
/*!
 * Provide the mipi camera power and reset
 */
void mipi_cam_power_on(void)
{
#if defined(BOARD_EVB)
    board_ioexpander_iomux_config();
    /*reset of camera sensor, pin 27 */
    max7310_set_gpio_output(0, 2, GPIO_LOW_LEVEL);
    hal_delay_us(1000);
    max7310_set_gpio_output(0, 2, GPIO_HIGH_LEVEL);

    /*power supply through pin25 of connector, for cam_pdown, power down and then up */
    max7310_set_gpio_output(0, 0, GPIO_LOW_LEVEL);
    hal_delay_us(1000);
    max7310_set_gpio_output(0, 0, GPIO_HIGH_LEVEL);
//    max7310_set_gpio_output(1, 1, GPIO_HIGH_LEVEL);
#endif

#if defined(BOARD_SABRE_AI)
    board_ioexpander_iomux_config();
    /*power supply through pin25 of connector, direct connected to P3V3_DELAY,
       controlled by CPU_PER_RST_B */
    /*reset of camera sensor, together with the reset button */
    max7310_set_gpio_output(0, 2, GPIO_LOW_LEVEL);
    hal_delay_us(1000);
    max7310_set_gpio_output(0, 2, GPIO_HIGH_LEVEL);
    max7310_set_gpio_output(0, 0, GPIO_HIGH_LEVEL);

#endif

#if defined(BOARD_SMART_DEVICE)
    /*power supply through pin25 of connector, for cam_pdown */
    gpio_set_gpio(GPIO_PORT6, 9);
    HW_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_WP_B_SRE_V(SLOW));
    gpio_set_direction(GPIO_PORT6, 9, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT6, 9, GPIO_HIGH_LEVEL);

    /*reset of camera sensor, pin 27 */
    gpio_set_gpio(GPIO_PORT6, 10);
    HW_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_READY_SRE_V(SLOW));
    gpio_set_direction(GPIO_PORT6, 10, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT6, 10, GPIO_LOW_LEVEL);
    hal_delay_us(1000);
    gpio_set_level(GPIO_PORT6, 10, GPIO_HIGH_LEVEL);
#endif
}
Пример #4
0
/*!
 * enable mipi backlight
 */
void mipi_backlight_en(void)
{
    //configure pin19 of the mipi dsi/csi connector
#ifdef BOARD_EVB
    //set GPIO1_9 to 0 so clear vbus on board
    gpio_set_direction(GPIO_PORT1, 9, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT1, 9, GPIO_HIGH_LEVEL);
#endif

#ifdef BOARD_SABRE_AI
    //default be populated by P3V3_DELAYED
#endif

#ifdef BOARD_SMART_DEVICE
    gpio_set_gpio(GPIO_PORT2, 0);
    HW_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_DATA00_SRE_V(SLOW));
    gpio_set_direction(GPIO_PORT2, 0, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT2, 0, GPIO_HIGH_LEVEL);
#endif
}
Пример #5
0
//Even though it's annoying to be locked into these 4 gpio pins, the fact
//that they'll always work without physical adjustment is a nice feature
void initIO(){
	//Mode0 names
	char gpio1[] = "gpmc_wait0";
	char gpio2[] = "gpmc_wpn";
	char gpio3[] = "gpmc_a0";
	char gpio4[] = "spi0_cs0";

	int i;

	//Set pin mux in gpio output mode for controlGPIOss
#ifdef SET_PIN_MUX
mode_gpio_out(gpio1);
	mode_gpio_out(gpio2);
	mode_gpio_out(gpio3);
	mode_gpio_out(gpio4);
#endif

	//Export gpios and set up output direction for controlGPIOss
	for (i = 0; i < 5; i++){
		gpio_export(controlGPIOs[i]);
		gpio_set_direction(controlGPIOs[i], 1);
	}
	//Toggle switch gpio
	printf("%d\n", controlGPIOs[4]);
	gpio_export(controlGPIOs[4]);
	gpio_set_direction(controlGPIOs[4], 0);
	
}
Пример #6
0
void lcd_attach( device_t parent, device_t self, void *aux )
{
	struct imx51_ipuv3_softc *sc = device_private(self);
	struct axi_attach_args *axia = aux;
	bus_space_tag_t iot = axia->aa_iot;

	sc->dev = self;

	/* XXX move this to imx51_ipuv3.c */
	{
		bus_space_handle_t mipi_ioh;
		uint32_t reg;

		if (bus_space_map(iot, 0x83fdc000, 0x1000, 0, &mipi_ioh))
			aprint_error_dev(self, "can't map MIPI HSC");
		else {
			bus_space_write_4(iot, mipi_ioh, 0x000, 0xf00);

			reg = bus_space_read_4(iot, mipi_ioh, 0x800);
			bus_space_write_4(iot, mipi_ioh, 0x800, reg | 0x0ff);

			reg = bus_space_read_4(iot, mipi_ioh, 0x800);
			bus_space_write_4(iot, mipi_ioh, 0x800, reg | 0x10000);
		}
	}

	/* LCD power on */
	gpio_set_direction(GPIO_NO(4, 9), GPIO_DIR_OUT);
	gpio_set_direction(GPIO_NO(4, 10), GPIO_DIR_OUT);
	gpio_set_direction(GPIO_NO(3, 3), GPIO_DIR_OUT);

	gpio_data_write(GPIO_NO(3, 3), 1);
	gpio_data_write(GPIO_NO(4, 9), 1);
	delay(180 * 1000);
	gpio_data_write(GPIO_NO(4, 10), 1);

	gpio_set_direction(GPIO_NO(2, 13), GPIO_DIR_OUT);
	gpio_data_write(GPIO_NO(2, 13), 1);

	imx51_ipuv3_attach_sub(sc, aux, &sharp_panel);

#if NWSDISPLAY == 0
	struct imx51_ipuv3_screen *screen;
	int error;

	error = imx51_ipuv3_new_screen(sc, &screen);
#ifdef LCD_DEBUG
	draw_test_pattern(sc, screen);
#endif
	if (error == 0) {
		sc->active = screen;
		imx51_ipuv3_start_dma(sc, screen);
	}
#endif
}
Пример #7
0
void phy_rmii_smi_configure_pins(uint8_t mdc_gpio, uint8_t mdio_gpio)
{
    // setup SMI MDC pin
    gpio_set_direction(mdc_gpio, GPIO_MODE_OUTPUT);
    gpio_matrix_out(mdc_gpio, EMAC_MDC_O_IDX, 0, 0);
    PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[mdc_gpio], PIN_FUNC_GPIO);
    // setup SMI MDIO pin
    gpio_set_direction(mdio_gpio, GPIO_MODE_INPUT_OUTPUT);
    gpio_matrix_out(mdio_gpio, EMAC_MDO_O_IDX, 0, 0);
    gpio_matrix_in(mdio_gpio, EMAC_MDI_I_IDX, 0);
    PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[mdio_gpio], PIN_FUNC_GPIO);
}
Пример #8
0
void ws2812_init(int gpioNum)
{
  SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_RMT_CLK_EN);
  CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_RMT_RST);

  PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpioNum], 2);
  gpio_matrix_out(gpioNum, RMT_SIG_OUT0_IDX + RMTCHANNEL, 0, 0);
  gpio_set_direction(gpioNum, GPIO_MODE_OUTPUT);

  ws2812_initRMTChannel(RMTCHANNEL);

  RMT.tx_lim_ch[RMTCHANNEL].limit = MAX_PULSES;
  RMT.int_ena.ch0_tx_thr_event = 1;
  RMT.int_ena.ch0_tx_end = 1;

  ws2812_bits[0].level0 = 1;
  ws2812_bits[0].level1 = 0;
  ws2812_bits[0].duration0 = PULSE_T0H;
  ws2812_bits[0].duration1 = PULSE_T0L;
  ws2812_bits[1].level0 = 1;
  ws2812_bits[1].level1 = 0;
  ws2812_bits[1].duration0 = PULSE_T1H;
  ws2812_bits[1].duration1 = PULSE_T1L;

  esp_intr_alloc(ETS_RMT_INTR_SOURCE, 0, ws2812_handleInterrupt, NULL, &rmt_intr_handle);

  return;
}
Пример #9
0
int softpwm_start(const char *key, float duty, float freq, int polarity)
{
    struct softpwm *new_pwm, *pwm;
    pthread_t new_thread;
    pthread_mutex_t *new_params_lock;
    int gpio;
    int ret;

    if (get_gpio_number(key, &gpio) < 0)
        return -1;
    if (gpio_export(gpio) < 0)
        return -1;
    if (gpio_set_direction(gpio, OUTPUT) < 0)
        return -1;

    // add to list
    new_pwm = malloc(sizeof(struct softpwm));  ASSRT(new_pwm != NULL);
    new_params_lock = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
    if (new_pwm == 0) {
        return -1; // out of memory
    }
    pthread_mutex_init(new_params_lock, NULL);
    pthread_mutex_lock(new_params_lock);

    strncpy(new_pwm->key, key, KEYLEN);  /* can leave string unterminated */
    new_pwm->key[KEYLEN] = '\0'; /* terminate string */
    new_pwm->gpio = gpio;
    new_pwm->params.enabled = true;
    new_pwm->params.stop_flag = false;
    new_pwm->params_lock = new_params_lock;
    new_pwm->next = NULL;

    if (exported_pwms == NULL)
    {
        // create new list
        exported_pwms = new_pwm;
    } else {
        // add to end of existing list
        pwm = exported_pwms;
        while (pwm->next != NULL)
            pwm = pwm->next;
        pwm->next = new_pwm;
    }
    pthread_mutex_unlock(new_params_lock);

    ASSRT(softpwm_set_duty_cycle(new_pwm->key, duty) == 0);
    ASSRT(softpwm_set_frequency(new_pwm->key, freq) == 0);
    ASSRT(softpwm_set_polarity(new_pwm->key, polarity) == 0);

    pthread_mutex_lock(new_params_lock);
    // create thread for pwm
    ret = pthread_create(&new_thread, NULL, softpwm_thread_toggle, (void *)new_pwm);
    ASSRT(ret == 0);

    new_pwm->thread = new_thread;

    pthread_mutex_unlock(new_params_lock);

    return 1;
}
Пример #10
0
/* This replaces the default PHY power on/off function with one that
   also uses a GPIO for power on/off.

   If this GPIO is not connected on your device (and PHY is always powered), you can use the default PHY-specific power
   on/off function rather than overriding with this one.
*/
static void phy_device_power_enable_via_gpio(bool enable)
{
    assert(DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable);

    if (!enable) {
        /* Do the PHY-specific power_enable(false) function before powering down */
        DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable(false);
    }

    gpio_pad_select_gpio(PIN_PHY_POWER);
    gpio_set_direction(PIN_PHY_POWER,GPIO_MODE_OUTPUT);
    if(enable == true) {
        gpio_set_level(PIN_PHY_POWER, 1);
        ESP_LOGD(TAG, "phy_device_power_enable(TRUE)");
    } else {
        gpio_set_level(PIN_PHY_POWER, 0);
        ESP_LOGD(TAG, "power_enable(FALSE)");
    }

    // Allow the power up/down to take effect, min 300us
    vTaskDelay(1);

    if (enable) {
        /* Run the PHY-specific power on operations now the PHY has power */
        DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable(true);
    }
}
Пример #11
0
int main(int argc,char **argv)
{
	unsigned int ret;
	int i;
	GPIO_OPEN();

	printf("\n%s entered\n",argv[0]);
/*      
        //gpio output test
	gpio_set_port_data(0x80);
	gpio_set_direction(0xff);
	gpio_set_int_mask(0xff);
	gpio_set_event_type(0xff);
	ret = gpio_get_int_status();
*/
	for(i=0;i<0xffff;i++);
        //gpio input test
	gpio_set_direction(0x0);
	gpio_set_int_mask(0x0);
	gpio_set_event_type(0xff);
	ret = gpio_get_port_data();
	printf("get port data = 0x%x\n",ret);
	ret = gpio_get_int_status();	
	printf("gpio status = %x\n",ret);
	
	GPIO_CLOSE();
	return 0;

}
Пример #12
0
/* HAL functions */
int sj_gpio_set_mode(int pin, enum gpio_mode mode, enum gpio_pull_type pull) {
  if (mode == GPIO_MODE_INOUT) {
    fprintf(stderr, "Inout mode is not supported\n");
    return -1;
  }

  if (pull != GPIO_PULL_FLOAT) {
    /*
     * Documented API for using internal pullup/pulldown
     * resistors requires kernel built with special flags
     * Basically, it works in Raspberian only
     * (and causes crash in another Linux)
     * Do not support internal pulling for now
     */
    fprintf(stderr, "Pullup/pulldown aren't supported\n");
    return -1;
  }

  if (gpio_export(pin) < 0) {
    return -1;
  }

  if (mode == GPIO_MODE_INT) {
    /*
     * GPIO should be in "IN" mode
     * for using /sys/edge
     */
    mode = GPIO_MODE_INPUT;
  }

  return gpio_set_direction(pin, mode);
}
Пример #13
0
static void phy_device_power_enable_via_gpio(bool enable)
{
    assert(DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable);

    if (!enable) {
        DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable(false);
    }

    gpio_pad_select_gpio(PIN_PHY_POWER);
    gpio_set_direction(PIN_PHY_POWER, GPIO_MODE_OUTPUT);
    if (enable == true) {
        gpio_set_level(PIN_PHY_POWER, 1);
        ESP_LOGI(__func__, "Power On Ethernet PHY");
    } else {
        gpio_set_level(PIN_PHY_POWER, 0);
        ESP_LOGI(__func__, "Power Off Ethernet PHY");
    }

    vTaskDelay(1); // Allow the power up/down to take effect, min 300us

    if (enable) {
        /* call the default PHY-specific power on function */
        DEFAULT_ETHERNET_PHY_CONFIG.phy_power_enable(true);
    }
}
void gpio_init(int gpio_id, char* direction, char value) {
	gpio_export(gpio_id);
	gpio_set_direction(gpio_id, direction);
	if (!strcmp(direction, "out")) {
		gpio_set_value(gpio_id, value);	
	}
}
int setup_pins(int gpionum)
{

    /*
     * Create the required GPIO pin and reserve it
     */

    if (gpio_alloc(gpionum))
        {
        fprintf(stderr, "Error allocating GPIO %d, errno = %d\n", gpionum, errno);
        return (1);
        }

    if (gpio_set_direction(gpionum, "out"))
        {
        fprintf(stderr, "Error setting GPIO %d direction, errno = %d\n", gpionum, errno);
        return (1);
        }

    if (gpio_write_pin(gpionum, "1"))
        {
        fprintf(stderr, "Error setting GPIO %d value, errno = %d\n", gpionum, errno);
        return (1);
        }

      return(0);
}
Пример #16
0
/**
 * Initialize the device.
 * @param device - The device structure.
 * @param init_param - The structure that contains the device initial
 * 					   parameters.
 * @return 0 in case of success, negative error code otherwise.
 */
int32_t adaq7980_setup(adaq7980_dev **device,
					 adaq7980_init_param init_param)
{
	adaq7980_dev *dev;
	int32_t ret = 0;

	dev = (adaq7980_dev *)malloc(sizeof(*dev));
	if (!dev) {
		return -1;
	}

	dev->spi_dev.chip_select = init_param.spi_chip_select;
	dev->spi_dev.mode = init_param.spi_mode;
	dev->spi_dev.device_id = init_param.spi_device_id;
	dev->spi_dev.type = init_param.spi_type;

	dev->gpio_dev.device_id = init_param.gpio_device_id;
	dev->gpio_dev.type = init_param.gpio_type;
	ret |= gpio_init(&dev->gpio_dev);

	dev->gpio_pd_ldo = init_param.gpio_pd_ldo;
	ret |= gpio_set_direction(&dev->gpio_dev, dev->gpio_pd_ldo, GPIO_OUT);
	ret |= gpio_set_value(&dev->gpio_dev, dev->gpio_pd_ldo, GPIO_LOW);
	mdelay(10);
	ret |= gpio_set_value(&dev->gpio_dev, dev->gpio_pd_ldo, GPIO_HIGH);
	mdelay(10);

	*device = dev;

	if (!ret)
		printf("adaq7980 successfully initialized\n");

	return ret;
}
Пример #17
0
/*
 * Reserve a GPIO and set it as output. Than set the state
 * and release the port.
 * @gpio the GPIO pin to set the state for.
 * @state 1 or 0
 * @return true if the state change was successful.
 */
bool gpio_write_and_close(int gpio, int state)
{
    return gpio_reserve(gpio)
           && gpio_set_direction(gpio, GPIO_OUT)
           && gpio_set_state(gpio, state)
           && gpio_release(gpio);
}
Пример #18
0
void Led_flash(void)
{
    gpio_set_direction(GPIO_P01, GPIO_OUTPUT);
    gpio_toggle_pin(GPIO_P01);
    delay(100000);
    gpio_toggle_pin(GPIO_P01);
}
Пример #19
0
esp_err_t rmt_set_pin(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_num)
{
    RMT_CHECK(channel < RMT_CHANNEL_MAX, RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG);
    RMT_CHECK(mode < RMT_MODE_MAX, RMT_MODE_ERROR_STR, ESP_ERR_INVALID_ARG);
    RMT_CHECK(((GPIO_IS_VALID_GPIO(gpio_num) && (mode == RMT_MODE_RX)) || (GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) && (mode == RMT_MODE_TX))),
        RMT_GPIO_ERROR_STR, ESP_ERR_INVALID_ARG);

    PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpio_num], 2);
    if(mode == RMT_MODE_TX) {
        gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT);
        gpio_matrix_out(gpio_num, RMT_SIG_OUT0_IDX + channel, 0, 0);
    } else {
        gpio_set_direction(gpio_num, GPIO_MODE_INPUT);
        gpio_matrix_in(gpio_num, RMT_SIG_IN0_IDX + channel, 0);
    }
    return ESP_OK;
}
Пример #20
0
/*!
 * Turn on LCDIF power_en pin
 *
 * KEY_ROW5 (pin79) controls WVGA panel DISP pin, which is active high. 
 * 
 */
void lcdif_power_on(void)
{
	/* turn on lcdif power on
	 * (KEY_ROW5) ALT5: GPIO4_3 */
    gpio_set_gpio(GPIO_PORT4, 3);
	gpio_set_direction(GPIO_PORT4, 3, GPIO_GDIR_OUTPUT);
	gpio_set_level(GPIO_PORT4, 3, GPIO_HIGH_LEVEL);
}
Пример #21
0
void epdc_power_supply(void)
{
	int i = 0;

	//EN : pmic_wakeup gpio2.14
    gpio_set_gpio(GPIO_PORT2, 14);
	gpio_set_direction(GPIO_PORT2, 14, GPIO_GDIR_OUTPUT);
	gpio_set_level(GPIO_PORT2, 14, GPIO_HIGH_LEVEL);

    //CEN : pmic_vcom gpio2.3
    gpio_set_gpio(GPIO_PORT2, 3);
	gpio_set_direction(GPIO_PORT2, 3, GPIO_GDIR_OUTPUT);
	gpio_set_level(GPIO_PORT2, 3, GPIO_HIGH_LEVEL);

    for (i = 0; i < 1000000; i++)
        __asm("nop");
}
Пример #22
0
/***************************************************************************//**
* @brief main
*******************************************************************************/
int main(void)
{
	ad7768_dev	*dev;
	gpio_device	gpio_dev;
	adc_core	core;

	ad7768_setup(&dev, default_init_param);

	/* Configure HDL */
	gpio_set_direction(&dev->gpio_dev, GPIO_UP_FORMAT_1, GPIO_OUT);
	gpio_set_value(&dev->gpio_dev, GPIO_UP_FORMAT_1, 0);
	gpio_set_direction(&dev->gpio_dev, GPIO_UP_FORMAT_0, GPIO_OUT);
	gpio_set_value(&dev->gpio_dev, GPIO_UP_FORMAT_0, 0);
	gpio_set_direction(&dev->gpio_dev, GPIO_UP_CRC_ENABLE, GPIO_OUT);
	gpio_set_value(&dev->gpio_dev, GPIO_UP_CRC_ENABLE,
			dev->crc_sel ? 1 : 0);
	gpio_set_direction(&dev->gpio_dev, GPIO_UP_CRC_4_OR_16_N, GPIO_OUT);
	gpio_set_value(&dev->gpio_dev, GPIO_UP_CRC_4_OR_16_N,
			dev->crc_sel == AD7768_CRC_4 ? 1 : 0);

	gpio_dev.type = AXI_GPIO;
	gpio_dev.device_id = XPAR_AD7768_GPIO_DEVICE_ID;
	gpio_init(&gpio_dev);

	ad7768_evb_clear_status(&gpio_dev);
	if (ad7768_evb_verify_status(&gpio_dev))
		printf("Interface errors\n");
	else
		printf("Interface OK\n");

	core.dmac_baseaddr = AD7768_DMA_BASEADDR;
	core.no_of_channels = 8;
	core.resolution = 24;

	printf("Capture samples...\n");
	adc_capture(core, 1024, ADC_DDR_BASEADDR);
	printf("Capture done\n");

	if (ad7768_evb_verify_status(&gpio_dev))
		printf("Interface errors\n");
	else
		printf("Interface OK\n");

	return 0;
}
Пример #23
0
/*! From obds
 * Audio Codec Power on
 */
void audio_codec_power_on (void)
{
#ifdef BOARD_SMART_DEVICE
    //CODEC PWR_EN, key_col12
    gpio_set_gpio(GPIO_PORT4, 10);
    gpio_set_direction(GPIO_PORT4, 10, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT4, 10, GPIO_HIGH_LEVEL);
#endif
}
Пример #24
0
void phy_rmii_configure_data_interface_pins(void)
{
    // CRS_DRV to GPIO27
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO27_U, FUNC_GPIO27_EMAC_RX_DV);

    // TXD0 to GPIO19
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, FUNC_GPIO19_EMAC_TXD0);
    // TX_EN to GPIO21
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_EMAC_TX_EN);
    // TXD1 to GPIO22
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, FUNC_GPIO22_EMAC_TXD1);
    // RXD0 to GPIO25
    gpio_set_direction(25, GPIO_MODE_INPUT);
    // RXD1 to GPIO26
    gpio_set_direction(26, GPIO_MODE_INPUT);
    // RMII CLK to GPIO0
    gpio_set_direction(0, GPIO_MODE_INPUT);
}
Пример #25
0
/*
 * Bypass the command sending infrastructure to allow
 * direct access to the what is sent to the chip
 */
static int cc2530_burst_write(void)
{
	int ret;
	uint16_t i;
	unsigned char result;
	unsigned int timeout = DEFAULT_TIMEOUT;
	bool val;

	ret = gpio_set_direction(DATA_GPIO, GPIO_DIRECTION_OUT);
	if (ret) {
		fprintf(stderr, "failed to put gpio in output direction\n");
		return ret;
	}

	send_byte(CMD_BURST_WR | HIBYTE(PROG_BLOCK_SIZE));
	send_byte(LOBYTE(PROG_BLOCK_SIZE));

	for (i = 0; i < PROG_BLOCK_SIZE; i++)
		send_byte(get_next_flash_byte());

	ret = gpio_set_direction(DATA_GPIO, GPIO_DIRECTION_IN);
	if (ret) {
		fprintf(stderr, "failed to put gpio in input direction\n");
		return ret;
	}

	gpio_get_value(DATA_GPIO, &val);
	while (val && timeout--) {
		for (i = 0; i < 8; i++) {
			gpio_set_value(CCLK_GPIO, 1);
			gpio_set_value(CCLK_GPIO, 0);
		}
		gpio_get_value(DATA_GPIO, &val);
	}

	if (!timeout) {
		fprintf(stderr, "timed out waiting for chip to be ready\n");
		return -1;
	}

	read_byte(&result);

	return 0;
}
Пример #26
0
void spdc_power_up(void)
{
    int i = 0;

    gpio_set_gpio(GPIO_PORT1, 17);
    gpio_set_direction(GPIO_PORT1, 17, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT1, 17, GPIO_LOW_LEVEL);

    /* Using the MAX17135 as the power supplier 
     * Panel connector are using the AXT334124
     *
     * Power Sequence:
     * VDD_Panel -> VEE -> VGG -> VDNS -> VDPS -> Vcom
     * 
     * Pin Connections:
     * Name         Pin# of MAX17135        Pin# of AXT334124   Comment
     * VDD_Panel:   3V15(from mainboard)    5,7                 default enabled, comming from DCDC3V15
     * VEE          6(DGVEE)                27,29
     * VGG          4(DGVDD)                23,25
     * VDNS         23(POS)                 1,3
     * VDPS         24(NEG)                 2,4
     * Vcom:        22(VCOM)                22,24
     */
    gpio_set_gpio(GPIO_PORT2, 7);
    gpio_set_direction(GPIO_PORT2, 7, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT2, 7, GPIO_HIGH_LEVEL);

    //EN : pmic_wakeup gpio2.14
    gpio_set_gpio(GPIO_PORT2, 14);
    gpio_set_direction(GPIO_PORT2, 14, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT2, 14, GPIO_HIGH_LEVEL);

    //CEN : pmic_vcom gpio2.3 
    gpio_set_gpio(GPIO_PORT2, 3);
    gpio_set_direction(GPIO_PORT2, 3, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT2, 3, GPIO_HIGH_LEVEL);

    while (i++ < 10000)
        __asm("nop");

    gpio_set_gpio(GPIO_PORT1, 17);
    gpio_set_direction(GPIO_PORT1, 17, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT1, 17, GPIO_HIGH_LEVEL);
}
Пример #27
0
/*!
 * reset MIPI display
 */
void mipi_display_reset(void)
{
#ifdef BOARD_EVB
/*pin29 of mipi connector for the LCD reset*/
    gpio_set_gpio(GPIO_PORT5, 0);
    HW_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_EIM_WAIT_SRE_V(SLOW));
    gpio_set_direction(GPIO_PORT5, 0, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT5, 0, GPIO_LOW_LEVEL);
    hal_delay_us(1000);
    gpio_set_level(GPIO_PORT5, 0, GPIO_HIGH_LEVEL);
    hal_delay_us(1000);
#endif

#ifdef BOARD_SABRE_AI
/*binded with the board reset button*/
#endif

#ifdef BOARD_SMART_DEVICE
/*pin29 of mipi connector for the LCD reset*/
    gpio_set_gpio(GPIO_PORT6, 11);
    HW_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_WR(
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_HYS_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_PUS_V(100K_OHM_PU) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_PUE_V(PULL) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_PKE_V(ENABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_ODE_V(DISABLED) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_SPEED_V(100MHZ) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_DSE_V(40_OHM) |
            BF_IOMUXC_SW_PAD_CTL_PAD_NAND_CS0_B_SRE_V(SLOW));
    gpio_set_direction(GPIO_PORT6, 11, GPIO_GDIR_OUTPUT);
    gpio_set_level(GPIO_PORT6, 11, GPIO_LOW_LEVEL);
    hal_delay_us(1000);
    gpio_set_level(GPIO_PORT6, 11, GPIO_HIGH_LEVEL);
    hal_delay_us(1000);
#endif
}
Пример #28
0
int main(void)
{
	// Configure GPIOs:
	gpio_set_direction(IO_ADDRESS(GPIO1_BASE), 0x0000); // Switches
	gpio_set_direction(IO_ADDRESS(GPIO2_BASE), 0xffff); // LEDs

	// Configure the 7-segment displays:
	seg7_set_enabled_displays(IO_ADDRESS(SEG7_BASE), 0xff);
	seg7_set_value(IO_ADDRESS(SEG7_BASE), 0);

	// Set up the timer:
	timer_set(IO_ADDRESS(TIMER_BASE), SYSTEM_CLK_FREQ);

	// Print a startup message:
	uart_puts(IO_ADDRESS(UART_BASE), "The Potato Processor SHA256 Benchmark\n\r\n\r");

	// Enable interrupts:
	potato_enable_irq(IRQ_TIMER);
	potato_enable_interrupts();

	struct sha256_context context;

	// Prepare a block for hashing:
	uint32_t block[16];
	uint8_t * block_ptr = (uint8_t *) block;
	block_ptr[0] = 'a';
	block_ptr[1] = 'b';
	block_ptr[2] = 'c';
	sha256_pad_le_block(block_ptr, 3, 3);

	// Repeatedly hash the same data over and over again:
	while(true)
	{
		uint8_t hash[32];

		sha256_reset(&context);
		sha256_hash_block(&context, block);
		sha256_get_hash(&context, hash);
		++hashes_per_second;
	}

	return 0;
}
Пример #29
0
/*!
 * set camera sensor to standby mode.
 *
 * @param	enable: specify whether set camera sensor to standby mode
 * 
 */
void sensor_standby(int32_t enable)
{
    /* MX6DQ/SDL_SMART_DEVICE: setting to gpio1_16, power down high active */
	BW_IOMUXC_SW_MUX_CTL_PAD_SD1_DATA0_MUX_MODE(BV_IOMUXC_SW_MUX_CTL_PAD_SD1_DATA0_MUX_MODE__ALT5);
	gpio_set_direction(GPIO_PORT1, 16, GPIO_GDIR_OUTPUT);
    if (enable)
		gpio_set_level(GPIO_PORT1, 16, GPIO_HIGH_LEVEL);
    else
		gpio_set_level(GPIO_PORT1, 16, GPIO_LOW_LEVEL);
}
Пример #30
0
static int checkOverrideGpio() {
#ifdef BOOTWIFI_OVERRIDE_GPIO
	gpio_pad_select_gpio(BOOTWIFI_OVERRIDE_GPIO);
	gpio_set_direction(BOOTWIFI_OVERRIDE_GPIO, GPIO_MODE_INPUT);
	gpio_set_pull_mode(BOOTWIFI_OVERRIDE_GPIO, GPIO_PULLDOWN_ONLY);
	return gpio_get_level(BOOTWIFI_OVERRIDE_GPIO);
#else
	return 0; // If no boot override, return false
#endif
} // checkOverrideGpio