コード例 #1
0
ファイル: flashdemo.c プロジェクト: Reisswolf/ztex
void main(void)	
{
    __xdata DWORD sector;

    init_USB();						// init everything

    if ( flash_enabled ) {
	flash_read_init( 0 ); 				// prepare reading sector 0
	flash_read((__xdata BYTE*) &sector, 4); 	// read the number of last sector 
	flash_read_finish(flash_sector_size - 4);	// dummy-read the rest of the sector + finish read operation

	sector++;
	if ( sector > flash_sectors || sector == 0 ) {
	    sector = 1;
	}

	flash_write_init( 0 ); 					// prepare writing sector 0
	flash_write((__xdata BYTE*) &sector, 4); 		// write the current sector number
	flash_write_finish_sector(flash_sector_size - 4);	// dummy-write the rest of the sector + CRC
	flash_write_finish();					// finish write operation

	flash_write_init( sector ); 						// prepare writing sector sector
	flash_write((__xdata BYTE*) flash_string, sizeof(flash_string)); 	// write the string 
	flash_write_finish_sector(flash_sector_size - sizeof(flash_string));	// dummy-write the rest of the sector + CRC
	flash_write_finish();							// finish write operation
    }

    while (1) {	}					//  twiddle thumbs
}
コード例 #2
0
ファイル: lightshow.c プロジェクト: Reisswolf/ztex
void main(void)	
{
// init everything
    init_USB();

    while ( 1 ) {
    }
}
コード例 #3
0
ファイル: default.c プロジェクト: freecores/usb_fpga_1_11
void main(void)	
{
    init_USB();

    if ( config_data_valid ) {
	mac_eeprom_read ( (__xdata BYTE*) (productString+20), 6, 1 );
    }
    
    while (1) {	}					//  twiddle thumbs
}
コード例 #4
0
ファイル: debug.c プロジェクト: freecores/usb_fpga_1_11
void main(void)	
{
    WORD i;
    BYTE b;
    
// init everything
    init_USB();
    
    i=0;
    while (1) {	

	debug_msg_buf[0] = i;		// write second counter to the message buffer
	debug_msg_buf[1] = i >> 8;
	debug_add_msg();		// add the message to the stack
	i+=1;

	for (b=0; b<100; b++) {		// 100 x 10ms
	    debug_stack_ptr[2] = b;	// write the 10ms tick number to the current message in stack
	    wait(10);			// wait 10ms
	}
    }
}
コード例 #5
0
ファイル: flashbench.c プロジェクト: Reisswolf/ztex
void main(void)	
{
    init_USB();		// init everything ...
    
    while (1) {	}	// ... and twiddle thumbs
}
コード例 #6
0
ファイル: ztex_ufm1_15y.c プロジェクト: Andreykavdv/BTCMiner
void main(void)	
{
    init_USB();						// init everything
    
    while (1) {	}					//  twiddle thumbs
}
コード例 #7
0
/*!
 * brief Main function. Execution starts here.
 */
int main(void)
{
	// Reset RIMA counter
	DEBUG_TotalRIMA_Count = 0;
		
	// Initialize everything here...
	init_mcu();

	// Continue...
	init_mcu_led();
	init_pipe_job_system();
	init_XLINK();
	init_USB();
	
	// Initialize A2D
	a2d_init();
	a2d_get_temp(0);    // This is to clear the first invalid conversion result...
	a2d_get_temp(1);    // This is to clear the first invalid conversion result...
	a2d_get_voltage(0); // This is to clear the first invalid conversion result...
	a2d_get_voltage(1); // This is to clear the first invalid conversion result...
	a2d_get_voltage(2); // This is to clear the first invalid conversion result...
	
	// Initialize timer
	MCU_Timer_Initialize();
	MCU_Timer_SetInterval(10);
	MCU_Timer_Start();
	
	// Turn on the front LED
	MCU_MainLED_Initialize();
	MCU_MainLED_Set();
	
	// Initialize flash-saving sequence
	__AVR32_Flash_Initialize();
	
	// Initialize FAN subsystem
	FAN_SUBSYS_Initialize();
	
	// Initialize Global Activity Chip LEDs
	GLOBAL_ChipActivityLEDCounter[0] = 0;
	GLOBAL_ChipActivityLEDCounter[1] = 0;
	GLOBAL_ChipActivityLEDCounter[2] = 0;
	GLOBAL_ChipActivityLEDCounter[3] = 0;
	GLOBAL_ChipActivityLEDCounter[4] = 0;
	GLOBAL_ChipActivityLEDCounter[5] = 0;
	GLOBAL_ChipActivityLEDCounter[6] = 0;
	GLOBAL_ChipActivityLEDCounter[7] = 0;
	
	// Reset the total number of engines detected on startup
	GLOBAL_TotalEnginesDetectedOnStartup = 0;
	
	// Initialize total thermal cycles
	GLOBAL_TOTAL_THERMAL_CYCLES = 0;	
	
	// Last time JobIssue was called. 
	GLOBAL_LastJobIssueToAllEngines = 0;
	
	// Wait for 500ms before doing anything
	volatile unsigned int iHolder = MACRO_GetTickCountRet;
	while (MACRO_GetTickCountRet + 2 - iHolder < 500000) WATCHDOG_RESET;
	
	// Perform an ASIC GET CHIP COUNT
	init_ASIC();
	
	// Now set the side-led's accordingly
	#if defined(__PRODUCT_MODEL_LITTLE_SINGLE) || defined(__PRODUCT_MODEL_JALAPENO)
		if (ASIC_does_chip_exist(0) == TRUE) MCU_LED_Set(1);	
		if (ASIC_does_chip_exist(1) == TRUE) MCU_LED_Set(2);
		if (ASIC_does_chip_exist(2) == TRUE) MCU_LED_Set(3);
		if (ASIC_does_chip_exist(3) == TRUE) MCU_LED_Set(4);
		if (ASIC_does_chip_exist(4) == TRUE) MCU_LED_Set(5);
		if (ASIC_does_chip_exist(5) == TRUE) MCU_LED_Set(6);
		if (ASIC_does_chip_exist(6) == TRUE) MCU_LED_Set(7);
		if (ASIC_does_chip_exist(7) == TRUE) MCU_LED_Set(8);	
	#endif
	
	// Detect if we're chain master or not [MODIFY]
	XLINK_ARE_WE_MASTER = XLINK_detect_if_we_are_master(); // For the moment we're the chain master [MODIFY]
	if (XLINK_ARE_WE_MASTER) 
	{ 
		// Wait for a small time
		blink_medium(); 
		WATCHDOG_RESET;
		blink_medium(); 
		WATCHDOG_RESET;
		blink_medium();
		WATCHDOG_RESET; 
		blink_medium();
		WATCHDOG_RESET; 
		blink_medium();
		WATCHDOG_RESET; 
		blink_medium();
		WATCHDOG_RESET; 
		
		// Initialize the XLINK. Interrogate all devices in the chain and assign then addresses
		if (XLINK_is_cpld_present() == TRUE)
		{
			// We're the master, set proper configuration
			XLINK_set_cpld_id(0);
			XLINK_set_cpld_master(TRUE);
			XLINK_set_cpld_passthrough(FALSE);
			
			if (XLINK_MASTER_Start_Chain() == FALSE)
			{
				// Ok this can be bad, we failed the chain initialization
			}
		}
	}
	else
	{
		if (XLINK_is_cpld_present() == TRUE)
		{
			// Disable pass-through and set our cpld-address = 0x1E
			// We will await enumeration
			XLINK_set_cpld_id(XLINK_GENERAL_DISPATCH_ADDRESS);
			XLINK_set_cpld_master(FALSE);
			XLINK_set_cpld_passthrough(FALSE);
		}
	}
	
	// Reset global values
	global_vals[0] = 0;
	global_vals[1] = 0;
	global_vals[2] = 0;
	global_vals[3] = 0;
	global_vals[4] = 0;
	global_vals[5] = 0;

	GLOBAL_BLINK_REQUEST = 0;
	GLOBAL_PULSE_BLINK_REQUEST = 0;
	
	// Clear ASIC Results... This will make sure the diagnostic nonces are cleared
	unsigned int iNonceValues[16];
	unsigned int iNonceCount;
	ASIC_get_job_status(iNonceValues, &iNonceCount, FALSE, 0);
	
	// Did we reset the ASICs internally?
	GLOBAL_INTERNAL_ASIC_RESET_EXECUTED = FALSE;
	
	// Go to our protocol main loop
	MCU_Main_Loop();
	return(0);
}