Example #1
0
void UART1_RX_IRQ()
{
    // Read cahracter
    unsigned char data = UART_ReadChar(UART1);

    // Put data into buffer
    *u1BufPtr = data;
    u1BufPtr++;


    if (data == CMD_DELIM)
    {
        // Simple buffer mantenance
        //  Don't use Ring Buffer, since we want string functions to
        //  be able to act on the buffer instead of copying it every
        //  time, which is time consuming
        if (u1BufPtr > u1Buf + 1000)
        {
            // Reset pointer to beginning of buffer
            u1BufPtr = u1Buf;
        }

        // Disabling local echo due to non-fifo U0TX implementation
        // Blocks, which drops data

        // Echo new line to USB
        //UART_WriteChar(UART0, ';');
    }
    else
    {
        // Echo to USB 
        //UART_WriteChar(UART0, data);
    }
}
Example #2
0
File: syscalls.c Project: cmonr/PAL
//TODO: getchar() does not function 
int _read(int file, char *ptr, int len)
{
    unsigned int i;
    for( i = 0; i < len; i++ ){
        ptr[i] = UART_ReadChar(PRINTF_UART_RX);
    }
    return len;
}
Example #3
0
/***************************************************************************//**
 * @brief Reads one command from console.
 *
 * @param command - Read command.
 *
 * @return None.
*******************************************************************************/
void CONSOLE_GetCommand(char* command)
{
    char receivedChar = 0;
    char charNumber   = 0;
    
    while((receivedChar != '\n') && (receivedChar != '\r'))
    {
        UART_ReadChar(&receivedChar);
        command[charNumber++] = receivedChar;
    }
}
Example #4
0
File: main.c Project: cmonr/PAL
int main(void)
{
    // Clock (80MHz)
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);

    // Init LEDs
    Pin_Init(rLED);
    Pin_Set(rLED, LOW);

    // Init UART0
    UART_Init(UART0);
    UART_Enable(UART0);
    setbuf(stdout, NULL);   // Disable printf internal buffer

    // Init I2C0
    I2C_Init(I2C0);
    I2C_Enable(I2C0);



    // Wait until user presses enter
    UART_ReadChar(UART0);

    // Scan for I2C addresses
    for(i=0; i < (1 << 7); i++)
    {
        printf("x%02x:", i);
        if (I2C_Write(I2C0, i, 0) == true)
            printf("* ");
        else    
            printf("  ");

        Pin_Toggle(rLED);


        if (i % 8 == 7)
            printf("\r\n");
    }

    // Indicator LED off
    Pin_Set(rLED, LOW);
       
    while(1);      
}
Example #5
0
File: uart.c Project: cmonr/PAL
void UART_Read(tUART* uart, unsigned char* buff, unsigned long len)
{
    for(; len > 0; len--)
       *buff++ = UART_ReadChar(uart);
}