efm8 usb bridge working

This commit is contained in:
Conor Patrick
2018-07-04 12:48:18 -04:00
parent ca882dc38a
commit 344a104ece
39 changed files with 9027 additions and 812 deletions

View File

@@ -10,6 +10,7 @@
#include "SI_EFM8UB1_Register_Enums.h"
#include <stdint.h>
#include <stdbool.h>
#include "efm8_config.h"
/******************************************************************************/
@@ -167,7 +168,7 @@ extern void USB_DisableInts(void);
* @brief Returns state of USB interrupt enabler
* @return TRUE if USB interrupts are enabled, FALSE otherwise.
******************************************************************************/
extern bool USB_GetIntsEnabled(void);
bool USB_GetIntsEnabled(void);
/***************************************************************************//**
* @brief Enables VBUS detection
@@ -324,7 +325,9 @@ extern void USB_SuspendTransceiver(void);
do \
{ \
SFRPAGE = PG3_PAGE; \
USB0XCN &= ~(USB0XCN_PHYEN__ENABLED | USB0XCN_Dp__HIGH | USB0XCN_Dn__HIGH);\
USB0XCN &= ~(USB0XCN_PHYEN__ENABLED \
| USB0XCN_Dp__HIGH \
| USB0XCN_Dn__HIGH); \
} while (0)
#endif
@@ -503,14 +506,14 @@ extern void USB_UnsuspendRegulator(void);
* @brief Determine if the internal regulator is enabled
* @return TRUE if the internal regulator is enabled, FALSE otherwise
******************************************************************************/
extern bool USB_IsRegulatorEnabled(void);
bool USB_IsRegulatorEnabled(void);
/***************************************************************************//**
* @brief Disable the prefetch engine
* @note This function is implemented as a macro.
******************************************************************************/
#ifdef IS_DOXYGEN
extern void USB_DisablePrefetch(void);
void USB_DisablePrefetch(void);
#else
#define USB_DisablePrefetch() \
do \
@@ -525,7 +528,7 @@ extern void USB_DisablePrefetch(void);
* @note This function is implemented as a macro.
******************************************************************************/
#ifdef IS_DOXYGEN
extern void USB_EnablePrefetch(void);
void USB_EnablePrefetch(void);
#else
#define USB_EnablePrefetch() \
do \
@@ -539,12 +542,12 @@ extern void USB_EnablePrefetch(void);
* @brief Determine if the prefetch engine is enabled
* @return TRUE if prefetch engine is enabled, FALSE otherwise.
******************************************************************************/
extern bool USB_IsPrefetchEnabled(void);
bool USB_IsPrefetchEnabled(void);
/***************************************************************************//**
* @brief Suspends internal oscillator
******************************************************************************/
extern void USB_SuspendOscillator(void);
void USB_SuspendOscillator(void);
/***************************************************************************//**
* @brief Enables clock recovery in full speed mode
@@ -731,8 +734,7 @@ extern void USB_Ep0SetLastOutPacketReady(void);
#ifdef IS_DOXYGEN
extern void USB_Ep0SendStall(void);
#else
#define USB_Ep0SendStall() \
USB_WRITE_BYTE(E0CSR, (E0CSR_SOPRDY__SET | E0CSR_SDSTL__SET))
#define USB_Ep0SendStall() USB_WRITE_BYTE(E0CSR, E0CSR_SDSTL__SET)
#endif
/***************************************************************************//**
@@ -964,7 +966,7 @@ extern bool USB_IsOut3IntActive(uint8_t OUT1INT_snapshot);
extern void USB_SetSuspendIntActive(uint8_t CMINT_snapshot);
#else
#define USB_SetSuspendIntActive(CMINT_snapshot) \
((CMINT_snapshot) |= CMINT_SUSINT__SET)
(CMINT_snapshot |= CMINT_SUSINT__SET)
#endif
/***************************************************************************//**
@@ -978,7 +980,7 @@ extern void USB_SetSuspendIntActive(uint8_t CMINT_snapshot);
extern void USB_SetEp0IntActive(uint8_t IN1INT_snapshot);
#else
#define USB_SetEp0IntActive(IN1INT_snapshot) \
((IN1INT_snapshot) |= IN1INT_EP0__SET)
(IN1INT_snapshot |= IN1INT_EP0__SET)
#endif
/***************************************************************************//**
@@ -992,7 +994,7 @@ extern void USB_SetEp0IntActive(uint8_t IN1INT_snapshot);
extern void USB_SetIn1IntActive(uint8_t IN1INT_snapshot);
#else
#define USB_SetIn1IntActive(IN1INT_snapshot) \
((IN1INT_snapshot) |= IN1INT_IN1__SET)
(IN1INT_snapshot |= IN1INT_IN1__SET)
#endif
/***************************************************************************//**
@@ -1006,7 +1008,7 @@ extern void USB_SetIn1IntActive(uint8_t IN1INT_snapshot);
extern void USB_SetIn2IntActive(uint8_t IN1INT_snapshot);
#else
#define USB_SetIn2IntActive(IN1INT_snapshot) \
((IN1INT_snapshot) |= IN1INT_IN2__SET)
(IN1INT_snapshot |= IN1INT_IN2__SET)
#endif
/***************************************************************************//**
@@ -1020,7 +1022,7 @@ extern void USB_SetIn2IntActive(uint8_t IN1INT_snapshot);
extern void USB_SetIn3IntActive(uint8_t IN1INT_snapshot);
#else
#define USB_SetIn3IntActive(IN1INT_snapshot) \
((IN1INT_snapshot) |= IN1INT_IN3__SET)
(IN1INT_snapshot |= IN1INT_IN3__SET)
#endif
/***************************************************************************//**
@@ -1034,7 +1036,7 @@ extern void USB_SetIn3IntActive(uint8_t IN1INT_snapshot);
extern void USB_SetOut1IntActive(uint8_t OUT1INT_snapshot);
#else
#define USB_SetOut1IntActive(OUT1INT_snapshot) \
((OUT1INT_snapshot) |= OUT1INT_OUT1__SET)
(OUT1INT_snapshot |= OUT1INT_OUT1__SET)
#endif
/***************************************************************************//**
@@ -1048,7 +1050,7 @@ extern void USB_SetOut1IntActive(uint8_t OUT1INT_snapshot);
extern void USB_SetOut2IntActive(uint8_t OUT1INT_snapshot);
#else
#define USB_SetOut2IntActive(OUT1INT_snapshot) \
((OUT1INT_snapshot) |= OUT1INT_OUT2__SET)
(OUT1INT_snapshot |= OUT1INT_OUT2__SET)
#endif
/***************************************************************************//**
@@ -1062,7 +1064,7 @@ extern void USB_SetOut2IntActive(uint8_t OUT1INT_snapshot);
extern void USB_SetOut3IntActive(uint8_t OUT1INT_snapshot);
#else
#define USB_SetOut3IntActive(OUT1INT_snapshot) \
((OUT1INT_snapshot) |= OUT1INT_OUT3__SET)
(OUT1INT_snapshot |= OUT1INT_OUT3__SET)
#endif
/***************************************************************************//**
@@ -1078,7 +1080,7 @@ extern void USB_EnableDeviceInts(void);
(CMIE_SOFE__ENABLED \
| CMIE_RSTINTE__ENABLED \
| CMIE_RSUINTE__ENABLED \
| CMIE_SUSINTE__ENABLED))
| CMIE_SUSINTE__ENABLED));
#endif
/***************************************************************************//**
@@ -1088,7 +1090,7 @@ extern void USB_EnableDeviceInts(void);
#ifdef IS_DOXYGEN
extern void USB_EnableSofInt(void);
#else
#define USB_EnableSofInt() USB_SET_BITS(CMIE, CMIE_SOFE__ENABLED)
#define USB_EnableSofInt() USB_SET_BITS(CMIE, CMIE_SOFE__ENABLED);
#endif
/***************************************************************************//**
@@ -1098,7 +1100,7 @@ extern void USB_EnableSofInt(void);
#ifdef IS_DOXYGEN
extern void USB_DisableSofInt(void);
#else
#define USB_DisableSofInt() USB_CLEAR_BITS(CMIE, CMIE_SOFE__ENABLED)
#define USB_DisableSofInt() USB_CLEAR_BITS(CMIE, CMIE_SOFE__ENABLED);
#endif
/***************************************************************************//**
@@ -1108,7 +1110,7 @@ extern void USB_DisableSofInt(void);
#ifdef IS_DOXYGEN
extern void USB_EnableResetInt(void);
#else
#define USB_EnableResetInt() USB_SET_BITS(CMIE, CMIE_RSTINTE__ENABLED)
#define USB_EnableResetInt() USB_SET_BITS(CMIE, CMIE_RSTINTE__ENABLED);
#endif
/***************************************************************************//**
@@ -1118,7 +1120,7 @@ extern void USB_EnableResetInt(void);
#ifdef IS_DOXYGEN
extern void USB_DisableResetInt(void);
#else
#define USB_DisableResetInt() USB_CLEAR_BITS(CMIE, CMIE_RSTINTE__ENABLED)
#define USB_DisableResetInt() USB_CLEAR_BITS(CMIE, CMIE_RSTINTE__ENABLED);
#endif
/***************************************************************************//**
@@ -1128,7 +1130,7 @@ extern void USB_DisableResetInt(void);
#ifdef IS_DOXYGEN
extern void USB_EnableResumeInt(void);
#else
#define USB_EnableResumeInt() USB_SET_BITS(CMIE, CMIE_RSUINTE__ENABLED)
#define USB_EnableResumeInt() USB_SET_BITS(CMIE, CMIE_RSUINTE__ENABLED);
#endif
/***************************************************************************//**
@@ -1138,7 +1140,7 @@ extern void USB_EnableResumeInt(void);
#ifdef IS_DOXYGEN
extern void USB_DisableResumeInt(void);
#else
#define USB_DisableResumeInt() USB_CLEAR_BITS(CMIE, CMIE_RSUINTE__ENABLED)
#define USB_DisableResumeInt() USB_CLEAR_BITS(CMIE, CMIE_RSUINTE__ENABLED);
#endif
/***************************************************************************//**
@@ -1148,7 +1150,7 @@ extern void USB_DisableResumeInt(void);
#ifdef IS_DOXYGEN
extern void USB_EnableSuspendInt(void);
#else
#define USB_EnableSuspendInt() USB_SET_BITS(CMIE, CMIE_SUSINTE__ENABLED)
#define USB_EnableSuspendInt() USB_SET_BITS(CMIE, CMIE_SUSINTE__ENABLED);
#endif
/***************************************************************************//**
@@ -1158,7 +1160,7 @@ extern void USB_EnableSuspendInt(void);
#ifdef IS_DOXYGEN
extern void USB_DisableSuspendInt(void);
#else
#define USB_DisableSuspendInt() USB_CLEAR_BITS(CMIE, CMIE_SUSINTE__ENABLED)
#define USB_DisableSuspendInt() USB_CLEAR_BITS(CMIE, CMIE_SUSINTE__ENABLED);
#endif
/***************************************************************************//**
@@ -1168,7 +1170,7 @@ extern void USB_DisableSuspendInt(void);
#ifdef IS_DOXYGEN
extern void USB_EnableEp0Int(void);
#else
#define USB_EnableEp0Int() USB_SET_BITS(IN1IE, IN1IE_EP0E__ENABLED)
#define USB_EnableEp0Int() USB_SET_BITS(IN1IE, IN1IE_EP0E__ENABLED);
#endif
/***************************************************************************//**
@@ -1178,7 +1180,7 @@ extern void USB_EnableEp0Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableEp0Int(void);
#else
#define USB_DisableEp0Int() USB_CLEAR_BITS(IN1IE, IN1IE_EP0E__ENABLED)
#define USB_DisableEp0Int() USB_CLEAR_BITS(IN1IE, IN1IE_EP0E__ENABLED);
#endif
/***************************************************************************//**
@@ -1188,7 +1190,7 @@ extern void USB_DisableEp0Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableIn1Int(void);
#else
#define USB_EnableIn1Int() USB_SET_BITS(IN1IE, IN1IE_IN1E__ENABLED)
#define USB_EnableIn1Int() USB_SET_BITS(IN1IE, IN1IE_IN1E__ENABLED);
#endif
/***************************************************************************//**
@@ -1198,7 +1200,7 @@ extern void USB_EnableIn1Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableIn1Int(void);
#else
#define USB_DisableIn1Int() USB_CLEAR_BITS(IN1IE, IN1IE_IN1E__ENABLED)
#define USB_DisableIn1Int() USB_CLEAR_BITS(IN1IE, IN1IE_IN1E__ENABLED);
#endif
/***************************************************************************//**
@@ -1208,7 +1210,7 @@ extern void USB_DisableIn1Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableIn2Int(void);
#else
#define USB_EnableIn2Int() USB_SET_BITS(IN1IE, IN1IE_IN2E__ENABLED)
#define USB_EnableIn2Int() USB_SET_BITS(IN1IE, IN1IE_IN2E__ENABLED);
#endif
/***************************************************************************//**
@@ -1218,7 +1220,7 @@ extern void USB_EnableIn2Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableIn2Int(void);
#else
#define USB_DisableIn2Int() USB_CLEAR_BITS(IN1IE, IN1IE_IN2E__ENABLED)
#define USB_DisableIn2Int() USB_CLEAR_BITS(IN1IE, IN1IE_IN2E__ENABLED);
#endif
/***************************************************************************//**
@@ -1228,7 +1230,7 @@ extern void USB_DisableIn2Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableIn3Int(void);
#else
#define USB_EnableIn3Int() USB_SET_BITS(IN1IE, IN1IE_IN3E__ENABLED)
#define USB_EnableIn3Int() USB_SET_BITS(IN1IE, IN1IE_IN3E__ENABLED);
#endif
/***************************************************************************//**
@@ -1238,7 +1240,7 @@ extern void USB_EnableIn3Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableIn3Int(void);
#else
#define USB_DisableIn3Int() USB_CLEAR_BITS(IN1IE, IN1IE_IN3E__ENABLED)
#define USB_DisableIn3Int() USB_CLEAR_BITS(IN1IE, IN1IE_IN3E__ENABLED);
#endif
/***************************************************************************//**
@@ -1248,7 +1250,7 @@ extern void USB_DisableIn3Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableOut1Int(void);
#else
#define USB_EnableOut1Int() USB_SET_BITS(OUT1IE, OUT1IE_OUT1E__ENABLED)
#define USB_EnableOut1Int() USB_SET_BITS(OUT1IE, OUT1IE_OUT1E__ENABLED);
#endif
/***************************************************************************//**
@@ -1258,7 +1260,7 @@ extern void USB_EnableOut1Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableOut1Int(void);
#else
#define USB_DisableOut1Int() USB_CLEAR_BITS(OUT1IE, OUT1IE_OUT1E__ENABLED)
#define USB_DisableOut1Int() USB_CLEAR_BITS(OUT1IE, OUT1IE_OUT1E__ENABLED);
#endif
/***************************************************************************//**
@@ -1268,7 +1270,7 @@ extern void USB_DisableOut1Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableOut2Int(void);
#else
#define USB_EnableOut2Int() USB_SET_BITS(OUT1IE, OUT1IE_OUT2E__ENABLED)
#define USB_EnableOut2Int() USB_SET_BITS(OUT1IE, OUT1IE_OUT2E__ENABLED);
#endif
/***************************************************************************//**
@@ -1278,7 +1280,7 @@ extern void USB_EnableOut2Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableOut2Int(void);
#else
#define USB_DisableOut2Int() USB_CLEAR_BITS(OUT1IE, OUT1IE_OUT2E__ENABLED)
#define USB_DisableOut2Int() USB_CLEAR_BITS(OUT1IE, OUT1IE_OUT2E__ENABLED);
#endif
/***************************************************************************//**
@@ -1288,7 +1290,7 @@ extern void USB_DisableOut2Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableOut3Int(void);
#else
#define USB_EnableOut3Int() USB_SET_BITS(OUT1IE, OUT1IE_OUT3E__ENABLED)
#define USB_EnableOut3Int() USB_SET_BITS(OUT1IE, OUT1IE_OUT3E__ENABLED);
#endif
/***************************************************************************//**
@@ -1298,7 +1300,7 @@ extern void USB_EnableOut3Int(void);
#ifdef IS_DOXYGEN
extern void USB_DisableOut3Int(void);
#else
#define USB_DisableOut3Int() USB_CLEAR_BITS(OUT1IE, OUT1IE_OUT3E__ENABLED)
#define USB_DisableOut3Int() USB_CLEAR_BITS(OUT1IE, OUT1IE_OUT3E__ENABLED);
#endif
/***************************************************************************//**
@@ -1308,7 +1310,7 @@ extern void USB_DisableOut3Int(void);
#ifdef IS_DOXYGEN
extern void USB_EnableEp1(void);
#else
#define USB_EnableEp1() USB_SET_BITS(EENABLE, EENABLE_EEN1__ENABLED)
#define USB_EnableEp1() USB_SET_BITS(EENABLE, EENABLE_EEN1__ENABLED);
#endif
/***************************************************************************//**
@@ -1318,7 +1320,7 @@ extern void USB_EnableEp1(void);
#ifdef IS_DOXYGEN
extern void USB_DisableEp1(void);
#else
#define USB_DisableEp1() USB_CLEAR_BITS(EENABLE, EENABLE_EEN1__ENABLED)
#define USB_DisableEp1() USB_CLEAR_BITS(EENABLE, EENABLE_EEN1__ENABLED);
#endif
/***************************************************************************//**
@@ -1328,7 +1330,7 @@ extern void USB_DisableEp1(void);
#ifdef IS_DOXYGEN
extern void USB_EnableEp2(void);
#else
#define USB_EnableEp2() USB_SET_BITS(EENABLE, EENABLE_EEN2__ENABLED)
#define USB_EnableEp2() USB_SET_BITS(EENABLE, EENABLE_EEN2__ENABLED);
#endif
/***************************************************************************//**
@@ -1338,7 +1340,7 @@ extern void USB_EnableEp2(void);
#ifdef IS_DOXYGEN
extern void USB_DisableEp2(void);
#else
#define USB_DisableEp2() USB_CLEAR_BITS(EENABLE, EENABLE_EEN2__ENABLED)
#define USB_DisableEp2() USB_CLEAR_BITS(EENABLE, EENABLE_EEN2__ENABLED);
#endif
/***************************************************************************//**
@@ -1348,7 +1350,7 @@ extern void USB_DisableEp2(void);
#ifdef IS_DOXYGEN
extern void USB_EnableEp3(void);
#else
#define USB_EnableEp3() USB_SET_BITS(EENABLE, EENABLE_EEN3__ENABLED)
#define USB_EnableEp3() USB_SET_BITS(EENABLE, EENABLE_EEN3__ENABLED);
#endif
/***************************************************************************//**
@@ -1358,7 +1360,7 @@ extern void USB_EnableEp3(void);
#ifdef IS_DOXYGEN
extern void USB_DisableEp3(void);
#else
#define USB_DisableEp3() USB_CLEAR_BITS(EENABLE, EENABLE_EEN3__ENABLED)
#define USB_DisableEp3() USB_CLEAR_BITS(EENABLE, EENABLE_EEN3__ENABLED);
#endif
/***************************************************************************//**
@@ -1368,7 +1370,7 @@ extern void USB_DisableEp3(void);
#ifdef IS_DOXYGEN
extern void USB_EpnDirectionOut(void);
#else
#define USB_EpnDirectionOut() USB_CLEAR_BITS(EINCSRH, EINCSRH_DIRSEL__IN)
#define USB_EpnDirectionOut() USB_CLEAR_BITS(EINCSRH, EINCSRH_DIRSEL__IN);
#endif
/***************************************************************************//**
@@ -1378,7 +1380,7 @@ extern void USB_EpnDirectionOut(void);
#ifdef IS_DOXYGEN
extern void USB_EpnDirectionIn(void);
#else
#define USB_EpnDirectionIn() USB_SET_BITS(EINCSRH, EINCSRH_DIRSEL__IN)
#define USB_EpnDirectionIn() USB_SET_BITS(EINCSRH, EINCSRH_DIRSEL__IN);
#endif
/***************************************************************************//**
@@ -1389,7 +1391,7 @@ extern void USB_EpnDirectionIn(void);
extern void USB_EpnEnableSplitMode(void);
#else
#define USB_EpnEnableSplitMode() \
USB_SET_BITS(EINCSRH, EINCSRH_SPLIT__ENABLED)
USB_SET_BITS(EINCSRH, EINCSRH_SPLIT__ENABLED);
#endif
/***************************************************************************//**
@@ -1400,7 +1402,7 @@ extern void USB_EpnEnableSplitMode(void);
extern void USB_EpnDisableSplitMode(void);
#else
#define USB_EpnDisableSplitMode() \
USB_CLEAR_BITS(EINCSRH, EINCSRH_SPLIT__ENABLED)
USB_CLEAR_BITS(EINCSRH, EINCSRH_SPLIT__ENABLED);
#endif
/***************************************************************************//**
@@ -1410,7 +1412,7 @@ extern void USB_EpnDisableSplitMode(void);
#ifdef IS_DOXYGEN
extern void USB_EpnInClearDataToggle(void);
#else
#define USB_EpnInClearDataToggle() USB_SET_BITS(EINCSRL, EINCSRL_CLRDT__BMASK)
#define USB_EpnInClearDataToggle() USB_SET_BITS(EINCSRL, EINCSRL_CLRDT__BMASK);
#endif
/***************************************************************************//**
@@ -1420,7 +1422,7 @@ extern void USB_EpnInClearDataToggle(void);
#ifdef IS_DOXYGEN
extern void USB_EpnInClearSentStall(void);
#else
#define USB_EpnInClearSentStall() USB_WRITE_BYTE(EINCSRL, 0)
#define USB_EpnInClearSentStall() USB_WRITE_BYTE(EINCSRL, 0);
#endif
/***************************************************************************//**
@@ -1430,7 +1432,7 @@ extern void USB_EpnInClearSentStall(void);
#ifdef IS_DOXYGEN
extern void USB_EpnInStall(void);
#else
#define USB_EpnInStall() USB_WRITE_BYTE(EINCSRL, EINCSRL_SDSTL__SET)
#define USB_EpnInStall() USB_WRITE_BYTE(EINCSRL, EINCSRL_SDSTL__SET);
#endif
/***************************************************************************//**
@@ -1440,7 +1442,7 @@ extern void USB_EpnInStall(void);
#ifdef IS_DOXYGEN
extern void USB_EpnInEndStall(void);
#else
#define USB_EpnInEndStall() USB_WRITE_BYTE(EINCSRL, 0)
#define USB_EpnInEndStall() USB_WRITE_BYTE(EINCSRL, 0);
#endif
/***************************************************************************//**
@@ -1452,7 +1454,7 @@ extern void USB_EpnInEndStall(void);
extern void USB_EpnInEndStallAndClearDataToggle(void);
#else
#define USB_EpnInEndStallAndClearDataToggle() \
USB_WRITE_BYTE(EINCSRL, EINCSRL_CLRDT__BMASK)
USB_WRITE_BYTE(EINCSRL, EINCSRL_CLRDT__BMASK);
#endif
/***************************************************************************//**
@@ -1470,7 +1472,7 @@ extern void USB_EpnInFlush(void);
{ \
USB_READ_BYTE(EINCSRL); \
} while (USB0DAT & EINCSRL_FLUSH__SET); \
} while (0)
} while (0);
#endif
/***************************************************************************//**
@@ -1480,7 +1482,7 @@ extern void USB_EpnInFlush(void);
#ifdef IS_DOXYGEN
extern void USB_EpnInClearUnderrun(void);
#else
#define USB_EpnInClearUnderrun() USB_CLEAR_BITS(EINCSRL, EINCSRL_UNDRUN__SET)
#define USB_EpnInClearUnderrun() USB_CLEAR_BITS(EINCSRL, EINCSRL_UNDRUN__SET);
#endif
/***************************************************************************//**
@@ -1490,7 +1492,7 @@ extern void USB_EpnInClearUnderrun(void);
#ifdef IS_DOXYGEN
extern void USB_EpnSetInPacketReady(void);
#else
#define USB_EpnSetInPacketReady() USB_SET_BITS(EINCSRL, EINCSRL_INPRDY__SET)
#define USB_EpnSetInPacketReady() USB_SET_BITS(EINCSRL, EINCSRL_INPRDY__SET);
#endif
/***************************************************************************//**
@@ -1501,7 +1503,7 @@ extern void USB_EpnSetInPacketReady(void);
extern void USB_EpnInEnableDoubleBuffer(void);
#else
#define USB_EpnInEnableDoubleBuffer() \
USB_SET_BITS(EINCSRH, EINCSRH_DBIEN__ENABLED)
USB_SET_BITS(EINCSRH, EINCSRH_DBIEN__ENABLED);
#endif
/***************************************************************************//**
@@ -1512,7 +1514,7 @@ extern void USB_EpnInEnableDoubleBuffer(void);
extern void USB_EpnInDisableDoubleBuffer(void);
#else
#define USB_EpnInDisableDoubleBuffer() \
USB_CLEAR_BITS(EINCSRH, EINCSRH_DBIEN__ENABLED)
USB_CLEAR_BITS(EINCSRH, EINCSRH_DBIEN__ENABLED);
#endif
/***************************************************************************//**
@@ -1523,7 +1525,7 @@ extern void USB_EpnInDisableDoubleBuffer(void);
extern void USB_EpnInEnableInterruptBulkMode(void);
#else
#define USB_EpnInEnableInterruptBulkMode() \
USB_CLEAR_BITS(EINCSRH, EINCSRH_ISO__ENABLED)
USB_CLEAR_BITS(EINCSRH, EINCSRH_ISO__ENABLED);
#endif
/***************************************************************************//**
@@ -1534,7 +1536,7 @@ extern void USB_EpnInEnableInterruptBulkMode(void);
extern void USB_EpnInEnableIsochronousMode(void);
#else
#define USB_EpnInEnableIsochronousMode() \
USB_SET_BITS(EINCSRH, EINCSRH_ISO__ENABLED)
USB_SET_BITS(EINCSRH, EINCSRH_ISO__ENABLED);
#endif
/***************************************************************************//**
@@ -1545,7 +1547,7 @@ extern void USB_EpnInEnableIsochronousMode(void);
extern void USB_EpnInEnableForcedDataToggle(void);
#else
#define USB_EpnInEnableForcedDataToggle() \
USB_SET_BITS(EINCSRH, EINCSRH_FCDT__ALWAYS_TOGGLE)
USB_SET_BITS(EINCSRH, EINCSRH_FCDT__ALWAYS_TOGGLE);
#endif
/***************************************************************************//**
@@ -1556,7 +1558,7 @@ extern void USB_EpnInEnableForcedDataToggle(void);
extern void USB_EpnInDisableForcedDataToggle(void);
#else
#define USB_EpnInDisableForcedDataToggle() \
USB_CLEAR_BITS(EINCSRH, EINCSRH_FCDT__ALWAYS_TOGGLE)
USB_CLEAR_BITS(EINCSRH, EINCSRH_FCDT__ALWAYS_TOGGLE);
#endif
/***************************************************************************//**
@@ -1567,7 +1569,7 @@ extern void USB_EpnInDisableForcedDataToggle(void);
extern void USB_EpnOutClearDataToggle(void);
#else
#define USB_EpnOutClearDataToggle() \
USB_SET_BITS(EOUTCSRL, EOUTCSRL_CLRDT__BMASK)
USB_SET_BITS(EOUTCSRL, EOUTCSRL_CLRDT__BMASK);
#endif
/***************************************************************************//**
@@ -1578,7 +1580,7 @@ extern void USB_EpnOutClearDataToggle(void);
extern void USB_EpnOutClearSentStall(void);
#else
#define USB_EpnOutClearSentStall() \
USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_STSTL__BMASK)
USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_STSTL__BMASK);
#endif
/***************************************************************************//**
@@ -1589,7 +1591,7 @@ extern void USB_EpnOutClearSentStall(void);
extern void USB_EpnOutStall(void);
#else
#define USB_EpnOutStall() \
USB_SET_BITS(EOUTCSRL, EOUTCSRL_SDSTL__SET)
USB_SET_BITS(EOUTCSRL, EOUTCSRL_SDSTL__SET);
#endif
/***************************************************************************//**
@@ -1599,7 +1601,7 @@ extern void USB_EpnOutStall(void);
#ifdef IS_DOXYGEN
extern void USB_EpnOutEndStall(void);
#else
#define USB_EpnOutEndStall() USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_SDSTL__SET)
#define USB_EpnOutEndStall() USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_SDSTL__SET);
#endif
/***************************************************************************//**
@@ -1618,7 +1620,7 @@ extern void USB_EpnOutEndStallAndClearDataToggle(void);
while (USB0ADR & USB0ADR_BUSY__SET) {} \
USB0DAT |= EOUTCSRL_CLRDT__BMASK; \
while (USB0ADR & USB0ADR_BUSY__SET) {} \
} while (0)
} while (0);
#endif
/***************************************************************************//**
@@ -1636,7 +1638,7 @@ extern void USB_EpnOutFlush(void);
{ \
USB_READ_BYTE(EOUTCSRL); \
} while (USB0DAT & EOUTCSRL_FLUSH__SET); \
} while (0)
} while (0);
#endif
/***************************************************************************//**
@@ -1646,7 +1648,7 @@ extern void USB_EpnOutFlush(void);
#ifdef IS_DOXYGEN
extern void USB_EpnOutClearOverrun(void);
#else
#define USB_EpnOutClearOverrun() USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_OVRUN__SET)
#define USB_EpnOutClearOverrun() USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_OVRUN__SET);
#endif
/***************************************************************************//**
@@ -1657,7 +1659,7 @@ extern void USB_EpnOutClearOverrun(void);
extern void USB_EpnClearOutPacketReady(void);
#else
#define USB_EpnClearOutPacketReady() \
USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_OPRDY__SET)
USB_CLEAR_BITS(EOUTCSRL, EOUTCSRL_OPRDY__SET);
#endif
/***************************************************************************//**
@@ -1668,7 +1670,7 @@ extern void USB_EpnClearOutPacketReady(void);
extern void USB_EpnOutEnableDoubleBuffer(void);
#else
#define USB_EpnOutEnableDoubleBuffer() \
USB_SET_BITS(EOUTCSRH, EOUTCSRH_DBIEN__ENABLED)
USB_SET_BITS(EOUTCSRH, EOUTCSRH_DBIEN__ENABLED);
#endif
/***************************************************************************//**
@@ -1679,7 +1681,7 @@ extern void USB_EpnOutEnableDoubleBuffer(void);
extern void USB_EpnOutDisableDoubleBuffer(void);
#else
#define USB_EpnOutDisableDoubleBuffer() \
USB_CLEAR_BITS(EOUTCSRH, EOUTCSRH_DBIEN__ENABLED)
USB_CLEAR_BITS(EOUTCSRH, EOUTCSRH_DBIEN__ENABLED);
#endif
/***************************************************************************//**
@@ -1690,7 +1692,7 @@ extern void USB_EpnOutDisableDoubleBuffer(void);
extern void USB_EpnOutEnableInterruptBulkMode(void);
#else
#define USB_EpnOutEnableInterruptBulkMode() \
USB_CLEAR_BITS(EOUTCSRH, EOUTCSRH_ISO__ENABLED)
USB_CLEAR_BITS(EOUTCSRH, EOUTCSRH_ISO__ENABLED);
#endif
/***************************************************************************//**
@@ -1701,7 +1703,7 @@ extern void USB_EpnOutEnableInterruptBulkMode(void);
extern void USB_EpnOutEnableIsochronousMode(void);
#else
#define USB_EpnOutEnableIsochronousMode() \
USB_SET_BITS(EOUTCSRH, EOUTCSRH_ISO__ENABLED)
USB_SET_BITS(EOUTCSRH, EOUTCSRH_ISO__ENABLED);
#endif
/***************************************************************************//**
@@ -1719,7 +1721,7 @@ extern void USB_EnableReadFIFO(uint8_t fifoNum);
while (USB0ADR & USB0ADR_BUSY__SET) {} \
USB0ADR = (USB0ADR_BUSY__SET \
| USB0ADR_AUTORD__ENABLED \
| (FIFO0 | (fifoNum))); \
| (FIFO0 | fifoNum)); \
} while (0)
#endif
@@ -1742,13 +1744,13 @@ extern void USB_DisableReadFIFO(uint8_t fifoNum);
* @note This function is implemented as a macro.
******************************************************************************/
#ifdef IS_DOXYGEN
extern void USB_GetFIFOByte(uint8_t *readDat);
extern void USB_GetFIFOByte(uint8_t * readDat);
#else
#define USB_GetFIFOByte(readDat) \
do \
{ \
while (USB0ADR & USB0ADR_BUSY__SET) {} \
*(readDat) = USB0DAT; \
readDat = USB0DAT; \
} while (0)
#endif
@@ -1764,14 +1766,14 @@ extern void USB_GetFIFOByte(uint8_t *readDat);
* @note This function is implemented as a macro.
******************************************************************************/
#ifdef IS_DOXYGEN
extern void USB_GetLastFIFOByte(uint8_t *readDat, uint8_t fifoNum);
extern void USB_GetLastFIFOByte(uint8_t * readDat, uint8_t fifoNum);
#else
#define USB_GetLastFIFOByte(readDat, fifoNum) \
do \
{ \
while (USB0ADR & USB0ADR_BUSY__SET) {} \
USB0ADR = (FIFO0 | (fifoNum));\
*(readDat) = USB0DAT; \
USB0ADR = (FIFO0 | fifoNum);\
readDat = USB0DAT; \
} while (0)
#endif
@@ -1788,7 +1790,7 @@ extern void USB_EnableWriteFIFO(uint8_t fifoNum);
do \
{ \
while (USB0ADR & USB0ADR_BUSY__SET) {} \
USB0ADR = (FIFO0 | (fifoNum)); \
USB0ADR = (FIFO0 | fifoNum); \
} while (0)
#endif
@@ -1817,7 +1819,7 @@ extern void USB_SetFIFOByte(uint8_t writeDat);
do \
{ \
while (USB0ADR & USB0ADR_BUSY__SET) {} \
USB0DAT = (writeDat); \
USB0DAT = writeDat; \
} while (0)
#endif
@@ -1850,98 +1852,92 @@ extern void USB_RestoreSfrPage();
* @param epsel
* Endpoint index to target
******************************************************************************/
extern void USB_SetIndex(uint8_t epsel);
void USB_SetIndex(uint8_t epsel);
/***************************************************************************//**
* @brief Reads the USB common interrupt register
* @return Value of CMINT
******************************************************************************/
extern uint8_t USB_GetCommonInts(void);
uint8_t USB_GetCommonInts(void);
/***************************************************************************//**
* @brief Reads the USB in interrupt register
* @return Value of IN1INT
******************************************************************************/
extern uint8_t USB_GetInInts(void);
uint8_t USB_GetInInts(void);
/***************************************************************************//**
* @brief Reads the out interrupt register
* @return Value of OUT1INT
******************************************************************************/
extern uint8_t USB_GetOutInts(void);
uint8_t USB_GetOutInts(void);
/***************************************************************************//**
* @brief Reads the value in INDEX
* @return Value of INDEX
******************************************************************************/
extern uint8_t USB_GetIndex(void);
uint8_t USB_GetIndex(void);
/***************************************************************************//**
* @brief Determines if the USB is currently suspended
* @return TRUE if USB is in suspend mode
******************************************************************************/
extern bool USB_IsSuspended(void);
bool USB_IsSuspended(void);
/***************************************************************************//**
* @brief Gets Setup End state
* @return TRUE when a control transaction end before software has
* set the DATAEND bit.
******************************************************************************/
extern bool USB_GetSetupEnd(void);
bool USB_GetSetupEnd(void);
/***************************************************************************//**
* @brief Determines if STALL was send on Endpoint 0
* @return TRUE after a STALL was sent on Endpoint 0
******************************************************************************/
extern bool USB_Ep0SentStall(void);
bool USB_Ep0SentStall(void);
/***************************************************************************//**
* @brief Determines if Out Packet Ready is set on Endpoint 0
* @return TRUE if Out Packet Ready is set on Endpoint 0
******************************************************************************/
extern bool USB_Ep0InPacketReady(void);
bool USB_Ep0InPacketReady(void);
/***************************************************************************//**
* @brief Determines if In Packet Ready is set on Endpoint 0
* @return TRUE if In Packet Ready is set on Endpoint 0
******************************************************************************/
extern bool USB_Ep0OutPacketReady(void);
bool USB_Ep0OutPacketReady(void);
/***************************************************************************//**
* @brief Gets Endpoint 0 data count
* @return Number of received data bytes in the Endpoint 0 FIFO
******************************************************************************/
extern uint8_t USB_Ep0GetCount(void);
uint8_t USB_Ep0GetCount(void);
/***************************************************************************//**
* @brief Checks if stall was sent on IN Endpoint N
* @return TRUE if stall was sent on IN Endpoint N, FALSE otherwise
******************************************************************************/
extern bool USB_EpnInGetSentStall(void);
bool USB_EpnInGetSentStall(void);
/***************************************************************************//**
* @brief Checks if stall was sent on OUT Endpoint N
* @return TRUE if stall was sent on OUT Endpoint N, FALSE otherwise
******************************************************************************/
extern bool USB_EpnGetInPacketReady(void);
bool USB_EpnGetInPacketReady(void);
/***************************************************************************//**
* @brief Checks if stall was sent on OUT Endpoint N
* @return TRUE if stall was sent on OUT Endpoint N, FALSE otherwise
******************************************************************************/
extern bool USB_EpnOutGetSentStall(void);
bool USB_EpnOutGetSentStall(void);
/***************************************************************************//**
* @brief Gets OutPacketReady on OUT Endpoint N
* @return TRUE if OUTPacketReady is set, FALSE otherwise
******************************************************************************/
extern bool USB_EpnGetOutPacketReady(void);
/***************************************************************************//**
* @brief Gets DataError on OUT Endpoint N
* @return TRUE if Data Error bit is set, FALSE otherwise
******************************************************************************/
extern bool USB_EpnGetDataError(void);
bool USB_EpnGetOutPacketReady(void);
/***************************************************************************//**
* @brief Gets number of bytes in the OUT FIFO
@@ -1949,27 +1945,27 @@ extern bool USB_EpnGetDataError(void);
* @return Number of bytes in the FIFO from the last received
* packet
******************************************************************************/
extern uint16_t USB_EpOutGetCount(void);
uint16_t USB_EpOutGetCount(void);
/***************************************************************************//**
* @brief Reads the USB frame number
* @return The frame number on the most recent SOF packet
******************************************************************************/
extern uint16_t USB_GetSofNumber(void);
uint16_t USB_GetSofNumber(void);
/***************************************************************************//**
* @brief Aborts pending IN transactions on the selected endpoint
* @param fifoNum
* Endpoint to abort
******************************************************************************/
extern void USB_AbortInEp(uint8_t fifoNum);
void USB_AbortInEp(uint8_t fifoNum);
/***************************************************************************//**
* @brief Aborts pending OUT transactions on the selected endpoint
* @param fifoNum
* Endpoint to abort
******************************************************************************/
extern void USB_AbortOutEp(uint8_t fifoNum);
void USB_AbortOutEp(uint8_t fifoNum);
/***************************************************************************//**
* @brief Activates the selected endpoint
@@ -1984,11 +1980,11 @@ extern void USB_AbortOutEp(uint8_t fifoNum);
* @param isoMode
* Set to 1 if endpoint is in isochronous mode, 0 if it is not
******************************************************************************/
extern void USB_ActivateEp(uint8_t ep,
uint16_t packetSize,
bool inDir,
bool splitMode,
bool isoMode);
void USB_ActivateEp(uint8_t ep,
uint16_t packetSize,
bool inDir,
bool splitMode,
bool isoMode);
/** @} (end addtogroup usb_0_runtime USB0 Runtime API) */
/** @} (end addtogroup usb_0_group USB0 Driver) */