⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcm44t.a51

📁 8051实时操作系统
💻 A51
字号:
$TITLE (iDCM 44 COMMUNICATIONS FIRMWARE: COMM TASK MODULE)
$DATE (8 AUGUST 86)
$NOMO
$PAGING
$REGISTERBANK (0)

;***************************************************************************
;*
;*     TITLE:          iDCM 44 COMMUNICATIONS FIRMWARE: COMM TASK MODULE
;*
;*     RELEASE:        2.0
;*
;*     DESCRIPTION:    THIS MODULE CONTAINS THE COMM TASK PROCEDURES
;*
;*     UPDATES:
;*
;***************************************************************************

;*         

;*           COPYRIGHT 1983, 1986 INTEL CORPORATION

;*

;*           INTEL CORPORATION PROPRIETARY INFORMATION.  THIS LISTING

;*           IS SUPPLIED UNDER THE TERMS OF A LICENSE  AGREEMENT WITH

;*           INTEL CORPORATION  AND MAY NOT  BE COPIED NOR  DISCLOSED

;*           EXCEPT IN  ACCORDANCE WITH THE  TERMS OF THAT AGREEMENT.

;* 

;***************************************************************************

NAME    DCM44T


USING 0

$include(reg44.pdf)
$include(dcm44c.lit)
$include(dcx51a.mac)

$include(dcx51a.lit)


PUBLIC  comm_task, event_detect, te_set_wait

EXTRN   CODE (init_serial, init_parallel_sw, local_gateway_switch)

EXTRN   CODE (serial_timeout, input_interrupt_check, output_interrupt_check)
EXTRN   CODE (serial_interrupt_check, reqwait)


EXTRN   DATA (s_timeout_val)


EXTRN   BIT  (s_timeout_set, x_parallel_enabled, i_blocked_flag)

DCMFW_CODE_SEG  SEGMENT CODE

RSEG            DCMFW_CODE_SEG

;***************************************************************************
;*
;*     INITIAL TASK DESCRIPTOR DEFINITION
;*
;*     THIS STRUCTURE DEFINES THE INITIAL TASK DESCRIPTOR FOR THE
;*     COMMUNICATIONS TASK UNDER DCX 51.  IT'S LOCATION IS DECLARED
;*     IN THE DCM44C.A51 CONFIGURATION FILE AS THE FIRST ITD.
;*
;*     THE INITIAL PROGRAM COUNTER IS THE COMM_TASK.
;*     THE REQUIRED STACK LENGTH IS 6 BYTES, 4 FOR DCX, 2 FOR INTERNAL
;*             CALLS.
;*     THE DCM44 COMMUNICATION TASK FUNCTION ID IS SPECIFIED AS 1.
;*     THE TASK IS CREATED TO OWN REGISTER BANK 0, UNIQUELY.
;*     THE TASK HAS THE HIGHEST PRIORITY IN THE SYSTEM, 4.
;*     THE TASK USES THE EXT INT 0, EXT INT 1, AND THE SERIAL INTERRUPT.
;*     THE NEXT ITD, USER DEFINED, MUST BE LOCATED AT 0FFF0H.
;*     
;***************************************************************************

PUBLIC  DCM_COMMUNICATIONS_ITD

DCM_COMMUNICATIONS_ITD:

        %ITD(comm_task, 6, 1, 100B, 4, 10101B, 0FFF0H)

                                ;comm_task    = beginning pc addr

                                ;6 = stack leng.  May need only 4

                                ;1            = function id

                                ;100B         = use register bank 0

                                ;4            = priority

                                ;10101B       = Assign SIU, Ext0, and

                                ;               Ext1 interrupts

                                ;0FFF0H       = Next ITD

PUBLIC  RQFIRSTITD
        RQFIRSTITD      EQU     DCM_COMMUNICATIONS_ITD

$EJECT
;***************************************************************************
;*
;*     PROCEDURE:      comm_task
;*
;*     PURPOSE:        Initialize H/W and S/W, initiate operations
;*
;*     CALLED FROM:    None
;*
;*     ENTERED FROM:   iDCX 51 task initialization
;*
;*     CALLS:          init_serial             (no parameters)
;*                     init_parallel_sw        (no parameters)
;*
;*     ENTERS:         event_detect            (no parameters)
;*
;*     INPUTS:         None
;*
;*     RETURNS:        Does not return - jump to event_detect
;*
;*     DESCRIPTION:    Comm_Task is the entry point to the Communications
;*                     Task under iRMX 51.     It executes the initialization
;*                     procedures, then jumps to event_detect to
;*                     iteratively process events.
;*
;***************************************************************************

comm_task:
    acall   init_serial                  ;init. siu and serial h/w & s/w
    acall   init_parallel_sw             ;init. parallel variables

;   ajmp    event_detect                 ;wait on first event

$EJECT
;***************************************************************************
;*
;*     PROCEDURE:      event_detect
;*
;*     PURPOSE:        Wait for and decode incoming messages and interrupts   
;*
;*     CALLED FROM:    None
;*
;*     ENTERED FROM:   comm_task
;*
;*     CALLS:          rqwait                          (event_vector in A,
;*                                                      timeout in B)
;*                                                     (event_type in A,
;*                                                      msg_ptr in R6,R7
;*                                                        on Return)
;*                     local_gateway_switch            (msg_ptr in R0)
;*                     output_interrupt_check          (no parameters)
;*
;*     ENTERS:         input_interrupt_check           (no parameters)
;*                     serial_interrupt_check          (no parameters)
;*                     serial_timeout                  (no parameters)
;*
;*     INPUTS:         None
;*
;*     RETURNS:        None - procedure loops forever
;*
;*     DESCRIPTION:    Event_detect waits for an incoming interrupt or message
;*                     It decodes the result and calls the appropriate
;*                     procedure.
;*
;*                     Initially, a serial interrupt is checked for to avoid
;*                     making an unnecessary context switch.  Otherwise,
;*                     the first step is to set up to do an RQWAIT.  If the
;*                     S_Timeout_Set is set, meaning that a response
;*                     from a secondary station is being waited for, then
;*                     the event vector for the RQWAIT is set for a timeout
;*                     and the timeout parameter is set to the BITBUS's
;*                     timeout period.  Also if the parallel input is blocked

;*                     because of no receive buffer then the timeout is set.

;*                     Otherwise, no timeout is waited for.

;*

;*                     Once RQWAIT returns, the status vector is
;*                     checked for a timeout, interrupt, or message as
;*                     the event received.  If a timeout, then if a serial

;*                     type of timeout is flagged, then Serial_Timeout is

;*                     If a serial type of timeout is not flagged, then

;*                     the Input Interrupt Check is called to check for

;*                     a free buffer.  If an interrupt, then the
;*                     status is checked for serial, parallel input,
;*                     or parallel output type.  The appropriate interrupt
;*                     handler is called.  The Input Interrupt type of

;*                     of condition is checked first to see if the input

;*                     function is enabled.  If not, the interrupt is

;*                     discarded.  If a message, then the
;*                     Local_Gateway_Switch is called to route it.
;*                     
;*                     For any functions which are called as opposed to

;*                     entered via a jump, after the call event_detect is

;*                     executed again.  Those functions which are jumped

;*                     to will jump back to execute event_detect.

;*
;***************************************************************************

event_detect:
    jb      si,te_serial_interrupt_check ;if serial interrupt, process directly

    jbc     i_blocked_flag,te_input_interrupt_check ;


te_set_wait:

    mov     b,s_timeout_val            ;set default timeout value
    mov     a,#(interrupt_event or message_event) ;wait for interrupt or msg.
    jb      s_timeout_set,te_comm_event_wait ;if serial timeout set, use default
    jb      i_blocked_flag,te_comm_event_wait;if waiting on buffer, use default

    mov     b,#wait_forever             ;if no timeout needed, wait forever

    
te_comm_event_wait:
    call    reqwait                     ;wait for an event
    jb      acc.interrupt_bmsk,te_decode_interrupt ;if interrupt, jump

    jb      acc.message_bmsk,te_local_gateway_switch_send ;if msg., jump

    jnb     s_timeout_set,te_parallel_interrupt_check ;if blocked timeout, jump
    ajmp    serial_timeout              ;else go process serial timeout



te_local_gateway_switch_send:
    mov     r0,ar7                      ;r0 => received message       
    acall   local_gateway_switch        ;route message
    sjmp    event_detect                ;and go wait on another event

te_decode_interrupt:                                                  

;if not serial interrupt, go check other two interrupts
    jnb     acc.serial_interrupt_bpos, te_parallel_interrupt_check

te_serial_interrupt_check:
    ajmp    serial_interrupt_check      ;if serial int. jump


te_parallel_interrupt_check:
    jnb     x_parallel_enabled,te_set_wait ; if parallel not config, go wait



te_output_interrupt_check:
    jnb     acc.output_interrupt_bpos,te_input_interrupt_check

    acall   output_interrupt_check      ;process output interrupt

    sjmp    event_detect


te_input_interrupt_check:
    ajmp    input_interrupt_check       ;else, process input interrupt

END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -