示例#1
0
static int stmmac_setup(void)
{
	clock_setup(SYSCFG_CLOCK_CFG);
	/* Set >RMII mode */
	STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
	clock_setup(STMMAC_CLOCK_CFG);

	return 0;
}
示例#2
0
文件: main.c 项目: Mechelix/btstack
int main(void)
{
	clock_setup();
	gpio_setup();
	hal_tick_init();
	debug_usart_setup();
	bluetooth_setup();

	// start with BTstack init - especially configure HCI Transport
    btstack_memory_init();
    run_loop_init(RUN_LOOP_EMBEDDED);
    
    // init HCI
    hci_transport_t    * transport = hci_transport_h4_dma_instance();
    bt_control_t       * control   = bt_control_cc256x_instance();
    remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
    hci_init(transport, (void*) &hci_uart_config_cc256x, control, remote_db);

    // enable eHCILL
    bt_control_cc256x_enable_ehcill(1);

	// hand over to btstack embedded code 
    btstack_main();

    // go
    run_loop_execute();

	return 0;
}
示例#3
0
int main(void)
{
	int i;

	struct color colors[COLOR_COUNT];

	clock_setup();
	gpio_setup();

	reset_colors(colors, COLOR_COUNT);
	init_colors(colors, COLOR_COUNT);

	while (1) {
		gpio_toggle(GPIOC, GPIO12);	/* LED on/off */

		send_colors(colors, COLOR_COUNT);

		step_colors(colors, COLOR_COUNT);

		for (i = 0; i < 1000000; i++)	/* Wait a bit. */
			__asm__("nop");
	}

	return 0;
}
示例#4
0
文件: stv0991.c 项目: OpenNoah/u-boot
int board_eth_enable(void)
{
	stv0991_pinmux_config(ETH_GPIOB_10_31_C_0_4);
	clock_setup(ETH_CLOCK_CFG);
	enable_eth_phy();
	return 0;
}
示例#5
0
int main(void)
{
	clock_setup();
	usart_clock_setup();
	gpio_setup();
	usart_setup();

	printf("\r\nstarting i2c scan.\r\n");

	int i, j;
	for (i = 1; i < 0x80; i++) {
		i2c_init();
		msleep(50);
		for (j = 0; j < 0x100; j++) {
			int data; // = 0;
			data = i2c_read(I2C3, i, j);
			if (data > -1) {
				if (data) {
					printf("device on address 0x%02X : reg = 0x%02X with data == 0x%02X\r\n", i, j, data);
				}
			} else {
				printf("errerr!!\r\n");
				break;
			}
			//i2c_send_stop(I2C3);
		}
		i2c_deinit();
		msleep(50);
	}
	printf("scan ended!\r\n");
	return 0;
}
示例#6
0
int main(void)
{
	int i, j = 0, c = 0;

	clock_setup();
	gpio_setup();
	usart_setup();

	/* Blink the LED (PE10) on the board with every transmitted byte. */
	while (1) {
		gpio_toggle(GPIO_PE10);			/* LED on/off */
		usart_send_blocking(USART1, c + '0');	/* USART1: Send byte. */
		usart_send_blocking(USART2, c + '0');	/* USART2: Send byte. */
		usart_send_blocking(USART3, c + '0');	/* USART3: Send byte. */
		c = (c == 9) ? 0 : c + 1;	/* Increment c. */
		if ((j++ % 80) == 0) {	/* Newline after line full. */
			usart_send_blocking(USART1, '\r');
			usart_send_blocking(USART1, '\n');
			usart_send_blocking(USART2, '\r');
			usart_send_blocking(USART2, '\n');
			usart_send_blocking(USART3, '\r');
			usart_send_blocking(USART3, '\n');
		}
		for (i = 0; i < 800000; i++)	/* Wait a bit. */
			__asm__ ("nop");
	}

	return 0;
}
int main(void)
{

    uint16_t printer_data = 0xff;
    clock_setup();
    gpio_setup();
    mco_setup();
    usart_setup();
    spi_setup();
    //timer_setup();
    systick_setup(SYSTICK_FREQ);
    print("Hello from STM32F0\n");
   // StepperMotor engine(GPIOA, M1,M2,M3,M4);
    //gpio_port_write(GPIOA,0);
//    gpio_set(GPIOA,GPIO1);
    //engine.step(100);
    while (1) {
        printer_send(printer_data);
        engine.step(1);
        delay(200);
       //engine.step(1);
       /*
    for(i = 0; i < sizeof(steps)/sizeof(steps[0]);i++) {
    gpio_port_write(GPIOA,steps[i]);
    delay(3);
    }
    */
    };
}
int uart_setup_gpio(void)
{
	int i;
	int rv = 0;

	clock_setup(GPIO_A_CLOCK_CFG);
	clock_setup(GPIO_B_CLOCK_CFG);
	for (i = 0; i < ARRAY_SIZE(usart_gpio); i++) {
		rv = stm32_gpio_config(&usart_gpio[i], &gpio_ctl_usart);
		if (rv)
			goto out;
	}

out:
	return rv;
}
示例#9
0
文件: adc-temp.c 项目: brabo/disco
int main(void)
{
	int i;
	int j = 0;
	clock_setup();
	usart_setup();
	printf("hi guys!\n");
	adc_setup();

	/* green led for ticking */
	gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
			LED_DISCO_GREEN_PIN);

	while (1) {
		//uint16_t input_adc0 = read_adc_naiive(0);
		//uint16_t target = input_adc0 / 2;
		//uint16_t input_adc1 = ((uint16_t)((read_adc_naiive(18) - 760) / 25) + 25);
		int i;
		for (i = 0; i < 0x13; i++) {
			uint16_t input_adc1 = read_adc_naiive(i);
			printf("tick: %d: adc1_%02X=%d\n", j++, i, input_adc1);
		}
		uint32_t reg = ADC_CCR;
		printf("reg = 0x%08X\r\n", reg);

		/* LED on/off */
		gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN);

		for (i = 0; i < 1000000; i++) { /* Wait a bit. */
			__asm__("NOP");
		}
	}

	return 0;
}
示例#10
0
int main(void)
{
	int i;

	clock_setup();
	button_setup();
	gpio_setup();

	/* Blink the LED (PD12) on the board. */
	while (1) {
		gpio_toggle(GPIOD, GPIO12);

		/* Upon button press, blink more slowly. */
		if (gpio_get(GPIOA, GPIO0)) {
			for (i = 0; i < 3000000; i++) {	/* Wait a bit. */
				__asm__("nop");
			}
		}

		for (i = 0; i < 3000000; i++) {		/* Wait a bit. */
			__asm__("nop");
		}
	}

	return 0;
}
示例#11
0
int main()
{
	init_gpio_led();
	set_clock_on_mco();
	clock_setup();

	while (1) {
		//led_blue(1);
		//delay_us(100);
		//led_blue(0);
		//delay_ms(1);
		//delay_ms(1000);

		//led_green(1);
		//delay_ms(50);
		//led_green(0);
		//delay_ms(1000);

		GPIOC->ODR |= (1 << LED_BLUE);
		delay_us(1);
		GPIOC->ODR &= ~(1 << LED_BLUE);
		delay_us(1);

		//send_command(0, 0, 0);
		//delay_ms(180);
	}

	return 0;
}
示例#12
0
int main(void)
{
#if defined(BOOTLOADER8K)
	SCB_VTOR = (uint32_t) 0x08002000;
#endif

	int i;

	clock_setup();
	gpio_setup();

	/* Blink the LED on the board. */
	while (1) {
		gpio_toggle(LED_GPIO, LED_PIN);

		/* Upon button press, blink more slowly. */
		if (gpio_get(BUTTON_GPIO, BUTTON_PIN)) {
			for (i = 0; i < 2000000; i++) {	/* Wait a bit. */
				__asm__("nop");
			}
		}

		for (i = 0; i < 2000000; i++) {		/* Wait a bit. */
			__asm__("nop");
		}
	}

	return 0;
}
示例#13
0
static int setup_devices() {
	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

//	gpio_setup(); // Not yet

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
#ifndef CONFIG_IPHONE_4
	wdt_setup();
#endif

	// Other devices
	usb_shutdown();
#ifndef CONFIG_IPHONE_4
	uart_setup();
	i2c_setup();

	dma_setup();

	spi_setup();
#endif

	return 0;
}
示例#14
0
int main(void)
{
	int i;

	clock_setup();
	gpio_setup();
	button_setup();

	/* Blink the LED (PC9) on the board. */
	while (1) {
		gpio_toggle(GPIOC, GPIO9);

		/* Upon button press, blink more slowly. */
		exti_line_state = GPIOA_IDR;
		if ((exti_line_state & (1 << 0)) != 0) {
			for (i = 0; i < 800000; i++)	/* Wait a bit. */
				__asm__("nop");
		}

		for (i = 0; i < 800000; i++)		/* Wait a bit. */
			__asm__("nop");
	}

	return 0;
}
示例#15
0
文件: a4.c 项目: boydcase31/openiBoot
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();

	// Other devices
	usb_shutdown();
	uart_setup();
	i2c_setup();

	// DMA currently f***s up. Need to check why. -- Bluerise
	// dma_setup();

	LeaveCriticalSection();

	framebuffer_hook(); // TODO: Remove once LCD implemented -- Ricky26
	framebuffer_setdisplaytext(TRUE);
}
int main(void)
{
	int i, j;

	clock_setup();
	gpio_setup();
	usart_setup();
	printf("\nStandard I/O Example.\n");

	/* Blink the LED (PD12) on the board with every transmitted byte. */
	while (1) {
		int delay = 0;
		char local_buf[32];

		gpio_toggle(GPIOA, GPIO5);	/* LED on/off */
		do {
			printf("Enter the delay constant for blink : ");
			fflush(stdout);
			fgets(local_buf, 32, stdin);
			delay = atoi(local_buf);
			if (delay <= 0) {
				printf("Error: expected a delay > 0\n");
			}
		} while (delay <= 0);

		printf("Blinking with a delay of %d\n", delay);
		for (j = 0; j < 1000; j++) {
			gpio_toggle(GPIOA, GPIO5);
			for (i = 0; i < delay; i++) {	/* Wait a bit. */
				__asm__("NOP");
			}
		}
	}
	return 0;
}
示例#17
0
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();
	i2c_setup();
	/*uint8_t data[1]={(0x4 << ACC_CTRL_REG1_A_ODR_SHIFT) | ACC_CTRL_REG1_A_XEN};*/
	uint8_t data[1]={0x97};
	write_i2c(I2C1, I2C_ACC_ADDR, ACC_CTRL_REG1_A, 1, data);
	data[0]=0x08;
	write_i2c(I2C1, I2C_ACC_ADDR, ACC_CTRL_REG4_A, 1, data);
	uint16_t acc_x;

	while (1) {

		read_i2c(I2C1, I2C_ACC_ADDR, ACC_STATUS, 1, data);
		/*my_usart_print_int(USART2, data[0]);*/
		read_i2c(I2C1, I2C_ACC_ADDR, ACC_OUT_X_L_A, 1, data);
		acc_x=data[0];
		read_i2c(I2C1, I2C_ACC_ADDR, ACC_OUT_X_H_A, 1, data);
		acc_x|=(data[0] << 8);
		my_usart_print_int(USART2, (int16_t) acc_x);
		//int i;
		//for (i = 0; i < 800000; i++)    /* Wait a bit. */
		//  __asm__("nop");
	}

	return 0;
}
示例#18
0
int main(void)
{
    int counter = 0;
    float fcounter = 0.0;
    double dcounter = 0.0;

    clock_setup();
    gpio_setup();
    usart_setup();

    /*
     * Write Hello World, an integer, float and double all over
     * again while incrementing the numbers.
     */
    while (1) {
        gpio_toggle(GPIOC, GPIO12);
        printf("Hello World! %i %f %f\r\n", counter, fcounter,
               dcounter);
        counter++;
        fcounter += 0.01;
        dcounter += 0.01;
    }

    return 0;
}
示例#19
0
int main(void)
{
	int counter = 0;
	uint16_t rx_value = 0x42;

	clock_setup();
	gpio_setup();
	usart_setup();
	spi_setup();


	/* Blink the LED (PA8) on the board with every transmitted byte. */
	while (1) {
		/* LED on/off */
		gpio_toggle(GPIOA, GPIO8);

		/* printf the value that SPI should send */
		printf("Counter: %i  SPI Sent Byte: %i", counter, (uint8_t) counter);
		/* blocking send of the byte out SPI1 */
		spi_send(SPI1, (uint8_t) counter);
		/* Read the byte that just came in (use a loopback between MISO and MOSI
		 * to get the same byte back)
		 */
		rx_value = spi_read(SPI1);
		/* printf the byte just received */
		printf("    SPI Received Byte: %i\r\n", rx_value);

		counter++;
		
	}

	return 0;
}
示例#20
0
/*
 * Initialize the reference clocks.
 */
void clock_init(void)
{
	static u32 apbahb_presc_tbl[] = {0, 0, 0, 0, 1, 2, 3, 4,
					 1, 2, 3, 4, 6, 7, 8, 9};

	u32 tmp, presc, pllvco, pllp, pllm;

	/*
	 * Set clocks to cfg, which is differs from the poweron default
	 */
	clock_setup();


	clock_val[CLOCK_SYSCLK] = 0;

	clock_val[CLOCK_HCLK] = 0;

	clock_val[CLOCK_PCLK1] = 0;

	clock_val[CLOCK_PCLK2] = 0;

	/*
	 * Set SYSTICK. Divider "8" is the SOC hardcoded.
	 */
	 clock_val[CLOCK_SYSTICK] = 0;

	return;
}
示例#21
0
static int setup_devices() {
	// Basic prerequisites for everything else
	miu_setup();
	power_setup();
	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
	wdt_setup();

	// Other devices
	usb_shutdown();
	uart_setup();
	i2c_setup();

	dma_setup();

	spi_setup();

	return 0;
}
int main(void)
{
    int i;
    int j = 0;
    clock_setup();
    usart_setup();
    printf("hi guys!\n");
    adc_setup();
    dac_setup();
    gpio_set_mode(LED_DISCOVERY_USER_PORT, GPIO_MODE_OUTPUT_2_MHZ,
                  GPIO_CNF_OUTPUT_PUSHPULL, LED_DISCOVERY_USER_PIN);

    while (1) {
        uint16_t input_adc0 = read_adc_naiive(0);
        uint16_t target = input_adc0 / 2;
        dac_load_data_buffer_single(target, RIGHT12, CHANNEL_2);
        dac_software_trigger(CHANNEL_2);
        uint16_t input_adc1 = read_adc_naiive(1);
        printf("tick: %d: adc0= %u, target adc1=%d, adc1=%d\n",
               j++, input_adc0, target, input_adc1);
        gpio_toggle(LED_DISCOVERY_USER_PORT, LED_DISCOVERY_USER_PIN); /* LED on/off */
        for (i = 0; i < 1000000; i++) /* Wait a bit. */
            __asm__("NOP");
    }

    return 0;
}
示例#23
0
文件: a4.c 项目: chronzz/openiBoot
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();

	// Other devices
	uart_setup();
	i2c_setup();

	dma_setup();

	LeaveCriticalSection();

	displaypipe_init();
	framebuffer_setup();
	framebuffer_setdisplaytext(TRUE);
}
示例#24
0
int main(void)
{
	clock_setup();
	gpio_setup();
	tim_setup();
	spi_setup();
	dac_setup();
	dma_setup();
	usb_setup();

	/* Attach the device to USB. */
	syscfg_enable_usb_pullup();

	/* Clear interrupt. */
	usbdevfs_clear_interrupt(USBDEVFS_ALL_INTERRUPT);

	/* Enable interrupt. */
	usbdevfs_enable_interrupt(USBDEVFS_CORRECT_TRANSFER | USBDEVFS_ERROR |
				  USBDEVFS_RESET | USBDEVFS_SOF);

	/* Wait forever and do nothing. */
	while (1)
		__asm__ ("nop");

	return 0;
}
示例#25
0
int main(void)
{
	int i;
	int j = 0;
	clock_setup();
	usart_setup();
	printf("hi guys!\n");
	adc_setup();
	dac_setup();

	/* green led for ticking */
	gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
			LED_DISCO_GREEN_PIN);

	while (1) {
		uint16_t input_adc0 = read_adc_naiive(0);
		uint16_t target = input_adc0 / 2;
		dac_load_data_buffer_single(target, RIGHT12, CHANNEL_2);
		dac_software_trigger(CHANNEL_2);
		uint16_t input_adc1 = read_adc_naiive(1);
		printf("tick: %d: adc0= %u, target adc1=%d, adc1=%d\n",
			j++, input_adc0, target, input_adc1);

		/* LED on/off */
		gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN);

		for (i = 0; i < 1000000; i++) { /* Wait a bit. */
			__asm__("NOP");
		}
	}

	return 0;
}
示例#26
0
int main(void)
{
	clock_setup();
	gpio_setup();
	usart_setup();
	spi_setup();
	buffer_init(send_buffer,BUFFER_SIZE);
	buffer_init(receive_buffer,BUFFER_SIZE);
	usart_enable_tx_interrupt(USART1);

/* Send a greeting message on USART1. */
	usart_print_string("SD Card SPI Mode Test\r\n");

	while (1)
	{
/* Command interface */
        if (buffer_input_available(receive_buffer))
        {
            char character = buffer_get(receive_buffer);
            if (character == 0x0D)
            {
                line[characterPosition] = 0;
                characterPosition = 0;
                parseCommand(line);
            }
            else line[characterPosition++] = character;
        }
	}

	return 0;
}
示例#27
0
void system_setup(void)
{
    clock_setup();
    mco_setup();
    usb_setup();
    systick_setup();
    rng_setup();
    battery_setup();

    speaker_setup();
    jack_setup();
    // setup pad and screen
    interface_setup();

    // setup and reset SAM2695
    sam2695_setup();
    wait_ms(100);
    sam2695_reset();

    usbmidi_setup();

    // init gfx and fill screen
    gfx_init(ssd1306_drawpixel, SSD1306_WIDTH, SSD1306_HEIGHT, GFX_FONT_SMALL);
    gfx_setRotation(GFX_ROT_180);
    gfx_fillScreen(OLED_BLACK);
    gfx_setTextColor(OLED_WHITE, OLED_BLACK);
//    gfx_setTextWrap(1);
    gfx_setTextSize(1);
    ssd1306_display();
}
示例#28
0
/*
 * Initialize the reference clocks.
 */
void clock_init(void)
{
	/*
	 * Set-up clocks
	 */
	clock_setup();

	/*
	 * Set-up Ethernet clocks
	 */
	eth_clock_setup();

	/*
	 * Set SysTick timer rate to the CPU core clock
	 */
	clock_val[CLOCK_SYSTICK] = LPC18XX_PLL1_CLK_OUT;

	/*
	 * Set the CPU core clock
	 */
	clock_val[CLOCK_CCLK] = LPC18XX_PLL1_CLK_OUT;

	/*
	 * Set UARTx base clock rate
	 */
	clock_val[CLOCK_UART0] = LPC18XX_PLL1_CLK_OUT;
	clock_val[CLOCK_UART1] = LPC18XX_PLL1_CLK_OUT;
	clock_val[CLOCK_UART2] = LPC18XX_PLL1_CLK_OUT;
	clock_val[CLOCK_UART3] = LPC18XX_PLL1_CLK_OUT;
}
示例#29
0
文件: bsp.c 项目: ssfrr/proxlamp
void bsp_setup() {
	clock_setup();
	triac_timer_setup();
	sensor_timer_setup();
	pin_io_setup();
	/* enable interupts */
	sei();
}
示例#30
0
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();
	
	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
	wdt_setup();

	// Other devices
//	uart_setup();
	i2c_setup();

//	dma_setup();

	spi_setup();

	LeaveCriticalSection();

	aes_setup();

	nor_setup();
	syscfg_setup();
	images_setup();
	nvram_setup();

//	lcd_setup();
	framebuffer_hook();	// TODO: Remove once LCD implemented
	framebuffer_setup();

//	audiohw_init();

	framebuffer_setdisplaytext(TRUE);


	gpio_register_interrupt(BUTTONS_HOLD_IRQ, BUTTONS_HOLD_IRQTYPE, BUTTONS_HOLD_IRQLEVEL, BUTTONS_HOLD_IRQAUTOFLIP, gpio_test_handler, 0);
	gpio_interrupt_enable(BUTTONS_HOLD_IRQ);
	gpio_register_interrupt(BUTTONS_HOME_IRQ, BUTTONS_HOME_IRQTYPE, BUTTONS_HOME_IRQLEVEL, BUTTONS_HOME_IRQAUTOFLIP, gpio_test_handler, 1);
	gpio_interrupt_enable(BUTTONS_HOME_IRQ);
	gpio_register_interrupt(BUTTONS_VOLUP_IRQ, BUTTONS_VOLUP_IRQTYPE, BUTTONS_VOLUP_IRQLEVEL, BUTTONS_VOLUP_IRQAUTOFLIP, gpio_test_handler, 2);
	gpio_interrupt_enable(BUTTONS_VOLUP_IRQ);
	gpio_register_interrupt(BUTTONS_VOLDOWN_IRQ, BUTTONS_VOLDOWN_IRQTYPE, BUTTONS_VOLDOWN_IRQLEVEL, BUTTONS_VOLDOWN_IRQAUTOFLIP, gpio_test_handler, 3);
	gpio_interrupt_enable(BUTTONS_VOLDOWN_IRQ);
}