Пример #1
0
/*
 * do a bulk transfer
 */
int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
					void *buffer, int len)
{
	int dir_out = usb_pipeout(pipe);
	int ep = usb_pipeendpoint(pipe);
#ifndef MUSB_NO_MULTIPOINT
	int devnum = usb_pipedevice(pipe);
#endif
	u8  type;
	u16 csr;
	u32 txlen = 0;
	u32 nextlen = 0;
	u8  devspeed;

	/* select bulk endpoint */
	writeb(MUSB_BULK_EP, &musbr->index);

#ifndef MUSB_NO_MULTIPOINT
	/* write the address of the device */
	if (dir_out)
		writeb(devnum, &musbr->tar[MUSB_BULK_EP].txfuncaddr);
	else
		writeb(devnum, &musbr->tar[MUSB_BULK_EP].rxfuncaddr);
#endif

	/* configure the hub address and the port number as required */
	devspeed = get_dev_speed(dev);
	if ((musb_ishighspeed()) && (dev->parent != NULL) &&
		(devspeed != MUSB_TYPE_SPEED_HIGH)) {
		/*
		 * MUSB is in high speed and the destination device is full
		 * speed device. So configure the hub address and port
		 * address registers.
		 */
		config_hub_port(dev, MUSB_BULK_EP);
	} else {
#ifndef MUSB_NO_MULTIPOINT
		if (dir_out) {
			writeb(0, &musbr->tar[MUSB_BULK_EP].txhubaddr);
			writeb(0, &musbr->tar[MUSB_BULK_EP].txhubport);
		} else {
			writeb(0, &musbr->tar[MUSB_BULK_EP].rxhubaddr);
			writeb(0, &musbr->tar[MUSB_BULK_EP].rxhubport);
		}
#endif
		devspeed = musb_cfg.musb_speed;
	}

	/* Write the saved toggle bit value */
	write_toggle(dev, ep, dir_out);

	if (dir_out) { /* bulk-out transfer */
		/* Program the TxType register */
		type = (devspeed << MUSB_TYPE_SPEED_SHIFT) |
			   (MUSB_TYPE_PROTO_BULK << MUSB_TYPE_PROTO_SHIFT) |
			   (ep & MUSB_TYPE_REMOTE_END);
		writeb(type, &musbr->txtype);

		/* Write maximum packet size to the TxMaxp register */
		writew(dev->epmaxpacketout[ep], &musbr->txmaxp);
		while (txlen < len) {
			nextlen = ((len-txlen) < dev->epmaxpacketout[ep]) ?
					(len-txlen) : dev->epmaxpacketout[ep];

			/* Write the data to the FIFO */
			write_fifo(MUSB_BULK_EP, nextlen,
					(void *)(((u8 *)buffer) + txlen));

			/* Set the TxPktRdy bit */
			csr = readw(&musbr->txcsr);
			writew(csr | MUSB_TXCSR_TXPKTRDY, &musbr->txcsr);

			/* Wait until the TxPktRdy bit is cleared */
			if (!wait_until_txep_ready(dev, MUSB_BULK_EP)) {
				readw(&musbr->txcsr);
				usb_settoggle(dev, ep, dir_out,
				(csr >> MUSB_TXCSR_H_DATATOGGLE_SHIFT) & 1);
				dev->act_len = txlen;
				return 0;
			}
			txlen += nextlen;
		}

		/* Keep a copy of the data toggle bit */
		csr = readw(&musbr->txcsr);
		usb_settoggle(dev, ep, dir_out,
				(csr >> MUSB_TXCSR_H_DATATOGGLE_SHIFT) & 1);
	} else { /* bulk-in transfer */
Пример #2
0
static void
WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
	write_fifo(cs->hw.spt.isac, data, size);
}
Пример #3
0
static void
isac_write_fifo(struct IsdnCardState *cs, u8 * data, int size)
{
	write_fifo(cs->hw.teles3.isacfifo, data, size);
}
Пример #4
0
static void
hscx_write_fifo(struct IsdnCardState *cs, int hscx, u8 *data, int size)
{
	write_fifo(cs->hw.teles3.hscxfifo[hscx], data, size);
}
Пример #5
0
/*
** Send the spooler a command to re-read a group definition
*/
static void reread_group(const char *group)
	{
	write_fifo("NG %s\n", group);
	}
Пример #6
0
static void gprs_switch(void)
{
	esn_msg_t esn_msg;
	esn_msg.event = GPRS_EVENT;
	if (e_state == E_SEND)
	{
		led_set(LED_RED, FALSE);
		write_fifo(send.buf, send.len);
	}
	else if (e_state == E_SEND_OK)
	{
		cipsend_ok_cb();
	}
	else if(e_state == E_OPEN)
	{
		e_state = E_IDLE;
		if(IS_HIGTH)
		{
			PULL_DOWN;
			vTaskDelay(2000 / portTICK_RATE_MS);
			PULL_UP;
			vTaskDelay(3000 / portTICK_RATE_MS);
		}
		else
		{
			DBG_ASSERT(FALSE __DBG_LINE);    //不可能进入这里
		}
		xQueueSend(gprs_queue, &esn_msg, portMAX_DELAY);
	}
	else if (e_state == E_CLOSE)
	{
		gprs_info.gprs_state = WORK_DOWN;
		led_set(LEN_GREEN, FALSE);
		led_set(LED_RED, FALSE);
		if(GPRS_DETECT_STATUS())            //判断是否是GPRS开机状态
		{
            if(gprs_info.data_mode)
            {
                vTaskDelay(1000 / portTICK_RATE_MS);
                write_fifo("+++",  sizeof("+++") - 1);
                vTaskDelay(1000 / portTICK_RATE_MS);
            }
			write_fifo(CIPCLOSE,  sizeof(CIPCLOSE) - 1);
			vTaskDelay(500 / portTICK_RATE_MS);
			PULL_DOWN;
			vTaskDelay(2000 / portTICK_RATE_MS);
			PULL_UP;
			vTaskDelay(2000 / portTICK_RATE_MS);
		}
		else
		{
			PULL_UP;
			vTaskDelay(5000 / portTICK_RATE_MS);
		}
		e_state = E_OPEN;
		xQueueSend(gprs_queue, &esn_msg, portMAX_DELAY);
	}
	else if (e_state == E_IDLE)
	{
		gprs_info.gprs_state = WORK_DOWN;
		static uint8_t idle_num = 0;
		led_set(LEN_GREEN, FALSE);
		if (idle_num++ >= 5)
			DBG_ASSERT(FALSE __DBG_LINE);
		
		if ((GPRS_DETECT_STATUS() != FALSE))
		{
			idle_num = 0;
			uint8_t cgatt_num = 0;
			bool_t cgatt_mark = FALSE;
			
			gprs_info.gprs_state = READY_IDLE;
			write_fifo(AT,  sizeof(AT) - 1);
			vTaskDelay(300 / portTICK_RATE_MS);
			
			if (at_deal())
				write_fifo(ATE0, sizeof(ATE0) - 1);
			else
			{
				switch_rest();
				return;
			}
			vTaskDelay(300 / portTICK_RATE_MS);
			
			if (ate0_deal())
				write_fifo(CSMINS, sizeof(CSMINS) - 1);
			else
			{
				switch_rest();
				return;
			}
			vTaskDelay(300 / portTICK_RATE_MS);
			
			if (csmins_deal())	//检查SIM卡
				write_fifo(CGATT, sizeof(CGATT) - 1);
			else
			{
				gprs_info.gprs_state = SIM_ERROR;
				return;
			}
			vTaskDelay(300 / portTICK_RATE_MS);
			
			while (cgatt_num++ < 20)
			{
				if (cgatt_deal())	//附着网络
				{
					cgatt_mark = TRUE;
					break;
				}
				else
					write_fifo(CGATT, sizeof(CGATT) - 1);
				vTaskDelay(2000 / portTICK_RATE_MS);
			}
			if (cgatt_mark == FALSE)
			{
				switch_rest();
				return;
			}
			
			if(gprs_info.data_mode) //判断是否开启数据透传
			{
				write_fifo(SCIPMODE, sizeof(SCIPMODE) - 1);
				vTaskDelay(300 / portTICK_RATE_MS);
				if(cipmode_deal() == FALSE)
				{
					switch_rest();
					return;
				}
			}
			
			if(switch_join()==FALSE)
			{
				switch_rest();
				return;
			}
			
			gprs_info.gprs_state = WORK_ON;
			gprs_info.lost_cnt = 0;
			led_set(LEN_GREEN, TRUE);
			esn_msg.event = GPRS_CNN_START;
			xQueueSend(esn_gain_queue, &esn_msg, portMAX_DELAY);
		}
		else
		{
			switch_rest();
		}
	}
	else if (e_state == E_REST)
	{
		gprs_info.gprs_state = WORK_DOWN;
		e_state = E_CLOSE;
		xQueueSend(gprs_queue, &esn_msg, portMAX_DELAY);
	}
}