src/ad7147.c File Reference

This file contains AD7147 Touchcap Nuggets for Init, touch get, touch event get and Release functionalities. More...

#include "ad7147.h"
#include "bf52x_uart.h"
#include "bf52xI2cMaster.h"
#include "string.h"

Include dependency graph for ad7147.c:


Functions

void memCpy16to8 (unsigned char *destination, unsigned int *source, int numSrcMembers)
 memCpy16to8 This function is private.
int tcapAD7147_Init (tcapAD7147_t *state, unsigned char slaveAddress, enum tcapAD7147_powerMode powerMode)
 tcapAD7147_Init This functions initializes the device with default values provided.
int tcapAD7147_touchGet (tcapAD7147_t *state)
 tcapAD7147_touchGet This function reads (no wait) the values of the buttons and updates the state variable.
int tcapAD7147_touchEventGet (tcapAD7147_t *state)
 tcapAD7147_touchEventGet This function busy waits till there is a change in the state of the touch cap buttons and then reports back the values of the buttons and the buttons which has caused the change in state of the touch cap.
int tcapAD7147_release (tcapAD7147_t *state)
 tcapAD7147_Release This functions switches off the device.

Detailed Description

This file contains AD7147 Touchcap Nuggets for Init, touch get, touch event get and Release functionalities.

It also contains internal (non user exposed) functions. The functions are as follows:

User Exposed Functions:

tcapAD7147_Init tcapAD7147_touchGet tcapAD7147_touchEventGet tcapAD7147_Release

Internal Functions:

memCpy16to8 : Copy data from a int array to char array

Version:
1.2
Date:
20120404
Author:
Karthikeyan. G.A.
XqJv Copyright(c) 2010-2012 The Learning Labs,Inc. All Rights Reserved jVkB

Organization: The Learning Labs

Tested: Compiler bfin-elf-gcc; Output format Bare Metal Elf; Target TLL6527M V1.2

Revised: 20130409, Author: Oleg Vaskevich: Ported for Northeastern PAL common code

Revised: 20120405, Author: Karthikeyan. G.A.: Cleaned up, modified boiler plate

Revised: 20120404, Author: Karthikeyan. G.A., Notes: Added the support for the eventGet to report touch and release events.

Created: 20120317, Author: Karthikeyan. G.A., Notes: Created the Initial Version

References:

1. AD7147 CapTouch Programmable Controller for Single-Electrode Capacitance Sensors datasheet Rev. D


Function Documentation

void memCpy16to8 ( unsigned char *  destination,
unsigned int *  source,
int  numSrcMembers 
)

memCpy16to8 This function is private.

This takes a char array and copies a int array's content such that the MSB(8 bits) is stored in the destiantion's odd place and LSB(8 bits) are stored in the even indices. destination[2*i]=(source[i])>>8; destination[(2*i)+1]=(source[i])&0x00ff;

Parameters:
destination unsigned char* The destination array where the contents have to be transferred
source unsigned int* The source from where the contents have to be copied
numSrcMembers int The number of integers to copy
Returns:
void

int tcapAD7147_Init ( tcapAD7147_t state,
unsigned char  slaveAddress,
enum tcapAD7147_powerMode  powerMode 
)

tcapAD7147_Init This functions initializes the device with default values provided.

Other registers are written with default setting. The registers are set as a bulk if their addresses are continuous.

Pre-conditions: Nothing

Post-Conditions: The device will be powered up following the power up sequence. The device is initialised with values such that all PB1 to PB4 is mapped to Stage 0 to Stage 3 of the device and wheel 0 through wheel 7 is mapped to Stage 4 through Stage 11 and PB5 is mapped to Stage 0. PB1 and PB5 are mapped to Stage0 such that a PB5 is conncected to negative and PB1 is connected to positive of Stage 0. Thus except PB5 all others will trigger a High interrupt while PB5 will trigger a Low interrupt.

Parameters:
state tcapAD7147_t The state variable of the device
slaveAddress unsigned char The slave address of AD7147 device.
powerMode enum tcapAD7147_powerMode The power mode in which the AD7147 has to be put to. Normal or low power.
Returns:
0 on success -1 on failure
Parameters:
slaveAddress  stores the state of AD7147 device
powerMode  slave address of the AD7147 device The power mode to be set for the AD7147 chip

int tcapAD7147_release ( tcapAD7147_t state  ) 

tcapAD7147_Release This functions switches off the device.

Pre-conditions: The device should have been initialised using the init function

Post-Conditions: The device will be powered off and no longer will respond to the interrupt

Parameters:
state tcapAD7147_t The state variable of the device
Returns:
0 on success -1 on failure

int tcapAD7147_touchEventGet ( tcapAD7147_t state  ) 

tcapAD7147_touchEventGet This function busy waits till there is a change in the state of the touch cap buttons and then reports back the values of the buttons and the buttons which has caused the change in state of the touch cap.

Pre-conditions: The device should have been initialised using the init function

Post-Conditions: The button change status and values are updated in the state variable

Parameters:
state tcapAD7147_t The state variable of the device
Returns:
0 on success -1 on failure

int tcapAD7147_touchGet ( tcapAD7147_t state  ) 

tcapAD7147_touchGet This function reads (no wait) the values of the buttons and updates the state variable.

Pre-conditions: The device should have been initialised using the init function

Post-Conditions: The button values are updated in the state variable

Parameters:
state tcapAD7147_t The state variable of the device
Returns:
0 on success -1 on failure


Generated on 3 Mar 2014 for PAL bare-c Library by  doxygen 1.4.7