Example #1
0
File: usart.c Project: onkwon/yaos
int __usart_open(unsigned int channel, unsigned int baudrate)
{
	if (channel)
		return -ERR_RANGE;

	/* Set GPIO first */
	SET_GPIO_FS(14, GPIO_ALT5);
	SET_GPIO_FS(15, GPIO_ALT5);
	gpio_pull(14, 0);
	gpio_pull(15, 0);

	struct aux *aux = (struct aux *)AUX_BASE;
	struct mini_uart *uart = (struct mini_uart *)UART_BASE;

	aux->enable = 1; /* enable mini-uart */
	uart->cntl  = 0;
	uart->lcr   = 3; /* 8-bit data */
	uart->iir   = 0xc6;
	uart->ier   = 5; /* enable rx interrupt */
	uart->baudrate = (SYSTEM_CLOCK / (baudrate * 8)) - 1;

	uart->cntl = 3; /* enable rx and tx */

	struct interrupt_controller *intcntl
		= (struct interrupt_controller *)INTCNTL_BASE;
	intcntl->irq1_enable = 1 << IRQ_AUX;

	return IRQ_AUX; /* aux int */
}
Example #2
0
FTVOID ft9xx_sdc_init (FTVOID)
{
#define SDC_TRY_RUN 10
#define SDC_TRY_WAIT 10
	FTU8 i = 0;

	sys_enable(sys_device_sd_card);	
	sdhost_init();

	gpio_function(FT9XX_SD_CLK, pad_sd_clk); 
	gpio_pull(FT9XX_SD_CLK, pad_pull_none);
	gpio_function(FT9XX_SD_CMD, pad_sd_cmd); 
	gpio_pull(FT9XX_SD_CMD, pad_pull_pullup);
	gpio_function(FT9XX_SD_DAT3, pad_sd_data3); 
	gpio_pull(FT9XX_SD_DAT3, pad_pull_pullup);
    gpio_function(FT9XX_SD_DAT2, pad_sd_data2); 
	gpio_pull(FT9XX_SD_DAT2, pad_pull_pullup);
	gpio_function(FT9XX_SD_DAT1, pad_sd_data1); 
	gpio_pull(FT9XX_SD_DAT1, pad_pull_pullup);
	gpio_function(FT9XX_SD_DAT0, pad_sd_data0); 
	gpio_pull(FT9XX_SD_DAT0, pad_pull_pullup);
	gpio_function(FT9XX_SD_CD, pad_sd_cd); 
	gpio_pull(FT9XX_SD_CD, pad_pull_pullup);
	gpio_function(FT9XX_SD_WP, pad_sd_wp); 
	gpio_pull(FT9XX_SD_WP, pad_pull_pullup);

	while ((SDC_TRY_RUN != ++i) && (sdhost_card_detect() != SDHOST_CARD_INSERTED)) {
		delayms(SDC_TRY_WAIT);
		FTPRINT(".");
	}

	if(i < SDC_TRY_RUN) {
		if (f_mount(&FT9xxFatFs, "", 0) != FR_OK) {
			FTPRINT("\nMount Disk Fail");
		} else {
			/* this lib seems not set the fs_type 
			   even it successful mounted */
			if (FT9xxFatFs.fs_type) { 
				FTPRINT("\nMount Disk Success");
			} else {
				FTPRINT("\nDisk Found");
			}
		}
	} else {
		FTPRINT("\nNo SD Card");
	}
		
	return;
}
Example #3
0
static int __init menu_buttons_init(void) {
	int ret;

	if (verbose) {
		pr_info("\n\n"DRVNAME": %s()\n", __func__);
		pr_info(DRVNAME":   driver: %s\n", menu_buttons.name);
	}

	gpio_pull(1);

	ret = platform_device_register(&menu_buttons);
	if (ret < 0) {
		pr_err(DRVNAME": platform_device_register() returned %d\n", ret);
		return ret;
	}

	return 0;
}
Example #4
0
static void pdev_release(struct device *dev) {
	if (verbose > 1)
		pr_info(DRVNAME": %s()\n", __func__);

	gpio_pull(0);
}