Ejemplo n.º 1
0
int main(void)
{
	volatile unsigned char idelay;
	volatile unsigned int jdelay;

	Buzzer_Init();	/* Buzzer pin as an output */

	BUZZER_ON;

	for(idelay=0;idelay<10;idelay++)	/* Software Delay */
		for(jdelay=0;jdelay<50000;jdelay++);

	//BUZZER_OFF;

	while(1);	/* wait forever */
}
Ejemplo n.º 2
0
void FlightState0()
{
	// init peripherals	
	LED_Init();
	USART_Comms_Init();
	init_M56511();
	Hotwire_Init();
	Buzzer_Init();
	
	for( int i = 0; i < 100; i++)
	{
		ms5611_altitude();
	}

	// after sampling many times, we store initAltitude
	initAltitude = telemetry.altitude_f;
	
	// start these up here so we don't broadcast garbage while sampling
	init_MS5611_callback();
	XBee_Init();
	
	// check timestamps here
	#ifdef TIMING_DEBUG
	while(true)
	{
		printf("\t\n");
		delay_ms(1000);
	}
	#endif
	
	#ifndef FS_DEBUG
	while((telemetry.altitude_f - initAltitude) < LAUNCH_DETECT)
	{
		delay_ms(1);
	}
	#endif
}
Ejemplo n.º 3
0
int main(void) {
	char buf[22];
	int len;

	PLLCFG = (1<<5) | (4<<0); //PLL MSEL=0x4 (+1), PSEL=0x1 (/2) so 11.0592*5 = 55.296MHz, Fcco = (2x55.296)*2 = 221MHz which is within 156 to 320MHz
	PLLCON = 0x01;
	PLLFEED = 0xaa;
	PLLFEED = 0x55; // Feed complete
	while(!(PLLSTAT & (1<<10))); // Wait for PLL to lock
	PLLCON = 0x03;
	PLLFEED = 0xaa;
	PLLFEED = 0x55; // Feed complete
	VPBDIV = 0x01; // APB runs at the same frequency as the CPU (55.296MHz)
	MAMTIM = 0x03; // 3 cycles flash access recommended >40MHz
	MAMCR = 0x02; // Fully enable memory accelerator
	
	Sched_Init();
	IO_Init();
	Set_Heater(0);
	Set_Fan(0);
	Serial_Init();
	I2C_Init();
	EEPROM_Init();
	NV_Init();

	if( NV_GetConfig(REFLOW_BEEP_DONE_LEN) == 255 ) {
		NV_SetConfig(REFLOW_BEEP_DONE_LEN, 10); // Default 1 second beep length
	}

	printf("\nInitializing improved reflow oven...");
	LCD_Init();
	LCD_BMPDisplay(logobmp,0,0);

	// Setup watchdog
	WDTC = PCLKFREQ / 3; // Some margin (PCLKFREQ/4 would be exactly the period the WD is fed by sleep_work)
	WDMOD = 0x03; // Enable
	WDFEED = 0xaa;
	WDFEED = 0x55;

	uint8_t resetreason = RSIR;
	RSIR = 0x0f; // Clear it out
	printf("\nReset reason(s): %s%s%s%s", (resetreason&(1<<0))?"[POR]":"", (resetreason&(1<<1))?"[EXTR]":"",
			(resetreason&(1<<2))?"[WDTR]":"", (resetreason&(1<<3))?"[BODR]":"");

	// Request part number
	command[0] = IAP_READ_PART;
	iap_entry(command, result);
	const char* partstrptr = NULL;
	for(int i=0; i<NUM_PARTS; i++) {
		if(result[1] == partmap[i].id) {
			partstrptr = partmap[i].name;
			break;
		}
	}
	// Read part revision
	partrev=*(uint8_t*)PART_REV_ADDR;
	if(partrev==0 || partrev > 0x1a) {
		partrev = '-';
	} else {
		partrev += 'A' - 1;
	}
	len = snprintf(buf,sizeof(buf),"%s rev %c",partstrptr,partrev);
	LCD_disp_str((uint8_t*)buf, len, 0, 64-6, FONT6X6);
	printf("\nRunning on an %s", buf);

	LCD_FB_Update();
	Keypad_Init();
	Buzzer_Init();
	ADC_Init();
	RTC_Init();
	OneWire_Init();
	Reflow_Init();

	Sched_SetWorkfunc( MAIN_WORK, Main_Work );
	Sched_SetState( MAIN_WORK, 1, TICKS_SECS( 2 ) ); // Enable in 2 seconds

	Buzzer_Beep( BUZZ_1KHZ, 255, TICKS_MS(100) );

	while(1) {
		int32_t sleeptime;
		sleeptime=Sched_Do( 0 ); // No fast-forward support
		//printf("\n%d ticks 'til next activity"),sleeptime);
	}
	return 0;
}