Exemplo n.º 1
0
void setup() {
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    ROM_FPULazyStackingEnable();
    ROM_FPUEnable();

    uart_setup();

    sd_init();
    dac_setup();
    keycontrol_setup();
    initConfig();
    tick_setup();    
    soundoutcontrol_setup();
    setupADC();
    setupUSBStore();
    initSampleBlocks();
    
    
    ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    ROM_IntMasterEnable();

    DEBUG_PRINT("Setup complete\n", NULL);
}
Exemplo n.º 2
0
int main(void)
{
	
	DO_TEST_HARNESS_PRE_INIT();

	setupIO();
	setupADC();
	setupTimer();
	setupStateMachine();
	
	pAverager = AVERAGER_GetAverager(U16, BUFFER_SIZE);
	
	sei();
	
	WD_DISABLE();
	
	DO_TEST_HARNESS_POST_INIT();
	
	while (true)
	{
		DO_TEST_HARNESS_RUNNING();
		
		if (ADC_TestAndClear(&adc))
		{
			adcHandler();
		}
		
		if (TMR8_Tick_TestAndClear(&appTick))
		{
			applicationTick();
		}		
	}

	return 0;
}
int main (void)
{
	/* set pin 5 of PORTB for output*/
	DDRB |= _BV(DDB5); //D13
	
	setupADC();
	hs_init();	
	hs_start(SERIAL_PORT, BAUD);

	while (1) 
	{
		if (hs_available(SERIAL_PORT))
		{
			u8Value = hs_getChar(SERIAL_PORT);
			if (u8Value == 'h')
			{
				/* set pin 5 high to turn led on */
				PORTB |= _BV(PORTB5);
				_delay_ms(BLINK_DELAY_MS);

				/* set pin 5 low to turn led off */
				PORTB &= ~_BV(PORTB5);
				_delay_ms(BLINK_DELAY_MS);
			}
		}
	}

	return 0;
}
Exemplo n.º 4
0
int main(void)
{
	unsigned constrained = 0, shutOffBuzzer = 0;
	
	//Set GPIO Pins
	if(!shutOffBuzzer)
		DDRB|=0b00100000; //PIN 13 output to buzzer
	
	DDRB|=0b00001000;

	sei();
		
	setupADC();
	setupPWM();
	startPWM();
	
	count=0;
    InitTimer0();
	StartTimer0();
	
	while(1)
    {	
		if(state)
			pwm_val = remap(adc_val,100,900);
		else
		{
		//0-255 steps for tone strength
			constrained = remap(adc_val,619,890);			
		//Output tone
			tone(constrained);
		}	
    }
}
Exemplo n.º 5
0
void main()
{
    DDRA = 0xFF;        // portA -> input
    DDRB = 0x0;         // portB -> output

    sei(); 		// Enable interupts
    setupADC();

    while(1)
    {
		runADC(Achannel);		    // Run ADC on A0, Interupt will then keep manage the
							        // Achannel variable and re-running the ADC

		while(Acomplete);		    // Wait for all ADC operations
	
		if(checkValues())		    // If slider has been moved encode & transmitt
	    {
		    char i=0;
		    for(i=0;i<3;i++)			// If difference copy new values to transmitt / prev out array
				Atrans[i] = Aout[i];

	        encode();
	        transmitt();
		}
		Acomplete = 0;
    }
    return 0;
}
Exemplo n.º 6
0
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
  wdt_disable();
//     SETUP_CREATE_PWR_EN;
//     h_CREATE_PWR_EN;
//     SETUP_KIN_EN;
//     h_KIN_EN;
//     SETUP_ULIMIT;
//     SETUP_LLIMIT;
//     EN_ULIMIT_ISR;
//     EN_LLIMIT_ISR;

//     setupGeneralState();

//     setupMotors();
     setupADC();

    //start next adc read:
//     ADCSRA |= 0x40;
   
//     setupMusic();   
   
	/* Disable clock division */
	clock_prescale_set(clock_div_1);

	/* Hardware Initialization */
// 	Joystick_Init();
// 	LEDs_Init();
	DDRD |= 0xf0; /* set LEDs to output */
	PORTD &= 0x0f; /* set LEDs to output */
SetupMotors();
 EnableMotors();
	USB_Init();
	
}
Exemplo n.º 7
0
int main(void)
{
	setupADC();	
	setupStepperMotor();
	startTimer();

	USART_init();
	
	mouse.velocity = 0;
	mouse.maxVelocity = 5000;
	mouse.acceleration = 2000;
	mouse.deceleration = 10000;

	enableDrive(1);
	turnOnTimers(1,1);
	
	for(int i = 0; i < 10; i++)
	{		
		int right = isWallRight();
		int front = isWallFront();
		int left = isWallLeft();
		
		if(!right)
		{
			rotateRight();
		}
		else if(front && !left)
		{
			rotateLeft();
		}
		else if(front)
		{
			moveBackwardsAndCorrect();
		}	
		
		if(left && right)		
			mouse.IR_CORRECT = 20;
		
		moveForwardAndStop();
		
		mouse.IR_CORRECT = 0;
		
		
	}

	
	turnOnTimers(0, 0);
	enableDrive(0);
	
	
	while(1==1)
	{

	}	
}
Exemplo n.º 8
0
void init(void) {
    setupFlash();
    setupClocks();
    setupNVIC();
    systick_init(SYSTICK_RELOAD_VAL);
    gpio_init_all();
    afio_init();
    setupADC();
    setupTimers();
    setupUSB();
    boardInit();
}
Exemplo n.º 9
0
void init(void) {
    setupFlash();
    setupClocks();
    setupNVIC();
    systick_init(SYSTICK_RELOAD_VAL);
    gpio_init_all();
    afio_init();
    setupADC();
    setupTimers();
    //    usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
    boardInit();
}
Exemplo n.º 10
0
int main(void) {
	char lcdString[80];

	// Initialize serial port for output
    uart_init();
    stdout = &uart_output;
    stdin  = &uart_input;

	setupADC(0x02);

	// Setup the LCD
	DDRB = 0xFF; // Set port B as output!
	PORTB = 0x00; // And zero it
	hd44780_connection *conn_struct = hd44780_createConnection(&PORTB, 0, &PORTB, 5, &PORTB, 4, &PORTB, 6);
	hd44780_driver *connDriver = hd44780_hl_createDriver(TMBC20464BSP_20x4, conn_struct, (uint8_t (*)(void*))hd44780_initLCD4Bit, (void (*)(void*, uint16_t))hd44780_sendCommand);
	hd44780_hl_init(connDriver, 0, 0);

	I2C_Config *masterConfig = I2C_buildDefaultConfig();
	I2C_masterBegin(masterConfig);

	DS1307_ToD time;	
	DS1307_setSQW(1, 0, DS1307_SQW_1Hz);
	DS1307_readToD(&time);

	DDRC &= 0xF7;
	PORTC |= 0x8;
	// See here for interrupts http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/
	PCICR |= 1 << PCIE1;
	PCMSK1 |= 1 << PCINT11;
	sei();


	_delay_ms(500);
	fprintf(stdout, "Start loop...\n");	

	uint16_t adc_val = readADC();
	while (1) {
		if (interruptReceived) {
			interruptReceived = 0;
			DS1307_readToD(&time);

			sprintf(lcdString, "%.2u-%.2u-%.4u\n%.2u:%.2u:%.2u\n\n%.1fC", time.dayOfMonth, time.month, time.year, time.hours, time.minutes, time.seconds, adcReadToTemp(adc_val, REF_VOLTAGE, SERIES_RESISTOR, THERMISTOR_NOMINAL, TEMPERATURE_NOMINAL, B_COEFFICIENT));
			hd44780_hl_printText(connDriver, 0, 0, lcdString);
		}

		adc_val = (adc_val +  readADC()) / 2;
	}

    return 0;
}
Exemplo n.º 11
0
void init(void) {
    setupFlash();
    setupClocks();
    setupNVIC();
    systick_init(SYSTICK_RELOAD_VAL);
    gpio_init_all();
    afio_init();
    setupADC();
    setupTimers();
//    setupUSB();
#if !defined(BOARD_STM32VLD)
    setupUSB();
#endif
    boardInit();
}
Exemplo n.º 12
0
//Reset and start all mouse constants and timers
void initializeMouse()
{
	setupADC();	
	setupStepperMotor();
	startTimer();
	
	USART_init();
	
	mouse.velocity = 0;
	mouse.maxVelocity = 2500;
	mouse.acceleration = 3000;
	mouse.deceleration = 12000;

	enableDrive(1);
	turnOnTimers(1,1);
}
Exemplo n.º 13
0
void init(void) {
    setupFlash();
// ok
    setupClocks();
// ok
    setupNVIC();
// ok
    systick_init(SYSTICK_RELOAD_VAL);
// ok
    gpio_init_all();
// ok
    afio_init();
// ok
    setupADC();
// adcs increase mA!
    setupTimers();
}
Exemplo n.º 14
0
int main(void)
{
    // Call setup functions
    setupSerial();
    setupTimers();
    setupADC();
    
    // Set external interrupts
    sei();
    
    while (1)
    {
        // Infinite loop
    }
    
    return 0;
}
int main (void)
{

	setupADC();
	hs_init();	
	hs_start(SERIAL_PORT, BAUD);

	while (1) 
	{
		u8Value = adc_read(ADC_IN);
		hs_writeChar(SERIAL_PORT, 'h');
		hs_writeChar(SERIAL_PORT, '\n');
		_delay_ms(1000);
	}

	return 0;
}
Exemplo n.º 16
0
/*
 * @brief   stm32 board specific init
 * @param   none
 * @return  none
 * @note    none
 */
void stm32utils_system_init(void)
{
    setupFlash();
    setupClocks();
    setupNVIC();
    systick_init(SYSTICK_RELOAD_VAL);
    gpio_init_all();
    afio_init();
    setupADC();
    setupTimers();
    setupUSART(USARTx, SERIAL_BAUDRATE);

    gpio_set_mode(GPIOA, 0, GPIO_OUTPUT_PP);
    gpio_write_bit(GPIOA, 0, 0);
    gpio_set_mode(GPIOA, 1, GPIO_OUTPUT_PP);
    gpio_write_bit(GPIOA, 1, 0);
    gpio_set_mode(GPIOA, 12, GPIO_OUTPUT_PP);
    gpio_write_bit(GPIOA, 12, 0);
}
Exemplo n.º 17
0
/**
 * The main setup function for the vehicle.  Initalized the Amarino communications,
 * then calls the various setup functions for the various modules.
 */
void setup()
{
  // Core board initialization
  initBoard();

  // Arm thruster
  thruster.arm();

  // Reset all PID values to zero
  resetPID();

  // Load PID constants in from EEPROM
  eeprom_read_block(&pid, &pidEeprom, sizeof(pidConstants_t));

  // Set up serial communications
  amarino.registerFunction(setVelocity, SET_VELOCITY_FN);
  amarino.registerFunction(setPID, SET_PID_FN);
  amarino.registerFunction(getPID, GET_PID_FN);

  // Configure ADC
  setupADC();
}
Exemplo n.º 18
0
void init(void) {
    setupFlash();
    setupClocks();
    setupNVIC();
    systick_init(SYSTICK_RELOAD_VAL);
    gpio_init_all();
    afio_init();
    setupADC();
    setupTimers();
    setupUSB();
    boardInit();

    //for debug
    gpio_set_mode(GPIOA, 2, GPIO_AF_OUTPUT_PP);
 	gpio_set_mode(GPIOA, 3, GPIO_INPUT_FLOATING);


 	usart_init(USART2);
 	usart_set_baud_rate(USART2, STM32_PCLK1, 57600);
 	usart_enable(USART2);
 	/*delay(1000);
 	TxDString("hello pandora\r\n");*/
}
Exemplo n.º 19
0
int main( void ) 
{
	setupBSP();

	Delay_Init();
 
	setupMEM();
	setupFPGA();
	setupINT();

	setupCMU();

	setupPRS();

	setupDAC();
	setupDMA();
	setupADC();

	setupTIMER();

	Delay_Init();

	BSP_LedsInit();
	BSP_LedsSet(0);

	while(1) {

		//test_and_display();
		BSP_LedToggle(0);
		Delay(1000);
		BSP_LedsSet(0);
		Delay(500);

	}
	
}
Exemplo n.º 20
0
int main(int argc, char * argv[])
{
  char count1;
  
  CircularBufInit(uart0_in,sizeof(uart0_in));
  CircularBufInit(uart0_out,sizeof(uart0_out));
  
  Uart0_Init();
//  Uart0_SetBaudrate(115200);
  Uart0_SetBaudrate(19200);
  Uart0_SetFormat(8,1,2);
  
  sei();
  
  ConfigTimer1PWM();
  
#if 0
  DIDR0=0x01; //Disable digital input buffers of ADC analog input pins.
  DIDR1=0x03; //Disable digital input buffers of ACOMP analog input pins.
 
  setupOCR2();
  
  EICRA = 0x03; //external interrupt
  EIMSK = 1;
  EIFR  = 1; // Remove possible interrupt from INT0
  setupADC();
#endif
  
  count1 = 0;

#if 0
  CircularBufWrite(uart0_out,'2');
  CircularBufWrite(uart0_out,'3');
  CircularBufWrite(uart0_out,'4');
  Uart0_StartTx();
#endif  

  
  while(1)
  {
    uint16_t w;
    
    if (CircularBufNotEmpty_INLINE(uart0_in))
    {
      uint8_t c;

      c = CircularBufRead(uart0_in);
      mudem_ByteReceived(c);
    }
    
    while ( CircularBufNotFull_INLINE(uart0_out) && (w = mudem_GetOut()))
    {
      CircularBufWrite(uart0_out,w);
      Uart0_StartTx();
    }
    
  //  dht11_start();

    
#if 0
    if(ev == serial_line_event_message)
    {
       char * pc=(char*)data;
       char c;
       
//       printf("received line: %s\n", pc);
       while (c=*pc++)
       {
         if (c=='-')
         {
           s_ocr2--;
           updateOCR2();
         }
         if (c=='+')
         {
           s_ocr2++;
           updateOCR2();
         }
         
         
//         printf("%dkHz",16000/s_ocr2);
       }
       
    }
#endif    
    
  }
  
}