Пример #1
0
/*..........................................................................*/
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);
}
Пример #2
0
/* 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);
}
Пример #3
0
/* 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);
}
Пример #4
0
/* 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);
}
Пример #5
0
/* @(/1/8) .................................................................*/
void Philo_ctor(void) {
    QMActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
    BSP_randomSeed(123U);
}
Пример #6
0
//............................................................................
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);
}
Пример #7
0
/*..........................................................................*/
void BSP_init(void) {
    printf("Dining Philosopher Problem example"
           "\nQP-nano %s\n"
           "Press 'p' to pause\n"
           "Press ESC to quit...\n",
           QP_getVersion());
    BSP_randomSeed(1234U);
}
//............................................................................
Gui::Gui(QWidget *parent)
    : QDialog(parent)
{
    l_instance = this;   // initialize the instance (Singleton)
    setupUi(this);
    setWindowTitle(tr("Dining Philosophers"));

    BSP_randomSeed(123U);
}
Пример #9
0
//............................................................................
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);
}
Пример #10
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);
}
Пример #11
0
/*..........................................................................*/
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);
}
Пример #12
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);
}
Пример #13
0
//............................................................................
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);
}
Пример #14
0
/*..........................................................................*/
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);

    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);
}