upd72001.c

#include <sil.h>
#include "target_syssvc.h"
#include "upd72001.h"

ソースコードを見る。

データ構造

struct  sio_port_initialization_block
struct  sio_port_control_block

マクロ定義

#define UPD72001_DELAY   200U
#define UPD72001_CR0   0x00U
#define UPD72001_CR1   0x01U
#define UPD72001_CR2   0x02U
#define UPD72001_CR3   0x03U
#define UPD72001_CR4   0x04U
#define UPD72001_CR5   0x05U
#define UPD72001_CR10   0x0aU
#define UPD72001_CR12   0x0cU
#define UPD72001_CR14   0x0eU
#define UPD72001_CR15   0x0fU
#define UPD72001_SR0   0x00U
#define CR_RESET   0x18U
#define CR0_EOI   0x38U
#define CR1_DOWN   0x00U
#define CR1_RECV   0x10U
#define CR1_SEND   0x02U
#define CR3_DEF   0xc1U
#define CR4_DEF   0x44U
#define CR5_DEF   0xeaU
#define CR10_DEF   0x00U
#define CR14_DEF   0x07U
#define CR15_DEF   0x56U
#define SR0_RECV   0x01U
#define SR0_SEND   0x04U
#define INDEX_SIOP(siopid)   ((uint_t)((siopid) - 1))
#define get_siopcb(siopid)   (&(siopcb_table[INDEX_SIOP(siopid)]))

型定義

typedef struct
sio_port_initialization_block 
SIOPINIB

関数

Inline uint8_t upd72001_read_reg (void *addr)
Inline void upd72001_write_reg (void *addr, uint8_t val)
Inline uint8_t upd72001_read_ctrl (void *addr, uint8_t reg)
Inline void upd72001_write_ctrl (void *addr, uint8_t reg, uint8_t val)
Inline void upd72001_write_brg (void *addr, uint8_t reg, uint8_t val, uint8_t brg2, uint8_t brg1)
static void upd72001_get_stat (SIOPCB *p_siopcb)
Inline bool_t upd72001_getready (SIOPCB *p_siopcb)
Inline bool_t upd72001_putready (SIOPCB *p_siopcb)
Inline char_t upd72001_getchar (SIOPCB *p_siopcb)
Inline void upd72001_putchar (SIOPCB *p_siopcb, char_t c)
Inline void upd72001_eoi (void)
void upd72001_initialize (void)
bool_t upd72001_openflag (void)
SIOPCBupd72001_opn_por (ID siopid, intptr_t exinf)
void upd72001_cls_por (SIOPCB *p_siopcb)
bool_t upd72001_snd_chr (SIOPCB *p_siopcb, char_t c)
int_t upd72001_rcv_chr (SIOPCB *p_siopcb)
void upd72001_ena_cbr (SIOPCB *p_siopcb, uint_t cbrtn)
void upd72001_dis_cbr (SIOPCB *p_siopcb, uint_t cbrtn)
static void upd72001_isr_siop (SIOPCB *p_siopcb)
void upd72001_isr (void)

変数

const SIOPINIB siopinib_table [TNUM_SIOP]
SIOPCB siopcb_table [TNUM_SIOP]


マクロ定義

#define CR0_EOI   0x38U

upd72001.c79 行で定義されています。

参照元 upd72001_eoi().

#define CR10_DEF   0x00U

upd72001.c89 行で定義されています。

参照元 upd72001_opn_por().

#define CR14_DEF   0x07U

upd72001.c90 行で定義されています。

参照元 upd72001_opn_por().

#define CR15_DEF   0x56U

upd72001.c91 行で定義されています。

参照元 upd72001_opn_por().

#define CR1_DOWN   0x00U

upd72001.c81 行で定義されています。

参照元 upd72001_cls_por(), と upd72001_opn_por().

#define CR1_RECV   0x10U

upd72001.c82 行で定義されています。

参照元 upd72001_dis_cbr(), upd72001_ena_cbr(), と upd72001_isr_siop().

#define CR1_SEND   0x02U

upd72001.c83 行で定義されています。

参照元 upd72001_dis_cbr(), upd72001_ena_cbr(), と upd72001_isr_siop().

#define CR3_DEF   0xc1U

upd72001.c85 行で定義されています。

#define CR4_DEF   0x44U

upd72001.c86 行で定義されています。

#define CR5_DEF   0xeaU

upd72001.c87 行で定義されています。

#define CR_RESET   0x18U

upd72001.c77 行で定義されています。

参照元 upd72001_opn_por().

#define get_siopcb ( siopid   )     (&(siopcb_table[INDEX_SIOP(siopid)]))

upd72001.c141 行で定義されています。

参照元 upd72001_opn_por().

#define INDEX_SIOP ( siopid   )     ((uint_t)((siopid) - 1))

upd72001.c140 行で定義されています。

#define SR0_RECV   0x01U

upd72001.c93 行で定義されています。

参照元 upd72001_get_stat().

#define SR0_SEND   0x04U

upd72001.c94 行で定義されています。

参照元 upd72001_get_stat().

#define UPD72001_CR0   0x00U

upd72001.c61 行で定義されています。

参照元 upd72001_eoi().

#define UPD72001_CR1   0x01U

upd72001.c62 行で定義されています。

参照元 upd72001_cls_por(), upd72001_dis_cbr(), upd72001_ena_cbr(), と upd72001_opn_por().

#define UPD72001_CR10   0x0aU

upd72001.c67 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR12   0x0cU

upd72001.c68 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR14   0x0eU

upd72001.c69 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR15   0x0fU

upd72001.c70 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR2   0x02U

upd72001.c63 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR3   0x03U

upd72001.c64 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR4   0x04U

upd72001.c65 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_CR5   0x05U

upd72001.c66 行で定義されています。

参照元 upd72001_opn_por().

#define UPD72001_DELAY   200U

upd72001.c56 行で定義されています。

参照元 upd72001_read_reg(), と upd72001_write_reg().

#define UPD72001_SR0   0x00U

upd72001.c72 行で定義されています。

参照元 upd72001_get_stat().


型定義


関数

void upd72001_cls_por ( SIOPCB p_siopcb  ) 

void upd72001_dis_cbr ( SIOPCB p_siopcb,
uint_t  cbrtn 
)

upd72001.c383 行で定義されています。

参照先 sio_port_control_block::cr1, CR1_RECV, CR1_SEND, sio_port_initialization_block::ctrl, sio_port_control_block::p_siopinib, SIO_RDY_RCV, SIO_RDY_SND, UPD72001_CR1, と upd72001_write_ctrl().

参照元 sio_dis_cbr().

00384 {
00385     uint8_t cr1_bit = 0;
00386 
00387     switch (cbrtn) {
00388     case SIO_RDY_SND:
00389         cr1_bit = CR1_SEND;
00390         break;
00391     case SIO_RDY_RCV:
00392         cr1_bit = CR1_RECV;
00393         break;
00394     }
00395     p_siopcb->cr1 &= ~cr1_bit;
00396     upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl,
00397                                     UPD72001_CR1, p_siopcb->cr1);
00398 }

void upd72001_ena_cbr ( SIOPCB p_siopcb,
uint_t  cbrtn 
)

upd72001.c362 行で定義されています。

参照先 sio_port_control_block::cr1, CR1_RECV, CR1_SEND, sio_port_initialization_block::ctrl, sio_port_control_block::p_siopinib, SIO_RDY_RCV, SIO_RDY_SND, UPD72001_CR1, と upd72001_write_ctrl().

参照元 sio_ena_cbr().

00363 {
00364     uint8_t cr1_bit = 0;
00365 
00366     switch (cbrtn) {
00367     case SIO_RDY_SND:
00368         cr1_bit = CR1_SEND;
00369         break;
00370     case SIO_RDY_RCV:
00371         cr1_bit = CR1_RECV;
00372         break;
00373     }
00374     p_siopcb->cr1 |= cr1_bit;
00375     upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl,
00376                                     UPD72001_CR1, p_siopcb->cr1);
00377 }

Inline void upd72001_eoi ( void   ) 

upd72001.c256 行で定義されています。

参照先 CR0_EOI, TADR_UPD72001_CTRLA, UPD72001_CR0, と upd72001_write_ctrl().

参照元 upd72001_isr().

00257 {
00258     upd72001_write_ctrl((void *) TADR_UPD72001_CTRLA, UPD72001_CR0, CR0_EOI);
00259 }

static void upd72001_get_stat ( SIOPCB p_siopcb  )  [static]

upd72001.c199 行で定義されています。

参照先 sio_port_initialization_block::ctrl, sio_port_control_block::getready, sio_port_control_block::p_siopinib, sio_port_control_block::putready, SR0_RECV, SR0_SEND, upd72001_read_ctrl(), と UPD72001_SR0.

参照元 upd72001_getready(), と upd72001_putready().

00200 {
00201     uint8_t sr0;
00202 
00203     sr0 = upd72001_read_ctrl(p_siopcb->p_siopinib->ctrl, UPD72001_SR0);
00204     if ((sr0 & SR0_RECV) != 0) {
00205         p_siopcb->getready = true;
00206     }
00207     if ((sr0 & SR0_SEND) != 0) {
00208         p_siopcb->putready = true;
00209     }
00210 }

Inline char_t upd72001_getchar ( SIOPCB p_siopcb  ) 

upd72001.c236 行で定義されています。

参照先 sio_port_initialization_block::data, sio_port_control_block::getready, sio_port_control_block::p_siopinib, と upd72001_read_reg().

参照元 upd72001_rcv_chr().

00237 {
00238     p_siopcb->getready = false;
00239     return((char_t) upd72001_read_reg(p_siopcb->p_siopinib->data));
00240 }

Inline bool_t upd72001_getready ( SIOPCB p_siopcb  ) 

upd72001.c216 行で定義されています。

参照先 sio_port_control_block::getready, と upd72001_get_stat().

参照元 upd72001_isr_siop(), と upd72001_rcv_chr().

00217 {
00218     upd72001_get_stat(p_siopcb);
00219     return(p_siopcb->getready);
00220 }

void upd72001_initialize ( void   ) 

upd72001.c265 行で定義されています。

参照先 sio_port_control_block::openflag, sio_port_control_block::p_siopinib, と TNUM_SIOP.

参照元 sio_initialize().

00266 {
00267     SIOPCB  *p_siopcb;
00268     uint_t  i;
00269 
00270     /*
00271      *  シリアルI/Oポート管理ブロックの初期化
00272      */
00273     for (p_siopcb = siopcb_table, i = 0; i < TNUM_SIOP; p_siopcb++, i++) {
00274         p_siopcb->p_siopinib = &(siopinib_table[i]);
00275         p_siopcb->openflag = false;
00276     }
00277 }

void upd72001_isr ( void   ) 

upd72001.c424 行で定義されています。

参照先 upd72001_eoi(), と upd72001_isr_siop().

参照元 sio_isr().

00425 {
00426     if (siopcb_table[0].openflag) {
00427         upd72001_isr_siop(&(siopcb_table[0]));
00428     }
00429     if (siopcb_table[1].openflag) {
00430         upd72001_isr_siop(&(siopcb_table[1]));
00431     }
00432     upd72001_eoi();
00433 }

static void upd72001_isr_siop ( SIOPCB p_siopcb  )  [static]

upd72001.c404 行で定義されています。

参照先 sio_port_control_block::cr1, CR1_RECV, CR1_SEND, sio_port_control_block::exinf, upd72001_getready(), upd72001_irdy_rcv(), upd72001_irdy_snd(), と upd72001_putready().

参照元 upd72001_isr().

00405 {
00406     if ((p_siopcb->cr1 & CR1_RECV) != 0U && upd72001_getready(p_siopcb)) {
00407         /*
00408          *  受信通知コールバックルーチンを呼び出す.
00409          */
00410         upd72001_irdy_rcv(p_siopcb->exinf);
00411     }
00412     if ((p_siopcb->cr1 & CR1_SEND) != 0U && upd72001_putready(p_siopcb)) {
00413         /*
00414          *  送信可能コールバックルーチンを呼び出す.
00415          */
00416         upd72001_irdy_snd(p_siopcb->exinf);
00417     }
00418 }

bool_t upd72001_openflag ( void   ) 

upd72001.c283 行で定義されています。

参照元 sio_cls_por(), sio_opn_por(), と upd72001_opn_por().

00284 {
00285     return(siopcb_table[0].openflag || siopcb_table[1].openflag);
00286 }

SIOPCB* upd72001_opn_por ( ID  siopid,
intptr_t  exinf 
)

upd72001.c292 行で定義されています。

参照先 sio_port_initialization_block::brg1_def, sio_port_initialization_block::brg2_def, sio_port_control_block::cr1, CR10_DEF, CR14_DEF, CR15_DEF, CR1_DOWN, sio_port_initialization_block::cr3_def, sio_port_initialization_block::cr4_def, sio_port_initialization_block::cr5_def, CR_RESET, sio_port_initialization_block::ctrl, sio_port_control_block::exinf, get_siopcb, sio_port_control_block::getready, sio_port_control_block::openflag, sio_port_control_block::p_siopinib, sio_port_control_block::putready, TADR_UPD72001_CTRLA, TADR_UPD72001_CTRLB, UPD72001_CR1, UPD72001_CR10, UPD72001_CR12, UPD72001_CR14, UPD72001_CR15, UPD72001_CR2, UPD72001_CR3, UPD72001_CR4, UPD72001_CR5, upd72001_openflag(), upd72001_write_brg(), upd72001_write_ctrl(), と upd72001_write_reg().

参照元 sio_opn_por().

00293 {
00294     SIOPCB      *p_siopcb;
00295     const SIOPINIB  *p_siopinib;
00296 
00297     p_siopcb = get_siopcb(siopid);
00298     p_siopinib = p_siopcb->p_siopinib;
00299 
00300     upd72001_write_reg(p_siopinib->ctrl, CR_RESET);
00301     if (!upd72001_openflag()) {
00302         upd72001_write_ctrl((void *) TADR_UPD72001_CTRLA, UPD72001_CR2, 0x18);
00303         upd72001_write_ctrl((void *) TADR_UPD72001_CTRLB, UPD72001_CR2, 0x00);
00304     }
00305     p_siopcb->cr1 = CR1_DOWN;
00306     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR1, p_siopcb->cr1);
00307     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR4, p_siopinib->cr4_def);
00308     upd72001_write_brg(p_siopinib->ctrl, UPD72001_CR12, 0x01U,
00309                             p_siopinib->brg2_def, p_siopinib->brg1_def);
00310     upd72001_write_brg(p_siopinib->ctrl, UPD72001_CR12, 0x02U,
00311                             p_siopinib->brg2_def, p_siopinib->brg1_def);
00312     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR15, CR15_DEF);
00313     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR14, CR14_DEF);
00314     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR10, CR10_DEF);
00315     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR3, p_siopinib->cr3_def);
00316     upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR5, p_siopinib->cr5_def);
00317     p_siopcb->exinf = exinf;
00318     p_siopcb->getready = p_siopcb->putready = false;
00319     p_siopcb->openflag = true;
00320     return(p_siopcb);
00321 }

Inline void upd72001_putchar ( SIOPCB p_siopcb,
char_t  c 
)

upd72001.c246 行で定義されています。

参照先 sio_port_initialization_block::data, sio_port_control_block::p_siopinib, sio_port_control_block::putready, と upd72001_write_reg().

参照元 upd72001_snd_chr().

00247 {
00248     p_siopcb->putready = false;
00249     upd72001_write_reg(p_siopcb->p_siopinib->data, (uint8_t) c);
00250 }

Inline bool_t upd72001_putready ( SIOPCB p_siopcb  ) 

upd72001.c226 行で定義されています。

参照先 sio_port_control_block::putready, と upd72001_get_stat().

参照元 upd72001_isr_siop(), と upd72001_snd_chr().

00227 {
00228     upd72001_get_stat(p_siopcb);
00229     return(p_siopcb->putready);
00230 }

int_t upd72001_rcv_chr ( SIOPCB p_siopcb  ) 

upd72001.c350 行で定義されています。

参照先 upd72001_getchar(), と upd72001_getready().

参照元 sio_rcv_chr().

00351 {
00352     if (upd72001_getready(p_siopcb)) {
00353         return((int_t)(uint8_t) upd72001_getchar(p_siopcb));
00354     }
00355     return(-1);
00356 }

Inline uint8_t upd72001_read_ctrl ( void *  addr,
uint8_t  reg 
)

upd72001.c164 行で定義されています。

参照先 upd72001_read_reg(), と upd72001_write_reg().

参照元 upd72001_get_stat().

00165 {
00166     upd72001_write_reg(addr, reg);
00167     return(upd72001_read_reg(addr));
00168 }

Inline uint8_t upd72001_read_reg ( void *  addr  ) 

upd72001.c147 行で定義されています。

参照先 sil_dly_nse(), UPD72001_DELAY, と upd72001_reb_reg.

参照元 upd72001_getchar(), upd72001_read_ctrl(), と upd72001_write_brg().

00148 {
00149     uint8_t val;
00150 
00151     val = upd72001_reb_reg(addr);
00152     sil_dly_nse(UPD72001_DELAY);
00153     return(val);
00154 }

bool_t upd72001_snd_chr ( SIOPCB p_siopcb,
char_t  c 
)

upd72001.c337 行で定義されています。

参照先 upd72001_putchar(), と upd72001_putready().

参照元 sio_snd_chr().

00338 {
00339     if (upd72001_putready(p_siopcb)) {
00340         upd72001_putchar(p_siopcb, c);
00341         return(true);
00342     }
00343     return(false);
00344 }

Inline void upd72001_write_brg ( void *  addr,
uint8_t  reg,
uint8_t  val,
uint8_t  brg2,
uint8_t  brg1 
)

upd72001.c178 行で定義されています。

参照先 upd72001_read_reg(), と upd72001_write_reg().

参照元 upd72001_opn_por().

00180 {
00181     upd72001_write_reg(addr, reg);
00182     upd72001_write_reg(addr, val);
00183     upd72001_write_reg(addr, brg2);
00184     upd72001_write_reg(addr, brg1);
00185     (void) upd72001_read_reg(addr);     /* ダミーリード */
00186 }

Inline void upd72001_write_ctrl ( void *  addr,
uint8_t  reg,
uint8_t  val 
)

upd72001.c171 行で定義されています。

参照先 upd72001_write_reg().

参照元 upd72001_cls_por(), upd72001_dis_cbr(), upd72001_ena_cbr(), upd72001_eoi(), と upd72001_opn_por().

00172 {
00173     upd72001_write_reg(addr, reg);
00174     upd72001_write_reg(addr, val);
00175 }

Inline void upd72001_write_reg ( void *  addr,
uint8_t  val 
)

upd72001.c157 行で定義されています。

参照先 sil_dly_nse(), UPD72001_DELAY, と upd72001_wrb_reg.

参照元 upd72001_opn_por(), upd72001_putchar(), upd72001_read_ctrl(), upd72001_write_brg(), と upd72001_write_ctrl().

00158 {
00159     upd72001_wrb_reg(addr, val);
00160     sil_dly_nse(UPD72001_DELAY);
00161 }


変数

SIOPCB siopcb_table[TNUM_SIOP]

upd72001.c135 行で定義されています。

const SIOPINIB siopinib_table[TNUM_SIOP]

初期値:

upd72001.c125 行で定義されています。


Copyright © 2008 by Kijineko Inc.

ホームページ制作