int _gettimeofday_r(struct _reent *, struct timeval *__tp, void *__tzp) { taskENTER_CRITICAL(); uint_t t = sdk_system_get_time(); if (s_lastSysTime > t) { s_timeAdj += (uint_t)-1; } s_lastSysTime = t; taskEXIT_CRITICAL(); uint64_t usec = s_lastSysTime + s_timeAdj; __tp->tv_usec = usec; __tp->tv_sec = usec / 1000000; // DEBUG_PRINT("_gettimeofday_r:__tp->tv_sec=%08X, __tp->tv_usec=%08X, s_lastSysTime=%08X, s_timeAdj=%016llX\n", __tp->tv_sec, __tp->tv_usec, s_lastSysTime, s_timeAdj); return 0; }
void vNetworkBufferRelease( xNetworkBufferDescriptor_t * const pxNetworkBuffer ) { portBASE_TYPE xListItemAlreadyInFreeList; /* Ensure the buffer is returned to the list of free buffers before the counting semaphore is 'given' to say a buffer is available. */ taskENTER_CRITICAL(); { xListItemAlreadyInFreeList = listIS_CONTAINED_WITHIN( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); if( xListItemAlreadyInFreeList == pdFALSE ) { vListInsertEnd( &xFreeBuffersList, &( pxNetworkBuffer->xBufferListItem ) ); } configASSERT( xListItemAlreadyInFreeList == pdFALSE ); } taskEXIT_CRITICAL(); xSemaphoreGive( xNetworkBufferSemaphore ); iptraceNETWORK_BUFFER_RELEASED( pxNetworkBuffer ); }
void registerShellCommand(shellCommand * newCommand) { xCommandListItem * item = &xRegisteredCommands; xCommandListItem * newItem = (xCommandListItem *) pvPortMalloc(sizeof(xCommandListItem)); taskENTER_CRITICAL(); // Get to the last item in list while (item->next != NULL) { item = item->next; } // Create list item newItem->command = newCommand; newItem->next = NULL; // Add item to list item->next = newItem; taskEXIT_CRITICAL(); }
/** * start wdt internal * * \param mode watchdog mode * \param action action * \param count countdown value */ void bmc_start_wd_timer(unsigned char use, unsigned char action, unsigned short count) { if (!(wd_timer.timer_use & WD_TIMER_START)) { taskENTER_CRITICAL(); /* set watchdog timer values */ wd_timer.timer_use = use; wd_timer.timer_action = action; wd_timer.initial_count = count; wd_timer.present_count = count; wd_timer.timer_use |= WD_TIMER_START; /* start or restart watchdog timer */ watchdog_start(); taskEXIT_CRITICAL(); #ifdef CFG_CPCI wd_set = 1; #endif } }
void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { unsigned portBASE_TYPE uxLEDMask; if( uxLED < partstNUM_LEDs ) { uxLEDMask = 1UL << uxLED; taskENTER_CRITICAL(); { if( MCF_GPIO_PORTTC & uxLEDMask ) { MCF_GPIO_PORTTC &= ~uxLEDMask; } else { MCF_GPIO_PORTTC |= uxLEDMask; } } taskEXIT_CRITICAL(); } }
portBASE_TYPE FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister ) { static CLI_Definition_List_Item_t *pxLastCommandInList = &xRegisteredCommands; CLI_Definition_List_Item_t *pxNewListItem; portBASE_TYPE xReturn = pdFAIL; /* Check the parameter is not NULL. */ configASSERT( pxCommandToRegister ); /* Create a new list item that will reference the command being registered. */ pxNewListItem = ( CLI_Definition_List_Item_t * ) pvPortMalloc( sizeof( CLI_Definition_List_Item_t ) ); configASSERT( pxNewListItem ); if( pxNewListItem != NULL ) { taskENTER_CRITICAL(); { /* Reference the command being registered from the newly created list item. */ pxNewListItem->pxCommandLineDefinition = pxCommandToRegister; /* The new list item will get added to the end of the list, so pxNext has nowhere to point. */ pxNewListItem->pxNext = NULL; /* Add the newly created list item to the end of the already existing list. */ pxLastCommandInList->pxNext = pxNewListItem; /* Set the end of list marker to the new list item. */ pxLastCommandInList = pxNewListItem; } taskEXIT_CRITICAL(); xReturn = pdPASS; } return xReturn; }
void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { unsigned portBASE_TYPE uxLEDMask; if( uxLED < partstNUM_LEDs ) { uxLEDMask = xLEDs[ uxLED ]; taskENTER_CRITICAL(); { if( P3 & uxLEDMask ) { P3 &= ~uxLEDMask; } else { P3 |= uxLEDMask; } } taskEXIT_CRITICAL(); } }
void vDebugString( char *s ) { /*---------------------------------------------------------- Local variables ----------------------------------------------------------*/ portBASE_TYPE xStatus; /*---------------------------------------------------------- Clear interrupts while copying the string ----------------------------------------------------------*/ taskENTER_CRITICAL(); while ( *s ) { xStatus = xQueueSendToBack( xDebugQueue, s++, 0 ); if ( xStatus == errQUEUE_FULL ) { break; } } taskEXIT_CRITICAL(); }
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) { unsigned portBASE_TYPE uxLEDMask; if( uxLED < partstNUM_LEDs ) { uxLEDMask = xLEDs[ uxLED ]; taskENTER_CRITICAL(); { if( xValue ) { P3 |= uxLEDMask; } else { P3 &= ~uxLEDMask; } } taskEXIT_CRITICAL(); } }
void vWriteBufferToDisk( const char * const pcBuffer, unsigned long ulBufferLength ) { #ifdef USE_STDIO const char * const pcFileName = "c:\\trace.bin"; FILE *pf; taskENTER_CRITICAL(); { pf = fopen( pcFileName, "wb" ); if( pf ) { fwrite( pcBuffer, ( size_t ) ulBufferLength, ( unsigned short ) 1, pf ); fclose( pf ); } } taskEXIT_CRITICAL(); #else /* Stop warnings. */ ( void ) pcBuffer; ( void ) ulBufferLength; #endif /*USE_STDIO*/ }
void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { if( uxLED < partstMAX_LEDS ) { /* A critical section is used as the LEDs are also accessed from an interrupt. */ taskENTER_CRITICAL(); { if( ( ulGPIOState & ( 1UL << uxLED ) ) != 0UL ) { ulGPIOState &= ~( 1UL << uxLED ); } else { ulGPIOState |= ( 1UL << uxLED ); } MSS_GPIO_set_outputs( ulGPIOState ); } taskEXIT_CRITICAL(); } }
BaseType_t FreeRTOS_closesocket( xSocket_t xSocket ) { xNetworkBufferDescriptor_t *pxNetworkBuffer; xFreeRTOS_Socket_t *pxSocket; pxSocket = ( xFreeRTOS_Socket_t * ) xSocket; configASSERT( pxSocket ); configASSERT( pxSocket != FREERTOS_INVALID_SOCKET ); /* Socket must be unbound first, to ensure no more packets are queued on it. */ if( socketSOCKET_IS_BOUND( pxSocket ) != pdFALSE ) { taskENTER_CRITICAL(); { uxListRemove( &( pxSocket->xBoundSocketListItem ) ); } taskEXIT_CRITICAL(); } /* Now the socket is not bound the list of waiting packets can be drained. */ if( pxSocket->xWaitingPacketSemaphore != NULL ) { while( listCURRENT_LIST_LENGTH( &( pxSocket->xWaitingPacketsList ) ) > 0U ) { pxNetworkBuffer = ( xNetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &( pxSocket->xWaitingPacketsList ) ); uxListRemove( &( pxNetworkBuffer->xBufferListItem ) ); vNetworkBufferRelease( pxNetworkBuffer ); } vSemaphoreDelete( pxSocket->xWaitingPacketSemaphore ); } vPortFree( pxSocket ); return 0; } /* Tested */
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(); }
/* * ======== MessageQCopy_create ======== */ MessageQCopy_Handle MessageQCopy_create(UInt32 reserved, UInt32 * endpoint) { MessageQCopy_Object *obj = NULL; Bool found = FALSE; Int i; UInt16 queueIndex = 0; taskENTER_CRITICAL(&virtQueLock); if(reserved == MessageQCopy_ASSIGN_ANY){ /* Search the array for a free slot above reserved: */ for(i = MessageQCopy_MAX_RESERVED_ENDPOINT + 1; (i < MAXMESSAGEQOBJECTS) && (found == FALSE); i++){ if(!IS_VALID_MSGQUEOBJ(&mQueObj[i])){ queueIndex = i; found = TRUE; break; } } } else if((queueIndex = reserved) <= MessageQCopy_MAX_RESERVED_ENDPOINT){ if(!IS_VALID_MSGQUEOBJ(&mQueObj[queueIndex])){ found = TRUE; } } if(found){ if(MsgQueObjInit(&mQueObj[queueIndex]) != FALSE){ obj = &mQueObj[queueIndex]; *endpoint = queueIndex; } } taskEXIT_CRITICAL(&virtQueLock); return obj; }
void vPortFree( void *pv ) { unsigned char *puc = ( unsigned char * ) pv; xBlockLink *pxLink; if( pv != NULL ) { /* The memory being freed will have an xBlockLink structure immediately before it. */ puc -= heapSTRUCT_SIZE; /* This casting is to keep the compiler from issuing warnings. */ pxLink = ( void * ) puc; taskENTER_CRITICAL( &xMemLock ); { /* Add this block to the list of free blocks. */ xFreeBytesRemaining += pxLink->xBlockSize; prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) ); } taskEXIT_CRITICAL( &xMemLock ); } }
void stop_PWM_hardware() { taskENTER_CRITICAL(); pwmTCCRa = 0; #if defined( portUSE_TIMER0_PWM ) pwmTCCRb DDRD &= ~pwmDDRD; // PD6 OC0A (Pin 6) & PD5 OC0B (Pin 5) #elif defined( portUSE_TIMER1_PWM ) #if defined(__AVR_ATmega328P__) // Arduino DDRB &= ~pwmDDRB; // PB1 OC1A (Pin 9) & PB2 OC1B (Pin 10) #elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)|| defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644PA__)// Pololu SVP with 1284p DDRD &= ~pwmDDRD; // PD5 OC1A & PD4 OC1B #endif #endif taskEXIT_CRITICAL(); }
void vBSP430ledSet( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) { if (uxLED < ( unsigned portBASE_TYPE ) ucLEDDefnCount) { const xLEDDefn * pxLED = pxLEDDefn + uxLED; taskENTER_CRITICAL(); if (xValue > 0) { *pxLED->pucPxOUT |= pxLED->ucBIT; } else if (xValue < 0) { *pxLED->pucPxOUT ^= pxLED->ucBIT; } else { *pxLED->pucPxOUT &= ~pxLED->ucBIT; } taskEXIT_CRITICAL(); } }
static uint16_t prvGetPrivatePortNumber( void ) { static uint16_t usNextPortToUse = socketAUTO_PORT_ALLOCATION_START_NUMBER - 1; uint16_t usReturn; /* Assign the next port in the range. */ taskENTER_CRITICAL(); usNextPortToUse++; taskEXIT_CRITICAL(); /* Has it overflowed? */ if( usNextPortToUse == 0U ) { /* Don't go right back to the start of the dynamic/private port range numbers as any persistent sockets are likely to have been create first so the early port numbers may still be in use. */ usNextPortToUse = socketAUTO_PORT_ALLOCATION_RESET_NUMBER; } usReturn = FreeRTOS_htons( usNextPortToUse ); return usReturn; } /* Tested */
struct eth_frame* retrieve_frame(void) { struct eth_frame *frame = NULL; taskENTER_CRITICAL(); if(eth_buffer.head) { frame = eth_buffer.head; if(eth_buffer.head->next) { eth_buffer.head = eth_buffer.head->next; eth_buffer.head->prev = NULL; } else { eth_buffer.head = NULL; eth_buffer.tail = NULL; } } taskEXIT_CRITICAL(); return frame; }
void vWriteMessageToDisk( const char * const pcMessage ) { #ifdef USE_STDIO const char * const pcFileName = "c:\\RTOSlog.txt"; const char * const pcSeparator = "\r\n-----------------------\r\n"; FILE *pf; taskENTER_CRITICAL(); { pf = fopen( pcFileName, "a" ); if( pf != NULL ) { fwrite( pcMessage, strlen( pcMessage ), ( unsigned short ) 1, pf ); fwrite( pcSeparator, strlen( pcSeparator ), ( unsigned short ) 1, pf ); fclose( pf ); } } taskEXIT_CRITICAL(); #else /* Stop warnings. */ ( void ) pcMessage; #endif /*USE_STDIO*/ }
unsigned portSHORT vActivateQueue(TaskToken taskToken, unsigned portSHORT usNumElement) { taskENTER_CRITICAL(); { //detect queue already exist if (xTaskQueueHandles[taskToken->enTaskID] == NULL) { //trim requested queue size usNumElement = (usNumElement > MAX_QUEUE_REQ_SIZE) ? MAX_QUEUE_REQ_SIZE : usNumElement; //create task queue memory xTaskQueueHandles[taskToken->enTaskID] = xQueueCreate(usNumElement, sizeof(MessagePacket)); } else { //TODO work out how to return existing queue size usNumElement = 0; } } taskEXIT_CRITICAL(); return usNumElement; }
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) { EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup; EventBits_t uxReturn; /* Check the user is not attempting to clear the bits used by the kernel itself. */ configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); taskENTER_CRITICAL(); { traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear ); /* The value returned is the event group value prior to the bits being cleared. */ uxReturn = pxEventBits->uxEventBits; /* Clear the bits. */ pxEventBits->uxEventBits &= ~uxBitsToClear; } taskEXIT_CRITICAL(); return uxReturn; }
vTaskDelay(100/portTICK_RATE_MS); receiver(); } } correction(); vTaskDelay(500/portTICK_RATE_MS); } } void sender(void){ #ifdef MASTERMODE uint8_t i; for(i=1;i<=MAX_SLAVE_CLOCK;i++){ taskENTER_CRITICAL(); unsigned long int timeSender=timeProt.saveTime[i].second; taskEXIT_CRITICAL(); if(timeSender!=0){ //printf("id : %d , delay response time second : %lu",i,timeSender);
xNetworkBufferDescriptor_t *pxNetworkBufferGet( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ) { xNetworkBufferDescriptor_t *pxReturn = NULL; /*_RB_ The current implementation only has a single size memory block, so the requested size parameter is not used (yet). */ ( void ) xRequestedSizeBytes; /* If there is a semaphore available, there is a network buffer available. */ if( xSemaphoreTake( xNetworkBufferSemaphore, xBlockTimeTicks ) == pdPASS ) { /* Protect the structure as it is accessed from tasks and interrupts. */ taskENTER_CRITICAL(); { pxReturn = ( xNetworkBufferDescriptor_t * ) listGET_OWNER_OF_HEAD_ENTRY( &xFreeBuffersList ); uxListRemove( &( pxReturn->xBufferListItem ) ); } taskEXIT_CRITICAL(); iptraceNETWORK_BUFFER_OBTAINED( pxReturn ); } else { iptraceFAILED_TO_OBTAIN_NETWORK_BUFFER(); } return pxReturn; }
BaseType_t FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister ) { static CLI_Definition_List_Item_t *pxLastCommandInList = &xRegisteredCommands; CLI_Definition_List_Item_t *pxNewListItem; BaseType_t xReturn = pdFAIL; // проверим не пустая ли команда configASSERT( pxCommandToRegister ); // Создать новый элемент списка, который будет ссылаться на команду pxNewListItem = ( CLI_Definition_List_Item_t * ) pvPortMalloc( sizeof( CLI_Definition_List_Item_t ) ); configASSERT( pxNewListItem ); if( pxNewListItem != NULL ) { taskENTER_CRITICAL(); { // ссылка на команду в списке pxNewListItem->pxCommandLineDefinition = pxCommandToRegister; // указатель на следующий элемент списка pxNewListItem->pxNext = NULL; // Добавим вновь созданный элемент списка в конец уже существующего списка pxLastCommandInList->pxNext = pxNewListItem; // Set the end of list marker to the new list item. pxLastCommandInList = pxNewListItem; } taskEXIT_CRITICAL(); xReturn = pdPASS; } return xReturn; }
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime ) { portBASE_TYPE xReturn = pdFALSE; /* The ISR is processing characters is so just add to the end of the queue. */ if( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) ) { xReturn = pdTRUE; } else { /* The queue is probably full. */ xReturn = pdFALSE; } /* Make sure that the interrupt will fire in the case where: Currently sending so the Tx Complete will fire. Not sending so the Empty will fire. */ taskENTER_CRITICAL(); UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY ); taskEXIT_CRITICAL(); return xReturn; }
void StartFsTask(void const * argument) { printf("Fs task started\n"); taskENTER_CRITICAL(); TREEVIEW_Handle filesystem = TREEVIEW_CreateEx( 500, 0, 300, 480, 0, WM_CF_SHOW, TREEVIEW_CF_AUTOSCROLLBAR_V | TREEVIEW_CF_AUTOSCROLLBAR_H | TREEVIEW_CF_ROWSELECT, GUI_ID_TREEVIEW0 ); TREEVIEW_SetFont(filesystem, GUI_FONT_24_ASCII); scan_files("", &filesystem); TREEVIEW_ITEM_ExpandAll(TREEVIEW_GetItem(filesystem, 0, TREEVIEW_GET_FIRST)); WM_SetCallback(WM_HBKWIN, _cbHBKWIN); WM_SetFocus(filesystem); taskEXIT_CRITICAL(); while(1) { osDelay(5000); } }
time_t ClockTimestamp() { t_RTCC myrtcc; time_t epoch_time; struct tm ts; //char rtccString[200]; RTCCRead(&myrtcc); /*sprintf(rtccString, "RTC %.4d-%.2d-%.2d / %.2d:%.2d.%.2d / %d\r\n",(myrtcc.year), myrtcc.month, myrtcc.day, myrtcc.hour, myrtcc.min, myrtcc.sec, myrtcc.dweek); UARTWrite(1, rtccString);*/ ts.tm_year = 100+myrtcc.year; ts.tm_mon = myrtcc.month-1; ts.tm_wday = myrtcc.dweek; ts.tm_mday = myrtcc.day; ts.tm_hour = myrtcc.hour; ts.tm_min = myrtcc.min; ts.tm_sec = myrtcc.sec; ts.tm_isdst = 0;//DST flag explicitly set to NULL to avoid random assigment during mktime call taskENTER_CRITICAL();//making it task critical as this function was making 3600 jump issue epoch_time = mktime(&ts);//jump was due to isdst flag in tm structure taskEXIT_CRITICAL(); return epoch_time; }
static void prvCheckForValidListAndQueue( void ) { /* Check that the list from which active timers are referenced, and the queue used to communicate with the timer service, have been initialised. */ taskENTER_CRITICAL(); { if( xTimerQueue == NULL ) { vListInitialise( &xActiveTimerList1 ); vListInitialise( &xActiveTimerList2 ); pxCurrentTimerList = &xActiveTimerList1; pxOverflowTimerList = &xActiveTimerList2; xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) ); configASSERT( xTimerQueue ); #if ( configQUEUE_REGISTRY_SIZE > 0 ) { if( xTimerQueue != NULL ) { vQueueAddToRegistry( xTimerQueue, "TmrQ" ); } else { mtCOVERAGE_TEST_MARKER(); } } #endif /* configQUEUE_REGISTRY_SIZE */ } else { mtCOVERAGE_TEST_MARKER(); } } taskEXIT_CRITICAL(); }
void vModeSmsStart(uint8_t option) { if (state != MODE_SMS_STATE_STOP) return; taskENTER_CRITICAL(); { eep_params.mode_sms_use_slider_as_shutter = 0; if (option & MODE_SMS_OPTION_SHUTTER) { eep_params.mode_sms_use_slider_as_shutter = 1; } for (uint8_t motor = 0; motor < SM_MOTORS_USED; motor++) { if (eep_params.mode_sms_accel_count[motor] == 0) { eep_params.mode_sms_accel_count[motor] = 1; } if (eep_params.mode_sms_decel_count[motor] == 0) { eep_params.mode_sms_decel_count[motor] = 1; } while (true) { if (mode_smsCOUNT_SUM_TOO_HIGH(motor) && eep_params.mode_sms_leadin_count[motor] > 0) { eep_params.mode_sms_leadin_count[motor]--; } if (mode_smsCOUNT_SUM_TOO_HIGH(motor) && eep_params.mode_sms_leadout_count[motor] > 0) { eep_params.mode_sms_leadout_count[motor]--; } if (mode_smsCOUNT_SUM_TOO_HIGH(motor) && eep_params.mode_sms_accel_count[motor] > 1) { eep_params.mode_sms_accel_count[motor]--; } if (mode_smsCOUNT_SUM_TOO_HIGH(motor) && eep_params.mode_sms_decel_count[motor] > 1) { eep_params.mode_sms_decel_count[motor]--; } if (!mode_smsCOUNT_SUM_TOO_HIGH(motor)) { break; } } int32_t steps = eep_params.mode_sms_positions[1].pos[motor] - eep_params.mode_sms_positions[0].pos[motor]; //int32_t img_count = (int32_t)eep_params.mode_sms_count; int32_t step_count = (int32_t)eep_params.mode_sms_count - 1; int32_t ramp_count = (int32_t)eep_params.mode_sms_accel_count[motor] + (int32_t)eep_params.mode_sms_decel_count[motor]; int32_t lead_count = (int32_t)eep_params.mode_sms_leadin_count[motor] + (int32_t)eep_params.mode_sms_leadout_count[motor]; int32_t move_count = step_count - lead_count; int32_t run_count = step_count - lead_count - ramp_count; if (move_count > 0 && steps != 0) { run_steps[motor] = 2 * steps / (2 * run_count + ramp_count); accel_steps_x1000[motor] = run_steps[motor] * 1000 / (int32_t)eep_params.mode_sms_accel_count[motor]; decel_steps_x1000[motor] = run_steps[motor] * 1000 / (int32_t)eep_params.mode_sms_decel_count[motor]; } else { run_steps[motor] = 0; accel_steps_x1000[motor] = 0; decel_steps_x1000[motor] = 0; } } test_mode = mode_smsTEST_NONE; current_step = 0; current_loop = 0; step_timer = 0; interval_timer = 0; vModeSmsCalcTime(); overall_time = eep_params.mode_sms_count * eep_params.mode_sms_interval; state = MODE_SMS_STATE_WAKE_SM; xTimerStart(xModeSmsControlTimer, 0); } taskEXIT_CRITICAL(); }