• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GLOBAL_LOCK函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GLOBAL_LOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ GLOBAL_LOCK函数的具体用法?C++ GLOBAL_LOCK怎么用?C++ GLOBAL_LOCK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GLOBAL_LOCK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: NATIVE_PROFILE_CLR_HARDWARE

HRESULT CLR_HW_Hardware::TransferAllInterruptsToApplicationQueue()
{
    NATIVE_PROFILE_CLR_HARDWARE();
    TINYCLR_HEADER();

    while(true)
    {
        HalInterruptRecord* rec;

        {
            GLOBAL_LOCK(irq1);

            rec = m_interruptData.m_HalQueue.Peek();
        }

        if(rec == NULL) break;

        CLR_RT_ApplicationInterrupt* queueRec = (CLR_RT_ApplicationInterrupt*)CLR_RT_Memory::Allocate_And_Erase( sizeof(CLR_RT_ApplicationInterrupt), CLR_RT_HeapBlock::HB_CompactOnFailure );  CHECK_ALLOCATION(queueRec);

        queueRec->m_interruptPortInterrupt.m_data1   =                                          rec->m_data1;
        queueRec->m_interruptPortInterrupt.m_data2   =                                          rec->m_data2;
        queueRec->m_interruptPortInterrupt.m_data3   =                                          rec->m_data3;
        queueRec->m_interruptPortInterrupt.m_time    =                                          rec->m_time;
        queueRec->m_interruptPortInterrupt.m_context = (CLR_RT_HeapBlock_NativeEventDispatcher*)rec->m_context;

        m_interruptData.m_applicationQueue.LinkAtBack( queueRec ); ++m_interruptData.m_queuedInterrupts;

        {
            GLOBAL_LOCK(irq2);
            
            m_interruptData.m_HalQueue.Pop();
        }
    }

    if(m_interruptData.m_queuedInterrupts == 0)
    {
        TINYCLR_SET_AND_LEAVE(CLR_E_NO_INTERRUPT);
    }

    TINYCLR_CLEANUP();

    if(CLR_E_OUT_OF_MEMORY == hr)
    {
        // if there is no memory left discard all interrupts to avoid getting into a death spiral of OOM exceptions
        {
            GLOBAL_LOCK(irq3);

            while(!m_interruptData.m_HalQueue.IsEmpty())
            {
                m_interruptData.m_HalQueue.Pop();
            }
        }
    }    
    
    TINYCLR_CLEANUP_END();
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:56,代码来源:InterruptHandler.cpp


示例2: NATIVE_PROFILE_PAL_COM

int USART_Driver::Read( int ComPortNum, char* Data, size_t size )
{
    NATIVE_PROFILE_PAL_COM();
    if((ComPortNum < 0) || (ComPortNum >= TOTAL_USART_PORT)) {ASSERT(FALSE); return -1;}
    if(Data == NULL                                        )                 return -1;

    HAL_USART_STATE& State = Hal_Usart_State[ComPortNum];

    if ( IS_POWERSAVE_ENABLED(State) || (!IS_USART_INITIALIZED(State))) return -1;


    int CharsRead = 0;

    while(CharsRead < size)
    {
        // keep interrupts off only during pointer movement so we are atomic
        GLOBAL_LOCK(irq);
        size_t toRead;
        UINT8 *Src;

        toRead = size - CharsRead;
        Src = State.RxQueue.Pop( toRead );
        if( NULL == Src )
            break;

        // Check if FIFO level has just passed or gotten down to the low water mark
        if(State.RxQueue.NumberOfElements() <= State.RxBufferLowWaterMark && (State.RxQueue.NumberOfElements() + toRead) > State.RxBufferLowWaterMark)
        {
            if( USART_FLAG_STATE(State, HAL_USART_STATE::c_RX_SWFLOW_CTRL) )
            {
                // Clear our XOFF state
                SendXON( ComPortNum, XOFF_FLAG_FULL );
            }
            if( USART_FLAG_STATE(State, HAL_USART_STATE::c_RX_HWFLOW_CTRL) )
            {
                CPU_USART_RxBufferFullInterruptEnable(ComPortNum, TRUE);
            }
        }
        memcpy(&Data[CharsRead], Src, toRead);   // Copy data from queue to Read buffer
        CharsRead += toRead;
    }

    {
        GLOBAL_LOCK(irq);
     
        State.fDataEventSet  = FALSE;        

        if(!State.RxQueue.IsEmpty())
        {
            SetEvent( ComPortNum, USART_EVENT_DATA_CHARS );
        }
     }

    return CharsRead;
}
开发者ID:TinkerPot,项目名称:.NETMF_for_LPC17xx,代码行数:55,代码来源:usart.cpp


示例3: NATIVE_PROFILE_PAL_ASYNC_PROC_CALL

void HAL_COMPLETION::DequeueAndExec()
{
    NATIVE_PROFILE_PAL_ASYNC_PROC_CALL();
    GLOBAL_LOCK(irq);

    HAL_COMPLETION* ptr     = (HAL_COMPLETION*)g_HAL_Completion_List.FirstNode();
    HAL_COMPLETION* ptrNext = (HAL_COMPLETION*)ptr->Next();

    // waitforevents does not have an associated completion, therefore we need to verify
    // than their is a next completion and that the current one has expired.
    if(ptrNext)
    {
        ASSERT(ptr->EventTimeTicks <= HAL_Time_CurrentTicks());
        
        Events_Set(SYSTEM_EVENT_FLAG_SYSTEM_TIMER);

        ptr->Unlink();

        //
        // In case there's no other request to serve, set the next interrupt to be 356 years since last powerup (@25kHz).
        //
        HAL_Time_SetCompare( ptrNext->Next() ? ptrNext->EventTimeTicks : HAL_Completion_IdleValue );

#if defined(_DEBUG)
        ptr->EventTimeTicks = 0;
#endif  // defined(_DEBUG)

        // let the ISR turn on interrupts, if it needs to
        ptr->Execute();
    }
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:31,代码来源:Completions.cpp


示例4: Events_Clear

void Events_Clear( UINT32 Events )
{
    NATIVE_PROFILE_PAL_EVENTS();
    GLOBAL_LOCK(irq);

    SystemEvents &= ~Events;
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:7,代码来源:events.cpp


示例5: GLOBAL_LOCK

BOOL USART_Driver::ConnectEventSink( int ComPortNum, int EventType, void* pContext, PFNUsartEvent pfnUsartEvtHandler, void** ppArg )
{
    if((ComPortNum < 0) || (ComPortNum >= TOTAL_USART_PORT)) return FALSE;

    {
        GLOBAL_LOCK(irq);

        HAL_USART_STATE& State = Hal_Usart_State[ComPortNum];


        State.PortIndex = ComPortNum;
        
        if(ppArg != NULL) *ppArg = (void*)ComPortNum;

        if(EventType == USART_EVENT_TYPE_DATA)
        {
            State.UsartDataEventCallback = pfnUsartEvtHandler;
            State.DataContext            = pContext;
        }
        else if(EventType == USART_EVENT_TYPE_ERROR)
        {
            State.UsartErrorEventCallback = pfnUsartEvtHandler;
            State.ErrorContext            = pContext;
        }

    }


    return TRUE;
}
开发者ID:TinkerPot,项目名称:.NETMF_for_LPC17xx,代码行数:30,代码来源:usart.cpp


示例6: IRQToIRQVector

BOOL MC9328MXL_AITC_Driver::ActivateInterrupt( UINT32 Irq_Index, BOOL Fast, HAL_CALLBACK_FPN ISR, void* ISR_Param, UINT8 Priority )
{
    // figure out the interrupt
    IRQ_VECTORING* IsrVector = IRQToIRQVector( Irq_Index ); if(!IsrVector) return FALSE;

    {
        GLOBAL_LOCK(irq);

        MC9328MXL_AITC& AITC = MC9328MXL::AITC();

        // disable this interrupt while we change it
        AITC.INTDISNUM = IsrVector->Index;

        // set the correct type
        AITC.SetType( IsrVector->Index, Fast );

        // set the correct priority
        AITC.SetPriority( IsrVector->Index, Priority );

        // set the vector
        IsrVector->Handler.Initialize( ISR, ISR_Param );

        // enable the interrupt if we have a vector
        AITC.INTENNUM = IsrVector->Index;
    }

    return TRUE;
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:28,代码来源:MC9328MXL__AITC.cpp


示例7: GLOBAL_LOCK

void LPC22XX_USART_Driver::TxBufferEmptyInterruptEnable( int ComPortNum, BOOL Enable  )
{
    GLOBAL_LOCK(irq);

    LPC22XX_USART& USARTC = LPC22XX::UART(ComPortNum);
    
    ASSERT(LPC22XX_USART_Driver::IsValidPortNum(ComPortNum));    

    if (Enable)
    {
       USARTC.SEL2.IER.UART_IER |=  (LPC22XX_USART::UART_IER_THREIE);      

        char c;
        for (int i=0; i<2; i++)
        {
            if (USART_RemoveCharFromTxBuffer( ComPortNum, c ))
            {
                WriteCharToTxBuffer( ComPortNum, c );
                Events_Set( SYSTEM_EVENT_FLAG_COM_OUT );
            }
            else
                break;
        }

       
    }
    else
    {
       USARTC.SEL2.IER.UART_IER &= ~(LPC22XX_USART::UART_IER_THREIE);              
    }

}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:32,代码来源:LPC22XX__USART.cpp


示例8: GLOBAL_LOCK

BOOL LPC22XX_GPIO_Driver::Uninitialize()
{
    GLOBAL_LOCK(irq);

// TODO Implementation
    return TRUE;
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:7,代码来源:LPC22XX__GPIO.cpp


示例9: PinToBit

void AT91_GPIO_Driver::EnableOutputPin( GPIO_PIN pin, BOOL initialState )
{

    
    UINT32   bitmask  = 1 << PinToBit( pin );
    UINT32  port = PinToPort( pin );


    AT91_PIO &pioX = AT91::PIO (port);

    GLOBAL_LOCK(irq);

    pioX.PIO_PER = bitmask;                   // Enable PIO function
    
        if(initialState)
        pioX.PIO_SODR = bitmask;
    else
        pioX.PIO_CODR = bitmask;

    pioX.PIO_OER = bitmask;                   // Enable Output

    PIN_ISR_DESCRIPTOR& pinIsr = g_AT91_GPIO_Driver.m_PinIsr[ pin ];

    pinIsr.m_intEdge = GPIO_INT_NONE;
    pinIsr.m_isr     = STUB_GPIOISRVector;
    pinIsr.m_param   = NULL;

}
开发者ID:prabby,项目名称:miniclr,代码行数:28,代码来源:AT91_GPIO.cpp


示例10: IRQToIRQVector

BOOL LPC24XX_VIC_Driver::ActivateInterrupt( UINT32 Irq_Index, BOOL Fast, HAL_CALLBACK_FPN ISR, void* ISR_Param )
{
    // figure out the interrupt
    IRQ_VECTORING* IsrVector = IRQToIRQVector( Irq_Index ); if(!IsrVector) return FALSE;

    {
        GLOBAL_LOCK(irq);

        LPC24XX_VIC& VIC = LPC24XX::VIC();

        // disable this interrupt while we change it
        VIC.INTENCLR = 1 << IsrVector->Index;

        // set the vector
        IsrVector->Handler.Initialize( ISR, ISR_Param );
        
        // Use Vector Address register to identify the source of interrupt
        VIC.VECTADDR[Irq_Index] = Irq_Index;

        // enable the interrupt if we have a vector
        VIC.INTENABLE = 1 << IsrVector->Index;
    }

    return TRUE;
}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:25,代码来源:LPC24XX__VIC.cpp


示例11: NATIVE_PROFILE_PAL_COM

void I2C_Driver::Cancel( I2C_HAL_XACTION* xAction, bool signal )
{
    NATIVE_PROFILE_PAL_COM();
    ASSERT(xAction);
    
    if(xAction == NULL) return;
    
    GLOBAL_LOCK(irq);
   
    switch(xAction->GetState())
    {
        // only one xAction will efer be in processing for every call to Abort
        case I2C_HAL_XACTION::c_Status_Processing:
            
            I2C_Internal_XActionStop();

            // fall through...

        case I2C_HAL_XACTION::c_Status_Scheduled:
        case I2C_HAL_XACTION::c_Status_Completed:
        case I2C_HAL_XACTION::c_Status_Aborted:

            xAction->Abort();

            xAction->SetState(I2C_HAL_XACTION::c_Status_Cancelled);

            StartNext();
            
            break;

        case I2C_HAL_XACTION::c_Status_Idle: // do nothing since we aren't enqueued yet
            break;
    }
}
开发者ID:prabby,项目名称:miniclr,代码行数:34,代码来源:i2c.cpp


示例12: TTWAIN_SupportsCompressionType

	/*---------------------------------------------------------------------------*/
	int TTWAIN_SupportsCompressionType(TW_UINT16 comprType)
	{
		int rc;
		TUINT32 size;
		int found = FALSE;
		TW_ENUMERATION *container = 0;
		TW_HANDLE handle = 0;

		if (!TTWAIN_IsCapCompressionSupported())
			return FALSE;
		rc = TTWAIN_GetCap(ICAP_COMPRESSION, TWON_ENUMERATION, (void *)0, &size);
		if (!rc || !size)
			return FALSE;

		handle = GLOBAL_ALLOC(GMEM_FIXED, size);
		if (!handle)
			return FALSE;

		container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);

		rc = TTWAIN_GetCap(ICAP_COMPRESSION, TWON_ENUMERATION, (void *)container, 0);

		if (!rc)
			goto done;
		found = TTWAIN_IsItemInList(container->ItemList, &comprType,
									container->NumItems, DCItemSize[container->ItemType]);
		found = TRUE;
	done:
		if (handle) {
			GLOBAL_UNLOCK(handle);
			GLOBAL_FREE(handle);
		}
		return found;
	}
开发者ID:GREYFOXRGR,项目名称:opentoonz,代码行数:35,代码来源:ttwain_util.c


示例13: TTWAIN_SupportsPixelType

	/*---------------------------------------------------------------------------*/
	int TTWAIN_SupportsPixelType(TTWAIN_PIXTYPE pix_type)
	{
		TW_HANDLE handle;
		TW_ENUMERATION *container;
		int rc, found = FALSE;
		TUINT32 size4data;
		TW_UINT16 twPix;

		twPix = PixType[pix_type].type;
		rc = TTWAIN_GetCap(ICAP_PIXELTYPE, TWON_ENUMERATION, (void *)0, &size4data);
		if (!rc)
			return FALSE;
		if (!size4data)
			return FALSE;
		handle = GLOBAL_ALLOC(GMEM_FIXED, size4data);
		if (!handle)
			return FALSE;

		container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);
		rc = TTWAIN_GetCap(ICAP_PIXELTYPE, TWON_ENUMERATION, (void *)container, 0);

		if (!rc)
			goto done;
		found = TTWAIN_IsItemInList(container->ItemList, &twPix,
									container->NumItems, DCItemSize[container->ItemType]);

	done:
		GLOBAL_UNLOCK(handle);
		GLOBAL_FREE(handle);
		return found;
	}
开发者ID:GREYFOXRGR,项目名称:opentoonz,代码行数:32,代码来源:ttwain_util.c


示例14: ASSERT

BOOL LPC24XX_TIMER_Driver::Initialize( UINT32 Timer, HAL_CALLBACK_FPN ISR, void* ISR_Param )
{
    ASSERT(Timer < c_MaxTimers);

    GLOBAL_LOCK(irq);

    if(g_LPC24XX_TIMER_Driver.m_configured[Timer] == TRUE) return FALSE;

    //--//

    if(ISR)
    {
        if(!CPU_INTC_ActivateInterrupt( LPC24XX_TIMER::getIntNo(Timer) , ISR, ISR_Param )) return FALSE;
    }

    LPC24XX_TIMER& TIMER = LPC24XX::TIMER( Timer );

    TIMER.TCR = LPC24XX_TIMER::TCR_TEN;

    //--//

    g_LPC24XX_TIMER_Driver.m_configured[Timer] = TRUE;

    return TRUE;
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:25,代码来源:LPC24XX__TIMER.cpp


示例15: Watchdog_LastOccurence

BOOL Watchdog_LastOccurence( INT64& time, INT64& timeout, UINT32& assembly, UINT32& method, BOOL fSet )
{
    GLOBAL_LOCK(irq);

    Watchdog_Driver::WatchdogEvent last; 

    if(fSet)
    {
        last.Time     = time;
        last.Timeout  = timeout;
        last.Assembly = assembly;
        last.Method   = method;
    }
    
    BOOL fRes = Watchdog_Driver::LastOccurence( last, fSet );

    if(!fSet && fRes)
    {
        time     = last.Time;
        timeout  = last.Timeout;
        assembly = last.Assembly;
        method   = last.Method;
    }

    return fRes;
}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:26,代码来源:Watchdog_functions.cpp


示例16: ASSERT

void LPC24XX_USART_Driver::ProtectPins ( int ComPortNum, BOOL On )
{
    ASSERT(LPC24XX_USART_Driver::IsValidPortNum(ComPortNum));    

    static BOOL COM1_PinsProtected = TRUE;   // start out doing work on first unprotect
    static BOOL COM2_PinsProtected = TRUE;   // start out doing work on first unprotect
    static BOOL COM3_PinsProtected = TRUE;   // start out doing work on first unprotect
    static BOOL COM4_PinsProtected = TRUE;   // start out doing work on first unprotect

    GLOBAL_LOCK(irq);

    UINT32                  SER_TXD;
    UINT32                  SER_RXD;
    BOOL*                   PinsProtected;

    switch(ComPortNum)
    {
    case c_COM1: SER_TXD = LPC24XX_USART::c_SER1_TXD; SER_RXD = LPC24XX_USART::c_SER1_RXD; PinsProtected = &COM1_PinsProtected; break;
    case c_COM2: SER_TXD = LPC24XX_USART::c_SER2_TXD; SER_RXD = LPC24XX_USART::c_SER2_RXD; PinsProtected = &COM2_PinsProtected; break;
    case c_COM3: SER_TXD = LPC24XX_USART::c_SER3_TXD; SER_RXD = LPC24XX_USART::c_SER3_RXD; PinsProtected = &COM3_PinsProtected; break;
    case c_COM4: SER_TXD = LPC24XX_USART::c_SER4_TXD; SER_RXD = LPC24XX_USART::c_SER4_RXD; PinsProtected = &COM4_PinsProtected; break;
    default: return;
    }

    if (On) 
    {
    
       if(!*PinsProtected)
        {
            *PinsProtected = TRUE;

            TxBufferEmptyInterruptEnable( ComPortNum, FALSE );
            // TODO Add config for uart pin protected state
            CPU_GPIO_EnableOutputPin( SER_TXD, RESISTOR_DISABLED );

            RxBufferFullInterruptEnable( ComPortNum, FALSE );
            // TODO Add config for uart pin protected state
            CPU_GPIO_EnableOutputPin( SER_RXD, RESISTOR_DISABLED );
        }
    }
    else 
    {
        if(*PinsProtected)
        {
            *PinsProtected = FALSE;

            // Connect pin to UART
            CPU_GPIO_DisablePin( SER_TXD, RESISTOR_DISABLED, GPIO_ATTRIBUTE_NONE, GPIO_ALT_MODE_1 );

            // Connect pin to UART
            CPU_GPIO_DisablePin( SER_RXD, RESISTOR_DISABLED, GPIO_ATTRIBUTE_NONE, GPIO_ALT_MODE_1 );

            TxBufferEmptyInterruptEnable( ComPortNum, TRUE );

            RxBufferFullInterruptEnable( ComPortNum, TRUE );

        }
    }
    
}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:60,代码来源:LPC24XX__USART.cpp


示例17: IRQToIRQVector

BOOL AT91_AIC_Driver::ActivateInterrupt(UINT32 Irq_Index, BOOL Fast, HAL_CALLBACK_FPN ISR, void* ISR_Param)
{
    // figure out the interrupt
    IRQ_VECTORING* IsrVector = IRQToIRQVector( Irq_Index );
    if(!IsrVector) 
        return FALSE;

    AT91_AIC &aic = AT91::AIC();

    GLOBAL_LOCK(irq);

    // disable this interrupt while we change it
    aic.AIC_IDCR= (0x01 << Irq_Index);

    // Clear the interrupt on the interrupt controller
    aic.AIC_ICCR = (0x01 << Irq_Index);
        
    // set the vector
    IsrVector->Handler.Initialize( ISR, ISR_Param );

    // enable the interrupt if we have a vector
    aic.AIC_IECR= 0x01<<Irq_Index;

    return TRUE;
}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:25,代码来源:AT91_AIC.cpp


示例18: CPU_USART_Initialize

BOOL CPU_USART_Initialize( int ComPortNum, int BaudRate, int Parity, int DataBits, int StopBits, int FlowValue )
{
    if (ComPortNum >= TOTAL_USART_PORT)
        return FALSE;

    if (Parity >= USART_PARITY_MARK)
        return FALSE;

    GLOBAL_LOCK(irq);

    ptr_USART_TypeDef uart = g_STM32F4_Uart_Ports[ComPortNum];
    UINT32 clk;

    // enable UART clock
    if (ComPortNum == 5)
    {   // COM6 on APB2
        RCC->APB2ENR |= RCC_APB2ENR_USART6EN;
        clk = SYSTEM_APB2_CLOCK_HZ;
    }
    else if (ComPortNum == 0)
    {   // COM1 on APB2
        RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
        clk = SYSTEM_APB2_CLOCK_HZ;
    }
    else if (ComPortNum < 5)
    {   // COM2-5 on APB1
        RCC->APB1ENR |= RCC_APB1ENR_USART2EN >> 1 << ComPortNum;
        clk = SYSTEM_APB1_CLOCK_HZ;
    }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:29,代码来源:STM32F4_usart_functions.cpp


示例19: CPU_USB_ProtectPins

// ---------------------------------------------------------------------------
BOOL CPU_USB_ProtectPins(int core, BOOL On)
{
    USB_CONTROLLER_STATE *State;
    USBD_HANDLE_T hUsb = USB_HANDLE(core);

    GLOBAL_LOCK(irq);

    if (core >= MAX_USB_CORE) return FALSE;
    State = USB_STATE(core);

    if (On)
    {
        // Clear queues
        for (int epNum = 1; epNum < State->EndpointCount; epNum++)
        {
            if (State->Queues[epNum] != NULL && State->IsTxQueue[epNum])
                State->Queues[epNum]->Initialize();
        }
#if 0 // Don't disconnect on CDC
        // Make soft disconnect and set detached state
        USBD_Connect(hUsb, 0); // Disconnect
        State->DeviceState = USB_DEVICE_STATE_DETACHED;
        USB_StateCallback(State);
#endif
    } else {
        // Make soft connect and set attached state
        USBD_Connect(hUsb, 1); // Connect
        State->DeviceState = USB_DEVICE_STATE_ATTACHED;
        USB_StateCallback(State);
    }

    return TRUE;
}
开发者ID:meikeric,项目名称:netmf-lpc43xx,代码行数:34,代码来源:LPC43XX_USB.cpp


示例20: __section

BOOL __section(SectionForFlashOperations) SAM7X_BS_Driver::ChipReadOnly(void * context, BOOL On, UINT32 ProtectionKey )
{
    // Internal setting for WriteProtection
    AT91_BL_EFC &efc0 = AT91_BL_EFC::BL_EFC(0);
    AT91_BL_EFC &efc1 = AT91_BL_EFC::BL_EFC(1);;
    int i;
    unsigned char command; 

    // Set Lock/Unlock command
    command = (On == TRUE) ? AT91_BL_EFC::MC_FCMD_LOCK : AT91_BL_EFC::MC_FCMD_UNLOCK;

    // Set EFC Mode Register - number of cycles during 1 microsecond
    efc0.EFC_FMR = (efc0.EFC_FMR & ~AT91_BL_EFC::MC_FMCN) | ((SYSTEM_CYCLE_CLOCK_HZ / 1000000) << 16);
    efc1.EFC_FMR = (efc1.EFC_FMR & ~AT91_BL_EFC::MC_FMCN) | ((SYSTEM_CYCLE_CLOCK_HZ / 1000000) << 16);

    {
        GLOBAL_LOCK(irq);

        // Lock regions of EFC0 controller (1st FLASH block)
        // Lock regions of EFC1 controller (2nd FLASH block)
        for(i=0; i<16; i++ )
        {
            efc0.EFC_FCR = (AT91_BL_EFC::MC_KEY_VALUE | ((i*PAGES_IN_REGION) << 8) | command);
            efc1.EFC_FCR = (AT91_BL_EFC::MC_KEY_VALUE | ((i*PAGES_IN_REGION) << 8) | command);

            // Wait EFC ready 
            while(  ((efc0.EFC_FSR & AT91_BL_EFC::MC_FRDY) != AT91_BL_EFC::MC_FRDY)  && 
                    ((efc1.EFC_FSR & AT91_BL_EFC::MC_FRDY) != AT91_BL_EFC::MC_FRDY)  );
        }
    }

    return TRUE;
}
开发者ID:prabby,项目名称:miniclr,代码行数:33,代码来源:AT91_BL_EFC.cpp



注:本文中的GLOBAL_LOCK函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GLOBAL_SIS函数代码示例发布时间:2022-05-30
下一篇:
C++ GLOBAL_DEF函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap