Ejemplo n.º 1
0
void Init() {
    JtagDisable();
    Uart.Init(USART2, 256000);
#ifndef TESTING
    // Charging and powering
    PinSetupIn(EXT_PWR_GPIO,  EXT_PWR_PIN,  pudPullDown);
    PinSetupIn(CHARGING_GPIO, CHARGING_PIN, pudPullUp);

    LedsInit();
    VibroInit();
    if(!Iwdg.ResetOccured()) {
        Uart.Printf("Glove1_f100 AHB=%u; APB1=%u; APB2=%u\r", Clk.AHBFreqHz, Clk.APB1FreqHz, Clk.APB2FreqHz);
        Vibro.On(100);
        chThdSleepMilliseconds(99);
        ShowChargeLevel();
        chThdSleepMilliseconds(900);
        SwitchOffEverything();
    }
    else Uart.Printf("W\r");
    AccInit();

    // Application init
    App.Init();
#else
    Uart.Printf("Glove tester\r");
    PinSetupOut(GPIOA, 15, omPushPull);
    PinSet(GPIOA, 15);
    chThdSleepMilliseconds(450);
    Acc[0].SetPortAndPins(GPIOA, 1, 3, 4);
#endif
}
Ejemplo n.º 2
0
void Global_Init(void)
{
	// Initialize system
		SystemInit();

		// Initialize button and LEDs
		init_GPIO();

		// Initialize delay
		TM_DELAY_Init();

		// Init sounds
		InitSounds();

		// Initialize accelerometer
		AccInit();

		// Initialize USB, IO, SysTick, and all those other things you do in the morning
		init();

		//timerINit
		Timer_Init();


}
Ejemplo n.º 3
0
int main(void)
{
    //Code geoptimaliseerd voor bordje 3
    //###1###

    //Initialize subsystems
    ClockInit();			//Initialize system clock (16 MHz)
    USARTInit();			//Initialize USART and bind to stdout,stdin
    AnalogInit();			//Initialize ADC
    AccInit();			//Initialize accelerometer system
    LEDInit();			//Initialize LEDs
    SwitchInit();			//Initialize switches
    EncoderInit();			//Initialize encoder
    SpeakerInit();			//Initialize speaker system

    //Enable interrupts
    PMIC.CTRL|=0b00000111;  	//Enable low, medium, high priority interrupts
    SREG|=0b10000000;		//Globale interrupt enable

    //###2###

    //Print the digits 0 to 9 5x on terminal device
    //Reason this section didn't work: de variabelen 'a' is globaal gedefinieerd. In het subprogramma 'SimpleFunction()' wordt
    //de variabelen 'a' gebruikt. Na dit subprogramma is de waarde van 'a' gelijk aan 10 en zal de lus (a<5) onderbroken worden.

    for (a=0; a<5; a++)
    {
        SimpleFunction();
        printf ("\r\n");
    }

    //###3###

    //Main program loop
    a=0;
    ledOn=0b00001000;

    //Beeps();		//Genereer 3 beeps van 500hz, 1000hz, 1500hz (500 ms)
    setNotes();		//Stel een reeks van noten in
    playNextNote();		//Speel de eerste noot uit de reeks

    while(1)
    {
        LoopLicht();						//LoopLicht sequentie
        AccLezen();						//Accelerometer lezen
        printf("$SWITCH %d\r\n", SwitchGet());			//Switchwaarde over USARTD: 1: center, 2: rechts, 4: beneden, 8: links, 16: boven
        printf("$ACCRAW %d %d %d\r\n", RawAccX, RawAccY, RawAccZ);						//Ongecalibreerde waardes accelerometer x, y, z over USARTD
        printf("$ACC__ %d %d %d\r\n", AccGetXAxis(RawAccX), AccGetYAxis(RawAccY), AccGetZAxis(RawAccZ));	//Gecalibreerde waardes accelerometer x, y, z over USARTD
        printf("$ENC__ %d\r\n", EncoderGetPos());
        //printf ("Counter:%d\r\n",a);
        //printf("%c", 0x55);					//Stuur de waarde 0x55 uit (0b01010101)
        //a++;
        _delay_ms(20);
    }
}