| Mobil_surveillance_system 1 | 
UART1 functions header file. More...
#include <string.h>#include <stdlib.h>#include "msp430f2617.h"#include "Bitmanip.h"#include "FIFO.h"#include "Interrupts.h"Go to the source code of this file.
| Defines | |
| #define | UART1_RX_BUFFER_SIZE 16 | 
| #define | UART1_TX_BUFFER_SIZE 16 | 
| #define | DEFINE_TBOOLEAN | 
| #define | UART1_TX_BUFFER_USED | 
| #define | UART1_TX_BUFFER_FREE (UART1_TX_BUFFER_SIZE - UART1_TX_BUFFER_USED) | 
| #define | UART1_TX_BUFFER_EMPTY | 
| #define | UART1_TX_BUFFER_FULL | 
| #define | UART1_ADVANCE_TX_BUFFER_INDEX(Index) ((Index) = ((Index) + 1) % UART1_TX_BUFFER_SIZE) | 
| #define | UART1_RX_BUFFER_USED | 
| #define | UART1_RX_BUFFER_FREE (UART1_RX_BUFFER_SIZE - UART1_RX_BUFFER_USED) | 
| #define | UART1_RX_BUFFER_EMPTY | 
| #define | UART1_RX_BUFFER_FULL | 
| #define | UART1_ADVANCE_RX_BUFFER_INDEX(Index) ((Index) = ((Index) + 1) % UART1_RX_BUFFER_SIZE) | 
| Typedefs | |
| typedef unsigned char | tBoolean | 
| typedef void(* | tpfUART1AppendResponseCallbackFunction )(const char *) | 
| Functions | |
| void | UART1_rxHandler (void) | 
| void | UART1_txHandler (void) | 
| void | UART1_initUART1 (void) | 
| int | UART1_read (void) | 
| int | UART1_write (char *pcBuffer, unsigned int uiLength) | 
| void | UART1_sendChar (void) | 
| tBoolean | UART1_isWritingDone (void) | 
| void | UART1_primeTransmit (void) | 
| void | UART1_flushRx (void) | 
| void | UART1_flushTx (void) | 
| void | UART1_setAppendResponseCallbackFunction (tpfUART1AppendResponseCallbackFunction pfCallbackAppendResponse) | 
| Variables | |
| tBoolean | ge_tbUART1RXITFLAG | 
| This flag inicates if any character has been received. | |
| tBoolean | ge_tbUART1TXITFLAG | 
| This flag inicates if any character has been sent. | |
UART1 functions header file.
This file contains functions prototypes reltad to the UART1 pertiferia.
Definition in file UART1.h.
| #define UART1_ADVANCE_RX_BUFFER_INDEX | ( | Index | ) | ((Index) = ((Index) + 1) % UART1_RX_BUFFER_SIZE) | 
| #define UART1_ADVANCE_TX_BUFFER_INDEX | ( | Index | ) | ((Index) = ((Index) + 1) % UART1_TX_BUFFER_SIZE) | 
| #define UART1_RX_BUFFER_EMPTY | 
This macro can be used to decide if the rx fifo is free.
| #define UART1_RX_BUFFER_FREE (UART1_RX_BUFFER_SIZE - UART1_RX_BUFFER_USED) | 
| #define UART1_RX_BUFFER_FULL | 
(FIFO_isBufferFull(&g_uiUart1RxReadIndex,\ &g_uiUart1RxWriteIndex, \ UART1_RX_BUFFER_SIZE))
This macro can de used to decide if the rx fifo is full.
| #define UART1_RX_BUFFER_USED | 
(FIFO_getBufferCount(&g_uiUart1RxReadIndex,\ &g_uiUart1RxWriteIndex,\ UART1_RX_BUFFER_SIZE))
This macro can be used to determine the current elements in the rx fifo.
| #define UART1_TX_BUFFER_EMPTY | 
This macro can be used to decide if the tx fifo is free.
| #define UART1_TX_BUFFER_FREE (UART1_TX_BUFFER_SIZE - UART1_TX_BUFFER_USED) | 
| #define UART1_TX_BUFFER_FULL | 
(FIFO_isBufferFull(&g_uiUart1TxReadIndex,\ &g_uiUart1TxWriteIndex,\ UART1_TX_BUFFER_SIZE))
This macro can de used to decide if the tx fifo is full.
| #define UART1_TX_BUFFER_USED | 
(FIFO_getBufferCount(&g_uiUart1TxReadIndex,\ &g_uiUart1TxWriteIndex,\ UART1_TX_BUFFER_SIZE))
This macro can be used to determine the current elements in the tx fifo.
| typedef void(* tpfUART1AppendResponseCallbackFunction)(const char *) | 
| void UART1_initUART1 | ( | void | ) | 
proba
Definition at line 118 of file UART1.c.
{
    P3OUT &= ~(BIT6+BIT7);
    // P3.6,7 = USCI_A1 TXD/RXD
    P3SEL = 0xC0;
    // CLK = ACLK
    UCA1CTL1 |= UCSSEL_1; 
    // 9600
    UCA1BR0 = 0x03;      // 32kHz/9600 = 3.41  
    // 9600                       
    UCA1BR1 = 0x00;
    // Modulation UCBRSx = 5
    UCA1MCTL = UCBRS1 + UCBRS0; // 
    // **Initialize USCI state machine**              
    UCA1CTL1 &= ~UCSWRST; 
    // Enable USCI_A1 RX interrupt                    
    UC1IE |= UCA1RXIE;
    // Enable USCI_A1 TX interrupt     
    UC1IE |= UCA1TXIE;  
    // Enable global interrupt
    _bis_SR_register(LPM3_bits + GIE);
    // set RX ISR callback function
    Interrupts_setUSCI1RX_ISRCallbackFunction(&UART1_rxHandler);
    // set TX ISR callback function;    
    Interrupts_setUSCI1TX_ISRCallbackFunction(&UART1_txHandler);              
}
| void UART1_setAppendResponseCallbackFunction | ( | tpfUART1AppendResponseCallbackFunction | pfCallbackAppendResponse | ) | 
| pfCallbackAppendResponse | 
Definition at line 169 of file UART1.c.
{
    g_pfOnCallbackGPSAppendResponse = pfCallbackAppendResponse;
}
| int UART1_write | ( | char * | pcBuffer, | 
| unsigned int | uiLength | ||
| ) | 
| pcBuffer | |
| uiLength | 
Definition at line 206 of file UART1.c.
{
    unsigned int uiIdx;
    for( uiIdx = 0; uiIdx < uiLength; uiIdx++ ){
        if(!UART1_TX_BUFFER_FULL){
            g_pcUart1TxBuffer[g_uiUart1TxWriteIndex] = pcBuffer[uiIdx];
            UART1_ADVANCE_TX_BUFFER_INDEX(g_uiUart1TxWriteIndex);
        }
        else{
            // TODO if the tx buffer is full
        }
    }
    if(!UART1_TX_BUFFER_EMPTY){
        // send as many characters to the uart buffer as many can
        UART1_primeTransmit();
    }
    // return the number of the character written into the buffer
    return uiIdx;
}
 1.7.4
 1.7.4