Skip to content

Commit

Permalink
Remove REF_CLK_FREQ (#383)
Browse files Browse the repository at this point in the history
* Added missing static keyword to inline definitions
* Update MIPS requirements in docs to match testing
* Removed use definition and use of REF_CLK_FREQ in favour of PLATFORM_REFERENCE_MHZ from platform.h
* Remove implementations for inlined functions when XUD_WEAK_API=1
* Changelog update and version bump
  • Loading branch information
xross authored Sep 19, 2023
1 parent a99f986 commit c8c7576
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 34 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
lib_xud Change Log
==================

2.2.4
-----

* CHANGE: Removed definition and use of REF_CLK_FREQ in favour of
PLATFORM_REFERENCE_MHZ from platform.h
* FIXED: Do not include implementations of inline functions when
XUD_WEAK_API is set

2.2.3
-----

Expand Down Expand Up @@ -165,7 +173,7 @@ Note: Forked from sc_xud at this point.

2.3.2
-----
* CHANGE: Interrupts disabled during any access to usb_tile. Allows greater reliability
* CHANGE: Interrupts disabled during any access to usb_tile. Allows greater reliability
if user suspend/resume functions enabled interrupts e.g. for role-switch

2.3.1
Expand Down
18 changes: 10 additions & 8 deletions lib_xud/api/xud.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
#define USB_TILE tile[0]
#endif

// TODO use PLATFORM_REFERENCE_MHZ from platform.h
#ifndef REF_CLK_FREQ
#define REF_CLK_FREQ (100)
#endif

#ifndef XUD_CORE_CLOCK
#ifdef __XS2A__
//#warning XUD_CORE_CLOCK not defined, using default (500MHz)
Expand Down Expand Up @@ -354,7 +349,10 @@ void XUD_Kill(XUD_ep ep);
* The buffer is assumed to be word aligned.
* \return XUD_RES_OKAY on success, for errors see `Status Reporting`.
*/
static inline int XUD_SetReady_OutPtr(XUD_ep ep, unsigned addr)
#if (XUD_WEAK_API)
XUD_Result_t XUD_SetReady_OutPtr(XUD_ep ep, unsigned addr);
#else
static inline XUD_Result_t XUD_SetReady_OutPtr(XUD_ep ep, unsigned addr)
{
int chan_array_ptr;
int reset;
Expand All @@ -371,6 +369,7 @@ static inline int XUD_SetReady_OutPtr(XUD_ep ep, unsigned addr)

return XUD_RES_OKAY;
}
#endif

/**
* \brief Marks an OUT endpoint as ready to receive data
Expand All @@ -379,7 +378,7 @@ static inline int XUD_SetReady_OutPtr(XUD_ep ep, unsigned addr)
* The buffer is assumed to be word aligned.
* \return XUD_RES_OKAY on success, for errors see `Status Reporting`.
*/
int XUD_SetReady_Out(XUD_ep ep, unsigned char buffer[]);
int XUD_SetReady_Out(XUD_ep ep, unsigned char buffer[]) ATTRIB_WEAK;


/**
Expand All @@ -390,6 +389,9 @@ int XUD_SetReady_Out(XUD_ep ep, unsigned char buffer[]);
* \param len The length of the data to transmit.
* \return XUD_RES_OKAY on success, for errors see `Status Reporting`.
*/
#if (XUD_WEAK_API)
XUD_Result_t XUD_SetReady_InPtr(XUD_ep ep, unsigned addr, int len);
#else
static inline XUD_Result_t XUD_SetReady_InPtr(XUD_ep ep, unsigned addr, int len)
{
int chan_array_ptr;
Expand Down Expand Up @@ -444,6 +446,7 @@ static inline XUD_Result_t XUD_SetReady_InPtr(XUD_ep ep, unsigned addr, int len)

return XUD_RES_OKAY;
}
#endif

/**
* \brief Marks an IN endpoint as ready to transmit data
Expand Down Expand Up @@ -475,7 +478,6 @@ static inline XUD_Result_t XUD_SetReady_In(XUD_ep ep, unsigned char buffer[], in
#endif
void XUD_GetData_Select(chanend c, XUD_ep ep, REFERENCE_PARAM(unsigned, length), REFERENCE_PARAM(XUD_Result_t, result));


/**
* \brief Select handler function for transmitting IN endpoint data in a select.
* \param c The chanend related to the endpoint
Expand Down
3 changes: 1 addition & 2 deletions lib_xud/module_build_info
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
VERSION = 2.2.3
VERSION = 2.2.4

MODULE_XCC_FLAGS = $(XCC_FLAGS) \
-O3 \
-DREF_CLK_FREQ=100 \
-fasm-linenum \
-fcomment-asm \
-DXUD_FULL_PIDTABLE=1 \
Expand Down
6 changes: 3 additions & 3 deletions lib_xud/src/core/XUD_DeviceAttach.xc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2022 XMOS LIMITED.
// Copyright 2011-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#if !defined(XUD_BYPASS_RESET)
#include <xs1.h>
Expand All @@ -14,13 +14,13 @@ extern in port flag2_port;
extern out buffered port:32 p_usb_txd;

#define TUCHEND_DELAY_us (1500) // 1.5ms
#define TUCHEND_DELAY (TUCHEND_DELAY_us * REF_CLK_FREQ)
#define TUCHEND_DELAY (TUCHEND_DELAY_us * PLATFORM_REFERENCE_MHZ)

#ifndef INVALID_DELAY_us
#define INVALID_DELAY_us (2500) // 2.5ms
#endif

#define INVALID_DELAY (INVALID_DELAY_us * REF_CLK_FREQ)
#define INVALID_DELAY (INVALID_DELAY_us * PLATFORM_REFERENCE_MHZ)

extern int resetCount;

Expand Down
4 changes: 2 additions & 2 deletions lib_xud/src/core/XUD_Main.xc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ unsigned sentReset = 0;
unsigned chanArray;

#define RESET_TIME_us (5)
#define RESET_TIME (RESET_TIME_us * REF_CLK_FREQ)
#define RESET_TIME (RESET_TIME_us * PLATFORM_REFERENCE_MHZ)

extern unsigned XUD_LLD_IoLoop(
in buffered port:32 rxd_port,
Expand Down Expand Up @@ -264,7 +264,7 @@ static int XUD_Manager_loop(XUD_chan epChans0[], XUD_chan epAddr_Ready[], chane
break;
}
t :> time;
time += (200 * REF_CLK_FREQ); // 200us poll
time += (200 * PLATFORM_REFERENCE_MHZ); // 200us poll
t when timerafter(time):> void;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib_xud/src/core/XUD_Signalling.xc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

#define T_WTRSTFS_us 26 // 26us
#ifndef T_WTRSTFS
#define T_WTRSTFS (T_WTRSTFS_us * REF_CLK_FREQ)
#define T_WTRSTFS (T_WTRSTFS_us * PLATFORM_REFERENCE_MHZ)
#endif
#define STATE_START_TO_us 3000 // 3ms
#define STATE_START_TO (STATE_START_TO_us * REF_CLK_FREQ)
#define STATE_START_TO (STATE_START_TO_us * PLATFORM_REFERENCE_MHZ)
#define DELAY_6ms_us 6000
#define DELAY_6ms (DELAY_6ms_us * REF_CLK_FREQ)
#define DELAY_6ms (DELAY_6ms_us * PLATFORM_REFERENCE_MHZ)
#define T_FILTSE0 250

#ifndef SUSPEND_VBUS_POLL_TIMER_TICKS
Expand Down
4 changes: 2 additions & 2 deletions lib_xud/src/core/XUD_TestMode.xc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2022 XMOS LIMITED.
// Copyright 2011-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <xs1.h>

Expand All @@ -8,7 +8,7 @@
extern out buffered port:32 p_usb_txd;

#define T_INTER_TEST_PACKET_us 2
#define T_INTER_TEST_PACKET (T_INTER_TEST_PACKET_us * REF_CLK_FREQ)
#define T_INTER_TEST_PACKET (T_INTER_TEST_PACKET_us * PLATFORM_REFERENCE_MHZ)

#ifndef XUD_TEST_MODE_SUPPORT_DISABLED
unsigned int test_packet[] =
Expand Down
22 changes: 10 additions & 12 deletions lib_xud/src/core/XUD_TimingDefines.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
// Copyright 2015-2022 XMOS LIMITED.
// Copyright 2015-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#ifndef _XUD_USB_DEFINES_H_
#define _XUD_USB_DEFINES_H_
#ifndef _XUD_TIMING_DEFINES_H_
#define _XUD_TIMING_DEFINES_H_

#ifndef REF_CLK_FREQ
#define REF_CLK_FREQ (100)
#endif
#include <platform.h>

// Defines relating to USB/ULPI/UTMI/Phy specs
#ifndef SUSPEND_TIMEOUT_us
#define SUSPEND_TIMEOUT_us (3000)
#endif
#define SUSPEND_TIMEOUT_ticks (SUSPEND_TIMEOUT_us * REF_CLK_FREQ)
#define SUSPEND_TIMEOUT_ticks (SUSPEND_TIMEOUT_us * PLATFORM_REFERENCE_MHZ)

// Device attach timing defines
#define T_UCHEND_T_UCH_us (1000000) // 1000ms
#define T_UCHEND_T_UCH (T_UCHEND_T_UCH_us * REF_CLK_FREQ)
#define T_UCHEND_T_UCH (T_UCHEND_T_UCH_us * PLATFORM_REFERENCE_MHZ)

#ifndef T_FILT_us
#define T_FILT_us (3) // 2.5us
#endif
#define T_FILT_ticks (T_FILT_us * REF_CLK_FREQ)
#define T_FILT_ticks (T_FILT_us * PLATFORM_REFERENCE_MHZ)

#ifndef SUSPEND_T_WTWRSTHS_us
#define SUSPEND_T_WTWRSTHS_us (200) // 200us Time beforechecking for J after asserting XcvrSelect and Termselect: T_WTRSTHS: 100-875us
#endif
#define SUSPEND_T_WTWRSTHS_ticks (SUSPEND_T_WTWRSTHS_us * REF_CLK_FREQ)
#define SUSPEND_T_WTWRSTHS_ticks (SUSPEND_T_WTWRSTHS_us * PLATFORM_REFERENCE_MHZ)

#define OUT_TIMEOUT_us (500) // How long we wait for data after OUT token
#define OUT_TIMEOUT_ticks (OUT_TIMEOUT_us * REF_CLK_FREQ)
#define OUT_TIMEOUT_ticks (OUT_TIMEOUT_us * PLATFORM_REFERENCE_MHZ)
#define TX_HANDSHAKE_TIMEOUT_us (5) // How long we wait for handshake after sending tx data
#define TX_HANDSHAKE_TIMEOUT_ticks (TX_HANDSHAKE_TIMEOUT_us * REF_CLK_FREQ)
#define TX_HANDSHAKE_TIMEOUT_ticks (TX_HANDSHAKE_TIMEOUT_us * PLATFORM_REFERENCE_MHZ)

#endif
2 changes: 1 addition & 1 deletion tests/suspend_resume_functional/makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LIBDIR = ../../lib_xud

all:
xcc -target=XCORE-200-EXPLORER -Os -D XUD_SERIES_SUPPORT=4 -D REF_CLK_FREQ=100 -D T_WTRSTFS=0 -D SUSPEND_VBUS_POLL_TIMER_TICKS=0 -D write_sswitch_reg=test_write_sswitch_reg -I read_sswitch_reg=test_read_sswitch_reg -I ${LIBDIR}/src/user -I ${LIBDIR}/api ${LIBDIR}/src/core/XUD_Main.xc ${LIBDIR}/src/core/XUD_PowerSig.xc ${LIBDIR}/src/core/XUD_Ports.xc test.xc strings.xc stubs.xc
xcc -target=XCORE-200-EXPLORER -Os -D XUD_SERIES_SUPPORT=4 -DT_WTRSTFS=0 -D SUSPEND_VBUS_POLL_TIMER_TICKS=0 -D write_sswitch_reg=test_write_sswitch_reg -I read_sswitch_reg=test_read_sswitch_reg -I ${LIBDIR}/src/user -I ${LIBDIR}/api ${LIBDIR}/src/core/XUD_Main.xc ${LIBDIR}/src/core/XUD_PowerSig.xc ${LIBDIR}/src/core/XUD_Ports.xc test.xc strings.xc stubs.xc
xobjdump -d a.xe > objdump

0 comments on commit c8c7576

Please sign in to comment.