The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2001-2012 Broadcom Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * this file contains constants and definitions for the bte project |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | #ifndef BTE_H |
| 25 | #define BTE_H |
| 26 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 27 | #include <pthread.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 28 | #include <semaphore.h> |
| 29 | #include <signal.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | #include "bt_target.h" |
| 31 | |
Myles Watson | a88d1e3 | 2016-11-09 09:41:48 -0800 | [diff] [blame] | 32 | /* By default on shutdown, the baud rate is reset to 115kbits. This should NOT |
| 33 | * be needed for platforms that kill the BTE driver and remove/reset BT chip. |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 34 | */ |
| 35 | #ifndef BTE_RESET_BAUD_ON_BT_DISABLE |
| 36 | #define BTE_RESET_BAUD_ON_BT_DISABLE TRUE |
| 37 | #endif |
| 38 | |
Myles Watson | a88d1e3 | 2016-11-09 09:41:48 -0800 | [diff] [blame] | 39 | /* Target Modes (based on jumper settings on hardware [see user manual]) |
| 40 | * BTE BBY |
| 41 | * J3 J4 SW3-3 SW3-2 SW3-1 |
| 42 | * -------------------------------------------- |
| 43 | * BTE_MODE_SERIAL_APP, OUT OUT OFF OFF OFF |
| 44 | * BTE_MODE_APPL, IN OUT OFF OFF ON |
| 45 | * BTE_MODE_RESERVED, OUT IN OFF ON OFF |
| 46 | * BTE_MODE_SAMPLE_APPS, IN IN OFF ON ON |
| 47 | * BTE_MODE_DONGLE, not yet supported ON OFF OFF |
| 48 | * BTE_MODE_APPL_PROTOCOL_TRACE, * this is a fake mode * |
| 49 | * BTE_MODE_INVALID |
| 50 | */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 51 | enum { |
| 52 | BTE_MODE_SERIAL_APP, /* Sample serial port application */ |
| 53 | BTE_MODE_APPL, /* Target used with Tester through RPC */ |
| 54 | BTE_MODE_RESERVED, /* Reserved */ |
| 55 | BTE_MODE_SAMPLE_APPS, /* Sample applications (ICP/HSP) */ |
| 56 | BTE_MODE_DONGLE, /* Dongle mode */ |
| 57 | BTE_MODE_APPL_PROTOCOL_TRACE, /* Allow protocol tracing without rpc */ |
| 58 | BTE_MODE_INVALID |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 61 | extern volatile uint8_t |
| 62 | bte_target_mode; /* indicates the mode that the board is running in */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 63 | |
| 64 | /* Startup options */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 65 | extern uint32_t bte_startup_options; /* Switch and jumper settings at startup */ |
| 66 | void bte_get_startup_options( |
| 67 | uint32_t* |
| 68 | p_options); /* Platform specific function for getting startup options */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 69 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 70 | #define BTE_OPTIONS_TARGET_MODE_MASK \ |
| 71 | 0x00000007 /* bits 2-0 indicate target mode (QuickConnect: jp3 & jp4, BBY: \ |
| 72 | SW3-1 & SW3-2)*/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 73 | |
| 74 | /**************************************************************************** |
| 75 | * Definitions to define which type of application gets built |
| 76 | ****************************************************************************/ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 77 | #define BUILD_HCITOOL FALSE |
| 78 | #define BUILD_L2PING FALSE |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 79 | |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 80 | #define LINUX_FM_DRIVER_INCLUDED FALSE |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 81 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 82 | /* hcisu userial operations. should probably go into bt_types to avoid |
| 83 | * collisions! */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 84 | #define BT_EVT_TO_HCISU_USERIAL_OP (0x0080 | BT_EVT_HCISU) |
| 85 | /* operation for above hcisu event */ |
Myles Watson | 9008888 | 2016-11-15 16:33:22 -0800 | [diff] [blame] | 86 | #define BT_HCISU_USERIAL_OPEN \ |
| 87 | (0) /* open serial port calling USERIAL_Open() \ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 88 | */ |
| 89 | #define BT_HCISU_USERIAL_CLOSE (1) /* close userial port */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 90 | /* options associated with close op */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 91 | #define BT_HCISU_USERIAL_CL_NO_DIS_BT \ |
| 92 | 0 /* do not touch bt_wake and power gpio */ |
| 93 | #define BT_HCISU_USERIAL_CL_DIS_BT \ |
| 94 | 1 /* put power and bt_wake into defined off state to preserve \ |
| 95 | power */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 96 | /* status codes for callback */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 97 | #define BTE_HCISU_USERIAL_FAIL 0 |
| 98 | #define BTE_HCISU_USERIAL_OK 1 |
| 99 | typedef void(tUSERIAL_MSG_CBACK)(int status); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 100 | typedef struct tHCISU_USERIAL_MSG_tag { |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 101 | BT_HDR hdr; |
| 102 | tUSERIAL_MSG_CBACK* p_cback; |
| 103 | uint8_t port; /* port number */ |
| 104 | uint8_t op; |
| 105 | uint8_t option; /* option for operation. depends on operation */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 106 | } tHCISU_USERIAL_MSG; |
| 107 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 108 | extern void bte_hcisu_userial_oper(tUSERIAL_MSG_CBACK* p_cback, uint8_t port, |
| 109 | uint8_t op, uint8_t option); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 110 | |
| 111 | /* Pointer to function for sending HCI commands and data to the HCI tranport */ |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 112 | extern int (*p_bte_hci_send)(uint16_t port, BT_HDR* p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 113 | |
Pavlin Radoslavov | b2a292b | 2016-10-14 19:34:48 -0700 | [diff] [blame] | 114 | // Initialize control block memory for each stack component. |
| 115 | extern void BTE_InitStack(void); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 116 | |
| 117 | /* Protocol trace mask */ |
Marie Janssen | d19e078 | 2016-07-15 12:48:27 -0700 | [diff] [blame] | 118 | extern uint32_t bte_proto_trace_mask; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 119 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 120 | typedef struct tBAUD_REG_tag { |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 121 | uint8_t DHBR; |
| 122 | uint8_t DLBR; |
| 123 | uint8_t ExplicitBaudRate0; |
| 124 | uint8_t ExplicitBaudRate1; |
| 125 | uint8_t ExplicitBaudRate2; |
| 126 | uint8_t ExplicitBaudRate3; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 127 | } tBAUD_REG; |
| 128 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 129 | extern const tBAUD_REG baud_rate_regs[]; |
| 130 | |
Myles Watson | c1e4239 | 2016-11-09 09:47:42 -0800 | [diff] [blame] | 131 | #endif /* BTE_H */ |