author | Mike Kinghan <mikek@symbian.org> |
Mon, 22 Nov 2010 14:32:00 +0000 | |
branch | GCC_SURGE |
changeset 121 | ad7caa8e9a62 |
parent 112 | fdfa12d9a47a |
permissions | -rw-r--r-- |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
1 |
// 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
|
2 |
// 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
|
3 |
// 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
|
4 |
// 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
|
5 |
// |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
6 |
// Initial Contributors: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
7 |
// lukasz.forynski@gmail.com |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
8 |
// |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
9 |
// Contributors: |
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 |
// Description: |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
12 |
// omap3530/omap3530_drivers/spi/omap3530_spi.inl |
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 |
// This file contains definitions to internal SPI implementation. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
15 |
// It is not intended to be exported - SPI registers must not be modified from outside of |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
16 |
// the driver! |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
17 |
// |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
18 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
19 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
20 |
// This sets the CS line to inactive mode (Specify aActiveMode as appropriate for configuration) |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
21 |
// The CS pin will be put back to the opposite mode - using GPIO.. THis is in order to always keep |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
22 |
// the CS line in an 'inactive' state (de-asserted) when the SPI is disabled. |
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
|
23 |
inline void SetCsInactive(TInt aModule, TInt aChannel, TSpiSsPinMode aActiveMode, TUint aPinSetId = 0) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
24 |
{ |
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
|
25 |
__ASSERT_DEBUG(aModule < KMaxSpiChannelsPerModule, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // aChannel > module channels |
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
|
26 |
__ASSERT_DEBUG( aModule != 2 ? !aPinSetId : ETrue, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // only channel 3 supports other pin configurations |
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
|
27 |
|
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
28 |
// set the pin to the opposite to the currently active CS mode.. |
85
d93b485c1325
updated SPI. Added template touch (byd_touch) -WORKING version,does not work-needs update as I missunderstood how the touchcontroller(chip) works. Submitting in order to share whatever there was-prior to going for holiday
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
84
diff
changeset
|
29 |
const TPinConfig& csConf = ModulePinConfig[aModule + aPinSetId].iCs[aChannel]; |
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
|
30 |
__ASSERT_DEBUG(csConf.iAddress, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // don't try to use non-existing CS! |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
31 |
|
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
32 |
// now switch the pin mode..(making sure it is at the proper level before that) |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
33 |
GPIO::SetOutputState(csConf.iPinNumber, aActiveMode == ESpiCSPinActiveLow ? GPIO::EHigh : GPIO::ELow); |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
34 |
SCM::SetPadConfig(csConf.iAddress, csConf.iMswLsw, SCM::EMode4); // always go to mode 4 (gpio) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
35 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
36 |
|
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
|
37 |
|
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
|
38 |
inline void SetCsActive(TInt aModule, TInt aChannel, TUint aPinSetId = 0) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
39 |
{ |
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
|
40 |
__ASSERT_DEBUG(aModule < KMaxSpiChannelsPerModule, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // aChannel > module channels |
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
|
41 |
__ASSERT_DEBUG( aModule != 2 ? !aPinSetId : ETrue, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // only channel 3 supports other pin configurations |
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
|
42 |
|
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
|
43 |
const TPinConfig &csConf = ModulePinConfig[aModule + aPinSetId].iCs[aChannel]; |
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
|
44 |
__ASSERT_DEBUG(csConf.iAddress, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // don't try to use non-existing CS! |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
45 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
46 |
// now switch the pin mode back to the SPI |
112
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
47 |
SCM::SetPadConfig(csConf.iAddress, csConf.iMswLsw, csConf.iFlags); |
77
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 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
50 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
51 |
// Setup pad function for SPI pins.. |
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 |
inline void SetupSpiPins(TUint aModule, TUint aPinSetId = 0) |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
53 |
{ |
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
|
54 |
__ASSERT_DEBUG(aModule < KMaxSpiChannelsPerModule, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // aChannel > module channels |
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
|
55 |
__ASSERT_DEBUG(aModule != 2 ? !aPinSetId : ETrue, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // only channel 3 supports other pin configurations |
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
|
56 |
|
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
|
57 |
const TSpiPinConfig& pinCnf = ModulePinConfig[aModule + aPinSetId]; |
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
|
58 |
|
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
59 |
SCM::SetPadConfig(pinCnf.iClk.iAddress, pinCnf.iClk.iMswLsw, pinCnf.iClk.iFlags); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
60 |
SCM::SetPadConfig(pinCnf.iSimo.iAddress, pinCnf.iSimo.iMswLsw, pinCnf.iSimo.iFlags); |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
61 |
SCM::SetPadConfig(pinCnf.iSomi.iAddress, pinCnf.iSomi.iMswLsw, pinCnf.iSomi.iFlags); |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
62 |
|
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
63 |
// Setup GPIO mode/direction for all CS pins only once - here. |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
64 |
for(TInt i = 0; i < KMaxSpiChannelsPerModule; i++) |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
65 |
{ |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
66 |
if(pinCnf.iCs[i].iPinNumber) |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
67 |
{ |
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
|
68 |
// pre-set the GPIO.. |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
69 |
GPIO::SetPinDirection(pinCnf.iCs[i].iPinNumber, GPIO::EOutput); |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
70 |
GPIO::SetPinMode(pinCnf.iCs[i].iPinNumber, GPIO::EEnabled); |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
71 |
} |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
72 |
else |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
73 |
{ |
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
|
74 |
break; // no more channels (cs signals) |
82
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
75 |
} |
65b40f262685
updated cs pin handling
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
77
diff
changeset
|
76 |
} |
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
77 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
78 |
|
112
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
79 |
// McSPI3 can have 3 different pin configuration, but only one can be active at the time. |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
80 |
// for that reason, before switching to different mode -at least SOMI has to be deactivated |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
81 |
// otherwise the newly activated pin does not work (why??). Changing these pins to the GPIO (mode 4) |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
82 |
inline void DeactivateSpiPins(TUint aModule, TUint aPinSetId = 0) |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
83 |
{ |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
84 |
__ASSERT_DEBUG(aModule < KMaxSpiChannelsPerModule, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // aChannel > module channels |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
85 |
__ASSERT_DEBUG(aModule != 2 ? !aPinSetId : ETrue, Kern::Fault("omap3530_spi.inl, line: ", __LINE__)); // only channel 3 supports other pin configurations |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
86 |
|
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
87 |
const TSpiPinConfig& pinCnf = ModulePinConfig[aModule + aPinSetId]; |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
88 |
|
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
89 |
SCM::SetPadConfig(pinCnf.iClk.iAddress, pinCnf.iClk.iMswLsw, SCM::EMode4 | SCM::EInputEnable); |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
90 |
SCM::SetPadConfig(pinCnf.iSimo.iAddress, pinCnf.iSimo.iMswLsw, SCM::EMode4 | SCM::EInputEnable); |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
91 |
SCM::SetPadConfig(pinCnf.iSomi.iAddress, pinCnf.iSomi.iMswLsw, SCM::EMode4 | SCM::EInputEnable); |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
92 |
} |
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
93 |
|
fdfa12d9a47a
SPI update: fixed pin and zero-lengh transfer bugs, added asynchronous trasaction example (test)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
85
diff
changeset
|
94 |
|
77
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
95 |
// helper function - returns appropriate value for the register for a given mode |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
96 |
inline TUint32 SpiClkMode(TSpiClkMode aClkMode) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
97 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
98 |
// (POL) (PHA) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
99 |
// 0 0 Mode 0: spim_clk is active high and sampling occurs on the rising edge. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
100 |
// 0 1 Mode 1: spim_clk is active high and sampling occurs on the falling edge. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
101 |
// 1 0 Mode 2: spim_clk is active low and sampling occurs on the falling edge. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
102 |
// 1 1 Mode 3: spim_clk is active low and sampling occurs on the rising edge. |
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 |
TUint val = 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
105 |
switch(aClkMode) |
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 |
//case ESpiPolarityLowRisingEdge: // Active high, odd edges |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
108 |
/*val |= MCSPI_CHxCONF_POL;*/ // 0 (not set) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
109 |
/*val |= MCSPI_CHxCONF_PHA;*/ // 0 (not set) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
110 |
//break; // commented out - it's only for reference - there's nothing to change |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
111 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
112 |
case ESpiPolarityLowFallingEdge: // Active high, even edges |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
113 |
/*val |= MCSPI_CHxCONF_POL;*/ // 0 (not set) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
114 |
val |= MCSPI_CHxCONF_PHA; // 1 |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
115 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
116 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
117 |
case ESpiPolarityHighFallingEdge: // Active low, odd edges |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
118 |
val |= MCSPI_CHxCONF_POL; // 1 |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
119 |
/*val |= MCSPI_CHxCONF_PHA;*/ // 0 (not set) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
120 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
121 |
|
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
122 |
case ESpiPolarityHighRisingEdge: // Active low, even edges |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
123 |
val |= MCSPI_CHxCONF_POL; // 1 |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
124 |
val |= MCSPI_CHxCONF_PHA; // 1 |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
125 |
break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
126 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
127 |
return val; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
128 |
} |
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 |
// helper function - returns appropriate value for the register for a given frequency (or error->if not found) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
131 |
inline TInt SpiClkValue(TInt aClkSpeedHz) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
132 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
133 |
for (TInt val = 0; val < 0xD; val++) // only loop through all possible values.. |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
134 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
135 |
if(MCSPI_K48MHz >> val == aClkSpeedHz) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
136 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
137 |
return (val << 2); // return value ready for the register |
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 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
140 |
return KErrNotFound; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
141 |
} |
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 |
inline TInt SpiWordWidth(TSpiWordWidth aWidth) |
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 |
TInt val = 0; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
146 |
switch(aWidth) |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
147 |
{ |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
148 |
case ESpiWordWidth_8: val |= MCSPI_CHxCONF_WL(8); break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
149 |
case ESpiWordWidth_10: val |= MCSPI_CHxCONF_WL(10); break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
150 |
case ESpiWordWidth_12: val |= MCSPI_CHxCONF_WL(12); break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
151 |
case ESpiWordWidth_16: val |= MCSPI_CHxCONF_WL(16); break; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
152 |
// case ESpiWordWidth_32: val |= MCSPI_CHxCONF_WL(32); break; // TODO uncomment when fix for Bug 3665 is released |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
153 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
154 |
return val; |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
155 |
} |
e5fd00cbb70a
Added IIC SPI implementation / tests (Master channel only)
Lukasz Forynski <lukasz.forynski@gmail.com>
parents:
diff
changeset
|
156 |