示例#1
0
文件: bsp.c 项目: alisonjoe/qpc
/* BSP functions ===========================================================*/
void BSP_init(void) {
    /* NOTE: SystemInit() has been already called from the startup code
    *  but SystemCoreClock needs to be updated
    */
    SystemCoreClockUpdate();

    /* turn the GPIO clock on */
    LPC_SC->PCONP |= (1U << 15);

    /* setup the GPIO pin functions for the LEDs... */
    LPC_PINCON->PINSEL3 &= ~(3U <<  4); /* LED_1: function P1.18 to GPIO */
    LPC_PINCON->PINSEL3 &= ~(3U <<  8); /* LED_2: function P1.20 to GPIO */
    LPC_PINCON->PINSEL3 &= ~(3U << 10); /* LED_3: function P1.21 to GPIO */
    LPC_PINCON->PINSEL3 &= ~(3U << 14); /* LED_4: function P1.23 to GPIO */

    /* Set GPIO-P1 LED pins to output */
    LPC_GPIO1->FIODIR |= (LED_1 | LED_2 | LED_3 | LED_4);


    /* setup the GPIO pin function for the Button... */
    LPC_PINCON->PINSEL0 &= ~(3U << 12); /* function P0.6 to GPIO, pull-up */

    /* Set GPIO-P0 Button pin as input */
    LPC_GPIO0->FIODIR &= ~BTN_EXT;

    BSP_randomSeed(1234U);

    if (QS_INIT((void *)0) == 0U) { /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_EINT0_IRQHandler);
    QS_USR_DICTIONARY(PHILO_STAT);
}
示例#2
0
文件: qp.c 项目: henrychoi/realtime
void BSP_init(void) {
	uint32_t err_code;
    err_code = nrf_drv_timer_init(&TIMER1, NULL, Timer1_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_timer_extended_compare(&TIMER1, NRF_TIMER_CC_CHANNEL0
    		, nrf_drv_timer_ms_to_ticks(&TIMER1, 1000/BSP_TICKS_PER_SEC)
			, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    // Configure button 1 for low accuracy (why not high accuracy?)
    Q_ALLEGE(nrf_drv_gpiote_init() == NRF_SUCCESS);

    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    config.pull = NRF_GPIO_PIN_PULLUP;

    Q_ALLEGE(nrf_drv_gpiote_in_init(BTN_PIN, &config, btn1_event_handler)
    		== NRF_SUCCESS);
    nrf_drv_gpiote_in_event_enable(BTN_PIN, /* int enable = */ true);

    NRF_GPIO->DIRSET = 1 << GPIO_TP;

    /* initialize the QS software tracing... */
    if (QS_INIT((void *)0) == 0) {
        Q_ERROR();
    }
}
示例#3
0
文件: bsp.cpp 项目: dongkc/rtu_drv
//............................................................................
void BSP_init(void) {

    Q_ALLEGE(QS_INIT((void *)0));
    QS_RESET();
    QS_OBJ_DICTIONARY(&l_clock_tick);      // must be called *after* QF_init()
    QS_USR_DICTIONARY(PHILO_STAT);
}
示例#4
0
文件: bsp.cpp 项目: dizel3d/qpcpp
//............................................................................
void BSP_init(int argc, char *argv[]) {
    // set the system clock as specified in lm3s_config.h (20MHz from PLL)
    SystemInit();

    // enable clock to the peripherals used by the application
    SYSCTL->RCGC2 |= (1 <<  0) | (1 <<  2);      // enable clock to GPIOA & C
    __NOP();                                     // wait after enabling clocks
    __NOP();
    __NOP();

    // configure the LED and push button
    GPIOC->DIR |= USER_LED;                           // set direction: output
    GPIOC->DEN |= USER_LED;                                  // digital enable
    GPIOC->DATA_Bits[USER_LED] = 0;                   // turn the User LED off

    GPIOC->DIR &= ~PUSH_BUTTON;                       //  set direction: input
    GPIOC->DEN |= PUSH_BUTTON;                               // digital enable

    Display96x16x1Init(1);                      // initialize the OLED display
    Display96x16x1StringDraw("Dining Philos", 0, 0);
    Display96x16x1StringDraw("0 ,1 ,2 ,3 ,4", 0, 1);

    if (QS_INIT((void *)0) == 0) {       // initialize the QS software tracing
        Q_ERROR();
    }

    (void)argc;              // avoid compiler warning about unused parameters
    (void)argv;
}
示例#5
0
/*..........................................................................*/
void BSP_init(void) {

    SystemInit();         /* initialize STM32 system (clock, PLL and Flash) */

             /* initialize LEDs, Key Button, and LCD on STM3210X-EVAL board */
    STM_EVAL_LEDInit(LED1);
    STM_EVAL_LEDInit(LED2);
    STM_EVAL_LEDInit(LED3);
    STM_EVAL_LEDInit(LED4);

    STM3210C_LCD_Init();                              /* initialize the LCD */
    LCD_Clear(White);                                      /* clear the LCD */
    LCD_SetBackColor(Grey);
    LCD_SetTextColor(Black);
    LCD_DisplayString(Line0, 0, "   Quantum Leaps    ");
    LCD_DisplayString(Line1, 0, "     DPP example    ");
    LCD_DisplayString(Line2, 0, "QP/C(Vanilla)       ");
    LCD_DisplayString(Line2, 14*16, QF_getVersion());
    LCD_SetBackColor(White);
    LCD_DisplayString(Line5, 0, "DPP:");
    LCD_SetBackColor(Black);
    LCD_SetTextColor(Yellow);
    LCD_DisplayString(Line9, 0, "  state-machine.com ");
    LCD_SetBackColor(Blue);
    LCD_SetTextColor(White);
    LCD_DisplayString(Line5, 4*16, "0 ,1 ,2 ,3 ,4    ");

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }
}
示例#6
0
文件: bsp.c 项目: alisonjoe/qpc
/* BSP functions ===========================================================*/
void BSP_init(void) {
    /* NOTE: SystemInit() has been already called from the startup code
    *  but SystemCoreClock needs to be updated
    */
    SystemCoreClockUpdate();

    /* enable GPIOA clock port for the LED LD2 */
    RCC->AHBENR |= (1U << 0);

    /* configure LED (PA.5) pin as push-pull output, no pull-up, pull-down */
    GPIOA->MODER   &= ~((3U << 2*5));
    GPIOA->MODER   |=  ((1U << 2*5));
    GPIOA->OTYPER  &= ~((1U <<   5));
    GPIOA->OSPEEDR &= ~((3U << 2*5));
    GPIOA->OSPEEDR |=  ((1U << 2*5));
    GPIOA->PUPDR   &= ~((3U << 2*5));

    /* enable GPIOC clock port for the Button B1 */
    RCC->AHBENR |=  (1U << 2);

    /* configure Button (PC.13) pins as input, no pull-up, pull-down */
    GPIOC->MODER   &= ~(3U << 2*13);
    GPIOC->OSPEEDR &= ~(3U << 2*13);
    GPIOC->OSPEEDR |=  (1U << 2*13);
    GPIOC->PUPDR   &= ~(3U << 2*13);

    BSP_randomSeed(1234U); /* seed the random number generator */

    /* initialize the QS software tracing... */
    if (QS_INIT((void *)0) == 0U) {
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
}
/*..........................................................................*/
void BSP_init(void) {
    WDT.TCSRWD.BYTE = 0x10;                             /* disable Watchdog */
    WDT.TCSRWD.BYTE = 0x00;

    MSTCR2.BIT.MSTTZ   = 0;                               /* turn on TimerZ */
    TZ0.TCR.BIT.TPSC   = 3;                         /* internal clock phi/8 */
    TZ0.TCR.BIT.CCLR   = 1;
    TZ0.GRA            = (uint16_t)(((f1_CLK_SPEED/8 + BSP_TICKS_PER_SEC/2)
                                     / BSP_TICKS_PER_SEC) - 1);
    TZ0.TIER.BIT.IMIEA = 1;               /* compare match interrupt enable */

                                                 /* enable the User LEDs... */
    LED0_DDR_1();                           /* configure LED0 pin as output */
    LED1_DDR_1();                           /* configure LED1 pin as output */
    LED2_DDR_1();                           /* configure LED2 pin as output */
    LED3_DDR_1();                           /* configure LED3 pin as output */
    LED0 = LED_OFF;
    LED1 = LED_OFF;
    LED2 = LED_OFF;
    LED3 = LED_OFF;
                                                    /* enable the Switch... */
    SW1_DDR = 0;

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }
}
示例#8
0
文件: bsp.c 项目: MCUapps/qpc-gnu
/*..........................................................................*/
void BSP_init(void) {
    WDTCTL   = (WDTPW | WDTHOLD);                               /* Stop WDT */

    /* configure the Basic Clock Module */
    DCOCTL   = CALDCO_8MHZ;                              /* Set DCO to 8MHz */
    BCSCTL1  = CALBC1_8MHZ;

    TACTL    = (ID_3 | TASSEL_2 | MC_1);       /* SMCLK, /8 divider, upmode */
    TACCR0   = (((BSP_SMCLK / 8) + BSP_TICKS_PER_SEC/2) / BSP_TICKS_PER_SEC);

    P1DIR   |= (BIT0 | BIT1);               /* P1.0 and P1.1 outputs (LEDs) */

    P1DIR  &= ~BIT2;                             /* P1.2 input (Switch TS1) */
    P1REN  |=  BIT2;                     /* enable pull-up resistor on P1.2 */
    P1SEL  &= ~BIT2;                         /* enable I/O function on P1.2 */
    P1IES  |=  BIT2;                     /* interrupt edge select high->low */
    P1IFG  &= ~BIT2;                              /* clear interrupt source */

    BSP_randomSeed(1234U);

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_RESET();
    QS_OBJ_DICTIONARY(&l_timerA_ISR);
}
示例#9
0
文件: bsp.c 项目: alisonjoe/qpc
/* BSP functions ===========================================================*/
void BSP_init(void) {
    /* NOTE: SystemInit() has been already called from the startup code
    *  but SystemCoreClock needs to be updated
    */
    SystemCoreClockUpdate();

    /* enable GPIOA clock for the LED */
    RCC->AHBENR |= (1U << 0);

    /* configure LED (PA.5) pin as push-pull outputs, No pull-up, pull-down */
    GPIOA->MODER   &= ~((3U << 2*5));
    GPIOA->MODER   |=  ((1U << 2*5));
    GPIOA->OTYPER  &= ~((1U <<   5));
    GPIOA->OSPEEDR &= ~((3U << 2*5));
    GPIOA->OSPEEDR |=  ((1U << 2*5));
    GPIOA->PUPDR   &= ~((3U << 2*5));

    /* enable GPIOC clock for the Button */
    RCC->AHBENR |=  (1ul << 2);

    /* configure BTN (PC.13) pin as push-pull outputs, No pull-up, pull-down */
    GPIOC->MODER   &= ~(3ul << 2*13);
    GPIOC->OSPEEDR &= ~(3ul << 2*13);
    GPIOC->OSPEEDR |=  (1ul << 2*13);
    GPIOC->PUPDR   &= ~(3ul << 2*13);


    BSP_randomSeed(1234U);

    if (QS_INIT((void *)0) == 0U) { /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_tickHook);
    QS_OBJ_DICTIONARY(&l_EXTI0_IRQHandler);
}
/*..........................................................................*/
void BSP_init(void) {
    uint32_t i;

    for (i = 0; i < Q_DIM(l_led); ++i) {          /* initialize the LEDs... */
        AT91C_BASE_PIOA->PIO_PER = l_led[i];                  /* enable pin */
        AT91C_BASE_PIOA->PIO_OER = l_led[i];     /* configure as output pin */
        LED_OFF(i);                                   /* extinguish the LED */
    }
                /* configure Advanced Interrupt Controller (AIC) of AT91... */
    AT91C_BASE_AIC->AIC_IDCR = ~0;                /* disable all interrupts */
    AT91C_BASE_AIC->AIC_ICCR = ~0;                  /* clear all interrupts */
    for (i = 0; i < 8; ++i) {
        AT91C_BASE_AIC->AIC_EOICR = 0;           /* write AIC_EOICR 8 times */
    }

                             /* set the desired ticking rate for the PIT... */
    i = (MCK / 16 / BSP_TICKS_PER_SEC) - 1;
    AT91C_BASE_PITC->PITC_PIMR = (AT91C_PITC_PITEN | AT91C_PITC_PITIEN | i);

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&QS_tickIRQ);
}
示例#11
0
//............................................................................
void BSP_init(void) {
    // set the system clock as specified in lm3s_config.h (20MHz from PLL)
    SystemInit();

    // enable clock to the peripherals used by the application
    SYSCTL->RCGC2 |= 1U | (1U << 2);              // enable clock to GPIOA & C
    __NOP();                                     // wait after enabling clocks
    __NOP();
    __NOP();

    // configure the LED and push button
    GPIOC->DIR |= USER_LED;                           // set direction: output
    GPIOC->DEN |= USER_LED;                                  // digital enable
    GPIOC->DATA_Bits[USER_LED] = 0U;                  // turn the User LED off

    GPIOC->DIR &= ~PUSH_BUTTON;                       //  set direction: input
    GPIOC->DEN |= PUSH_BUTTON;                               // digital enable

    Display96x16x1Init(1U);                     // initialize the OLED display
    Display96x16x1StringDraw(&"Dining Philos"[0], 0U, 0U);
    Display96x16x1StringDraw(&"0 ,1 ,2 ,3 ,4"[0], 0U, 1U);

    Q_ALLEGE(QS_INIT(static_cast<void *>(0)));
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_GPIOPortA_IRQHandler);
    QS_USR_DICTIONARY(PHILO_STAT);
}
示例#12
0
//............................................................................
void BSP_init(void) {
    int n;

    GUI_Init(); // initialize the embedded GUI

    n = SIM_HARDKEY_GetNum();
    for (n = n - 1; n >= 0; --n) {
        SIM_HARDKEY_SetCallback(n, &simHardKey);
    }

    QF_setTickRate(BSP_TICKS_PER_SEC, 30); // set the desired tick rate

#ifdef Q_SPY
    {
        HANDLE hIdle;
        char const *hostAndPort = SIM_GetCmdLine();
        if (hostAndPort != NULL) { // port specified?
            hostAndPort = "localhost:6601";
        }
        if (!QS_INIT(hostAndPort)) {
            MessageBox(NULL, "Failed to open the TCP/IP socket for QS output",
                       "QS Socket Failure", MB_TASKMODAL | MB_OK);
            return;
        }
        hIdle = CreateThread(NULL, 1024, &idleThread, (void *)0, 0, NULL);
        Q_ASSERT(hIdle != (HANDLE)0); // thread must be created
        SetThreadPriority(hIdle, THREAD_PRIORITY_IDLE);
    }
#endif
}
/*..........................................................................*/
void BSP_init(void) {

    /* Set up system clocks, see manual 8.2.1
    * 12MHz clock
    * I Clk   = 96 MHz
    * B Clk   = 24 MHz
    * P Clock = 48 MHz
    */
    SYSTEM.SCKCR.LONG = ((0UL << 24) | (2UL << 16) | (1UL << 8));

    /* init LEDs (GPIOs and LED states to OFF) */
    PORTD.DDR.BYTE  = 0xFF;
    PORTE.DDR.BYTE |= 0x0F;
    PORTD.DR.BYTE   = 0xFF;             /* initialize all LEDs to OFF state */
    PORTE.DR.BYTE  |= 0x0F;             /* initialize all LEDs to OFF state */

    /* Init buttons as GPIO inputs
    * Config GPIO Port 4 as input for reading buttons
    * Not needed after POR because this is the default value...
    */
    PORT4.DDR.BYTE = 0;

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&QS_Excep_CMTU0_CMT0);
    QS_OBJ_DICTIONARY(&QS_Excep_IRQ8);
    QS_OBJ_DICTIONARY(&QS_Excep_IRQ9);
    QS_OBJ_DICTIONARY(&QS_Excep_IRQ10);
}
示例#14
0
文件: bsp.cpp 项目: dgu123/qpcpp
//............................................................................
void BSP_init(void) {
    Q_ALLEGE(QS_INIT((char *)0));
    QS_RESET();
    QS_OBJ_DICTIONARY(&l_time_tick);
    QS_USR_DICTIONARY(PHILO_STAT);

    BSP_randomSeed(1234U);
}
/*..........................................................................*/
void BSP_init(void) {
    uint16_t volatile delay;
                                                 /* initialize the clock... */

    prc0 = 1;                   /* allow writing to clock control registers */
    cm07 = 0;    /* clock selected by cm21 in CM2 (oscillation stop detect) */
    cm21 = 0;    /* clock selected by cm17 in CM1 (system clock select reg) */
    cm17 = 0;                                 /* clock source is main clock */
    mcd  = 0x12;                      /* set divide for BCLK to divide by 1 */

                               /* configure and switch main clock to PLL... */
    /* set PLL to multiply by 6 and divide by 2 giving 30MHz when writing PLL
    * control registers write to both plc0 and plc1 (addresses 0026 and 0027)
    * using a word write command. Set divide ratio with the PLL off
    */
    *(uint16_t *)&plc0 = 0x0253;
    _asm("nop");
    *(uint16_t *)&plc0 = 0x02D3;                         /* turn the PLL on */
    for (delay = 0; delay < 0x4000; ++delay) {          /* delay for 20msec */
    }
    cm17 = 1;                         /*  make the PLL the CPU clock source */
    prc0 = 0;                            /* protect clock control registers */


    pd6 |= 0x0F;   /* port 6 is used by E8 do not modify upper half of port */

                                                  /* enable the User Button */
    SW1_DDR = 0;

                                               /* LED port configuration... */
    LED0_DDR = 1;
    LED1_DDR = 1;
    LED2_DDR = 1;
    LED3_DDR = 1;
    LED0     = LED_OFF;
    LED1     = LED_OFF;
    LED2     = LED_OFF;
    LED3     = LED_OFF;

    /* start the 32kHz crystal subclock (remove if 32kHz clock not used)... */
    prc0  = 1;    /* unlock CM0 and CM1 and set GPIO to inputs (XCin/XCout) */
    pd8_7 = 0;
    pd8_6 = 0;
    cm04  = 1;                                   /* start the 32kHz crystal */

                                      /* setup Timer A running from fc32... */
    ta0mr = 0xC0;                      /* Timer mode, fc32, no pulse output */
    ta0   = (int)((fc_CLK_SPEED/32 + BSP_TICKS_PER_SEC/2)
                  / BSP_TICKS_PER_SEC) - 1;                       /* period */
    ta0ic = TICK_ISR_PRIO;   /* set the clock tick interrupt priority level */

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }
}
/*..........................................................................*/
void BSP_init(void) {
    DDRD  = 0xFF;                    /* All PORTD pins are outputs for LEDs */
    LED_OFF_ALL();                                     /* trun off all LEDs */

                                            /* set the output compare value */
    OCR0A  = ((F_CPU / BSP_TICKS_PER_SEC / 1024) - 1);

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }
}
示例#17
0
文件: bsp.cpp 项目: alisonjoe/qpcpp
//............................................................................
void BSP_init(void) {
    Q_ALLEGE(QS_INIT((char *)0));
    QS_RESET();
    QS_OBJ_DICTIONARY(&l_time_tick);
    QS_USR_DICTIONARY(PHILO_STAT);

    l_stdOutStream << "DPP-Qt console example" << endl
                   << "QP " << QP::QF::getVersion() << endl;

    BSP_randomSeed(1234U);
}
/*--------------------------------------------------------------------------*/
void BSP_init(void) {
    RCONbits.SWDTEN = 0;                                /* disable Watchdog */

    TRISA = 0x00;                                /* set LED pins as outputs */
    PORTA = 0x00;                               /* set LEDs drive state low */

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_T2Interrupt);
}
示例#19
0
文件: bsp.c 项目: michaeltandy/qpc
/*..........................................................................*/
void BSP_init(void) {
    if (QS_INIT(l_cmdLine) == (uint8_t)0) { /* QS initialization failed? */
        MessageBox(l_hWnd,
                   "Cannot connect to QSPY via TCP/IP\n"
                   "Please make sure that 'qspy -t' is running",
                   "QS_INIT() Error",
                   MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
    }
    QS_OBJ_DICTIONARY(&l_clock_tick);
    QS_USR_DICTIONARY(PLAYER_TRIGGER);
    QS_USR_DICTIONARY(COMMAND_STAT);
}
示例#20
0
//............................................................................
void BSP_init(void) {
    SystemInit();                            // initialize the clocking system

    GPIOInit();                             // initialize GPIO (sets up clock)
    GPIOSetDir(LED_PORT, LED_BIT, 1);            // set port for LED to output

    if (QS_INIT((void *)0) == 0) {       // initialize the QS software tracing
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_GPIOPortA_IRQHandler);
}
/*..........................................................................*/
void BSP_init(void) {
    SystemInit();                         /* initialize the clocking system */

    GPIOInit();                          /* initialize GPIO (sets up clock) */
    GPIOSetDir(LED_PORT, LED_BIT, 1);         /* set port for LED to output */

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }

    QS_RESET();
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_PIOINT0_IRQHandler);
}
示例#22
0
/*..........................................................................*/
void BSP_init(void) {

    printf("Dining Philosopher Problem example"
           "\nQEP %s\nQF  %s\n"
           "Press 'p' to pause/un-pause\n"
           "Press ESC to quit...\n",
           QEP_getVersion(),
           QF_getVersion());

    BSP_randomSeed(1234U);
    Q_ALLEGE(QS_INIT((void *)0));
    QS_OBJ_DICTIONARY(&l_clock_tick);   /* must be called *after* QF_init() */
    QS_USR_DICTIONARY(PHILO_STAT);
}
示例#23
0
/* BSP functions ===========================================================*/
void BSP_init(void) {
    /* setup the port for the LED (PORTB.5) */
    DDRB   =  0xFFU;    /* set all pins on PORTB as output */
    PORTB &= ~LED_L;    /* drive LED_L pin low */

    /* setup the port for the Button (PORTD.2) */
    DDRD  &= ~BTN_EXT;  /* set PORTD pin BTN_EXT as input */

    if (QS_INIT((void *)0) == 0) { /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_ISR_TIMER2_COMPA);
    QS_USR_DICTIONARY(PHILO_STAT);
}
示例#24
0
文件: bsp.c 项目: KnightSch/qpc
/*..........................................................................*/
void BSP_init(int argc, char *argv[]) {

    printf("Dining Philosophers Problem example"
           "\nQP %s\n"
           "Press 'p' to pause\n"
           "Press 's' to serve\n"
           "Press ESC to quit...\n",
           QP_versionStr);

    BSP_randomSeed(1234U);

    Q_ALLEGE(QS_INIT((void *)0));
    QS_OBJ_DICTIONARY(&l_clock_tick); /* must be called *after* QF_init() */
    QS_USR_DICTIONARY(PHILO_STAT);
}
示例#25
0
/*..........................................................................*/
void BSP_init(void) {
    /* NOTE: SystemInit() already called from startup_TM4C123GH6PM.s
    *  but SystemCoreClock needs to be updated
    */
    SystemCoreClockUpdate();

    SYSCTL->RCGC2 |= (1 << 5); /* enable clock to GPIOF (User and Eth LEDs)*/
    __NOP();
    __NOP();

    /* configure the pin driving the Ethernet LED */
    GPIOF->DIR   &= ~(ETH0_LED | ETH1_LED); /* set direction: hardware */
    GPIOF->AFSEL |=  (ETH0_LED | ETH1_LED);
    GPIOF->DR2R  |=  (ETH0_LED | ETH1_LED);
    GPIOF->ODR   &= ~(ETH0_LED | ETH1_LED);
    GPIOF->PUR   |=  (ETH0_LED | ETH1_LED);
    GPIOF->PDR   &= ~(ETH0_LED | ETH1_LED);
    GPIOF->DEN   |=  (ETH0_LED | ETH1_LED);
    GPIOF->AMSEL &= ~(ETH0_LED | ETH1_LED);

    /* configure the pin driving the User LED */
    GPIOF->DIR   |=  USER_LED;  /* set direction: output */
    GPIOF->DR2R  |=  USER_LED;
    GPIOF->DEN   |=  USER_LED;
    GPIOF->AMSEL &= ~USER_LED;
    GPIOF->DATA_Bits[USER_LED] = 0; /* turn the LED off */

    /* configure the pin connected to the Buttons */
    GPIOF->DIR   &= ~USER_BTN;  /* set direction: input */
    GPIOF->DR2R  |=  USER_BTN;
    GPIOF->ODR   &= ~USER_BTN;
    GPIOF->PUR   |=  USER_BTN;
    GPIOF->PDR   &= ~USER_BTN;
    GPIOF->DEN   |=  USER_BTN;
    GPIOF->AMSEL &= ~USER_BTN;

    /* NOTE:
    * The OLED display is encapsulated inside the Table AO, so the
    * initialization of the OLED display happens in the top-most initial
    * transition of the Table AO (see Table_displayInit()).
    */

    if (QS_INIT((void *)0) == 0) {  /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
}
/*..........................................................................*/
void BSP_init(void) {
    WDTCTL   = (WDTPW | WDTHOLD);                               /* Stop WDT */

    /* configure the Basic Clock Module */
    DCOCTL   = CALDCO_8MHZ;                              /* Set DCO to 8MHz */
    BCSCTL1  = CALBC1_8MHZ;

    TACTL    = (ID_3 | TASSEL_2 | MC_1);       /* SMCLK, /8 divider, upmode */
    TACCR0   = (((BSP_SMCLK / 8) + BSP_TICKS_PER_SEC/2) / BSP_TICKS_PER_SEC);

    P1DIR   |= (BIT0 | BIT1);               /* P1.0 and P1.1 outputs (LEDs) */

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&l_timerA_ISR);
}
示例#27
0
//............................................................................
void BSP_init(int argc, char *argv[]) {
    char const *com = "COM1";

    com = com;                     // avoid compiler warning if QS is not used

    if (argc > 1) {
        com = argv[1];
    }
    if (!QS_INIT(com)) {                                      // initialize QS
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&l_tmr);
    QS_OBJ_DICTIONARY(&l_kbd);

    Video::clearScreen(Video::BGND_LIGHT_GRAY);
    Video::clearRect( 0,  0, 80,   1, Video::BGND_RED | Video::BGND_BLINK);
    Video::clearRect( 0,  8, 80,  24, Video::BGND_BLACK | Video::FGND_WHITE);
    Video::clearRect( 0,  7, 80,   8, Video::BGND_BLUE);
    Video::clearRect( 0, 24, 80,  25, Video::BGND_BLUE);

    Video::clearRect(24, 24, 28,  25, Video::BGND_RED | Video::BGND_BLINK);
    Video::clearRect(24, 24, 28,  25, Video::BGND_RED | Video::BGND_BLINK);

    Video::printStrAt(35,  0, Video::FGND_WHITE, "FLY 'n' SHOOT");
    Video::printStrAt(15,  2, Video::FGND_BLACK,
                     "Press UP-arrow   to move the space ship up");
    Video::printStrAt(15,  3, Video::FGND_BLACK,
                     "Press DOWN-arrow to move the space ship down");
    Video::printStrAt(15,  4, Video::FGND_BLACK,
                     "Press SPACE      to fire the missile");
    Video::printStrAt(15,  5, Video::FGND_BLACK,
                     "Press ESC        to quit the game");
    Video::printStrAt( 8, 24, Video::FGND_WHITE, "Ship Position:");
    Video::printStrAt(37, 24, Video::FGND_WHITE, "Triggers:");
    Video::printStrAt(61, 24, Video::FGND_WHITE, "Score:");

    Video::clearRect(24, 24, 28,  25, Video::BGND_RED);
    Video::clearRect(47, 24, 51,  25, Video::BGND_RED);
    Video::clearRect(68, 24, 72,  25, Video::BGND_RED);
    Video::printNumAt(24, 24, Video::FGND_YELLOW, 0);
    Video::printNumAt(47, 24, Video::FGND_YELLOW, 0);
    Video::printNumAt(68, 24, Video::FGND_YELLOW, 0);
}
示例#28
0
/* BSP functions ===========================================================*/
void BSP_init(void) {
    uint32_t i;

    /* When using the JTAG debugger the AIC might not be initialised
    * to the correct default state. This line ensures that AIC does not
    * mask all interrupts at the start.
    */
    AT91C_BASE_AIC->AIC_EOICR = 0U;

    /* enable peripheral clock for PIOA */
    AT91C_BASE_PMC->PMC_PCER = (1U << AT91C_ID_PIOA);

    /* initialize the LEDs... */
    for (i = 0; i < Q_DIM(l_led); ++i) {
        AT91C_BASE_PIOA->PIO_PER = l_led[i];  /* enable pin */
        AT91C_BASE_PIOA->PIO_OER = l_led[i];  /* configure as output pin */
        LED_OFF(i);                           /* extinguish the LED */
    }

    /* initialize the Buttons... */
    for (i = 0; i < Q_DIM(l_btn); ++i) {
        AT91C_BASE_PIOA->PIO_ODR = l_btn[i]; /* disable output (input pin) */
        AT91C_BASE_PIOA->PIO_PER = l_btn[i]; /* enable pin */
    }

    /* configure Advanced Interrupt Controller (AIC) of AT91... */
    AT91C_BASE_AIC->AIC_IDCR = ~0;            /* disable all interrupts */
    AT91C_BASE_AIC->AIC_ICCR = ~0;            /* clear all interrupts */
    for (i = 0; i < 8; ++i) {
        AT91C_BASE_AIC->AIC_EOICR = 0;        /* write AIC_EOICR 8 times */
    }

    /* set the desired ticking rate for the PIT... */
    i = (get_MCK_FREQ() / 16U / BSP_TICKS_PER_SEC) - 1U;
    AT91C_BASE_PITC->PITC_PIMR = (AT91C_PITC_PITEN | AT91C_PITC_PITIEN | i);

    BSP_randomSeed(1234U); /* seed the random number generator */

    if (QS_INIT((void *)0) == 0) { /* initialize the QS software tracing */
        Q_ERROR();
    }
    QS_OBJ_DICTIONARY(&l_ISR_tick);
}
/*..........................................................................*/
void BSP_init(void) {
    EXTI_InitTypeDef exti_init;

    SystemInit();         /* initialize STM32 system (clock, PLL and Flash) */

             /* initialize LEDs, Key Button, and LCD on STM3210X-EVAL board */
    STM_EVAL_LEDInit(LED1);
    STM_EVAL_LEDInit(LED2);
    STM_EVAL_LEDInit(LED3);
    STM_EVAL_LEDInit(LED4);

                    /* initialize the EXTI Line0 interrupt used for testing */
    exti_init.EXTI_Mode    = EXTI_Mode_Interrupt;
    exti_init.EXTI_Trigger = EXTI_Trigger_Rising;
    exti_init.EXTI_Line    = EXTI_Line0;
    exti_init.EXTI_LineCmd = ENABLE;
    EXTI_Init(&exti_init);

    STM3210C_LCD_Init();                              /* initialize the LCD */
    LCD_Clear(White);                                      /* clear the LCD */
    LCD_SetBackColor(Grey);
    LCD_SetTextColor(Black);
    LCD_DisplayString(Line0, 0, "   Quantum Leaps    ");
    LCD_DisplayString(Line1, 0, "     DPP example    ");
    LCD_DisplayString(Line2, 0, " QP/C (QK)          ");
    LCD_DisplayString(Line2, 14*16, QF_getVersion());
    LCD_SetBackColor(White);
    LCD_DisplayString(Line5, 0, "DPP:");
    LCD_SetBackColor(Black);
    LCD_SetTextColor(Yellow);
    LCD_DisplayString(Line9, 0, "  state-machine.com ");
    LCD_SetBackColor(Blue);
    LCD_SetTextColor(White);
    LCD_DisplayString(Line5, 4*16, "0 ,1 ,2 ,3 ,4    ");

    if (QS_INIT((void *)0) == 0) {    /* initialize the QS software tracing */
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
}
示例#30
0
文件: bsp.cpp 项目: dongkc/rtu_drv
//............................................................................
void BSP_init(void) {
                                             // Enable the floating-point unit
    SCB->CPACR |= (0xFU << 20);

    // Enable lazy stacking for interrupt handlers. This allows FPU
    // instructions to be used within interrupt handlers, but at the
    // expense of extra stack and CPU usage.
    //
    FPU->FPCCR |= (1U << FPU_FPCCR_ASPEN_Pos) | (1U << FPU_FPCCR_LSPEN_Pos);

    // Set the clocking to run directly from the crystal
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC
                       | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    // enable clock to the peripherals used by the application
    SYSCTL->RCGC2 |= (1U << 5);                       // enable clock to GPIOF
    __NOP();                                     // wait after enabling clocks
    __NOP();
    __NOP();

    // configure the LEDs and push buttons
    GPIOF->DIR |= (LED_RED | LED_GREEN | LED_BLUE);   // set direction: output
    GPIOF->DEN |= (LED_RED | LED_GREEN | LED_BLUE);          // digital enable
    GPIOF->DATA_Bits[LED_RED]   = 0;                       // turn the LED off
    GPIOF->DATA_Bits[LED_GREEN] = 0;                       // turn the LED off
    GPIOF->DATA_Bits[LED_BLUE]  = 0;                       // turn the LED off

    // configure the User Switches
    GPIOF->DIR &= ~(USR_SW1 | USR_SW2);               //  set direction: input
    ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, (USR_SW1 | USR_SW2),
                         GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    BSP_randomSeed(1234U);

    Q_ALLEGE(QS_INIT(static_cast<void *>(0)));
    QS_RESET();
    QS_OBJ_DICTIONARY(&l_SysTick_Handler);
    QS_OBJ_DICTIONARY(&l_GPIOPortA_IRQHandler);
    QS_USR_DICTIONARY(PHILO_STAT);
}