int pfq_egress_bind(pfq_t *q, const char *dev, int queue) { struct pfq_binding b; int index; if (strcmp(dev, "any")==0) { index = Q_ANY_DEVICE; } else { index = pfq_ifindex(q, dev); if (index == -1) { return Q_ERROR(q, "PFQ: egress_bind: device not found"); } } b.gid = 0; b.if_index = index; b.hw_queue = queue; if (setsockopt(q->fd, PF_Q, Q_SO_EGRESS_BIND, &b, sizeof(b)) == -1) return Q_ERROR(q, "PFQ: egress bind error"); return Q_OK(q); }
int pfq_unbind_group(pfq_t *q, int gid, const char *dev, int queue) /* Q_ANY_QUEUE */ { struct pfq_binding b; int index; if (strcmp(dev, "any")==0) { index = Q_ANY_DEVICE; } else { index = pfq_ifindex(q, dev); if (index == -1) { return Q_ERROR(q, "PFQ: unbind_group: device not found"); } } b.gid = gid; b.if_index = index; b.hw_queue = queue; if (setsockopt(q->fd, PF_Q, Q_SO_GROUP_UNBIND, &b, sizeof(b)) == -1) { return Q_ERROR(q, "PFQ: unbind error"); } return Q_OK(q); }
int pfq_disable(pfq_t *q) { if (q->fd == -1) return Q_ERROR(q, "PFQ: socket not open"); if (q->shm_addr != MAP_FAILED) { if (munmap(q->shm_addr,q->shm_size) == -1) return Q_ERROR(q, "PFQ: munmap error"); if (q->hd != -1) { char filename[64]; snprintf(filename, 64, "/dev/hugepages/pfq.%d", q->fd); unlink(filename); } } q->shm_addr = NULL; q->shm_size = 0; if(setsockopt(q->fd, PF_Q, Q_SO_DISABLE, NULL, 0) == -1) { return Q_ERROR(q, "PFQ: socket disable"); } return Q_OK(q); }
int main(void) { uint16_t status; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer LED_init(); LED_on(); /* configure the Basic Clock Module */ DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; BCSCTL2 = SELM_3 + DIVM_0;//MCLK = LFXTCLK/1 #ifdef NECESSARY do { int i; IFG1 &= ~OFIFG; // Clear OSCFault flag for (i = 0xFF; i > 0; i--); // Time for flag to set } while ((IFG1 & OFIFG)); // OSCFault flag still set? #endif TACTL = TASSEL_2 | MC_1; /* SMCLK, upmode */ TACCR0 = TIMER_CLK_HZ/SYSTICK_HZ; TACCTL0 = CCIE; /*Enable timer A0 interrupt*/ //Enable SCLK, SDI, SDO, master USICTL0 |= USIPE7 | USIPE6 | USIPE5 | USIMST | USIOE; USICKCTL |= USIDIV_0 //this actually means divide by 1 | USISSEL_2//Use SMCLK to drive the SPI clk //| USICKPL ; USICTL1 |= USICKPH;//delay? //USICTL1 |= USIIE;//interrupt enable // ; P1OUT = BIT4;//Pull up nCS at first P1DIR |= BIT4;//nCS is P1.4 //P1REN |= 0x10;? _enable_interrupts();//vs. _BIS_SR(LPM0_bits + GIE); LED_off(); dSPIN_Soft_Stop(); dSPIN_Reset_Device(); status = dSPIN_Get_Status(); if(status & dSPIN_STATUS_SW_EVN || (status & dSPIN_STATUS_MOT_STATUS) != dSPIN_STATUS_MOT_STATUS_STOPPED || status & dSPIN_STATUS_NOTPERF_CMD || status & dSPIN_STATUS_WRONG_CMD // !(status & dSPIN_STATUS_UVLO) || !(status & dSPIN_STATUS_TH_SD) || !(status & dSPIN_STATUS_OCD)) Q_ERROR(); if(dSPIN_Busy_HW()) Q_ERROR(); return 0; }
int pfq_enable(pfq_t *q) { size_t tot_mem; socklen_t size = sizeof(tot_mem); char filename[64]; if (q->shm_addr != MAP_FAILED && q->shm_addr != NULL) { return Q_ERROR(q, "PFQ: queue already enabled"); } if (getsockopt(q->fd, PF_Q, Q_SO_GET_SHMEM_SIZE, &tot_mem, &size) == -1) { return Q_ERROR(q, "PFQ: queue memory error"); } snprintf(filename, 64, "/dev/hugepages/pfq.%d", q->fd); q->hd = open(filename, O_CREAT | O_RDWR, 0755); if (q->hd != -1) q->shm_addr = mmap(NULL, tot_mem, PROT_READ|PROT_WRITE, MAP_SHARED, q->hd, 0); if (q->shm_addr != MAP_FAILED && q->shm_addr != NULL) { if(setsockopt(q->fd, PF_Q, Q_SO_ENABLE, &q->shm_addr, sizeof(q->shm_addr)) == -1) { return Q_ERROR(q, "PFQ: socket enable (hugepages)"); } } else { void * null = NULL; if(setsockopt(q->fd, PF_Q, Q_SO_ENABLE, &null, sizeof(null)) == -1) { return Q_ERROR(q, "PFQ: socket enable"); } q->shm_addr = mmap(NULL, tot_mem, PROT_READ|PROT_WRITE, MAP_SHARED, q->fd, 0); } if (q->shm_addr == MAP_FAILED || q->shm_addr == NULL) { return Q_ERROR(q, "PFQ: socket enable (memory map)"); } q->shm_size = tot_mem; q->rx_queue_addr = (char *)(q->shm_addr) + sizeof(struct pfq_shared_queue); q->rx_queue_size = q->rx_slots * q->rx_slot_size; q->tx_queue_addr = (char *)(q->shm_addr) + sizeof(struct pfq_shared_queue) + q->rx_queue_size * 2; q->tx_queue_size = q->tx_slots * q->tx_slot_size; return Q_OK(q); }
int pfq_set_tx_slots(pfq_t *q, size_t value) { int enabled = pfq_is_enabled(q); if (enabled == 1) { return Q_ERROR(q, "PFQ: enabled (Tx slots could not be set)"); } if (setsockopt(q->fd, PF_Q, Q_SO_SET_TX_SLOTS, &value, sizeof(value)) == -1) { return Q_ERROR(q, "PFQ: set Tx slots error"); } q->tx_slots = value; return Q_OK(q); }
int pfq_set_caplen(pfq_t *q, size_t value) { int enabled = pfq_is_enabled(q); if (enabled == 1) { return Q_ERROR(q, "PFQ: enabled (caplen could not be set)"); } if (setsockopt(q->fd, PF_Q, Q_SO_SET_RX_CAPLEN, &value, sizeof(value)) == -1) { return Q_ERROR(q, "PFQ: set caplen error"); } q->rx_slot_size = ALIGN(sizeof(struct pfq_pkthdr) + value, 8); return Q_OK(q); }
/*..........................................................................*/ 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(); } }
/* 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); }
/*${AOs::Philo::SM::hungry} ................................................*/ QState Philo_hungry(Philo * const me) { QState status_; switch (Q_SIG(me)) { /*${AOs::Philo::SM::hungry} */ case Q_ENTRY_SIG: { QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->num); status_ = Q_HANDLED(); break; } /*${AOs::Philo::SM::hungry::EAT} */ case EAT_SIG: { status_ = Q_TRAN(&Philo_eating); break; } /*${AOs::Philo::SM::hungry::DONE} */ case DONE_SIG: { Q_ERROR(); /* this event should never arrive in this state */ status_ = Q_HANDLED(); break; } default: { status_ = Q_SUPER(&QHsm_top); break; } } return status_; }
/*${AOs::Philo::SM::thinking} ..............................................*/ QState Philo_thinking(Philo * const me) { QState status_; switch (Q_SIG(me)) { /*${AOs::Philo::SM::thinking} */ case Q_ENTRY_SIG: { me->tickCtr = THINK_TIME; status_ = Q_HANDLED(); break; } /*${AOs::Philo::SM::thinking} */ case Q_EXIT_SIG: { me->tickCtr = 0U; status_ = Q_HANDLED(); break; } /*${AOs::Philo::SM::thinking::Q_TIMEOUT} */ case Q_TIMEOUT_SIG: { status_ = Q_TRAN(&Philo_hungry); break; } /*${AOs::Philo::SM::thinking::EAT, DONE} */ case EAT_SIG: /* intentionally fall through */ case DONE_SIG: { Q_ERROR(); /* these events should never arrive in this state */ status_ = Q_HANDLED(); break; } default: { status_ = Q_SUPER(&QHsm_top); break; } } return status_; }
/*${AOs::Philo::SM::eating} ................................................*/ QState Philo_eating(Philo * const me) { QState status_; switch (Q_SIG(me)) { /*${AOs::Philo::SM::eating} */ case Q_ENTRY_SIG: { me->tickCtr = EAT_TIME; status_ = Q_HANDLED(); break; } /*${AOs::Philo::SM::eating} */ case Q_EXIT_SIG: { me->tickCtr = 0U; QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->num); status_ = Q_HANDLED(); break; } /*${AOs::Philo::SM::eating::Q_TIMEOUT} */ case Q_TIMEOUT_SIG: { status_ = Q_TRAN(&Philo_thinking); break; } /*${AOs::Philo::SM::eating::EAT, DONE} */ case EAT_SIG: /* intentionally fall through */ case DONE_SIG: { Q_ERROR(); /* these events should never arrive in this state */ status_ = Q_HANDLED(); break; } default: { status_ = Q_SUPER(&QHsm_top); break; } } return status_; }
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(); } }
/* 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/2/3) .............................................................*/ QState Philo_eating(Philo *me, QEvent const *e) { switch (e->sig) { /* @(/2/0/2/3) */ case Q_ENTRY_SIG: { QTimeEvt_postIn(&me->timeEvt, &me->super, EAT_TIME); return Q_HANDLED(); } /* @(/2/0/2/3) */ case Q_EXIT_SIG: { TableEvt *pe = Q_NEW(TableEvt, DONE_SIG); pe->philoNum = PHILO_ID(me); QF_PUBLISH((QEvent const *)pe, me); return Q_HANDLED(); } /* @(/2/0/2/3/0) */ case TIMEOUT_SIG: { BSP_busyDelay(); return Q_TRAN(&Philo_thinking); } /* @(/2/0/2/3/1) */ case TERMINATE_SIG: /* intentionally fall through */ case DONE_SIG: { Q_ERROR(); return Q_HANDLED(); } /* @(/2/0/2/3/2) */ case EAT_SIG: { Q_ASSERT(((TableEvt const *)e)->philoNum != PHILO_ID(me)); return Q_HANDLED(); } } return Q_SUPER(&QHsm_top); }
/*..........................................................................*/ 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(); } }
/* @(/2/0/2/1) .............................................................*/ QState Philo_thinking(Philo *me, QEvent const *e) { switch (e->sig) { /* @(/2/0/2/1) */ case Q_ENTRY_SIG: { QTimeEvt_postIn(&me->timeEvt, &me->super, THINK_TIME); return Q_HANDLED(); } /* @(/2/0/2/1/0) */ case TIMEOUT_SIG: { BSP_busyDelay(); return Q_TRAN(&Philo_hungry); } /* @(/2/0/2/1/1) */ case TERMINATE_SIG: /* intentionally fall through */ case DONE_SIG: { Q_ERROR(); return Q_HANDLED(); } /* @(/2/0/2/1/2) */ case EAT_SIG: { Q_ASSERT(((TableEvt const *)e)->philoNum != PHILO_ID(me)); return Q_HANDLED(); } } return Q_SUPER(&QHsm_top); }
/* @(/2/0/2/2) .............................................................*/ QState Philo_hungry(Philo *me, QEvent const *e) { switch (e->sig) { /* @(/2/0/2/2) */ case Q_ENTRY_SIG: { TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG); pe->philoNum = PHILO_ID(me); QACTIVE_POST(AO_Table, (QEvent const *)pe, me); return Q_HANDLED(); } /* @(/2/0/2/2/0) */ case EAT_SIG: { /* @(/2/0/2/2/0/0) */ if (((TableEvt const *)e)->philoNum == PHILO_ID(me)) { BSP_busyDelay(); return Q_TRAN(&Philo_eating); } break; } /* @(/2/0/2/2/1) */ case TERMINATE_SIG: /* intentionally fall through */ case DONE_SIG: { Q_ERROR(); return Q_HANDLED(); } } return Q_SUPER(&QHsm_top); }
/*..........................................................................*/ 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); }
//............................................................................ 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; }
/*..........................................................................*/ 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); }
/* 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); }
static QState Philo_hungry(Philo * const me) { QState status_; switch (Q_SIG(me)) { /* @(/1/0/0/2/0) */ case EAT_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&Philo_eating_e), Q_ACTION_CAST(0) }; status_ = QM_TRAN(&Philo_eating_s, &act_[0]); break; } /* @(/1/0/0/2/1) */ case DONE_SIG: { Q_ERROR(); /* this event should never arrive in this state */ status_ = QM_HANDLED(); break; } default: { status_ = QM_SUPER(); break; } } return status_; }
static QState Philo_eating(Philo * const me) { QState status_; switch (Q_SIG(me)) { /* @(/1/0/0/3/0) */ case Q_TIMEOUT_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&Philo_eating_x), Q_ACTION_CAST(&Philo_thinking_e), Q_ACTION_CAST(0) }; status_ = QM_TRAN(&Philo_thinking_s, &act_[0]); break; } /* @(/1/0/0/3/1) */ case EAT_SIG: /* intentionally fall through */ case DONE_SIG: { Q_ERROR(); /* these events should never arrive in this state */ status_ = QM_HANDLED(); break; } default: { status_ = QM_SUPER(); break; } } return status_; }
int pfq_set_group_computation_from_string(pfq_t *q, int gid, const char *comp) { int do_set_group_computation(char **fun, int n) { int i = 0, j, ret; struct pfq_computation_descr * prog = malloc(sizeof(size_t) * 2 + sizeof(struct pfq_functional_descr) * n); if (!prog) return Q_ERROR(q, "PFQ: group computation error (no memory)"); prog->entry_point = 0; prog->size = n; for(i = 0; i < n; i++) { prog->fun[i].symbol = trim_string(fun[i]); prog->fun[i].next = i+1; for (j = 0; j < 8; j++) { prog->fun[i].arg[j].addr = NULL; prog->fun[i].arg[j].size = 0; prog->fun[i].arg[j].nelem = 0; } } ret = pfq_set_group_computation(q, gid, prog); free(prog); return ret; }
/**@brief Callback function for handling asserts in the SoftDevice. * * @details This function is called in case of an assert in the SoftDevice. * * @warning This handler is an example only and does not fit a final product. * You must analyze how your product should react to asserts. * @warning On assert from the SoftDevice, the system can recover only on reset. * * @param[in] line_num Line number of the failing ASSERT call. * @param[in] file_name File name of the failing ASSERT call. */ void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) { Q_ERROR(); /**< Value used as error code on stack dump. Can be used to identify * stack location on stack unwind. */ #define DEAD_BEEF 0xDEADBEEF //app_error_handler(DEAD_BEEF, line_num, p_file_name); }
int pfq_egress_unbind(pfq_t *q) { if (setsockopt(q->fd, PF_Q, Q_SO_EGRESS_UNBIND, 0, 0) == -1) return Q_ERROR(q, "PFQ: egress unbind error"); return Q_OK(q); }
int pfq_unbind(pfq_t *q, const char *dev, int queue) { int gid = q->gid; if (gid < 0) { return Q_ERROR(q, "PFQ: default group undefined"); } return pfq_unbind_group(q, gid, dev, queue); }
int pfq_timestamp_enable(pfq_t *q, int value) { int ts = value; if (setsockopt(q->fd, PF_Q, Q_SO_SET_RX_TSTAMP, &ts, sizeof(ts)) == -1) { return Q_ERROR(q, "PFQ: set timestamp mode"); } return Q_OK(q); }