Exemplo n.º 1
0
/*
 *  受信した文字の取出し
 */
Inline bool_t scif_getchar(SIOPCB *p_siopcb, char *rxdata)
{
	uint16_t fsrval;
	uint16_t lsrval;
	uint8_t read_data;

	fsrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFSR));
	lsrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCLSR));
	if (fsrval & (SCFSR_ER | SCFSR_BRK)) {
		fsrval = fsrval & ~(SCFSR_ER | SCFSR_BRK);
		sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFSR), fsrval);
	}
	if (lsrval & SCLSR_ORER) {
		lsrval = lsrval & ~SCLSR_ORER;
		sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCLSR), lsrval);
	}
	if (fsrval & SCFSR_RDF) {
		read_data = sil_reb_mem((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFRDR);
		fsrval = fsrval & ~SCFSR_RDF;
		sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFSR), fsrval);
		*rxdata = (char)read_data;
		return true;
	}
	return false;
}
Exemplo n.º 2
0
/*
 * ハードウェアの初期化処理
 */
static int scif_init_siopinib(const SIOPINIB *p_siopinib)
{
	uint16_t fsrval;
	uint8_t brrval;

	fsrval = UART_CLK / (32 * p_siopinib->bps_setting) - 1;
	if (fsrval > 255) return 1;
	brrval = (uint8_t)fsrval;

	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCSCR), 0);
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFCR), SCFCR_TFRST | SCFCR_RFRST);
	(void)sil_reh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR));
	(void)sil_reh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCLSR));
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR), 0);
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCLSR), 0);
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCSCR), SCSCR_INTCLK);
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCSMR), SCSMR_CKS1);	/* 8N1, P1clock/1 */
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCEMR), 0);
	sil_wrb_mem((uint8_t *)p_siopinib->port + REG_SCBRR, brrval);
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFCR), SCFCR_RSTRG_15 | SCFCR_RTRG_1 | SCFCR_TTRG_8);
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCSCR), SCSCR_TE | SCSCR_RE | SCSCR_INTCLK);
	while (sil_reh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR)) & SCFSR_RDF) {
		(void)sil_reb_mem((uint8_t *)p_siopinib->port + REG_SCFRDR);
		sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR), ~SCFSR_RDF);
	}
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR), 0);
	return 0;
}
Exemplo n.º 3
0
/*
 *  シリアルI/Oポートのオープン
 */
SIOPCB *
sh2scif_opn_por (ID siopid, VP_INT exinf)
{
	SIOPCB *siopcb;

	siopcb = get_siopcb (siopid);

	/*  送受信停止  */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCSCR),
				 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
									  SCIF_SCSCR)) & ~(SCSCR_TE | SCSCR_RE));

	/*  SCIFデータ入出力ポートの設定  */
	/*  ピンアサイン */
	/* sys_initializeで設定 */

	/*  FIFOの初期化  */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCFCR),
				 (VH) (SCFCR_TFRST | SCFCR_RFRST));

	/*  送受信フォーマット  */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCSMR), 0x0000);
	/*  調歩同期式  */
	/*  8ビット、パリティなし  */
	/*  ストップビットレングス:1   */
	/*  クロックセレクト */

	sil_wrb_mem ((VB *) (siopcb->siopinib->reg_base + SCIF_SCBRR),
				 (VB) siopcb->siopinib->brr);	/* ボーレート設定 */


	/*
	 * ボーレートの設定後、1カウント分待たなければならない。
	 */
	sil_dly_nse (sh2scif_DELAY);

	/*  FIFOの設定  */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCFCR), 0x0030);

	/* エラーフラグをクリア */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCFSR),
				 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
									  SCIF_SCFSR)) & ~SCFSR_ER);

	/*  送受信開始  */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCSCR),
				 (VH) (SCSCR_TE | SCSCR_RE));

	siopcb->exinf = exinf;
	siopcb->openflag = TRUE;
	return (siopcb);
}
Exemplo n.º 4
0
/*
 *  シリアルI/Oポートへのポーリングでの出力
 */
void
scif_pol_putc(char c, ID siopid)
{
	const SIOPINIB *p_siopinib;
	uint16_t fsrval;
	SIL_PRE_LOC;

	p_siopinib = get_siopinib(siopid);

	while(1) {
		/*
		 *  リエントラントにするため、全割込みロック状態にする。
		 */
		SIL_LOC_INT();

		fsrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR));
		if (fsrval & SCFSR_TDFE) {
			sil_wrb_mem((uint8_t *)p_siopinib->port + REG_SCFTDR, c);
			sil_wrh_mem((uint16_t *)((uint8_t *)p_siopinib->port + REG_SCFSR), ~(SCFSR_TEND | SCFSR_TDFE));
			/*
			 *  リターンする前に全割込みロックフラグを元の状態に戻す。
			 */
			SIL_UNL_INT();
			return;
		} else {
			/*
			 *  ここで全割込みロックを解除して、割込みを受け付ける。
			 */
			SIL_UNL_INT();
		}
	}
}
Exemplo n.º 5
0
/*
 *  文字を受信できるか?
 */
Inline BOOL
sh2scif_getready (SIOPCB * siopcb)
{
	/*  レシーブデータレジスタフル・フラグのチェック  */
	return (sil_reh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SC1SSR)) &
			SC1SSR_RDRF);
}
Exemplo n.º 6
0
/*
 *  文字を送信できるか?
 */
Inline BOOL
sh2scif_putready (SIOPCB * siopcb)
{
	/*  トランスミットFIFOデータレジスタエンプティ・フラグのチェック */
	return (sil_reh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SC1SSR)) &
			SC1SSR_TDFE);
}
Exemplo n.º 7
0
/*
 *  シリアルI/Oポートからのコールバックの禁止
 */
void
sh2scif_dis_cbr (SIOPCB * siopcb, UINT cbrtn)
{
	switch (cbrtn) {
	case SIO_ERDY_SND:			/* 送信割り込み要求を禁止 */
		sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCSCR),
					 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
										  SCIF_SCSCR)) & ~SCSCR_TIE);
		break;
	case SIO_ERDY_RCV:			/* 受信割り込み要求を禁止 */
		sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCSCR),
					 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
										  SCIF_SCSCR)) & ~SCSCR_RIE);
		break;
	}
}
Exemplo n.º 8
0
/* フラグをリセットする */
Inline void
sh2scif_isr_siop_brk (SIOPCB * siopcb)
{
	/* フラグをクリア */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SC1SSR),
				 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
									  SCIF_SC1SSR)) & ~SC1SSR_BRK);
}
Exemplo n.º 9
0
/*
 *  受信割込み許可
 */
Inline void scif_enable_rcv(SIOPCB *p_siopcb)
{
	uint16_t scrval;

	scrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCSCR));
	scrval |= SCSCR_RIE;
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCSCR), scrval);
}
Exemplo n.º 10
0
/*
 *  送信割込み禁止
 */
Inline void scif_disable_send(SIOPCB *p_siopcb)
{
	uint16_t scrval;

	scrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCSCR));
	scrval = scrval & ~SCSCR_TIE;
	sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCSCR), scrval);
}
Exemplo n.º 11
0
/*
 *  シリアルI/Oポートのオープン
 */
SIOPCB *
sh1sci_opn_por(ID siopid, VP_INT exinf)
{
	SIOPCB *siopcb = get_siopcb(siopid);
	VB scr, smr;
	VH pbcr1;

#ifdef GDB_STUB
	if (siopid == PORT1) {
		siopcb->exinf = exinf;
		siopcb->openflag = TRUE;
		return(siopcb);
	}
#endif	/*  GDB_STUB  */

	sh1_anb_reg(siopcb->inib->base + SCR, (VB)~(SCR_TE | SCR_RE));	/*  送受信停止  */

	/*  ピンアサイン
	 *     シリアルデバイス自体の事項ではないので
	 *     本来はこのファイルに記述するのはふさわしくないが、
	 *     hw_serial.cを用意するのも煩雑なので暫定的にここに入れている。
	 */
	pbcr1 = sil_reh_mem((VP)PBCR1);
	if (siopid == PORT1) {	/* PB08:RxD0 PB09:TxD0  */
		pbcr1 = (pbcr1 & PBCR1_TD0_RD0_MASK) | PBCR1_TD0 | PBCR1_RD0;
	} else {		/* PB10:RxD1 PB11:TxD1  */
		pbcr1 = (pbcr1 & PBCR1_TD1_RD1_MASK) | PBCR1_TD1 | PBCR1_RD1;
	}
	sil_wrh_mem((VP)PBCR1, pbcr1);
	
						/*  送受信フォーマット  */
	smr = siopcb->inib->smr_init;

	sil_wrb_mem(siopcb->inib->base + SMR, smr);
	
	sil_wrb_mem(siopcb->inib->base + BRR, (UB)siopcb->inib->baudrate);	/*  ボーレート設定  	*/

					/*  割込み禁止とクロックソースの選択 */
	scr = (VB)(~(SCR_TIE | SCR_RIE | SCR_TE | SCR_RE |
			  SCR_MPIE | SCR_TEIE | SCR_CKE_MASK) | SCR_CKE);
	sil_wrb_mem(siopcb->inib->base + SCR, scr);
	
	/*
	 * ボーレートの設定後、1カウント分待たなければならない。
	 */
	sil_dly_nse(siopcb->inib->delay);

					/* エラーフラグをクリア	*/
	sh1_anb_reg(siopcb->inib->base + SSR, (VB)~(SSR_ORER | SSR_FER | SSR_PER));
					/* 受信割り込み許可   	*/
					/* 送受信許可  		*/
	sh1_orb_reg(siopcb->inib->base + SCR, (SCR_RIE | SCR_TE | SCR_RE));
			/*  送信割込みの許可は送信制御関数で行う  */

	siopcb->exinf = exinf;
	siopcb->openflag = TRUE;
	return(siopcb);
}
Exemplo n.º 12
0
/*
 *  送信する文字の書込み
 */
Inline void
sh2scif_putchar (SIOPCB * siopcb, char c)
{
	/*  トランスミットFIFOデータレジスタエンプティ・フラグのクリア */
	sil_wrb_mem ((VB *) (siopcb->siopinib->reg_base + SCIF_SCFTDR), c);
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SC1SSR),
				 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
									  SCIF_SC1SSR)) & ~SC1SSR_TDFE);
}
Exemplo n.º 13
0
/*
 *  文字を送信できるか?
 */
Inline bool_t scif_putready(SIOPCB *p_siopcb)
{
	uint16_t fsrval;

	fsrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFSR));
	if (fsrval & SCFSR_TDFE) {
		return true;
	}
	return false;
}
Exemplo n.º 14
0
/*
 *  文字を受信したか?
 */
Inline bool_t scif_getready(SIOPCB *p_siopcb)
{
	uint16_t fsrval;
	uint16_t lsrval;

	fsrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFSR));
	lsrval = sil_reh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCLSR));
	if (fsrval & (SCFSR_ER | SCFSR_BRK)) {
		fsrval = fsrval & ~(SCFSR_ER | SCFSR_BRK);
		sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCFSR), fsrval);
	}
	if (lsrval & SCLSR_ORER) {
		lsrval = lsrval & ~SCLSR_ORER;
		sil_wrh_mem((uint16_t *)((uint8_t *)p_siopcb->p_siopinib->port + REG_SCLSR), lsrval);
	}
	if (fsrval & SCFSR_RDF) {
		return true;
	}
	return false;
}
Exemplo n.º 15
0
/*
 *  シリアルI/Oポートに対する受信エラー割込み処理
 */
Inline void
sh2scif_isr_siop_err (SIOPCB * siopcb)
{
	/* エラーフラグをクリア */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SC1SSR),
				 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
									  SCIF_SC1SSR)) & ~SC1SSR_ER);
	/*  FIFOの初期化  */
	sil_wrb_mem ((VB *) (siopcb->siopinib->reg_base + SCIF_SCFCR),
				 (VB) SCFCR_RFRST);
	sil_wrb_mem ((VB *) (siopcb->siopinib->reg_base + SCIF_SCFCR), 0x30);
}
Exemplo n.º 16
0
/*
 *  受信した文字の取出し
 */
Inline char
sh2scif_getchar (SIOPCB * siopcb)
{
	VB data;

	data = sil_reb_mem ((VB *) (siopcb->siopinib->reg_base + SCIF_SCFRDR));
	/*  レシーブデータレジスタフル・フラグのクリア  */
	sil_wrh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SC1SSR),
				 sil_reh_mem ((VH *) (siopcb->siopinib->reg_base +
									  SCIF_SC1SSR)) & ~SC1SSR_RDRF);
	return data;
}
Exemplo n.º 17
0
/*
 *  シリアルI/Oポートに対する受信割込み処理
 */
Inline void
sh2scif_isr_siop_in (SIOPCB * siopcb)
{
	VH scr0 = sil_reh_mem ((VH *) (siopcb->siopinib->reg_base + SCIF_SCSCR));

	if ((scr0 & SCSCR_RIE) != 0 && sh2scif_getready (siopcb)) {
		/*
		 *  受信通知コールバックルーチンを呼び出す.
		 */
		sh2scif_ierdy_rcv (siopcb->exinf);
	}
}
Exemplo n.º 18
0
/*
 *  送信する文字の書込み
 */
Inline void
sh1sci_putchar(SIOPCB *siopcb, char c)
{
	if (siopcb->inib->rs485if) {
		if (!(sil_reh_mem(PB_DR) & PB_TXE1)) {
			sh1_orh_reg(PB_DR, PB_TXE1);	/* TXENA ON 		*/
			sil_dly_nse(5000);		/* 5us 保護時間		*/
		}
		sil_wrb_mem(siopcb->inib->base + TDR ,c);
		/*  トランスミットデータレジスタエンプティ・フラグのクリア*/
		sh1_anb_reg(siopcb->inib->base + SSR, (VB)~SSR_TDRE);
		/*  TXENA OFF制御のため、のコールバックの許可 */
		sh1sci_ena_cbr(siopcb, SIO_ERDY_SND);
	} else {
#ifdef GDB_STUB
		gdb_stub_putc( c );
#else
		sil_wrb_mem(siopcb->inib->base + TDR ,c);

		/*  トランスミットデータレジスタエンプティ・フラグのクリア*/
		sh1_anb_reg(siopcb->inib->base + SSR, (VB)~SSR_TDRE);
#endif
	}
}
Exemplo n.º 19
0
/*
 *  シリアルI/Oポートの初期化 banner出力のためカーネルの初期化と無関係に行う
 */
void
sys_initialize ()
{
	SIOPCB *siopcb;

	/* 使用する周辺機器はここで有効にしておく。 */
	/*  SCIデータ入出力ポートの設定  */

#ifndef GDB_STUB

	/* SCI1 */
	sil_wrh_mem (MSTCR1, (VH) ((VH) sil_reh_mem (MSTCR1) & ~0x0002));
	sil_wrh_mem (PACRL2, sil_reh_mem (PACRL2) | (PFC_TXD1 | PFC_RXD1));
#if TNUM_PORT >=2
	/* SCI0 */
	sil_wrh_mem (MSTCR1, (VH) ((VH) sil_reh_mem (MSTCR1) & ~0x0001));
	sil_wrh_mem (PACRL2, sil_reh_mem (PACRL2) | (PFC_TXD0 | PFC_RXD0));
#endif /*TNUM_PORT >=2 */

#else /* GDB_STUB */

	/* SCI0 */
	sil_wrh_mem (MSTCR1, (VH) ((VH) sil_reh_mem (MSTCR1) & ~0x0001));
	sil_wrh_mem (PACRL2, sil_reh_mem (PACRL2) | (PFC_TXD0 | PFC_RXD0));

#endif /* GDB_STUB */

	/* CMT0 */
	sil_wrh_mem (MSTCR2, (VH) ((VH) sil_reh_mem (MSTCR2) & ~0x1000));
	/*
	 *  デバイス依存のオープン処理.
	 */
	/*バナー出力するため */
	sh2sci_initialize();
	siopcb = sh2sci_opn_por (LOGTASK_PORTID, 0);
}
Exemplo n.º 20
0
Inline UB
st16c_read(UW addr, UW offset)
{
    return(sil_reh_mem((VP)(addr + offset)));
}