hal_diag.c File Reference


Detailed Description

HAL diagnostic output.

Author:
Yoshinori Sato, Uwe Kindler
Date:
2003-12-06
Implementations of HAL diagnostic output support.

Definition in file hal_diag.c.

Go to the source code of this file.

Functions

void hal_console_comm_init (channel_data_t *pchan, cyg_uint8 chan_no)
 Initializes diagnostic channel.

void hal_diag_init (channel_data_t *pchan_arg)
 Initialize dignostic device manually (no virtual vector support).

void hal_diag_write_char (char c)
 Write char to diagnostic device.

void hal_diag_read_char (char *c)
 Read character from diagnostic device.

int hal_diag_put_buf (const char *pbuf_in, int len_in)
 Outputs a buffer of len_in bytes via diagnostic device.

void hal_diag_put_string (unsigned char *pstr_in)
 Sends zero terminated string through diagnostic device.

void hal_diag_put_long (unsigned long l_in)
 Send long value through diagnostic serial channel.

char hal_lnibble_to_hex (char n_in)
 Converts low nibble of byte into hex char.

unsigned char hal_long_to_hexbuf (long l_in, char *phexbuf_out)
 Converts long into hex string.

void hal_diag_put_long_hex (long l_in)
 Converts long into hex string and sends it through diagnostic device.


Variables

channel_data_tpchannel


Function Documentation

void hal_console_comm_init channel_data_t pchan,
cyg_uint8  chan_no
 

Initializes diagnostic channel.

Initialisation of one diagnostic channel and setting the of COMM table for this channel if virtual vectors are used.

Parameters:
pchan Points to buffer holding channel configuration data
chan_no Number of virtual vector channel

Definition at line 108 of file hal_diag.c.

References hal_sci_control(), hal_sci_getc(), hal_sci_getc_timeout(), hal_sci_init_channel(), hal_sci_isr(), hal_sci_putc(), hal_sci_read(), hal_sci_write(), and channel_data_t::isr_vector.

Referenced by cyg_hal_plf_comms_init().

00109 {
00110     hal_virtual_comm_table_t *pvcomm_tbl;
00111     int                       cur;
00112     
00113     //
00114     // first save the current console channel settings
00115     //
00116     cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
00117     //
00118     // Now we we initailise the channel an store there patrameters into
00119     // tom COMM tables of the virtual vector calling interface
00120     //
00121     HAL_INTERRUPT_MASK(pchan->isr_vector);          // Disable interrupts
00122     hal_sci_init_channel((void *)pchan);            // Init channel 
00123     //
00124     // Setup procs in the vector table
00125     // Initialize channel procs
00126     //
00127     CYGACC_CALL_IF_SET_CONSOLE_COMM(chan_no);
00128     pvcomm_tbl = CYGACC_CALL_IF_CONSOLE_PROCS();
00129     CYGACC_COMM_IF_CH_DATA_SET(*pvcomm_tbl, pchan);
00130     CYGACC_COMM_IF_WRITE_SET(*pvcomm_tbl, hal_sci_write);
00131     CYGACC_COMM_IF_READ_SET(*pvcomm_tbl, hal_sci_read);
00132     CYGACC_COMM_IF_PUTC_SET(*pvcomm_tbl, hal_sci_putc);
00133     CYGACC_COMM_IF_GETC_SET(*pvcomm_tbl, hal_sci_getc);
00134     CYGACC_COMM_IF_CONTROL_SET(*pvcomm_tbl, hal_sci_control);
00135     CYGACC_COMM_IF_DBG_ISR_SET(*pvcomm_tbl, hal_sci_isr);
00136     CYGACC_COMM_IF_GETC_TIMEOUT_SET(*pvcomm_tbl, hal_sci_getc_timeout);
00137     //
00138     //  Now we restore the original console which was saved previously
00139     //
00140     CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
00141 }

Here is the call graph for this function:

void hal_diag_init channel_data_t pchan_arg  ) 
 

Initialize dignostic device manually (no virtual vector support).

If we do not use virtual vector comm channels then we have to initialize the hardwired debug channel manually.

Parameters:
pchan_arg Points to channel configuration data

Definition at line 162 of file hal_diag.c.

References hal_sci_init_channel(), and pchannel.

Referenced by hal_plf_diag_init().

00163 {
00164     pchannel = pchan_arg;
00165     hal_sci_init_channel((void *)pchannel);
00166 }

Here is the call graph for this function:

int hal_diag_put_buf const char *  pbuf_in,
int  len_in
 

Outputs a buffer of len_in bytes via diagnostic device.

Parameters:
pbuf_in Points to buffer with date to be sent
len_in Number of bytes to be sent
Returns:
A simple checksum.

Definition at line 209 of file hal_diag.c.

References hal_diag_write_char().

Referenced by hal_diag_put_long_hex().

00210 {
00211    unsigned char sum;
00212 
00213 
00214    sum = 0;
00215    while (len_in--)
00216    {
00217       sum += *(unsigned char*)pbuf_in;
00218       hal_diag_write_char(*pbuf_in++);
00219    }
00220 
00221    return sum;
00222 }

Here is the call graph for this function:

void hal_diag_put_long unsigned long  l_in  ) 
 

Send long value through diagnostic serial channel.

Converts long number into a number string and sends it through serial channel.

Parameters:
l_in Long number to be send

Definition at line 250 of file hal_diag.c.

References hal_diag_write_char().

00251 {
00252    unsigned char charbuf[10];
00253    unsigned char i;
00254 
00255 
00256    //
00257    // A zero value is a special case - we send zero char and leave
00258    //
00259    if (l_in == 0)
00260    {
00261        hal_diag_write_char('0');
00262        return;
00263    }
00264 
00265    //
00266    // Here we calculate the entries for the char buffer. We start with
00267    // the least significant number and devide by 10 until l_in = zero.
00268    // An ASCII offset is added to get a char from a numeric value.
00269    //
00270    i = 9;
00271    while (l_in > 0)
00272    {
00273       charbuf[i] = (l_in % 10) + '0';
00274       i--;
00275       l_in = l_in / 10;
00276    }
00277 
00278    //
00279    // This part sends the content of the charbuffer out through serial
00280    // interface
00281    //
00282    i++;
00283    while (i < 10)
00284    {
00285       hal_diag_write_char(charbuf[i]);
00286       i++;
00287    }
00288 }

Here is the call graph for this function:

void hal_diag_put_long_hex long  l_in  ) 
 

Converts long into hex string and sends it through diagnostic device.

Parameters:
l_in Long number to be sent

Definition at line 356 of file hal_diag.c.

References hal_diag_put_buf(), and hal_long_to_hexbuf().

00357 {
00358     unsigned char hexbuf[10] = "0x";
00359     unsigned char len = 2;
00360 
00361 
00362     len += hal_long_to_hexbuf(l_in, &hexbuf[2]);
00363     hal_diag_put_buf(hexbuf, len);
00364 }

Here is the call graph for this function:

void hal_diag_put_string unsigned char *  pstr_in  ) 
 

Sends zero terminated string through diagnostic device.

Parameters:
pstr_in Pointer to zero terminated string

Definition at line 232 of file hal_diag.c.

References hal_diag_write_char().

00233 {
00234    while (*pstr_in != '\0')       // repeat until detection of terminating zero
00235    {
00236       hal_diag_write_char(*pstr_in++);
00237    }
00238 }

Here is the call graph for this function:

void hal_diag_read_char char *  c  ) 
 

Read character from diagnostic device.

If we do not use virtual vector comm channels then we have to use this function.

Parameters:
c Stores received character

Definition at line 193 of file hal_diag.c.

References hal_sci_getc(), and pchannel.

00194 {
00195     *c = (char) hal_sci_getc((void *)pchannel);
00196 }

Here is the call graph for this function:

void hal_diag_write_char char  c  ) 
 

Write char to diagnostic device.

If we do not use virtual vector comm channels then we have to use this function.

Parameters:
c Char to be written to diagostic device

Definition at line 178 of file hal_diag.c.

References hal_sci_putc(), and pchannel.

Referenced by hal_diag_put_buf(), hal_diag_put_long(), and hal_diag_put_string().

00179 {
00180     hal_sci_putc((void *)pchannel, c);
00181 }

Here is the call graph for this function:

char hal_lnibble_to_hex char  n_in  )  [static]
 

Converts low nibble of byte into hex char.

Parameters:
n_in Number to be converted
Returns:
Converted hex char

Definition at line 300 of file hal_diag.c.

Referenced by hal_long_to_hexbuf().

00301 {
00302     static const char lnibble_to_hex_tbl[] = "0123456789abcdef";
00303 
00304     return lnibble_to_hex_tbl[n_in & 0xf];
00305 }

unsigned char hal_long_to_hexbuf long  l_in,
char *  phexbuf_out
[static]
 

Converts long into hex string.

Parameters:
l_in Long number to be converted
phexbuf_out Stores hex string
Returns:
Number of char written into phexbuf_out

Definition at line 318 of file hal_diag.c.

References hal_lnibble_to_hex().

Referenced by hal_diag_put_long_hex().

00319 {
00320     typedef union
00321     {
00322         long  lbuf;
00323         short sbuf;
00324         char  cbuf[sizeof(long)];
00325     } lsc_buf_t;
00326     
00327     lsc_buf_t     lscbuf;
00328     unsigned char ret;
00329     unsigned char i;
00330 
00331 
00332     ret = 0;
00333     lscbuf.lbuf = l_in;
00334     //
00335     // Now we convert the value in lscbuf into hex chars and store
00336     // them into phexbuf_out
00337     //
00338     for (i = 0; i < sizeof(long); i++)
00339     {
00340         *phexbuf_out++ = hal_lnibble_to_hex(lscbuf.cbuf[i] >> 4);  // high nibble
00341         *phexbuf_out++ = hal_lnibble_to_hex(lscbuf.cbuf[i]);       // low nibble
00342         ret += 2;                                                  // inc. counter for chars in buf
00343     }
00344 
00345     return ret;
00346 }

Here is the call graph for this function:


Variable Documentation

channel_data_t* pchannel [static]
 

Definition at line 151 of file hal_diag.c.

Referenced by hal_diag_init(), hal_diag_read_char(), and hal_diag_write_char().


Generated on Tue Feb 17 09:06:16 2004 for eCos EDOSK-2674 HAL by doxygen 1.3.5