rs232dbg/rs232dbg.c
changeset 0 05c992bf5847
equal deleted inserted replaced
-1:000000000000 0:05c992bf5847
       
     1 /******************************************************************************
       
     2 *
       
     3 *           msr_io.c
       
     4 *
       
     5 *           Debugging über Serielle Schnittstelle
       
     6 *           
       
     7 *           Autoren: Wilhelm Hagemeister
       
     8 *
       
     9 *           $LastChangedDate: 2005-09-16 17:45:46 +0200 (Fri, 16 Sep 2005) $
       
    10 *           $Author: hm $
       
    11 *
       
    12 *           (C) Copyright IgH 2005
       
    13 *           Ingenieurgemeinschaft IgH
       
    14 *           Heinz-Bäcker Str. 34
       
    15 *           D-45356 Essen
       
    16 *           Tel.: +49 201/61 99 31
       
    17 *           Fax.: +49 201/61 98 36
       
    18 *           E-mail: sp@igh-essen.com
       
    19 *
       
    20 * /bin/setserial /dev/ttyS0 uart none
       
    21 * /bin/setserial /dev/ttyS1 uart none
       
    22 *
       
    23 *
       
    24 ******************************************************************************/
       
    25 
       
    26 /*--Includes-----------------------------------------------------------------*/
       
    27 
       
    28 #include <linux/module.h>
       
    29 #include <linux/tqueue.h>
       
    30 #include <linux/slab.h>
       
    31 #include <linux/delay.h>
       
    32 #include <linux/spinlock.h>
       
    33 
       
    34 #include "aip_com.h"
       
    35 #include "rs232dbg.h"
       
    36 #include <rtai.h>
       
    37 
       
    38 spinlock_t rs232wlock;
       
    39 
       
    40 
       
    41 void SDBG_print(const char *format, ...) 
       
    42 {
       
    43     va_list argptr;  
       
    44     static char buf[1024];                               
       
    45     int len;
       
    46     if(format != NULL) {
       
    47 	va_start(argptr,format); 
       
    48 	len = vsnprintf(buf, sizeof(buf), format, argptr);
       
    49         if (len > 0 && buf[len - 1] == '\n') len--; // fp
       
    50 	rt_com_write(0,buf,len);
       
    51 	rt_com_write(0,"\r\n",2);
       
    52 	va_end(argptr); 
       
    53     }
       
    54 }
       
    55 
       
    56 /*
       
    57 void SDBG_print(unsigned char *buf)
       
    58 {
       
    59     static int counter = 0;
       
    60     unsigned char cbuf[20];
       
    61     unsigned long flags;
       
    62 
       
    63 //    flags = rt_spin_lock_irqsave (&rs232wlock);
       
    64 
       
    65     sprintf(cbuf,"%0d -- ",counter);
       
    66     rt_com_write(0,cbuf,strlen(cbuf));
       
    67     rt_com_write(0,buf,strlen(buf));
       
    68     rt_com_write(0,"\r\n",2);
       
    69     counter++;
       
    70     counter %= 10; //did we miss frames ??
       
    71 //    rt_spin_unlock_irqrestore (&rs232wlock,flags);
       
    72 }
       
    73 */
       
    74 
       
    75 
       
    76 /*
       
    77 *******************************************************************************
       
    78 *
       
    79 * Function: msr_init
       
    80 *
       
    81 * Beschreibung: MSR initialisieren
       
    82 *
       
    83 * Parameter:
       
    84 *
       
    85 * Rückgabe: 
       
    86 *               
       
    87 * Status: exp
       
    88 *
       
    89 *******************************************************************************
       
    90 */
       
    91 
       
    92 int msr_init(void)
       
    93 {   
       
    94     spin_lock_init (&rs2323wlock);
       
    95 
       
    96     printk("starting RS232 Setup\n");
       
    97     if(init_aip_com())
       
    98     {
       
    99 	printk("RS232 Setup failed\n");
       
   100 	return -1;
       
   101     }
       
   102 
       
   103     SDBG_print("Hello Word, Serial Debugger started...");
       
   104     mdelay(10);
       
   105     return 0;
       
   106 }
       
   107 
       
   108 /*
       
   109 *******************************************************************************
       
   110 *
       
   111 * Function: msr_io_cleanup
       
   112 *
       
   113 * Beschreibung: Aufräumen
       
   114 *
       
   115 * Parameter:
       
   116 *
       
   117 * Rückgabe: 
       
   118 *               
       
   119 * Status: exp
       
   120 *
       
   121 *******************************************************************************
       
   122 */
       
   123 
       
   124 void msr_io_cleanup(void)
       
   125 {
       
   126   cleanup_aip_com();
       
   127 }
       
   128 
       
   129 /*---Treiber-Einsprungspunkte etc.-------------------------------------------*/
       
   130 
       
   131 MODULE_LICENSE("GPL");
       
   132 
       
   133 module_init(msr_init);
       
   134 module_exit(msr_io_cleanup);
       
   135 
       
   136 /*---Ende--------------------------------------------------------------------*/