Exemple #1
0
void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
{
	/* Parameters are not used. */
	( void ) ulLine;
	( void ) pcFileName;

	taskDISABLE_INTERRUPTS();

#if defined (__WIN32__)
	__asm volatile( "int $3" );
#endif

	taskENABLE_INTERRUPTS();

}
Exemple #2
0
void vApplicationMallocFailedHook( void )
{
	/* vApplicationMallocFailedHook() will only be called if
	configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook
	function that will get called if a call to pvPortMalloc() fails.
	pvPortMalloc() is called internally by the kernel whenever a task, queue,
	timer or semaphore is created.  It is also called by various parts of the
	demo application.  If heap_1.c or heap_2.c are used, then the size of the
	heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
	FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
	to query the size of free heap space that remains (although it does not
	provide information on how the remaining heap might be fragmented). */
	taskDISABLE_INTERRUPTS();
	for( ;; );
}
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( xTaskHandle pxTask,
		signed char *pcTaskName )
{
	(void)pcTaskName;
	(void)pxTask;

	/* Run time stack overflow checking is performed if
	 * configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook
	 * function is called if a stack overflow is detected. */
	taskDISABLE_INTERRUPTS();
	for (;;) {
		while (1) {
		}
	}
}
Exemple #4
0
/* This function is explained in the comments at the top of this file. */
static void prvRegTest1Task( void *pvParameters )
{
	if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )
	{
		/* The parameter did not contain the expected value. */
		for( ;; )
		{
			/* Stop the tick interrupt so its obvious something has gone wrong. */
			taskDISABLE_INTERRUPTS();
		}
	}

	/* This is an asm function that never returns. */
	prvRegTest1Implementation();
}
//=========================================================================================================
// 
//=========================================================================================================
void vApplicationMallocFailedHook(void)
{
	/* 
	 �ڴ����ʧ�ܹ��Ӻ���
	 FreeRTOS�ں��ڴ������񡢶��С���ʱ�������ź�ʱ�����pvPortMalloc() ������
	 һ��pvPortMalloc() ��������ʧ�ܣ��������ļ�FreeRTOSConfig.h�У�
	 configUSE_MALLOC_FAILED_HOOK����Ϊ1ʱ����øú�����
	 �ú���Ҳ������Ӧ�ó�����á�
	 ���Ӧ�ó����а������ļ�heap_1.c ���� heap_2.c��pvPortMalloc() ��ʹ�õĶѴ�С
	 ���ļ�FreeRTOSConfig.h�е�configTOTAL_HEAP_SIZE���塣
	 ����API����xPortGetFreeHeapSize()���Է��ؿ��еĶѿռ��С��
	*/
	taskDISABLE_INTERRUPTS();//�������п����ε��ж�
	for( ;; );
}
Exemple #6
0
/**
 * @brief		If enabled, this hook will be called in case of a stack
 * 				overflow.
 * @param[in]	pxTask		Task handle.
 * @param[in]	pcTaskName	Pointer to task name.
 */
void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName )
{
	/* This will get called if a stack overflow is detected during the context
	 switch.  Set configCHECK_FOR_STACK_OVERFLOWS to 2 to also check for stack
	 problems within nested interrupts, but only do this for debug purposes as
	 it will increase the context switch time. */
	(void)pxTask;
	(void)pcTaskName;
	taskDISABLE_INTERRUPTS();
	/* Write your code here ... */
	//for(;;) {}
	while ( 1 )
	{
		blink( 1, 100 );
	}
}
Exemple #7
0
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
	( void ) pcTaskName;
	( void ) pxTask;

	/* Run time stack overflow checking is performed if
	configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook
	function is called if a stack overflow is detected.

	Increase the size of the stack allocated to the offending task.

	Force an assert. */
	configASSERT( pxTask == NULL );
	taskDISABLE_INTERRUPTS();
	for( ;; );
}
void vAssertCalled( void )
{
const unsigned long ulLongSleep = 1000UL;
volatile uint32_t ulBlockVariable = 0UL;

	/* Setting ulBlockVariable to a non-zero value in the debugger will allow
	this function to be exited. */
	taskDISABLE_INTERRUPTS();
	{
		while( ulBlockVariable == 0UL )
		{
			Sleep( ulLongSleep );
		}
	}
	taskENABLE_INTERRUPTS();
}
Exemple #9
0
/*---------------------------------------------------------------------------*
 * Routine:  PlayAudio
 *---------------------------------------------------------------------------*
 * Description:
 *      Play a tone for the given length, staying here until done.
 * Inptus:
 *      TUInt32 aHz                 -- Tone in Hz
 *      TUInt32 aMS                 -- Duration of tone
 *---------------------------------------------------------------------------*/
void PlayAudio(TUInt32 aHz, TUInt32 aMS)
{

#if OPTION_USE_GPIO_LINES_FOR_AUDIO
    static HAL_GPIOPort **p_gpio0;
    TUInt32 n;
    TUInt32 start = UEZTickCounterGet();
    TUInt32 count;

    HALInterfaceFind("GPIO0", (T_halWorkspace **)&p_gpio0);
    (*p_gpio0)->SetOutputMode(p_gpio0, (1<<26));

    // Wait for the parameters to be ready
    n = (G_subTickCount*1000/2)/aHz;
    taskDISABLE_INTERRUPTS();
    G_dummyCounter = 0;
    // Wait for first tick count
    while ((T1IR&2)==0)
        {}
    while (aMS--) {
        T1IR = 2;
        while (!(T1IR & 2)) {
            count = n;
            while (count--)
                { G_dummyCounter++; }
            (*p_gpio0)->Clear(p_gpio0, (1<<26));
            count = n;
            while (count--)
                { G_dummyCounter++; }
            (*p_gpio0)->Set(p_gpio0, (1<<26));
        }
    }

    taskENABLE_INTERRUPTS();
#else
    if (!G_tg)
        CalibrateAudioTiming();
    //PWMAudio(aHz, (aMS+10)/10, 0);
    if (G_tg)
        UEZToneGeneratorPlayTone(
                G_tg,
                TONE_GENERATOR_HZ(aHz),
                aMS);
    else
        UEZTaskDelay(aMS);
#endif
}
Exemple #10
0
void TerminalTask( void *pvParameters )
{
	terminalQueue = xQueueCreate(TERMINAL_QUEUE_LEN, MAX_CHARS);
	// Initialize memory (in stack) for message.

	static unsigned char string[MAX_CHARS];
	// Try to receive message, put the task to sleep for at most RXTIMEOUT ticks if queue is empty.
	for(;;)
	{
		if (xQueueReceive(terminalQueue, string, TERMINAL_QUEUE_TIMEOUT))
		{
		    taskDISABLE_INTERRUPTS();
		    USART_puts(USART1, (volatile char*)string);
		    taskENABLE_INTERRUPTS();
		}
	}
}
Exemple #11
0
void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
{
	/* Parameters are not used. */
	( void ) ulLine;
	( void ) pcFileName;

	taskDISABLE_INTERRUPTS();

	/* Stop the trace recording. */
	if( xTraceRunning == pdTRUE )
	{
		vTraceStop();
		prvSaveTraceFile();
	}
		
	for( ;; );
}
Exemple #12
0
void vAssertCalled(const char *file, const char *line) {
    char *msg;
    taskDISABLE_INTERRUPTS();
    
    write_std_out("Assert called ", strlen("Assert called "));
    write_std_out(file, strlen(file));
    write_std_out(":", 1);
    write_std_out(line, strlen(line));
    write_std_out("\r\n", 2);
    
    msg = "In thread ";
    write_std_out(msg, strlen(msg));
    msg = pcTaskGetName(NULL);
    write_std_out(msg, strlen(msg));
    
    while(1) {;}
}
Exemple #13
0
void disable_global_interrupts() {
#ifdef USE_FREERTOS
	taskDISABLE_INTERRUPTS();
#else
	unsigned int value = 0;

	ARM_AR_INT_BITS_GET(&value);

	if (value != old_value) {

		ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);

		old_value = value;

	}
#endif
}
Exemple #14
0
static void new_multimeter_sample(const measure_data_t* data)
{
  int channel = ch_generic2internal(data->ch);
  static portTickType last_update[NUMBER_OF_CHANNELS] = { 0 };

  if((last_update[channel] + CONFIG_DISPLAY_MULTIMETER_REFRESH_TIME) < xTaskGetTickCount())
  {
    static char buffer[15];
    static const int max_mV = 3300;
    int mV = (data->data[0]*max_mV)/ADC_MAX;
    int Line;
    char ch;
    last_update[channel] = xTaskGetTickCount();


    switch (channel)
    {
      case  input_channel0:
        Line = Line3;
        ch = 'A';
        break;

      case  input_channel1:
        Line = Line4;
        ch = 'B';
        break;

      default:
        ipc_watchdog_signal_error(0);
        return;
    }
    sprintf (buffer, "Channel %c: %i.%03i V", ch, mV/1000,mV%1000);

    xSemaphoreTake(lcdLock, portMAX_DELAY);
    taskDISABLE_INTERRUPTS();
    TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
    
    GLCD_setTextColor(Black);
    GLCD_displayStringLn(Line, (unsigned char *) buffer); 

    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
    taskENABLE_INTERRUPTS();
    xSemaphoreGive(lcdLock);
  }
}
bool LineRecv(unsigned char* pRecvBuf,unsigned long ulLength)
{
	//ASSERT(ulLength>=ITEM_LENGTH);
	//ASSERT(pRecvBuf != NULL);
	taskDISABLE_INTERRUPTS();
	unsigned char* pLine;
	portBASE_TYPE ptRet = xQueueReceive(s_QueueLine,&pLine,0);
	if (ptRet != pdPASS) {
		taskENABLE_INTERRUPTS();
		return false;
	}
	memcpy(pRecvBuf, pLine, ITEM_LENGTH);
	ptRet = xQueueSendToBack(s_QueueBuff,&pLine,0);
	ASSERT(ptRet == pdPASS);
	taskENABLE_INTERRUPTS();
	
	return true;
}
void vAssertCalled( const char * pcFile, unsigned long ulLine )
{
volatile unsigned long ul = 0;

	( void ) pcFile;
	( void ) ulLine;

	taskDISABLE_INTERRUPTS();
	{
		/* Set ul to a non-zero value using the debugger to step out of this
		function. */
		while( ul == 0 )
		{
			portNOP();
		}
	}
	taskENABLE_INTERRUPTS();
}
/***********************************************************************************************************************
* Function Name: R_SCI7_AsyncTransmit
* Description  : This function sends SCI7 data and waits for the transmit end flag.
* Arguments    : tx_buf -
*                    transfer buffer pointer
*                tx_num -
*                    buffer size
* Return Value : status -
*                    MD_OK or MD_ARGERROR
***********************************************************************************************************************/
MD_STATUS R_SCI7_AsyncTransmit (uint8_t * const tx_buf, const uint16_t tx_num)
{
    MD_STATUS status = MD_OK;
taskDISABLE_INTERRUPTS();
while( 1 );
    /* clear the flag before initiating a new transmission */
    sci7_txdone = FALSE;

    /* Send the data using the API */
    status = R_SCI7_Serial_Send(tx_buf, tx_num);

    /* Wait for the transmit end flag */
    while (FALSE == sci7_txdone)
    {
        /* Wait */
    }
    return (status);
}
Exemple #18
0
void prvTaskExtCtrl(void* pvParameters)
{
    while(1)
    {
        /* Store value converted from mdps to dps */
        xSemaphoreTake(xExtCtrlSem, 0);
        taskDISABLE_INTERRUPTS();
        xExtCtrl.pitch = (xPitchTick - EXTCTRL_TIM_COUNT_MIN) / (EXTCTRL_TIM_COUNT_MAX - EXTCTRL_TIM_COUNT_MIN) * 100;
        xExtCtrl.roll  = (xRollTick - EXTCTRL_TIM_COUNT_MIN) / (EXTCTRL_TIM_COUNT_MAX - EXTCTRL_TIM_COUNT_MIN) * 100;
        xExtCtrl.yaw   = (xYawTick - EXTCTRL_TIM_COUNT_MIN) / (EXTCTRL_TIM_COUNT_MAX - EXTCTRL_TIM_COUNT_MIN) * 100;
        taskENABLE_INTERRUPTS();
        /* Critical section */
        xSemaphoreGive(xExtCtrlSem);

        /* Delay specified period of time */
        vTaskDelay(1000 / TASK_EXTCTRL_SAMPLING_RATE / portTICK_PERIOD_MS);
    }
}
Exemple #19
0
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
    taskDISABLE_INTERRUPTS();

    /* Disable the watchdog. */
    WDTCTL = WDTPW + WDTHOLD;

    //halBoardInit();
    Board_init();

    // Set Vcore to accomodate for max. allowed system speed
    SetVCore(3);

    // Use 32.768kHz XTAL as reference
    LFXT_Start(XT1DRIVE_0);

    // Set system clock to max (25MHz)
    Init_FLL_Settle(25000, 762);

    SFRIFG1 = 0;
    SFRIE1 |= OFIE;

    //LFXT_Start( XT1DRIVE_0 );
    //hal430SetSystemClock( configCPU_CLOCK_HZ, configLFXT_CLOCK_HZ );

    //halButtonsInit( BUTTON_ALL );
    Buttons_init(BUTTON_ALL);
    //halButtonsInterruptEnable( BUTTON_SELECT );
    Buttons_interruptEnable(BUTTON_S2);

    /* Initialise the LCD, but note that the backlight is not used as the
    library function uses timer A0 to modulate the backlight, and this file
    defines	vApplicationSetupTimerInterrupt() to also use timer A0 to generate
    the tick interrupt.  If the backlight is required, then change either the
    halLCD library or vApplicationSetupTimerInterrupt() to use a different
    timer.  Timer A1 is used for the run time stats time base6. */
    //halLcdInit();
    //halLcdSetContrast( 100 );
    //halLcdClearScreen();

    //halLcdPrintLine( " www.FreeRTOS.org", 0,  OVERWRITE_TEXT );
}
Exemple #20
0
//*=========================================================
//*		READ
//*=========================================================
//*----------------------------------------------------------------------------
//* \fn    AT91F_TWI_Read
//* \brief Read n bytes from a slave device
//*----------------------------------------------------------------------------
int AT91F_TWI_Read(unsigned int devaddress,unsigned int address,unsigned char *data,int size)
{	
  unsigned int SizeReaded;
  volatile unsigned int status;
  if( TWI_Semaphore != NULL )
    {
      if( xSemaphoreTake( TWI_Semaphore, ( portTickType ) 2000 ) == pdTRUE )
      {
        SizeReaded = 0;
        AT91PS_TWI TWI = AT91C_BASE_TWI;
        TWI_DataPointer = data;
        TWI_Bytes2Transfere = size;
        TWI_DeviceAddr = devaddress;
	if(TWI_Bytes2Transfere>1)TWI_ConitiosTransaction = 1;
taskDISABLE_INTERRUPTS();
	TWI->TWI_IADR = address;
	TWI->TWI_MMR = TWI_DeviceAddr | AT91C_TWI_IADRSZ_2_BYTE | AT91C_TWI_MREAD;	
        TWI_TransferStatus = ON_READ_DATA;
        AT91F_TWI_EnableIt(TWI, AT91C_TWI_TXCOMP | AT91C_TWI_NACK | AT91C_TWI_OVRE | AT91C_TWI_UNRE);
        TWI->TWI_CR = AT91C_TWI_START | AT91C_TWI_MSEN | AT91C_TWI_STOP ;
        status = TWI->TWI_SR;
taskENABLE_INTERRUPTS();
        xQueueReceive( TWI_QUEUE, &( SizeReaded ), ( portTickType ) AT91C_TWI_TMO_VOL(size) );

   if( TWI_TransferStatus != FREE)
         {
         //  SYSTEM_ERROR(TWI_TMO_Error);
           RESET_TWI();

         } ;
        TWI_TransferStatus = FREE;
        xSemaphoreGive( TWI_Semaphore );
      }
        else
        {
         //SYSTEM_ERROR(TWI_SEM_Error);
        }
    }
  return SizeReaded;
}
Exemple #21
0
void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
{
static portBASE_TYPE xPrinted = pdFALSE;

	/* Parameters are not used. */
	( void ) ulLine;
	( void ) pcFileName;

	taskDISABLE_INTERRUPTS();

	/* Stop the trace recording. */
	if( xPrinted == pdFALSE )
	{
		xPrinted = pdTRUE;
		if( xTraceRunning == pdTRUE )
		{
		vTraceStop();
		prvSaveTraceFile();
		}
	}
	for( ;; );
}
void vtHandleFatalError(int code,int line,char file[]) {
    static unsigned int delayCounter = 0;
    // There are lots of ways you can (and may want to) handle a fatal error
    // In this implementation, I suspend tasks and then flash the LEDs.  Note that the stop may not be
    //   immediate because this task has to be scheduled first for that to happen.  In fact, one task might
    //   call this while another tries to get into
    taskENTER_CRITICAL();
    taskDISABLE_INTERRUPTS();
    /* LEDs on ports 1 and 2 to output (1). */
    // Note that all LED access is through the proper LPC library calls (or my own routines that call them)

    // Print where error occured for debugging
    printf("ERROR: code %d on line %d in file %s",code,line,file);

    vtInitLED();
    for (;;) {
        // Silly delay loop, but we really don't have much choice here w/o interrupts and FreeRTOS...
        // This won't be okay to do *anywhere* else in your code
        for (delayCounter=0; delayCounter<10000000; delayCounter++) {
        }
        // Turn off half and on half
        vtLEDOn(0xAA);
        vtLEDOff(0x55);
        // Delay again
        for (delayCounter=0; delayCounter<10000000; delayCounter++) {
        }
        // Toggle
        vtLEDOff(0xAA);
        vtLEDOn(0x55);
        // Here is some dumb code to make sure that the three input parameters are not optimized away by the compiler
        if ((code < -55) && (line < -55) && (file == NULL)) {
            vtLEDOff(0x0); // We won't get here
        }
        // End of dumb code
    }
    // We will never get here
    taskEXIT_CRITICAL();
}
Exemple #23
0
//*=========================================================
//*		WRITE
//*=========================================================
//*----------------------------------------------------------------------------
//* \fn    AT91F_TWI_Write
//* \brief Send n bytes to a slave device
//*----------------------------------------------------------------------------
int AT91F_TWI_Write(unsigned int devaddress,unsigned int address,unsigned char *data2send, int size)
{
 unsigned int SizeNotWrited = 0;
//---------------------------------------------------------
 if( TWI_Semaphore != NULL )
    {
      if( xSemaphoreTake( TWI_Semaphore, ( portTickType ) 2000 ) == pdTRUE )
      {
        TWI_TransferStatus = ON_WRITE_DATA;
        SizeNotWrited = 0;
        TWI_DataPointer = data2send;
        TWI_Bytes2Transfere = size;
        TWI_DeviceAddr = devaddress;
        TWI_TransferStatus = ON_WRITE_DATA;
taskDISABLE_INTERRUPTS();
        AT91C_BASE_TWI->TWI_MMR = ( TWI_DeviceAddr | AT91C_TWI_IADRSZ_2_BYTE ) & ~AT91C_TWI_MREAD;	
        AT91C_BASE_TWI->TWI_IADR = address;
	AT91C_BASE_TWI->TWI_THR = *(TWI_DataPointer++);
        AT91F_TWI_EnableIt(AT91C_BASE_TWI,AT91C_TWI_TXRDY | AT91C_TWI_NACK);
        AT91C_BASE_TWI->TWI_CR = AT91C_TWI_START ;
taskENABLE_INTERRUPTS();
        xQueueReceive( TWI_QUEUE, &( SizeNotWrited ), ( portTickType ) AT91C_TWI_TMO_VOL(size));
        if( TWI_TransferStatus != FREE)
         {
          // SYSTEM_ERROR(TWI_TMO_Error);
           RESET_TWI();
         };
        TWI_TransferStatus = FREE;

        xSemaphoreGive( TWI_Semaphore );
      }
        else
        {
         //SYSTEM_ERROR(TWI_SEM_Error);
        }
    }
 return SizeNotWrited;
}
/**
 * Called when the system hits a non-recoverable error.  Ensure to use
 * the correct PANIC_CAUSE_* enum to help users inform us of the issue.
 */
void panic(const enum panic_cause cause)
{
        taskDISABLE_INTERRUPTS();

        led_enable(LED_ERROR);
        for(;;) {
                led_enable(LED_GPS);
                led_enable(LED_LOGGER);
                delay_seconds(FLASH_PAUSE_DELAY_S);
                led_disable(LED_GPS);
                led_disable(LED_LOGGER);
                delay_seconds(FLASH_DELAY_S);

                for (int c = 0; c < cause; ++c) {
                        led_enable(LED_GPS);
                        led_enable(LED_LOGGER);
                        delay_seconds(FLASH_DELAY_S);
                        led_disable(LED_GPS);
                        led_disable(LED_LOGGER);
                        delay_seconds(FLASH_DELAY_S);
                }
        }
}
Exemple #25
0
static void ReadParameters(void)  // read parameters requested by the user in the NMEA sent.
{ if((!NMEA.hasCheck()) || NMEA.isChecked() )
  { const char *Parm; int8_t Val;
    Parm = (const char *)NMEA.ParmPtr(0);                                  // [0..15] aircraft-type: 1=glider, 2=towa plane, 3=helicopter, ...
    if(Parm)
    { Val=Read_Hex1(Parm[0]);
      if( (Val>=0) && (Val<16) ) Parameters.setAcftType(Val); }
    Parm = (const char *)NMEA.ParmPtr(1);                                  // [0..3] addr-type: 1=ICAO, 2=FLARM, 3=OGN
    if(Parm)
    { Val=Read_Hex1(Parm[0]);
      if( (Val>=0) && (Val<4) ) Parameters.setAddrType(Val); }
    Parm = (const char *)NMEA.ParmPtr(2);                                  // [HHHHHH] Address (ID): 6 hex digits, 24-bit
    uint32_t Addr;
    int8_t Len=Read_Hex(Addr, Parm);
    if( (Len==6) && (Addr<0x01000000) ) Parameters.setAddress(Addr);
    Parm = (const char *)NMEA.ParmPtr(3);                                  // [0..1] RFM69HW (up to +20dBm) or W (up to +13dBm)
    if(Parm)
    { Val=Read_Dec1(Parm[0]);
           if(Val==0) Parameters.clrTxTypeHW();
      else if(Val==1) Parameters.setTxTypeHW(); }
    Parm = (const char *)NMEA.ParmPtr(4);                                  // [dBm] Tx power
    int32_t TxPower;
    Len=Read_SignDec(TxPower, Parm);
    if( (Len>0) && (TxPower>=(-10)) && (TxPower<=20) ) Parameters.setTxPower(TxPower);
    Parm = (const char *)NMEA.ParmPtr(5);                                  // [Hz] Tx/Rx frequency correction
    int32_t FreqCorr;
    Len=Read_SignDec(FreqCorr, Parm);
    if( (Len>0) && (FreqCorr>=(-100000)) && (FreqCorr<=100000) ) Parameters.RFchipFreqCorr = (FreqCorr<<8)/15625;

    taskDISABLE_INTERRUPTS();                                              // disable all interrupts: Flash can not be read while being erased
    IWDG_ReloadCounter();                                                  // kick the watch-dog
    Parameters.WriteToFlash();                                             // erase and write the parameters into the last page of Flash
    if(Parameters.ReadFromFlash()<0) Parameters.setDefault();              // read the parameters back: if invalid, set defaults
    taskENABLE_INTERRUPTS();                                               // bring back interrupts and the system
  }
  PrintParameters();
}
/**
 * Called when the system hits a non-recoverable error.  Ensure to use
 * the correct PANIC_CAUSE_* enum to help users inform us of the issue.
 */
void panic(const enum panic_cause cause)
{
        taskDISABLE_INTERRUPTS();
	led_device_set_all(false);

        led_enable(LED_ERROR);
        for(;;) {
                led_enable(LED_GPS);
                led_enable(LED_LOGGER);
                cpu_device_spin(FLASH_PAUSE_DELAY_MS);
                led_disable(LED_GPS);
                led_disable(LED_LOGGER);
                cpu_device_spin(FLASH_DELAY_MS);

                for (int c = 0; c < cause - 1; ++c) {
                        led_enable(LED_GPS);
                        led_enable(LED_LOGGER);
                        cpu_device_spin(FLASH_DELAY_MS);
                        led_disable(LED_GPS);
                        led_disable(LED_LOGGER);
                        cpu_device_spin(FLASH_DELAY_MS);
                }
        }
}
Exemple #27
0
/* FreeRTOS malloc fail hook */
__WEAK__ void vApplicationMallocFailedHook(void)
{
	DEBUGSTR("DIE:ERROR:FreeRTOS: Malloc Failure!\r\n");
	taskDISABLE_INTERRUPTS();
	for (;; ) {}
}
Exemple #28
0
/* vApplicationMallocFailedHook() will only be called if
   configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook
   function that will get called if a call to pvPortMalloc() fails.
   pvPortMalloc() is called internally by the kernel whenever a task, queue,
   timer or semaphore is created.  It is also called by various parts of the
   demo application.  If heap_1.c or heap_2.c are used, then the size of the
   heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
   FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
   to query the size of free heap space that remains (although it does not
   provide information on how the remaining heap might be fragmented). */
void vApplicationMallocFailedHook(void) {
  taskDISABLE_INTERRUPTS();
  for(;;);
}
Exemple #29
0
void vAssertCalled( void )
{
	taskDISABLE_INTERRUPTS();
	for( ;; );
}
Exemple #30
0
void prvSystemSleep( TickType_t xExpectedIdleTime )
{
        uint32_t ulSleepTime;
        eSleepModeStatus eSleepStatus;

        /* A simple WFI() is executed in any of the cases below:
         * 1. the system has just booted and the dg_configINITIAL_SLEEP_DELAY_TIME has not yet
         *    passed
         * 2. the XTAL32K is used as the LP clock, the system has just woke up after clockless
         *    sleep and the LP clock has not yet settled.
         */
        if( !cm_lp_clk_is_avail() ) {
                __WFI();                                // Wait for an interrupt...
                return;
        }

        if (dg_configUSE_LP_CLK == LP_CLK_RCX) {
                // Update if a previous calibration was running and is finished.
                if (cm_rcx_calibration_is_on) {
                        if (cm_calibrate_rcx_update()) {
                                return;
                        }
                }
        }

        /*
         * Calculate the sleep time
         */
        ulSleepTime = pm_conv_ticks_2_prescaled_lpcycles(xExpectedIdleTime);

        /* Enter a critical section that will not effect interrupts bringing the MCU
         * out of sleep mode.
         */
        taskDISABLE_INTERRUPTS();

        DBG_CONFIGURE_LOW(CMN_TIMING_DEBUG, CMNDBG_CRITICAL_SECTION);

        DBG_SET_HIGH(CPM_USE_TIMING_DEBUG, CPMDBG_SLEEP_ENTER);

        /* Ensure it is still ok to enter the sleep mode. */
        eSleepStatus = eTaskConfirmSleepModeStatus();

        if( eSleepStatus == eAbortSleep ) {
                DBG_SET_LOW(CPM_USE_TIMING_DEBUG, CPMDBG_SLEEP_ENTER);

                /* A task has been moved out of the Blocked state since this macro was
                 * executed, or a context switch is being held pending. Do not enter a
                 * sleep state. Restart the tick and exit the critical section.
                 */
                taskENABLE_INTERRUPTS();
        }
        else {
#if (dg_configIMAGE_SETUP == DEVELOPMENT_MODE)
                uint32_t primask;
#endif

                if( eSleepStatus == eNoTasksWaitingTimeout )
                {
                        /* It is not necessary to configure an interrupt to bring the
                         * microcontroller out of its low power state at a fixed time in the
                         * future.
                         * Enter the low power state.
                         */
                        pm_sleep_enter( 0 );
                }
                else
                {
                        /* Configure an interrupt to bring the microcontroller out of its low
                         * power state at the time the kernel next needs to execute.
                         * Enter the low power state.
                         */
                        pm_sleep_enter( ulSleepTime );
                }

#if (dg_configIMAGE_SETUP == DEVELOPMENT_MODE)
                /* If the code stops at this point then the interrupts were enabled while they
                 * shouldn't be so.
                 */
                primask = __get_PRIMASK();
                ASSERT_WARNING(primask == 1);
#endif

                /* Wake-up! */
                pm_system_wake_up();
        }
}