gonzui


Format: Advanced Search

mtkernel_3/device/ser/ser.hbare sourcepermlink (0.00 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    Device Driver for micro T-Kernel for μT-Kernel 3.00.05
    4:  *
    5:  *    Copyright (C) 2020-2021 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.2.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2021/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: 
   15: /*
   16:  *      dev_ser.h
   17:  *      Serial communication device driver
   18:  *      Driver local definition
   19:  */
   20: 
   21: #ifndef __DEV_SER_H__
   22: #define __DEV_SER_H__
   23: 
   24: #include "../include/dev_ser.h"
   25: #include "../common/drvif/msdrvif.h"
   26: #include "ser_cnf.h"
   27: 
   28: /*----------------------------------------------------------------------
   29:  * Hardware dependent definition
   30:  */
   31: #ifdef CPU_TMPM367FDFG
   32: #include "sysdepend/tx03_m367/ser_m367.h"
   33: #endif          /* CPU_TMPM367FDFG */
   34: #ifdef CPU_RX231
   35: #include "sysdepend/rx231/ser_rx231.h"
   36: #endif  /* CPU_RX231 */
   37: #ifdef CPU_STM32L4
   38: #include "sysdepend/stm32l4/ser_stm32l4.h"
   39: #endif  /* CPU_STM32L4 */
   40: #ifdef CPU_RZA2M
   41: #include "sysdepend/rza2m/ser_rza2m.h"
   42: #endif  /* CPU_RZA2M */
   43: 
   44: 
   45: /*----------------------------------------------------------------------
   46:  * Communication data buffer
   47:  */
   48: typedef struct {
   49:         UW     top;
   50:         UW     tail;
   51:         ID     wait_tskid;
   52:         UB     data[DEVCONF_SER_BUFFSIZE];
   53: } T_SER_BUFF;
   54: 
   55: Inline  void buff_init(T_SER_BUFF *buff)
   56: {
   57:         buff->top = buff->tail = buff->wait_tskid = 0;
   58: }
   59: 
   60: /*----------------------------------------------------------------------
   61:  * Device driver Control block
   62:  */
   63: typedef struct {
   64:         UW     unit;               /* Unit No. */
   65:         UINT   omode;            /* Open mode */
   66: 
   67:         /* Attribute data */
   68:         ID     evtmbfid;   /* MBF ID for event notification */
   69:         UW     com_mode;   /* Communication mode */
   70:         UW     com_speed;  /* Communication Speed */
   71:         UW     com_error;  /* Communication Error */
   72:         TMO    snd_tmo;   /* Send timeout */
   73:         TMO    rcv_tmo;   /* Receive timeout */
   74: 
   75:         /* Intrrupt number */
   76:         UINT   intno_rcv;
   77:         UINT   intno_snd;
   78: 
   79:         /* Communication data buffer */
   80:         T_SER_BUFF     snd_buff;
   81:         T_SER_BUFF     rcv_buff;
   82: 
   83: } T_SER_DCB;
   84: 
   85: /*----------------------------------------------------------------------
   86:  * Serial device driver low-level interface
   87:  */
   88: 
   89: /* The following functions are defined in the system common part. */
   90: IMPORT BOOL dev_ser_get_snddat(UW unit, UW *data);      /* Get send data */
   91: IMPORT void dev_ser_notify_rcv(UW unit, UW data);       /* Notification of receipt */
   92: IMPORT void dev_ser_notify_err(UW unit, UW err);        /* Communication error notification */
   93: 
   94: /* The following functions are defined in the system-dependent part. */
   95: 
   96: /* Low-level device control */
   97: IMPORT ER dev_ser_llctl(UW, INT, UW);           /* Low-Level device control */
   98: IMPORT ER dev_ser_llinit(T_SER_DCB*);           /* Low-level device initialization */
   99: 
  100: /* Low-level device control command */
  101: typedef enum {
  102:         LLD_SER_MODE,          /* Set Communication mode */
  103:         LLD_SER_SPEED,         /* Set Communication Speed */
  104:         LLD_SER_START,         /* Start communication */
  105:         LLD_SER_STOP,          /* Stop Start communication */
  106:         LLD_SER_SEND,          /* Send data */
  107:         LLD_SER_BREAK,         /* Send Break */
  108:         LLD_SER_INTCTL,                /* Interrupt control */
  109: } T_LLD_SER_CMD;
  110: 
  111: #endif          /* __DEV_SER_H__ */