Пример #1
0
/*********************************************************************//**
 * @brief 		Configure the page mode
 * @param[in]	index index number, should be from 0 to 3
 * @param[in] 	page_mode  page mode, should be:
 * 					- 0: disable
 * 					- 1: asynchronous page mode enable
 * @return 		None
 **********************************************************************/
void EMC_StaMemConfigPM(uint32_t index , uint32_t page_mode)
{
   uint32_t mask =  ~(uint32_t)(_BIT(3))  ;
   switch ( index)
   {
      case 0:
         LPC_EMC->StaticConfig0 = (LPC_EMC->StaticConfig0 & mask) | page_mode;
	   break;
      case 1:
         LPC_EMC->StaticConfig1 = (LPC_EMC->StaticConfig1 & mask) | page_mode;
	   break;
      case 2:
         LPC_EMC->StaticConfig2 = (LPC_EMC->StaticConfig2  & mask)| page_mode;
	   break;
      case 3:
         LPC_EMC->StaticConfig3 = (LPC_EMC->StaticConfig3  & mask)| page_mode;
	   break;
   }
}
Пример #2
0
/*********************************************************************//**
 * @brief 		Configure write permission: protect or not
 * @param[in]	index index number, should be from 0 to 3
 * @param[in] 	permission  permission mode, should be:
 * 					- ENABLE: protect
 * 					- DISABLE: not protect
 * @return 		None
 **********************************************************************/
void EMC_DynMemConfigP(uint32_t index , uint32_t permission)
{
   uint32_t mask =  ~(uint32_t)(_BIT(20))  ;
   switch ( index)
   {
      case 0:
         LPC_EMC->DynamicConfig0 = (LPC_EMC->DynamicConfig0 & mask) | permission;
	   break;
      case 1:
         LPC_EMC->DynamicConfig1 = (LPC_EMC->DynamicConfig1 & mask) | permission;
	   break;
      case 2:
         LPC_EMC->DynamicConfig2 = ( LPC_EMC->DynamicConfig2 & mask) | permission;
	   break;
      case 3:
         LPC_EMC->DynamicConfig3 = (LPC_EMC->DynamicConfig3 & mask) | permission;
	   break;
   }
}
Пример #3
0
/*********************************************************************//**
 * @brief 		Enable/disable the buffer
 * @param[in]	index index number, should be from 0 to 3
 * @param[in] 	buff_control buffer control mode, should be:
 * 					- ENABLE
 * 					- DISABLE
 * @return 		None
 **********************************************************************/
void EMC_DynMemConfigB(uint32_t index , uint32_t buff_control)
{
   uint32_t mask =  ~(uint32_t)(_BIT(19))  ;
   switch ( index)
   {
      case 0:
         LPC_EMC->DynamicConfig0 = (LPC_EMC->DynamicConfig0 & mask) | buff_control;
	   break;
      case 1:
         LPC_EMC->DynamicConfig1 = ( LPC_EMC->DynamicConfig1 & mask) | buff_control;
	   break;
      case 2:
         LPC_EMC->DynamicConfig2 = (LPC_EMC->DynamicConfig2 & mask)| buff_control;
	   break;
      case 3:
         LPC_EMC->DynamicConfig3 = (LPC_EMC->DynamicConfig3 & mask) | buff_control;
	   break;
   }
}
Пример #4
0
static unsigned int startup_ilc_irq(unsigned int irq)
{
	struct ilc *ilc = get_irq_chip_data(irq);
	unsigned int priority;
	unsigned long flags;
	int input = irq - ilc->first_irq;
	struct ilc_irq *ilc_irq;

	DPRINTK("%s: irq %d\n", __func__, irq);

	if ((input < 0) || (input >= ilc->inputs_num))
		return -ENODEV;

	ilc_irq = &ilc->irqs[input];
	priority = ilc_irq->priority;

	spin_lock_irqsave(&ilc->lock, flags);
	ilc_set_used(ilc_irq);
	ilc_set_enabled(ilc_irq);
	ilc->priority[priority][_BANK(input)] |= _BIT(input);
	spin_unlock_irqrestore(&ilc->lock, flags);

#if	defined(CONFIG_CPU_SUBTYPE_STX5206) || \
	defined(CONFIG_CPU_SUBTYPE_STX7111)
	/* ILC_EXT_OUT[4] -> IRL[0] (default priority 13 = irq  2) */
	/* ILC_EXT_OUT[5] -> IRL[1] (default priority 10 = irq  5) */
	/* ILC_EXT_OUT[6] -> IRL[2] (default priority  7 = irq  8) */
	/* ILC_EXT_OUT[7] -> IRL[3] (default priority  4 = irq 11) */
	ILC_SET_PRI(ilc->base, input, 0x8007);
#elif	defined(CONFIG_CPU_SUBTYPE_FLI7510) || \
	defined(CONFIG_CPU_SUBTYPE_STX5197) || \
	defined(CONFIG_CPU_SUBTYPE_STX7105) || \
	defined(CONFIG_CPU_SUBTYPE_STX7200)
	ILC_SET_PRI(ilc->base, input, priority);
#elif	defined(CONFIG_CPU_SUBTYPE_STX7108) || \
	defined(CONFIG_CPU_SUBTYPE_STX7141)
	ILC_SET_PRI(ilc->base, input, 0x0);
#endif

	ILC_SET_ENABLE(ilc->base, input);

	return 0;
}
Пример #5
0
/*********************************************************************//**
 * @brief 		Configure the extended wait value
 * @param[in]	index index number, should be from 0 to 3
 * @param[in] 	ex_wait  Extended wait mode, should be:
 * 					- 0: Extended wait disabled.
 * 					- 1: Extended wait enabled.
 * @return 		None
 **********************************************************************/
void EMC_StaMemConfigEW ( uint32_t index , uint32_t ex_wait )
{
    uint32_t mask =  ~ ( uint32_t ) ( _BIT ( 8 ) )  ;

    switch ( index )
    {
        case 0:
            LPC_EMC->StaticConfig0 = ( LPC_EMC->StaticConfig0 & mask ) | ex_wait;
            break;
        case 1:
            LPC_EMC->StaticConfig1 = ( LPC_EMC->StaticConfig1 & mask ) | ex_wait;
            break;
        case 2:
            LPC_EMC->StaticConfig2 = ( LPC_EMC->StaticConfig2 & mask ) | ex_wait;
            break;
        case 3:
            LPC_EMC->StaticConfig3 = ( LPC_EMC->StaticConfig3 & mask ) | ex_wait;
            break;
    }
}
Пример #6
0
/*********************************************************************//**
 * @brief 		SysTick interrupt handler
 * @param		None
 * @return 		None
 ***********************************************************************/
void SysTick_Handler(void)
{
    if(led_timer)
    {
    	--led_timer;
    }
    else
    {
    	LPC_GPIO3->FIOPIN ^= _BIT(25); //Toggle P3.25 Hearbeat led
    	led_timer=led_delay;
    }

	if(delay_timer)
    {
      --delay_timer;           /*decrement Delay Timer */
    }
	
	//Clear System Tick counter flag
	SYSTICK_ClearCounterFlag();
}
Пример #7
0
/*********************************************************************//**
 * @brief 		Map the address for the memory device
 * @param[in]	index index number, should be from 0 to 3
 * @param[in] 	add_mapped address where the memory will be mapped
 * @return 		None
 **********************************************************************/
void EMC_DynMemConfigAM ( uint32_t index , uint32_t add_mapped )
{
    uint32_t mask = ~ ( uint32_t ) ( _SBF ( 7, 0x3f ) ) | ~ ( uint32_t ) ( _BIT ( 14 ) )  ;

    switch ( index )
    {
        case 0:
            LPC_EMC->DynamicConfig0 = ( LPC_EMC->DynamicConfig0 & mask ) | add_mapped;
            break;
        case 1:
            LPC_EMC->DynamicConfig1 = ( LPC_EMC->DynamicConfig1 & mask ) | add_mapped;
            break;
        case 2:
            LPC_EMC->DynamicConfig2 = ( LPC_EMC->DynamicConfig2 & mask ) | add_mapped;
            break;
        case 3:
            LPC_EMC->DynamicConfig3 = ( LPC_EMC->DynamicConfig3 & mask ) | add_mapped;
            break;
    }
}
Пример #8
0
/*********************************************************************//**
 * @brief 		Configure the write permission
 * @param[in]	index index number, should be from 0 to 3
 * @param[in] 	per_val  Permission mode, should be:
 * 					- 0: Write not protected.
 * 					- 1: Write protected.
 * @return 		None
 **********************************************************************/
void EMC_StaMemConfigpP ( uint32_t index , uint32_t per_val )
{
    uint32_t mask =  ~ ( uint32_t ) ( _BIT ( 20 ) )  ;

    switch ( index )
    {
        case 0:
            LPC_EMC->StaticConfig0 = ( LPC_EMC->StaticConfig0 & mask )  | per_val;
            break;
        case 1:
            LPC_EMC->StaticConfig1 = ( LPC_EMC->StaticConfig1 & mask )  | per_val;
            break;
        case 2:
            LPC_EMC->StaticConfig2 = ( LPC_EMC->StaticConfig2 & mask )  | per_val;
            break;
        case 3:
            LPC_EMC->StaticConfig3 = ( LPC_EMC->StaticConfig3 & mask )  | per_val;
            break;
    }
}
Пример #9
0
/*********************************************************************//**
 * @brief	Initial System Init using Port and Peripheral
 * @param[in]	None
 * @return 		None
 **********************************************************************/
void System_Init(void)
{
	LPC_WDT->WDMOD &= ~WDT_WDMOD_WDEN;  // Disable Watchdog
	SystemInit();						// Initialize system and update core clock
	Port_Init();                        // Port Initialization
	SYSTICK_Config();                   // Systick Initialization
	led_delay = 1000;                   // Heart Beat rate of 1Sec toggle
	NVIC_SetPriority(SysTick_IRQn, 0);  // Set SysTick as Highest Priority

	UART_Config(LPC_UART0, 115200);       // Uart0 Initialize at 9600 Baud Rate
	SSP_Config (LPC_SSP1);              // Initialize SPI
	I2C_Config (LPC_I2C0);              // Initialize I2C0
	GLCD_Init();                        // Initialize GLCD

	GPIO_IntCmd(2,_BIT(7),1);          // Enable GPIO Interrupt at P0.19 Falling Edge
	NVIC_EnableIRQ(EINT3_IRQn);         // NVIC Interrupt EINT3_IRQn for GPIO
	NVIC_SetPriority(EINT3_IRQn, 4);    // Set any lower Priority than SysTick

	TSC2004_Cal_Init(&cmatrix);

}
Пример #10
0
int lpc32xx_dma_wait_status(int channel)
{
	while((
	      (dma_base->raw_tc_stat | dma_base->raw_err_stat) &
	      _BIT(channel)) == 0
	     ) ;

	if (unlikely(dma_base->raw_err_stat & _BIT(channel))) {
		dma_base->int_err_clear |= _BIT(channel);
		dma_base->raw_err_stat |= _BIT(channel);
		return -1;
	}
	dma_base->int_tc_clear |= _BIT(channel);
	dma_base->raw_tc_stat |= _BIT(channel);
	return 0;
}
Пример #11
0
static void __init ea_add_device_dm9000(void)
{
	/*
	 * Configure Chip-Select 2 on SMC for the DM9000.
	 * Note: These timings were calculated for MASTER_CLOCK = 90000000
	 *  according to the DM9000 timings.
	 */
	MPMC_STCONFIG1 = 0x81;
	MPMC_STWTWEN1 = 1;
	MPMC_STWTOEN1 = 1;
	MPMC_STWTRD1 = 4;
	MPMC_STWTPG1 = 1;
	MPMC_STWTWR1 = 1;
	MPMC_STWTTURN1 = 2;
	/* enable oe toggle between consec reads */
	SYS_MPMC_WTD_DEL1 = _BIT(5) | 4;

	/* Configure Interrupt pin as input, no pull-up */
	gpio_direction_input(GPIO_MNAND_RYBN3);

	platform_device_register(&dm9000_device);
}
void DMANewTransferRequestISR()
{
	uint32_t PhyEP;
	uint32_t NDDRIntSt = USB_REG(0)->NDDRIntSt;

	for (PhyEP = 2; PhyEP < USED_PHYSICAL_ENDPOINTS; PhyEP++)			   /* Check All Endpoints */
		if ( NDDRIntSt & _BIT(PhyEP) ) {
			if ( IsOutEndpoint(PhyEP) ) {					/* OUT Endpoint */
				if (dmaDescriptor[PhyEP].Isochronous == 1) {// iso endpoint
					DcdDataTransfer(PhyEP, ISO_Address, 512);
				}
				else {
					uint16_t MaxPS = dmaDescriptor[PhyEP].MaxPacketSize;
					if (usb_data_buffer_OUT_size[0] == 0) {
						usb_data_buffer_OUT_index[0] = 0;
						DcdDataTransfer(PhyEP, usb_data_buffer_OUT[0], MaxPS);

					}
					else {
							uint32_t tem = usb_data_buffer_OUT_index[0];      //just to clear warning
							DcdDataTransfer(PhyEP, &usb_data_buffer_OUT[0][usb_data_buffer_OUT_size[0] + tem], MaxPS);
					}
				}
			}
			else {								/* IN Endpoint */
				if (dmaDescriptor[PhyEP].Isochronous == 1) {
					ISO_Address = (uint8_t *) CALLBACK_HAL_GetISOBufferAddress(PhyEP / 2, &SizeAudioTransfer);
					if (SizeAudioTransfer > 0) {
						DcdDataTransfer(PhyEP, ISO_Address, SizeAudioTransfer);
					}
					else {
						DcdDataTransfer(PhyEP, ISO_Address, 512);
					}
				}
			}
		}
	USB_REG(0)->NDDRIntClr = NDDRIntSt;
}
void DcdDataTransfer(uint8_t PhyEP, uint8_t *pData, uint32_t cnt)
{
	dmaDescriptor[PhyEP].BufferStartAddr = pData;
	if (dmaDescriptor[PhyEP].Isochronous == 1) {// iso endpoint
		if (PhyEP & 1) {// IN DIRECTION
			uint8_t BufferCount;
			for (BufferCount = 0; BufferCount < cnt / 0xFF; BufferCount++)
				BufferAddressIso[BufferCount] = 0xFF;
			BufferAddressIso[BufferCount] = (cnt % 0xFF);
			if (cnt % 0xFF != 0) {
				dmaDescriptor[PhyEP].BufferLength = cnt / 0xFF + 1;
			}
			else {
				dmaDescriptor[PhyEP].BufferLength = cnt / 0xFF;
			}
		}
		else {	// OUT DIRECTION
			dmaDescriptor[PhyEP].BufferLength = 1;
		}
		dmaDescriptor[PhyEP].IsoBufferAddr = (uint32_t) BufferAddressIso;
		dmaDescriptor[PhyEP].Isochronous = 1;
		dmaDescriptor[PhyEP].MaxPacketSize = 0;
	}
	else {
		dmaDescriptor[PhyEP].BufferLength = cnt;
	}
	dmaDescriptor[PhyEP].Retired = 0;
	dmaDescriptor[PhyEP].Status = 0;
	dmaDescriptor[PhyEP].IsoPacketValid = 0;
	dmaDescriptor[PhyEP].LSByteExtracted = 0;
	dmaDescriptor[PhyEP].MSByteExtracted = 0;
	dmaDescriptor[PhyEP].PresentCount = 0;

	UDCA[PhyEP] = (uint32_t) &dmaDescriptor[PhyEP];
	USB_REG(0)->EpDMAEn = _BIT(PhyEP);
}
void DMAEndTransferISR() 
{
	uint32_t PhyEP;
	uint32_t EoTIntSt = LPC_USB->EoTIntSt;

	for (PhyEP = 2; PhyEP < USED_PHYSICAL_ENDPOINTS; PhyEP++)              /* Check All Endpoints */
	{
		if ( EoTIntSt & _BIT(PhyEP) )
		{
			if ( IsOutEndpoint(PhyEP) )                 /* OUT Endpoint */
			{
				if(dmaDescriptor[PhyEP].Isochronous == 1) // iso endpoint
				{
#if 0
					SizeAudioTransfer = (BufferAddressIso[0])& 0xFFFF;
					ISO_Address = (uint8_t*)CALLBACK_HAL_GetISOBufferAddress(PhyEP/2,&SizeAudioTransfer);
					DcdDataTransfer(PhyEP, ISO_Address,512);
#endif //0
				}
				usb_data_buffer_OUT_size += dmaDescriptor[PhyEP].PresentCount;
                                uint32_t index = usb_data_buffer_OUT_index;
                                
				if((usb_data_buffer_OUT_size + index +
				    dmaDescriptor[PhyEP].MaxPacketSize) > 512)
                                {
				  LPC_USB->DMAIntEn &= (uint32_t)~(1<<1);
                                }
			}
			else			                    /* IN Endpoint */
			{
				/* Should be left blank */
			}
		}
	}
	LPC_USB->EoTIntClr = EoTIntSt;
}
LRESULT CIMoteTerminal::OnReceiveUSBData(WPARAM wParam, LPARAM lParam){
	//following couple of lines allow us to debug a raw datastream
	BYTE *InputReport = (BYTE *)lParam;
	DWORD BytesRead = ((USBmessage *)wParam)->actualBytesRead;
	BYTE type;
	BYTE valid;
	USBdata *USBin = &m_dataIn;

	type = *(InputReport + IMOTE_HID_TYPE);
	if((type >> IMOTE_HID_TYPE_MSC) != 0){	//the only protocol currently supported involves msc being 0
		free(InputReport);
		return FALSE;
	}
	if(isFlagged(type, _BIT(IMOTE_HID_TYPE_H))){
		USBin->i = 0;
		USBin->type = type;
		free(USBin->data);
		USBin->data = NULL;
		
		switch((USBin->type >> IMOTE_HID_TYPE_L) & 3){
			case IMOTE_HID_TYPE_L_BYTE:
                USBin->n = *(InputReport + IMOTE_HID_NI);
				if(USBin->n == 0){
					valid = *(InputReport + IMOTE_HID_NI + 1);
					USBin->data = (BYTE *)malloc(valid);
				}
				else{
					valid = IMOTE_HID_BYTE_MAXPACKETDATA;
					USBin->data = (BYTE *)malloc((USBin->n + 1) * IMOTE_HID_BYTE_MAXPACKETDATA - 1);
				}
				
				memcpy(USBin->data, InputReport + IMOTE_HID_NI + 1 + (USBin->n == 0?1:0), valid);
				break;
			case IMOTE_HID_TYPE_L_SHORT:
				USBin->n = (*(InputReport + IMOTE_HID_NI) << 8) | *(InputReport + IMOTE_HID_NI + 1);
				if(USBin->n == 0){
					valid = *(InputReport + IMOTE_HID_NI + 2);
					USBin->data = (BYTE *)malloc(valid);
				}
				else{
					valid = IMOTE_HID_SHORT_MAXPACKETDATA;
					USBin->data = (BYTE *)malloc((USBin->n + 1) * IMOTE_HID_SHORT_MAXPACKETDATA - 1);
				}
				memcpy(USBin->data, InputReport + IMOTE_HID_NI + 2 + (USBin->n == 0?1:0), valid);
                break;
			case IMOTE_HID_TYPE_L_INT:
				USBin->n = (*(InputReport + IMOTE_HID_NI) << 24) | (*(InputReport + IMOTE_HID_NI + 1) << 16) | (*(InputReport + IMOTE_HID_NI + 2) << 8) | *(InputReport + IMOTE_HID_NI + 3);
				if(USBin->n == 0){
					valid = *(InputReport + IMOTE_HID_NI + 4);
					USBin->data = (BYTE *)malloc(valid);
				}
				else{
					valid = IMOTE_HID_INT_MAXPACKETDATA;
					USBin->data = (BYTE *)malloc((USBin->n + 1) * IMOTE_HID_INT_MAXPACKETDATA - 1);
				}
				memcpy(USBin->data, InputReport + IMOTE_HID_NI + 4 + (USBin->n == 0?1:0), valid);
                break;
			default:
				TRACE("AH HAH!\r\n");
		}
	}
	else{
		switch((USBin->type >> IMOTE_HID_TYPE_L) & 3){
Пример #16
0
void cleanup_module(void)
{
    if ((old_mux_state & _BIT(3)) == 0) {
        __raw_writel(_BIT(3), LPC32XX_GPIO_P2_MUX_CLR);
    }
}
Пример #17
0
int init_module(void)
{
    old_mux_state = __raw_readl(LPC32XX_GPIO_P2_MUX_STATE);
    __raw_writel(_BIT(3), LPC32XX_GPIO_P2_MUX_SET);
    return 0;
}
Пример #18
0
/*******************************************************************************
* Function Name	: 
* Description		: 
* Output				:
* Return				:
*******************************************************************************/
void			_CAN::Parse(void *v) {	

unsigned	int tstamp=0;
CanTxMsg	msg={0,0,CAN_ID_STD,CAN_RTR_DATA,0,0,0,0,0,0,0,0,0};		
_LM				*lm = (_LM *)v;
//
//________ flushing com buffer/not echoed if debug_________ 
					if(com &&  tx->size - _buffer_count(tx) > sizeof(CanTxMsg)) {
						msg.StdId=Com2CanIoc;
						msg.DLC=_buffer_pull(com->tx,msg.Data,sizeof(msg.Data));
						if(msg.DLC)
							Send(&msg);
					}
//______________________________________________________________________________________					
					if(_buffer_count(rx)  && _buffer_pull(rx,&msg,sizeof(CanTxMsg)) && _buffer_pull(rx,&tstamp,sizeof(unsigned int))) {
//
//________ debug print__________________________________________________________________
						if(_BIT(_LM::debug, DBG_CAN_RX)) {
//							_io *temp=_stdio(lm->io);
							printf("\r\n:%04d<%02X ",__time__ % 10000,msg.StdId);
							for(int i=0;i<msg.DLC;++i)
								printf(" %02X",msg.Data[i]);
							printf("\r\n:");
//							_stdio(temp);
						}
//______________________________________________________________________________________
						switch(msg.StdId) {
//______________________________________________________________________________________							
							case Com2CanEc20: 
							case Com2CanIoc: 
							{
								if(lm->Selected() == REMOTE_CONSOLE)
									for(int i=0; i<msg.DLC; ++i)
										putchar(msg.Data[i]);
							}
							break;
//______________________________________________________________________________________
							case Can2ComIoc:
								if(msg.DLC) {
									if(com == NULL) {
										com=_io_init(128,128);
										_thread_add((void *)ParseCom,com,(char *)"ParseCom CAN",0);	
									}
									_buffer_push(com->rx,msg.Data,msg.DLC);
								} else {
									_thread_remove((void *)ParseCom,com);	
									com=_io_close(com);
								}
								break;
//______________________________________________________________________________________
//							case SprayCommand:
//								if(msg.DLC) {
//									lm->spray.AirLevel=msg.Data[0];
//									lm->spray.WaterLevel=msg.Data[1];
//								} else {
//									char	c[64];
//									sprintf(c,">%02X%02X%02X",	SprayCommand,
//																								lm->spray.AirLevel,
//																									lm->spray.WaterLevel);
//									Send(c);
//								}
//								break;
////______________________________________________________________________________________
//							case SprayStatus:
//								char	c[64];
//								sprintf(c,">%02X%02X%02X",	SprayStatus,
//																							_ADC::Th2o()/100,
//																								_ADC::Status());
//								Send(c);
//								break;
//______________________________________________________________________________________
							case Sys2Ec:
							case Ec2Sys:								
							case Ergm2Sys: 																						// energometer messages
								lm->ec20.Parse(&msg);
								break;
//______________________________________________________________________________________					
							default:
							break;
						}
					}
}
Пример #19
0
static HCD_STATUS QueueOneITD(uint32_t EdIdx, uint8_t* dataBuff, uint32_t TDLen, uint16_t StartingFrame)
{
	uint32_t i;
	PHCD_IsoTransferDescriptor pItd = (PHCD_IsoTransferDescriptor) Align16( HcdED(EdIdx)->hcED.TailP );
	
	pItd->StartingFrame = StartingFrame;
	pItd->FrameCount = (TDLen / HcdED(EdIdx)->hcED.MaxPackageSize) + (TDLen % HcdED(EdIdx)->hcED.MaxPackageSize ? 1 : 0) - 1;
	pItd->BufferPage0 = Align4k( (uint32_t) dataBuff );
	pItd->BufferEnd = (uint32_t) (dataBuff + TDLen - 1);

	for (i=0; TDLen>0 && i < 8; i++)
	{
		uint32_t XactLen = MIN(TDLen, HcdED(EdIdx)->hcED.MaxPackageSize);

		pItd->OffsetPSW[i] = (HCD_STATUS_TRANSFER_NotAccessed << 12) | (Align4k((uint32_t)dataBuff) != Align4k(pItd->BufferPage0) ? _BIT(12) : 0) |
							Offset4k((uint32_t)dataBuff); /*-- FIXME take into cross page account later 15-12: ConditionCode, 11-0: offset --*/
		
		TDLen -= XactLen;
		dataBuff += XactLen;
	}

	/* Create a new place holder TD & link setup TD to the new place holder */
	ASSERT_STATUS_OK ( AllocItdForEd(EdIdx) );

	return HCD_STATUS_OK;
}
Пример #20
0
/*********************************************************************//**
 * @brief 		General Port Initialization
 * @param[in]	None
 * @return 		None
 **********************************************************************/
void Port_Init(void)
{
	GPIO_SetDir(3, _BIT(25), 1);        // Set HeartBeat Led P3.25 to Output
}
Пример #21
0
/*********************************************************************//**
 * @brief 		Enable/disable CLKOUT
 * @param[in]	MMC_val	Memory clock control mode, should be:
 * 					- 0: CLKOUT enabled
 * 					- 1: CLKOUT disabled
 * @return 		None
 **********************************************************************/
void EMC_DynCtrlMMC ( uint32_t MMC_val )
{
    uint32_t mask = ~ ( uint32_t ) ( _BIT ( 5 ) );
    LPC_EMC->DynamicControl = ( ( LPC_EMC->DynamicControl & mask ) | MMC_val );
}
Пример #22
0
/*********************************************************************//**
 * @brief 		Switch between Normal operation and deep sleep power mode
 * @param[in]	Power_command	Low-power SDRAM deep-sleep mode, should be:
 *					- 0: Normal operation
 *					- 1: Enter deep-sleep mode
 * @return 		None
 **********************************************************************/
void EMC_DynCtrlPowerDownMode ( uint32_t Power_command )
{
    uint32_t mask = ~ ( uint32_t ) ( _BIT ( 13 ) );
    LPC_EMC->DynamicControl = ( ( LPC_EMC->DynamicControl & mask ) | Power_command );
}
/********************************************************************//**
 * @brief
 * @param
 * @return
 *********************************************************************/
void HAL17XX_USBConnect (uint32_t con)
{
  SIE_WriteCommandData(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
  GPIO_OutputValue(USB_CONNECT_PORT, _BIT(USB_CONNECT_PIN), con ? 0 : DEV_CON);
}
Пример #24
0
/*********************************************************************//**
 * @brief 		Initialize CS pin as GPIO function to drive /CS pin
 * 				due to definition of CS_PORT_NUM and CS_PORT_NUM
 * @param		None
 * @return		None
 ***********************************************************************/
void CS_Init (void)
{
	GPIO_SetDir(0, _BIT(16), 1);
	GPIO_SetValue(0, _BIT(16));
}
Пример #25
0
/*********************************************************************//**
 * @brief 		Initial Timer/Counter device
 * 				 	Set Clock frequency for Timer
 * 					Set initial configuration for Timer
 * @param[in]	TIMx  Timer selection, should be:
 * 				- LPC_TIM0: TIMER0 peripheral
 * 				- LPC_TIM1: TIMER1 peripheral
 * 				- LPC_TIM2: TIMER2 peripheral
 * 				- LPC_TIM3: TIMER3 peripheral
 * @param[in]	TimerCounterMode Timer counter mode, should be:
 * 				- TIM_TIMER_MODE: Timer mode
 * 				- TIM_COUNTER_RISING_MODE: Counter rising mode
 * 				- TIM_COUNTER_FALLING_MODE: Counter falling mode
 * 				- TIM_COUNTER_ANY_MODE:Counter on both edges
 * @param[in]	TIM_ConfigStruct pointer to TIM_TIMERCFG_Type
 * 				that contains the configuration information for the
 *                    specified Timer peripheral.
 * @return 		None
 **********************************************************************/
void TIM_Init(LPC_TIM_TypeDef *TIMx, TIM_MODE_OPT TimerCounterMode, void *TIM_ConfigStruct)
{
	TIM_TIMERCFG_Type *pTimeCfg;
	TIM_COUNTERCFG_Type *pCounterCfg;

	CHECK_PARAM(PARAM_TIMx(TIMx));
	CHECK_PARAM(PARAM_TIM_MODE_OPT(TimerCounterMode));

	//set power
	if (TIMx== LPC_TIM0)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM0, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER0, CLKPWR_PCLKSEL_CCLK_DIV_4);
	}
	else if (TIMx== LPC_TIM1)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM1, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER1, CLKPWR_PCLKSEL_CCLK_DIV_4);

	}

	else if (TIMx== LPC_TIM2)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM2, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER2, CLKPWR_PCLKSEL_CCLK_DIV_4);
	}
	else if (TIMx== LPC_TIM3)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM3, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER3, CLKPWR_PCLKSEL_CCLK_DIV_4);

	}

	TIMx->CTCR &= ~TIM_CTCR_MODE_MASK;
	TIMx->CTCR |= TimerCounterMode;

	TIMx->TC =0;
	TIMx->PC =0;
	TIMx->PR =0;
	TIMx->TCR |= (1<<1); //Reset Counter
	TIMx->TCR &= ~(1<<1); //release reset
	if (TimerCounterMode == TIM_TIMER_MODE )
	{
		pTimeCfg = (TIM_TIMERCFG_Type *)TIM_ConfigStruct;
		if (pTimeCfg->PrescaleOption  == TIM_PRESCALE_TICKVAL)
		{
			TIMx->PR   = pTimeCfg->PrescaleValue -1  ;
		}
		else
		{
			TIMx->PR   = converUSecToVal (converPtrToTimeNum(TIMx),pTimeCfg->PrescaleValue)-1;
		}
	}
	else
	{

		pCounterCfg = (TIM_COUNTERCFG_Type *)TIM_ConfigStruct;
		TIMx->CTCR  &= ~TIM_CTCR_INPUT_MASK;
		if (pCounterCfg->CountInputSelect == TIM_COUNTER_INCAP1)
			TIMx->CCR |= _BIT(2);
	}

	// Clear interrupt pending
	TIMx->IR = 0xFFFFFFFF;

}
Пример #26
0
/*********************************************************************//**
 * @brief		RIT interrupt handler sub-routine
 * @param[in]	None
 * @return 		None
 **********************************************************************/
void RIT_IRQHandler(void)
{
	RIT_GetIntStatus(LPC_RIT); //call this to clear interrupt flag
	LPC_GPIO0->FIOPIN ^= _BIT(10); //Toggle P0.10 led
}
Пример #27
0
LRESULT CIMoteTerminal::OnReceiveUSBData(WPARAM wParam, LPARAM lParam){
	//following couple of lines allow us to debug a raw datastream
	BYTE *InputReport = (BYTE *)lParam;
	USBmessage *usbMsg = ((USBmessage *)wParam);
	DWORD totalBytes, BytesRead = usbMsg->actualBytesRead;
	BYTE type;
	BYTE valid;
	USBdata *USBin;

	type = *(InputReport + IMOTE_HID_TYPE);

	USBin = &(m_dataIn[(type & 0x3)]);
	if(isFlagged(type, _BIT(IMOTE_HID_TYPE_H))){
		//this is the header of the overall set of packets
		USBin->i = 0;
		USBin->type = type;
		/*free(USBin->data);
		USBin->data = NULL;*/
		
		assert(USBin->data == NULL); //make sure that we're not leaking memory

		switch((USBin->type >> IMOTE_HID_TYPE_L) & 3){
			case IMOTE_HID_TYPE_L_BYTE:
				USBin->n = *(InputReport + IMOTE_HID_NI);
				if(USBin->n == 0)
				{
					valid = *(InputReport + IMOTE_HID_NI + 1);  //number of valid bytes
					totalBytes = valid;
				}
				else
				{
					valid = IMOTE_HID_BYTE_MAXPACKETDATA;
					totalBytes = (USBin->n + 1) * IMOTE_HID_BYTE_MAXPACKETDATA; 
				}
				USBin->data = (BYTE *)malloc(totalBytes);
				memcpy(USBin->data, InputReport + IMOTE_HID_NI + 1 + (USBin->n == 0?1:0), valid);
				break;

			case IMOTE_HID_TYPE_L_SHORT:
				USBin->n = (*(InputReport + IMOTE_HID_NI) << 8) | *(InputReport + IMOTE_HID_NI + 1);
				if(USBin->n == 0)
				{
					valid = *(InputReport + IMOTE_HID_NI + 2);
					totalBytes = valid;
				}
				else
				{
					valid = IMOTE_HID_SHORT_MAXPACKETDATA;
					totalBytes = (USBin->n + 1) * IMOTE_HID_SHORT_MAXPACKETDATA; 
				}
				USBin->data = (BYTE *)malloc(totalBytes);
				memcpy(USBin->data, InputReport + IMOTE_HID_NI + 2 + (USBin->n == 0?1:0), valid);
                break;

			case IMOTE_HID_TYPE_L_INT:
				USBin->n = (*(InputReport + IMOTE_HID_NI) << 24) | (*(InputReport + IMOTE_HID_NI + 1) << 16) | (*(InputReport + IMOTE_HID_NI + 2) << 8) | *(InputReport + IMOTE_HID_NI + 3);
				if(USBin->n == 0)
				{
					valid = *(InputReport + IMOTE_HID_NI + 4);
					totalBytes = valid;
				}			
				else
				{
					valid = IMOTE_HID_INT_MAXPACKETDATA;
					totalBytes = (USBin->n + 1) * IMOTE_HID_INT_MAXPACKETDATA; 
						
				}
				USBin->data = (BYTE *)malloc(totalBytes);
				memcpy(USBin->data, InputReport + IMOTE_HID_NI + 4 + (USBin->n == 0?1:0), valid);
                break;
			default:
				TRACE("AH HAH!\r\n");
		}
	}
	else{
		//continuing to receive the transmission
		switch((USBin->type >> IMOTE_HID_TYPE_L) & 3){
Пример #28
0
/*********************************************************************//**
 * @brief 		Initial Timer/Counter device
 * 				 	Set Clock frequency for ADC
 * 					Set initial configuration for ADC
 * @param[in]	TIMx  Timer selection, should be TIM0, TIM1, TIM2, TIM3
 * @param[in]	TimerCounterMode TIM_MODE_OPT
 * @param[in]	TIM_ConfigStruct pointer to TIM_TIMERCFG_Type
 * 				that contains the configuration information for the
 *                    specified Timer peripheral.
 * @return 		None
 **********************************************************************/
void TIM_Init(TIM_TypeDef *TIMx, uint8_t TimerCounterMode, void *TIM_ConfigStruct)
{
	TIM_TIMERCFG_Type *pTimeCfg;
	TIM_COUNTERCFG_Type *pCounterCfg;

	CHECK_PARAM(PARAM_TIMx(TIMx));
	CHECK_PARAM(PARAM_TIM_MODE_OPT(TimerCounterMode));
	uint32_t timer = TIM_ConverPtrToTimeNum(TIMx) ;
	//set power
	if (TIMx== TIM0)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM0, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER0, CLKPWR_PCLKSEL_CCLK_DIV_4);
	}
	else if (TIMx== TIM1)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM1, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER1, CLKPWR_PCLKSEL_CCLK_DIV_4);

	}

	else if (TIMx== TIM2)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM2, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER2, CLKPWR_PCLKSEL_CCLK_DIV_4);
	}
	else if (TIMx== TIM3)
	{
		CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCTIM3, ENABLE);
		CLKPWR_SetPCLKDiv (CLKPWR_PCLKSEL_TIMER3, CLKPWR_PCLKSEL_CCLK_DIV_4);

	}

	TIMx->CCR &= ~TIM_CTCR_MODE_MASK;
	TIMx->CCR |= TIM_TIMER_MODE;

	TIMx->TC =0;
	TIMx->PC =0;
	TIMx->PR =0;
	if (TimerCounterMode == TIM_TIMER_MODE )
	{
		pTimeCfg = (TIM_TIMERCFG_Type *)TIM_ConfigStruct;
		if (pTimeCfg->PrescaleOption  == TIM_PRESCALE_TICKVAL)
		{
			TIMx->PR   = pTimeCfg->PrescaleValue -1  ;
		}
		else
		{
			TIMx->PR   = TIM_ConverUSecToVal (TIM_ConverPtrToTimeNum(TIMx),pTimeCfg->PrescaleValue)-1;
		}
	}
	else
	{

		pCounterCfg = (TIM_COUNTERCFG_Type *)TIM_ConfigStruct;
		TIMx->CCR  &= ~TIM_CTCR_INPUT_MASK;
		if (pCounterCfg->CountInputSelect == TIM_COUNTER_INCAP1)
			TIMx->CCR |= _BIT(2);
		//set pin function
		PINSEL_ConfigPin((PINSEL_CFG_Type *)&timer_caption_pin[2*timer + pCounterCfg->CountInputSelect]);

	}

	// Clear interrupt pending
	TIMx->IR = 0xFFFFFFFF;

}