void ui_notify_user(notifications_t beep_type) { xTaskNotify(s_notify_task_handle,beep_type,eSetValueWithOverwrite); }
/*------------------------------------------------------------------------------------*/ static void cmdReadFunction(void) { u08 argc; char *p; argc = pv_makeArgv(); // EE // read ee address length if (!strcmp_P( strupr(argv[1]), PSTR("EE\0"))) { pv_cmdRdEE(); return; } // RTC if (!strcmp_P( strupr(argv[1]), PSTR("RTC\0"))) { pv_cmdRdRTC(); return; } // MCP // read mcp 0|1|2 addr if (!strcmp_P( strupr(argv[1]), PSTR("MCP\0"))) { pv_cmdRdMCP(); return; } // DIN // read din 0|1 if (!strcmp_P( strupr(argv[1]), PSTR("DIN\0"))) { pv_cmdRdDIN(); return; } // DEFAULT if (!strcmp_P( strupr(argv[1]), PSTR("DEFAULTS\0"))) { u_loadDefaults(); return; } // FRAME if (!strcmp_P( strupr(argv[1]), PSTR("FRAME\0")) && ( systemVars.wrkMode == WK_SERVICE) ) { while ( xTaskNotify(xHandle_tkRange, TKR_READ_FRAME , eSetBits ) != pdPASS ) { vTaskDelay( ( TickType_t)( 100 / portTICK_RATE_MS ) ); } return; } // MEMORY if (!strcmp_P( strupr(argv[1]), PSTR("MEMORY\0")) && ( systemVars.wrkMode == WK_SERVICE) ) { pv_readMemory(); return; } // GPRS RSP. if (!strcmp_P( strupr(argv[1]), PSTR("GPRS\0"))) { p = FreeRTOS_UART_getFifoPtr(&pdUART0); FreeRTOS_write( &pdUART1, "rx->", sizeof("rx->") ); FreeRTOS_write( &pdUART1, p, UART0_RXBUFFER_LEN ); FreeRTOS_write( &pdUART1, "\r\n\0", sizeof("\r\n\0") ); return; } // CMD NOT FOUND snprintf_P( cmd_printfBuff,sizeof(cmd_printfBuff),PSTR("ERROR\r\nCMD NOT DEFINED\r\n")); FreeRTOS_write( &pdUART1, cmd_printfBuff, sizeof(cmd_printfBuff) ); return; }
/*------------------------------------------------------------------------------------*/ static int anTR_07(void) { // En modo discreto apago los sensores. // Promedio // Convierto a magnitud. // Completo el frame con fechaHora y datos digitales. // Imprimo // Si corresponde, salvo en BD. u32 tickCount; double I,M; u08 i; u16 D; u08 channel; u16 pos = 0; size_t bWrite; StatBuffer_t pxFFStatBuffer; // En modo discreto debo apagar sensores if ( systemVars.pwrMode == PWR_DISCRETO ) { pv_ApagarSensores(); } // Promedio canales analogicos y bateria for ( channel = 0; channel < (NRO_ANALOG_CHANNELS + 1); channel++) { rAIn[channel] /= CICLOS_POLEO; tickCount = xTaskGetTickCount(); snprintf_P( aIn_printfBuff,CHAR128,PSTR(".[%06lu] tkAnalogIn::trD06 AvgCh[%d]=%.02f\r\n\0"), tickCount, channel, rAIn[channel]); u_debugPrint(D_DATA, aIn_printfBuff, sizeof(aIn_printfBuff) ); } // Convierto los canales analogicos a magnitudes. for ( channel = 0; channel < NRO_ANALOG_CHANNELS ; channel++) { // Calculo la corriente medida en el canal I = rAIn[channel] * systemVars.Imax[channel] / 4096; // Calculo la pendiente M = 0; D = systemVars.Imax[channel] - systemVars.Imin[channel]; if ( D != 0 ) { M = ( systemVars.Mmax[channel] - systemVars.Mmin[channel] ) / D; rAIn[channel] = systemVars.Mmin[channel] + M * ( I - systemVars.Imin[channel] ); } else { // Error: denominador = 0. rAIn[channel] = -999; } } #ifdef OSE_3CH // Convierto la bateria. rAIn[NRO_ANALOG_CHANNELS] = (15 * rAIn[NRO_ANALOG_CHANNELS]) / 4096; // Bateria // DEBUG for ( channel = 0; channel <= NRO_ANALOG_CHANNELS; channel++) { tickCount = xTaskGetTickCount(); snprintf_P( aIn_printfBuff,CHAR128,PSTR(".[%06lu] tkAnalogIn::trD06 MagCh[%d]=%.02f\r\n\0"), tickCount, channel, rAIn[channel]); u_debugPrint(D_DATA, aIn_printfBuff, sizeof(aIn_printfBuff) ); } #endif #ifdef UTE_8CH // DEBUG for ( channel = 0; channel < NRO_ANALOG_CHANNELS; channel++) { tickCount = xTaskGetTickCount(); snprintf_P( aIn_printfBuff,CHAR128,PSTR(".[%06lu] tkAnalogIn::trD06 MagCh[%d]=%.02f\r\n\0"), tickCount, channel, rAIn[channel]); u_debugPrint(D_DATA, aIn_printfBuff, sizeof(aIn_printfBuff) ); } #endif // Armo el frame. RTC_read(&Aframe.rtc); // Analogico for ( channel = 0; channel < NRO_ANALOG_CHANNELS; channel++) { Aframe.analogIn[channel] = rAIn[channel]; } #ifdef OSE_3CH // Bateria Aframe.batt = rAIn[3]; #endif // Digital u_readDigitalCounters( &Aframe.dIn, TRUE ); // Convierto los pulsos a los valores de la magnitud. for ( i = 0; i < NRO_DIGITAL_CHANNELS; i++ ) { Aframe.dIn.pulses[i] *= systemVars.magPP[i]; } #if !defined(SERIAL) // Guardo en BD ? if ( AN_flags.saveFrameInBD ) { AN_flags.saveFrameInBD = FALSE; bWrite = FF_fwrite( &Aframe, sizeof(Aframe)); FF_stat(&pxFFStatBuffer); if ( bWrite != sizeof(Aframe) ) { // Error de escritura ?? snprintf_P( aIn_printfBuff,sizeof(aIn_printfBuff),PSTR("WR ERROR: (%d)\r\n\0"),pxFFStatBuffer.errno); } else { // Stats de memoria snprintf_P( aIn_printfBuff, sizeof(aIn_printfBuff), PSTR("MEM [%d/%d/%d][%d/%d]\r\n\0"), pxFFStatBuffer.HEAD,pxFFStatBuffer.RD, pxFFStatBuffer.TAIL,pxFFStatBuffer.rcdsFree,pxFFStatBuffer.rcds4del); } u_debugPrint(D_BASIC, aIn_printfBuff, sizeof(aIn_printfBuff) ); } #endif #ifdef UTE_8CH // Imprimo el frame. pos = snprintf_P( aIn_printfBuff, sizeof(aIn_printfBuff), PSTR("FRAME::{" )); // timeStamp. pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ),PSTR( "%04d%02d%02d,"),Aframe.rtc.year,Aframe.rtc.month,Aframe.rtc.day ); pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR("%02d%02d%02d"),Aframe.rtc.hour,Aframe.rtc.min, Aframe.rtc.sec ); // Valores analogicos for ( channel = 0; channel < NRO_ANALOG_CHANNELS; channel++) { pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR(",%s=%.02f"),systemVars.aChName[channel],Aframe.analogIn[channel] ); } #ifdef SERIAL // Valores digitales for ( channel = 0; channel < NRO_DIGITAL_CHANNELS; channel++) { pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR(",%s_P=%.02f,%s_L=%d"), systemVars.dChName[channel],Aframe.dIn.pulses[channel], systemVars.dChName[channel],Aframe.dIn.level[channel] ); } #else // Valores digitales for ( channel = 0; channel < NRO_DIGITAL_CHANNELS; channel++) { pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR(",%s{P=%.02f,L=%d,T=%d}"), systemVars.dChName[channel],Aframe.dIn.pulses[channel],Aframe.dIn.level[channel],Aframe.dIn.secsUp[channel] ); } #endif pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR("}\r\n\0") ); u_logPrint (aIn_printfBuff, sizeof(aIn_printfBuff) ); #ifdef SERIAL if ( systemVars.log == OFF ) { FreeRTOS_write( &pdUART1, aIn_printfBuff, sizeof(aIn_printfBuff) ); } #endif #endif #ifdef OSE_3CH // Imprimo el frame. pos = snprintf_P( aIn_printfBuff, sizeof(aIn_printfBuff), PSTR("FRAME::{" )); // timeStamp. pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ),PSTR( "%04d%02d%02d,"),Aframe.rtc.year,Aframe.rtc.month,Aframe.rtc.day ); pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR("%02d%02d%02d"),Aframe.rtc.hour,Aframe.rtc.min, Aframe.rtc.sec ); // Valores analogicos for ( channel = 0; channel < NRO_ANALOG_CHANNELS; channel++) { pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR(",%s=%.02f"),systemVars.aChName[channel],Aframe.analogIn[channel] ); } // Valores digitales for ( channel = 0; channel < NRO_DIGITAL_CHANNELS; channel++) { pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR(",%sP=%.02f"), systemVars.dChName[channel],Aframe.dIn.pulses[channel] ); } // Bateria pos += snprintf_P( &aIn_printfBuff[pos], ( sizeof(aIn_printfBuff) - pos ), PSTR(",bt=%.02f}\r\n\0"),Aframe.batt ); FreeRTOS_write( &pdUART1, aIn_printfBuff, sizeof(aIn_printfBuff) ); #endif #ifdef CONSIGNA // Envio un mensaje a la tarea de la consigna diciendole que estan los datos listos if ( systemVars.consigna.type == CONSIGNA_CONTINUA ) { while ( xTaskNotify(xHandle_tkConsignas, TKC_FRAME_READY , eSetBits ) != pdPASS ) { vTaskDelay( ( TickType_t)( 100 / portTICK_RATE_MS ) ); } // snprintf_P( aIn_printfBuff,sizeof(aIn_printfBuff),PSTR("DEBUG SEND MSG 2 CC\r\n\0")); // FreeRTOS_write( &pdUART1, aIn_printfBuff,sizeof(aIn_printfBuff) ); } #endif AN_flags.start2poll = FALSE; pv_AINprintExitMsg(7); return(anST_A01); }
void MM_StopPlaying(void) { (void)xTaskNotify(MidiPlayTaskHandle, MIDI_SONG_STOP, eSetBits); }
void MM_PlayMusic(int song) { if (song==-1) { /* use set/stored song */ song = MM_SetSong; } (void)xTaskNotify(MidiPlayTaskHandle, (1<<song)|MIDI_SONG_START, eSetBits); }
static void prvSingleTaskTests( void ) { const TickType_t xTicksToWait = pdMS_TO_TICKS( 100UL ); BaseType_t xReturned; uint32_t ulNotifiedValue, ulLoop, ulNotifyingValue, ulPreviousValue, ulExpectedValue; TickType_t xTimeOnEntering; const uint32_t ulFirstNotifiedConst = 100001UL, ulSecondNotifiedValueConst = 5555UL, ulMaxLoops = 5UL; const uint32_t ulBit0 = 0x01UL, ulBit1 = 0x02UL; /* ------------------------------------------------------------------------- Check blocking when there are no notifications. */ xTimeOnEntering = xTaskGetTickCount(); xReturned = xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, xTicksToWait ); /* Should have blocked for the entire block time. */ if( ( xTaskGetTickCount() - xTimeOnEntering ) < xTicksToWait ) { xErrorStatus = pdFAIL; } configASSERT( xReturned == pdFAIL ); configASSERT( ulNotifiedValue == 0UL ); /* ------------------------------------------------------------------------- Check no blocking when notifications are pending. First notify itself - this would not be a normal thing to do and is done here for test purposes only. */ xReturned = xTaskNotifyAndQuery( xTaskToNotify, ulFirstNotifiedConst, eSetValueWithoutOverwrite, &ulPreviousValue ); /* Even through the 'without overwrite' action was used the update should have been successful. */ configASSERT( xReturned == pdPASS ); /* No bits should have been pending previously. */ configASSERT( ulPreviousValue == 0 ); /* The task should now have a notification pending, and so not time out. */ xTimeOnEntering = xTaskGetTickCount(); xReturned = xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, xTicksToWait ); if( ( xTaskGetTickCount() - xTimeOnEntering ) >= xTicksToWait ) { xErrorStatus = pdFAIL; } /* The task should have been notified, and the notified value should be equal to ulFirstNotifiedConst. */ configASSERT( xReturned == pdPASS ); configASSERT( ulNotifiedValue == ulFirstNotifiedConst ); /* Incremented to show the task is still running. */ ulNotifyCycleCount++; /*-------------------------------------------------------------------------- Check the non-overwriting functionality. The notification is done twice using two different notification values. The action says don't overwrite so only the first notification should pass and the value read back should also be that used with the first notification. */ xReturned = xTaskNotify( xTaskToNotify, ulFirstNotifiedConst, eSetValueWithoutOverwrite ); configASSERT( xReturned == pdPASS ); xReturned = xTaskNotify( xTaskToNotify, ulSecondNotifiedValueConst, eSetValueWithoutOverwrite ); configASSERT( xReturned == pdFAIL ); /* Waiting for the notification should now return immediately so a block time of zero is used. */ xReturned = xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdPASS ); configASSERT( ulNotifiedValue == ulFirstNotifiedConst ); /*-------------------------------------------------------------------------- Do the same again, only this time use the overwriting version. This time both notifications should pass, and the value written the second time should overwrite the value written the first time, and so be the value that is read back. */ xReturned = xTaskNotify( xTaskToNotify, ulFirstNotifiedConst, eSetValueWithOverwrite ); configASSERT( xReturned == pdPASS ); xReturned = xTaskNotify( xTaskToNotify, ulSecondNotifiedValueConst, eSetValueWithOverwrite ); configASSERT( xReturned == pdPASS ); xReturned = xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdPASS ); configASSERT( ulNotifiedValue == ulSecondNotifiedValueConst ); /*-------------------------------------------------------------------------- Check notifications with no action pass without updating the value. Even though ulFirstNotifiedConst is used as the value the value read back should remain at ulSecondNotifiedConst. */ xReturned = xTaskNotify( xTaskToNotify, ulFirstNotifiedConst, eNoAction ); configASSERT( xReturned == pdPASS ); xReturned = xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, 0 ); configASSERT( ulNotifiedValue == ulSecondNotifiedValueConst ); /*-------------------------------------------------------------------------- Check incrementing values. Send ulMaxLoop increment notifications, then ensure the received value is as expected - which should be ulSecondNotificationValueConst plus how ever many times to loop iterated. */ for( ulLoop = 0; ulLoop < ulMaxLoops; ulLoop++ ) { xReturned = xTaskNotify( xTaskToNotify, 0, eIncrement ); configASSERT( xReturned == pdPASS ); } xReturned = xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdPASS ); configASSERT( ulNotifiedValue == ( ulSecondNotifiedValueConst + ulMaxLoops ) ); /* Should not be any notifications pending now. */ xReturned = xTaskNotifyWait( 0, 0, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdFAIL ); /*-------------------------------------------------------------------------- Check all bits can be set by notifying the task with one additional bit set on each notification, and exiting the loop when all the bits are found to be set. As there are 32-bits the loop should execute 32 times before all the bits are found to be set. */ ulNotifyingValue = 0x01; ulLoop = 0; /* Start with all bits clear. */ xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, 0 ); do { /* Set the next bit in the task's notified value. */ xTaskNotify( xTaskToNotify, ulNotifyingValue, eSetBits ); /* Wait for the notified value - which of course will already be available. Don't clear the bits on entry or exit as this loop is exited when all the bits are set. */ xReturned = xTaskNotifyWait( 0, 0, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdPASS ); ulLoop++; /* Use the next bit on the next iteration around this loop. */ ulNotifyingValue <<= 1UL; } while ( ulNotifiedValue != ULONG_MAX ); /* As a 32-bit value was used the loop should have executed 32 times before all the bits were set. */ configASSERT( ulLoop == 32 ); /*-------------------------------------------------------------------------- Check bits are cleared on entry but not on exit when a notification fails to arrive before timing out - both with and without a timeout value. Wait for the notification again - but this time it is not given by anything and should return pdFAIL. The parameters are set to clear bit zero on entry and bit one on exit. As no notification was received only the bit cleared on entry should actually get cleared. */ xReturned = xTaskNotifyWait( ulBit0, ulBit1, &ulNotifiedValue, xTicksToWait ); configASSERT( xReturned == pdFAIL ); /* Notify the task with no action so as not to update the bits even though ULONG_MAX is used as the notification value. */ xTaskNotify( xTaskToNotify, ULONG_MAX, eNoAction ); /* Reading back the value should should find bit 0 is clear, as this was cleared on entry, but bit 1 is not clear as it will not have been cleared on exit as no notification was received. */ xReturned = xTaskNotifyWait( 0x00UL, 0x00UL, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdPASS ); configASSERT( ulNotifiedValue == ( ULONG_MAX & ~ulBit0 ) ); /*-------------------------------------------------------------------------- Now try clearing the bit on exit. For that to happen a notification must be received, so the task is notified first. */ xTaskNotify( xTaskToNotify, 0, eNoAction ); xTaskNotifyWait( 0x00, ulBit1, &ulNotifiedValue, 0 ); /* However as the bit is cleared on exit, after the returned notification value is set, the returned notification value should not have the bit cleared... */ configASSERT( ulNotifiedValue == ( ULONG_MAX & ~ulBit0 ) ); /* ...but reading the value back again should find that the bit was indeed cleared internally. The returned value should be pdFAIL however as nothing has notified the task in the mean time. */ xReturned = xTaskNotifyWait( 0x00, 0x00, &ulNotifiedValue, 0 ); configASSERT( xReturned == pdFAIL ); configASSERT( ulNotifiedValue == ( ULONG_MAX & ~( ulBit0 | ulBit1 ) ) ); /*-------------------------------------------------------------------------- Now try querying the previous value while notifying a task. */ xTaskNotifyAndQuery( xTaskToNotify, 0x00, eSetBits, &ulPreviousValue ); configASSERT( ulNotifiedValue == ( ULONG_MAX & ~( ulBit0 | ulBit1 ) ) ); /* Clear all bits. */ xTaskNotifyWait( 0x00, ULONG_MAX, &ulNotifiedValue, 0 ); xTaskNotifyAndQuery( xTaskToNotify, 0x00, eSetBits, &ulPreviousValue ); configASSERT( ulPreviousValue == 0 ); ulExpectedValue = 0; for( ulLoop = 0x01; ulLoop < 0x80UL; ulLoop <<= 1UL ) { /* Set the next bit up, and expect to receive the last bits set (so the previous value will not yet have the bit being set this time around). */ xTaskNotifyAndQuery( xTaskToNotify, ulLoop, eSetBits, &ulPreviousValue ); configASSERT( ulExpectedValue == ulPreviousValue ); ulExpectedValue |= ulLoop; } /* ------------------------------------------------------------------------- Clear the previous notifications. */ xTaskNotifyWait( ULONG_MAX, 0, &ulNotifiedValue, 0 ); /* The task should not have any notifications pending, so an attempt to clear the notification state should fail. */ configASSERT( xTaskNotifyStateClear( NULL ) == pdFALSE ); /* Get the task to notify itself. This is not a normal thing to do, and is only done here for test purposes. */ xTaskNotifyAndQuery( xTaskToNotify, ulFirstNotifiedConst, eSetValueWithoutOverwrite, &ulPreviousValue ); /* Now the notification state should be eNotified, so it should now be possible to clear the notification state. */ configASSERT( xTaskNotifyStateClear( NULL ) == pdTRUE ); configASSERT( xTaskNotifyStateClear( NULL ) == pdFALSE ); /* Incremented to show the task is still running. */ ulNotifyCycleCount++; /* Leave all bits cleared. */ xTaskNotifyWait( ULONG_MAX, 0, NULL, 0 ); }
void ProgramManager::notifyManager(uint32_t ulValue){ if(xManagerHandle != NULL) xTaskNotify(xManagerHandle, ulValue, eSetBits); }