Exemplo n.º 1
0
void Main_task(uint32_t initial_data)
{
    int  ret = 0;
    char filesystem_name[] = "a:";
    char partman_name[]    = "pm:";
    MQX_FILE_PTR com_handle, sdcard_handle, filesystem_handle, partman_handle;

    printf("Starting client example... \n");

    ret = sdcard_open(&com_handle, &sdcard_handle, &partman_handle,
                      &filesystem_handle, partman_name, filesystem_name);

    if (ret != 0) {
        printf("error: sdcard_open(), ret = %d\n", ret);
        _mqx_exit(1);
    }
    printf("SD card installed to %s\n", filesystem_name);

    setup_ethernet();
    setup_clock();
    client_test();

    ret = sdcard_close(&sdcard_handle, &partman_handle, &filesystem_handle,
                       partman_name, filesystem_name);

    if (ret != 0) {
        printf("error: sdcard_close(), ret = %d\n", ret);
        _mqx_exit(1);
    }
    printf("SD card uninstalled.\n");

    _mqx_exit(0);
}
Exemplo n.º 2
0
void main(void)
{
	struct mem_timings *mem;
	void *entry;
	int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP);

	/* Clock must be initialized before console_init, otherwise you may need
	 * to re-initialize serial console drivers again. */
	mem = setup_clock();

	console_init();

	setup_power(is_resume);
	setup_memory(mem, is_resume);

	if (is_resume) {
		wakeup();
	}

	setup_storage();
	setup_gpio();
	setup_graphics();

	/* Set SPI (primary CBFS media) clock to 50MHz and configure pinmux. */
	exynos_pinmux_spi1();
	clock_set_rate(PERIPH_ID_SPI1, 50000000);

	cbmem_initialize_empty();

	entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, "fallback/ramstage");
	stage_exit(entry);
}
Exemplo n.º 3
0
int main( void )
{
	stop_watchdog();
	setup_finish_ports();
	setup_clock();
	setup_uart();
	rf_init(sizeof(struct packet));
	configure_timer_38k();
	timer_38k_enable(1);
	configure_watchdog();

	__enable_interrupt();

	// Show battery voltage on start
	display_vcc();

	// Setup RF channel
	setup_channel();

	set_state(st_stopped);

	// Start/stop loop
	for (;;) {
		wait_start();
		set_state(st_started);
		beep(SHORT_DELAY_TICKS);
		detect_finish();
		set_state(st_stopped);
		report_finish();
	}
}
Exemplo n.º 4
0
void setup(){
    setup_clock();
    enable_interrupts();
    enable_timer0();
    setup_pulse_in();
    setup_pulse_out();
    setup_uart();
    #ifdef DEBUG
    run_tests();
    #endif
}
Exemplo n.º 5
0
int main( void )
{
	cli();

	setup_clock();

	InitBuffer(&ab);

	//Don't touch any PORTB below 4, those are for printf
//	SetupPrintf();

	USB_ZeroPrescaler();
	USB_Init();

	DDRC = 0x0;

	SPI_MasterInit();

//	_delay_ms(10); //wait for tiny 44 to be ready for data
//	setup_timers();

	setup_channel_interrupt();

	DDRD |= _BV(PD6);

	sei();

//	testAsm();
//	if (testPtr == 'w') PORTD |= _BV(PD6);

	while(1)
	{
		UENUM = 4; //interrupts can change this

		//these if statements can take a bit of time so run them and save the
		//result for future use
		if ( USB_READY(UEINTX) && (BytesFree(&ab) >= 8) )
			dataState=1;
		else if ( BytesUsed(&ab) >= 2)
			dataState=2;
		else
			dataState=0;

		while (needAudioFlag==0);
cli();
		needAudioFlag=0;

		DoAudioState();
sei();
	}

	return 0;
}
Exemplo n.º 6
0
int main( )
{
	int i;
	cli();

	setup_clock();

	DDRB &= _BV(2); //Sound input
	DDRB |= _BV(3) | _BV(4); //Speaker

	//Processor is operating at ~25 MHz, or a 100? MHz main clock???
	//Let's try using the timer as-is, 8 bit fast PWM.
	//120 MHz?? / 256 cycles = 500 kHz... That seems high enough.

	//CONNECT SPEAKER PIN PB3 to PB4
	//PB3 = ~OC1B~
	//PB4 =  OC1B

	//CONNECT Electret Mic between GND and PB2, with a resistor from PB2 to VCC.

	TCCR1 = _BV(CS10); //Use high speed PCK.
	GTCCR = _BV(PWM1B) | _BV(COM1B0);
	//Make sure PLLE is already selected.

	//Turn on the ADC.
	//ADC1 = PB2 (MUX = 1)
	//REFS = 0 to 5V ADC.
	//Set ADC to free run, with MSB 8 bits in ADCH. (ADLAR = 1)
	//Set ADC clock to system / 16.
	ADMUX = /*_BV(ADLAR) |*/1;
	ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADPS2) | _BV(ADPS1);
	while(1)
	{
		//This will cause OCR1B to make a triangle wave, going up over time,
		//then resetting to 0 every 256 cycles.
		//If you wait 100 us between cycles, that is 1/(.00001*256)
		//Or around 390 Hz.
		//Measured voltage = 2.05V / 4.85 = 0.422 * 256 = 108 is the center.

		int16_t i = ADC;
		i -= 104*4;

		i *= 5;

		if( i > 127 ) i = 127;
		if( i < -127 ) i = -127;

		OCR1B = i + 127;
	}
	
	return 0;
} 
Exemplo n.º 7
0
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    setup_clock();

    init_quadromotor_booster_pack_stepper();

    for(;;) {
    	motor_1_do_one_step(FWD);
    	motor_2_do_one_step(BWD);
    	_delay_cycles(10000);
    }
	
	return 0;
}
Exemplo n.º 8
0
int main( void )
{
	cli();

	DDRB = _BV(PB2); //pwm output for LED

	setup_clock();
	setup_pwm();

	OCR0A = 0; //25%

	sei();

	while(1);

	return 0;
}
Exemplo n.º 9
0
void main(void)
{
	struct mem_timings *mem;
	int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP);

	timestamp_init(timestamp_get());
	timestamp_add_now(TS_START_ROMSTAGE);

	/* Clock must be initialized before console_init, otherwise you may need
	 * to re-initialize serial console drivers again. */
	mem = setup_clock();

	console_init();
	exception_init();

	setup_power(is_resume);

	timestamp_add_now(TS_BEFORE_INITRAM);

	setup_memory(mem, is_resume);

	timestamp_add_now(TS_AFTER_INITRAM);

	/* This needs to happen on normal boots and on resume. */
	trustzone_init();

	if (is_resume) {
		wakeup();
	}

	setup_gpio();
	setup_graphics();

	/* Set SPI (primary CBFS media) clock to 50MHz and configure pinmux. */
	exynos_pinmux_spi1();
	clock_set_rate(PERIPH_ID_SPI1, 50000000);

	cbmem_initialize_empty();

	timestamp_add_now(TS_END_ROMSTAGE);

	run_ramstage();
}
Exemplo n.º 10
0
int main( void )
{
	cli();

	SetupPins();

	setup_clock();
	setup_timers();

//	setup_spi();
	sei();

	while(1)
	{
//		ReportCalibration();
		if (DoShutterEvent != NULL) TryShutterEvent();
		if ((flags & _BV(BUTTON_UPDATE))>0) ButtonFeedback();
		if ((flags & _BV(BUTTON_RELEASED))>0) ProcesButton();
	}

	return 0;
}
Exemplo n.º 11
0
void setup() {
  measurePCLK();
  setup_clock();
  pinMode(15,OUTPUT);
}
Exemplo n.º 12
0
int main( )
{
	int i;
	unsigned char wasa, wasb, isa, isb;
	cli();

	setup_clock();

	DDRB = 0;
	DDRB |= _BV(3) | _BV(4) | _BV(1);
	PORTB &= ~_BV(1);

	wasa = 0;
	wasb = 0;

	int suppress = 10;

#define STREAM
	for( ;; )
	{
#ifdef STREAM
		_delay_ms(8);
			SendCPacket();
		continue;
#endif

		_delay_ms(8);
//		PORTB |= _BV(1);
		SendTick();
//		PORTB |= _BV(1);
		_delay_ms(8);

//			SendCPacket();
//continue;

		i++;


/*		if( !suppress )
		{
			if( isa != wasa )
			{
				if( isa )
					SendAPacket();
				wasa = isa;
				continue;
			}
			if( isb != wasb )
			{
				if( isb )
					SendBPacket();
				wasb = isb;
				continue;
			}
		}*/

		if( i == 20 )
		{
			SendCPacket();
//			PORTB |= _BV(1);
			if( suppress ) suppress--;
			i = 0;
		}
	}

	
	return 0;
} 
Exemplo n.º 13
0
int main( )
{
	uint8_t frame;
	static uint8_t i;
	static uint16_t adcT = 0;  //ADC Temp
	static uint16_t adcP = 0;  //ADC Pin
	static uint8_t last_timercycle = 0;
	cli();

	setup_clock();

	//1st let's see how fast we can clock the pin.
	et_init( MyMAC );

	i = 0;


	//Assumed setup:
	//
	// PB2: Disconnect this (I don't know if you can use it at all)
	// PB1: TX (From this device, out) Put a 47nF capcaitor in series.

	//Enable ADC.  (For reading in pin ADC2)
	PORTB &= ~_BV(4);
	PORTB |= _BV(4);
	ADCSRA = _BV(ADEN) | _BV(ADPS1) | _BV(ADPS0) | _BV(ADSC) | _BV(ADATE);

	//Enable port B for the WS2812B.
	WSDDR |= WSPIN;
	WSPORT &= ~WSPIN;

	//The burden of configuring the tick timer is on you, the user.
	//#188 Creates a clock with period ~4ms. ~3.2ms at 31MHz, ~4.8ms at 20 MHz.
	//Making it lower seems to help.
	TCCR1 = _BV(CTC1) | _BV(CS13) | _BV(CS12); //HS Clock/2048
	OCR1C = 255; 
	OCR1A = 1;
	TIMSK = _BV(OCIE1A);

	//Enable Pin Change Interrupt.
	//(For if we have some RX data)
	PCMSK |= _BV(PCINT0);
	GIMSK |= _BV(PCIE);

	sei();

	OSCCAL = OSCHIGH;
	PORTB |= _BV(0);

	while(1)
	{
		if( last_timercycle != timercycle )
		{
			last_timercycle = timercycle;
			//i++;
			i = timercycle & 0x0f;

			if( i == 0 )
			{
				ADMUX = 2;
			}

			if( i == 1 )
			{
				adcP = ADC;
				ADMUX = _BV(REFS1) | 0x0f;
			}

			if( i == 2 )
			{
				adcT = ADC;
			}

			if( i == 14 )
			{

				frame++;
				//How to send a UDP Packet.
				cli();
				OSCCAL = OSC20;
				et_stopop();
				et_startsend( 0 );
				memset( macfrom, 0xff, 6 );
				send_etherlink_header( 0x0800 );
				send_ip_header( 0, (unsigned char*)"\xff\xff\xff\xff", 17 ); //UDP Packet to 255.255.255.255
				et_push16( 13313  ); //to port
				et_push16( 13312 ); //from port
				et_push16( 0 ); //length for later
				et_push16( 0 ); //csum for later
				et_pushpgmstr( PSTR( "TPIN" ) ); //csum for later
				et_push16( adcT ); 
				et_push16( adcP ); 
				et_push16( icmp_out ); 
				et_push16( hict ); 
				et_push16( lowct );
				util_finish_udp_packet();
				OSCCAL = OSCHIGH;
				sei();
				i = 0;

			}

		}
	}



	return 0;
} 
Exemplo n.º 14
0
int main( void )
{
	int32_t tmp = 0x0;
//	uint8_t tmp8;

	cli();

	SetupInterruptPins();

	y_pos = 0;
	x_pos = 0;

//	DDRC = _BV(PC6); //output pin
	SetupDriverPins();

	setup_clock();
	setup_timers();
	SetupPrintf();

	USB_ZeroPrescaler();
	USB_Init();

	sei();

	printf("hello world");

//	motorflags |= 0x01;
//	set_motor_pwm(PWM_MAX);
//	forward();
//	while(1);

//AutoSlop();

/*
AutoSlop();
while(1);
*/

//		dec_backward();
//		set_dec_pwm(0x1fff);
//		ra_forward();
//		set_ra_pwm(0x3fff);

	while(1)
	{
		cli();
//		tmp8 = usbHasEvent;
		//add accumulated radial encoder output
		y_pos += y_tmp;
		y_tmp = 0;

		x_pos += x_tmp;
		x_tmp = 0;
		sei();

		if (usbHasEvent) ProcessUSB();

		if (jog_value_dec == 0) {
			tmp = ComputeOffset(&y_pos,&y_dest); //pid error value
			slew_dec(&tmp);
		}

		if (jog_value_ra == 0) {
			tmp = ComputeOffset(&x_pos,&x_dest); //pid error value
			slew_ra(&tmp);
		}

	}
	return 0;
}
Exemplo n.º 15
0
extern "C" void handler_reset() {
    setup_clock();
    copy(&__data_start, &__data_end, &__data_load);
    fill(&__bss_start, &__bss_end, 0);
    kmain();
}