mcp41.c

Go to the documentation of this file.
00001 
00039 #include "hw/hw_mcp41.h"
00040 
00041 #include <cfg/macros.h>
00042 #include <cfg/compiler.h>
00043 
00044 #include <drv/timer.h>
00045 #include <drv/mcp41.h>
00046 #include <drv/ser.h>
00047 
00048 #warning FIXME:This implementation is obsolete. Refactor with KFile interface.
00049 
00050 #if 0
00051 static Serial *spi_ser;
00052 
00056 void mcp41_setResistance(Mcp41Dev dev, mcp41_res_t res)
00057 {
00058     MCP41_ON(dev);
00059     /* send command byte */
00060     ser_putchar(MCP41_WRITE_DATA, spi_ser);
00061     ser_putchar(((MCP41_HW_MAX * (uint32_t)res)  + (MCP41_MAX / 2)) / MCP41_MAX, spi_ser);
00062     ser_drain(spi_ser);
00063 
00064     MCP41_OFF(dev);
00065 }
00066 
00067 
00071 void mcp41_init(Serial *spi_port)
00072 {
00073     Mcp41Dev dev;
00074 
00075     /* Init all potentiometer ports */
00076     for (dev = 0; dev < MCP41_CNT; dev++)
00077     {
00078         SET_MCP41_DDR(dev);
00079         MCP41_OFF(dev);
00080     }
00081 
00082     spi_ser = spi_port;
00083 }
00084 
00085 #endif