From ab6f1a365c1f5a698d8060fbb73dce5a8304e96c Mon Sep 17 00:00:00 2001 From: batt Date: Fri, 17 Apr 2009 10:40:29 +0000 Subject: [PATCH] Refactor to use kfile interface; add to wizard. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2537 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/drv/mcp41.c | 18 +++++++----------- bertos/drv/mcp41.h | 10 +++++++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bertos/drv/mcp41.c b/bertos/drv/mcp41.c index ede899f7..02cff086 100644 --- a/bertos/drv/mcp41.c +++ b/bertos/drv/mcp41.c @@ -43,12 +43,9 @@ #include #include -#include +#include -#warning FIXME:This implementation is obsolete. Refactor with KFile interface. - -#if 0 -static Serial *spi_ser; +static KFile *ch; /** * Set resitance for digital pot \a dev @@ -57,8 +54,9 @@ void mcp41_setResistance(Mcp41Dev dev, mcp41_res_t res) { MCP41_ON(dev); /* send command byte */ - ser_putchar(MCP41_WRITE_DATA, spi_ser); - ser_putchar(((MCP41_HW_MAX * (uint32_t)res) + (MCP41_MAX / 2)) / MCP41_MAX, spi_ser); + kfile_putc(MCP41_WRITE_DATA, ch); + kfile_putc(((MCP41_HW_MAX * (uint32_t)res) + (MCP41_MAX / 2)) / MCP41_MAX, ch); + kfile_flush(ch); ser_drain(spi_ser); MCP41_OFF(dev); @@ -68,7 +66,7 @@ void mcp41_setResistance(Mcp41Dev dev, mcp41_res_t res) /** * Initialize mcp41 potentiometer driver */ -void mcp41_init(Serial *spi_port) +void mcp41_init(KFile *_ch) { Mcp41Dev dev; @@ -79,7 +77,5 @@ void mcp41_init(Serial *spi_port) MCP41_OFF(dev); } - spi_ser = spi_port; + ch = _ch; } - -#endif diff --git a/bertos/drv/mcp41.h b/bertos/drv/mcp41.h index 827b903b..032a0b81 100644 --- a/bertos/drv/mcp41.h +++ b/bertos/drv/mcp41.h @@ -31,10 +31,14 @@ * * \version $Id$ * - * \brief MCP41xxx digital potentiomenter driver (interface) + * \brief MCP41xxx digital potentiomenter driver. * * \version $Id$ * \author Francesco Sacchi + * + * $WIZ$ module_name = "mcp41" + * $WIZ$ module_depends = "timer", "kfile" + * $WIZ$ module_hw = "bertos/hw/hw_mcp41.h" */ #ifndef DRV_MCP41_H @@ -43,7 +47,7 @@ #include "hw/mcp41_map.h" #include -#include +#include #define MCP41_WRITE_DATA 0x11 #define MCP41_HW_MAX 255 @@ -55,6 +59,6 @@ typedef uint16_t mcp41_res_t; void mcp41_setResistance(Mcp41Dev dev, mcp41_res_t res); -void mcp41_init(Serial *spi_port); +void mcp41_init(KFile *ch); #endif /* DRV_MCP41_H */ -- 2.25.1