示例#1
0
static void
cyg_hal_plf_sci_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len)
{
    CYGARC_HAL_SAVE_GP();

    while(__len-- > 0)
        *__buf++ = cyg_hal_plf_sci_getc(__ch_data);

    CYGARC_HAL_RESTORE_GP();
}
示例#2
0
// Packet function
void 
hal_diag_write_char(char c)
{
#ifdef CYG_HAL_DIAG_GDB
    static char line[100];
    static int pos = 0;

    // No need to send CRs
    if( c == '\r' ) return;

    line[pos++] = c;

    if( c == '\n' || pos == sizeof(line) )
    {
        CYG_INTERRUPT_STATE old;

        // Disable interrupts. This prevents GDB trying to interrupt us
        // while we are in the middle of sending a packet. The serial
        // receive interrupt will be seen when we re-enable interrupts
        // later.
        
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
        CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old);
#else
        HAL_DISABLE_INTERRUPTS(old);
#endif
        
        while(1)
        {
            char c1;
            static char hex[] = "0123456789ABCDEF";
            cyg_uint8 csum = 0;
            int i;
        
            cyg_hal_plf_sci_putc(&channel, '$');
            cyg_hal_plf_sci_putc(&channel, 'O');
            csum += 'O';
            for( i = 0; i < pos; i++ )
            {
                char ch = line[i];
                char h = hex[(ch>>4)&0xF];
                char l = hex[ch&0xF];
                cyg_hal_plf_sci_putc(&channel, h);
                cyg_hal_plf_sci_putc(&channel, l);
                csum += h;
                csum += l;
            }
            cyg_hal_plf_sci_putc(&channel, '#');
            cyg_hal_plf_sci_putc(&channel, hex[(csum>>4)&0xF]);
            cyg_hal_plf_sci_putc(&channel, hex[csum&0xF]);

            // Wait for the ACK character '+' from GDB here and handle
            // receiving a ^C instead.
            c1 = (char) cyg_hal_plf_sci_getc(&channel);

            if( c1 == '+' )
                break;              // a good acknowledge

            // Check for user break.
            if( cyg_hal_is_break( &c1, 1 ) )
                cyg_hal_user_break( NULL );

            // otherwise, loop round again
        }
        
        pos = 0;

        // And re-enable interrupts
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
        CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old);
#else
        HAL_RESTORE_INTERRUPTS(old);
#endif
    }
示例#3
0
void
hal_diag_read_char(char *c)
{
    *c = (char) cyg_hal_plf_sci_getc(&channel);
}