MMC card with spi-sd-card.c [adding syslog()]

Gene Smith gds at chartertn.net
Tue Dec 23 22:30:49 UTC 2008


To allow syslog() as alternate to print[fk] I did this in 
cpukit/include/rtems/status-checks.h:

#ifndef SYSLOG_PRINT
   #ifdef RTEMS_STATUS_CHECKS_USE_PRINTK
     #define SYSLOG_PRINT( fmt, ...) \
       printk( fmt, ##__VA_ARGS__)
   #else
     #ifdef RTEMS_STATUS_CHECKS_USE_SYSLOG /*<-define before 
status-checks.h includes*/
       #define SYSLOG_PRINT( fmt, ...) \
         syslog(LOG_USER|LOG_INFO, fmt, ##__VA_ARGS__)
     #else /* default to printf */
       #define SYSLOG_PRINT( fmt, ...) \
         printf( fmt, ##__VA_ARGS__)
     #endif
   #endif /* RTEMS_STATUS_CHECKS_USE_PRINTK */
#endif /* SYSLOG_PRINT */

Before initializing spi with call to bsp_register_spi() in Init() I do:

#include <syslog.h>
#include <rtems/libi2c.h>
#include <rtems/libio.h>
#include <rtems/diskdevs.h>
#include <libchip/spi-sd-card.h>
:
openlog("[MMC]", LOG_CONS, LOG_USER);
bsp_register_spi();

Finally, to get udp/ip for syslog() to send in spi/i2c code, I had to 
temporarily disable locking in cpukit/libi2c/libic2.c:

#if 0
#define LOCK(m)		assert(!rtems_semaphore_obtain((m), RTEMS_WAIT, 
RTEMS_NO_TIMEOUT))
#define UNLOCK(m)	rtems_semaphore_release((m))
#else
#define LOCK(m)	
#define UNLOCK(m)
#endif

Not sure why this is needed??

-gene









More information about the users mailing list