示例#1
0
void serialPortEnable(bool xRxEnable, bool xTxEnable)
{
    ENTER_CRITICAL_SECTION();

    if( xRxEnable )
    {
        P1OUT &= ~BIT1;		// set to receive mode
        IE1 |= URXIE0;
    }
    else
    {
    	IFG1 &= ~URXIFG0;   // Clear rx interrupt flag
        IE1  &= ~URXIE0;
    }

    if(xTxEnable)
    {
        P1OUT |= BIT1;		// set to transmit mode
    	IE1   |= UTXIE0;
        IFG1  |= UTXIFG0;	// trigger 1st interrupt manually
    }
    else
    {
    	IFG1 &= ~UTXIFG0;   // Clear tx interrupt flag
        IE1  &= ~UTXIE0;
    }

    EXIT_CRITICAL_SECTION();

    return ;
}
示例#2
0
文件: rf1a.c 项目: alkin/tidecc
// *************************************************************************************************
// @fn          WritePATable
// @brief       Write data to power table
// @param       unsigned char value             Value to write
// @return      none
// *************************************************************************************************
void WritePATable(unsigned char value)
{
   unsigned char readbackPATableValue = 0;
   u16 int_state;

   ENTER_CRITICAL_SECTION(int_state);

   while (readbackPATableValue != value)
   {
      while (!(RF1AIFCTL1 & RFINSTRIFG)) ;
      RF1AINSTRW = 0x7E00 + value;      // PA Table write (burst)

      while (!(RF1AIFCTL1 & RFINSTRIFG)) ;
      RF1AINSTRB = RF_SNOP;     // reset pointer

      while (!(RF1AIFCTL1 & RFINSTRIFG)) ;
      RF1AINSTRB = 0xFE;        // PA Table read (burst)

      while (!(RF1AIFCTL1 & RFDINIFG)) ;
      RF1ADINB = 0x00;          //dummy write

      while (!(RF1AIFCTL1 & RFDOUTIFG)) ;
      readbackPATableValue = RF1ADOUT0B;

      while (!(RF1AIFCTL1 & RFINSTRIFG)) ;
      RF1AINSTRB = RF_SNOP;
   }

   EXIT_CRITICAL_SECTION(int_state);
}
示例#3
0
/**
 -----------------------------------------------------------------------------------------------------------------------
 eMBRTUStop
 -----------------------------------------------------------------------------------------------------------------------
*   Event Handler for GPI module
*
* 	@date       			DEC/02/2013
* 	@author                         FW_DEV_2
* 	@pre                            None
* 	@return	 			None
************************************************************************************************************************
*/
void eMBRTUStop( void )
{
    ENTER_CRITICAL_SECTION(  );
    vMBPortSerialEnable( FALSE, FALSE );
    vMBPortTimersDisable(  );
    EXIT_CRITICAL_SECTION(  );
}
示例#4
0
static BOOL FddpPushJobItem(FDD_JOB_ITEM *pJobItem)
{
	BOOL bResult = TRUE;

ENTER_CRITICAL_SECTION();
	{
		/* check up the remain space of Q */
		if(m_JobItemQ.cnt >= FDD_JOB_ITEM_Q_SIZE) {
			bResult = FALSE;
			goto $exit;
		}

		/* process */
		m_JobItemQ.cnt++;
		m_JobItemQ.queue[m_JobItemQ.tail].type					= pJobItem->type;
		m_JobItemQ.queue[m_JobItemQ.tail].sector				= pJobItem->sector;
		m_JobItemQ.queue[m_JobItemQ.tail].numbers_of_sectors	= pJobItem->numbers_of_sectors;
		m_JobItemQ.queue[m_JobItemQ.tail].pt_data				= pJobItem->pt_data;
		m_JobItemQ.queue[m_JobItemQ.tail].thread				= pJobItem->thread;
		m_JobItemQ.tail++;
		if(m_JobItemQ.tail >= FDD_JOB_ITEM_Q_SIZE)
			m_JobItemQ.tail = 0;
	}
$exit:
EXIT_CRITICAL_SECTION();
	return bResult;
}
示例#5
0
文件: uxos.c 项目: wkxboot/rtos
static void uxos_update_sysclock()
{

	uint16_t temp_overflow_count;
	ENTER_CRITICAL_SECTION();
	temp_overflow_count=uxos_get_overflow();
	EXIT_CRITICAL_SECTION();
	if (temp_overflow_count>0)
	{
		ENTER_CRITICAL_SECTION();
		uxos_clear_overflow();
		EXIT_CRITICAL_SECTION();
		uxos_timer_update(temp_overflow_count);
	} 
		
}
示例#6
0
static BOOL FddpPopJobItem(FDD_JOB_ITEM *pJobItem)
{
	BOOL bResult = TRUE;

ENTER_CRITICAL_SECTION();
	{
		/* check up count */
		if(m_JobItemQ.cnt == 0) {
			bResult = FALSE;
			goto $exit;
		}

		/* process */
		m_JobItemQ.cnt--;
		pJobItem->type					= m_JobItemQ.queue[m_JobItemQ.head].type;
		pJobItem->sector				= m_JobItemQ.queue[m_JobItemQ.head].sector;
		pJobItem->numbers_of_sectors	= m_JobItemQ.queue[m_JobItemQ.head].numbers_of_sectors;
		pJobItem->pt_data				= m_JobItemQ.queue[m_JobItemQ.head].pt_data;
		pJobItem->thread				= m_JobItemQ.queue[m_JobItemQ.head].thread;
		m_JobItemQ.head++;
		if(m_JobItemQ.head >= FDD_JOB_ITEM_Q_SIZE)
			m_JobItemQ.head = 0;
	}
$exit:
EXIT_CRITICAL_SECTION();
	return bResult;
}
示例#7
0
/**
 * Initialize ModBus master.
 *
 * @param ucSlaveAddress - Not used in master mode
 * @param ucPort - Serial port number
 * @param ulBaudRate - Serial port baud rate
 * @param eParity -  MB_PAR_NONE, MB_PAR_ODD, MB_PAR_EVEN
 * @return MB_ENOERR on success
 */
eMBErrorCode eMBRTUInit(UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate,
        eMBParity eParity)
{
    eMBErrorCode    eStatus = MB_ENOERR;
    ULONG           ulTimerT35_50us;
    ( void )ucSlaveAddress;
    ENTER_CRITICAL_SECTION(  );

    /* Modbus RTU uses 8 Databits. */
    if( xMBPortSerialInit( ucPort, ulBaudRate, 8, eParity ) != TRUE )
    {
        eStatus = MB_EPORTERR;
    }
    if( ulBaudRate > 19200 )
    {
        /* The timer reload value for a character is given by:
         *
         * ChTimeValue = Ticks_per_1s / ( Baudrate / 11 )
         *             = 11 * Ticks_per_1s / Baudrate
         *             = 220000 / Baudrate
         * The reload for t3.5 is 1.5 times this value and similarly
         * for t3.5.
         */
         ulTimerT35_50us = ( 7UL * 220000UL ) / ( 2UL * ulBaudRate );
    }
    DEBUG_PUTSTRING1("T35 = ", ulTimerT35_50us);
    if( xMBPortTimersInit( ( USHORT ) ulTimerT35_50us ) != TRUE )
    {
         eStatus = MB_EPORTERR;
    }
    EXIT_CRITICAL_SECTION(  );

    return eStatus;
}
示例#8
0
文件: mbrtu.c 项目: zpcaams/osm
eMBErrorCode
eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
{
    BOOL            xFrameReceived = FALSE;
    eMBErrorCode    eStatus = MB_ENOERR;

    ENTER_CRITICAL_SECTION();
    assert( usRcvBufferPos < MB_SER_PDU_SIZE_MAX );

    /* Length and CRC check */
    if( ( usRcvBufferPos >= MB_SER_PDU_SIZE_MIN )
        && ( usMBCRC16( ( UCHAR * ) ucRTUBuf, usRcvBufferPos ) == 0 ) )
    {
        /* Save the address field. All frames are passed to the upper layed
         * and the decision if a frame is used is done there.
         */
        *pucRcvAddress = ucRTUBuf[MB_SER_PDU_ADDR_OFF];

        /* Total length of Modbus-PDU is Modbus-Serial-Line-PDU minus
         * size of address field and CRC checksum.
         */
        *pusLength = ( USHORT )( usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_CRC );

        /* Return the start of the Modbus PDU to the caller. */
        *pucFrame = ( UCHAR * ) & ucRTUBuf[MB_SER_PDU_PDU_OFF];
        xFrameReceived = TRUE;
    }
    else
    {
        eStatus = MB_EIO;
    }

    EXIT_CRITICAL_SECTION();
    return eStatus;
}
示例#9
0
/* ----------------------- Start implementation -----------------------------*/
void vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable )
{
	/* If xRXEnable enable serial receive interrupts. If xTxENable enable
	 * transmitter empty interrupts.
	 */
	ENTER_CRITICAL_SECTION(  );
	if(xRxEnable){
		//SciaRegs.SCICTL1.bit.RXENA = 1;
		SciaRegs.SCICTL2.bit.RXBKINTENA =1;
	}
	else {
		//SciaRegs.SCICTL1.bit.RXENA = 0;
		SciaRegs.SCICTL2.bit.RXBKINTENA =0;
	}

	if(xTxEnable){
		//SciaRegs.SCICTL1.bit.TXENA = 1;
		SciaRegs.SCICTL2.bit.TXINTENA =1;
		SciaRegs.SCICTL2.bit.TXEMPTY = 0;
		SciaRegs.SCICTL1.bit.SWRESET = 0;
		SciaRegs.SCICTL1.bit.SWRESET = 1;
		//IFR = 0x0000;
	}
	else{
		//SciaRegs.SCICTL1.bit.TXENA = 0;
		SciaRegs.SCICTL2.bit.TXINTENA =0;
	}
	EXIT_CRITICAL_SECTION(  );
}
示例#10
0
void protocolSendPacket(uint8 *buf, uint8 len)
{
    uint16	checksum;

    if ( (len!=PDU_SIZE) || (g_serialPortRecvState!=STATE_RX_IDLE) )
    {
    	return ;
    }

    ENTER_CRITICAL_SECTION();

	g_serialPortBufSendCnt = len;
	g_serialPortSendPtr = g_serialPortBuf;

	checksum = computeChecksum(buf, len-2);
	buf[CSM_OFF] = (uint8)(checksum & 0xFF);
    buf[CSM_OFF+1] = (uint8)(checksum >> 8);

    g_serialPortSendState = STATE_TX_XMIT;
    serialPortEnable(FALSE, TRUE);

    EXIT_CRITICAL_SECTION();

    return ;
}
示例#11
0
/*************************************************************************
 * eMBMasterRTUReceive
 * Функция приёма данных и проверка их целосности.
 *************************************************************************/
eMBErrorCode
eMBMasterRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength )
{
    eMBErrorCode    eStatus = MB_ENOERR;

    ENTER_CRITICAL_SECTION(  );
    assert_param( usMasterRcvBufferPos < MB_SER_PDU_SIZE_MAX );

    // Проверка длинны пакета и его CRC
    if( ( usMasterRcvBufferPos >= MB_SER_PDU_SIZE_MIN )
        && ( usMBCRC16( ( UCHAR * ) ucMasterRTURcvBuf, usMasterRcvBufferPos ) == 0 ) )
    {
        // Save the address field. All frames are passed to the upper layed and the decision if a frame is used is done there.
        *pucRcvAddress = ucMasterRTURcvBuf[MB_SER_PDU_ADDR_OFF];

        // Общая длина данных(Modbus-PDU) без поля адреса и CRC.
        *pusLength = ( USHORT )( usMasterRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_CRC );

        // Адрес начала данных(Modbus-PDU)
        *pucFrame = ( UCHAR * ) & ucMasterRTURcvBuf[MB_SER_PDU_PDU_OFF];
    }
    else
    {
        eStatus = MB_EIO;
    }

    EXIT_CRITICAL_SECTION(  );
    return eStatus;
}
示例#12
0
void
eMBMasterRTUStop( void )
{
		OS_CPU_SR  cpu_sr;
    ENTER_CRITICAL_SECTION(  );
    vMBMasterPortSerialEnable( FALSE, FALSE );
    vMBMasterPortTimersDisable(  );
    EXIT_CRITICAL_SECTION(  );
}
示例#13
0
void
eMBASCIIStop( void )
{
	  ENTER_CRITICAL_DECLARE( );
	
    ENTER_CRITICAL_SECTION(  );
    vMBPortSerialEnable( FALSE, FALSE );
    vMBPortTimersDisable(  );
    EXIT_CRITICAL_SECTION(  );
}
示例#14
0
KERNELAPI HANDLE PsGetCurrentThread(VOID)
{
	HANDLE thread;

ENTER_CRITICAL_SECTION();
	thread = (HANDLE)(m_ProcMgrBlk.pt_current_thread);
EXIT_CRITICAL_SECTION();

	return thread;
}
示例#15
0
static DWORD PspGetNextProcessID(void)
{
	DWORD process_id;

ENTER_CRITICAL_SECTION();
	process_id = m_ProcMgrBlk.next_process_id++;
EXIT_CRITICAL_SECTION();

	return process_id;
}
示例#16
0
static DWORD PspGetNextThreadID(HANDLE ProcessHandle)
{
	DWORD thread_id;

ENTER_CRITICAL_SECTION();
	thread_id = PsGetProcessPtr(ProcessHandle)->next_thread_id++;
EXIT_CRITICAL_SECTION();

	return thread_id;
}
示例#17
0
static DWORD PspThreadCutterThread(PVOID StartContext)
{
	HANDLE ProcessHandle, ThreadHandle;
	PTHREAD_CONTROL_BLOCK *pt_prev_thread, *pt_cur_thread;

	while(1) {
		/* check thread cutting list */
		if(!PspPopCuttingItem(&m_ThreadCuttingList, &ThreadHandle)) {
			HalTaskSwitch();
			continue;
		}

ENTER_CRITICAL_SECTION();
		ProcessHandle = PsGetThreadPtr(ThreadHandle)->parent_process_handle;

		/* if requsted thread's parent process handle is same with system process handle, then do nothing!! protect system thread */
		if(ProcessHandle == PsGetThreadPtr(PsGetCurrentThread())->parent_process_handle) {
			goto $exit;
		}

		/* invalid thread */
		if(PsGetProcessPtr(ProcessHandle)->thread_count == 0) {
			goto $exit;
		} 
		/* check whether there is only one thread exist in the parent process */
		else if(PsGetProcessPtr(ProcessHandle)->thread_count == 1) {
			PsGetProcessPtr(ProcessHandle)->pt_head_thread = NULL;
		}
		/* more than 2 threads exist */
		else {
			pt_prev_thread = pt_cur_thread = &(PsGetProcessPtr(ProcessHandle)->pt_head_thread);
			while(*pt_cur_thread != PsGetThreadPtr(ThreadHandle)) {
				/* there is no requested thread in the parent process */
				if((*pt_cur_thread)->pt_next_thread == NULL) {
					goto $exit;
				}
				pt_prev_thread = pt_cur_thread;
				pt_cur_thread = &((*pt_cur_thread)->pt_next_thread);
			}
			/* change next thread pointer */
			(*pt_prev_thread)->pt_next_thread = (*pt_cur_thread)->pt_next_thread;
		}
		PsGetProcessPtr(ProcessHandle)->thread_count--;

		/* except user mode program's stack */
		if(PsGetThreadPtr(ThreadHandle)->pt_stack_base_address >= (int *)0x00200000)
			MmFreeNonCachedMemory((PVOID)(PsGetThreadPtr(ThreadHandle)->pt_stack_base_address)); /* dealloc stack */
		MmFreeNonCachedMemory((PVOID)(PsGetThreadPtr(ThreadHandle))); /* dealloc thread */

$exit:
EXIT_CRITICAL_SECTION();
	}

	return 0;
}
示例#18
0
文件: mbascii.c 项目: 198401/pid
void
eMBASCIIStart( void )
{
    ENTER_CRITICAL_SECTION(  );
    vMBPortSerialEnable( TRUE, FALSE );
    eRcvState = STATE_RX_IDLE;
    EXIT_CRITICAL_SECTION(  );

    /* No special startup required for ASCII. */
    ( void )xMBPortEventPost( EV_READY );
}
示例#19
0
文件: uxtrap.c 项目: barak/mit-scheme
static void
trap_recover (void)
{
  if (WITHIN_CRITICAL_SECTION_P ())
    {
      CLEAR_CRITICAL_SECTION_HOOK ();
      EXIT_CRITICAL_SECTION ({});
    }
  reset_interruptable_extent ();
  continue_from_trap (saved_signo, saved_info, saved_scp);
}
示例#20
0
/*************************************************************************
 * eMBMasterRTUStart
 * Изначально приемник в состоянии STATE_M_RX_INIT. Запускаем таймер на t3.5
 * Если символ не получен, то переводим приемник в STATE_M_RX_IDLE.
 * гарантировано пока не увидим начало фрейма(t3.5) не примем никакого мусора.
 *************************************************************************/
void
eMBMasterRTUStart( void )
{
    ENTER_CRITICAL_SECTION(  );

    eRcvState = STATE_M_RX_INIT;
 //   vMBMasterPortSerialEnable( TRUE, FALSE );			// Режим приёма
    vMBMasterPortTimersT35Enable(  );					// Старт таймера t3.5 символа

    EXIT_CRITICAL_SECTION(  );
}
示例#21
0
文件: LDS_485.C 项目: Triney/code
void lds_uart_init(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	USART_InitTypeDef USART_InitStructure;
	NVIC_InitTypeDef NVIC_InitStructure;
	//	USART_ClockInitTypeDef USART_ClockInitStructure;
	//	NVIC_InitTypeDef NVIC_InitStructure;
	//======================时钟初始化=======================================
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
//	//======================IO初始化=======================================	

	//USART2_TX
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	//USART2_RX
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	//配置485发送和接收模式
//    TODO   暂时先写B13 等之后组网测试时再修改
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	//======================串口初始化=======================================
	USART_InitStructure.USART_BaudRate = 9600;
	USART_InitStructure.USART_Parity = USART_Parity_No;
	USART_InitStructure.USART_WordLength = USART_WordLength_8b;
	USART_InitStructure.USART_StopBits = USART_StopBits_1;
	USART_InitStructure.USART_HardwareFlowControl =
			USART_HardwareFlowControl_None;
	USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
	
	GPIO_SetBits(GPIOC ,GPIO_Pin_3);

	ENTER_CRITICAL_SECTION(); //关全局中断

	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);

	USART_Init(USART2, &USART_InitStructure);
	USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
	USART_Cmd(USART2, ENABLE);
	EXIT_CRITICAL_SECTION(); //开全局中断	
}
示例#22
0
static DWORD PspProcessCutterThread(PVOID StartContext)
{
	HANDLE ProcessHandle;
	PPROCESS_CONTROL_BLOCK *pt_prev_process, *pt_cur_process;
	PTHREAD_CONTROL_BLOCK  *pt_cur_thread;

	while(1) {
		/* check process cutting list */
		if(!PspPopCuttingItem(&m_ProcessCuttingList, &ProcessHandle)) {
			HalTaskSwitch();
			continue;
		}

ENTER_CRITICAL_SECTION();
		/* if requsted process handle is same with system process handle, then do nothing!! protect system process */
		if(ProcessHandle == PsGetThreadPtr(PsGetCurrentThread())->parent_process_handle) {
			goto $exit;
		}

		/* find requested process position in the process list */
		pt_prev_process = pt_cur_process = &(m_ProcMgrBlk.pt_head_process);
		while(*pt_cur_process != PsGetProcessPtr(ProcessHandle)) {
			/* there is no requested process in the list */
			if((*pt_cur_process)->pt_next_process == NULL) {
				goto $exit;
			}
			pt_prev_process = pt_cur_process;
			pt_cur_process = &((*pt_cur_process)->pt_next_process);
		}

		/* change next process pointer */
		(*pt_prev_process)->pt_next_process = (*pt_cur_process)->pt_next_process;
		m_ProcMgrBlk.process_count--;

		/* dealloc all threads belonged to the requested process */
		pt_cur_thread = &(PsGetProcessPtr(ProcessHandle)->pt_head_thread);
		while(*pt_cur_thread != NULL) {
			MmFreeNonCachedMemory((PVOID)((*pt_cur_thread)->pt_stack_base_address));
			MmFreeNonCachedMemory((PVOID)(*pt_cur_thread));
			pt_cur_thread = &((*pt_cur_thread)->pt_next_thread);
		}

		/* dealloc the requested process memory */
		MmFreeNonCachedMemory((PVOID)ProcessHandle);

$exit:
EXIT_CRITICAL_SECTION();
	}

	return 0;
}
示例#23
0
static BOOL PspAddNewThread(HANDLE ProcessHandle, HANDLE ThreadHandle)
{
	PTHREAD_CONTROL_BLOCK *pt_next_thread;

ENTER_CRITICAL_SECTION();
	pt_next_thread = &PsGetProcessPtr(ProcessHandle)->pt_head_thread;
	while(*pt_next_thread)
		pt_next_thread = &(*pt_next_thread)->pt_next_thread;
	*pt_next_thread = PsGetThreadPtr(ThreadHandle);
	PsGetProcessPtr(ProcessHandle)->thread_count++;
EXIT_CRITICAL_SECTION();

	return TRUE;
}
示例#24
0
static BOOL PspAddNewProcess(HANDLE ProcessHandle)
{
	PPROCESS_CONTROL_BLOCK *pt_next_process;

ENTER_CRITICAL_SECTION();
	pt_next_process = &m_ProcMgrBlk.pt_head_process;
	while(*pt_next_process)
		pt_next_process = &(*pt_next_process)->pt_next_process;
	*pt_next_process = PsGetProcessPtr(ProcessHandle);
	m_ProcMgrBlk.process_count++;
EXIT_CRITICAL_SECTION();

	return TRUE;
}
示例#25
0
void
vMBPortEventClose(  )
{
    ENTER_CRITICAL_SECTION(  );
    if( bIsInitialized )
    {
        if( 0 != arxEventHdls[0].xQueueHdl )
        {
            vQueueDelete( arxEventHdls[0].xQueueHdl );
        }
        HDL_RESET( &arxEventHdls[0] );
    }
    EXIT_CRITICAL_SECTION(  );
}
示例#26
0
static BOOL SyspSetupSysCallgate(void)
{
ENTER_CRITICAL_SECTION();
	m_GdtTable[SYSCALL_GATE>>3].count		= 1;
	m_GdtTable[SYSCALL_GATE>>3].type		= 0xec; /* 11101100 */
	m_GdtTable[SYSCALL_GATE>>3].selector	= KERNEL_CS;
	m_GdtTable[SYSCALL_GATE>>3].offset_1	= (BYTE) (((int)Sysp_SERVICE_CALL_MANAGER) & 0x000000ff);
	m_GdtTable[SYSCALL_GATE>>3].offset_2	= (BYTE)((((int)Sysp_SERVICE_CALL_MANAGER) & 0x0000ff00) >> 8);
	m_GdtTable[SYSCALL_GATE>>3].offset_3	= (BYTE)((((int)Sysp_SERVICE_CALL_MANAGER) & 0x00ff0000) >> 16);
	m_GdtTable[SYSCALL_GATE>>3].offset_4	= (BYTE)((((int)Sysp_SERVICE_CALL_MANAGER) & 0xff000000) >> 24);
EXIT_CRITICAL_SECTION();

	return TRUE;
}
示例#27
0
文件: rf1a.c 项目: alkin/tidecc
// *************************************************************************************************
// @fn          ReadSingleReg
// @brief       Read byte from register.
// @param       none
// @return      none
// *************************************************************************************************
unsigned char ReadSingleReg(unsigned char addr)
{
   unsigned char x;
   u16 int_state;

   ENTER_CRITICAL_SECTION(int_state);

   RF1AINSTR1B = (addr | RF_REGRD);
   x = RF1ADOUT1B;

   EXIT_CRITICAL_SECTION(int_state);

   return x;
}
/****************************************************************************************************
 * @fn      GetPoolStats
 *          Returns the total block count and used blocks count from the given pool
 *
 * @param   [IN]pPool - Pointer to the memory pool that has been initialized
 * @param   [OUT]pTotalCount - return the total number of blocks in the given pool
 * @param   [OUT]pUsedCount - return the current used block count
 *
 * @return  none
 *
 ***************************************************************************************************/
void GetPoolStats( void *pPool, uint32_t *pTotalCount, uint32_t *pUsedCount )
{
    SETUP_CRITICAL_SECTION();
    ENTER_CRITICAL_SECTION();
    if (pTotalCount)
    {
        *pTotalCount = ((BlkMem_t*)pPool)->TotalCnt;
    }
    if (pUsedCount)
    {
        *pUsedCount = ((BlkMem_t*)pPool)->UsedCnt;
    }
    EXIT_CRITICAL_SECTION();
}
示例#29
0
/**
 -----------------------------------------------------------------------------------------------------------------------
 eMBRTUInit
 -----------------------------------------------------------------------------------------------------------------------
*   Event Handler for GPI module
*
* 	@date       			DEC/02/2013
* 	@author                         FW_DEV_2
* 	@pre                            None
* 	@return	 			None
************************************************************************************************************************
*/
eMBErrorCode eMBRTUInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
{
    eMBErrorCode    eStatus = MB_ENOERR;
    ULONG           usTimer1_5=0;
    ULONG 			usTimer3_5=0;

    printf("Initializing RTU\n");
    ( void )ucSlaveAddress;
    ENTER_CRITICAL_SECTION(  );

    /* Modbus RTU uses 8 Databits. */
    if( xMBPortSerialInit( ucPort, ulBaudRate, 8, eParity ) != TRUE )
    {
        printf("Serial port initialization failed\n");
    	eStatus = MB_EPORTERR;
    }
    else
    {
        /* If baudrate > 19200 then we should use the fixed timer values
         * t35 = 1750us. Otherwise t35 must be 3.5 times the character time.
         */
        if( ulBaudRate > 19200 )
        {
        	usTimer1_5 = 75000;       	/* 750 us */
            usTimer3_5 = 175000;		/* 1.750 ms*/
        }
        else
        {
            /* The timer reload value for a character is given by:
             *
             * ChTimeValue = Ticks_per_1s / ( Baudrate / 11 )
             *             = 11 * Ticks_per_1s / Baudrate
             *             = 220000 / Baudrate
             * The reload for t3.5 is 1.5 times this value and similary
             * for t3.5.
             */
        	usTimer1_5 = (1500000/ulBaudRate); 		//
        	usTimer3_5 = (3500000/ulBaudRate);
        }
        printf("Initialize timer");
        if( xMBPortTimersInit( ( USHORT ) usTimer3_5 ) != TRUE )
        {
            eStatus = MB_EPORTERR;
        }
    }

    EXIT_CRITICAL_SECTION(  );

    return eStatus;
}
示例#30
0
void
eMBRTUStart( void )
{
    ENTER_CRITICAL_SECTION(  );
    /* Initially the receiver is in the state STATE_RX_INIT. we start
     * the timer and if no character is received within t3.5 we change
     * to STATE_RX_IDLE. This makes sure that we delay startup of the
     * modbus protocol stack until the bus is free.
     */
    eRcvState = STATE_RX_INIT;
    vMBPortSerialEnable( TRUE, FALSE );
    vMBPortTimersEnable(  );

    EXIT_CRITICAL_SECTION(  );
}