Beispiel #1
0
/* Main ----------------------------------------------------------------------*/
int main(void){

 // Setups.
	setup_ADC1_with_DMA2( );	
	setup_USART1_with_NVIC( );
	setup_GPIO( );
	GPIO_SetBits(GPIOD, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
	//setup_Timer2( );
	setup_PWM( );


	//uint32_t motorBaseA = 100;
	//uint32_t motorBaseB = 100;

	while(1){

		// Skickar iväg ADC buffern som är 16 lång. 
		for(int i=0; i<16; i++){
			USART_putn(USART1, (char*)&ADC_RawBuffer[i], 2);    	
		}
		//USART_putn(USART1, (char*)&ADC_RawBuffer[2], 2);

		delay(50); // Vänte lite med och skicka igen.


		// LÄSA ADCn

		// REGULATOR

		// REGLERA PWM FÖR MOTORERNA

 
	}
}
Beispiel #2
0
int main(void) {
    setup_serial();
    setup_PWM();

    while(1) {
        receive(); // block waiting for the next command from the PC
        process_command();  // we've gotten a command, so process it
        OCR1A = brightness*brightness; // set the brightness of the LED accordingly
    }
    return 0;
}