STM32 mass update to current naming convention in ChibiOS
This commit is contained in:
parent
b86af2c09f
commit
9d74dd2661
|
@ -1,21 +1,21 @@
|
|||
include ${CHIBIOS}/os/hal/hal.mk
|
||||
|
||||
HALSRC += ${CHIBIOS_CONTRIB}/os/hal/src/hal_community.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/nand.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/onewire.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/eicu.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/crc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/rng.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/usbh_debug.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/usbh_desciter.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/usbh_hub.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/usbh_msd.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/usbh_ftdi.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/usbh_uvc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/ee24xx.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/ee25xx.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/eeprom.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/timcap.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_nand.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_onewire.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_eicu.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_crc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_rng.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_usbh.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/hal_usbh_debug.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/hal_usbh_desciter.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/hal_usbh_hub.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/hal_usbh_msd.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/hal_usbh_ftdi.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/usbh/hal_usbh_uvc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_ee24xx.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_ee25xx.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_eeprom.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_timcap.c \
|
||||
|
||||
HALINC += ${CHIBIOS_CONTRIB}/os/hal/include
|
||||
|
|
|
@ -30,16 +30,16 @@
|
|||
/* Shared headers.*/
|
||||
|
||||
/* Normal drivers.*/
|
||||
#include "nand.h"
|
||||
#include "eicu.h"
|
||||
#include "rng.h"
|
||||
#include "usbh.h"
|
||||
#include "timcap.h"
|
||||
#include "hal_nand.h"
|
||||
#include "hal_eicu.h"
|
||||
#include "hal_rng.h"
|
||||
#include "hal_usbh.h"
|
||||
#include "hal_timcap.h"
|
||||
|
||||
/* Complex drivers.*/
|
||||
#include "onewire.h"
|
||||
#include "crc.h"
|
||||
#include "eeprom.h"
|
||||
#include "hal_onewire.h"
|
||||
#include "hal_crc.h"
|
||||
#include "hal_eeprom.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef enum {
|
|||
CRC_COMPLETE /* Asynchronous operation complete. */
|
||||
} crcstate_t;
|
||||
|
||||
#include "crc_lld.h"
|
||||
#include "hal_crc_lld.h"
|
||||
#include "crcsw.h" /* Include software LL driver */
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ typedef struct EICUDriver EICUDriver;
|
|||
typedef void (*eicucallback_t)(EICUDriver *eicup, eicuchannel_t channel,
|
||||
uint32_t width, uint32_t period);
|
||||
|
||||
#include "eicu_lld.h"
|
||||
#include "hal_eicu_lld.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
|
@ -89,7 +89,7 @@ typedef enum {
|
|||
*/
|
||||
typedef struct NANDDriver NANDDriver;
|
||||
|
||||
#include "nand_lld.h"
|
||||
#include "hal_nand_lld.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
|
@ -1,439 +1,439 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef USBH_H_
|
||||
#define USBH_H_
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#ifndef HAL_USE_USBH
|
||||
#define HAL_USE_USBH FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_FTDI
|
||||
#define HAL_USBH_USE_FTDI FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_HUB
|
||||
#define HAL_USBH_USE_HUB FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_MSD
|
||||
#define HAL_USBH_USE_MSD FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_UVC
|
||||
#define HAL_USBH_USE_UVC FALSE
|
||||
#endif
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
#include "osal.h"
|
||||
#include "usbh/list.h"
|
||||
#include "usbh/defs.h"
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* - Integrate VBUS power switching functionality to the API.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if !HAL_USBH_USE_HUB
|
||||
#define USBH_MAX_ADDRESSES 1
|
||||
#else
|
||||
#define USBH_MAX_ADDRESSES (HAL_USBHHUB_MAX_PORTS + 1)
|
||||
#endif
|
||||
|
||||
enum usbh_status {
|
||||
USBH_STATUS_STOPPED = 0,
|
||||
USBH_STATUS_STARTED,
|
||||
USBH_STATUS_SUSPENDED,
|
||||
};
|
||||
|
||||
enum usbh_devstatus {
|
||||
USBH_DEVSTATUS_DISCONNECTED = 0,
|
||||
USBH_DEVSTATUS_ATTACHED,
|
||||
USBH_DEVSTATUS_CONNECTED,
|
||||
USBH_DEVSTATUS_DEFAULT,
|
||||
USBH_DEVSTATUS_ADDRESS,
|
||||
USBH_DEVSTATUS_CONFIGURED,
|
||||
};
|
||||
|
||||
enum usbh_devspeed {
|
||||
USBH_DEVSPEED_LOW = 0,
|
||||
USBH_DEVSPEED_FULL,
|
||||
USBH_DEVSPEED_HIGH,
|
||||
};
|
||||
|
||||
enum usbh_epdir {
|
||||
USBH_EPDIR_IN = 0x80,
|
||||
USBH_EPDIR_OUT = 0
|
||||
};
|
||||
|
||||
enum usbh_eptype {
|
||||
USBH_EPTYPE_CTRL = 0,
|
||||
USBH_EPTYPE_ISO = 1,
|
||||
USBH_EPTYPE_BULK = 2,
|
||||
USBH_EPTYPE_INT = 3,
|
||||
};
|
||||
|
||||
enum usbh_epstatus {
|
||||
USBH_EPSTATUS_UNINITIALIZED = 0,
|
||||
USBH_EPSTATUS_CLOSED,
|
||||
USBH_EPSTATUS_OPEN,
|
||||
USBH_EPSTATUS_HALTED,
|
||||
};
|
||||
|
||||
enum usbh_urbstatus {
|
||||
USBH_URBSTATUS_UNINITIALIZED = 0,
|
||||
USBH_URBSTATUS_INITIALIZED,
|
||||
USBH_URBSTATUS_PENDING,
|
||||
// USBH_URBSTATUS_QUEUED,
|
||||
USBH_URBSTATUS_ERROR,
|
||||
USBH_URBSTATUS_TIMEOUT,
|
||||
USBH_URBSTATUS_CANCELLED,
|
||||
USBH_URBSTATUS_STALL,
|
||||
USBH_URBSTATUS_DISCONNECTED,
|
||||
// USBH_URBSTATUS_EPCLOSED,
|
||||
USBH_URBSTATUS_OK,
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* forward declarations */
|
||||
typedef struct USBHDriver USBHDriver;
|
||||
typedef struct usbh_port usbh_port_t;
|
||||
typedef struct usbh_device usbh_device_t;
|
||||
typedef struct usbh_ep usbh_ep_t;
|
||||
typedef struct usbh_urb usbh_urb_t;
|
||||
typedef struct usbh_baseclassdriver usbh_baseclassdriver_t;
|
||||
typedef struct usbh_classdriverinfo usbh_classdriverinfo_t;
|
||||
#if HAL_USBH_USE_HUB
|
||||
typedef struct USBHHubDriver USBHHubDriver;
|
||||
#endif
|
||||
|
||||
/* typedefs */
|
||||
typedef enum usbh_status usbh_status_t;
|
||||
typedef enum usbh_devspeed usbh_devspeed_t;
|
||||
typedef enum usbh_devstatus usbh_devstatus_t;
|
||||
typedef enum usbh_epdir usbh_epdir_t;
|
||||
typedef enum usbh_eptype usbh_eptype_t;
|
||||
typedef enum usbh_epstatus usbh_epstatus_t;
|
||||
typedef enum usbh_urbstatus usbh_urbstatus_t;
|
||||
typedef uint16_t usbh_portstatus_t;
|
||||
typedef uint16_t usbh_portcstatus_t;
|
||||
typedef void (*usbh_completion_cb)(usbh_urb_t *);
|
||||
|
||||
/* include the low level driver; the required definitions are above */
|
||||
#include "usbh_lld.h"
|
||||
|
||||
#define USBH_DEFINE_BUFFER(type, name) USBH_LLD_DEFINE_BUFFER(type, name)
|
||||
|
||||
struct usbh_urb {
|
||||
usbh_ep_t *ep;
|
||||
|
||||
void *userData;
|
||||
usbh_completion_cb callback;
|
||||
|
||||
const void *setup_buff;
|
||||
void *buff;
|
||||
uint32_t requestedLength;
|
||||
uint32_t actualLength;
|
||||
|
||||
usbh_urbstatus_t status;
|
||||
|
||||
thread_reference_t waitingThread;
|
||||
thread_reference_t abortingThread;
|
||||
|
||||
/* Low level part */
|
||||
_usbh_urb_ll_data
|
||||
};
|
||||
|
||||
struct usbh_ep {
|
||||
usbh_device_t *device;
|
||||
usbh_ep_t *next;
|
||||
|
||||
usbh_epstatus_t status;
|
||||
uint8_t address;
|
||||
bool in;
|
||||
usbh_eptype_t type;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
|
||||
/* debug */
|
||||
const char *name;
|
||||
|
||||
/* Low-level part */
|
||||
_usbh_ep_ll_data
|
||||
};
|
||||
|
||||
struct usbh_device {
|
||||
USBHDriver *host; /* shortcut to host */
|
||||
|
||||
usbh_ep_t ctrl;
|
||||
usbh_ep_t *endpoints;
|
||||
|
||||
usbh_baseclassdriver_t *drivers;
|
||||
|
||||
uint16_t langID0;
|
||||
|
||||
usbh_devstatus_t status;
|
||||
usbh_devspeed_t speed;
|
||||
|
||||
USBH_DEFINE_BUFFER(usbh_device_descriptor_t, devDesc);
|
||||
unsigned char align_bytes[2];
|
||||
USBH_DEFINE_BUFFER(usbh_config_descriptor_t, basicConfigDesc);
|
||||
|
||||
uint8_t *fullConfigurationDescriptor;
|
||||
uint8_t keepFullCfgDesc;
|
||||
|
||||
uint8_t address;
|
||||
uint8_t bConfiguration;
|
||||
|
||||
/* Low level part */
|
||||
_usbh_device_ll_data
|
||||
};
|
||||
|
||||
|
||||
struct usbh_port {
|
||||
#if HAL_USBH_USE_HUB
|
||||
USBHHubDriver *hub;
|
||||
#endif
|
||||
|
||||
usbh_portstatus_t status;
|
||||
usbh_portcstatus_t c_status;
|
||||
|
||||
usbh_port_t *next;
|
||||
|
||||
uint8_t number;
|
||||
|
||||
usbh_device_t device;
|
||||
|
||||
/* Low level part */
|
||||
_usbh_port_ll_data
|
||||
};
|
||||
|
||||
struct USBHDriver {
|
||||
usbh_status_t status;
|
||||
uint8_t address_bitmap[(USBH_MAX_ADDRESSES + 7) / 8];
|
||||
|
||||
usbh_port_t rootport;
|
||||
|
||||
#if HAL_USBH_USE_HUB
|
||||
struct list_head hubs;
|
||||
#endif
|
||||
|
||||
/* Low level part */
|
||||
_usbhdriver_ll_data
|
||||
|
||||
#if USBH_DEBUG_ENABLE
|
||||
/* debug */
|
||||
uint8_t dbg_buff[USBH_DEBUG_BUFFER];
|
||||
THD_WORKING_AREA(waDebug, 512);
|
||||
input_queue_t iq;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if STM32_USBH_USE_OTG1
|
||||
extern USBHDriver USBHD1;
|
||||
#endif
|
||||
|
||||
#if STM32_USBH_USE_OTG2
|
||||
extern USBHDriver USBHD2;
|
||||
#endif
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Main driver API. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Main functions */
|
||||
void usbhObjectInit(USBHDriver *usbh);
|
||||
void usbhInit(void);
|
||||
void usbhStart(USBHDriver *usbh);
|
||||
void usbhStop(USBHDriver *usbh);
|
||||
void usbhSuspend(USBHDriver *usbh);
|
||||
void usbhResume(USBHDriver *usbh);
|
||||
|
||||
/* Device-related */
|
||||
#if USBH_DEBUG_ENABLE && USBH_DEBUG_ENABLE_INFO
|
||||
void usbhDevicePrintInfo(usbh_device_t *dev);
|
||||
void usbhDevicePrintConfiguration(const uint8_t *descriptor, uint16_t rem);
|
||||
#else
|
||||
# define usbhDevicePrintInfo(dev) do {} while(0)
|
||||
# define usbhDevicePrintConfiguration(descriptor, rem) do {} while(0)
|
||||
#endif
|
||||
bool usbhDeviceReadString(usbh_device_t *dev, char *dest, uint8_t size,
|
||||
uint8_t index, uint16_t langID);
|
||||
static inline usbh_port_t *usbhDeviceGetPort(usbh_device_t *dev) {
|
||||
return container_of(dev, usbh_port_t, device);
|
||||
}
|
||||
|
||||
/* Synchronous API */
|
||||
usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep,
|
||||
void *data,
|
||||
uint32_t len,
|
||||
uint32_t *actual_len,
|
||||
systime_t timeout);
|
||||
usbh_urbstatus_t usbhControlRequest(usbh_device_t *dev,
|
||||
uint8_t bmRequestType,
|
||||
uint8_t bRequest,
|
||||
uint16_t wValue,
|
||||
uint16_t wIndex,
|
||||
uint16_t wLength,
|
||||
uint8_t *buff);
|
||||
usbh_urbstatus_t usbhControlRequestExtended(usbh_device_t *dev,
|
||||
const usbh_control_request_t *req,
|
||||
uint8_t *buff,
|
||||
uint32_t *actual_len,
|
||||
systime_t timeout);
|
||||
|
||||
/* Standard request helpers */
|
||||
bool usbhStdReqGetDeviceDescriptor(usbh_device_t *dev,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf);
|
||||
bool usbhStdReqGetConfigurationDescriptor(usbh_device_t *dev,
|
||||
uint8_t index,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf);
|
||||
bool usbhStdReqGetStringDescriptor(usbh_device_t *dev,
|
||||
uint8_t index,
|
||||
uint16_t langID,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf);
|
||||
bool usbhStdReqSetInterface(usbh_device_t *dev,
|
||||
uint8_t bInterfaceNumber,
|
||||
uint8_t bAlternateSetting);
|
||||
bool usbhStdReqGetInterface(usbh_device_t *dev,
|
||||
uint8_t bInterfaceNumber,
|
||||
uint8_t *bAlternateSetting);
|
||||
|
||||
/* Endpoint/pipe management */
|
||||
void usbhEPObjectInit(usbh_ep_t *ep, usbh_device_t *dev, const usbh_endpoint_descriptor_t *desc);
|
||||
static inline void usbhEPOpen(usbh_ep_t *ep) {
|
||||
osalDbgCheck(ep != 0);
|
||||
osalSysLock();
|
||||
osalDbgAssert(ep->status == USBH_EPSTATUS_CLOSED, "invalid state");
|
||||
usbh_lld_ep_open(ep);
|
||||
ep->next = ep->device->endpoints;
|
||||
ep->device->endpoints = ep;
|
||||
osalSysUnlock();
|
||||
}
|
||||
static inline void usbhEPCloseS(usbh_ep_t *ep) {
|
||||
osalDbgCheck(ep != 0);
|
||||
osalDbgCheckClassS();
|
||||
osalDbgAssert(ep->status != USBH_EPSTATUS_UNINITIALIZED, "invalid state");
|
||||
if (ep->status == USBH_EPSTATUS_CLOSED) {
|
||||
osalOsRescheduleS();
|
||||
return;
|
||||
}
|
||||
usbh_lld_ep_close(ep);
|
||||
}
|
||||
static inline void usbhEPClose(usbh_ep_t *ep) {
|
||||
osalSysLock();
|
||||
usbhEPCloseS(ep);
|
||||
osalSysUnlock();
|
||||
}
|
||||
static inline void usbhEPResetI(usbh_ep_t *ep) {
|
||||
osalDbgCheckClassI();
|
||||
osalDbgCheck(ep != NULL);
|
||||
usbh_lld_epreset(ep);
|
||||
}
|
||||
static inline bool usbhEPIsPeriodic(usbh_ep_t *ep) {
|
||||
osalDbgCheck(ep != NULL);
|
||||
return (ep->type & 1) != 0;
|
||||
}
|
||||
static inline bool usbhURBIsBusy(usbh_urb_t *urb) {
|
||||
osalDbgCheck(urb != NULL);
|
||||
return (urb->status == USBH_URBSTATUS_PENDING);
|
||||
}
|
||||
static inline void usbhEPSetName(usbh_ep_t *ep, const char *name) {
|
||||
ep->name = name;
|
||||
}
|
||||
|
||||
/* URB management */
|
||||
void usbhURBObjectInit(usbh_urb_t *urb, usbh_ep_t *ep, usbh_completion_cb callback,
|
||||
void *user, void *buff, uint32_t len);
|
||||
void usbhURBObjectResetI(usbh_urb_t *urb);
|
||||
void usbhURBSubmitI(usbh_urb_t *urb);
|
||||
bool usbhURBCancelI(usbh_urb_t *urb);
|
||||
msg_t usbhURBSubmitAndWaitS(usbh_urb_t *urb, systime_t timeout);
|
||||
void usbhURBCancelAndWaitS(usbh_urb_t *urb);
|
||||
msg_t usbhURBWaitTimeoutS(usbh_urb_t *urb, systime_t timeout);
|
||||
|
||||
/* Main loop */
|
||||
void usbhMainLoop(USBHDriver *usbh);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Class driver definitions and API. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct usbh_classdriver_vmt usbh_classdriver_vmt_t;
|
||||
struct usbh_classdriver_vmt {
|
||||
usbh_baseclassdriver_t *(*load)(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem);
|
||||
void (*unload)(usbh_baseclassdriver_t *drv);
|
||||
};
|
||||
|
||||
struct usbh_classdriverinfo {
|
||||
int16_t class;
|
||||
int16_t subclass;
|
||||
int16_t protocol;
|
||||
const char *name;
|
||||
const usbh_classdriver_vmt_t *vmt;
|
||||
};
|
||||
|
||||
#define _usbh_base_classdriver_data \
|
||||
const usbh_classdriverinfo_t *info; \
|
||||
usbh_device_t *dev; \
|
||||
usbh_baseclassdriver_t *next;
|
||||
|
||||
struct usbh_baseclassdriver {
|
||||
_usbh_base_classdriver_data
|
||||
};
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Helper functions. */
|
||||
/*===========================================================================*/
|
||||
#include <usbh/desciter.h> /* descriptor iterators */
|
||||
#include <usbh/debug.h> /* debug */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* USBH_H_ */
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef USBH_H_
|
||||
#define USBH_H_
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#ifndef HAL_USE_USBH
|
||||
#define HAL_USE_USBH FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_FTDI
|
||||
#define HAL_USBH_USE_FTDI FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_HUB
|
||||
#define HAL_USBH_USE_HUB FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_MSD
|
||||
#define HAL_USBH_USE_MSD FALSE
|
||||
#endif
|
||||
|
||||
#ifndef HAL_USBH_USE_UVC
|
||||
#define HAL_USBH_USE_UVC FALSE
|
||||
#endif
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
#include "osal.h"
|
||||
#include "usbh/list.h"
|
||||
#include "usbh/defs.h"
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* - Integrate VBUS power switching functionality to the API.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if !HAL_USBH_USE_HUB
|
||||
#define USBH_MAX_ADDRESSES 1
|
||||
#else
|
||||
#define USBH_MAX_ADDRESSES (HAL_USBHHUB_MAX_PORTS + 1)
|
||||
#endif
|
||||
|
||||
enum usbh_status {
|
||||
USBH_STATUS_STOPPED = 0,
|
||||
USBH_STATUS_STARTED,
|
||||
USBH_STATUS_SUSPENDED,
|
||||
};
|
||||
|
||||
enum usbh_devstatus {
|
||||
USBH_DEVSTATUS_DISCONNECTED = 0,
|
||||
USBH_DEVSTATUS_ATTACHED,
|
||||
USBH_DEVSTATUS_CONNECTED,
|
||||
USBH_DEVSTATUS_DEFAULT,
|
||||
USBH_DEVSTATUS_ADDRESS,
|
||||
USBH_DEVSTATUS_CONFIGURED,
|
||||
};
|
||||
|
||||
enum usbh_devspeed {
|
||||
USBH_DEVSPEED_LOW = 0,
|
||||
USBH_DEVSPEED_FULL,
|
||||
USBH_DEVSPEED_HIGH,
|
||||
};
|
||||
|
||||
enum usbh_epdir {
|
||||
USBH_EPDIR_IN = 0x80,
|
||||
USBH_EPDIR_OUT = 0
|
||||
};
|
||||
|
||||
enum usbh_eptype {
|
||||
USBH_EPTYPE_CTRL = 0,
|
||||
USBH_EPTYPE_ISO = 1,
|
||||
USBH_EPTYPE_BULK = 2,
|
||||
USBH_EPTYPE_INT = 3,
|
||||
};
|
||||
|
||||
enum usbh_epstatus {
|
||||
USBH_EPSTATUS_UNINITIALIZED = 0,
|
||||
USBH_EPSTATUS_CLOSED,
|
||||
USBH_EPSTATUS_OPEN,
|
||||
USBH_EPSTATUS_HALTED,
|
||||
};
|
||||
|
||||
enum usbh_urbstatus {
|
||||
USBH_URBSTATUS_UNINITIALIZED = 0,
|
||||
USBH_URBSTATUS_INITIALIZED,
|
||||
USBH_URBSTATUS_PENDING,
|
||||
// USBH_URBSTATUS_QUEUED,
|
||||
USBH_URBSTATUS_ERROR,
|
||||
USBH_URBSTATUS_TIMEOUT,
|
||||
USBH_URBSTATUS_CANCELLED,
|
||||
USBH_URBSTATUS_STALL,
|
||||
USBH_URBSTATUS_DISCONNECTED,
|
||||
// USBH_URBSTATUS_EPCLOSED,
|
||||
USBH_URBSTATUS_OK,
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* forward declarations */
|
||||
typedef struct USBHDriver USBHDriver;
|
||||
typedef struct usbh_port usbh_port_t;
|
||||
typedef struct usbh_device usbh_device_t;
|
||||
typedef struct usbh_ep usbh_ep_t;
|
||||
typedef struct usbh_urb usbh_urb_t;
|
||||
typedef struct usbh_baseclassdriver usbh_baseclassdriver_t;
|
||||
typedef struct usbh_classdriverinfo usbh_classdriverinfo_t;
|
||||
#if HAL_USBH_USE_HUB
|
||||
typedef struct USBHHubDriver USBHHubDriver;
|
||||
#endif
|
||||
|
||||
/* typedefs */
|
||||
typedef enum usbh_status usbh_status_t;
|
||||
typedef enum usbh_devspeed usbh_devspeed_t;
|
||||
typedef enum usbh_devstatus usbh_devstatus_t;
|
||||
typedef enum usbh_epdir usbh_epdir_t;
|
||||
typedef enum usbh_eptype usbh_eptype_t;
|
||||
typedef enum usbh_epstatus usbh_epstatus_t;
|
||||
typedef enum usbh_urbstatus usbh_urbstatus_t;
|
||||
typedef uint16_t usbh_portstatus_t;
|
||||
typedef uint16_t usbh_portcstatus_t;
|
||||
typedef void (*usbh_completion_cb)(usbh_urb_t *);
|
||||
|
||||
/* include the low level driver; the required definitions are above */
|
||||
#include "hal_usbh_lld.h"
|
||||
|
||||
#define USBH_DEFINE_BUFFER(type, name) USBH_LLD_DEFINE_BUFFER(type, name)
|
||||
|
||||
struct usbh_urb {
|
||||
usbh_ep_t *ep;
|
||||
|
||||
void *userData;
|
||||
usbh_completion_cb callback;
|
||||
|
||||
const void *setup_buff;
|
||||
void *buff;
|
||||
uint32_t requestedLength;
|
||||
uint32_t actualLength;
|
||||
|
||||
usbh_urbstatus_t status;
|
||||
|
||||
thread_reference_t waitingThread;
|
||||
thread_reference_t abortingThread;
|
||||
|
||||
/* Low level part */
|
||||
_usbh_urb_ll_data
|
||||
};
|
||||
|
||||
struct usbh_ep {
|
||||
usbh_device_t *device;
|
||||
usbh_ep_t *next;
|
||||
|
||||
usbh_epstatus_t status;
|
||||
uint8_t address;
|
||||
bool in;
|
||||
usbh_eptype_t type;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
|
||||
/* debug */
|
||||
const char *name;
|
||||
|
||||
/* Low-level part */
|
||||
_usbh_ep_ll_data
|
||||
};
|
||||
|
||||
struct usbh_device {
|
||||
USBHDriver *host; /* shortcut to host */
|
||||
|
||||
usbh_ep_t ctrl;
|
||||
usbh_ep_t *endpoints;
|
||||
|
||||
usbh_baseclassdriver_t *drivers;
|
||||
|
||||
uint16_t langID0;
|
||||
|
||||
usbh_devstatus_t status;
|
||||
usbh_devspeed_t speed;
|
||||
|
||||
USBH_DEFINE_BUFFER(usbh_device_descriptor_t, devDesc);
|
||||
unsigned char align_bytes[2];
|
||||
USBH_DEFINE_BUFFER(usbh_config_descriptor_t, basicConfigDesc);
|
||||
|
||||
uint8_t *fullConfigurationDescriptor;
|
||||
uint8_t keepFullCfgDesc;
|
||||
|
||||
uint8_t address;
|
||||
uint8_t bConfiguration;
|
||||
|
||||
/* Low level part */
|
||||
_usbh_device_ll_data
|
||||
};
|
||||
|
||||
|
||||
struct usbh_port {
|
||||
#if HAL_USBH_USE_HUB
|
||||
USBHHubDriver *hub;
|
||||
#endif
|
||||
|
||||
usbh_portstatus_t status;
|
||||
usbh_portcstatus_t c_status;
|
||||
|
||||
usbh_port_t *next;
|
||||
|
||||
uint8_t number;
|
||||
|
||||
usbh_device_t device;
|
||||
|
||||
/* Low level part */
|
||||
_usbh_port_ll_data
|
||||
};
|
||||
|
||||
struct USBHDriver {
|
||||
usbh_status_t status;
|
||||
uint8_t address_bitmap[(USBH_MAX_ADDRESSES + 7) / 8];
|
||||
|
||||
usbh_port_t rootport;
|
||||
|
||||
#if HAL_USBH_USE_HUB
|
||||
struct list_head hubs;
|
||||
#endif
|
||||
|
||||
/* Low level part */
|
||||
_usbhdriver_ll_data
|
||||
|
||||
#if USBH_DEBUG_ENABLE
|
||||
/* debug */
|
||||
uint8_t dbg_buff[USBH_DEBUG_BUFFER];
|
||||
THD_WORKING_AREA(waDebug, 512);
|
||||
input_queue_t iq;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if STM32_USBH_USE_OTG1
|
||||
extern USBHDriver USBHD1;
|
||||
#endif
|
||||
|
||||
#if STM32_USBH_USE_OTG2
|
||||
extern USBHDriver USBHD2;
|
||||
#endif
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Main driver API. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Main functions */
|
||||
void usbhObjectInit(USBHDriver *usbh);
|
||||
void usbhInit(void);
|
||||
void usbhStart(USBHDriver *usbh);
|
||||
void usbhStop(USBHDriver *usbh);
|
||||
void usbhSuspend(USBHDriver *usbh);
|
||||
void usbhResume(USBHDriver *usbh);
|
||||
|
||||
/* Device-related */
|
||||
#if USBH_DEBUG_ENABLE && USBH_DEBUG_ENABLE_INFO
|
||||
void usbhDevicePrintInfo(usbh_device_t *dev);
|
||||
void usbhDevicePrintConfiguration(const uint8_t *descriptor, uint16_t rem);
|
||||
#else
|
||||
# define usbhDevicePrintInfo(dev) do {} while(0)
|
||||
# define usbhDevicePrintConfiguration(descriptor, rem) do {} while(0)
|
||||
#endif
|
||||
bool usbhDeviceReadString(usbh_device_t *dev, char *dest, uint8_t size,
|
||||
uint8_t index, uint16_t langID);
|
||||
static inline usbh_port_t *usbhDeviceGetPort(usbh_device_t *dev) {
|
||||
return container_of(dev, usbh_port_t, device);
|
||||
}
|
||||
|
||||
/* Synchronous API */
|
||||
usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep,
|
||||
void *data,
|
||||
uint32_t len,
|
||||
uint32_t *actual_len,
|
||||
systime_t timeout);
|
||||
usbh_urbstatus_t usbhControlRequest(usbh_device_t *dev,
|
||||
uint8_t bmRequestType,
|
||||
uint8_t bRequest,
|
||||
uint16_t wValue,
|
||||
uint16_t wIndex,
|
||||
uint16_t wLength,
|
||||
uint8_t *buff);
|
||||
usbh_urbstatus_t usbhControlRequestExtended(usbh_device_t *dev,
|
||||
const usbh_control_request_t *req,
|
||||
uint8_t *buff,
|
||||
uint32_t *actual_len,
|
||||
systime_t timeout);
|
||||
|
||||
/* Standard request helpers */
|
||||
bool usbhStdReqGetDeviceDescriptor(usbh_device_t *dev,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf);
|
||||
bool usbhStdReqGetConfigurationDescriptor(usbh_device_t *dev,
|
||||
uint8_t index,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf);
|
||||
bool usbhStdReqGetStringDescriptor(usbh_device_t *dev,
|
||||
uint8_t index,
|
||||
uint16_t langID,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf);
|
||||
bool usbhStdReqSetInterface(usbh_device_t *dev,
|
||||
uint8_t bInterfaceNumber,
|
||||
uint8_t bAlternateSetting);
|
||||
bool usbhStdReqGetInterface(usbh_device_t *dev,
|
||||
uint8_t bInterfaceNumber,
|
||||
uint8_t *bAlternateSetting);
|
||||
|
||||
/* Endpoint/pipe management */
|
||||
void usbhEPObjectInit(usbh_ep_t *ep, usbh_device_t *dev, const usbh_endpoint_descriptor_t *desc);
|
||||
static inline void usbhEPOpen(usbh_ep_t *ep) {
|
||||
osalDbgCheck(ep != 0);
|
||||
osalSysLock();
|
||||
osalDbgAssert(ep->status == USBH_EPSTATUS_CLOSED, "invalid state");
|
||||
usbh_lld_ep_open(ep);
|
||||
ep->next = ep->device->endpoints;
|
||||
ep->device->endpoints = ep;
|
||||
osalSysUnlock();
|
||||
}
|
||||
static inline void usbhEPCloseS(usbh_ep_t *ep) {
|
||||
osalDbgCheck(ep != 0);
|
||||
osalDbgCheckClassS();
|
||||
osalDbgAssert(ep->status != USBH_EPSTATUS_UNINITIALIZED, "invalid state");
|
||||
if (ep->status == USBH_EPSTATUS_CLOSED) {
|
||||
osalOsRescheduleS();
|
||||
return;
|
||||
}
|
||||
usbh_lld_ep_close(ep);
|
||||
}
|
||||
static inline void usbhEPClose(usbh_ep_t *ep) {
|
||||
osalSysLock();
|
||||
usbhEPCloseS(ep);
|
||||
osalSysUnlock();
|
||||
}
|
||||
static inline void usbhEPResetI(usbh_ep_t *ep) {
|
||||
osalDbgCheckClassI();
|
||||
osalDbgCheck(ep != NULL);
|
||||
usbh_lld_epreset(ep);
|
||||
}
|
||||
static inline bool usbhEPIsPeriodic(usbh_ep_t *ep) {
|
||||
osalDbgCheck(ep != NULL);
|
||||
return (ep->type & 1) != 0;
|
||||
}
|
||||
static inline bool usbhURBIsBusy(usbh_urb_t *urb) {
|
||||
osalDbgCheck(urb != NULL);
|
||||
return (urb->status == USBH_URBSTATUS_PENDING);
|
||||
}
|
||||
static inline void usbhEPSetName(usbh_ep_t *ep, const char *name) {
|
||||
ep->name = name;
|
||||
}
|
||||
|
||||
/* URB management */
|
||||
void usbhURBObjectInit(usbh_urb_t *urb, usbh_ep_t *ep, usbh_completion_cb callback,
|
||||
void *user, void *buff, uint32_t len);
|
||||
void usbhURBObjectResetI(usbh_urb_t *urb);
|
||||
void usbhURBSubmitI(usbh_urb_t *urb);
|
||||
bool usbhURBCancelI(usbh_urb_t *urb);
|
||||
msg_t usbhURBSubmitAndWaitS(usbh_urb_t *urb, systime_t timeout);
|
||||
void usbhURBCancelAndWaitS(usbh_urb_t *urb);
|
||||
msg_t usbhURBWaitTimeoutS(usbh_urb_t *urb, systime_t timeout);
|
||||
|
||||
/* Main loop */
|
||||
void usbhMainLoop(USBHDriver *usbh);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Class driver definitions and API. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct usbh_classdriver_vmt usbh_classdriver_vmt_t;
|
||||
struct usbh_classdriver_vmt {
|
||||
usbh_baseclassdriver_t *(*load)(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem);
|
||||
void (*unload)(usbh_baseclassdriver_t *drv);
|
||||
};
|
||||
|
||||
struct usbh_classdriverinfo {
|
||||
int16_t class;
|
||||
int16_t subclass;
|
||||
int16_t protocol;
|
||||
const char *name;
|
||||
const usbh_classdriver_vmt_t *vmt;
|
||||
};
|
||||
|
||||
#define _usbh_base_classdriver_data \
|
||||
const usbh_classdriverinfo_t *info; \
|
||||
usbh_device_t *dev; \
|
||||
usbh_baseclassdriver_t *next;
|
||||
|
||||
struct usbh_baseclassdriver {
|
||||
_usbh_base_classdriver_data
|
||||
};
|
||||
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Helper functions. */
|
||||
/*===========================================================================*/
|
||||
#include <usbh/desciter.h> /* descriptor iterators */
|
||||
#include <usbh/debug.h> /* debug */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* USBH_H_ */
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef USBH_DEBUG_H_
|
||||
#define USBH_DEBUG_H_
|
||||
|
||||
#include "usbh.h"
|
||||
#include "hal_usbh.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef USBH_FTDI_H_
|
||||
#define USBH_FTDI_H_
|
||||
|
||||
#include "usbh.h"
|
||||
#include "hal_usbh.h"
|
||||
|
||||
#if HAL_USE_USBH && HAL_USBH_USE_FTDI
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef USBH_HUB_H_
|
||||
#define USBH_HUB_H_
|
||||
|
||||
#include "usbh.h"
|
||||
#include "hal_usbh.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
#if HAL_USBH_USE_HUB
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef USBH_MSD_H_
|
||||
#define USBH_MSD_H_
|
||||
|
||||
#include "usbh.h"
|
||||
#include "hal_usbh.h"
|
||||
|
||||
#if HAL_USE_USBH && HAL_USBH_USE_MSD
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef USBH_INTERNAL_H_
|
||||
#define USBH_INTERNAL_H_
|
||||
|
||||
#include "usbh.h"
|
||||
#include "hal_usbh.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,7 @@
|
|||
* @{
|
||||
*/
|
||||
#include "hal.h"
|
||||
#include "fsmc.h"
|
||||
#include "hal_fsmc.h"
|
||||
|
||||
#if (HAL_USE_FSMC == TRUE) || defined(__DOXYGEN__)
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#if (STM32_USE_FSMC_SDRAM == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
#include "fsmc_sdram.h"
|
||||
#include "hal_fsmc_sdram.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local definitions. */
|
|
@ -31,7 +31,7 @@
|
|||
#if (defined(STM32F427xx) || defined(STM32F437xx) || \
|
||||
defined(STM32F429xx) || defined(STM32F439xx))
|
||||
|
||||
#include "fsmc.h"
|
||||
#include "hal_fsmc.h"
|
||||
|
||||
#if (STM32_USE_FSMC_SDRAM == TRUE) || defined(__DOXYGEN__)
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
* @{
|
||||
*/
|
||||
#include "hal.h"
|
||||
#include "fsmc_sram.h"
|
||||
#include "hal_fsmc_sram.h"
|
||||
|
||||
#if (STM32_USE_FSMC_SRAM == TRUE) || defined(__DOXYGEN__)
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
#ifndef _FSMC_SRAM_H_
|
||||
#define _FSMC_SRAM_H_
|
||||
|
||||
#include "fsmc.h"
|
||||
#include "hal_fsmc.h"
|
||||
|
||||
#if (STM32_USE_FSMC_SRAM == TRUE) || defined(__DOXYGEN__)
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
#ifndef _NAND_LLD_H_
|
||||
#define _NAND_LLD_H_
|
||||
|
||||
#include "fsmc.h"
|
||||
#include "hal_fsmc.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
#if (HAL_USE_NAND == TRUE) || defined(__DOXYGEN__)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -37,7 +37,7 @@
|
|||
#if HAL_USE_TIMCAP || defined(__DOXYGEN__)
|
||||
|
||||
#include "stm32_tim.h"
|
||||
#include "timcap.h"
|
||||
#include "hal_timcap.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local definitions. */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,153 +1,153 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef USBH_LLD_H_
|
||||
#define USBH_LLD_H_
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
#include "osal.h"
|
||||
#include "stm32_otg.h"
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* - Implement ISO/INT OUT and test
|
||||
* - Consider DMA mode for OTG_HS, consider external PHY for HS.
|
||||
* - Implement a data pump thread, so we don't have to copy data from the ISR
|
||||
* This might be a bad idea for small endpoint packet sizes (the context switch
|
||||
* could be longer than the copy)
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
USBH_LLD_CTRLPHASE_SETUP,
|
||||
USBH_LLD_CTRLPHASE_DATA,
|
||||
USBH_LLD_CTRLPHASE_STATUS
|
||||
} usbh_lld_ctrlphase_t;
|
||||
|
||||
typedef enum {
|
||||
USBH_LLD_HALTREASON_NONE,
|
||||
USBH_LLD_HALTREASON_XFRC,
|
||||
USBH_LLD_HALTREASON_NAK,
|
||||
USBH_LLD_HALTREASON_STALL,
|
||||
USBH_LLD_HALTREASON_ERROR,
|
||||
USBH_LLD_HALTREASON_ABORT
|
||||
} usbh_lld_halt_reason_t;
|
||||
|
||||
|
||||
typedef struct stm32_hc_management {
|
||||
struct list_head node;
|
||||
|
||||
stm32_otg_host_chn_t *hc;
|
||||
volatile uint32_t *fifo;
|
||||
usbh_ep_t *ep;
|
||||
uint16_t haintmsk;
|
||||
usbh_lld_halt_reason_t halt_reason;
|
||||
} stm32_hc_management_t;
|
||||
|
||||
|
||||
#define _usbhdriver_ll_data \
|
||||
stm32_otg_t *otg; \
|
||||
/* channels */ \
|
||||
uint8_t channels_number; \
|
||||
stm32_hc_management_t channels[STM32_OTG2_CHANNELS_NUMBER]; \
|
||||
struct list_head ch_free[2]; \
|
||||
/* Enpoints being processed */ \
|
||||
struct list_head ep_active_lists[4]; \
|
||||
/* Pending endpoints */ \
|
||||
struct list_head ep_pending_lists[4];
|
||||
|
||||
|
||||
#define _usbh_ep_ll_data \
|
||||
struct list_head *active_list; /* shortcut to ep list */ \
|
||||
struct list_head *pending_list; /* shortcut to ep list */ \
|
||||
struct list_head urb_list; /* list of URBs queued in this EP */ \
|
||||
struct list_head node; /* this EP */ \
|
||||
uint32_t hcintmsk; \
|
||||
uint32_t hcchar; \
|
||||
uint32_t dt_mask; /* data-toggle mask */ \
|
||||
/* current transfer */ \
|
||||
struct { \
|
||||
stm32_hc_management_t *hcm; /* assigned channel */ \
|
||||
uint32_t len; /* this transfer's total length */ \
|
||||
uint8_t *buf; /* this transfer's buffer */ \
|
||||
uint32_t partial; /* this transfer's partial length */\
|
||||
uint16_t packets; /* packets allocated */ \
|
||||
union { \
|
||||
uint32_t frame_counter; /* frame counter (for INT) */ \
|
||||
usbh_lld_ctrlphase_t ctrl_phase; /* control phase (for CTRL) */ \
|
||||
} u; \
|
||||
uint8_t error_count; /* error count */ \
|
||||
} xfer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define _usbh_port_ll_data \
|
||||
uint16_t lld_c_status; \
|
||||
uint16_t lld_status;
|
||||
|
||||
#define _usbh_device_ll_data
|
||||
|
||||
#define _usbh_hub_ll_data
|
||||
|
||||
#define _usbh_urb_ll_data \
|
||||
struct list_head node; \
|
||||
bool queued;
|
||||
|
||||
|
||||
#define usbh_lld_urb_object_init(urb) \
|
||||
do { \
|
||||
osalDbgAssert(((uint32_t)urb->buff & 3) == 0, \
|
||||
"use USBH_DEFINE_BUFFER() to declare the IO buffers"); \
|
||||
urb->queued = FALSE; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define usbh_lld_urb_object_reset(urb) \
|
||||
do { \
|
||||
osalDbgAssert(urb->queued == FALSE, "wrong state"); \
|
||||
osalDbgAssert(((uint32_t)urb->buff & 3) == 0, \
|
||||
"use USBH_DEFINE_BUFFER() to declare the IO buffers"); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
void usbh_lld_init(void);
|
||||
void usbh_lld_start(USBHDriver *usbh);
|
||||
void usbh_lld_ep_object_init(usbh_ep_t *ep);
|
||||
void usbh_lld_ep_open(usbh_ep_t *ep);
|
||||
void usbh_lld_ep_close(usbh_ep_t *ep);
|
||||
void usbh_lld_urb_submit(usbh_urb_t *urb);
|
||||
bool usbh_lld_urb_abort(usbh_urb_t *urb, usbh_urbstatus_t status);
|
||||
usbh_urbstatus_t usbh_lld_root_hub_request(USBHDriver *usbh, uint8_t bmRequestType, uint8_t bRequest,
|
||||
uint16_t wvalue, uint16_t windex, uint16_t wlength, uint8_t *buf);
|
||||
uint8_t usbh_lld_roothub_get_statuschange_bitmap(USBHDriver *usbh);
|
||||
|
||||
#define usbh_lld_epreset(ep) do {(ep)->dt_mask = HCTSIZ_DPID_DATA0;} while (0);
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#define USBH_LLD_DEFINE_BUFFER(type, name) type name
|
||||
#else
|
||||
#define USBH_LLD_DEFINE_BUFFER(type, name) type name __attribute__((aligned(4)))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* USBH_LLD_H_ */
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef USBH_LLD_H_
|
||||
#define USBH_LLD_H_
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
#include "osal.h"
|
||||
#include "stm32_otg.h"
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* - Implement ISO/INT OUT and test
|
||||
* - Consider DMA mode for OTG_HS, consider external PHY for HS.
|
||||
* - Implement a data pump thread, so we don't have to copy data from the ISR
|
||||
* This might be a bad idea for small endpoint packet sizes (the context switch
|
||||
* could be longer than the copy)
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
USBH_LLD_CTRLPHASE_SETUP,
|
||||
USBH_LLD_CTRLPHASE_DATA,
|
||||
USBH_LLD_CTRLPHASE_STATUS
|
||||
} usbh_lld_ctrlphase_t;
|
||||
|
||||
typedef enum {
|
||||
USBH_LLD_HALTREASON_NONE,
|
||||
USBH_LLD_HALTREASON_XFRC,
|
||||
USBH_LLD_HALTREASON_NAK,
|
||||
USBH_LLD_HALTREASON_STALL,
|
||||
USBH_LLD_HALTREASON_ERROR,
|
||||
USBH_LLD_HALTREASON_ABORT
|
||||
} usbh_lld_halt_reason_t;
|
||||
|
||||
|
||||
typedef struct stm32_hc_management {
|
||||
struct list_head node;
|
||||
|
||||
stm32_otg_host_chn_t *hc;
|
||||
volatile uint32_t *fifo;
|
||||
usbh_ep_t *ep;
|
||||
uint16_t haintmsk;
|
||||
usbh_lld_halt_reason_t halt_reason;
|
||||
} stm32_hc_management_t;
|
||||
|
||||
|
||||
#define _usbhdriver_ll_data \
|
||||
stm32_otg_t *otg; \
|
||||
/* channels */ \
|
||||
uint8_t channels_number; \
|
||||
stm32_hc_management_t channels[STM32_OTG2_CHANNELS_NUMBER]; \
|
||||
struct list_head ch_free[2]; \
|
||||
/* Enpoints being processed */ \
|
||||
struct list_head ep_active_lists[4]; \
|
||||
/* Pending endpoints */ \
|
||||
struct list_head ep_pending_lists[4];
|
||||
|
||||
|
||||
#define _usbh_ep_ll_data \
|
||||
struct list_head *active_list; /* shortcut to ep list */ \
|
||||
struct list_head *pending_list; /* shortcut to ep list */ \
|
||||
struct list_head urb_list; /* list of URBs queued in this EP */ \
|
||||
struct list_head node; /* this EP */ \
|
||||
uint32_t hcintmsk; \
|
||||
uint32_t hcchar; \
|
||||
uint32_t dt_mask; /* data-toggle mask */ \
|
||||
/* current transfer */ \
|
||||
struct { \
|
||||
stm32_hc_management_t *hcm; /* assigned channel */ \
|
||||
uint32_t len; /* this transfer's total length */ \
|
||||
uint8_t *buf; /* this transfer's buffer */ \
|
||||
uint32_t partial; /* this transfer's partial length */\
|
||||
uint16_t packets; /* packets allocated */ \
|
||||
union { \
|
||||
uint32_t frame_counter; /* frame counter (for INT) */ \
|
||||
usbh_lld_ctrlphase_t ctrl_phase; /* control phase (for CTRL) */ \
|
||||
} u; \
|
||||
uint8_t error_count; /* error count */ \
|
||||
} xfer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define _usbh_port_ll_data \
|
||||
uint16_t lld_c_status; \
|
||||
uint16_t lld_status;
|
||||
|
||||
#define _usbh_device_ll_data
|
||||
|
||||
#define _usbh_hub_ll_data
|
||||
|
||||
#define _usbh_urb_ll_data \
|
||||
struct list_head node; \
|
||||
bool queued;
|
||||
|
||||
|
||||
#define usbh_lld_urb_object_init(urb) \
|
||||
do { \
|
||||
osalDbgAssert(((uint32_t)urb->buff & 3) == 0, \
|
||||
"use USBH_DEFINE_BUFFER() to declare the IO buffers"); \
|
||||
urb->queued = FALSE; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define usbh_lld_urb_object_reset(urb) \
|
||||
do { \
|
||||
osalDbgAssert(urb->queued == FALSE, "wrong state"); \
|
||||
osalDbgAssert(((uint32_t)urb->buff & 3) == 0, \
|
||||
"use USBH_DEFINE_BUFFER() to declare the IO buffers"); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
void usbh_lld_init(void);
|
||||
void usbh_lld_start(USBHDriver *usbh);
|
||||
void usbh_lld_ep_object_init(usbh_ep_t *ep);
|
||||
void usbh_lld_ep_open(usbh_ep_t *ep);
|
||||
void usbh_lld_ep_close(usbh_ep_t *ep);
|
||||
void usbh_lld_urb_submit(usbh_urb_t *urb);
|
||||
bool usbh_lld_urb_abort(usbh_urb_t *urb, usbh_urbstatus_t status);
|
||||
usbh_urbstatus_t usbh_lld_root_hub_request(USBHDriver *usbh, uint8_t bmRequestType, uint8_t bRequest,
|
||||
uint16_t wvalue, uint16_t windex, uint16_t wlength, uint8_t *buf);
|
||||
uint8_t usbh_lld_roothub_get_statuschange_bitmap(USBHDriver *usbh);
|
||||
|
||||
#define usbh_lld_epreset(ep) do {(ep)->dt_mask = HCTSIZ_DPID_DATA0;} while (0);
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#define USBH_LLD_DEFINE_BUFFER(type, name) type name
|
||||
#else
|
||||
#define USBH_LLD_DEFINE_BUFFER(type, name) type name __attribute__((aligned(4)))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* USBH_LLD_H_ */
|
|
@ -1,7 +1,7 @@
|
|||
include ${CHIBIOS}/os/hal/ports/STM32/STM32F0xx/platform.mk
|
||||
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1/crc_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/timcap_lld.c \
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1/hal_crc_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/hal_timcap_lld.c \
|
||||
|
||||
PLATFORMINC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1 \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1 \
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
include ${CHIBIOS}/os/hal/ports/STM32/STM32F3xx/platform.mk
|
||||
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1/crc_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/eicu_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/timcap_lld.c
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1/hal_crc_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/hal_eicu_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/hal_timcap_lld.c
|
||||
|
||||
PLATFORMINC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1 \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1 \
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
include ${CHIBIOS}/os/hal/ports/STM32/STM32F4xx/platform.mk
|
||||
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/DMA2Dv1/stm32_dma2d.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1/fsmc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1/nand_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1/fsmc_sram.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/LTDCv1/stm32_ltdc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/eicu_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/timcap_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/USBHv1/usbh_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/fsmc_sdram.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1/crc_lld.c
|
||||
PLATFORMSRC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/DMA2Dv1/hal_stm32_dma2d.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1/hal_nand_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/LTDCv1/hal_stm32_ltdc.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/hal_eicu_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/TIMv1/hal_timcap_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/src/hal_fsmc_sdram.c \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/CRCv1/hal_crc_lld.c
|
||||
|
||||
PLATFORMINC += ${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/DMA2Dv1 \
|
||||
${CHIBIOS_CONTRIB}/os/hal/ports/STM32/LLD/FSMCv1 \
|
||||
|
|
|
@ -42,7 +42,7 @@ Note:
|
|||
being written to the next page as might be expected.
|
||||
*********************************************************************/
|
||||
|
||||
#include "ee24xx.h"
|
||||
#include "hal_ee24xx.h"
|
||||
#include <string.h>
|
||||
|
||||
#if (defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE24XX) || defined(__DOXYGEN__)
|
|
@ -42,7 +42,7 @@ Note:
|
|||
being written to the next page as might be expected.
|
||||
*********************************************************************/
|
||||
|
||||
#include "ee25xx.h"
|
||||
#include "hal_ee25xx.h"
|
||||
#include <string.h>
|
||||
|
||||
#if (defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE25XX) || defined(__DOXYGEN__)
|
|
@ -26,7 +26,7 @@
|
|||
The work is provided "as is" without warranty of any kind, neither express nor implied.
|
||||
*/
|
||||
|
||||
#include "eeprom.h"
|
||||
#include "hal_eeprom.h"
|
||||
#include <string.h>
|
||||
|
||||
#if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM
|
|
@ -26,7 +26,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include "timcap.h"
|
||||
#include "hal_timcap.h"
|
||||
|
||||
#if HAL_USE_TIMCAP || defined(__DOXYGEN__)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,165 +1,165 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
#include "usbh/defs.h"
|
||||
#include "usbh/desciter.h"
|
||||
|
||||
void cfg_iter_init(generic_iterator_t *icfg, const uint8_t *buff, uint16_t rem) {
|
||||
icfg->valid = 0;
|
||||
|
||||
if ((buff[0] < 2) || (rem < 2) || (rem < buff[0])
|
||||
|| (buff[0] < USBH_DT_CONFIG_SIZE)
|
||||
|| (buff[1] != USBH_DT_CONFIG))
|
||||
return;
|
||||
|
||||
if (rem > ((usbh_config_descriptor_t *)buff)->wTotalLength) {
|
||||
rem = ((usbh_config_descriptor_t *)buff)->wTotalLength;
|
||||
}
|
||||
|
||||
icfg->valid = 1;
|
||||
icfg->rem = rem;
|
||||
icfg->curr = buff;
|
||||
}
|
||||
|
||||
void if_iter_next(if_iterator_t *iif) {
|
||||
const uint8_t *curr = iif->curr;
|
||||
uint16_t rem = iif->rem;
|
||||
|
||||
iif->valid = 0;
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
rem -= curr[0];
|
||||
curr += curr[0];
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
if (curr[1] == USBH_DT_INTERFACE_ASSOCIATION) {
|
||||
if (curr[0] < USBH_DT_INTERFACE_ASSOCIATION_SIZE)
|
||||
return;
|
||||
|
||||
iif->iad = (usbh_ia_descriptor_t *)curr;
|
||||
|
||||
} else if (curr[1] == USBH_DT_INTERFACE) {
|
||||
if (curr[0] < USBH_DT_INTERFACE_SIZE)
|
||||
return;
|
||||
|
||||
if (iif->iad) {
|
||||
if ((curr[2] < iif->iad->bFirstInterface)
|
||||
|| (curr[2] >= (iif->iad->bFirstInterface + iif->iad->bInterfaceCount)))
|
||||
iif->iad = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iif->valid = 1;
|
||||
iif->rem = rem;
|
||||
iif->curr = curr;
|
||||
}
|
||||
|
||||
void if_iter_init(if_iterator_t *iif, const generic_iterator_t *icfg) {
|
||||
iif->iad = 0;
|
||||
iif->curr = icfg->curr;
|
||||
iif->rem = icfg->rem;
|
||||
if_iter_next(iif);
|
||||
}
|
||||
|
||||
void ep_iter_next(generic_iterator_t *iep) {
|
||||
const uint8_t *curr = iep->curr;
|
||||
uint16_t rem = iep->rem;
|
||||
|
||||
iep->valid = 0;
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
rem -= curr[0];
|
||||
curr += curr[0];
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
if ((curr[1] == USBH_DT_INTERFACE_ASSOCIATION)
|
||||
|| (curr[1] == USBH_DT_INTERFACE)
|
||||
|| (curr[1] == USBH_DT_CONFIG)) {
|
||||
return;
|
||||
} else if (curr[1] == USBH_DT_ENDPOINT) {
|
||||
if (curr[0] < USBH_DT_ENDPOINT_SIZE)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iep->valid = 1;
|
||||
iep->rem = rem;
|
||||
iep->curr = curr;
|
||||
}
|
||||
|
||||
void ep_iter_init(generic_iterator_t *iep, const if_iterator_t *iif) {
|
||||
iep->curr = iif->curr;
|
||||
iep->rem = iif->rem;
|
||||
ep_iter_next(iep);
|
||||
}
|
||||
|
||||
void cs_iter_next(generic_iterator_t *ics) {
|
||||
const uint8_t *curr = ics->curr;
|
||||
uint16_t rem = ics->rem;
|
||||
|
||||
ics->valid = 0;
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
//for (;;) {
|
||||
rem -= curr[0];
|
||||
curr += curr[0];
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
if ((curr[1] == USBH_DT_INTERFACE_ASSOCIATION)
|
||||
|| (curr[1] == USBH_DT_INTERFACE)
|
||||
|| (curr[1] == USBH_DT_CONFIG)
|
||||
|| (curr[1] == USBH_DT_ENDPOINT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// break;
|
||||
//}
|
||||
|
||||
ics->valid = 1;
|
||||
ics->rem = rem;
|
||||
ics->curr = curr;
|
||||
}
|
||||
|
||||
void cs_iter_init(generic_iterator_t *ics, const generic_iterator_t *iter) {
|
||||
ics->curr = iter->curr;
|
||||
ics->rem = iter->rem;
|
||||
cs_iter_next(ics);
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#if HAL_USE_USBH
|
||||
|
||||
#include "usbh/defs.h"
|
||||
#include "usbh/desciter.h"
|
||||
|
||||
void cfg_iter_init(generic_iterator_t *icfg, const uint8_t *buff, uint16_t rem) {
|
||||
icfg->valid = 0;
|
||||
|
||||
if ((buff[0] < 2) || (rem < 2) || (rem < buff[0])
|
||||
|| (buff[0] < USBH_DT_CONFIG_SIZE)
|
||||
|| (buff[1] != USBH_DT_CONFIG))
|
||||
return;
|
||||
|
||||
if (rem > ((usbh_config_descriptor_t *)buff)->wTotalLength) {
|
||||
rem = ((usbh_config_descriptor_t *)buff)->wTotalLength;
|
||||
}
|
||||
|
||||
icfg->valid = 1;
|
||||
icfg->rem = rem;
|
||||
icfg->curr = buff;
|
||||
}
|
||||
|
||||
void if_iter_next(if_iterator_t *iif) {
|
||||
const uint8_t *curr = iif->curr;
|
||||
uint16_t rem = iif->rem;
|
||||
|
||||
iif->valid = 0;
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
rem -= curr[0];
|
||||
curr += curr[0];
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
if (curr[1] == USBH_DT_INTERFACE_ASSOCIATION) {
|
||||
if (curr[0] < USBH_DT_INTERFACE_ASSOCIATION_SIZE)
|
||||
return;
|
||||
|
||||
iif->iad = (usbh_ia_descriptor_t *)curr;
|
||||
|
||||
} else if (curr[1] == USBH_DT_INTERFACE) {
|
||||
if (curr[0] < USBH_DT_INTERFACE_SIZE)
|
||||
return;
|
||||
|
||||
if (iif->iad) {
|
||||
if ((curr[2] < iif->iad->bFirstInterface)
|
||||
|| (curr[2] >= (iif->iad->bFirstInterface + iif->iad->bInterfaceCount)))
|
||||
iif->iad = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iif->valid = 1;
|
||||
iif->rem = rem;
|
||||
iif->curr = curr;
|
||||
}
|
||||
|
||||
void if_iter_init(if_iterator_t *iif, const generic_iterator_t *icfg) {
|
||||
iif->iad = 0;
|
||||
iif->curr = icfg->curr;
|
||||
iif->rem = icfg->rem;
|
||||
if_iter_next(iif);
|
||||
}
|
||||
|
||||
void ep_iter_next(generic_iterator_t *iep) {
|
||||
const uint8_t *curr = iep->curr;
|
||||
uint16_t rem = iep->rem;
|
||||
|
||||
iep->valid = 0;
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
rem -= curr[0];
|
||||
curr += curr[0];
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
if ((curr[1] == USBH_DT_INTERFACE_ASSOCIATION)
|
||||
|| (curr[1] == USBH_DT_INTERFACE)
|
||||
|| (curr[1] == USBH_DT_CONFIG)) {
|
||||
return;
|
||||
} else if (curr[1] == USBH_DT_ENDPOINT) {
|
||||
if (curr[0] < USBH_DT_ENDPOINT_SIZE)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iep->valid = 1;
|
||||
iep->rem = rem;
|
||||
iep->curr = curr;
|
||||
}
|
||||
|
||||
void ep_iter_init(generic_iterator_t *iep, const if_iterator_t *iif) {
|
||||
iep->curr = iif->curr;
|
||||
iep->rem = iif->rem;
|
||||
ep_iter_next(iep);
|
||||
}
|
||||
|
||||
void cs_iter_next(generic_iterator_t *ics) {
|
||||
const uint8_t *curr = ics->curr;
|
||||
uint16_t rem = ics->rem;
|
||||
|
||||
ics->valid = 0;
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
//for (;;) {
|
||||
rem -= curr[0];
|
||||
curr += curr[0];
|
||||
|
||||
if ((curr[0] < 2) || (rem < 2) || (rem < curr[0]))
|
||||
return;
|
||||
|
||||
if ((curr[1] == USBH_DT_INTERFACE_ASSOCIATION)
|
||||
|| (curr[1] == USBH_DT_INTERFACE)
|
||||
|| (curr[1] == USBH_DT_CONFIG)
|
||||
|| (curr[1] == USBH_DT_ENDPOINT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// break;
|
||||
//}
|
||||
|
||||
ics->valid = 1;
|
||||
ics->rem = rem;
|
||||
ics->curr = curr;
|
||||
}
|
||||
|
||||
void cs_iter_init(generic_iterator_t *ics, const generic_iterator_t *iter) {
|
||||
ics->curr = iter->curr;
|
||||
ics->rem = iter->rem;
|
||||
cs_iter_next(ics);
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,302 +1,302 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
#include "usbh.h"
|
||||
#include "usbh/internal.h"
|
||||
|
||||
#if HAL_USBH_USE_HUB
|
||||
|
||||
#if !HAL_USE_USBH
|
||||
#error "USBHHUB needs HAL_USE_USBH"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "usbh/dev/hub.h"
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_TRACE
|
||||
#define udbgf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define udbg(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define udbgf(f, ...) do {} while(0)
|
||||
#define udbg(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_INFO
|
||||
#define uinfof(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uinfo(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uinfof(f, ...) do {} while(0)
|
||||
#define uinfo(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_WARNINGS
|
||||
#define uwarnf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uwarn(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uwarnf(f, ...) do {} while(0)
|
||||
#define uwarn(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_ERRORS
|
||||
#define uerrf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uerr(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uerrf(f, ...) do {} while(0)
|
||||
#define uerr(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
USBHHubDriver USBHHUBD[HAL_USBHHUB_MAX_INSTANCES];
|
||||
usbh_port_t USBHPorts[HAL_USBHHUB_MAX_PORTS];
|
||||
|
||||
static usbh_baseclassdriver_t *hub_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem);
|
||||
static void hub_unload(usbh_baseclassdriver_t *drv);
|
||||
static const usbh_classdriver_vmt_t usbhhubClassDriverVMT = {
|
||||
hub_load,
|
||||
hub_unload
|
||||
};
|
||||
const usbh_classdriverinfo_t usbhhubClassDriverInfo = {
|
||||
0x09, 0x00, -1, "HUB", &usbhhubClassDriverVMT
|
||||
};
|
||||
|
||||
|
||||
void _usbhub_port_object_init(usbh_port_t *port, USBHDriver *usbh,
|
||||
USBHHubDriver *hub, uint8_t number) {
|
||||
memset(port, 0, sizeof(*port));
|
||||
port->number = number;
|
||||
port->device.host = usbh;
|
||||
port->hub = hub;
|
||||
}
|
||||
|
||||
usbh_urbstatus_t usbhhubControlRequest(USBHDriver *host, USBHHubDriver *hub,
|
||||
uint8_t bmRequestType,
|
||||
uint8_t bRequest,
|
||||
uint16_t wValue,
|
||||
uint16_t wIndex,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf) {
|
||||
if (hub == NULL)
|
||||
return usbh_lld_root_hub_request(host, bmRequestType, bRequest, wValue, wIndex, wLength, buf);
|
||||
|
||||
return usbhControlRequest(hub->dev,
|
||||
bmRequestType, bRequest, wValue, wIndex, wLength, buf);
|
||||
}
|
||||
|
||||
|
||||
static void _urb_complete(usbh_urb_t *urb) {
|
||||
|
||||
USBHHubDriver *const hubdp = (USBHHubDriver *)urb->userData;
|
||||
switch (urb->status) {
|
||||
case USBH_URBSTATUS_TIMEOUT:
|
||||
/* the device NAKed */
|
||||
udbg("HUB: no info");
|
||||
hubdp->statuschange = 0;
|
||||
break;
|
||||
case USBH_URBSTATUS_OK: {
|
||||
uint8_t len = hubdp->hubDesc.bNbrPorts / 8 + 1;
|
||||
if (urb->actualLength != len) {
|
||||
uwarnf("Expected %d status change bytes but got %d", len, urb->actualLength);
|
||||
}
|
||||
|
||||
if (urb->actualLength < len)
|
||||
len = urb->actualLength;
|
||||
|
||||
if (len > 4)
|
||||
len = 4;
|
||||
|
||||
uint8_t *sc = (uint8_t *)&hubdp->statuschange;
|
||||
uint8_t *r = hubdp->scbuff;
|
||||
while (len--)
|
||||
*sc++ |= *r++;
|
||||
|
||||
uinfof("HUB: change, %08x", hubdp->statuschange);
|
||||
} break;
|
||||
case USBH_URBSTATUS_DISCONNECTED:
|
||||
uwarn("HUB: URB disconnected, aborting poll");
|
||||
return;
|
||||
default:
|
||||
uerrf("HUB: URB status unexpected = %d", urb->status);
|
||||
break;
|
||||
}
|
||||
|
||||
usbhURBObjectResetI(urb);
|
||||
usbhURBSubmitI(urb);
|
||||
}
|
||||
|
||||
static usbh_baseclassdriver_t *hub_load(usbh_device_t *dev,
|
||||
const uint8_t *descriptor, uint16_t rem) {
|
||||
int i;
|
||||
|
||||
USBHHubDriver *hubdp;
|
||||
|
||||
if ((rem < descriptor[0]) || (descriptor[1] != USBH_DT_DEVICE))
|
||||
return NULL;
|
||||
|
||||
if (dev->devDesc.bDeviceProtocol != 0)
|
||||
return NULL;
|
||||
|
||||
generic_iterator_t iep, icfg;
|
||||
if_iterator_t iif;
|
||||
|
||||
cfg_iter_init(&icfg, dev->fullConfigurationDescriptor,
|
||||
dev->basicConfigDesc.wTotalLength);
|
||||
|
||||
if_iter_init(&iif, &icfg);
|
||||
if (!iif.valid)
|
||||
return NULL;
|
||||
const usbh_interface_descriptor_t *const ifdesc = if_get(&iif);
|
||||
if ((ifdesc->bInterfaceClass != 0x09)
|
||||
|| (ifdesc->bInterfaceSubClass != 0x00)
|
||||
|| (ifdesc->bInterfaceProtocol != 0x00)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ep_iter_init(&iep, &iif);
|
||||
if (!iep.valid)
|
||||
return NULL;
|
||||
const usbh_endpoint_descriptor_t *const epdesc = ep_get(&iep);
|
||||
if ((epdesc->bmAttributes & 0x03) != USBH_EPTYPE_INT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* alloc driver */
|
||||
for (i = 0; i < HAL_USBHHUB_MAX_INSTANCES; i++) {
|
||||
if (USBHHUBD[i].dev == NULL) {
|
||||
hubdp = &USBHHUBD[i];
|
||||
goto alloc_ok;
|
||||
}
|
||||
}
|
||||
|
||||
uwarn("Can't alloc HUB driver");
|
||||
|
||||
/* can't alloc */
|
||||
return NULL;
|
||||
|
||||
alloc_ok:
|
||||
/* initialize the driver's variables */
|
||||
hubdp->epint.status = USBH_EPSTATUS_UNINITIALIZED;
|
||||
hubdp->dev = dev;
|
||||
hubdp->ports = 0;
|
||||
|
||||
usbhEPSetName(&dev->ctrl, "HUB[CTRL]");
|
||||
|
||||
/* read Hub descriptor */
|
||||
uinfo("Read Hub descriptor");
|
||||
if (usbhhubControlRequest(dev->host, hubdp,
|
||||
USBH_REQTYPE_IN | USBH_REQTYPE_CLASS | USBH_REQTYPE_DEVICE,
|
||||
USBH_REQ_GET_DESCRIPTOR,
|
||||
(USBH_DT_HUB << 8), 0, sizeof(hubdp->hubDesc),
|
||||
(uint8_t *)&hubdp->hubDesc) != USBH_URBSTATUS_OK) {
|
||||
hubdp->dev = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const usbh_hub_descriptor_t *const hubdesc = &hubdp->hubDesc;
|
||||
|
||||
uinfof("Hub descriptor loaded; %d ports, wHubCharacteristics=%04x, bPwrOn2PwrGood=%d, bHubContrCurrent=%d",
|
||||
hubdesc->bNbrPorts,
|
||||
hubdesc->wHubCharacteristics,
|
||||
hubdesc->bPwrOn2PwrGood,
|
||||
hubdesc->bHubContrCurrent);
|
||||
|
||||
/* Alloc ports */
|
||||
uint8_t ports = hubdesc->bNbrPorts;
|
||||
for (i = 0; (ports > 0) && (i < HAL_USBHHUB_MAX_PORTS); i++) {
|
||||
if (USBHPorts[i].hub == NULL) {
|
||||
uinfof("Alloc port %d", ports);
|
||||
_usbhub_port_object_init(&USBHPorts[i], dev->host, hubdp, ports);
|
||||
USBHPorts[i].next = hubdp->ports;
|
||||
hubdp->ports = &USBHPorts[i];
|
||||
--ports;
|
||||
}
|
||||
}
|
||||
|
||||
if (ports) {
|
||||
uwarn("Could not alloc all ports");
|
||||
}
|
||||
|
||||
/* link hub to the host's list */
|
||||
list_add_tail(&hubdp->node, &dev->host->hubs);
|
||||
|
||||
/* enable power to ports */
|
||||
usbh_port_t *port = hubdp->ports;
|
||||
while (port) {
|
||||
uinfof("Enable power for port %d", port->number);
|
||||
usbhhubSetFeaturePort(port, USBH_PORT_FEAT_POWER);
|
||||
port = port->next;
|
||||
}
|
||||
|
||||
if (hubdesc->bPwrOn2PwrGood)
|
||||
osalThreadSleepMilliseconds(2 * hubdesc->bPwrOn2PwrGood);
|
||||
|
||||
/* initialize the status change endpoint and trigger the first transfer */
|
||||
usbhEPObjectInit(&hubdp->epint, dev, epdesc);
|
||||
usbhEPSetName(&hubdp->epint, "HUB[INT ]");
|
||||
usbhEPOpen(&hubdp->epint);
|
||||
|
||||
usbhURBObjectInit(&hubdp->urb, &hubdp->epint,
|
||||
_urb_complete, hubdp, hubdp->scbuff,
|
||||
(hubdesc->bNbrPorts + 8) / 8);
|
||||
|
||||
osalSysLock();
|
||||
usbhURBSubmitI(&hubdp->urb);
|
||||
osalOsRescheduleS();
|
||||
osalSysUnlock();
|
||||
|
||||
return (usbh_baseclassdriver_t *)hubdp;
|
||||
}
|
||||
|
||||
static void hub_unload(usbh_baseclassdriver_t *drv) {
|
||||
osalDbgCheck(drv != NULL);
|
||||
USBHHubDriver *const hubdp = (USBHHubDriver *)drv;
|
||||
|
||||
/* close the status change endpoint (this cancels ongoing URBs) */
|
||||
osalSysLock();
|
||||
usbhEPCloseS(&hubdp->epint);
|
||||
osalSysUnlock();
|
||||
|
||||
/* de-alloc ports and unload drivers */
|
||||
usbh_port_t *port = hubdp->ports;
|
||||
while (port) {
|
||||
_usbh_port_disconnected(port);
|
||||
port->hub = NULL;
|
||||
port = port->next;
|
||||
}
|
||||
|
||||
/* unlink the hub from the host's list */
|
||||
list_del(&hubdp->node);
|
||||
|
||||
}
|
||||
|
||||
void usbhhubObjectInit(USBHHubDriver *hubdp) {
|
||||
osalDbgCheck(hubdp != NULL);
|
||||
memset(hubdp, 0, sizeof(*hubdp));
|
||||
hubdp->info = &usbhhubClassDriverInfo;
|
||||
}
|
||||
#else
|
||||
|
||||
#if HAL_USE_USBH
|
||||
void _usbhub_port_object_init(usbh_port_t *port, USBHDriver *usbh, uint8_t number) {
|
||||
memset(port, 0, sizeof(*port));
|
||||
port->number = number;
|
||||
port->device.host = usbh;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
#include "hal_usbh.h"
|
||||
#include "usbh/internal.h"
|
||||
|
||||
#if HAL_USBH_USE_HUB
|
||||
|
||||
#if !HAL_USE_USBH
|
||||
#error "USBHHUB needs HAL_USE_USBH"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "usbh/dev/hub.h"
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_TRACE
|
||||
#define udbgf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define udbg(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define udbgf(f, ...) do {} while(0)
|
||||
#define udbg(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_INFO
|
||||
#define uinfof(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uinfo(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uinfof(f, ...) do {} while(0)
|
||||
#define uinfo(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_WARNINGS
|
||||
#define uwarnf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uwarn(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uwarnf(f, ...) do {} while(0)
|
||||
#define uwarn(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHHUB_DEBUG_ENABLE_ERRORS
|
||||
#define uerrf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uerr(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uerrf(f, ...) do {} while(0)
|
||||
#define uerr(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
USBHHubDriver USBHHUBD[HAL_USBHHUB_MAX_INSTANCES];
|
||||
usbh_port_t USBHPorts[HAL_USBHHUB_MAX_PORTS];
|
||||
|
||||
static usbh_baseclassdriver_t *hub_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem);
|
||||
static void hub_unload(usbh_baseclassdriver_t *drv);
|
||||
static const usbh_classdriver_vmt_t usbhhubClassDriverVMT = {
|
||||
hub_load,
|
||||
hub_unload
|
||||
};
|
||||
const usbh_classdriverinfo_t usbhhubClassDriverInfo = {
|
||||
0x09, 0x00, -1, "HUB", &usbhhubClassDriverVMT
|
||||
};
|
||||
|
||||
|
||||
void _usbhub_port_object_init(usbh_port_t *port, USBHDriver *usbh,
|
||||
USBHHubDriver *hub, uint8_t number) {
|
||||
memset(port, 0, sizeof(*port));
|
||||
port->number = number;
|
||||
port->device.host = usbh;
|
||||
port->hub = hub;
|
||||
}
|
||||
|
||||
usbh_urbstatus_t usbhhubControlRequest(USBHDriver *host, USBHHubDriver *hub,
|
||||
uint8_t bmRequestType,
|
||||
uint8_t bRequest,
|
||||
uint16_t wValue,
|
||||
uint16_t wIndex,
|
||||
uint16_t wLength,
|
||||
uint8_t *buf) {
|
||||
if (hub == NULL)
|
||||
return usbh_lld_root_hub_request(host, bmRequestType, bRequest, wValue, wIndex, wLength, buf);
|
||||
|
||||
return usbhControlRequest(hub->dev,
|
||||
bmRequestType, bRequest, wValue, wIndex, wLength, buf);
|
||||
}
|
||||
|
||||
|
||||
static void _urb_complete(usbh_urb_t *urb) {
|
||||
|
||||
USBHHubDriver *const hubdp = (USBHHubDriver *)urb->userData;
|
||||
switch (urb->status) {
|
||||
case USBH_URBSTATUS_TIMEOUT:
|
||||
/* the device NAKed */
|
||||
udbg("HUB: no info");
|
||||
hubdp->statuschange = 0;
|
||||
break;
|
||||
case USBH_URBSTATUS_OK: {
|
||||
uint8_t len = hubdp->hubDesc.bNbrPorts / 8 + 1;
|
||||
if (urb->actualLength != len) {
|
||||
uwarnf("Expected %d status change bytes but got %d", len, urb->actualLength);
|
||||
}
|
||||
|
||||
if (urb->actualLength < len)
|
||||
len = urb->actualLength;
|
||||
|
||||
if (len > 4)
|
||||
len = 4;
|
||||
|
||||
uint8_t *sc = (uint8_t *)&hubdp->statuschange;
|
||||
uint8_t *r = hubdp->scbuff;
|
||||
while (len--)
|
||||
*sc++ |= *r++;
|
||||
|
||||
uinfof("HUB: change, %08x", hubdp->statuschange);
|
||||
} break;
|
||||
case USBH_URBSTATUS_DISCONNECTED:
|
||||
uwarn("HUB: URB disconnected, aborting poll");
|
||||
return;
|
||||
default:
|
||||
uerrf("HUB: URB status unexpected = %d", urb->status);
|
||||
break;
|
||||
}
|
||||
|
||||
usbhURBObjectResetI(urb);
|
||||
usbhURBSubmitI(urb);
|
||||
}
|
||||
|
||||
static usbh_baseclassdriver_t *hub_load(usbh_device_t *dev,
|
||||
const uint8_t *descriptor, uint16_t rem) {
|
||||
int i;
|
||||
|
||||
USBHHubDriver *hubdp;
|
||||
|
||||
if ((rem < descriptor[0]) || (descriptor[1] != USBH_DT_DEVICE))
|
||||
return NULL;
|
||||
|
||||
if (dev->devDesc.bDeviceProtocol != 0)
|
||||
return NULL;
|
||||
|
||||
generic_iterator_t iep, icfg;
|
||||
if_iterator_t iif;
|
||||
|
||||
cfg_iter_init(&icfg, dev->fullConfigurationDescriptor,
|
||||
dev->basicConfigDesc.wTotalLength);
|
||||
|
||||
if_iter_init(&iif, &icfg);
|
||||
if (!iif.valid)
|
||||
return NULL;
|
||||
const usbh_interface_descriptor_t *const ifdesc = if_get(&iif);
|
||||
if ((ifdesc->bInterfaceClass != 0x09)
|
||||
|| (ifdesc->bInterfaceSubClass != 0x00)
|
||||
|| (ifdesc->bInterfaceProtocol != 0x00)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ep_iter_init(&iep, &iif);
|
||||
if (!iep.valid)
|
||||
return NULL;
|
||||
const usbh_endpoint_descriptor_t *const epdesc = ep_get(&iep);
|
||||
if ((epdesc->bmAttributes & 0x03) != USBH_EPTYPE_INT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* alloc driver */
|
||||
for (i = 0; i < HAL_USBHHUB_MAX_INSTANCES; i++) {
|
||||
if (USBHHUBD[i].dev == NULL) {
|
||||
hubdp = &USBHHUBD[i];
|
||||
goto alloc_ok;
|
||||
}
|
||||
}
|
||||
|
||||
uwarn("Can't alloc HUB driver");
|
||||
|
||||
/* can't alloc */
|
||||
return NULL;
|
||||
|
||||
alloc_ok:
|
||||
/* initialize the driver's variables */
|
||||
hubdp->epint.status = USBH_EPSTATUS_UNINITIALIZED;
|
||||
hubdp->dev = dev;
|
||||
hubdp->ports = 0;
|
||||
|
||||
usbhEPSetName(&dev->ctrl, "HUB[CTRL]");
|
||||
|
||||
/* read Hub descriptor */
|
||||
uinfo("Read Hub descriptor");
|
||||
if (usbhhubControlRequest(dev->host, hubdp,
|
||||
USBH_REQTYPE_IN | USBH_REQTYPE_CLASS | USBH_REQTYPE_DEVICE,
|
||||
USBH_REQ_GET_DESCRIPTOR,
|
||||
(USBH_DT_HUB << 8), 0, sizeof(hubdp->hubDesc),
|
||||
(uint8_t *)&hubdp->hubDesc) != USBH_URBSTATUS_OK) {
|
||||
hubdp->dev = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const usbh_hub_descriptor_t *const hubdesc = &hubdp->hubDesc;
|
||||
|
||||
uinfof("Hub descriptor loaded; %d ports, wHubCharacteristics=%04x, bPwrOn2PwrGood=%d, bHubContrCurrent=%d",
|
||||
hubdesc->bNbrPorts,
|
||||
hubdesc->wHubCharacteristics,
|
||||
hubdesc->bPwrOn2PwrGood,
|
||||
hubdesc->bHubContrCurrent);
|
||||
|
||||
/* Alloc ports */
|
||||
uint8_t ports = hubdesc->bNbrPorts;
|
||||
for (i = 0; (ports > 0) && (i < HAL_USBHHUB_MAX_PORTS); i++) {
|
||||
if (USBHPorts[i].hub == NULL) {
|
||||
uinfof("Alloc port %d", ports);
|
||||
_usbhub_port_object_init(&USBHPorts[i], dev->host, hubdp, ports);
|
||||
USBHPorts[i].next = hubdp->ports;
|
||||
hubdp->ports = &USBHPorts[i];
|
||||
--ports;
|
||||
}
|
||||
}
|
||||
|
||||
if (ports) {
|
||||
uwarn("Could not alloc all ports");
|
||||
}
|
||||
|
||||
/* link hub to the host's list */
|
||||
list_add_tail(&hubdp->node, &dev->host->hubs);
|
||||
|
||||
/* enable power to ports */
|
||||
usbh_port_t *port = hubdp->ports;
|
||||
while (port) {
|
||||
uinfof("Enable power for port %d", port->number);
|
||||
usbhhubSetFeaturePort(port, USBH_PORT_FEAT_POWER);
|
||||
port = port->next;
|
||||
}
|
||||
|
||||
if (hubdesc->bPwrOn2PwrGood)
|
||||
osalThreadSleepMilliseconds(2 * hubdesc->bPwrOn2PwrGood);
|
||||
|
||||
/* initialize the status change endpoint and trigger the first transfer */
|
||||
usbhEPObjectInit(&hubdp->epint, dev, epdesc);
|
||||
usbhEPSetName(&hubdp->epint, "HUB[INT ]");
|
||||
usbhEPOpen(&hubdp->epint);
|
||||
|
||||
usbhURBObjectInit(&hubdp->urb, &hubdp->epint,
|
||||
_urb_complete, hubdp, hubdp->scbuff,
|
||||
(hubdesc->bNbrPorts + 8) / 8);
|
||||
|
||||
osalSysLock();
|
||||
usbhURBSubmitI(&hubdp->urb);
|
||||
osalOsRescheduleS();
|
||||
osalSysUnlock();
|
||||
|
||||
return (usbh_baseclassdriver_t *)hubdp;
|
||||
}
|
||||
|
||||
static void hub_unload(usbh_baseclassdriver_t *drv) {
|
||||
osalDbgCheck(drv != NULL);
|
||||
USBHHubDriver *const hubdp = (USBHHubDriver *)drv;
|
||||
|
||||
/* close the status change endpoint (this cancels ongoing URBs) */
|
||||
osalSysLock();
|
||||
usbhEPCloseS(&hubdp->epint);
|
||||
osalSysUnlock();
|
||||
|
||||
/* de-alloc ports and unload drivers */
|
||||
usbh_port_t *port = hubdp->ports;
|
||||
while (port) {
|
||||
_usbh_port_disconnected(port);
|
||||
port->hub = NULL;
|
||||
port = port->next;
|
||||
}
|
||||
|
||||
/* unlink the hub from the host's list */
|
||||
list_del(&hubdp->node);
|
||||
|
||||
}
|
||||
|
||||
void usbhhubObjectInit(USBHHubDriver *hubdp) {
|
||||
osalDbgCheck(hubdp != NULL);
|
||||
memset(hubdp, 0, sizeof(*hubdp));
|
||||
hubdp->info = &usbhhubClassDriverInfo;
|
||||
}
|
||||
#else
|
||||
|
||||
#if HAL_USE_USBH
|
||||
void _usbhub_port_object_init(usbh_port_t *port, USBHDriver *usbh, uint8_t number) {
|
||||
memset(port, 0, sizeof(*port));
|
||||
port->number = number;
|
||||
port->device.host = usbh;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,89 +1,89 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
#include "usbh.h"
|
||||
|
||||
#if HAL_USBH_USE_UVC
|
||||
|
||||
#if !HAL_USE_USBH
|
||||
#error "USBHUVC needs HAL_USE_USBH"
|
||||
#endif
|
||||
|
||||
#if !HAL_USBH_USE_IAD
|
||||
#error "USBHUVC needs HAL_USBH_USE_IAD"
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_TRACE
|
||||
#define udbgf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define udbg(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define udbgf(f, ...) do {} while(0)
|
||||
#define udbg(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_INFO
|
||||
#define uinfof(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uinfo(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uinfof(f, ...) do {} while(0)
|
||||
#define uinfo(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_WARNINGS
|
||||
#define uwarnf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uwarn(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uwarnf(f, ...) do {} while(0)
|
||||
#define uwarn(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_ERRORS
|
||||
#define uerrf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uerr(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uerrf(f, ...) do {} while(0)
|
||||
#define uerr(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev,
|
||||
const uint8_t *descriptor, uint16_t rem);
|
||||
static void uvc_unload(usbh_baseclassdriver_t *drv);
|
||||
|
||||
static const usbh_classdriver_vmt_t class_driver_vmt = {
|
||||
uvc_load,
|
||||
uvc_unload
|
||||
};
|
||||
const usbh_classdriverinfo_t usbhuvcClassDriverInfo = {
|
||||
0x0e, 0x03, 0x00, "UVC", &class_driver_vmt
|
||||
};
|
||||
|
||||
|
||||
static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) {
|
||||
(void)dev;
|
||||
(void)descriptor;
|
||||
(void)rem;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void uvc_unload(usbh_baseclassdriver_t *drv) {
|
||||
(void)drv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
#include "hal_usbh.h"
|
||||
|
||||
#if HAL_USBH_USE_UVC
|
||||
|
||||
#if !HAL_USE_USBH
|
||||
#error "USBHUVC needs HAL_USE_USBH"
|
||||
#endif
|
||||
|
||||
#if !HAL_USBH_USE_IAD
|
||||
#error "USBHUVC needs HAL_USBH_USE_IAD"
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_TRACE
|
||||
#define udbgf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define udbg(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define udbgf(f, ...) do {} while(0)
|
||||
#define udbg(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_INFO
|
||||
#define uinfof(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uinfo(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uinfof(f, ...) do {} while(0)
|
||||
#define uinfo(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_WARNINGS
|
||||
#define uwarnf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uwarn(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uwarnf(f, ...) do {} while(0)
|
||||
#define uwarn(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#if USBHUVC_DEBUG_ENABLE_ERRORS
|
||||
#define uerrf(f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
|
||||
#define uerr(f, ...) usbDbgPuts(f, ##__VA_ARGS__)
|
||||
#else
|
||||
#define uerrf(f, ...) do {} while(0)
|
||||
#define uerr(f, ...) do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev,
|
||||
const uint8_t *descriptor, uint16_t rem);
|
||||
static void uvc_unload(usbh_baseclassdriver_t *drv);
|
||||
|
||||
static const usbh_classdriver_vmt_t class_driver_vmt = {
|
||||
uvc_load,
|
||||
uvc_unload
|
||||
};
|
||||
const usbh_classdriverinfo_t usbhuvcClassDriverInfo = {
|
||||
0x0e, 0x03, 0x00, "UVC", &class_driver_vmt
|
||||
};
|
||||
|
||||
|
||||
static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) {
|
||||
(void)dev;
|
||||
(void)descriptor;
|
||||
(void)rem;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void uvc_unload(usbh_baseclassdriver_t *drv) {
|
||||
(void)drv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,33 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="0.615626871">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.615626871" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<cconfiguration id="0.689012726">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.689012726" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration buildProperties="" description="" id="0.615626871" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.615626871." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2088952429" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.2088952429.950601975" name=""/>
|
||||
<builder id="org.eclipse.cdt.build.core.settings.default.builder.207008171" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.299570443" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.295096740" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1090608272" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.689012726" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.689012726." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1927048022" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1927048022.133421332" name=""/>
|
||||
<builder id="org.eclipse.cdt.build.core.settings.default.builder.860237702" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1015298275" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1849946851" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1235940747" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/opt/arm-none-eabi/arm-none-eabi/include"/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/lib/gcc/arm-none-eabi/${GCC_VERSION}/include""/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/lib/gcc/arm-none-eabi/${GCC_VERSION}/include-fixed""/>
|
||||
</option>
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.782791296" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.936085132" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1189952937" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.801978059" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.769587840" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/opt/arm-none-eabi/arm-none-eabi/include"/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/lib/gcc/arm-none-eabi/${GCC_VERSION}/include""/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/lib/gcc/arm-none-eabi/${GCC_VERSION}/include-fixed""/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/arm-none-eabi/include/c++/${GCC_VERSION}""/>
|
||||
</option>
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.610180386" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.891075427" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.152078979" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1670728915" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1406120469" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/opt/arm-none-eabi/arm-none-eabi/include"/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/lib/gcc/arm-none-eabi/${GCC_VERSION}/include""/>
|
||||
<listOptionValue builtIn="false" value=""/opt/arm-none-eabi/lib/gcc/arm-none-eabi/${GCC_VERSION}/include-fixed""/>
|
||||
</option>
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1480940900" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
|
@ -37,16 +53,19 @@
|
|||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="onewire_f0x.null.2066526446" name="onewire_f0x"/>
|
||||
<project id="STM32F0xx-1-Wire.null.964703683" name="STM32F0xx-1-Wire"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Default">
|
||||
<resource resourceType="PROJECT" workspacePath="/STM32F0xx-1-Wire"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="0.615626871">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="0.114656749">
|
||||
<scannerConfigBuildInfo instanceId="0.689012726">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>STM32F0xx-onewire</name>
|
||||
<name>STM32F0xx-1-Wire</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
@ -9,58 +9,6 @@
|
|||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value>-j1</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
|
@ -74,18 +22,17 @@
|
|||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>os-community</name>
|
||||
<name>os-contrib</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-4-PROJECT_LOC/os</locationURI>
|
||||
<locationURI>CHIBIOS_CONTRIB</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>os-git</name>
|
||||
<name>os</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-5-PROJECT_LOC/ChibiOS-RT/os</locationURI>
|
||||
<locationURI>CHIBIOS</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "string.h"
|
||||
|
||||
#include "fsmc_sdram.h"
|
||||
#include "hal_fsmc_sdram.h"
|
||||
#include "membench.h"
|
||||
#include "memtest.h"
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "fsmc_sram.h"
|
||||
#include "hal_fsmc_sram.h"
|
||||
#include "membench.h"
|
||||
#include "memtest.h"
|
||||
|
||||
|
|
|
@ -1,211 +1,211 @@
|
|||
##############################################################################
|
||||
# Build global options
|
||||
# NOTE: Can be overridden externally.
|
||||
#
|
||||
|
||||
# Compiler options here.
|
||||
ifeq ($(USE_OPT),)
|
||||
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
endif
|
||||
|
||||
# C specific options here (added to USE_OPT).
|
||||
ifeq ($(USE_COPT),)
|
||||
USE_COPT =
|
||||
endif
|
||||
|
||||
# C++ specific options here (added to USE_OPT).
|
||||
ifeq ($(USE_CPPOPT),)
|
||||
USE_CPPOPT = -fno-rtti
|
||||
endif
|
||||
|
||||
# Enable this if you want the linker to remove unused code and data
|
||||
ifeq ($(USE_LINK_GC),)
|
||||
USE_LINK_GC = yes
|
||||
endif
|
||||
|
||||
# Linker extra options here.
|
||||
ifeq ($(USE_LDOPT),)
|
||||
USE_LDOPT =
|
||||
endif
|
||||
|
||||
# Enable this if you want link time optimizations (LTO)
|
||||
ifeq ($(USE_LTO),)
|
||||
USE_LTO = no
|
||||
endif
|
||||
|
||||
# If enabled, this option allows to compile the application in THUMB mode.
|
||||
ifeq ($(USE_THUMB),)
|
||||
USE_THUMB = yes
|
||||
endif
|
||||
|
||||
# Enable this if you want to see the full log while compiling.
|
||||
ifeq ($(USE_VERBOSE_COMPILE),)
|
||||
USE_VERBOSE_COMPILE = no
|
||||
endif
|
||||
|
||||
#
|
||||
# Build global options
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Architecture or project specific options
|
||||
#
|
||||
|
||||
# Stack size to be allocated to the Cortex-M process stack. This stack is
|
||||
# the stack used by the main() thread.
|
||||
ifeq ($(USE_PROCESS_STACKSIZE),)
|
||||
USE_PROCESS_STACKSIZE = 0x400
|
||||
endif
|
||||
|
||||
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
||||
# stack is used for processing interrupts and exceptions.
|
||||
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
|
||||
USE_EXCEPTIONS_STACKSIZE = 0x400
|
||||
endif
|
||||
|
||||
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
|
||||
ifeq ($(USE_FPU),)
|
||||
USE_FPU = no
|
||||
endif
|
||||
|
||||
#
|
||||
# Architecture or project specific options
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Project, sources and paths
|
||||
#
|
||||
|
||||
# Define project name here
|
||||
PROJECT = ch
|
||||
|
||||
# Imported source files and paths
|
||||
##############################################################################
|
||||
# Build global options
|
||||
# NOTE: Can be overridden externally.
|
||||
#
|
||||
|
||||
# Compiler options here.
|
||||
ifeq ($(USE_OPT),)
|
||||
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
endif
|
||||
|
||||
# C specific options here (added to USE_OPT).
|
||||
ifeq ($(USE_COPT),)
|
||||
USE_COPT =
|
||||
endif
|
||||
|
||||
# C++ specific options here (added to USE_OPT).
|
||||
ifeq ($(USE_CPPOPT),)
|
||||
USE_CPPOPT = -fno-rtti
|
||||
endif
|
||||
|
||||
# Enable this if you want the linker to remove unused code and data
|
||||
ifeq ($(USE_LINK_GC),)
|
||||
USE_LINK_GC = yes
|
||||
endif
|
||||
|
||||
# Linker extra options here.
|
||||
ifeq ($(USE_LDOPT),)
|
||||
USE_LDOPT =
|
||||
endif
|
||||
|
||||
# Enable this if you want link time optimizations (LTO)
|
||||
ifeq ($(USE_LTO),)
|
||||
USE_LTO = no
|
||||
endif
|
||||
|
||||
# If enabled, this option allows to compile the application in THUMB mode.
|
||||
ifeq ($(USE_THUMB),)
|
||||
USE_THUMB = yes
|
||||
endif
|
||||
|
||||
# Enable this if you want to see the full log while compiling.
|
||||
ifeq ($(USE_VERBOSE_COMPILE),)
|
||||
USE_VERBOSE_COMPILE = no
|
||||
endif
|
||||
|
||||
#
|
||||
# Build global options
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Architecture or project specific options
|
||||
#
|
||||
|
||||
# Stack size to be allocated to the Cortex-M process stack. This stack is
|
||||
# the stack used by the main() thread.
|
||||
ifeq ($(USE_PROCESS_STACKSIZE),)
|
||||
USE_PROCESS_STACKSIZE = 0x400
|
||||
endif
|
||||
|
||||
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
||||
# stack is used for processing interrupts and exceptions.
|
||||
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
|
||||
USE_EXCEPTIONS_STACKSIZE = 0x400
|
||||
endif
|
||||
|
||||
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
|
||||
ifeq ($(USE_FPU),)
|
||||
USE_FPU = no
|
||||
endif
|
||||
|
||||
#
|
||||
# Architecture or project specific options
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Project, sources and paths
|
||||
#
|
||||
|
||||
# Define project name here
|
||||
PROJECT = ch
|
||||
|
||||
# Imported source files and paths
|
||||
CHIBIOS = ../../../../../ChibiOS-RT
|
||||
CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
|
||||
# Startup files.
|
||||
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
|
||||
# HAL-OSAL files (optional).
|
||||
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
|
||||
include $(CHIBIOS_CONTRIB)/os/hal/ports/STM32/STM32F4xx/platform.mk
|
||||
include $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.mk
|
||||
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
||||
# RTOS files (optional).
|
||||
include $(CHIBIOS)/os/rt/rt.mk
|
||||
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
||||
|
||||
# Define linker script file here
|
||||
LDSCRIPT= $(STARTUPLD)/STM32F407xG.ld
|
||||
|
||||
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
CSRC = $(STARTUPSRC) \
|
||||
$(KERNSRC) \
|
||||
$(PORTSRC) \
|
||||
$(OSALSRC) \
|
||||
$(HALSRC) \
|
||||
$(PLATFORMSRC) \
|
||||
$(BOARDSRC) \
|
||||
$(TESTSRC) \
|
||||
main.c \
|
||||
onewire_test.c
|
||||
|
||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
CPPSRC =
|
||||
|
||||
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
ACSRC =
|
||||
|
||||
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
ACPPSRC =
|
||||
|
||||
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
TCSRC =
|
||||
|
||||
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
TCPPSRC =
|
||||
|
||||
# List ASM source files here
|
||||
ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
||||
|
||||
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
|
||||
$(CHIBIOS)/os/various
|
||||
|
||||
#
|
||||
# Project, sources and paths
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Compiler settings
|
||||
#
|
||||
|
||||
MCU = cortex-m4
|
||||
|
||||
#TRGT = arm-elf-
|
||||
TRGT = arm-none-eabi-
|
||||
CC = $(TRGT)gcc
|
||||
CPPC = $(TRGT)g++
|
||||
# Enable loading with g++ only if you need C++ runtime support.
|
||||
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||
# runtime support makes code size explode.
|
||||
LD = $(TRGT)gcc
|
||||
#LD = $(TRGT)g++
|
||||
CP = $(TRGT)objcopy
|
||||
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||
AR = $(TRGT)ar
|
||||
OD = $(TRGT)objdump
|
||||
SZ = $(TRGT)size
|
||||
HEX = $(CP) -O ihex
|
||||
BIN = $(CP) -O binary
|
||||
|
||||
# ARM-specific options here
|
||||
AOPT =
|
||||
|
||||
# THUMB-specific options here
|
||||
TOPT = -mthumb -DTHUMB
|
||||
|
||||
# Define C warning options here
|
||||
CWARN = -Wall -Wextra -Wstrict-prototypes -Wundef
|
||||
|
||||
# Define C++ warning options here
|
||||
CPPWARN = -Wall -Wextra -Wundef
|
||||
|
||||
#
|
||||
# Compiler settings
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Start of user section
|
||||
#
|
||||
|
||||
# List all user C define here, like -D_DEBUG=1
|
||||
UDEFS =
|
||||
|
||||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
||||
# List all user directories here
|
||||
UINCDIR =
|
||||
|
||||
# List the user directory to look for the libraries here
|
||||
ULIBDIR =
|
||||
|
||||
# List all user libraries here
|
||||
ULIBS =
|
||||
|
||||
#
|
||||
# End of user defines
|
||||
##############################################################################
|
||||
|
||||
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
|
||||
include $(RULESPATH)/rules.mk
|
||||
|
||||
CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
|
||||
# Startup files.
|
||||
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
|
||||
# HAL-OSAL files (optional).
|
||||
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
|
||||
include $(CHIBIOS_CONTRIB)/os/hal/ports/STM32/STM32F4xx/platform.mk
|
||||
include $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.mk
|
||||
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
||||
# RTOS files (optional).
|
||||
include $(CHIBIOS)/os/rt/rt.mk
|
||||
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
||||
|
||||
# Define linker script file here
|
||||
LDSCRIPT= $(STARTUPLD)/STM32F407xG.ld
|
||||
|
||||
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
CSRC = $(STARTUPSRC) \
|
||||
$(KERNSRC) \
|
||||
$(PORTSRC) \
|
||||
$(OSALSRC) \
|
||||
$(HALSRC) \
|
||||
$(PLATFORMSRC) \
|
||||
$(BOARDSRC) \
|
||||
$(TESTSRC) \
|
||||
main.c \
|
||||
onewire_test.c
|
||||
|
||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
# setting.
|
||||
CPPSRC =
|
||||
|
||||
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
ACSRC =
|
||||
|
||||
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
ACPPSRC =
|
||||
|
||||
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
TCSRC =
|
||||
|
||||
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||
# option that results in lower performance and larger code size.
|
||||
TCPPSRC =
|
||||
|
||||
# List ASM source files here
|
||||
ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
||||
|
||||
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
|
||||
$(CHIBIOS)/os/various
|
||||
|
||||
#
|
||||
# Project, sources and paths
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Compiler settings
|
||||
#
|
||||
|
||||
MCU = cortex-m4
|
||||
|
||||
#TRGT = arm-elf-
|
||||
TRGT = arm-none-eabi-
|
||||
CC = $(TRGT)gcc
|
||||
CPPC = $(TRGT)g++
|
||||
# Enable loading with g++ only if you need C++ runtime support.
|
||||
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||
# runtime support makes code size explode.
|
||||
LD = $(TRGT)gcc
|
||||
#LD = $(TRGT)g++
|
||||
CP = $(TRGT)objcopy
|
||||
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||
AR = $(TRGT)ar
|
||||
OD = $(TRGT)objdump
|
||||
SZ = $(TRGT)size
|
||||
HEX = $(CP) -O ihex
|
||||
BIN = $(CP) -O binary
|
||||
|
||||
# ARM-specific options here
|
||||
AOPT =
|
||||
|
||||
# THUMB-specific options here
|
||||
TOPT = -mthumb -DTHUMB
|
||||
|
||||
# Define C warning options here
|
||||
CWARN = -Wall -Wextra -Wstrict-prototypes -Wundef
|
||||
|
||||
# Define C++ warning options here
|
||||
CPPWARN = -Wall -Wextra -Wundef
|
||||
|
||||
#
|
||||
# Compiler settings
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Start of user section
|
||||
#
|
||||
|
||||
# List all user C define here, like -D_DEBUG=1
|
||||
UDEFS =
|
||||
|
||||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
||||
# List all user directories here
|
||||
UINCDIR =
|
||||
|
||||
# List the user directory to look for the libraries here
|
||||
ULIBDIR =
|
||||
|
||||
# List all user libraries here
|
||||
ULIBS =
|
||||
|
||||
#
|
||||
# End of user defines
|
||||
##############################################################################
|
||||
|
||||
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
|
||||
include $(RULESPATH)/rules.mk
|
||||
|
||||
|
|
Loading…
Reference in New Issue