add lib_dnr lib_roleswitch

This commit is contained in:
Steven Dan
2026-01-27 22:43:20 +08:00
parent ed84aad10d
commit c505cf84a9
8 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
set(LIB_NAME lib_dnr)
set(LIB_VERSION 1.0.0)
set(LIB_INCLUDES api)
set(LIB_DEPENDENT_MODULES "")
XMOS_REGISTER_MODULE()

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
# You can set flags specifically for your module by using the MODULE_XCC_FLAGS
# variable. So the following
#
# MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
#
# specifies that everything in the modules should have the application
# build flags with -O3 appended (so the files will build at
# optimization level -O3).
#
# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
VERSION = 1.0.0

View File

@@ -0,0 +1,15 @@
module_roleswitch
*****************
scope:
General Use
description:
Roleswitch helper functions
keywords:
Apple, USB, roleswitch, MFI
boards:
XK-USB-AUDIO-U8-2C

View File

@@ -0,0 +1,11 @@
#define USB_IN_FLAG 0x11AA
#define COAX_IN_FLAG 0x22BB
#define OPT_IN_FLAG 0x33CC
#define UAC1_IN_FLAG 0x44DD
#define BT_IN_FLAG 0x55EE
#define I2S_IN_FLAG 0x66FF
void SetRoleSwitchFlag(unsigned flagVal);
unsigned GetRoleSwitchFlag();

View File

@@ -0,0 +1,6 @@
set(LIB_NAME lib_roleswitch)
set(LIB_VERSION 0.0.1)
set(LIB_INCLUDES include)
set(LIB_COMPILER_FLAGS -Os)
XMOS_REGISTER_MODULE()

View File

@@ -0,0 +1,22 @@
#if defined(__XS2A__)
/* Note range 0x7FFC8 - 0x7FFFF guarenteed to be untouched by tools */
#define FLAG_ADDRESS 0x7ffc8
#else
/* Note range 0xFFFC8 - 0xFFFFF guarenteed to be untouched by tools */
#define FLAG_ADDRESS 0xfffc8
#endif
/* Store Flag to fixed address */
void SetRoleSwitchFlag(unsigned x)
{
asm volatile("stw %0, %1[0]" :: "r"(x), "r"(FLAG_ADDRESS));
}
/* Load flag from fixed address */
unsigned GetRoleSwitchFlag()
{
unsigned x;
asm volatile("ldw %0, %1[0]" : "=r"(x) : "r"(FLAG_ADDRESS));
return x;
}