Skip to content

Commit 5444bac

Browse files
kevin-whisperNahal Farhi
authored andcommitted
Added callbacks for asserting/deasserting the mfi audio sync signal (zephyrproject-rtos#23)
Adds in callbacks into the lower link layer code for asserting and de-asserting the sync signal code inside of the ISR handling RX radio packets. If it's an audio packet and it's not a re-transmit, toggle the sync signal pin.
1 parent 2c3155c commit 5444bac

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef LLL_MFI_AUDIO_INTERNAL_H
2+
#define LLL_MFI_AUDIO_INTERNAL_H
3+
4+
// *** Whisper added for MFI. Register callbacks for triggering the audio
5+
// sync signal to the ezairo
6+
typedef void (*mfi_audio_sync_assert_cb_fn)(void);
7+
typedef void (*mfi_audio_sync_deassert_cb_fn)(void);
8+
void lll_mfi_audio_sync_register_cb(mfi_audio_sync_assert_cb_fn mfi_audio_sync_assert_cb,
9+
mfi_audio_sync_deassert_cb_fn mfi_audio_sync_deassert_cb);
10+
11+
#endif // LLL_MFI_AUDIO_INTERNAL_H

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "lll_df.h"
3333
#include "lll_conn.h"
3434

35+
#include "lll_mfi_audio_internal.h"
3536
#include "lll_internal.h"
3637
#include "lll_df_internal.h"
3738
#include "lll_tim_internal.h"
@@ -106,6 +107,16 @@ static uint8_t force_md_cnt;
106107
#define FORCE_MD_CNT_SET()
107108
#endif /* !CONFIG_BT_CTLR_FORCE_MD_COUNT */
108109

110+
// *** Whisper added for MFI
111+
static mfi_audio_sync_assert_cb_fn lll_mfi_audio_sync_assert_cb = NULL;
112+
static mfi_audio_sync_deassert_cb_fn lll_mfi_audio_sync_deassert_cb = NULL;
113+
void lll_mfi_audio_sync_register_cb(mfi_audio_sync_assert_cb_fn mfi_audio_sync_assert_cb,
114+
mfi_audio_sync_deassert_cb_fn mfi_audio_sync_deassert_cb)
115+
{
116+
lll_mfi_audio_sync_assert_cb = mfi_audio_sync_assert_cb;
117+
lll_mfi_audio_sync_deassert_cb = mfi_audio_sync_deassert_cb;
118+
}
119+
109120
int lll_conn_init(void)
110121
{
111122
int err;
@@ -1011,6 +1022,14 @@ static inline int isr_rx_pdu(struct lll_conn *lll, struct pdu_data *pdu_data_rx,
10111022

10121023
// Whisper added for MFI
10131024
if (lll->mode2_rx_enabled) {
1025+
// if this is an audio packet and the primary transmit slot, assert the sync signal
1026+
// for the ezairo
1027+
if((pdu_data_rx->ll_id == PDU_DATA_LLID_RESV) &&
1028+
(pdu_data_rx->sn == 0) &&
1029+
lll_mfi_audio_sync_assert_cb) {
1030+
lll_mfi_audio_sync_assert_cb();
1031+
}
1032+
10141033
// decrypt apple's mode 2 encryption packet via a soft decrypt routine
10151034
// first get the encrypted packet
10161035
struct pdu_data *scratch_pkt = radio_pkt_scratch_get();
@@ -1038,6 +1057,14 @@ static inline int isr_rx_pdu(struct lll_conn *lll, struct pdu_data *pdu_data_rx,
10381057

10391058
// there's no MIC with mode 2 encryption so set this to false
10401059
mic_failure = false;
1060+
1061+
// if this is an audio packet and the primary transmit slot, deassert the sync signal
1062+
// for the ezairo
1063+
if((pdu_data_rx->ll_id == PDU_DATA_LLID_RESV) &&
1064+
(pdu_data_rx->sn == 0) &&
1065+
lll_mfi_audio_sync_deassert_cb) {
1066+
lll_mfi_audio_sync_deassert_cb();
1067+
}
10411068
}
10421069

10431070
if (mic_failure &&

0 commit comments

Comments
 (0)