Exemplo n.º 1
0
static void run_usb_msc_test(const struct test_case *test)
{
	memories_initialization();

	// Start USB stack to authorize VBus monitoring
	udc_start();

	if (!udc_include_vbus_monitoring()) {
		// VBUS monitoring is not available on this product
		// thereby VBUS has to be considered as present
		main_vbus_action(true);
	}

	// The main loop manages only the power mode
	// because the USB management is done by interrupt
	while (!main_b_msc_read) {

		if (main_b_msc_enumerated) {
			if (!udi_msc_process_trans()) {
				sleepmgr_enter_sleep();
			}
		}else{
			sleepmgr_enter_sleep();
		}
	}
	test_assert_true(test, main_b_msc_enumerated, "MSC enumeration fails");

	udc_stop();
}
Exemplo n.º 2
0
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	irq_initialize_vectors();
	cpu_irq_enable();

	// Initialize the sleep manager
	sleepmgr_init();

	sysclk_init();
	board_init();
	ui_init();
	ui_powerdown();

	memories_initialization();

	// Start USB stack to authorize VBus monitoring
	udc_start();

	// The main loop manages only the power mode
	// because the USB management is done by interrupt
	while (true) {

		if (main_b_msc_enable) {
			if (!udi_msc_process_trans()) {
				sleepmgr_enter_sleep();
			}
		}else{
			sleepmgr_enter_sleep();
		}
	}
}
Exemplo n.º 3
0
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	//Initialize interrupt controller
	irq_initialize_vectors();
	cpu_irq_enable();

	// Initialize sleep manager
	sleepmgr_init();
	// Initialize clock tree
	sysclk_init();
	// Initialize hardware board resources
	board_init();

	// Initialize user interface
	ui_init();
	ui_powerdown();

	// Sanity check about Silicon revision Vs Firmware build
	// for Silicon revision A, firmware should be specific
	if ((!firmware_rev_a) && (nvm_read_device_rev()==0)) {
		ui_si_revision_error();
		while(ui_button()!=1);
		while(ui_button()!=2);
		while(ui_button()!=4);
		while(ui_button()!=8);
	}

	// Initialize DATA Flash
	at45dbx_init();

	// Initialize ADC for on-board sensors
	adc_sensors_init();

	// Initialize USB HID report protocol
	usb_hid_com_init();

	// Start USB stack
	main_build_usb_serial_number();
	udc_start();

	// The main loop manages only the power mode
	// because everything else is managed by interrupt.
	// The USB Start of Frame event manages internal tick events for
	// on-board sensor updates as well as LCD display update.
	while (true) {
		if (main_b_msc_enable) {
			if (!udi_msc_process_trans()) {
				sleepmgr_enter_sleep();
			}
		} else {
			sleepmgr_enter_sleep();
		}
		if (usb_hid_com_is_start_dfu()) {
			main_start_dfu_session();
		}
	}
}
Exemplo n.º 4
0
static void main_memories_trans_task(void *pvParameters)
{
	UNUSED(pvParameters);
	while (true) {
		// Wait for a semaphore which signals that a transfer is requested
		if( xSemaphoreTake( main_trans_semphr, portMAX_DELAY ) == pdTRUE ) {
			udi_msc_process_trans();
		}
	}
}
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	irq_initialize_vectors();
	cpu_irq_enable();

	// Initialize the sleep manager
	sleepmgr_init();

	sysclk_init();
	board_init();
	ui_init();
	ui_powerdown();

#if UC3A3
	// Init Hmatrix bus   
	sysclk_enable_pbb_module(SYSCLK_HMATRIX);
	init_hmatrix();
#endif
#if (defined AT45DBX_MEM) && (AT45DBX_MEM == ENABLE)
	at45dbx_init();
#endif
#if ((defined SD_MMC_MCI_0_MEM) && (SD_MMC_MCI_0_MEM == ENABLE)) \
	|| ((defined SD_MMC_MCI_1_MEM) && (SD_MMC_MCI_1_MEM == ENABLE))
	// Initialize SD/MMC with MCI PB clock.
	sysclk_enable_pbb_module(SYSCLK_MCI);
	sysclk_enable_hsb_module(SYSCLK_DMACA);
	sd_mmc_mci_resources_init();
#endif

	// Start USB stack to authorize VBus monitoring
	udc_start();

	if (!udc_include_vbus_monitoring()) {
		// VBUS monitoring is not available on this product
		// thereby VBUS has to be considered as present
		main_vbus_action(true);
	}

	// The main loop manages only the power mode
	// because the USB management is done by interrupt
	while (true) {

		sleepmgr_enter_sleep();
		if (main_b_msc_enable) {
         udi_msc_process_trans();
      }
	}
}
Exemplo n.º 6
0
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	//uint8_t i = 0;
	uint16_t temp_crc;
	irq_initialize_vectors();
	cpu_irq_enable();

	// Initialize the sleep manager
	sleepmgr_init();

	sysclk_init();
	board_init();

	ui_init();
	ui_powerdown();

	memories_initialization();

	// Initialize LCD
	et024006_Init( FOSC0, FOSC0 );
	gpio_set_gpio_pin(ET024006DHU_BL_PIN);
	
	//et024006_PrintConsole("Welcome Eric", BLACK, -1);
	//clear_lcd
	et024006_DrawFilledRect(1, 1, ET024006_WIDTH, ET024006_HEIGHT, BLACK);
	
	// Initialize AES module
	aes_task();

	// Start TC
	tc_task();

	Init_System_Status();
	// Initialize crc for fast calculations
	crcInit();
		
	// Read the stored values from the flash
	Load_stored_values();
	//i = sizeof(stored_values_t) - sizeof(uint16_t);
	temp_crc = crcFast((const uint8_t *)&Stored_values_ram, 192);
	//temp_crc1 = crcFast("123456789", 9);
	if (temp_crc == Stored_values_ram.block_crc)
	{
		stSystemStatus.stored_value_crc_status = 1;
	}
	//Stored_values_ram.salt[5] = 0x4d68ab23;
	
	//Update_stored_values();
	// Start USB stack to authorize VBus monitoring
	udc_start();

	if (!udc_include_vbus_monitoring()) {
		// VBUS monitoring is not available on this product
		// thereby VBUS has to be considered as present
		main_vbus_action(true);
	}

	// The main loop manages only the power mode
	// because the USB management is done by interrupt
	while (true)
	{
		if (main_b_msc_enable)
		{
			if (!udi_msc_process_trans())
			{
				sleepmgr_enter_sleep();
			}
		}
		else
		{
			sleepmgr_enter_sleep();
		}
		//main_process_mode();
	}
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: Toussaic/main
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	irq_initialize_vectors();
	cpu_irq_enable();
	wdt_disable(WDT);

	// Initialize the sleep manager
	sleepmgr_init();

	// Board initialization
	sysclk_init();
	init_board();
	init_pwm();
	init_i2c();

	// Module initialization	
	init_module_peripherals_bp();

	/* Initialize SD MMC stack */
	delay_ms(200);
	sd_mmc_init();

	// Start USB stack to authorize VBus monitoring
	udc_start();
	
	// Init SCPI parser
    console_init();
	
	// Enable 12V
	enable_12v();
	
	while (true) 
	{
		console_process();
		
 		if((get_ok_12v_status() == RETURN_OK) && (last_ok_12v_state == false))
 		{
 			set_user_led_colour(0, 100, 0);
			last_ok_12v_state = true;
 		}
		else if((get_ok_12v_status() == RETURN_NOK) && (last_ok_12v_state == true))
		{
			set_user_led_colour(0, 0, 0);
			last_ok_12v_state = false;			
		}
// 		else if(get_sync_signal_status() == RETURN_OK)
// 			set_user_led_colour(0, 0, 100);
// 		else if(get_ok_12v_status() == RETURN_OK)
// 			set_user_led_colour(100, 0, 0);
// 		else
// 			set_user_led_colour(0, 0, 0);			

		if (main_b_msc_enable) 
		{
			if (!udi_msc_process_trans()) 
			{
				//sleepmgr_enter_sleep();
			}
		}
		else
		{
			//sleepmgr_enter_sleep();
		}
	}
}
Exemplo n.º 8
0
Arquivo: main.c Projeto: Toussaic/main
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	irq_initialize_vectors();
	cpu_irq_enable();
	wdt_disable(WDT);

	// Initialize the sleep manager
	sleepmgr_init();

	// Board initialization
	sysclk_init();
	init_board();
	init_pwm();
	init_i2c();

	// Module initialization	
	init_module_peripherals_bp();

	/* Initialize SD MMC stack */
	delay_ms(200);
	sd_mmc_init();

	// Start USB stack to authorize VBus monitoring
	udc_start();
	
	// Init SCPI parser
    console_init();	
	
	// Enable 12v
	enable_12v();
	
	#ifdef TEST_FW
		set_user_led_colour(100, 100, 100);
	#else
		set_user_led_colour(0, 100, 0);
	#endif
	
	while (true) 
	{
		console_process();		
		
		if((get_ok_12v_status() == RETURN_OK) && (last_ok_12v_state == FALSE))
		{
			#ifdef TEST_FW
				set_user_led_colour(300, 300, 300);
			#else
				set_user_led_colour(0, 100, 0);
			#endif
			last_ok_12v_state = TRUE;
		}
		else if((get_ok_12v_status() == RETURN_NOK) && (last_ok_12v_state == TRUE))
		{
			set_user_led_colour(0, 100, 0);
			last_ok_12v_state = FALSE;
		}

		if(integrator_flag == TRUE)
		{
			integrator_flag = FALSE;
			
			ch0_integration_time_counter++;
			ch1_integration_time_counter++;
			ch0_counter_integrated += get_counter0_value();
			ch1_counter_integrated += get_counter1_value();
			
			if(ch0_integration_time_counter == ch0_integration_time_goal)
			{
				ch0_integration_time_counter = 0;
				if(meas_push_activated)
				{
					printf("Counter0 value: %llu\x0D", ch0_counter_integrated);
				}
				if(get_countera_en_status() == TRUE)
				{
					if(last_countera_en == FALSE)
						last_countera_en = TRUE;
					else
						add_new_countera_measurement_to_queue(ch0_counter_integrated);
				}
				else
					last_countera_en = FALSE;
				ch0_counter_integrated = 0;
			}
			
			if(ch1_integration_time_counter == ch1_integration_time_goal)
			{
				ch1_integration_time_counter = 0;
				if(meas_push_activated)
				{
					printf("Counter1 value: %llu\x0D", ch1_counter_integrated);
				}
				if(get_counterb_en_status() == TRUE)
				{
					if(last_counterb_en == FALSE)
						last_counterb_en = TRUE;
					else
						add_new_counterb_measurement_to_queue(ch1_counter_integrated);
				}
				else
					last_counterb_en = FALSE;
				ch1_counter_integrated = 0;
			}
		}
		
		if(second_flag == TRUE)
		{
			second_flag = FALSE;	
		}	

		if (main_b_msc_enable) 
		{
			if (!udi_msc_process_trans()) 
			{
				//sleepmgr_enter_sleep();
			}
		}
		else
		{
			//sleepmgr_enter_sleep();
		}
	}
}
Exemplo n.º 9
0
void app_usb_task(void)
{
	static bool sw0_released = true;
	static bool usb_running = false;
	static bool cdc_running = false;
	static bool toggle = true;

	if (sw0_released && ioport_pin_is_low(GPIO_PUSH_BUTTON_0)) {
		/* A new press has been done */
		sw0_released = false;
		/* Switch USB state */
		if (usb_running) {
			udc_stop();
			gfx_mono_draw_filled_rect(DISPLAY_USB_STA_POS_X,
					DISPLAY_USB_STA_POS_Y,
					DISPLAY_USB_STA_SIZE_X,
					DISPLAY_USB_STA_SIZE_Y,
					GFX_PIXEL_CLR);
			app_microsd_start();
		} else {
			/* Stop FatFS on uSD card if enabled */
			app_microsd_stop();
			stdio_usb_init(); /* Start USB */
			gfx_mono_generic_put_bitmap(&bitmap_usb,
					DISPLAY_USB_STA_POS_X,
					DISPLAY_USB_STA_POS_Y);
		}

		usb_running = !usb_running;
		cdc_running = true;
	} else {
		/* Wait switch release */
		sw0_released = ioport_pin_is_high(GPIO_PUSH_BUTTON_0);
	}

	if (!usb_running) {
		return;
	}

	/* USB MSC task */
	while (udi_msc_process_trans()) {
	}

	if (app_usb_cdc_open && !cdc_running) {
		printf("\x0CSensor data logs:\r\n");
		cdc_running = true;
	}

	if (!app_usb_cdc_open && cdc_running) {
		cdc_running = false;
	}

	/* Toggle USB icon */
	if ((app_usb_cdc_open && app_usb_rec_toggle) ||
			(toggle && app_usb_rec_toggle)) {
		app_usb_rec_toggle = false;
		toggle = !toggle;
		gfx_mono_draw_rect(DISPLAY_USB_STACDC_POS_X,
				DISPLAY_USB_STACDC_POS_Y,
				DISPLAY_USB_STACDC_SIZE_X,
				DISPLAY_USB_STACDC_SIZE_Y,
				toggle ? GFX_PIXEL_SET : GFX_PIXEL_CLR);
	}
}