对于左右耳,可以通过蓝牙地址奇或者gpio的方式进行区分,首先,看是否定义USE_BDADDR_FOR_LEFT_RIGHT,如有,即通过蓝牙地址奇偶数进行区分,否则即GPIO的方式区分左右耳。
具体代码如下:
earbud\src\earbud_config.h
#ifdef USE_BDADDR_FOR_LEFT_RIGHT
/* Left and right earbud roles are selected from Bluetooth address. */
/*! TRUE if this is the left earbud (Bluetooth address LAP is odd). */
#define appConfigIsLeft() (InitGetTaskData()->appInitIsLeft)
/*! TRUE if this is the right earbud (Bluetooth address LAP is even). */
#define appConfigIsRight() (appConfigIsLeft() ^ 1)
#else
/*! Left and right earbud roles are selected from the state of this PIO */
#define appConfigHandednessPio() (2)
/*! TRUE if this is the left earbud (the #appConfigHandednessPio state is 1) */
#define appConfigIsLeft() ((PioGet32Bank(appConfigHandednessPio() / 32) & (1UL << appConfigHandednessPio())) ? 1 : 0)
/*! TRUE if this is the right earbud (the #appConfigHandednessPio state is 0) */
#define appConfigIsRight() (appConfigIsLeft() ^ 1)
#endif