tc520.c File Reference

TC520 ADC driver (implementation). More...

#include <drv/tc520.h>
#include <drv/timer.h>
#include <hw_tc520.h>
#include <cfg/macros.h>
#include <cfg/compiler.h>
#include <drv/ser.h>

Go to the source code of this file.


Functions

tc520_data_t tc520_read (void)
 Start an AD conversion and return result.
void tc520_init (Serial *spi_port)
 Initialize tc520 A/D converter driver.

Detailed Description

TC520 ADC driver (implementation).

Version:
Id
tc520.c 992 2007-11-07 22:25:54Z marco

Version:
Id
tc520.c 992 2007-11-07 22:25:54Z marco
Author:
Francesco Sacchi <batt@develer.com>

Marco Benelli <marco@develer.com>

Definition in file tc520.c.


Function Documentation

tc520_data_t tc520_read ( void   ) 

Start an AD conversion and return result.

To start a conversion first we must pull down CE pin. The ADC starts a convertion and keeps the DV pin high until the end. At this point, we can read the conversion value by SPI. The convertion result is yield in 3 bytes.

 *
 * First byte:
 * bit | Value
 * ----|-------
 *  7  | Overrange
 *  6  | Polarity
 * 5:0 | data bits 15:10
 *
 * Second byte: data 9:2
 *
 * Third byte:
 * bit | Value
 * ----|-------
 *  7  | data bit 1
 *  6  | data bit 0
 * 5:0 | '0'
 *
 * 

So, to get the result we must shift and recompose the bits.

Note:
Overrange bit is handled as the 17th data bit.

Definition at line 87 of file tc520.c.