omap3530/omap3530_drivers/spi/master.h
author Lukasz Forynski <lukasz.forynski@gmail.com>
Tue, 21 Sep 2010 02:30:11 +0100
branchBeagle_BSP_dev
changeset 77 e5fd00cbb70a
child 84 09e266454dcf
permissions -rw-r--r--
Added IIC SPI implementation / tests (Master channel only)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     2
// All rights reserved.
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     7
//
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     8
// Initial Contributors:
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    10
//
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    11
// Contributors:
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    12
// lukasz.forynski@gmail.com
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    13
//
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    14
// Description:
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    15
// omap3530/omap3530_drivers/spi/master.h
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    16
//
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    17
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    18
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    19
#ifndef __OMAP3530_SPI_MASTER_H__
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    20
#define __OMAP3530_SPI_MASTER_H__
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    21
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    22
#include <drivers/iic_channel.h>
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    23
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    24
_LIT(KIicPslThreadName,"SpiChannelThread_");
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    25
const TInt KIicPslDfcPriority = 0;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    26
const TInt KIicPslThreadPriority = 24;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    27
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    28
// class declaration for SPI master
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    29
class DSpiMasterBeagle : public DIicBusChannelMaster
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    30
	{
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    31
public:
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    32
	static DSpiMasterBeagle* New(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    33
	virtual TInt DoRequest(TIicBusTransaction* aTransaction); // Gateway function for PSL implementation
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    34
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    35
private:
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    36
	DSpiMasterBeagle(TInt aChannelNumber, const TBusType aBusType, const TChannelDuplex aChanDuplex);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    37
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    38
	// Override base-class pure virtual methods
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    39
	virtual TInt DoCreate();
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    40
	virtual TInt CheckHdr(TDes8* aHdr);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    41
	virtual TInt HandleSlaveTimeout();
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    42
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    43
	// Internal methods
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    44
	TInt ConfigureInterface();
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    45
	TBool TransConfigDiffersFromPrev();
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    46
	TInt ProcessNextTransfers();
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    47
	TInt StartTransfer(TIicBusTransfer* aTransferPtr, TUint8 aType);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    48
	TInt DoTransfer(TUint8 aType);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    49
	static void Isr(TAny* aPtr);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    50
	static void TransferEndDfc(TAny* aPtr);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    51
	void ExitComplete(TInt aErr, TBool aComplete = ETrue);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    52
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    53
#ifdef _DEBUG
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    54
	void DumpCurrentStatus(const TInt8* aWhere = NULL);
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    55
#endif
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    56
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    57
private:
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    58
	TDfc iTransferEndDfc;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    59
	TIicOperationType iOperation;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    60
	TUint8 iWordSize;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    61
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    62
	TInt8 iTxFifoThreshold;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    63
	enum TMyState
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    64
		{
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    65
		EIdle,
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    66
		EBusy
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    67
		};
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    68
	TMyState iState;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    69
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    70
	TInt iIrqId;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    71
	TLinAddr iHwBase;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    72
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    73
	// Pointers used to store current transfers information
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    74
	TIicBusTransfer* iHalfDTransfer;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    75
	TIicBusTransfer* iFullDTransfer;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    76
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    77
	// Pointer to the current transaction.
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    78
	TIicBusTransaction* iCurrTransaction;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    79
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    80
	// Pointers to buffers used for Rx and Tx transfers
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    81
	TInt8 *iTxData;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    82
	TInt8 *iRxData;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    83
	TInt8 *iTxDataEnd;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    84
	TInt8 *iRxDataEnd;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    85
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    86
	// global status of the transaction
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    87
	volatile TInt iTransactionStatus;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    88
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    89
	TConfigSpiV01 iCurrHeader;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    90
	TInt iCurrSS;
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    91
	};
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    92
e5fd00cbb70a Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff changeset
    93
#endif //__OMAP3530_SPI_MASTER_H__