Ejemplo n.º 1
0
Archivo: gps.c Proyecto: mdunne/ANIMA
void GPS_Init(void) {
    GtransmitBuffer = (struct CircBuffer*) &GoutgoingUart; //set up buffer for receive
    GPSnewCircBuffer(GtransmitBuffer);

    GreceiveBuffer = (struct CircBuffer*) &GincomingUart; //set up buffer for transmit
    GPSnewCircBuffer(GreceiveBuffer);

    UARTConfigure(UART2, 0x00);
    UARTSetDataRate(UART2, F_PB, 38400);
    UARTSetFifoMode(UART2, UART_INTERRUPT_ON_RX_NOT_EMPTY | UART_INTERRUPT_ON_RX_NOT_EMPTY);

    mU2SetIntPriority(4); //set the interrupt priority

    UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX));

    mU2RXIntEnable(1);
    mU2TXIntEnable(1);
    GPS_Configure();
}
Ejemplo n.º 2
0
Archivo: Uart.c Proyecto: sdajani/sdp
void UART_init(uint8_t id, uint32_t baudRate){

    //will need buffers for both the UARTS
    if(id == UART1_ID){
        transmitBufferUart1 = (struct CircBuffer*) &outgoingUart1; //set up buffer for receive
        newCircBuffer(transmitBufferUart1);

        receiveBufferUart1 = (struct CircBuffer*) &incomingUart1; //set up buffer for transmit
        newCircBuffer(receiveBufferUart1);

        UARTConfigure(UART1, 0x00);
        UARTSetDataRate(UART1, F_PB, baudRate);
        UARTSetFifoMode(UART1, UART_INTERRUPT_ON_RX_NOT_EMPTY);

        mU1SetIntPriority(4); //set the interrupt priority

        UARTEnable(UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX));
        mU1RXIntEnable(1);
        mU1TXIntEnable(1);
    }else if(id == UART2_ID){
        transmitBufferUart2 = (struct CircBuffer*) &outgoingUart2; //set up buffer for receive
        newCircBuffer(transmitBufferUart2);

        receiveBufferUart2 = (struct CircBuffer*) &incomingUart2; //set up buffer for transmit
        newCircBuffer(receiveBufferUart2);

        UARTConfigure(UART2, 0x00);
        UARTSetDataRate(UART2, F_PB, baudRate);
        UARTSetFifoMode(UART2, UART_INTERRUPT_ON_RX_NOT_EMPTY);

        mU2SetIntPriority(4); //set the interrupt priority

        UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_TX | UART_RX));
        mU2RXIntEnable(1);
        mU2TXIntEnable(1);
    }
}