Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <drivers/iic.h>
20 #include <drivers/iic_channel.h>
25 #include "iic_master.h"
28 #include "iic_slave.h"
32 // EXTENSION DLL ENTRY POINT
33 DECLARE_EXTENSION_WITH_PRIORITY(BUS_IMPLMENTATION_PRIORITY)
35 // Array of pointers to the Channels that the PSL creates, for registration with the Bus Controller
36 // Use a local array, since the IIC Controller operates on a copy of the array entries.
37 DIicBusChannel* channelPtrArray[KIicPslNumOfChannels];
43 // If only MASTER_MODE is declared - Create only DIicBusChannelMasterPsl channels
44 __KTRACE_OPT(KIIC, Kern::Printf("\n\nCreating DIicBusChannelMasterPsl only\n"));
46 DIicBusChannel* chan = NULL;
47 for (TInt i = 0; i < KIicPslNumOfChannels; ++i)
49 // The first argument repesents the PSL-assigned channel number
50 // The second argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
51 chan = DIicBusChannelMasterPsl::New(i, DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex);
56 channelPtrArray[i] = chan;
60 // Master and Slave functionality is available, so create Master, Slave and MasterSlave Channels
61 // Create channel 0 as Master, channel 1 as a Slave, and channel 2 as MasterSlave.
62 __KTRACE_OPT(KIIC, Kern::Printf("\n\nCreating Master, Slave and MasterSlave channels\n"));
64 DIicBusChannel* chan = NULL;
67 // The first argument repesents the PSL-assigned channel number
68 // The second argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
69 chan = DIicBusChannelMasterPsl::New(0, DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex);
74 channelPtrArray[0] = chan;
77 // The first argument repesents the PSL-assigned channel number
78 // The second argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
79 chan = DIicBusChannelSlavePsl::New(1, DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex);
84 channelPtrArray[1] = chan;
86 // MasterSlave channel
87 // MasterSlave channels are not for derivation; instead, they have a pointer to a (derived) Master channel
88 // and a pointer to a (derived) Slave channel
89 DIicBusChannel* chanM = NULL;
90 DIicBusChannel* chanS = NULL;
91 // For MasterSlave channel, the channel number for both the Master and Slave channels must be the same
94 // The first argument repesents the PSL-assigned channel number
95 // The second argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
96 chanM = DIicBusChannelMasterPsl::New(msChanNum, DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex);
102 // The first argument repesents the PSL-assigned channel number
103 // The second argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
104 chanS = DIicBusChannelSlavePsl::New(msChanNum, DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex);
109 // MasterSlave channel
110 // The first argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
111 chan = new DIicBusChannelMasterSlave(DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex, (DIicBusChannelMaster*)chanM, (DIicBusChannelSlave*)chanS);
116 r = ((DIicBusChannelMasterSlave*)chan)->DoCreate();
117 channelPtrArray[2] = chan;
120 #endif /*SLAVE_MODE*/
121 #else /*MASTER_MODE*/
124 // If only SLAVE_MODE is declared - Create all as DIicBusChannelSlavePsl channels
125 __KTRACE_OPT(KIIC, Kern::Printf("\n\nCreating DIicBusChannelSlavePsl only\n"));
127 DIicBusChannel* chan = NULL;
128 for (TInt i = 0; i < KIicPslNumOfChannels; ++i)
130 // The first argument repesents the PSL-assigned channel number
131 // The second argument, DIicBusChannel::ESpi, should be replaced with the relevant bus type for the PSL
132 chan = DIicBusChannelSlavePsl::New(i, DIicBusChannel::ESpi, DIicBusChannel::EFullDuplex);
137 channelPtrArray[i] = chan;
141 #endif /*MASTER_MODE*/
143 // Register them with the Bus Controller
144 r = DIicBusController::RegisterChannels(channelPtrArray, KIicPslNumOfChannels);