Beispiel #1
0
static void bmk7_execute(void) {
  uint32_t n;

  threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL);
  threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL);
  threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL);
  threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL);
  threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL);

  n = 0;
  test_wait_tick();
  test_start_timer(1000);
  do {
    chSemReset(&sem1, 0);
    n++;
#if defined(SIMULATOR)
    ChkIntSources();
#endif
  } while (!test_timer_done);
  test_terminate_threads();
  chSemReset(&sem1, 0);
  test_wait_threads();

  test_print("--- Score : ");
  test_printn(n);
  test_print(" reschedules/S, ");
  test_printn(n * 6);
  test_println(" ctxswc/S");
}
Beispiel #2
0
static void rt_test_005_001_execute(void) {

  /* [5.1.1] The function chSemWait() is invoked, after return the
     counter and the returned message are tested.*/
  test_set_step(1);
  {
    msg_t msg;

    msg = chSemWait(&sem1);
    test_assert_lock(chSemGetCounterI(&sem1) == 0, "wrong counter value");
    test_assert(MSG_OK == msg, "wrong returned message");
  }

  /* [5.1.2] The function chSemSignal() is invoked, after return the
     counter is tested.*/
  test_set_step(2);
  {
    chSemSignal(&sem1);
    test_assert_lock(chSemGetCounterI(&sem1) == 1, "wrong counter value");
  }

  /* [5.1.3] The function chSemReset() is invoked, after return the
     counter is tested.*/
  test_set_step(3);
  {
    chSemReset(&sem1, 2);
    test_assert_lock(chSemGetCounterI(&sem1) == 2, "wrong counter value");
  }
}
Beispiel #3
0
/**
 * @brief   Deletes a mutex.
 * @note    After deletion there could be references in the system to a
 *          non-existent semaphore.
 */
osStatus osMutexDelete(osMutexId mutex_id) {

  chSemReset((semaphore_t *)mutex_id, 0);
  chPoolFree(&sempool, (void *)mutex_id);

  return osOK;
}
Beispiel #4
0
/**
 * @brief   Deletes a semaphore.
 * @note    After deletion there could be references in the system to a
 *          non-existent semaphore.
 */
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id) {

  chSemReset((semaphore_t *)semaphore_id, 0);
  chPoolFree(&sempool, (void *)semaphore_id);

  return osOK;
}
/** @details
 *  This clears the counter used for tone duration and resets the semaphore
 *  the audio task is blocking on causing it to wake.
 */
void
vexAudioStopSound()
{
    // clear count
    VSL_Counter = 0;
    // stop chip tone
    vexAudioStopChipToneSong();
    // wake audio thread
    chSemReset(&vslSem, 0);
}
void mp45dt02Shutdown(void)
{
    i2sStopExchange(&MP45DT02_I2S_DRIVER);
    i2sStop(&MP45DT02_I2S_DRIVER);

    chThdTerminate(pMp45dt02ProcessingThd);
    chSemReset(&mp45dt02ProcessingSem, 1);
    chThdWait(pMp45dt02ProcessingThd);
    pMp45dt02ProcessingThd = NULL;
}
void
vexAudioPlaySound( int freq, int amplitude, int timems )
{
    static int current_amplitude = DEFAULT_AMPLITUDE;
    int f1, f2;

    // Not available on the Olimex eval card
#if defined (STM32F10X_HD)

    // init first time
    if( vslThread == NULL )
        {
        VSL_Init();
        // init counting semaphore with a value of 0
        chSemInit( &vslSem, 0 );
        vslThread = chThdCreateFromHeap(NULL, AUDIO_WA_SIZE, NORMALPRIO, vexAudioTask, (void *)NULL );
        }

    // try and stop pops
    // a frequency of 0 means silence
    if( freq == 0 )
        {
        freq = 1000;
        amplitude = 0;
        }

    // create waveform
    if( amplitude != current_amplitude )
        {
        VSL_CreateSineWave( amplitude );
        current_amplitude = amplitude;
        }

    // limit range of frequencies 200Hz to 10KHz
    if( freq <   200 ) freq =   200;
    if( freq > 10000 ) freq = 10000;
    
    // calculate prescale and period for the timer
    VSL_Factorize( 72000000L / (32 * freq), &f1, &f2 );

    // ReInit timer
    VSL_InitTimer(f1, f2);

    // Enable DMA for the DAC
    DAC->CR |= (DAC_CR_EN1 << DAC_Channel_1);
    
    /* TIM7 enable counter */
    TIM7->CR1 |= TIM_CR1_CEN;

    // stop after time
    VSL_Counter = timems;
    // this will wake audio thread if necessary
    chSemReset(&vslSem, 0);
#endif
}
Beispiel #8
0
void Lcd_t::Shutdown(void) {
#if LCD_DMA_BASED
    dmaStreamDisable(LCD_DMA);
#endif
    XRES_Lo();
    XCS_Lo();
    SCLK_Lo();
    SDA_Lo();
    Backlight(0);
    chSemReset(&semLcd, 1);
}
Beispiel #9
0
static void rt_test_005_001_teardown(void) {
  chSemReset(&sem1, 0);
}
static void test_002_003_teardown(void) {

  chSemReset(&sem1, 0);
}
Beispiel #11
0
void CounterSemaphore::reset(cnt_t n) {

    chSemReset(&sem, n);
}
  void Semaphore::Reset(cnt_t n) {

    chSemReset(&sem, n);
  }
Beispiel #13
0
void gfxSemDestroy(gfxSem *psem) {
	chSemReset(&psem->sem, 1);
}
inline
void Semaphore_::reset(Count value) {

  chSemReset(&impl, value);
}
Beispiel #15
0
/*------------------------------------------------------------------------*/
int ff_del_syncobj(_SYNC_t sobj) {

    chSemReset(sobj, 0);
    return TRUE;
}