Refactory and generalize sipo module.
[bertos.git] / bertos / cpu / avr / drv / sipo.h
index ab57908b76aaf9b0c4a887955a477905f5ef740c..ab5100f45e9f10378256153ab4f458771a770293 100644 (file)
  *
  * \version $Id$
  *
- * \author Andrea Grandi <andrea@develer.com>
+ * \author Daniele Basile <asterix@develer.com>
  */
 
-#ifndef SIPO_H
-#define SIPO_H
+#ifndef DRV_SIPO_H
+#define DRV_SIPO_H
 
-#include "hw/hw_sipo.h"
+#include <kern/kfile.h>
 
-#include <avr/io.h>
+/**
+ * Sipo KFile context structure.
+ */
+typedef struct Sipo
+{
+       KFile fd;                       ///< File descriptor.
+} Sipo;
+
+/**
+ * ID for sipo.
+ */
+#define KFT_SIPO MAKE_ID('S', 'I', 'P', 'O')
+
+/**
+ * Convert + ASSERT from generic KFile to Sipo.
+ */
+INLINE Sipo * SIPO_CAST(KFile *fd)
+{
+       ASSERT(fd->_type == KFT_SIPO);
+       return (Sipo *)fd;
+}
 
-void sipo_init(void);
-void sipo_putchar(uint8_t c);
+void sipo_init(Sipo *fd);
 
-#endif // SIPO_H
+#endif // DRV_SIPO_H