starting to add support for IAR workbench
This commit is contained in:
@@ -289,7 +289,7 @@ void cdch_close(uint8_t dev_addr)
|
||||
|
||||
ASSERT(err1 == TUSB_ERROR_NONE &&
|
||||
err2 == TUSB_ERROR_NONE &&
|
||||
err3 == TUSB_ERROR_NONE, (void) 0 );
|
||||
err3 == TUSB_ERROR_NONE, VOID_RETURN );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t leng
|
||||
tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
|
||||
|
||||
//------------- CDC Application Callback -------------//
|
||||
void tusbh_cdc_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) ATTR_WEAK;
|
||||
ATTR_WEAK void tusbh_cdc_mounted_cb(uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_cdc_unmounted_isr(uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes);
|
||||
|
||||
|
||||
#if TUSB_CFG_HOST_CDC_RNDIS
|
||||
@@ -83,9 +83,9 @@ bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RES
|
||||
tusb_error_t tusbh_cdc_rndis_get_mac_addr(uint8_t dev_addr, uint8_t mac_address[6]);
|
||||
|
||||
//------------- RNDIS Application Callback (overshadow CDC callbacks) -------------//
|
||||
void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_rndis_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_rndis_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) ATTR_WEAK;
|
||||
ATTR_WEAK void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_cdc_rndis_unmounted_isr(uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_cdc_rndis_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#define RNDIS_MSG_PAYLOAD_MAX (1024*4)
|
||||
|
||||
static uint8_t msg_notification[TUSB_CFG_HOST_DEVICE_MAX][8] TUSB_CFG_ATTR_USBRAM;
|
||||
static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX] TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4);
|
||||
ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
STATIC_ rndish_data_t rndish_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
@@ -154,7 +154,6 @@ static rndis_msg_query_t const msg_query_permanent_addr =
|
||||
.oid = OID_802_3_PERMANENT_ADDRESS,
|
||||
.buffer_length = 6,
|
||||
.buffer_offset = 20,
|
||||
.oid_buffer = {0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static rndis_msg_set_t const msg_set_packet_filter =
|
||||
@@ -165,7 +164,6 @@ static rndis_msg_set_t const msg_set_packet_filter =
|
||||
.oid = OID_GEN_CURRENT_PACKET_FILTER,
|
||||
.buffer_length = 4,
|
||||
.buffer_offset = 20,
|
||||
.oid_buffer = { (uint8_t) (NDIS_PACKET_TYPE_DIRECTED | NDIS_PACKET_TYPE_MULTICAST | NDIS_PACKET_TYPE_BROADCAST), 0, 0, 0}
|
||||
};
|
||||
|
||||
tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
|
||||
@@ -191,7 +189,8 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
|
||||
rndish_data[dev_addr-1].max_xfer_size = p_init_cmpt->max_xfer_size;
|
||||
|
||||
//------------- Message Query 802.3 Permanent Address -------------//
|
||||
memcpy(msg_payload, &msg_query_permanent_addr, sizeof(rndis_msg_query_t) + 6); // 6 bytes for MAC address
|
||||
memcpy(msg_payload, &msg_query_permanent_addr, sizeof(rndis_msg_query_t));
|
||||
memclr_(msg_payload + sizeof(rndis_msg_query_t), 6); // 6 bytes for MAC address
|
||||
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
send_message_get_response_subtask( dev_addr, p_cdc,
|
||||
@@ -206,7 +205,9 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
|
||||
memcpy(rndish_data[dev_addr-1].mac_address, msg_payload + 8 + p_query_cmpt->buffer_offset, 6);
|
||||
|
||||
//------------- Set OID_GEN_CURRENT_PACKET_FILTER to (DIRECTED | MULTICAST | BROADCAST) -------------//
|
||||
memcpy(msg_payload, &msg_set_packet_filter, sizeof(rndis_msg_set_t) + 4); // 4 bytes for filter flags
|
||||
memcpy(msg_payload, &msg_set_packet_filter, sizeof(rndis_msg_set_t));
|
||||
memclr_(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags
|
||||
((rndis_msg_set_t*) msg_payload)->oid_buffer[0] = (NDIS_PACKET_TYPE_DIRECTED | NDIS_PACKET_TYPE_MULTICAST | NDIS_PACKET_TYPE_BROADCAST);
|
||||
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
send_message_get_response_subtask( dev_addr, p_cdc,
|
||||
|
||||
@@ -87,7 +87,7 @@ static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t
|
||||
if ( pipehandle_is_valid(pipe_hdl) )
|
||||
{
|
||||
memclr_(p_hid, sizeof(hidh_interface_info_t));
|
||||
ASSERT_INT( TUSB_ERROR_NONE, hcd_pipe_close(pipe_hdl), (void) 0 );
|
||||
ASSERT_INT( TUSB_ERROR_NONE, hcd_pipe_close(pipe_hdl), VOID_RETURN );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WAR
|
||||
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void * report) /*ATTR_WARN_UNUSED_RESULT*/;
|
||||
tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||
//------------- Application Callback -------------//
|
||||
void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
|
||||
void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_hid_keyboard_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
ATTR_WEAK void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event);
|
||||
ATTR_WEAK void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_hid_keyboard_unmounted_isr(uint8_t dev_addr);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MOUSE Application API
|
||||
@@ -74,9 +74,9 @@ bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_U
|
||||
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void* report) /*ATTR_WARN_UNUSED_RESULT*/;
|
||||
tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||
//------------- Application Callback -------------//
|
||||
void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
|
||||
void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_hid_mouse_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
ATTR_WEAK void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event);
|
||||
ATTR_WEAK void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_hid_mouse_unmounted_isr(uint8_t dev_addr);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// GENERIC Application API
|
||||
@@ -87,7 +87,7 @@ tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, void* report, bool
|
||||
tusb_interface_status_t tusbh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_interface_status_t tusbh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||
//------------- Application Callback -------------//
|
||||
void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
|
||||
ATTR_WEAK void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH-CLASS DRIVER API
|
||||
|
||||
@@ -60,6 +60,8 @@ extern "C"
|
||||
#include "tusb_option.h"
|
||||
#include "hal/hal.h" // TODO find a way to break hal dependency
|
||||
|
||||
#define VOID_RETURN
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Compile-time Assert
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -95,7 +97,7 @@ extern "C"
|
||||
|
||||
#ifndef _TEST_ASSERT_
|
||||
#define ASSERT_ERROR_HANDLER(x, para) \
|
||||
return (x)
|
||||
return x
|
||||
#else
|
||||
#define ASSERT_ERROR_HANDLER(x, para) Throw(x)
|
||||
#endif
|
||||
|
||||
@@ -52,11 +52,123 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ALIGN_OF(x) __ALIGNOF__(x)
|
||||
#define ALIGN_OF(x) __ALIGNOF__(x)
|
||||
|
||||
#define ATTR_PACKED_STRUCT(x) __packed x
|
||||
#define ATTR_PREPACKED __packed
|
||||
#define ATTR_PACKED
|
||||
|
||||
#define ATTR_ALIGNED(Bytes) ATTR_ALIGNED_##Bytes
|
||||
#define ATTR_ALIGNED_4096 _Pragma("data_alignment=4096")
|
||||
#define ATTR_ALIGNED_2048 _Pragma("data_alignment=2048")
|
||||
#define ATTR_ALIGNED_256 _Pragma("data_alignment=256")
|
||||
#define ATTR_ALIGNED_128 _Pragma("data_alignment=128")
|
||||
#define ATTR_ALIGNED_64 _Pragma("data_alignment=64")
|
||||
#define ATTR_ALIGNED_48 _Pragma("data_alignment=48")
|
||||
#define ATTR_ALIGNED_32 _Pragma("data_alignment=32")
|
||||
#define ATTR_ALIGNED_4 _Pragma("data_alignment=4")
|
||||
|
||||
|
||||
|
||||
#ifndef ATTR_ALWAYS_INLINE
|
||||
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
|
||||
#define ATTR_ALWAYS_INLINE error
|
||||
#endif
|
||||
|
||||
#define ATTR_PURE // TODO IAR pure function attribute
|
||||
#define ATTR_CONST // TODO IAR const function attribute
|
||||
#define ATTR_WEAK __weak
|
||||
|
||||
#define ATTR_WARN_UNUSED_RESULT
|
||||
#define ATTR_USED
|
||||
#define ATTR_UNUSED
|
||||
|
||||
#if 0
|
||||
|
||||
/** Indicates to the compiler that the function can not ever return, so that any stack restoring or
|
||||
* return code may be omitted by the compiler in the resulting binary.
|
||||
*/
|
||||
#define ATTR_NO_RETURN
|
||||
|
||||
/** Indicates that the specified parameters of the function are pointers which should never be \c NULL.
|
||||
* When applied as a 1-based comma separated list the compiler will emit a warning if the specified
|
||||
* parameters are known at compiler time to be \c NULL at the point of calling the function.
|
||||
*/
|
||||
#define ATTR_NON_NULL_PTR_ARG(...)
|
||||
|
||||
/** Removes any preamble or postamble from the function. When used, the function will not have any
|
||||
* register or stack saving code. This should be used with caution, and when used the programmer
|
||||
* is responsible for maintaining stack and register integrity.
|
||||
*/
|
||||
#define ATTR_NAKED __attribute__ ((naked))
|
||||
|
||||
/** Prevents the compiler from considering a specified function for in-lining. When applied, the given
|
||||
* function will not be in-lined under any circumstances.
|
||||
*/
|
||||
#define ATTR_NO_INLINE __attribute__ ((noinline))
|
||||
|
||||
/** Forces the compiler to inline the specified function. When applied, the given function will be
|
||||
* in-lined under all circumstances.
|
||||
*/
|
||||
#define PRAGMA_ALWAYS_INLINE _Pragma("inline=forced")
|
||||
#define ATTR_ALWAYS_INLINE
|
||||
|
||||
/** Indicates that the specified function is pure, in that it has no side-effects other than global
|
||||
* or parameter variable access.
|
||||
*/
|
||||
#define ATTR_PURE __attribute__ ((pure))
|
||||
|
||||
/** Indicates that the specified function is constant, in that it has no side effects other than
|
||||
* parameter access.
|
||||
*/
|
||||
#define ATTR_CONST
|
||||
|
||||
/** Marks a given function as deprecated, which produces a warning if the function is called. */
|
||||
#define ATTR_DEPRECATED// __attribute__ ((deprecated))
|
||||
|
||||
/** Marks a function as a weak reference, which can be overridden by other functions with an
|
||||
* identical name (in which case the weak reference is discarded at link time).
|
||||
*/
|
||||
#define _PPTOSTR_(x) #x
|
||||
#define PRAGMA_WEAK(name, vector) _Pragma(_PPTOSTR_(weak name=vector))
|
||||
#define ATTR_WEAK
|
||||
|
||||
/** Marks a function as an alias for another function.
|
||||
*
|
||||
* \param[in] Func Name of the function which the given function name should alias.
|
||||
*/
|
||||
#define ATTR_ALIAS(Func)
|
||||
|
||||
/** Forces the compiler to not automatically zero the given global variable on startup, so that the
|
||||
* current RAM contents is retained. Under most conditions this value will be random due to the
|
||||
* behaviour of volatile memory once power is removed, but may be used in some specific circumstances,
|
||||
* like the passing of values back after a system watchdog reset.
|
||||
*/
|
||||
#define ATTR_NO_INIT __attribute__ ((section (".noinit")))
|
||||
/** Indicates the minimum alignment in bytes for a variable or struct element.
|
||||
*
|
||||
* \param[in] Bytes Minimum number of bytes the item should be aligned to.
|
||||
*/
|
||||
#define PRAGMA_ALIGN_4096 _Pragma("data_alignment=4096")
|
||||
#define PRAGMA_ALIGN_2048 _Pragma("data_alignment=2048")
|
||||
#define PRAGMA_ALIGN_256 _Pragma("data_alignment=256")
|
||||
#define PRAGMA_ALIGN_128 _Pragma("data_alignment=128")
|
||||
#define PRAGMA_ALIGN_64 _Pragma("data_alignment=64")
|
||||
#define PRAGMA_ALIGN_48 _Pragma("data_alignment=48")
|
||||
#define PRAGMA_ALIGN_32 _Pragma("data_alignment=32")
|
||||
#define PRAGMA_ALIGN_4 _Pragma("data_alignment=4")
|
||||
#define ATTR_ALIGNED(Bytes)
|
||||
|
||||
//#define ATTR_DEPRECATED __attribute__ ((deprecated))
|
||||
|
||||
#define ATTR_ERROR(Message)// __attribute__ (( error(Message) ))
|
||||
|
||||
#define ATTR_WARNING(Message) // __attribute__ (( warning(Message) ))
|
||||
|
||||
#define ATTR_IAR_PACKED __packed
|
||||
#define ATTR_PACKED
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -62,13 +62,19 @@ STATIC_ ehci_data_t ehci_data TUSB_CFG_ATTR_USBRAM;
|
||||
#if EHCI_PERIODIC_LIST
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST)
|
||||
STATIC_ ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) TUSB_CFG_ATTR_USBRAM;
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation
|
||||
ATTR_ALIGNED(4096) STATIC_ ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with dataalignment pragma
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)
|
||||
STATIC_ ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) TUSB_CFG_ATTR_USBRAM;
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation
|
||||
|
||||
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with dataalignment pragma
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -587,7 +593,7 @@ static void period_list_xfer_complete_isr(uint8_t hostid, uint8_t interval_ms)
|
||||
case EHCI_QUEUE_ELEMENT_SITD:
|
||||
case EHCI_QUEUE_ELEMENT_FSTN:
|
||||
default:
|
||||
ASSERT (false, (void) 0); // TODO support hs/fs ISO
|
||||
ASSERT (false, VOID_RETURN); // TODO support hs/fs ISO
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -667,7 +673,7 @@ static void xfer_error_isr(uint8_t hostid)
|
||||
case EHCI_QUEUE_ELEMENT_SITD:
|
||||
case EHCI_QUEUE_ELEMENT_FSTN:
|
||||
default:
|
||||
ASSERT (false, (void) 0); // TODO support hs/fs ISO
|
||||
ASSERT (false, VOID_RETURN); // TODO support hs/fs ISO
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -905,7 +911,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
|
||||
{
|
||||
if (TUSB_SPEED_HIGH == p_qhd->endpoint_speed)
|
||||
{
|
||||
ASSERT_INT_WITHIN(1, 16, interval, (void) 0);
|
||||
ASSERT_INT_WITHIN(1, 16, interval, VOID_RETURN);
|
||||
if ( interval < 4) // sub milisecond interval
|
||||
{
|
||||
p_qhd->interval_ms = 0;
|
||||
@@ -918,7 +924,7 @@ static void qhd_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_si
|
||||
}
|
||||
}else
|
||||
{
|
||||
ASSERT( 0 != interval, (void) 0);
|
||||
ASSERT( 0 != interval, VOID_RETURN);
|
||||
// Full/Low: 4.12.2.1 (EHCI) case 1 schedule start split at 1 us & complete split at 2,3,4 uframes
|
||||
p_qhd->interrupt_smask = 0x01;
|
||||
p_qhd->non_hs_interrupt_cmask = BIN8(11100);
|
||||
|
||||
@@ -261,7 +261,7 @@ void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t even
|
||||
usbh_class_drivers[class_index].isr(pipe_hdl, event, xferred_bytes);
|
||||
}else
|
||||
{
|
||||
ASSERT(false, (void) 0); // something wrong, no one claims the isr's source
|
||||
ASSERT(false, VOID_RETURN); // something wrong, no one claims the isr's source
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ uint32_t tusbh_device_get_mounted_class_flag(uint8_t dev_addr);
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CALLBACK
|
||||
//--------------------------------------------------------------------+
|
||||
uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK ATTR_WARN_UNUSED_RESULT;
|
||||
void tusbh_device_mount_succeed_cb (uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK; // TODO refractor remove desc_device
|
||||
ATTR_WEAK uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WARN_UNUSED_RESULT;
|
||||
ATTR_WEAK void tusbh_device_mount_succeed_cb (uint8_t dev_addr);
|
||||
ATTR_WEAK void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device); // TODO refractor remove desc_device
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// CLASS-USBH & INTERNAL API
|
||||
|
||||
Reference in New Issue
Block a user