本文整理汇总了C++中osSignalWait函数的典型用法代码示例。如果您正苦于以下问题:C++ osSignalWait函数的具体用法?C++ osSignalWait怎么用?C++ osSignalWait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osSignalWait函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: temperature_DispFlag_thread
/*!
@brief Thread to display temperature
@param argument Unused
*/
void temperature_DispFlag_thread(void const * argument)
{
// Extracts the semaphore object from the argument.
// This semaphore object was created in the main
osSemaphoreId* semaphore;
semaphore = (osSemaphoreId*)argument;
uint8_t ResourceLocked = 1; // Flag gets turned on if semaphore_lock achieved
uint32_t tokentemp; // Return of semwait
// Wait for the semaphore with 1ms timeout
osEvent event = osSignalWait(SIGNAL_DISP_TEMPERATURE, 1);
while(1)
{
tokentemp=osSemaphoreWait (*semaphore, osWaitForever);
ResourceLocked=1; // turn flag on if resource_locked
while (ResourceLocked)
{
// wait for a signal with 1ms timeout
event = osSignalWait(SIGNAL_DISP_TEMPERATURE, 1);
if (event.status == osEventTimeout)
{
// in case of timeout display
LCD_DisplayTemperature(temp);
}
else
{
// signal received which is not timeout
// clear the signal flag for the tilt display thread
osSignalClear (tilt_TurnDispFlag_thread, SIGNAL_DISP_TILT);
//clear the screen
LCD_clear_display();
// turn the resource_locked flag off
ResourceLocked = 0;
tokentemp=0;
// turn the flag to display the string "temperature" once
GLB_Temperature_display_flag=1;
// release the semaphore
osSemaphoreRelease(*semaphore);
//wait 5ms for the other thread to grab the semaphore
osDelay(5);
}
}
}
}
示例2: blinkLED
void blinkLED(void const *argument) {
while (1) {
__GPIO_WRITE(GPIOA, 5, GPIO_PIN_SET);
osSignalWait(0x0001, osWaitForever);
__GPIO_WRITE(GPIOA, 5, GPIO_PIN_RESET);
osSignalWait(0x0001, osWaitForever);
//sprintf(Buf, "%x\r\n", serbuff);
//HAL_UART_Transmit(&huart2, (uint8_t *) Buf, strlen(Buf), 0xffffffff);
}
}
示例3: Thread_ACCELEROMETER
/*----------------------------------------------------------------------------
* Thread 'Accelerometer': Reads Accelerometer
*---------------------------------------------------------------------------*/
void Thread_ACCELEROMETER (void const *argument)
{
/* These are preserved between function calls (static) */
KalmanState kstate_pitch = {0.001, 0.0032, 0.0, 0.0, 0.0}; /* Filter parameters obtained by experiment and variance calculations */
KalmanState kstate_roll = {0.001, 0.0032, 0.0, 0.0, 0.0}; /* Filter parameters obtained by experiment and variance calculations */
float ax, ay, az;
float roll, pitch;
osTimerId doubletap_timer_id, accel_dataready_timer_id;
doubletap_timer_id = osTimerCreate(osTimer(doubletap_timer), osTimerOnce, NULL);
accel_dataready_timer_id = osTimerCreate(osTimer(accel_dataready_timer), osTimerOnce, NULL);
while(1)
{
/* Wait for accelerometer new data signal or Nucleo board SPI signal for read request.
No need to send data all the time. */
osSignalWait(ACCELEROMETER_SIGNAL, osWaitForever);
Accelerometer_ReadAccel(&ax, &ay, &az);
Accelerometer_Calibrate(&ax, &ay, &az);
Accelerometer_GetRollPitch(ax, ay, az, &pitch, &roll);
Kalmanfilter_asm(&pitch, &filtered_pitch, 1, &kstate_pitch); /* filter the pitch angle */
Kalmanfilter_asm(&roll, &filtered_roll, 1, &kstate_roll); /* filter the roll angle */
if (Accelerometer_DetectDoubletap(sqrtf(ax * ax + ay * ay + az * az)))
NucleoSPI_SetDoubletap(doubletap_timer_id, DOUBLETAP_TIMEOUT_MS);
NucleoSPI_SetAccelDataready(accel_dataready_timer_id, ACCEL_DATAREADY_TIMEOUT_MS);
}
}
示例4: main
/*----------------------------------------------------------------------------
* Main: Initialise and start RTX Kernel
*---------------------------------------------------------------------------*/
int main(void) {
// Get main thread ID
mainFunctionId = osThreadGetId();
// Create thread
threadFunctionId = osThreadCreate(osThread(threadFunction), NULL);
if (threadFunctionId == NULL) {
__asm__("bkpt");
}
// Need suitable features for the stdio & leds
// printf("Main thread ID = %d\n", (int)mainFunctionId);
// printf("Thread ID = %d\n", (int)threadFunctionId);
// led_initialise();
for (;;) {
// Wait for signal from thread
osSignalWait(SIGNAL_MASK, osWaitForever);
// printf("Thread signaled\n");
// greenLedToggle();
}
}
示例5: Thread_SEGMENT
/*----------------------------------------------------------------------------
* Thread 'SEGMENT': Display values on 7-segment display
*---------------------------------------------------------------------------*/
void Thread_SEGMENT (void const *argument)
{
int counter = 0;
DisplayMode mode;
while(1)
{
osSignalWait(SEGMENT_SIGNAL, osWaitForever);
if (counter % FLASH_PERIOD == 0)
{
if (SevenSegment_GetFlashing()) {
osMutexWait(segment_mutex, osWaitForever);
activated = !activated;
osMutexRelease(segment_mutex);
}
}
mode = SevenSegment_GetDisplayMode();
if (mode == TEMP_MODE) {
SevenSegment_ToggleDisplayedDigit_Angle();
} else if (mode == ANGLE_MODE) {
SevenSegment_ToggleDisplayedDigit_Temp();
}
counter++;
}
}
示例6: ledOff
/*----------------------------------------------------------------------------
Task 2 'ledOff': switches the LED off
*---------------------------------------------------------------------------*/
void ledOff (void const *argument) {
for (;;) {
osSignalWait (0x0001, osWaitForever); /* wait for an event flag 0x0001 */
osDelay(800); /* delay 800ms */
LED_Off(0); /* Turn LED Off */
}
}
示例7: Thread_ADC
/**
* @brief Main loop for the adc
* @param None
* @retval None
*/
void Thread_ADC (void const *argument) {
while(1){
osSignalWait (ADC_FLAG,osWaitForever);
osSignalClear(tid_Thread_ADC,ADC_FLAG);
poll();
}
}
示例8: TC_MutexTimeout
/**
\brief Test case: TC_MutexTimeout
\details
- Create and initialize a mutex object
- Create a thread that acquires a mutex but never release it
- Wait for mutex release until timeout
*/
void TC_MutexTimeout (void) {
osThreadId ctrl_id, lock_id;
osEvent evt;
/* Get control thread id */
ctrl_id = osThreadGetId ();
ASSERT_TRUE (ctrl_id != NULL);
if (ctrl_id != NULL) {
/* - Create and initialize a mutex object */
G_MutexId = osMutexCreate (osMutex (MutexTout));
ASSERT_TRUE (G_MutexId != NULL);
if (G_MutexId != NULL) {
/* - Create a thread that acquires a mutex but never release it */
lock_id = osThreadCreate (osThread (Th_MutexLock), &ctrl_id);
ASSERT_TRUE (lock_id != NULL);
if (lock_id != NULL) {
/* - Wait for mutex release until timeout */
ASSERT_TRUE (osMutexWait (G_MutexId, 10) == osErrorTimeoutResource);
/* - Release a mutex */
osSignalSet (lock_id, 0x01);
evt = osSignalWait (0x01, 100);
ASSERT_TRUE (evt.status == osEventSignal);
/* - Terminate locking thread */
ASSERT_TRUE (osThreadTerminate (lock_id) == osOK);
}
/* Delete mutex object */
ASSERT_TRUE (osMutexDelete (G_MutexId) == osOK);
}
}
}
示例9: lights
/*----------------------------------------------------------------------------
Thread 3 'lights': executes if current time is between start & end time
*---------------------------------------------------------------------------*/
void lights (void const *argument) { /* traffic light operation */
SetLights (RED, 1); /* RED & STOP lights on */
SetLights (STOP, 1);
SetLights (YELLOW, 0);
SetLights (GREEN, 0);
SetLights (WALK, 0);
while (1) { /* endless loop */
osDelay(500); /* wait for timeout: 500ms */
if (!signalon ()) { /* if traffic signal time over */
tid_blinking = osThreadCreate(osThread(blinking), NULL);
/* start blinking */
return; /* STOP lights */
}
SetLights (YELLOW, 1);
osDelay(500); /* wait for timeout: 500ms */
SetLights (RED, 0); /* GREEN light for cars */
SetLights (YELLOW, 0);
SetLights (GREEN, 1);
osSignalClear(tid_lights, 0x0010);
osDelay(500); /* wait for timeout: 500ms */
osSignalWait(0x0010, 7500); /* wait for event with timeout */
SetLights (YELLOW, 1); /* timeout value: 7.5s */
SetLights (GREEN, 0);
osDelay(500); /* wait for timeout: 500ms */
SetLights (RED, 1); /* RED light for cars */
SetLights (YELLOW, 0);
osDelay(500); /* wait for timeout: 500ms */
SetLights (STOP, 0); /* GREEN light for WALKers */
SetLights (WALK, 1);
osDelay(2500); /* wait for timeout: 2.5s */
SetLights (STOP, 1); /* RED light for WALKers */
SetLights (WALK, 0);
}
}
示例10: oModeTransThread
void oModeTransThread(void const *args)
{
while (1)
{
osSignalWait(SIG_START, osWaitForever);
send_block_angles(totalNum, _rolls, _pitches, _deltas);
}
}
开发者ID:headyin,项目名称:Wireless-Board-Orientation-Control-System-ARM-Micro-Processor-Lab-,代码行数:8,代码来源:oModeTrans.c
示例11: Keypad
/*!
Get pressed key after keypad interrupt occurs
*/
void Keypad(void const *argument){
while (1){
//wait until called
osSignalWait(SIGNAL_KEYPAD, osWaitForever);
get_press();
osDelay(150);
}
}
示例12: clock
/*----------------------------------------------------------------------------
Thread 5 'clock': Signal Clock
*---------------------------------------------------------------------------*/
void clock (void const *argument) {
for (;;) {
osSignalWait(0x0100, osWaitForever); /* wait for an event flag 0x0100 */
LED_on (LED_CLK);
osDelay(80); /* delay 80ms */
LED_off(LED_CLK);
}
}
示例13: blinkLED
/*----------------------------------------------------------------------------
* blinkLED: blink LED and check button state
*----------------------------------------------------------------------------*/
void blinkLED(void const *argument) {
int32_t max_num = LED_GetCount();
int32_t num = 0;
for (;;) {
LED_On(num); // Turn specified LED on
osSignalWait(0x0001, osWaitForever);
LED_Off(num); // Turn specified LED off
osSignalWait(0x0001, osWaitForever);
num++; // Change LED number
if (num >= max_num) {
num = 0; // Restart with first LED
}
}
}
示例14: phaseA
/*----------------------------------------------------------------------------
Thread 1 'phaseA': Phase A output
*---------------------------------------------------------------------------*/
void phaseA (void const *argument) {
for (;;) {
osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */
LED_on (LED_A);
signal_func (tid_phaseB); /* call common signal function */
LED_off(LED_A);
}
}
示例15: phaseD
/*----------------------------------------------------------------------------
* Thread 4 'phaseD': Phase D output
*---------------------------------------------------------------------------*/
void phaseD (void const *argument) {
for (;;) {
osSignalWait(0x0001, osWaitForever); /* wait for an event flag 0x0001 */
Switch_On (LED_D);
signal_func(tid_phaseA); /* call common signal function */
Switch_Off(LED_D);
}
}