Skip to content

Commit 1318ec3

Browse files
author
zichuancui
committed
[int][new][bt] support 56/58 ptc control co channel config
Project: Bluetooth redmine: #10032, REDMINE-id ext-redmine: bug|feat#id [Description in detail] Affected branch: [master] Change-Id: If89005160f54d268fcba8d0f8689e317c1975cb2
1 parent 8a04643 commit 1318ec3

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

service/bt/bt_cm/bt_connection_manager.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,12 @@ void bt_cm(uint8_t argc, char **argv)
18871887
}
18881888
}
18891889
}
1890-
1890+
#ifdef BSP_BQB_TEST
1891+
uint8_t bt_is_in_BQB_mode(void)
1892+
{
1893+
return 1;
1894+
}
1895+
#endif
18911896
#ifdef RT_USING_FINSH
18921897
MSH_CMD_EXPORT(bt_cm, BT connection manager command);
18931898
#endif // RT_USING_FINSH

service/internal/bluetooth_misc.c

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
#define RF_FORCE 0
2626

27-
static PTC_HandleTypeDef PtcHandle[6];
28-
const static uint8_t g_ptc_task[6] = {1, 2, 4, 5, 6, 7};
27+
static PTC_HandleTypeDef PtcHandle[7];
28+
const static uint8_t g_ptc_task[7] = {1, 2, 4, 5, 6, 7, 0};
2929

3030
#ifdef PTC_DYN_CTRL
3131
#ifdef SOC_SF32LB58X
@@ -37,7 +37,7 @@ const static uint8_t g_ptc_task[6] = {1, 2, 4, 5, 6, 7};
3737
#endif
3838
#define PTC_CONFIG_NUMBER 5
3939

40-
40+
void ptc_save_phase(void);
4141

4242
uint32_t *g_ptc_config;
4343

@@ -152,6 +152,11 @@ void PTC2_IRQHandler(void)
152152
HAL_PTC_IRQHandler(&PtcHandle[5]);
153153
}
154154
#endif
155+
if ((isr_flag & (1 << g_ptc_task[6])) != 0)
156+
{
157+
HAL_PTC_IRQHandler(&PtcHandle[6]);
158+
ptc_save_phase();
159+
}
155160

156161
rt_interrupt_leave();
157162

@@ -194,6 +199,55 @@ static uint16_t ptc_delay_cal(uint16_t ns)
194199

195200
}
196201

202+
typedef struct
203+
{
204+
uint32_t cfo_phase[2];
205+
uint32_t cnt;
206+
} cfo_phase_t;
207+
208+
cfo_phase_t *pt_cfo = (cfo_phase_t *)0x500827E0;
209+
210+
void ptc_save_phase(void)
211+
{
212+
uint16_t phase_tmp = hwp_bt_phy->RX_STATUS1 & BT_PHY_RX_STATUS1_CFO_PHASE;
213+
214+
215+
if (phase_tmp >= 0x800)
216+
{
217+
phase_tmp = (~phase_tmp) & BT_PHY_RX_STATUS1_CFO_PHASE;
218+
}
219+
220+
if (phase_tmp == 0)
221+
{
222+
return;
223+
}
224+
225+
226+
pt_cfo->cfo_phase[0] = phase_tmp;
227+
228+
}
229+
void ptc_config_co(uint8_t index, uint8_t sel_idx, uint8_t tripol, uint16_t delay)
230+
{
231+
PtcHandle[index].Instance = hwp_ptc2;
232+
PtcHandle[index].Init.Channel = g_ptc_task[index]; // Use PTC Channel 0
233+
PtcHandle[index].Init.Address = (uint32_t) & (pt_cfo->cfo_phase[0]);
234+
PtcHandle[index].Init.data = 0; // data to handle with value in Address.
235+
PtcHandle[index].Init.Operation = PTC_OP_OR; // Or and write back
236+
PtcHandle[index].Init.Sel = sel_idx;
237+
PtcHandle[index].Init.Tripol = tripol;
238+
PtcHandle[index].Init.Delay = delay;
239+
HAL_NVIC_SetPriority(PTC2_IRQn, 0, 0);
240+
//NVIC_EnableIRQ(PTC2_IRQn);
241+
242+
if (HAL_PTC_Init(& PtcHandle[index]) != HAL_OK) // Initialize PTC
243+
{
244+
/* Initialization Error */
245+
RT_ASSERT(RT_FALSE);
246+
}
247+
HAL_PTC_Enable(&PtcHandle[index], 1); // Enable PTC
248+
249+
}
250+
197251
#if SF_WLAN_COEX
198252

199253
#ifdef SOC_SF32LB58X
@@ -262,6 +316,7 @@ void rf_ptc_config(uint8_t is_reset)
262316
pta_ptc_config(4, PTC_LCPU_BT_PRIORITY, 0, 0);
263317
pta_ptc_config(5, PTC_LCPU_BT_PRIORITY, 1, 0);
264318
#endif
319+
ptc_config_co(6, PTC_LCPU_BT_PKTDET, 0, 0);
265320

266321
#endif // BLUETOOTH_PTC_CONFIG
267322
}

0 commit comments

Comments
 (0)