blob: bead5b983175fad585d500eb896663b59eec8cc7 [file] [log] [blame]
/*
** $Id: spi.h 4461 2014-07-16 15:39:20Z nizajerk $
**
** This file is system specific and should be edited for your hardware platform
**
** This file is used by proslic_timer_intf.h and proslic_spiGci.h
*/
#ifndef SPI_TYPE_H
#define SPI_TYPE_H
#include <linux/ioctl.h>
//////#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <pthread.h>
#include <string.h>
#include "si_voice_datatypes.h"
#include "si_voice.h"
#include "proslic_timer.h"
/* See: http://tldp.org/LDP/lkmpg/2.6/html/x892.html for IOCTL exampels */
#define SI_LINUX_SPI_MAGIC 'S'
#define SI_IOCTL_ASSERT_RESET _IOR(SI_LINUX_SPI_MAGIC,0, int ) /* Argument 1 = in reset, 0 = out of reset */
#define SI_IOCTL_MAX 1
#define NUMBER_OF_DEVICES 1
#define CHAN_PER_DEVICE 1
#define NUMBER_OF_CHAN (NUMBER_OF_DEVICES * CHAN_PER_DEVICE)
#define NUMBER_OF_SPI_FD NUMBER_OF_CHAN
typedef struct si_hctrl
{
int spi_fd[NUMBER_OF_SPI_FD]; /* File descriptor to SPI device */
pthread_mutex_t mutex;
} si_hctrl_t;
int si_setup_spi(si_hctrl_t *hCtrl);
int si_teardown_spi(si_hctrl_t *hCtrl);
int si_assoc_apis(si_hctrl_t *hCtrl, SiVoiceControlInterfaceType *proslic_if);
/*
** SPI/GCI structure
*/
typedef struct{
int port;
si_hctrl_t hw_ctrl;
} ctrl_S;
/*
** Function: SPI_Init
**
** Description:
** Initializes the SPI interface
*/
int SPI_Init (si_hctrl_t *hSpi);
/*
** Function: ctrl_ResetWrapper
**
** Description:
** Sets the reset pin of the ProSLIC
*/
int ctrl_ResetWrapper (void *hCtrl, int status);
/*
** register read
**
** Description:
** Reads ProSLIC registers
*/
unsigned char ctrl_ReadRegisterWrapper (void *hCtrl, unsigned char channel, unsigned char regAddr);
/*
** Function: ctrl_WriteRegisterWrapper
**
** Description:
** Writes ProSLIC registers
*/
int ctrl_WriteRegisterWrapper (void *hSpiGci, unsigned char channel, unsigned char regAddr, unsigned char data);
/*
** Function: ctrl_WriteRAMWrapper
**
** Description:
** Writes ProSLIC RAM
*/
int ctrl_WriteRAMWrapper (void *hSpiGci, unsigned char channel, unsigned short ramAddr, unsigned int data);
/*
** Function: ctrl_ReadRAMWrapper
**
** Description:
** Reads ProSLIC RAM
*/
unsigned int ctrl_ReadRAMWrapper (void *hSpiGci, unsigned char channel, unsigned short ramAddr);
#endif
/*
** $Log: spi.h,v $
** Revision 1.2 2007/10/22 21:38:10 lajordan
** fixed some warnings
**
** Revision 1.1 2007/10/22 20:52:09 lajordan
** no message
**
** Revision 1.1 2007/06/01 02:27:11 lajordan
** no message
**
** Revision 1.2 2007/02/21 16:53:07 lajordan
** no message
**
** Revision 1.1 2007/02/16 23:55:15 lajordan
** no message
**
** Revision 1.2 2007/02/15 23:33:25 lajordan
** no message
**
** Revision 1.1.1.1 2006/07/13 20:26:08 lajordan
** no message
**
*/