bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4.cpp
author Christophe Porcel <christophe.porcel@broadcom.com>
Wed, 28 Jul 2010 17:24:32 +0100
branchbroadcom_h4
changeset 37 f53839ff73b7
permissions -rw-r--r--
Broadcom H4 contribution
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     2
// All rights reserved.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     7
//
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     8
// Initial Contributors:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    10
//
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    11
// Contributors:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    12
//
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    13
// Description:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    14
//
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    15
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    16
/**
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    17
 @file
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    18
 @internalComponent
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    19
*/
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    20
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    21
#include "Broadcom_Hctl_H4.h"
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    22
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    23
#include "Broadcom_Hctl_H4_sender.h"
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    24
#include "Broadcom_Hctl_H4_receiver.h"
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    25
#include "controllermanager.h"
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    26
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    27
#include "Broadcom_Hctl_H4_utils.h"
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    28
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    29
#include <bluetooth/hci/hctleventobserver.h>
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    30
#include <bluetooth/hci/hctldataobserver.h>
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    31
#include <bluetooth/hci/hctlchannelobserver.h>
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    32
#include <bluetooth/logger.h>
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    33
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    34
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    35
#ifdef __FLOG_ACTIVE
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    36
_LIT8(KLogComponent, LOG_COMPONENT_HCTL_BCM_H4);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    37
#endif
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    38
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    39
CHCTLBcmH4::CHCTLBcmH4()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    40
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    41
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    42
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    43
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    44
CHCTLBcmH4::~CHCTLBcmH4()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    45
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    46
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    47
	HCI_LOG_UNLOAD(this);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    48
	delete iReceiver;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    49
	delete iSender; 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    50
	delete iControllerMan;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    51
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    52
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    53
CHCTLBcmH4* CHCTLBcmH4::NewL()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    54
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    55
	LOG_STATIC_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    56
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    57
	CHCTLBcmH4* self = new(ELeave) CHCTLBcmH4();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    58
	CleanupStack::PushL(self);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    59
	self->ConstructL();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    60
	CleanupStack::Pop();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    61
	return self;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    62
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    63
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    64
void CHCTLBcmH4::ConstructL()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    65
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    66
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    67
	HCI_LOG_LOADL(this, KHCILoggerDatalinkTypeH4);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    68
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    69
	// Initialises iSender and iReceiver via the PortOpenedL method.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    70
	BaseConstructL(KIniFileName());
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    71
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    72
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    73
	iControllerMan = CControllerManager::NewL(*this);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    74
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    75
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    76
TAny* CHCTLBcmH4::Interface(TUid aUid)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    77
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    78
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    79
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    80
	TAny* ret = NULL;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    81
	switch(aUid.iUid)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    82
		{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    83
		case KHCTLInterfaceUid:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    84
			ret = reinterpret_cast<TAny*>(static_cast<MHCTLInterface*>(this));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    85
			break;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    86
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    87
		case KHCTLPowerInterfaceUid:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    88
			ret = reinterpret_cast<TAny*>(static_cast<MHCTLPowerInterface*>(iControllerMan));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    89
			break;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    90
         
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    91
		case KHCHardResetUid:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    92
			ret = reinterpret_cast<TAny*>(static_cast<MHardResetInitiator*>(this));   
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    93
			break;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    94
			
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    95
		case KHctlBcmConfigInterfaceUid:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    96
			ret = reinterpret_cast<TAny*>(static_cast<MHctlBcmConfigInterface*>(this));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    97
			break;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    98
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
    99
		default:
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   100
			break;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   101
		}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   102
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   103
	return ret;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   104
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   105
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   106
void CHCTLBcmH4::DoConfigL()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   107
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   108
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   109
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   110
	Port().ResetBuffers();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   111
	TCommConfig conf;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   112
	Port().Config(conf);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   113
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   114
	// Get reference to TCommConfig config
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   115
	TCommConfigV01& config = conf(); 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   116
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   117
	// Set Config to 8bit char, 1 stop bit and no parity
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   118
	config.iDataBits = EData8;			
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   119
	config.iStopBits = EStop1;			
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   120
	config.iParity = EParityNone;			
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   121
	config.iParityError = KConfigParityErrorIgnore;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   122
	config.iHandshake = KConfigObeyCTS;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   123
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   124
	LEAVEIFERRORL(Port().SetConfig(conf));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   125
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   126
	// allows HC to talk back to us!
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   127
	Port().SetSignals(KSignalRTS, KSignalDTEInputs); 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   128
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   129
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   130
//Implementation of pure virtuals from MHCTLInterface
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   131
TInt CHCTLBcmH4::MhiWriteAclData(const TDesC8& aData)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   132
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   133
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   134
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   135
	TInt rerr = KErrNotReady;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   136
	// Send if the power is on.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   137
	if(iCurrentPowerState == EBTOn)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   138
		{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   139
		// Add the packet indicator to the first byte of the buffer.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   140
		SetPacketIndicator(EACLDataPacket, aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   141
		rerr = iSender->Write(aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   142
		HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerACLDataFrame, aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   143
		}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   144
		
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   145
	return rerr;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   146
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   147
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   148
TInt CHCTLBcmH4::MhiWriteSynchronousData(const TDesC8& aData)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   149
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   150
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   151
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   152
	TInt rerr = KErrNotReady;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   153
	// Send if the power is on.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   154
	if(iCurrentPowerState == EBTOn)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   155
		{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   156
		// Add the packet indicator to the first byte of the buffer.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   157
		SetPacketIndicator(ESynchronousDataPacket, aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   158
		rerr = iSender->Write(aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   159
		HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerSynchronousDataFrame, aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   160
		}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   161
		
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   162
	return rerr;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   163
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   164
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   165
TInt CHCTLBcmH4::MhiWriteCommand(const TDesC8& aData)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   166
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   167
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   168
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   169
	TInt rerr = KErrNotReady;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   170
	// Send if the power is on.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   171
	if(iCurrentPowerState == EBTOn)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   172
		{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   173
		// Add the packet indicator to the first byte of the buffer.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   174
		SetPacketIndicator(ECommandPacket, aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   175
		rerr = iSender->Write(aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   176
		HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerCommandOrEvent, aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   177
		}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   178
		
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   179
	return rerr;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   180
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   181
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   182
void CHCTLBcmH4::MhiSetQdpPluginInterfaceFinder(MQdpPluginInterfaceFinder& aQdpPluginInterfaceFinder)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   183
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   184
	iQdpPluginInterfaceFinder = &aQdpPluginInterfaceFinder;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   185
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   186
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   187
void CHCTLBcmH4::MhriStartHardReset()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   188
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   189
	__ASSERT_DEBUG(iControllerMan, PANIC(KBcmHctlH4Panic, ENoControllerManager));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   190
	iControllerMan->HardReset();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   191
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   192
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   193
void CHCTLBcmH4::MhiGetAclDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   194
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   195
	// Return the transport overhead for ACL data.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   196
	aHeaderSize = KHCTLAclDataHeaderSize;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   197
	aTrailerSize = KHCTLAclDataTrailerSize;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   198
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   199
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   200
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   201
void CHCTLBcmH4::MhiGetSynchronousDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   202
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   203
	// Return the transport overhead for Synchronous data.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   204
	aHeaderSize = KHCTLSynchronousDataHeaderSize;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   205
	aTrailerSize = KHCTLSynchronousDataTrailerSize;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   206
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   207
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   208
void CHCTLBcmH4::MhiGetCommandTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   209
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   210
	// Return the transport overhead for HCI commands data.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   211
	aHeaderSize = KHCTLCommandHeaderSize;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   212
	aTrailerSize = KHCTLCommandTrailerSize;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   213
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   214
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   215
TInt CHCTLBcmH4::MhciUpdateBaudRate(TUint32 aBaudRate)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   216
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   217
	// Call the base class method to process this change.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   218
	TRAPD(rerr, SetPortBaudRateL(aBaudRate));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   219
	return rerr;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   220
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   221
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   222
void CHCTLBcmH4::MhciSetInitPluginState(TInitState InitState)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   223
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   224
	iInitpluginState = InitState;	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   225
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   226
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   227
/**
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   228
This function is used by the receiver for informing HCI that ACL data has been received
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   229
The receiver doesn't have reference to iDataObserver. So this is merely a wrapper for iDataObserver
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   230
*/
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   231
void CHCTLBcmH4::ProcessACLData(const TDesC8& aData)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   232
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   233
	iDataObserver->MhdoProcessAclData(aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   234
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   235
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   236
/**
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   237
This function is used by the receiver for informing HCI that Synchronous data has been received
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   238
The receiver doesn't have reference to iDataObserver. So this is merely a wrapper for iDataObserver
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   239
*/
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   240
void CHCTLBcmH4::ProcessSynchronousData(const TDesC8& aData)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   241
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   242
	iDataObserver->MhdoProcessSynchronousData(aData);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   243
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   244
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   245
/**
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   246
This function is used by the receiver for informing HCI that event has been received
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   247
The receiver doesn't have reference to iEventObserver. So this is merely a wrapper for iDataObserver
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   248
*/	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   249
void CHCTLBcmH4::ProcessEvent(const TDesC8& aEvent)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   250
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   251
	iEventObserver->MheoProcessEvent(aEvent);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   252
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   253
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   254
/**
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   255
QdpPluginInterfaceFinder getter.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   256
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   257
@return returns iQdpPluginInterfaceFinder which could be NULL 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   258
if it has not been given one.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   259
*/
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   260
MQdpPluginInterfaceFinder* CHCTLBcmH4::QdpPluginInterfaceFinder()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   261
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   262
	return iQdpPluginInterfaceFinder;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   263
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   264
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   265
/**
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   266
Sets the packet type indicator at the begining of the HCI packet.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   267
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   268
Hence the HC can recognise whether this packet is a command, ACL/SCO data.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   269
The packet preamble/indication is different between different HCTL 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   270
implementations and are totally dependent upon the meduim used (UART, R2232 etc).
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   271
*/
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   272
/*static*/ void CHCTLBcmH4::SetPacketIndicator(THctlPacketType aType, const TDesC8& aData)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   273
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   274
	LOG_STATIC_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   275
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   276
	TUint8* ptr = const_cast<TUint8*>(aData.Ptr());
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   277
	*ptr = static_cast<TUint8>(aType);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   278
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   279
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   280
// Implementation of pure virtual from CHCTLUartBase
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   281
void CHCTLBcmH4::PortOpenedL()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   282
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   283
	LOG_FUNC
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   284
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   285
	__ASSERT_DEBUG(Port().Handle(), PANIC(KBcmHctlH4Panic, EPortNotOpen));
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   286
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   287
	if (iSender || iReceiver)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   288
		{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   289
		LEAVEIFERRORL(KErrAlreadyExists);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   290
		}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   291
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   292
	DoConfigL();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   293
	iCurrentPowerState = EBTOn;	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   294
	// The sender Active Object must be added to the Active Scheduler before 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   295
	// the receiver Active Object so that it gets preferential treatment. It 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   296
	// is reported that otherwise the response from a command can come in 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   297
	// before the sending client is told that the send has completed!
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   298
	iSender	= CHCTLBcmH4Sender::NewL(Port());
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   299
	iReceiver = CHCTLBcmH4Receiver::NewL(*this, Port());
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   300
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   301
	// Start reading from the UART  
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   302
	iReceiver->Start();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   303
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   304
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   305
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   306
void CHCTLBcmH4::MhiSetDataObserver(MHCTLDataObserver& aDataObserver)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   307
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   308
	iDataObserver = &aDataObserver;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   309
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   310
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   311
void CHCTLBcmH4::MhiSetEventObserver(MHCTLEventObserver& aEventObserver)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   312
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   313
	iEventObserver = &aEventObserver;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   314
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   315
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   316
void CHCTLBcmH4::MhiSetChannelObserver(MHCTLChannelObserver& aChannelObserver)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   317
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   318
	iChannelObserver = &aChannelObserver;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   319
	iSender->SetChannelObserver(aChannelObserver); 
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   320
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   321
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   322
void CHCTLBcmH4::MhiSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   323
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   324
	iControllerStateObserver = &aControllerStateObserver;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   325
	iControllerMan->SetControllerStateObserver(aControllerStateObserver);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   326
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   327
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   328
void CHCTLBcmH4::HandlePowerOff()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   329
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   330
	iCurrentPowerState = EBTOff;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   331
	// Close all channels and cancel the sender and receiver.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   332
	iSender->Cancel();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   333
	iReceiver->Cancel();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   334
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   335
	iChannelObserver->MhcoChannelClosed(KHCITransportAllChannels);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   336
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   337
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   338
void CHCTLBcmH4::HandlePowerOn()
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   339
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   340
	iCurrentPowerState = EBTOn;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   341
	iChannelObserver->MhcoChannelOpen(KHCITransportAllChannels);
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   342
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   343
	// Clear any spurious data from the buffer.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   344
	Port().ResetBuffers();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   345
	
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   346
	iReceiver->Start();
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   347
	// The sender will be activated when the first frame needs to be sent.
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   348
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   349
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   350
TBTPowerState CHCTLBcmH4::CurrentPowerState() const
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   351
	{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   352
	return iCurrentPowerState;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   353
	}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   354
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   355
//CHRIS MODIF
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   356
//void CHCTLBcmH4::SetInitFlag(TBool flag)
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   357
	//{
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   358
	//iInitFlag = flag;
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   359
	//}
f53839ff73b7 Broadcom H4 contribution
Christophe Porcel <christophe.porcel@broadcom.com>
parents:
diff changeset
   360