API UART: Rozdiel medzi revíziami

Z Kiwiki
Skočit na navigaci Skočit na vyhledávání
Riadok 5: Riadok 5:
 
== Aplikačné rozhranie bloku UART ==
 
== Aplikačné rozhranie bloku UART ==
  
void UART_Start(BYTE bParity) Enable user module and set parity.   
+
* '''UART_Start''' Enable user module and set parity.   
void UART_Stop(void)  Disable user module.   
+
* '''UART_Stop''' Disable user module.   
void UART_EnableInt(void)  Enable both RX and TX interrupts.   
+
* '''UART_EnableInt'''  Enable both RX and TX interrupts.   
void UART_DisableInt(void)  Disable both RX and TX interrupts.   
+
* '''UART_DisableInt'''  Disable both RX and TX interrupts.   
void UART_SetTxIntMode(BYTE bTxIntMode) Set the source of the Tx interrupt.   
+
* '''UART_SetTxIntMode''' Set the source of the Tx interrupt.   
void UART_SendData(BYTE bTxData) Send byte without checking TX status.   
+
* '''UART_SendData''' Send byte without checking TX status.   
BYTE UART_bReadTxStatus(void) Return status of TX Status register.   
+
* '''UART_bReadTxStatus''' Return status of TX Status register.   
BYTE UART_bReadRxData(void) Return data in RX Data register without checking status of character is valid.   
+
* '''UART_bReadRxData''' Return data in RX Data register without checking status of character is valid.   
BYTE UART_bReadRxStatus(void) Check status of RX Status register.
+
* '''UART_bReadRxStatus''' Check status of RX Status register.
  
 
== Príklady použitia ==
 
== Príklady použitia ==

Verzia zo dňa a času 23:41, 27. máj 2010


Imbox draft.png
Toto je projekt, na ktorom sa ešte stále pracuje!!

Aj keď sú v tomto dokumente použiteľné informácie, ešte nie je dokončený. Svoje návrhy môžete vyjadriť v diskusii o tejto stránke.

Aplikačné rozhranie bloku UART

  • UART_Start Enable user module and set parity.
  • UART_Stop Disable user module.
  • UART_EnableInt Enable both RX and TX interrupts.
  • UART_DisableInt Disable both RX and TX interrupts.
  • UART_SetTxIntMode Set the source of the Tx interrupt.
  • UART_SendData Send byte without checking TX status.
  • UART_bReadTxStatus Return status of TX Status register.
  • UART_bReadRxData Return data in RX Data register without checking status of character is valid.
  • UART_bReadRxStatus Check status of RX Status register.

Príklady použitia

Zdrojový kód jednoduchého povelového interpreteru. Program prijíma znaky z UART a podľa ich významu vykonáva predvolené aktivity.

_main:	
        mov   A,UART_PARITY_NONE        ; inicializacia serioveho rozhrania  
        call  UART_Start         
	M8C_EnableGInt   

   WaitForData:                         ; cakanie na prichod znaku     
        call  UART_bReadRxStatus    
        and   A, UART_RX_COMPLETE    
        jz    WaitForData        
     
        call  UART_bReadRxData          ; nacitanie znaku     
        call  UART_SendData             ; echo znaku  
    
 
 	cmp A,'x'                       ; skok na aktivitu 'x'
 	jz state_x
 	
 	cmp A,'y'			; skok na aktivitu 'y'
 	jz state_y
 	
        jmp   WaitForData               ; navrat do slucky cakania na novy znak

state_x:   
        .....                           ; implementacia aktivity 'x'
        jmp   WaitForData

state_y:   
        .....                           ; implementacia aktivity 'y'
        jmp   WaitForData

Odkazy a literatúra