static cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8 ch; while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)); return ch; }
static cyg_bool cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch) { int delay_count; channel_data_t* chan; cyg_bool res; CYGARC_HAL_SAVE_GP(); // Some of the diagnostic print code calls through here with no idea what the ch_data is. // Go ahead and assume it is channels[0]. if (__ch_data == 0) __ch_data = (void*)&channels[0]; chan = (channel_data_t*)__ch_data; delay_count = chan->msec_timeout * 10; // delay in .1 ms steps for(;;) { res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch); if (res || 0 == delay_count--) break; CYGACC_CALL_IF_DELAY_US(100); } CYGARC_HAL_RESTORE_GP(); return res; }
cyg_uint8 cyg_hal_plf_serial_getc(channel_data_t *chan) { cyg_uint8 ch; while(!cyg_hal_plf_serial_getc_nonblock(chan, &ch)); return ch; }
static bool hal_diag_read_serial(char *c) { long timeout = 1000000000; // A long time... while (!cyg_hal_plf_serial_getc_nonblock(&ser_channel, c)) if (0 == --timeout) return false; return true; }
//=========================================================================== // Read single character blocking //=========================================================================== cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8 ch; CYGARC_HAL_SAVE_GP(); while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)); CYGARC_HAL_RESTORE_GP(); return ch; }
cyg_uint8 CYGOPT_HAL_KINETIS_DIAG_FLASH_SECTION_ATTR cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8 ch; CYGARC_HAL_SAVE_GP(); while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)); CYGARC_HAL_RESTORE_GP(); return ch; }
cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8* base = ((channel_data_t*)__ch_data)->base; cyg_uint8 ch; CYGARC_HAL_SAVE_GP(); /* see if there's some cached data in the FIFO */ if (!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)) { /* there isn't - open the flood gates */ FLOWCTL_WAIT_FOR(DSR); FLOWCTL_SET(RTS); while (!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)); FLOWCTL_CLEAR(RTS); } CYGARC_HAL_RESTORE_GP(); return ch; }
cyg_bool cyg_hal_plf_serial_getc_timeout(channel_data_t *chan, cyg_uint8* ch) { int delay_count; cyg_bool res; delay_count = chan->msec_timeout * 10; // delay in .1 ms steps for(;;) { res = cyg_hal_plf_serial_getc_nonblock(chan, ch); if (res || 0 == delay_count--) break; CYGACC_CALL_IF_DELAY_US(100); } return res; }
static cyg_bool cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch) { int delay_count = msec_timeout * 10; // delay in .1 ms steps cyg_bool res; for(;;) { res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch); if (res || 0 == delay_count--) break; CYGACC_CALL_IF_DELAY_US(100); } return res; }
cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8 ch; CYGARC_HAL_SAVE_GP(); // Some of the diagnostic print code calls through here with no idea what the ch_data is. // Go ahead and assume it is channels[0]. if (__ch_data == 0) __ch_data = (void*)&channels[0]; while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)); CYGARC_HAL_RESTORE_GP(); return ch; }
//=========================================================================== // Read single character with timeout //=========================================================================== cyg_bool cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch) { int delay_count; channel_data_t* chan = (channel_data_t*)__ch_data; cyg_bool res; CYGARC_HAL_SAVE_GP(); delay_count = chan->msec_timeout * 10; // delay in .1 ms steps for(;;) { res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch); if (res || 0 == delay_count--) break; CYGACC_CALL_IF_DELAY_US(100); } CYGARC_HAL_RESTORE_GP(); return res; }
cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8 ch; int delay_timer = 0; CYGARC_HAL_SAVE_GP(); while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)) { CYGACC_CALL_IF_DELAY_US(50); // A reasonable time // Only delay every 10ms or so if (++delay_timer == 10*20) { dram_delay_loop(); delay_timer = 0; } } CYGARC_HAL_RESTORE_GP(); return ch; }
cyg_bool CYGOPT_HAL_KINETIS_DIAG_FLASH_SECTION_ATTR cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* p_ch_in) { int delay_count; cyg_bool res; CYGARC_HAL_SAVE_GP(); // delay in .1 ms steps delay_count = ((channel_data_t*)__ch_data)->msec_timeout * 10; for(;;) { res = cyg_hal_plf_serial_getc_nonblock(__ch_data, p_ch_in); if (res || 0 == delay_count--) break; CYGACC_CALL_IF_DELAY_US(100); } CYGARC_HAL_RESTORE_GP(); return res; }
cyg_bool cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch) { #if 1 int delay_count; channel_data_t* chan = (channel_data_t*)__ch_data; cyg_uint8* base = chan->base; cyg_uint8 last, val; cyg_bool res; CYGARC_HAL_SAVE_GP(); /* see if there's any cached data in the FIFO */ res = cyg_hal_plf_serial_getc_nonblock(__ch_data,ch); if (!res) { /* there isn't - open the flood gates */ delay_count = chan->msec_timeout * 125; // want delay in 8uS steps HAL_WRITE_UINT8(TM0BR,200); // IOCLK is 25MHz, we want 125KHz HAL_WRITE_UINT8(TM0MD,0x40); // stop and load HAL_WRITE_UINT8(TM0MD,0x80); // set source to be IOCLK and go HAL_READ_UINT8(TM0BC,last); while (delay_count>0 && !FLOWCTL_QUERY(DSR)) { HAL_READ_UINT8(TM0BC,val); if (val==last) continue; if (val>last) delay_count--; // count the underflows last = val; } if (delay_count==0) goto timeout; FLOWCTL_SET(RTS); while (delay_count>0 && !LSR_QUERY(DR)) { HAL_READ_UINT8(TM0BC,val); if (val==last) continue; if (val>last) delay_count--; // count the underflows last = val; } FLOWCTL_CLEAR(RTS); if (LSR_QUERY(DR)) { HAL_READ_UINT8(base+CYG_DEV_RBR, *ch); res = true; } timeout: HAL_WRITE_UINT8(TM0MD,0x00); // stop h/w timer } CYGARC_HAL_RESTORE_GP(); return res; #else int delay_count; channel_data_t* chan = (channel_data_t*)__ch_data; cyg_uint8* base = chan->base; cyg_bool res; CYGARC_HAL_SAVE_GP(); /* see if there's some cached data in the FIFO */ res = cyg_hal_plf_serial_getc_nonblock(__ch_data,ch); if (!res) { /* there isn't - open the flood gates */ delay_count = chan->msec_timeout * 1000; // want delay in uS steps for (; delay_count>0 && !FLOWCTL_QUERY(DSR); delay_count--) CYGACC_CALL_IF_DELAY_US(1); if (delay_count==0) goto timeout; FLOWCTL_SET(RTS); for (; delay_count>0 && !LSR_QUERY(DR); delay_count--) CYGACC_CALL_IF_DELAY_US(1); FLOWCTL_CLEAR(RTS); if (LSR_QUERY(DR)) { HAL_READ_UINT8(base+CYG_DEV_RBR, *ch); res = true; } } timeout: CYGARC_HAL_RESTORE_GP(); return res; #endif }