Esempio n. 1
0
/**
 * \brief main function
 */
int main(void)
{
	pmic_init();
	board_init();
	sysclk_init();
	sleepmgr_init();

	rtc_init();
	rtc_set_callback(alarm);

	cpu_irq_enable();

	/* The lowest value which is safe to use is 3. This the use of 2 could
	 * happen in a second change, and we would not get an interrupt. A
	 * value of 3 causes the alarm to be set of in 3-4 seconds.
	 */
	rtc_set_alarm_relative(3);

	while (true) {
		/* Alarm action is handled in alarm callback so we just go to
		 * sleep here.
		 */
		sleepmgr_enter_sleep();
	}
}
Esempio n. 2
0
void bluetooth_init(void)
{
	ioport_set_pin_dir(BT_TX,IOPORT_DIR_OUTPUT);
	
	static usart_serial_options_t usart_options = {
		.baudrate = 115200,
		.charlength = USART_CHSIZE_8BIT_gc,
		.paritytype = USART_PMODE_DISABLED_gc,
		.stopbits = false
	};
	usart_serial_init(BLUETOOTH, &usart_options);
	
	#ifdef PRINTF_BLUETOOTH
	// setup our stdio stream
	stdout = &mystdout;
	stdin = &mystdout;
#endif
	
}

void bluetooth_init_interrupt(void)
{
	pmic_init();
	pmic_set_scheduling(PMIC_SCH_ROUND_ROBIN);
	USARTD0.CTRLA = USART_RXCINTLVL_HI_gc;
	cpu_irq_enable();
}
Esempio n. 3
0
/**
 * \brief Main function.
 *
 * Initializes the board, and runs the application in an infinite loop.
 */
int main(void)
{
    /* hardware initialization */
    sysclk_init();
    board_init();
    pmic_init();
    timer_init();
    rs485_init();
    led_init();
	adc_init();
#ifdef CONF_BOARD_ENABLE_RS485_XPLAINED
    // Enable display backlight
    gpio_set_pin_high(NHD_C12832A1Z_BACKLIGHT);
#endif
    // Workaround for known issue: Enable RTC32 sysclk
    sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
    while (RTC32.SYNCCTRL & RTC32_SYNCBUSY_bm) {
        // Wait for RTC32 sysclk to become stable
    }
    cpu_irq_enable();
    /* application initialization */
    rs485_baud_rate_set(38400);
    bacnet_init();
    /*  run forever - timed tasks */
    timer_callback(bacnet_task_timed, 5);
    for (;;) {
        bacnet_task();
        led_task();
    }
}
Esempio n. 4
0
int board_init(void)
{
	/* address of boot parameters */
	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;

	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
	setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info_loc);
	setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info3);

#if defined(CONFIG_VIDEO_IPUV3)
	setup_display();
#endif

#ifdef CONFIG_TDX_CMD_IMX_MFGR
	(void) pmic_init();
#endif

#ifdef CONFIG_SATA
	setup_sata();
#endif

	setup_iomux_gpio();

	return 0;
}
Esempio n. 5
0
void bootblock_mainboard_init(void)
{
	set_clock_sources();

	/* Set up the pads required to load romstage. */
	soc_configure_pads(padcfgs, ARRAY_SIZE(padcfgs));
	soc_configure_funits(funits, ARRAY_SIZE(funits));

	/* PMIC */
	i2c_init(I2CPWR_BUS);
	pmic_init(I2CPWR_BUS);

	/* TPM */
	i2c_init(I2C3_BUS);

	/* EC */
	i2c_init(I2C2_BUS);

	/*
	 * Set power detect override for GPIO, audio & sdmmc3 rails.
	 * GPIO rail override is required to put it into 1.8V mode.
	 */
	pmc_override_pwr_det(PMC_GPIO_RAIL_AO_MASK | PMC_AUDIO_RAIL_AO_MASK |
			     PMC_SDMMC3_RAIL_AO_MASK, PMC_GPIO_RAIL_AO_DISABLE |
			     PMC_AUDIO_RAIL_AO_DISABLE |
			     PMC_SDMMC3_RAIL_AO_DISABLE);
}
Esempio n. 6
0
int main (void)
{
    sysclk_init();
	pmic_init();
    port_init();
	tc_init();
	wdt_set_timeout_period(WDT_TIMEOUT_PERIOD_32CLK);
	wdt_enable();
	usart_init();
	spi_init();
	
	char str[200];
	uint8_t count ;
	count = sprintf(str,"RESET");
	for (uint8_t i=0;i<count;i++)
	usart_putchar(&USARTE0,str[i]);
	nrf_init(Address);
	sei();
	

	for (uint8_t i=0;i<Max_Robot;i++)
	{
		Robot_D_tmp[2][i].RID=12;
	}

	while (1)
	{
		
	}
}
Esempio n. 7
0
int exynos_power_init(void)
{
	pmic_init(0);
	pmic_init_max77686();

	return 0;
}
Esempio n. 8
0
/**
 * \brief Run low power demo
 *
 * This function initializes the XMEGA to the least power consuming state,
 * before initializing the sleep manager interrupts on switchports.
 * The device is then put to sleep, and the sleep mode is configured by the
 * interrupt routines.
 */
int main(void)
{
	board_init();
	sysclk_init();
	lowpower_init();

	/* Initialize the sleep manager. */
	sleepmgr_init();

	/* Enable interrupts from switchports on
	 * low level to sense all interrupts */
	pmic_init();
	SWITCHPORT0.INTCTRL = SWITCHPORT_INT_LEVEL;
	SWITCHPORT1.INTCTRL = SWITCHPORT_INT_LEVEL;
	SWITCHPORT0.INT0MASK = SWITCHMASK0;
	SWITCHPORT1.INT0MASK = SWITCHMASK1;
	ioport_configure_port_pin(&SWITCHPORT0,
			SWITCHMASK0, IOPORT_LEVEL | IOPORT_PULL_UP);
	ioport_configure_port_pin(&SWITCHPORT1,
			SWITCHMASK1, IOPORT_LEVEL | IOPORT_PULL_UP);
	cpu_irq_enable();

	/* Start in active mode */
	sleepmgr_lock_mode(SLEEPMGR_ACTIVE);

	/* Go to sleep, sleep modes are configured by interrupt routines. */
	while (1) {
		sleepmgr_enter_sleep();
	}
}
Esempio n. 9
0
void power_init(void)
{
	unsigned int val;
	struct pmic *p;

	pmic_init();
	p = get_pmic();

	/* Set VDDA to 1.25V */
	pmic_reg_read(p, REG_SW_2, &val);
	val &= ~SWX_OUT_MASK;
	val |= SWX_OUT_1_25;
	pmic_reg_write(p, REG_SW_2, val);

	/*
	 * Need increase VCC and VDDA to 1.3V
	 * according to MX53 IC TO2 datasheet.
	 */
	if (is_soc_rev(CHIP_REV_2_0) == 0) {
		/* Set VCC to 1.3V for TO2 */
		pmic_reg_read(p, REG_SW_1, &val);
		val &= ~SWX_OUT_MASK;
		val |= SWX_OUT_1_30;
		pmic_reg_write(p, REG_SW_1, val);

		/* Set VDDA to 1.3V for TO2 */
		pmic_reg_read(p, REG_SW_2, &val);
		val &= ~SWX_OUT_MASK;
		val |= SWX_OUT_1_30;
		pmic_reg_write(p, REG_SW_2, val);
	}
}
Esempio n. 10
0
/* This function is meant to contain board-specific initialization code
 * for, e.g., the I/O pins. The initialization can rely on application-
 * specific board configuration, found in conf_board.h.
 */
void v2x_board_init(void)
{
	irq_initialize_vectors();
	pmic_init();
	sysclk_init();							//configure clock sources for core and USB
	sleepmgr_init();						// Initialize the sleep manager
	ioport_init();							//Initializes the IOPORT service
	pin_init();								//whole chip pin init, modes and initial conditions
	spi_start();							//start SPI driver
	PWR_init();								//sets SR to default states - holds power up
	cpu_irq_enable();
	eeprom_init();							//verifies eeprom safe for use
	menu_init();							//loads menu settings
	time_init();							//starts the RTC
	button_init();							//init button stuffs
	ACL_init();								//configures, but does not start sampling
	GSM_usart_init();						//starts direct serial channel to the SIM module
	CAN_uart_start();						//starts direct serial channel to the ELM module
	canbus_serial_routing(AVR_ROUTING);		//cause the serial 3-state buffer to route the serial path from the ELM to the FTDI 
	udc_start();							//start stack and vbus monitoring
	PWR_hub_start();						//connect the hub to the computer

	//autostart all systems
	delay_ms(500);
	GSM_modem_init();
	CAN_elm_init();
	ACL_set_sample_on();
	PWR_host_start();
}
Esempio n. 11
0
int board_late_init(void)
{
#ifdef CONFIG_CMD_BMODE
	add_board_boot_modes(board_boot_modes);
#endif

#ifdef CONFIG_VIDEO_IPUV3
	/* We need at least 200ms between power on and backlight on
	 * as per specifications from CHI MEI */
	mdelay(250);

	/* enable backlight PWM 1 */
	pwm_init(0, 0, 0);

	/* duty cycle 5000000ns, period: 5000000ns */
	pwm_config(0, 5000000, 5000000);

	/* Backlight Power */
	gpio_direction_output(LVDS_BACKLIGHT_GP, 1);

	pwm_enable(0);
#endif

	/* board specific pmic init */
	pmic_init();

	return 0;
}
Esempio n. 12
0
int main(void)
{
	pmic_init();
	board_init();
	sysclk_init();
	sleepmgr_init();

	cpu_irq_enable();

#if (BOARD == XMEGA_A3BU_XPLAINED)
	/* The status LED must be used as LED2, so we turn off
	 * the green led which is in the same packaging. */
	ioport_set_pin_high(LED3_GPIO);
#endif

	/*
	* Unmask clock for TIMER_EXAMPLE
	*/
	tc_enable(&TIMER_EXAMPLE);

	/*
	* Configure interrupts callback functions for TIMER_EXAMPLE
	* overflow interrupt, CCA interrupt and CCB interrupt
	*/
	tc_set_overflow_interrupt_callback(&TIMER_EXAMPLE,
			example_ovf_interrupt_callback);
	tc_set_cca_interrupt_callback(&TIMER_EXAMPLE,
			example_cca_interrupt_callback);
	tc_set_ccb_interrupt_callback(&TIMER_EXAMPLE,
			example_ccb_interrupt_callback);

	/*
	* Configure TC in normal mode, configure period, CCA and CCB
	* Enable both CCA and CCB channels
	*/

	tc_set_wgm(&TIMER_EXAMPLE, TC_WG_NORMAL);
	tc_write_period(&TIMER_EXAMPLE, TIMER_EXAMPLE_PERIOD);
	tc_write_cc(&TIMER_EXAMPLE, TC_CCA, TIMER_EXAMPLE_PERIOD / 2);
	tc_write_cc(&TIMER_EXAMPLE, TC_CCB, TIMER_EXAMPLE_PERIOD / 4);
	tc_enable_cc_channels(&TIMER_EXAMPLE,(enum tc_cc_channel_mask_enable_t)(TC_CCAEN | TC_CCBEN));

	/*
	* Enable TC interrupts (overflow, CCA and CCB)
	*/
	tc_set_overflow_interrupt_level(&TIMER_EXAMPLE, TC_INT_LVL_LO);
	tc_set_cca_interrupt_level(&TIMER_EXAMPLE, TC_INT_LVL_LO);
	tc_set_ccb_interrupt_level(&TIMER_EXAMPLE, TC_INT_LVL_LO);

	/*
	* Run TIMER_EXAMPLE at TIMER_EXAMPLE_PERIOD(31250Hz) resolution
	*/
	tc_set_resolution(&TIMER_EXAMPLE, TIMER_EXAMPLE_PERIOD);

	do {
		/* Go to sleep, everything is handled by interrupts. */
		sleepmgr_enter_sleep();
	} while (1);
}
Esempio n. 13
0
//! \brief Set up and run test suite
int main(void)
{
	/* USART init values */
	const usart_serial_options_t usart_serial_options =
	{
		.baudrate     = CONF_TEST_BAUDRATE,
		.charlength   = CONF_TEST_CHARLENGTH,
		.paritytype   = CONF_TEST_PARITY,
		.stopbits     = CONF_TEST_STOPBITS,
	};

	/* Start services */
	pmic_init();
	sysclk_init();
	board_init();
	sleepmgr_init();
	stdio_serial_init(CONF_TEST_USART, &usart_serial_options);

	/* Enable the clock for the AES module */
	sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_AES);

	/* Enable global interrupts */
	cpu_irq_enable();

	// Set callback for AES module
	aes_set_callback(&int_callback_aes);

	/* Define test cases */
	DEFINE_TEST_CASE(aes_get_set_test, NULL, run_aes_set_and_get_key_test,
			NULL, "Get and set functions");
	DEFINE_TEST_CASE(aes_state_interface_test, NULL,
			run_aes_state_interface_test, NULL, "Test of AES state functions");
	DEFINE_TEST_CASE(aes_encryption_test, NULL, run_aes_encryption_test,
			NULL, "Encryption with known result");
	DEFINE_TEST_CASE(aes_decryption_test, NULL, run_aes_decryption_test,
			NULL, "Decryption function known result");
	DEFINE_TEST_CASE(aes_enc_dec_test, NULL,
			run_aes_encrypt_and_decrypt_test, NULL,
			"Encryption and decryption with interrupt and auto mode");

	DEFINE_TEST_ARRAY(aes_tests) = {
		&aes_get_set_test,
		&aes_state_interface_test,
		&aes_encryption_test,
		&aes_decryption_test,
		&aes_enc_dec_test
	};

	DEFINE_TEST_SUITE(aes_suite, aes_tests, "XMEGA AES driver test suite");

	/* Run all test in the suite */
	test_suite_run(&aes_suite);

	while (1) {
		/* Intentionally left blank */
	}
}
Esempio n. 14
0
int power_init_board(void)
{
	int ret;

	ret = pmic_init(I2C_5);
	if (ret)
		return ret;

	return 0;
}
Esempio n. 15
0
int board_init(void)
{
	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;

#if defined(CONFIG_PMIC)
	pmic_init();
#endif

	return 0;
}
Esempio n. 16
0
/**
 * \brief Main application routine
 *  - Initializes the board and LCD display
 *  - Initialize ADC ,to read ADC offset and configure for oversampling
 *  - If number of sample Reached to  total number of oversample required,
 *    call function to start process on oversampled ADC readings
 */
int main( void )
{
	/*
	 * Initialize basic features for the AVR XMEGA family.
	 *  - PMIC is needed to enable all interrupt levels.
	 *  - Board init for setting up GPIO and board specific features.
	 *  - Sysclk init for configuring clock speed and turning off unused
	 *    peripherals.
	 *  - Sleepmgr init for setting up the basics for the sleep manager,
	 */

	board_init();
	sysclk_init();
	pmic_init();
	sleepmgr_init();

	/* Initialize ST7565R controller and LCD display */
	gfx_mono_init();

	/* Display headings on LCD for oversampled result */
	gfx_mono_draw_string("Oversampled", 0, 0, &sysfont);

	/* Display headings on LCD for normal result */
	gfx_mono_draw_string("Normal", 80, 0, &sysfont);

	/* Initialize ADC ,to read ADC offset and configure ADC for oversampling
	**/
	init_adc();

	/* Enable global interrupt */
	cpu_irq_enable();

	/* Switch ON LCD back light */
	ioport_set_pin_high(NHD_C12832A1Z_BACKLIGHT);

	/* Set LCD contrast */
	st7565r_set_contrast(ST7565R_DISPLAY_CONTRAST_MIN);

	/* Continuous Execution Loop */
	while (1) {
		/*
		 * Check if number of sample reached to  total Number of
		 * oversample required by checking status of
		 * adc_oversampled_flag
		 */
		if (adc_oversampled_flag == true) {
			/* Reset the adc_oversampled_flag */
			adc_oversampled_flag = false;

			/* Process all received ADC samples and calculate analog
			 * input */
			adc_oversampled();
		}
	}
}
Esempio n. 17
0
int main(void)
{
	uint8_t lcd_text[]    = "XmegaB1";
	uint16_t i;

	sysclk_init();
	pmic_init();
	sleepmgr_init();
	board_init();
	c42048a_init();

	c42048a_set_contrast(60);
	c42048a_blinkrate_init(LCD_BLINKRATE_1Hz_gc);

	// Alphanumeric
	c42048a_set_text(lcd_text);
	// Numeric
	c42048a_set_numeric_dec(1245);

	// All pixels "on" blinking
	c42048a_set_blink_screen();
	c42048a_wait_int_period(16);
	c42048a_clear_blink_screen();

	// AVR icon blinking alone
	c42048a_blink_pixel(ICON_AVR);
	c42048a_wait_int_period(16);

	// AVR icon on
	c42048a_set_pixel(ICON_AVR);

	// USB icon blinking
	c42048a_blink_pixel(ICON_USB);
	// AM is not part of blinking icons
	// AM will be ON only
	c42048a_blink_pixel(ICON_AM);

	// Display a progress bar graph value
	for(i=1; i<256; i+=16) {
		c42048a_bar_graph((uint8_t)i);
		c42048a_wait_int_period(1);
	}
	c42048a_wait_int_period(4);

	// Blink entire screen 8 times
	c42048a_set_blink_screen();
	c42048a_wait_int_period(16);

	// Unblink all the screen
	c42048a_clear_blink_screen();

	while(true) {
		sleepmgr_enter_sleep();
	}
}
Esempio n. 18
0
int main(void)
{
	pmic_init();
	board_init();
	sysclk_init();
	sleepmgr_init();
	cpu_irq_enable();

	/* Enables the Timer defined in conf_example.h : TCE0 in this example */
	tc_enable(&TIMER_EXAMPLE);

	/* Configures the interrupt level of CCA and CCB modules : low */
	tc_set_cca_interrupt_level(&TIMER_EXAMPLE, TC_INT_LVL_LO);
	tc_set_ccb_interrupt_level(&TIMER_EXAMPLE, TC_INT_LVL_LO);

	/* Configures the waveform generator of this Timer mode in NORMAL mode */
	tc_set_wgm(&TIMER_EXAMPLE, TC_WG_NORMAL);

	/* Declares the interrupt functions which will be called when CCA and CCB
	interrupts will occur */
	tc_set_cca_interrupt_callback(&TIMER_EXAMPLE,
			example_cca_interrupt_callback);
	tc_set_ccb_interrupt_callback(&TIMER_EXAMPLE,
			example_ccb_interrupt_callback);

	/* Configures the Timer period*/
	tc_write_period(&TIMER_EXAMPLE, TIMER_EXAMPLE_PERIOD);

	/* Configures the CCA and CCB levels*/
	tc_write_cc(&TIMER_EXAMPLE, TC_CCA, TIMER_EXAMPLE_PERIOD/2);
	tc_write_cc(&TIMER_EXAMPLE, TC_CCB, TIMER_EXAMPLE_PERIOD/2);

	/* Enables the CCA and CCB channels*/
	tc_enable_cc_channels(&TIMER_EXAMPLE,TC_CCAEN);
	tc_enable_cc_channels(&TIMER_EXAMPLE,TC_CCAEN);

	/* Configures the waveform genertaor in Dual Slope mode and Top*/
	tc_set_wgm(&TIMER_EXAMPLE,TC_WG_DS_T);

	/* Enables and configures the deadtime of CCA and CCB outputs*/
	tc_awex_enable_cca_deadtime(&AWEXE);
	tc_awex_enable_ccb_deadtime(&AWEXE);
	tc_awex_set_dti_high(&AWEXE, TIMER_EXAMPLE_PERIOD/6);
	tc_awex_set_dti_low(&AWEXE, TIMER_EXAMPLE_PERIOD/6);

	/* Outputs CCA and CCB on Port E0 and E1*/
	tc_awex_set_output_override(&AWEXE, 0x03);

	tc_set_resolution(&TIMER_EXAMPLE, 10000);

	do {
		/* Go to sleep, everything is handled by interrupts. */
		sleepmgr_enter_sleep();
	} while (1);
}
Esempio n. 19
0
void bootblock_mainboard_init(void)
{
	set_clock_sources();

	/* Set up controllers and pads to load romstage. */
	soc_configure_funits(funits, ARRAY_SIZE(funits));
	soc_configure_pads(padcfgs, ARRAY_SIZE(padcfgs));

	i2c_init(I2CPWR_BUS);
	pmic_init(I2CPWR_BUS);
}
Esempio n. 20
0
static int power_init(void)
{
	unsigned int val;
	int ret = -1;
	struct pmic *p;

	if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR)) {
		pmic_dialog_init();
		p = get_pmic();

		/* Set VDDA to 1.25V */
		val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V;
		ret = pmic_reg_write(p, DA9053_BUCKCORE_REG, val);

		ret |= pmic_reg_read(p, DA9053_SUPPLY_REG, &val);
		val |= DA9052_SUPPLY_VBCOREGO;
		ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, val);

		/* Set Vcc peripheral to 1.30V */
		ret |= pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62);
		ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62);
	}

	if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) {
		pmic_init();
		p = get_pmic();

		/* Set VDDGP to 1.25V for 1GHz on SW1 */
		pmic_reg_read(p, REG_SW_0, &val);
		val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_250V_MC34708;
		ret = pmic_reg_write(p, REG_SW_0, val);

		/* Set VCC as 1.30V on SW2 */
		pmic_reg_read(p, REG_SW_1, &val);
		val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_300V_MC34708;
		ret |= pmic_reg_write(p, REG_SW_1, val);

		/* Set global reset timer to 4s */
		pmic_reg_read(p, REG_POWER_CTL2, &val);
		val = (val & ~TIMER_MASK_MC34708) | TIMER_4S_MC34708;
		ret |= pmic_reg_write(p, REG_POWER_CTL2, val);

		/* Set VUSBSEL and VUSBEN for USB PHY supply*/
		pmic_reg_read(p, REG_MODE_0, &val);
		val |= (VUSBSEL_MC34708 | VUSBEN_MC34708);
		ret |= pmic_reg_write(p, REG_MODE_0, val);

		/* Set SWBST to 5V in auto mode */
		val = SWBST_AUTO;
		ret |= pmic_reg_write(p, SWBST_CTRL, val);
	}

	return ret;
}
Esempio n. 21
0
void bootblock_mainboard_init(void)
{
	set_clock_sources();

	soc_configure_funits(funits, ARRAY_SIZE(funits));

	i2c_init(I2CPWR_BUS);
	pmic_init(I2CPWR_BUS);

	/* Foster has no TPM yet. This is for future TPM. */
	i2c_init(I2C3_BUS);
}
Esempio n. 22
0
int main()
{
    /* USART init values */
    const usart_serial_options_t usart_serial_options = {
        .baudrate     = CONF_TEST_BAUDRATE,
        .charlength   = CONF_TEST_CHARLENGTH,
        .paritytype   = CONF_TEST_PARITY,
        .stopbits     = CONF_TEST_STOPBITS,
    };

    // Initialize the board and all the peripheral required
    sysclk_init();
    board_init();
    stdio_serial_init(CONF_TEST_USART, &usart_serial_options);

#if XMEGA
    pmic_init();
    sleepmgr_init();
#endif

    DEFINE_TEST_CASE(membag_init_test, NULL, run_membag_init_test,
                     NULL, "Test membag initialization");
    DEFINE_TEST_CASE(membag_alloc_test, NULL, run_membag_alloc_test,
                     NULL, "Test membag memory allocation");
    DEFINE_TEST_CASE(membag_free_test, NULL, run_membag_free_test,
                     NULL, "Test membag memory freeing");
    DEFINE_TEST_CASE(membag_get_test, NULL, run_membag_get_test,
                     NULL, "Test membag get functions");
    DEFINE_TEST_CASE(membag_alloc_when_full_test, NULL,
                     run_membag_alloc_when_full_test, NULL,
                     "Test membag allocation when all membags are full");
    DEFINE_TEST_CASE(membag_realloc_test, NULL, run_membag_realloc_test,
                     NULL, "Test membag allocation and reallocation");

    DEFINE_TEST_ARRAY(membag_tests) = {
        &membag_init_test,
        &membag_alloc_test,
        &membag_free_test,
        &membag_get_test,
        &membag_alloc_when_full_test,
        &membag_realloc_test
    };

    DEFINE_TEST_SUITE(membag_suite,
                      membag_tests, "Common util membag test suite");

    test_suite_run(&membag_suite);

    while (1) {
        /* Intentionally left blank */
    }
}
Esempio n. 23
0
void bootblock_mainboard_init(void)
{
	set_clock_sources();

	/* Set up the pads required to load romstage. */
	soc_configure_pads(padcfgs, ARRAY_SIZE(padcfgs));
	soc_configure_funits(funitcfgs, ARRAY_SIZE(funitcfgs));

	i2c_init(4);
	pmic_init(4);

	tegra_spi_init(4);
}
Esempio n. 24
0
int board_init(void)
{
	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;

	check_hw_revision();
	printf("HW Revision:\t0x%x\n", board_rev);

#if defined(CONFIG_PMIC)
	pmic_init();
#endif

	return 0;
}
Esempio n. 25
0
// setup the board instead of board_init() as recommended by ASF.. because christmas lights, that's why.
void init (void) {
	static usart_serial_options_t usart_options = {
		.baudrate = USART_SERIAL_BAUDRATE,
		.charlength = USART_SERIAL_CHAR_LENGTH,
		.paritytype = USART_SERIAL_PARITY,
		.stopbits = USART_SERIAL_STOP_BIT
	};
	
	// initialize ASF stuff
	board_init();
	sysclk_init();
	ioport_init();
	pmic_init();
	pmic_set_scheduling(PMIC_SCH_FIXED_PRIORITY);
	
	// remap, enable TX, and configure USART on PORT C
	PORTC.REMAP |= PR_USART0_bm;
	PORTC.DIR |= (1 << PIN7_bp);
		
	sysclk_enable_module(SYSCLK_PORT_C, PR_USART0_bm);
	usart_init_rs232(USART_SERIAL, &usart_options);
	
	// setup timer for PWM
	tc45_enable(&TCC4);
	tc45_set_overflow_interrupt_callback(&TCC4, pwm_callback);
	tc45_set_wgm(&TCC4, TC45_WG_NORMAL);
	tc45_write_period(&TCC4, 256);
	tc45_set_overflow_interrupt_level(&TCC4, TC45_INT_LVL_MED);
		
	// enable all channels and turn off (high)
	ioport_set_port_dir(IOPORT_PORTA, PORTA_MASK, IOPORT_DIR_OUTPUT);
	ioport_set_port_dir(IOPORT_PORTD, PORTD_MASK, IOPORT_DIR_OUTPUT);
	ioport_set_port_dir(IOPORT_PORTR, PORTR_MASK, IOPORT_DIR_OUTPUT);
	ioport_set_port_level(IOPORT_PORTA, PORTA_MASK, 0xFF);
	ioport_set_port_level(IOPORT_PORTD, PORTD_MASK, 0xFF);
	ioport_set_port_level(IOPORT_PORTR, PORTR_MASK, 0xFF);
	for (uint8_t i=0; i<NUM_CHANNELS; i++) {
		compare[i] = 0;
		compbuff[i] = 0;
	}
	
	// enable status LEDs and turn off
	ioport_set_pin_dir(LED_STATUS, IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED_DATA, IOPORT_DIR_OUTPUT);
	ioport_set_pin_level(LED_STATUS, 1);
	ioport_set_pin_level(LED_DATA, 1);
	
	// enable interrupts and start timer for PWM
	cpu_irq_enable();
	tc45_write_clock_source(&TCC4, TC45_CLKSEL_DIV2_gc);	
}
Esempio n. 26
0
int power_init_board(void)
{
	int ret;

	/*
	 * For PMIC the I2C bus is named as I2C5, but it is connected
	 * to logical I2C adapter 0
	 */
	ret = pmic_init(I2C_0);
	if (ret)
		return ret;

	return 0;
}
Esempio n. 27
0
void init_vrtc(){
	//real time clock inits
	pmic_init();
	sysclk_init();
	sleepmgr_init();
	rtc_init();	
	cpu_irq_enable();
	
	//v2x init
	soft_counter = 0x00;
	rtc_set_callback(alarm);
	rtc_set_alarm_relative(32768);
	
}
Esempio n. 28
0
int main (void)
{
	U8 msg[32] = "Hi ArduSub\n\r";
	pmic_init();
	sysclk_init();
	
	adc_init();
	thruster_init();
	ioport_init();
	timer_init(10000);
	timer_set_counts(TIMER_HEARTBEAT,timer_ms_to_counts(250));
	timer_start(TIMER_HEARTBEAT);
	cpu_irq_enable();

	volatile U8 count = 0;
	ioport_set_pin_dir(LED1,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(LED2,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(UARTD_TX,IOPORT_DIR_OUTPUT);
	ioport_set_pin_dir(UARTD_RX,IOPORT_DIR_INPUT);
	ioport_set_pin_dir(TXEN,IOPORT_DIR_OUTPUT);
	board_init();
	uart_init(19200);
	do 
	{
		message_tasks();

		count++;
		if (count > 52)
		{
			
			count  = 0;
			
		}
		if(timer_is_expired(TIMER_HEARTBEAT))
		{
			timer_reset(TIMER_HEARTBEAT);
			board_pres_read();
			ext_temp_read();
			//ioport_set_pin_level(TXEN,1);
			//uart_write(&msg[0],12);
			//while(uart_tx_count() != 0);
			//blink heart beat LED
			ioport_set_pin_level(LED2,!ioport_get_pin_level(LED2));
		}
	} while (1);

	// Insert application code here, after the board has been initialized.
}
Esempio n. 29
0
/*! \brief Main function.
 */
int main(void)
{
	uint8_t tx_buf[] = "\n\rHello AVR world ! : ";
	uint8_t i;

	/* Initialize the board.
	 * The board-specific conf_board.h file contains the configuration of
	 * the board initialization.
	 */
	board_init();
	sysclk_init();
	pmic_init();
	cpu_irq_enable();
	sleepmgr_init();
	sleepmgr_lock_mode(SLEEPMGR_STDBY);

	/* USART options. */
	static usart_xmegae_rs232_options_t USART_SERIAL_OPTIONS = {
		.baudrate = USART_SERIAL_EXAMPLE_BAUDRATE,
		.charlength = USART_SERIAL_CHAR_LENGTH,
		.paritytype = USART_SERIAL_PARITY,
		.stopbits = USART_SERIAL_STOP_BIT,
		.start_frame_detection = false,
		.one_wire = false,
		.pec_length = USART_SERIAL_VARIABLE_CHAR_LENGTH,
		.pec_action = USART_PECACT_PERC01_gc,
		.encoding_type = USART_DECTYPE_DATA_gc,
		.encoding_stream = USART_LUTACT_OFF_gc,
	};

	/* Initialize usart driver in RS232 mode */
	usart_xmegae_init_rs232(USART_SERIAL_EXAMPLE, &USART_SERIAL_OPTIONS);
	usart_set_rx_interrupt_level(USART_SERIAL_EXAMPLE, USART_INT_LVL_LO);

	/* Send "message header" */
	for (i = 0; i < sizeof(tx_buf); i++) {
		usart_putchar(USART_SERIAL_EXAMPLE, tx_buf[i]);
		while (!usart_tx_is_complete(USART_SERIAL_EXAMPLE)) {
		}
		usart_clear_tx_complete(USART_SERIAL_EXAMPLE);
	}

	/* Incoming character is process under interrupt
	 * main loop simply enters sleep mode */
	while (true) {
		sleepmgr_enter_sleep();
	}
}
Esempio n. 30
0
int board_late_init(void)
{
	u32 val;
	struct pmic *p;

	pmic_init();
	p = get_pmic();

	/* Enable RTC battery */
	pmic_reg_read(p, REG_POWER_CTL0, &val);
	pmic_reg_write(p, REG_POWER_CTL0, val | COINCHEN);
	pmic_reg_write(p, REG_INT_STATUS1, RTCRSTI);
#ifdef CONFIG_HW_WATCHDOG
	mxc_hw_watchdog_enable();
#endif
	return 0;
}