author | Lukasz Forynski <lukasz.forynski@gmail.com> |
Tue, 28 Sep 2010 02:37:35 +0100 | |
branch | Beagle_BSP_dev |
changeset 84 | 09e266454dcf |
parent 82 | 65b40f262685 |
child 85 | d93b485c1325 |
permissions | -rw-r--r-- |
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 |
// Implementation of IIC master channel for a SPI bus. |
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 |
#define DBGPRINT(x) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
19 |
#define DBG_ERR(x) x |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
20 |
|
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 |
#ifdef _DEBUG |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
23 |
#define DEBUG_ONLY(x) //x |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
24 |
#else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
25 |
#define DEBUG_ONLY(x) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
26 |
#endif |
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 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
29 |
// DO NOT CHANGE THESE- trying to tune the driver (unless you really know what you're doing) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
30 |
// as this this is only for development purpose to tune the driver. Fifo mode is not yet enabled, but this |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
31 |
// doesn't affect operation. After development has been finished - these macros and #ifdefs will be removed |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
32 |
// entirely. For now only SINGLE_MODE should ever be defined. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
33 |
//#define USE_TX_FIFO |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
34 |
//#define USING_TX_COUNTER |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
35 |
//#define PER_TRANSFER_MODE |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
36 |
#define SINGLE_MODE |
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 |
#include <assp/omap3530_assp/omap3530_assp_priv.h> |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
39 |
#include <assp/omap3530_assp/omap3530_prcm.h> |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
40 |
#include <drivers/iic.h> |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
41 |
#include "omap3530_spi.h" |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
42 |
#include "psl_init.h" |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
43 |
#include "master.h" |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
44 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
45 |
DSpiMasterBeagle::DSpiMasterBeagle(TInt aChannelNumber, TBusType aBusType, TChannelDuplex aChanDuplex) : |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
46 |
DIicBusChannelMaster(aBusType, aChanDuplex), |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
47 |
iTransferEndDfc(TransferEndDfc, this, KIicPslDfcPriority) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
48 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
49 |
iChannelNumber = aChannelNumber; |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
50 |
iIrqId = KMcSpiIrqId[iChannelNumber]; |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
51 |
iHwBase = KMcSpiRegBase[iChannelNumber]; |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
52 |
iState = EIdle; |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
53 |
iCurrSS = -1; // make sure channel will be fully configured on the first use |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
54 |
DBGPRINT(Kern::Printf("DSpiMasterBeagle::DSpiMasterBeagle: at 0x%x, iChannelNumber = %d", this, iChannelNumber)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
55 |
} |
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 |
TInt DSpiMasterBeagle::DoCreate() |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
58 |
{ |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
59 |
DBGPRINT(Kern::Printf("\nDSpiMasterBeagle::DoCreate() McSPI%d \n", iChannelNumber+1)); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
60 |
DBGPRINT(Kern::Printf("HW revision is %x", AsspRegister::Read32(iHwBase + MCSPI_REVISION))); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
61 |
TInt r = KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
62 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
63 |
// Create the DFCQ to be used by the channel |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
64 |
if(!iDfcQ) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
65 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
66 |
TBuf8<KMaxName> threadName (KIicPslThreadName); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
67 |
threadName.AppendNum(iChannelNumber); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
68 |
r = Kern::DfcQCreate(iDfcQ, KIicPslThreadPriority, &threadName); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
69 |
if(r != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
70 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
71 |
DBG_ERR(Kern::Printf("DFC Queue creation failed, channel number: %d, r = %d\n", iChannelNumber, r)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
72 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
73 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
74 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
75 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
76 |
// PIL Base class initialization - this must be called prior to SetDfcQ(iDfcQ) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
77 |
r = Init(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
78 |
if(r == KErrNone) |
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 |
// Call base class function to set DFCQ pointers in the required objects |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
81 |
// This also enables the channel to process transaction requests |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
82 |
SetDfcQ(iDfcQ); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
83 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
84 |
// PSL DFCQ initialisation for local DFC |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
85 |
iTransferEndDfc.SetDfcQ(iDfcQ); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
86 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
87 |
// Bind interrupts. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
88 |
r = Interrupt::Bind(iIrqId, Isr, this); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
89 |
if(r < KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
90 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
91 |
DBG_ERR(Kern::Printf("ERROR: InterruptBind error.. %d", r)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
92 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
93 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
94 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
95 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
96 |
// Make sure clocks are enabled (TBD: this could go to 'PowerUp/PowerDown' if using PRM) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
97 |
Prcm::SetClockState( Prcm::EClkMcSpi3_F, Prcm::EClkOn ); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
98 |
Prcm::SetClockState( Prcm::EClkMcSpi3_I, Prcm::EClkOn ); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
99 |
// TODO:consider auto-idle for PRCM.CM_AUTOIDLE1_CORE |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
100 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
101 |
// setup default spi pins. For channel 2 (McSPI3) it can be configured dynamically |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
102 |
SetupSpiPins(iChannelNumber); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
103 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
104 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
105 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
106 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
107 |
// A static method used to construct the DSpiMasterBeagle object. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
108 |
DSpiMasterBeagle* 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
|
109 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
110 |
DBGPRINT(Kern::Printf("DSpiMasterBeagle::NewL(): ChannelNumber = %d, BusType =%d", aChannelNumber, aBusType)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
111 |
DSpiMasterBeagle *pChan = new DSpiMasterBeagle(aChannelNumber, aBusType, aChanDuplex); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
112 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
113 |
TInt r = KErrNoMemory; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
114 |
if(pChan) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
115 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
116 |
r = pChan->DoCreate(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
117 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
118 |
if(r != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
119 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
120 |
delete pChan; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
121 |
pChan = NULL; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
122 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
123 |
return pChan; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
124 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
125 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
126 |
// This method is called by the PIL to initiate the transaction. After finishing it's processing, |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
127 |
// the PSL calls the PIL function CompleteRequest to indicate the success (or otherwise) of the request |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
128 |
TInt DSpiMasterBeagle::DoRequest(TIicBusTransaction* aTransaction) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
129 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
130 |
DBGPRINT(Kern::Printf("\n=>DSpiMasterBeagle::DoRequest (aTransaction=0x%x)\n", aTransaction)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
131 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
132 |
// If the pointer to the transaction passed in as a parameter, or its associated pointer to the |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
133 |
// header information is NULL, return KErrArgument |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
134 |
if(!aTransaction || !GetTransactionHeader(aTransaction)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
135 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
136 |
return KErrArgument; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
137 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
138 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
139 |
// The PSL operates a simple state machine to ensure that only one transaction is processed |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
140 |
// at a time - if the channel is currently busy, reject the request (PIL should not try that!) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
141 |
if(iState != EIdle) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
142 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
143 |
return KErrInUse; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
144 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
145 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
146 |
// copy pointer to the transaction |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
147 |
iCurrTransaction = aTransaction; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
148 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
149 |
// Configure the hardware to support the transaction |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
150 |
TInt r = PrepareConfiguration(); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
151 |
if(r == KErrNone) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
152 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
153 |
r = ConfigureInterface(); |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
154 |
if(r == KErrNone) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
155 |
{ |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
156 |
// start processing transfers of this transaction. |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
157 |
r = ProcessNextTransfers(); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
158 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
159 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
160 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
161 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
162 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
163 |
TInt DSpiMasterBeagle::PrepareConfiguration() |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
164 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
165 |
TConfigSpiV01 &newHeader = (*(TConfigSpiBufV01*) (GetTransactionHeader(iCurrTransaction)))(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
166 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
167 |
// get the slave address (i.e. known as a 'channel' for the current SPI module) |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
168 |
TInt busId = iCurrTransaction->GetBusId(); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
169 |
TInt slaveAddr = GET_SLAVE_ADDR(busId); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
170 |
TInt slavePinSet = 0; |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
171 |
|
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
172 |
if(slaveAddr >= KMcSpiNumSupportedSlaves[iChannelNumber]) // address is 0-based |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
173 |
{ |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
174 |
DBG_ERR(Kern::Printf("Slave address for McSPI%d should be < %, was: %d !", |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
175 |
iChannelNumber + 1, KMcSpiNumSupportedSlaves[iChannelNumber], slaveAddr)); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
176 |
return KErrArgument; // Slave address out of range |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
177 |
} |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
178 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
179 |
// Slave addresses > 1 for McSPI3 (iChannel2) really means alternative pin settings, |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
180 |
// so adjust it in such case. *Pin set indexes are +1 to skip over the pin set for McSPI4 |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
181 |
// channel in the pin configuration table. |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
182 |
if(iChannelNumber == 2 && slaveAddr > 1) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
183 |
{ |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
184 |
slavePinSet = slaveAddr > 3 ? 3 : 2; // slaveAddr: 2-3: pin set 2(1*); 4-5: pin set 3(2*) |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
185 |
slaveAddr &= 1; // modulo 2 (i.e. 2 CS for McSPI3) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
186 |
} |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
187 |
|
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
188 |
// store configuration parameters |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
189 |
iCurrSS = slaveAddr; |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
190 |
iCurrSlavePinSet = slavePinSet; |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
191 |
iCurrHeader = newHeader; //copy the header.. |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
192 |
|
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
193 |
return KErrNone; |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
194 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
195 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
196 |
// Init the hardware with the data provided in the transaction and slave-address field |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
197 |
// (these values are already stored in the iCurrHeader) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
198 |
TInt DSpiMasterBeagle::ConfigureInterface() |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
199 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
200 |
DBGPRINT(Kern::Printf("ConfigureInterface()")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
201 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
202 |
// make sure pins are set up properly (only for McSPI3) |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
203 |
if(iCurrSlavePinSet == 2) |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
204 |
{ |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
205 |
SetupSpiPins(iChannelNumber, iCurrSlavePinSet); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
206 |
} |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
207 |
|
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
208 |
// soft reset the SPI.. |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
209 |
TUint val = AsspRegister::Read32(iHwBase + MCSPI_SYSCONFIG); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
210 |
val = MCSPI_SYSCONFIG_SOFTRESET; // issue reset |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
211 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
212 |
AsspRegister::Write32(iHwBase + MCSPI_SYSCONFIG, MCSPI_SYSCONFIG_SOFTRESET); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
213 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
214 |
val = 0; // TODO will add here this 'smart-wait' stuff that was proposed earlier.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
215 |
while (!(val & MCSPI_SYSSTATUS_RESETDONE)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
216 |
val = AsspRegister::Read32(iHwBase + MCSPI_SYSSTATUS); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
217 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
218 |
// disable and clear all interrupts.. |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
219 |
AsspRegister::Write32(iHwBase + MCSPI_IRQENABLE, 0); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
220 |
AsspRegister::Write32(iHwBase + MCSPI_IRQSTATUS, |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
221 |
MCSPI_IRQ_RX_FULL(iCurrSS) | |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
222 |
MCSPI_IRQ_RX_FULL(iCurrSS) | |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
223 |
MCSPI_IRQ_TX_UNDERFLOW(iCurrSS) | |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
224 |
MCSPI_IRQ_TX_EMPTY(iCurrSS) | |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
225 |
MCSPI_IRQ_RX_OVERFLOW); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
226 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
227 |
// channel configuration |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
228 |
// Set the SPI1.MCSPI_CHxCONF[18] IS bit to 0 for the spi1_somi pin in receive mode. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
229 |
// val = MCSPI_CHxCONF_IS; // pin selection (somi - simo) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
230 |
// TODO configuration of PINS could also be configurable on a 'per SPI module' basis.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
231 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
232 |
// Set the SPI1.MCSPI_CHxCONF[17] DPE1 bit to 0 and the SPI1.MCSPI_CHxCONF[16] DPE0 bit to 1 for the spi1.simo pin in transmit mode. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
233 |
val = MCSPI_CHxCONF_DPE0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
234 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
235 |
// Set transmit & | receive mode for transmit only mode here. If needed - it will be changed dynamically. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
236 |
val |= MCSPI_CHxCONF_TRM_NO_RECEIVE; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
237 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
238 |
// set word length. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
239 |
val |= SpiWordWidth(iCurrHeader.iWordWidth); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
240 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
241 |
// use the appropriate word with (assuming the data is aligned to bytes). |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
242 |
if(iCurrHeader.iWordWidth > ESpiWordWidth_16) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
243 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
244 |
iWordSize = 4; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
245 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
246 |
else if (iCurrHeader.iWordWidth > ESpiWordWidth_8) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
247 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
248 |
iWordSize = 2; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
249 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
250 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
251 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
252 |
iWordSize = 1; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
253 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
254 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
255 |
// set Slave Select / Chip select signal mode |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
256 |
val |= iCurrHeader.iSSPinActiveMode == ESpiCSPinActiveLow ? MCSPI_CHxCONF_EPOL_LOW : 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
257 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
258 |
// set the CLK POL and PHA (clock mode) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
259 |
val |= SpiClkMode(iCurrHeader.iClkMode); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
260 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
261 |
// Set clock. Note that CheckHdr() will be called prior to this function for this header, |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
262 |
// so the value iClkSpeedHz is valid at this point, the KErrNotSupported is not possible |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
263 |
// so the return value check can be ommited here |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
264 |
val |= SpiClkValue(iCurrHeader.iClkSpeedHz); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
265 |
// __ASSERT_DEBUG(val >= KErrNone, Kern::Fault("spi/master.cpp, line: ", __LINE__)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
266 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
267 |
#ifdef USE_TX_FIFO |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
268 |
// enable fifo for transmission.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
269 |
// Update me: this can only set in a 'single' mode.. or for only one channel |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
270 |
// but at the momment IIC SPI is used in 'single' mode onlny.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
271 |
val |= MCSPI_CHxCONF_FFEW; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
272 |
// val |= MCSPI_CHxCONF_FFER; // fifo enable for receive.. (TODO) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
273 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
274 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
275 |
// update the register.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
276 |
AsspRegister::Write32(iHwBase + MCSPI_CHxCONF(iCurrSS), val); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
277 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
278 |
// set spim_somi pin direction to input |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
279 |
val = MCSPI_SYST_SPIDATDIR0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
280 |
|
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
281 |
// drive csx pin to inactive state |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
282 |
if(iCurrHeader.iSSPinActiveMode == ESpiCSPinActiveLow) |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
283 |
{ |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
284 |
AsspRegister::Modify32(iHwBase + MCSPI_SYST, 1u << iCurrSS, 0); |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
285 |
} |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
286 |
else |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
287 |
{ |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
288 |
AsspRegister::Modify32(iHwBase + MCSPI_SYST, 0, (1u << iCurrSS)); |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
289 |
} |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
290 |
|
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
291 |
// Set the MS bit to 0 to provide the clock (ie. to setup as master) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
292 |
#ifndef SINGLE_MODE |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
293 |
AsspRegister::Write32(iHwBase + MCSPI_MODULCTRL, MCSPI_MODULCTRL_MS_MASTER); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
294 |
#else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
295 |
AsspRegister::Write32(iHwBase + MCSPI_MODULCTRL, MCSPI_MODULCTRL_MS_MASTER | MCSPI_MODULCTRL_SINGLE); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
296 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
297 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
298 |
return KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
299 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
300 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
301 |
TInt DSpiMasterBeagle::ProcessNextTransfers() |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
302 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
303 |
DBGPRINT(Kern::Printf("DSpiMasterBeagle::ProcessNextTransfers():%s", iState==EIdle ? "first" : "next")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
304 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
305 |
// Since new transfers are strating, clear exisiting flags |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
306 |
iOperation.iValue = TIicOperationType::ENop; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
307 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
308 |
// If this is the first transfer in the transaction the channel will be in state EIdle |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
309 |
if(iState == EIdle) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
310 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
311 |
// Get the pointer to half-duplex transfer object.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
312 |
iHalfDTransfer = GetTransHalfDuplexTferPtr(iCurrTransaction); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
313 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
314 |
// Get the pointer to full-duplex transfer object.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
315 |
iFullDTransfer = GetTransFullDuplexTferPtr(iCurrTransaction); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
316 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
317 |
// Update the channel state to EBusy and initialise the transaction status |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
318 |
iState = EBusy; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
319 |
iTransactionStatus = KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
320 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
321 |
// start timeout timer for this transaction |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
322 |
StartSlaveTimeOutTimer(iCurrHeader.iTimeoutPeriod); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
323 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
324 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
325 |
// If not in state EIdle, get the next transfer in the linked-list held by the transaction |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
326 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
327 |
// Get the pointer the next half-duplex transfer object.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
328 |
iHalfDTransfer = GetTferNextTfer(iHalfDTransfer); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
329 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
330 |
// Get the pointer to the next half-duplex transfer object.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
331 |
if(iFullDTransfer) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
332 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
333 |
iFullDTransfer = GetTferNextTfer(iFullDTransfer); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
334 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
335 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
336 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
337 |
TInt r = KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
338 |
if(!iFullDTransfer && !iHalfDTransfer) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
339 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
340 |
// There is no more to transfer - and all previous were were completed, |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
341 |
DBGPRINT(Kern::Printf("All transfers completed successfully")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
342 |
ExitComplete(KErrNone); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
343 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
344 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
345 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
346 |
// Process next transfers |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
347 |
TInt8 hDTrType = (TInt8) GetTferType(iHalfDTransfer); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
348 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
349 |
if(iFullDTransfer) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
350 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
351 |
// For full-duplex transfer setup the read transfer first, as it doesn't |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
352 |
// really start anything - SPI master starts operation when Tx (or clocks)starts.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
353 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
354 |
if(hDTrType == TIicBusTransfer::EMasterRead) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
355 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
356 |
r = StartTransfer(iHalfDTransfer, TIicBusTransfer::EMasterRead); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
357 |
if(r != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
358 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
359 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
360 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
361 |
r = StartTransfer(iFullDTransfer, TIicBusTransfer::EMasterWrite); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
362 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
363 |
else // hDTrType == TIicBusTransfer::EMasterWrite) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
364 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
365 |
r = StartTransfer(iFullDTransfer, TIicBusTransfer::EMasterRead); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
366 |
if(r != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
367 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
368 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
369 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
370 |
r = StartTransfer(iHalfDTransfer, TIicBusTransfer::EMasterWrite); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
371 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
372 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
373 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
374 |
// This is a HalfDuplex transfer - so just start it |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
375 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
376 |
r = StartTransfer(iHalfDTransfer, hDTrType); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
377 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
378 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
379 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
380 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
381 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
382 |
TInt DSpiMasterBeagle::StartTransfer(TIicBusTransfer* aTransferPtr, TUint8 aType) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
383 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
384 |
DBGPRINT(Kern::Printf("DSpiMasterBeagle::StartTransfer() @0x%x, aType: %s", |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
385 |
aTransferPtr, aType == TIicBusTransfer::EMasterWrite ? "write" : "read")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
386 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
387 |
if(aTransferPtr == NULL) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
388 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
389 |
DBG_ERR(Kern::Printf("DSpiMasterBeagle::StartTransfer - NULL pointer\n")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
390 |
return KErrArgument; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
391 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
392 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
393 |
TInt r = KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
394 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
395 |
switch(aType) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
396 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
397 |
case TIicBusTransfer::EMasterWrite: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
398 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
399 |
DBGPRINT(Kern::Printf("Starting EMasterWrite, duplex=%x", iFullDTransfer)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
400 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
401 |
// Get a pointer to the transfer object's buffer, to facilitate passing arguments to DoTransfer |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
402 |
const TDes8* desBufPtr = GetTferBuffer(aTransferPtr); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
403 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
404 |
DBGPRINT(Kern::Printf("Length %d, iWordSize %d", desBufPtr->Length(), iWordSize)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
405 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
406 |
// Store the current address and ending address for Transmission - they are required by the ISR and DFC |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
407 |
iTxData = (TInt8*) desBufPtr->Ptr(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
408 |
iTxDataEnd = (TInt8*) (iTxData + desBufPtr->Length()); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
409 |
if ((TInt)iTxDataEnd % iWordSize) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
410 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
411 |
DBG_ERR(Kern::Printf("Wrong configuration - word size does not match buffer length")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
412 |
return KErrArgument; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
413 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
414 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
415 |
DBGPRINT(Kern::Printf("Tx: Start: %x, End %x, bytes %d", iTxData, iTxDataEnd, desBufPtr->Length())); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
416 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
417 |
// Set the flag to indicate that we'll be transmitting data |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
418 |
iOperation.iOp.iIsTransmitting = ETrue; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
419 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
420 |
// initiate the transmission.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
421 |
r = DoTransfer(aType); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
422 |
if(r != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
423 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
424 |
DBG_ERR(Kern::Printf("Starting Write failed, r = %d", r)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
425 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
426 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
427 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
428 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
429 |
case TIicBusTransfer::EMasterRead: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
430 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
431 |
DBGPRINT(Kern::Printf("Starting EMasterRead, duplex=%x", iFullDTransfer)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
432 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
433 |
// Get a pointer to the transfer object's buffer, to facilitate passing arguments to DoTransfer |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
434 |
const TDes8* aBufPtr = GetTferBuffer(aTransferPtr); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
435 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
436 |
// Store the current address and ending address for Reception - they are required by the ISR and DFC |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
437 |
iRxData = (TInt8*) aBufPtr->Ptr(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
438 |
iRxDataEnd = (TInt8*) (iRxData + aBufPtr->Length()); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
439 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
440 |
DBGPRINT(Kern::Printf("Rx: Start: %x, End %x, bytes %d", iRxData, iRxDataEnd, aBufPtr->Length())); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
441 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
442 |
// Set the flag to indicate that we'll be receiving data |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
443 |
iOperation.iOp.iIsReceiving = ETrue; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
444 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
445 |
// initiate the reception |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
446 |
r = DoTransfer(aType); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
447 |
if(r != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
448 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
449 |
DBG_ERR(Kern::Printf("Starting Read failed, r = %d", r)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
450 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
451 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
452 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
453 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
454 |
default: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
455 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
456 |
DBG_ERR(Kern::Printf("Unsupported TransactionType %x", aType)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
457 |
r = KErrArgument; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
458 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
459 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
460 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
461 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
462 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
463 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
464 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
465 |
// Method called by StartTransfer to actually initiate the transfers. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
466 |
TInt DSpiMasterBeagle::DoTransfer(TUint8 aType) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
467 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
468 |
DBGPRINT(Kern::Printf("\nDSpiMasterBeagle::DoTransfer()")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
469 |
TInt r = KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
470 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
471 |
AsspRegister::Write32(iHwBase + MCSPI_IRQSTATUS, ~0); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
472 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
473 |
switch(aType) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
474 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
475 |
case TIicBusTransfer::EMasterWrite: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
476 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
477 |
// enable the channel here.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
478 |
AsspRegister::Write32(iHwBase + MCSPI_CHxCTRL(iCurrSS), MCSPI_CHxCTRL_EN); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
479 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
480 |
AsspRegister::Modify32(iHwBase + MCSPI_IRQSTATUS, 0, |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
481 |
MCSPI_IRQ_TX_EMPTY(iCurrSS) /*| MCSPI_IRQ_TX_UNDERFLOW(iCurrSS)*/); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
482 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
483 |
AsspRegister::Modify32(iHwBase + MCSPI_IRQENABLE, 0, |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
484 |
MCSPI_IRQ_TX_EMPTY(iCurrSS) /*| MCSPI_IRQ_TX_UNDERFLOW(iCurrSS)*/); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
485 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
486 |
#ifdef SINGLE_MODE |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
487 |
// in SINGLE mode needs to manually assert CS line for current |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
488 |
AsspRegister::Modify32(iHwBase + MCSPI_CHxCONF(iCurrSS), 0, MCSPI_CHxCONF_FORCE); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
489 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
490 |
// change the pad config - now the SPI drives the line appropriately.. |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
491 |
SetCsActive(iChannelNumber, iCurrSS, iCurrSlavePinSet); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
492 |
#endif /*SINGLE_MODE*/ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
493 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
494 |
#ifdef USE_TX_FIFO |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
495 |
const TInt KTxFifoThreshold = 8; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
496 |
TUint numWordsToTransfer = (iTxDataEnd - iTxData); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
497 |
TUint wordsToWrite = Min(numWordsToTransfer/iWordSize, KTxFifoThreshold/iWordSize); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
498 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
499 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
500 |
TInt iAlmostFullLevel = 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
501 |
TInt iAlmostEmptyLevel = 1; //KTxFifoThreshold; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
502 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
503 |
// setup FIFOs |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
504 |
AsspRegister::Write32(iHwBase + MCSPI_XFERLEVEL, |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
505 |
MCSPI_XFERLEVEL_WCNT(0) | // total num words |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
506 |
MCSPI_XFERLEVEL_AFL(iAlmostFullLevel) | // Rx almost full |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
507 |
MCSPI_XFERLEVEL_AEL(iAlmostEmptyLevel) ); // Tx almost empty |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
508 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
509 |
// copy data to fifo.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
510 |
for (TInt i = 0; i < wordsToWrite; i++) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
511 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
512 |
iTxData += iWordSize; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
513 |
AsspRegister::Write32(iHwBase + MCSPI_TXx(iCurrSS), *(iTxData -iWordSize)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
514 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
515 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
516 |
#else /*USE_TX_FIFO*/ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
517 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
518 |
TUint val = 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
519 |
for (TInt i = 0; i < iWordSize; i++) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
520 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
521 |
val |= (*iTxData++) << i * 8; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
522 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
523 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
524 |
DEBUG_ONLY(DumpCurrentStatus("DoTransfer(Write)")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
525 |
AsspRegister::Write32(iHwBase + MCSPI_TXx(iCurrSS), val); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
526 |
#endif /*USE_TX_FIFO*/ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
527 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
528 |
// enable system interrupt |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
529 |
Interrupt::Enable(iIrqId); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
530 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
531 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
532 |
case TIicBusTransfer::EMasterRead: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
533 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
534 |
// enable transmit and receive.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
535 |
AsspRegister::Modify32(iHwBase + MCSPI_CHxCONF(iCurrSS), MCSPI_CHxCONF_TRM_NO_RECEIVE, 0); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
536 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
537 |
// for single read (not duplex) one way to to allow clock generation is to enable Tx |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
538 |
// and write '0' to Txregister (just like in duplex transaction). We also need to assert Cs line. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
539 |
if(!iFullDTransfer) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
540 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
541 |
// enable the channel.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
542 |
AsspRegister::Write32(iHwBase + MCSPI_CHxCTRL(iCurrSS), MCSPI_CHxCTRL_EN); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
543 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
544 |
// enable TX and RX Empty interrupts |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
545 |
AsspRegister::Modify32(iHwBase + MCSPI_IRQSTATUS, 0, MCSPI_IRQ_TX_EMPTY(iCurrSS) | MCSPI_IRQ_RX_FULL(iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
546 |
AsspRegister::Modify32(iHwBase + MCSPI_IRQENABLE, 0, MCSPI_IRQ_TX_EMPTY(iCurrSS) | MCSPI_IRQ_RX_FULL(iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
547 |
#ifdef SINGLE_MODE |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
548 |
// in SINGLE mode needs to manually assert CS line for current |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
549 |
AsspRegister::Modify32(iHwBase + MCSPI_CHxCONF(iCurrSS), 0, MCSPI_CHxCONF_FORCE); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
550 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
551 |
// change the pad config - now the SPI drives the line appropriately.. |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
552 |
SetCsActive(iChannelNumber, iCurrSS, iCurrSlavePinSet); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
553 |
#endif /*SINGLE_MODE*/ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
554 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
555 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
556 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
557 |
// enable only interrupts for RX here. Tx is handled in EMasterWrite case above. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
558 |
AsspRegister::Write32(iHwBase + MCSPI_IRQSTATUS, MCSPI_IRQ_RX_FULL(iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
559 |
AsspRegister::Write32(iHwBase + MCSPI_IRQENABLE, MCSPI_IRQ_RX_FULL(iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
560 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
561 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
562 |
DEBUG_ONLY(DumpCurrentStatus("DoTransfer(Read)")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
563 |
// and enable system interrupts |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
564 |
if(!iFullDTransfer) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
565 |
Interrupt::Enable(iIrqId); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
566 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
567 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
568 |
default: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
569 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
570 |
DBG_ERR(Kern::Printf("Unsupported TransactionType %x", aType)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
571 |
r = KErrArgument; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
572 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
573 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
574 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
575 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
576 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
577 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
578 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
579 |
#ifdef _DEBUG |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
580 |
static TInt IsrCnt = 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
581 |
void DSpiMasterBeagle::DumpCurrentStatus(const TInt8* aWhere /*=NULL*/) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
582 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
583 |
if(aWhere) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
584 |
Kern::Printf("------ Status (%s)--------", aWhere); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
585 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
586 |
Kern::Printf("------ Status --------"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
587 |
Kern::Printf("\niTransactionStatus: %d", iTransactionStatus); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
588 |
Kern::Printf("iTransferEndDfc %s queued", iTransferEndDfc.Queued() ? "" : "NOT"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
589 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
590 |
if(iOperation.iOp.iIsTransmitting) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
591 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
592 |
Kern::Printf("TX STATUS:"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
593 |
Kern::Printf(" iTxData %x", iTxData); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
594 |
Kern::Printf(" iTxDataEnd %x", iTxDataEnd); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
595 |
Kern::Printf(" left to write: %x (words)", (iTxDataEnd - iTxData)/iWordSize); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
596 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
597 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
598 |
if(iOperation.iOp.iIsReceiving) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
599 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
600 |
Kern::Printf("RX STATUS:"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
601 |
Kern::Printf(" iRxData %x", iRxData); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
602 |
Kern::Printf(" iRxDataEnd %x", iRxDataEnd); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
603 |
Kern::Printf(" left to read: %x (words)", (iRxDataEnd - iRxData)/iWordSize); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
604 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
605 |
Kern::Printf(" iCurrSS %d",iCurrSS); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
606 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
607 |
Kern::Printf("IsrCnt %d", IsrCnt); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
608 |
TUint status = AsspRegister::Read32(iHwBase + MCSPI_IRQSTATUS); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
609 |
Kern::Printf("MCSPI_IRQSTATUS (0x%x):", status); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
610 |
if(status & MCSPI_IRQ_TX_EMPTY(iCurrSS)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
611 |
Kern::Printf(" MCSPI_IRQ_TX_EMPTY"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
612 |
if(status & MCSPI_IRQ_TX_UNDERFLOW(iCurrSS)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
613 |
Kern::Printf(" MCSPI_IRQ_TX_UNDERFLOW"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
614 |
if(!iCurrSS && status & MCSPI_IRQ_RX_OVERFLOW) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
615 |
Kern::Printf(" MCSPI_IRQ_RX_OVERFLOW"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
616 |
if(status & MCSPI_IRQ_RX_FULL(iCurrSS)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
617 |
Kern::Printf(" MCSPI_IRQ_RX_FULL"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
618 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
619 |
Kern::Printf("MCSPI_CHxSTAT(%d):", iCurrSS); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
620 |
status = AsspRegister::Read32(iHwBase + MCSPI_CHxSTAT(iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
621 |
if(status & MCSPI_CHxSTAT_RXFFF) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
622 |
Kern::Printf(" MCSPI_CHxSTAT_RXFFF"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
623 |
if(status & MCSPI_CHxSTAT_RXFFE) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
624 |
Kern::Printf(" MCSPI_CHxSTAT_RXFFE"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
625 |
if(status & MCSPI_CHxSTAT_TXFFF) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
626 |
Kern::Printf(" MCSPI_CHxSTAT_TXFFF"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
627 |
if(status & MCSPI_CHxSTAT_TXFFE) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
628 |
Kern::Printf(" MCSPI_CHxSTAT_TXFFE"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
629 |
if(status & MCSPI_CHxSTAT_EOT) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
630 |
Kern::Printf(" MCSPI_CHxSTAT_EOT"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
631 |
if(status & MCSPI_CHxSTAT_TXS) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
632 |
Kern::Printf(" MCSPI_CHxSTAT_TXS"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
633 |
if(status & MCSPI_CHxSTAT_RXS) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
634 |
Kern::Printf(" MCSPI_CHxSTAT_RXS"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
635 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
636 |
Kern::Printf("MCSPI_XFERLEVEL:"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
637 |
status = AsspRegister::Read32(iHwBase + MCSPI_XFERLEVEL); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
638 |
Kern::Printf(" MCSPI_XFERLEVEL_WCNT %d", status >> MCSPI_XFERLEVEL_WCNT_OFFSET); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
639 |
Kern::Printf(" MCSPI_XFERLEVEL_AFL %d", (status >> MCSPI_XFERLEVEL_AFL_OFFSET) & 0x3F); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
640 |
Kern::Printf(" MCSPI_XFERLEVEL_AEL %d\n", (status >> MCSPI_XFERLEVEL_AEL_OFFSET) & 0x1F); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
641 |
Kern::Printf("---------------------------------------/*\n\n\n"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
642 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
643 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
644 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
645 |
void DSpiMasterBeagle::Isr(TAny* aPtr) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
646 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
647 |
DSpiMasterBeagle *a = (DSpiMasterBeagle*) aPtr; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
648 |
DEBUG_ONLY(IsrCnt++); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
649 |
DEBUG_ONLY(a->DumpCurrentStatus("Isr entry")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
650 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
651 |
TUint32 status = AsspRegister::Read32(a->iHwBase + MCSPI_IRQSTATUS); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
652 |
AsspRegister::Write32(a->iHwBase + MCSPI_IRQSTATUS, status); // clear status bits.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
653 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
654 |
// TX_EMPTY - when an item (or number of items if FIFO is used) was transmitted.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
655 |
if(status & MCSPI_IRQ_TX_EMPTY(a->iCurrSS)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
656 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
657 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
658 |
if(a->iOperation.iOp.iIsTransmitting) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
659 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
660 |
#ifdef USE_TX_FIFO |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
661 |
// when FIFO is used - should write (at least) the MCSPI_XFERLEVEL_AFL + 1 words to this register.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
662 |
while(a->iTxData != a->iTxDataEnd) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
663 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
664 |
AsspRegister::Write32(a->iHwBase + MCSPI_TXx(a->iCurrSS), *a->iTxData); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
665 |
a->iTxData += a->iWordSize; // Then increment the pointer to the data.s |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
666 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
667 |
if(AsspRegister::Read32(a->iHwBase + MCSPI_CHxSTAT(a->iCurrSS)) & MCSPI_CHxSTAT_TXFFF) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
668 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
669 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
670 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
671 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
672 |
#else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
673 |
// transfer next word.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
674 |
if(a->iTxData != a->iTxDataEnd) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
675 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
676 |
TUint val = 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
677 |
for (TInt i = 0; i < a->iWordSize; i++) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
678 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
679 |
val |= (*a->iTxData++) << i * 8; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
680 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
681 |
AsspRegister::Write32(a->iHwBase + MCSPI_TXx(a->iCurrSS), val); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
682 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
683 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
684 |
// check again - if this was the last one..and we're not waiting for rx - end transfer |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
685 |
if(a->iTxData == a->iTxDataEnd && !a->iOperation.iOp.iIsReceiving) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
686 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
687 |
Interrupt::Disable(a->iIrqId); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
688 |
a->iTransferEndDfc.Add(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
689 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
690 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
691 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
692 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
693 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
694 |
// writing a 'dummy' word (for read only transferss (writing 0 doesn't change line state) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
695 |
AsspRegister::Write32(a->iHwBase + MCSPI_TXx(a->iCurrSS), 0); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
696 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
697 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
698 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
699 |
if(status & MCSPI_IRQ_RX_FULL(a->iCurrSS)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
700 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
701 |
if(a->iOperation.iOp.iIsReceiving) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
702 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
703 |
if(a->iRxDataEnd != a->iRxData) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
704 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
705 |
TUint8 nextRxValue = AsspRegister::Read32(a->iHwBase + MCSPI_RXx(a->iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
706 |
*a->iRxData = nextRxValue; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
707 |
a->iRxData += a->iWordSize; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
708 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
709 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
710 |
// If the Rx buffer is now full, finish the transmission. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
711 |
if(a->iRxDataEnd == a->iRxData) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
712 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
713 |
Interrupt::Disable(a->iIrqId); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
714 |
a->iTransferEndDfc.Add(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
715 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
716 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
717 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
718 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
719 |
#if 0 // TODO - probably master, as it creates CLK for slave - will never have to bother with this.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
720 |
if(status & MCSPI_IRQ_TX_UNDERFLOW(a->iCurrSS)) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
721 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
722 |
DBG_ERR(Kern::Printf("Underflow")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
723 |
a->iTransactionStatus = KErrUnderflow; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
724 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
725 |
// disable the channel.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
726 |
AsspRegister::Modify32(a->iHwBase + MCSPI_CHxCTRL(0), MCSPI_CHxCTRL_EN, 0); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
727 |
Interrupt::Disable(a->iIrqId); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
728 |
DEBUG_ONLY(a->DumpCurrentStatus("TxUnderflow")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
729 |
DBG_ERR(Kern::Fault("TxUnderflow", 0)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
730 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
731 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
732 |
#if defined(USE_TX_FIFO) && defined(USING_TX_COUNTER) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
733 |
if(status & MCSPI_IRQSTATUS_EOW) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
734 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
735 |
Kern::Printf("EOW"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
736 |
// TODO: end of transfer.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
737 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
738 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
739 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
740 |
// end of ISR processing |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
741 |
DEBUG_ONLY(a->DumpCurrentStatus("Isr end")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
742 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
743 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
744 |
void DSpiMasterBeagle::TransferEndDfc(TAny* aPtr) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
745 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
746 |
DBGPRINT(Kern::Printf("DSpiMasterBeagle::TransferEndDfc")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
747 |
DSpiMasterBeagle *a = (DSpiMasterBeagle*) aPtr; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
748 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
749 |
TUint chanStatus = AsspRegister::Read32(a->iHwBase + MCSPI_CHxSTAT(a->iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
750 |
if(a->iOperation.iOp.iIsTransmitting) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
751 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
752 |
TUint expected = MCSPI_CHxSTAT_EOT | MCSPI_CHxSTAT_TXS; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
753 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
754 |
#ifdef USE_TX_FIFO |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
755 |
while(!AsspRegister::Read32(a->iHwBase + MCSPI_CHxSTAT(a->iCurrSS)) & MCSPI_CHxSTAT_TXFFE); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
756 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
757 |
while(chanStatus & expected != expected) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
758 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
759 |
chanStatus = AsspRegister::Read32(a->iHwBase + MCSPI_CHxSTAT(a->iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
760 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
761 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
762 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
763 |
if(a->iOperation.iOp.iIsReceiving) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
764 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
765 |
TUint expected = MCSPI_CHxSTAT_RXS; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
766 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
767 |
while(chanStatus & expected != expected) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
768 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
769 |
chanStatus = AsspRegister::Read32(a->iHwBase + MCSPI_CHxSTAT(a->iCurrSS)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
770 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
771 |
__ASSERT_DEBUG(a->iRxDataEnd == a->iRxData, |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
772 |
Kern::Fault("SPI master: exiting not having received all?", 12)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
773 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
774 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
775 |
#ifdef SINGLE_MODE |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
776 |
// manually de-assert CS line for this channel |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
777 |
AsspRegister::Modify32(a->iHwBase + MCSPI_CHxCONF(a->iCurrSS), MCSPI_CHxCONF_FORCE, 0); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
778 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
779 |
// put the CS signal to 'inactive' state (as on channel disable it would have a glitch) |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
780 |
SetCsInactive(a->iChannelNumber, a->iCurrSS, a->iCurrHeader.iSSPinActiveMode, a->iCurrSlavePinSet); |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
781 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
782 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
783 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
784 |
// disable the channel |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
785 |
AsspRegister::Modify32(a->iHwBase + MCSPI_CHxCTRL(0), MCSPI_CHxCTRL_EN, 0); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
786 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
787 |
// Start the next transfer for this transaction, if any remain |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
788 |
if(a->iState == EBusy) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
789 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
790 |
TInt err = a->ProcessNextTransfers(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
791 |
if(err != KErrNone) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
792 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
793 |
// If the next transfer could not be started, complete the transaction with |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
794 |
// the returned error code |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
795 |
a->ExitComplete(err); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
796 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
797 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
798 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
799 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
800 |
void DSpiMasterBeagle::ExitComplete(TInt aErr, TBool aComplete /*= ETrue*/) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
801 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
802 |
DBGPRINT(Kern::Printf("DSpiMasterBeagle::ExitComplete, aErr %d, aComplete %d", aErr, aComplete)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
803 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
804 |
// make sure CS is in inactive state (for the current / last transaction) on error |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
805 |
// TODO: add extendable transaction support (..i.e. with no de-assertion of CS pin between such transactions) |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
806 |
SetCsInactive(iChannelNumber, iCurrSS, iCurrHeader.iSSPinActiveMode, iCurrSlavePinSet); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
807 |
|
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
808 |
// disable this channel |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
809 |
AsspRegister::Modify32(iHwBase + MCSPI_CHxCTRL(iCurrSS), MCSPI_CHxCTRL_EN, 0); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
810 |
|
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
811 |
// in the case of error - make sure to reset the channel |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
812 |
if(aErr != KErrNone) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
813 |
{ |
84
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
814 |
AsspRegister::Write32(iHwBase + MCSPI_SYSCONFIG, MCSPI_SYSCONFIG_SOFTRESET); |
09e266454dcf
Update SPI master pin handling: added dynamic pin configuration for McSPI3 (needed if want to use multiple device on this interface. Now following number of Slave devices is available: McSPI1: 4, McSPI2: 2, McSPI3: 6 (2 per each pin configuration), McSPI4: 1. Only McSPI3 and McSPI4 are available now -there are issues with McSPI1 & 2 due to register access (something wrong with mapping? There is Fault Category: Exception Fault Reason: 10000000
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
82
diff
changeset
|
815 |
iCurrSS = -1; // make sure the interface will be re-configured at next transaction |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
816 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
817 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
818 |
// Disable interrupts for the channel |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
819 |
Interrupt::Disable(iIrqId); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
820 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
821 |
// Cancel any timers and DFCs.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
822 |
CancelTimeOut(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
823 |
iTransferEndDfc.Cancel(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
824 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
825 |
// Change the channel state back to EIdle |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
826 |
iState = EIdle; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
827 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
828 |
// Call the PIL method to complete the request |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
829 |
if(aComplete) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
830 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
831 |
CompleteRequest(aErr); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
832 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
833 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
834 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
835 |
#ifdef _DEBUG |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
836 |
void DumpHeader(TConfigSpiV01& aHeader) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
837 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
838 |
Kern::Printf("header:"); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
839 |
Kern::Printf("iWordWidth %d (%d bits)", aHeader.iWordWidth, (SpiWordWidth(aHeader.iWordWidth)) >> MCSPI_CHxCONF_WL_OFFSET + 1); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
840 |
Kern::Printf("iClkSpeedHz %d", aHeader.iClkSpeedHz); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
841 |
Kern::Printf("iClkMode %d", aHeader.iClkMode); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
842 |
Kern::Printf("iTimeoutPeriod %d", aHeader.iTimeoutPeriod); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
843 |
Kern::Printf("iBitOrder %d", aHeader.iBitOrder); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
844 |
Kern::Printf("iTransactionWaitCycles %d", aHeader.iTransactionWaitCycles); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
845 |
Kern::Printf("iSSPinActiveMode %d", aHeader.iSSPinActiveMode); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
846 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
847 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
848 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
849 |
// virtual method called by the PIL when a transaction is queued (with QueueTransaction). |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
850 |
// This is done in the context of the Client's thread. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
851 |
// The PSL is required to check that the transaction header is valid for this channel. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
852 |
TInt DSpiMasterBeagle::CheckHdr(TDes8* aHdrBuff) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
853 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
854 |
TInt r = KErrNone; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
855 |
if(!aHdrBuff) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
856 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
857 |
r = KErrArgument; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
858 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
859 |
else |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
860 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
861 |
TConfigSpiV01 &header = (*(TConfigSpiBufV01*) (aHdrBuff))(); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
862 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
863 |
// check if word width and clock are supported |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
864 |
if(SpiWordWidth(header.iWordWidth) < KMinSpiWordWidth || |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
865 |
SpiClkValue(header.iClkSpeedHz) < 0 || // == KErrNotSupported |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
866 |
header.iBitOrder == ELsbFirst) // this SPI only transmits MSB fist |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
867 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
868 |
#ifdef _DEBUG |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
869 |
if(header.iBitOrder == ELsbFirst) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
870 |
DBG_ERR(Kern::Printf("iClkSpeedHz value (%d) is not supported", header.iClkSpeedHz)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
871 |
if(SpiClkValue(header.iClkSpeedHz) < 0) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
872 |
DBG_ERR(Kern::Printf("iClkSpeedHz: %d is not supported", header.iClkSpeedHz)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
873 |
if((SpiWordWidth(header.iWordWidth)+ 1) >> MCSPI_CHxCONF_WL_OFFSET < KMinSpiWordWidth) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
874 |
DBG_ERR(Kern::Printf("iWordWidth: %d is not supported, min value is: %d", |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
875 |
SpiWordWidth(header.iWordWidth), KMinSpiWordWidth)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
876 |
DumpHeader(header); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
877 |
#endif |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
878 |
r = KErrNotSupported; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
879 |
DBG_ERR(Kern::Printf("DSpiMasterBeagle::CheckHdr()failed, r = %d", r)); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
880 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
881 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
882 |
return r; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
883 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
884 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
885 |
// This method is called by the PIL in the case of expiry of a timer for a transaction. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
886 |
// TODO: this name is confusing - it could be changed in the PIL to reflect it's real purpose(TBD) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
887 |
// It has NOTHING to do with a Slave (i.e. slave might be completely silent for SPI-and master won't notice it!) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
888 |
TInt DSpiMasterBeagle::HandleSlaveTimeout() |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
889 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
890 |
DBG_ERR(Kern::Printf("HandleSlaveTimeout")); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
891 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
892 |
// Stop the PSL's operation, and inform the PIL of the timeout |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
893 |
ExitComplete(KErrTimedOut, EFalse); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
894 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
895 |
return KErrTimedOut; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
896 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
897 |