Beispiel #1
0
/*
 *  シリアルI/Oポート割込みハンドラ
 */
void sio_handler(void)
{
	int port;

	for(port = 0; port < TNUM_PORT; ++ port)
	{
		if(BITTEST(siopcb_table[port].Flag, SIO_STA_OPEN))
		{
				/* 受信完了割込み */
			if(BITTEST(siopcb_table[port].Flag, SIO_STA_INTRCV))
			{
					/* 受信した文字を取り出し */
				BITCLEAR(siopcb_table[port].Flag, SIO_STA_INTRCV);
				sio_ierdy_rcv(GET_SIOPCB(ID_PORT(port))->exinf);

			}

				/* 送信完了割込み */
			if(BITTEST(siopcb_table[port].Flag, SIO_STA_INTSND))
			{
				BITCLEAR(siopcb_table[port].Flag, SIO_STA_INTSND);
				sio_ierdy_snd(GET_SIOPCB(ID_PORT(port))->exinf);
			}
		}
	}
}
Beispiel #2
0
/*
 *  シリアルI/Oポートのオープン
 */
SIOPCB * sio_opn_por(ID siopid, VP_INT exinf)
{
	BOOL     success;
	SIOPCB * siopcb = GET_SIOPCB(siopid);

	assert(siopcb != NULL);

	siopcb->exinf = exinf;

	success = TRUE;
	switch(SIO_TYP(siopcb->Flag))
	{
	case SIO_TYP_CONSOLE:
		HALExecuteProcedure(CreateSerialConsole,siopcb);
		break;
	case SIO_TYP_TTY:
		WinConsole_CreatePort(siopcb);
		break;
	case SIO_TYP_SCRBUF:
		HALExecuteProcedure(ScreenBuffer_CreatePort,siopcb);
		break;
	case SIO_TYP_RAWSIO:
		HALExecuteProcedure(RawSerial_CreatePort,siopcb);
		break;
	default:
		success = FALSE;
	}

	if(success == TRUE)
		BITSET(siopcb->Flag, SIO_STA_OPEN);

	return siopcb;
}
Beispiel #3
0
void sio_handler_in(void)
{
	int port;

	for(port = 0; port < TNUM_PORT; ++ port)
	{
		if( hw_port_getready(&siopcb_table[port]) == TRUE )
			sio_ierdy_rcv(GET_SIOPCB(ID_PORT(port))->exinf);
	}
}
Beispiel #4
0
/**
 * \ingroup SIOAPI
 * \brief 割込みサービスルーチン
 * \param exinf 拡張
 * \details
 * porting.txtの8.3節で養成されている割り込みサービスルーチン。
 * このルーチンはextinfの情報を元にどの割り込みが発生したか自動判別
 * している。
 *
 * extinfにどのような情報を与えるかは、明言されていないように思える。
 * CORTEX-M3版ではポート番号(1から始まってTNUM_PORTまでの識別
 * 番号)がtarget_erial.cfgの中でATTISRのextinf引数として与えられている。
 */
void sio_isr(intptr_t exinf)
{
	SIOPCB* siopcb = GET_SIOPCB(exinf);
	int32_t reg = siopcb->reg_base;
		/* 送信コールバック可能でかつ送信可能なら、送信コールバックを呼ぶ  */
	if (sio_putready(siopcb) && ( uart_read(reg, UART_IER) &  IER_TX)) {
		sio_irdy_snd(siopcb->exinf);
	}
		/* 受信コールバック可能でかつ受信可能なら、受信コールバックを呼ぶ  */
	if (sio_getready(siopcb) && ( uart_read(reg, UART_IER) &  IER_RX)) {
		sio_irdy_rcv(siopcb->exinf);
	}
}
Beispiel #5
0
/**
 * \ingroup SIOAPI
 * \brief シリアル・オープン
 * \param siopid SIOを識別する番号。1から TNUM_PORTまでの整数
 * \param exinf 拡張情報。コールバックを呼ぶときに引数として渡す
 * \details
 * シリアル・ペリフェラルを初期化する。ペリフェラルはプロトコル、スピードなどの
 * 設定を終え、割り込み禁止状態で待機する。この関数に続いて sio_ena_cbrが
 * 呼び出される。
 *
 * 引数extinfで渡される情報を処理する必要はない。この引数はそのまま
 * sio_irdy_sndおよび sio_irdy_rcvコールバックに渡される。
 *
 * プロトコルは8bit, 1stopbit, parityなしに決めうちしていい。
 */
SIOPCB *sio_opn_por(ID siopid, intptr_t exinf)
{
	SIOPCB* siopcb;

	if (siopid > TNUM_PORT) {
		return NULL;
	}

	siopcb = GET_SIOPCB(siopid);
	siopcb->exinf = exinf;

	target_uart_init(siopid);

	return siopcb;
}
Beispiel #6
0
void sio_handler_out(void)
{
	int port;

	for(port = 0; port < TNUM_PORT; ++ port)
	{
		if((siopcb_table[port].flags & SIO_STS_SENDING) != 0)
		{
			/* 送信ステータス初期化 */
			sil_wrb_mem((void *)(SIOCR(port)+2), 0x1);
			siopcb_table[port].flags &= ~SIO_STS_SENDING;

			sio_ierdy_snd(GET_SIOPCB(ID_PORT(port))->exinf);
		}
	}
}
Beispiel #7
0
/*
 *  シリアルI/Oポートのオープン
 */
SIOPCB *
sio_opn_por(ID siopid, VP_INT exinf)
{
	SIOPCB * siopcb = GET_SIOPCB(siopid);

	siopcb->exinf = exinf;

	switch(SIO_TYP(siopcb->flags)) {
	case SIO_TYP_M32RUART:

		/* UART初期化 */
		sil_wrb_mem((void *)(SIOCR(siopcb->port)+3), 0);

		/* ポートを開く(UART0) */
		sil_wrb_mem((void *)PDATA(5), 0);
		sil_wrb_mem((void *)PDIR(5),  0x80);

		/* UART, Non-parity, 1 stop-bit */
		sil_wrb_mem((void *)(SIOMOD0(siopcb->port)+3), 0);

		/* 8bit, internal clock */
		sil_wrh_mem((void *)(SIOMOD1(siopcb->port)+2), 0x0800);

		/* M32R(32102) - f(BLK)=16MHzで115200bps */
		sil_wrh_mem((void *)(SIOBAUR(siopcb->port)+2), SERIAL_CLKDIV);
		sil_wrb_mem((void *)(SIORBAUR(siopcb->port)+3), SERIAL_CLKCMP);

		/* 送受信割込み発生許可 */
		sil_wrh_mem((void *)(SIOTRCR(siopcb->port)+2), 0x0006);

		/* ステータスクリア, 送受信動作開始 */
		sil_wrb_mem((void *)(SIOCR(siopcb->port)+2), 0x3);
		sil_wrb_mem((void *)(SIOCR(siopcb->port)+3), 0x3);

		/* 受信割込み受付許可 */
		sil_wrh_mem((void *)(ICUCR(SIO,siopcb->port)+2), 0x1000);
		sil_wrh_mem((void *)(ICUCR(SIO,siopcb->port)+6), 0x1000);

		/* TxD,RxDピン有効(UART0) */
		sil_wrh_mem((void *)PMOD(5), 0x5500);

		break;
	}

	return siopcb;
}