aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/hal_community.h5
-rw-r--r--os/hal/include/hal_crc.h6
-rw-r--r--os/hal/include/hal_ee24xx.h6
-rw-r--r--os/hal/include/hal_ee25xx.h6
-rw-r--r--os/hal/include/hal_eeprom.h6
-rw-r--r--os/hal/include/hal_eicu.h6
-rw-r--r--os/hal/include/hal_nand.h6
-rw-r--r--os/hal/include/hal_onewire.h13
-rw-r--r--os/hal/include/hal_rng.h6
-rw-r--r--os/hal/include/hal_timcap.h8
-rw-r--r--os/hal/include/hal_usb_msd.h192
-rw-r--r--os/hal/include/hal_usbh.h6
12 files changed, 232 insertions, 34 deletions
diff --git a/os/hal/include/hal_community.h b/os/hal/include/hal_community.h
index 1518c7e..430df7c 100644
--- a/os/hal/include/hal_community.h
+++ b/os/hal/include/hal_community.h
@@ -67,6 +67,10 @@
#define HAL_USE_USB_HID FALSE
#endif
+#if !defined(HAL_USE_USB_MSD)
+#define HAL_USE_USB_MSD FALSE
+#endif
+
/* Abstract interfaces.*/
/* Shared headers.*/
@@ -84,6 +88,7 @@
#include "hal_crc.h"
#include "hal_eeprom.h"
#include "hal_usb_hid.h"
+#include "hal_usb_msd.h"
/*===========================================================================*/
/* Driver constants. */
diff --git a/os/hal/include/hal_crc.h b/os/hal/include/hal_crc.h
index 8c4c895..d7ef10f 100644
--- a/os/hal/include/hal_crc.h
+++ b/os/hal/include/hal_crc.h
@@ -14,8 +14,8 @@
limitations under the License.
*/
-#ifndef _CRC_H_
-#define _CRC_H_
+#ifndef HAL_CRC_H_
+#define HAL_CRC_H_
#if (HAL_USE_CRC == TRUE) || defined(__DOXYGEN__)
@@ -153,6 +153,6 @@ extern "C" {
#endif /* HAL_USE_CRC */
-#endif /* _CRC_H_ */
+#endif /* HAL_CRC_H_ */
/** @} */
diff --git a/os/hal/include/hal_ee24xx.h b/os/hal/include/hal_ee24xx.h
index ab12fd1..00cdc95 100644
--- a/os/hal/include/hal_ee24xx.h
+++ b/os/hal/include/hal_ee24xx.h
@@ -4,8 +4,8 @@
The work is provided "as is" without warranty of any kind, neither express nor implied.
*/
-#ifndef EE24XX_H
-#define EE24XX_H
+#ifndef HAL_EE24XX_H
+#define HAL_EE24XX_H
#include "hal.h"
@@ -61,4 +61,4 @@ typedef struct {
#endif /* #if defined(EEPROM_USE_EE24XX) && EEPROM_USE_EE24XX */
-#endif // EE24XX_H
+#endif // HAL_EE24XX_H
diff --git a/os/hal/include/hal_ee25xx.h b/os/hal/include/hal_ee25xx.h
index fc2ad6f..e520bd6 100644
--- a/os/hal/include/hal_ee25xx.h
+++ b/os/hal/include/hal_ee25xx.h
@@ -4,8 +4,8 @@
The work is provided "as is" without warranty of any kind, neither express nor implied.
*/
-#ifndef EE25XX_H
-#define EE25XX_H
+#ifndef HAL_EE25XX_H
+#define HAL_EE25XX_H
#include "hal.h"
@@ -60,4 +60,4 @@ EepromFileStream *SPIEepromFileOpen(SPIEepromFileStream *efs,
#endif /* #if defined(EEPROM_USE_EE25XX) && EEPROM_USE_EE25XX */
-#endif // EE25XX_H
+#endif // HAL_EE25XX_H
diff --git a/os/hal/include/hal_eeprom.h b/os/hal/include/hal_eeprom.h
index cd05e14..6f53fb9 100644
--- a/os/hal/include/hal_eeprom.h
+++ b/os/hal/include/hal_eeprom.h
@@ -26,8 +26,8 @@
The work is provided "as is" without warranty of any kind, neither express nor implied.
*/
-#ifndef __EEPROM_H__
-#define __EEPROM_H__
+#ifndef HAL_EEPROM_H_
+#define HAL_EEPROM_H_
#include "ch.h"
#include "hal.h"
@@ -140,4 +140,4 @@ msg_t eepfs_get(void *ip);
#include "hal_ee25xx.h"
#endif /* #if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM */
-#endif /* __EEPROM_H__ */
+#endif /* HAL_EEPROM_H_ */
diff --git a/os/hal/include/hal_eicu.h b/os/hal/include/hal_eicu.h
index d4b0ed2..8b4b07d 100644
--- a/os/hal/include/hal_eicu.h
+++ b/os/hal/include/hal_eicu.h
@@ -22,8 +22,8 @@
32-bit timers and timers with single capture/compare channels.
*/
-#ifndef _EICU_H_
-#define _EICU_H_
+#ifndef HAL_EICU_H_
+#define HAL_EICU_H_
#if (HAL_USE_EICU == TRUE) || defined(__DOXYGEN__)
@@ -186,6 +186,6 @@ extern "C" {
#endif /* HAL_USE_EICU */
-#endif /* _EICU_H_ */
+#endif /* HAL_EICU_H_ */
/** @} */
diff --git a/os/hal/include/hal_nand.h b/os/hal/include/hal_nand.h
index d5a1c04..ace3e5d 100644
--- a/os/hal/include/hal_nand.h
+++ b/os/hal/include/hal_nand.h
@@ -15,15 +15,15 @@
*/
/**
- * @file nand.h
+ * @file hal_nand.h
* @brief NAND Driver macros and structures.
*
* @addtogroup NAND
* @{
*/
-#ifndef _NAND_H_
-#define _NAND_H_
+#ifndef HAL_NAND_H_
+#define HAL_NAND_H_
#if (HAL_USE_NAND == TRUE) || defined(__DOXYGEN__)
diff --git a/os/hal/include/hal_onewire.h b/os/hal/include/hal_onewire.h
index 9fb5be2..bbaf77b 100644
--- a/os/hal/include/hal_onewire.h
+++ b/os/hal/include/hal_onewire.h
@@ -15,15 +15,15 @@
*/
/**
- * @file onewire.h
+ * @file hal_onewire.h
* @brief 1-wire Driver macros and structures.
*
* @addtogroup onewire
* @{
*/
-#ifndef _ONEWIRE_H_
-#define _ONEWIRE_H_
+#ifndef HAL_ONEWIRE_H_
+#define HAL_ONEWIRE_H_
#if (HAL_USE_ONEWIRE == TRUE) || defined(__DOXYGEN__)
@@ -59,11 +59,13 @@
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
+#if ONEWIRE_SYNTH_SEARCH_TEST && !ONEWIRE_USE_SEARCH_ROM
+#error "Synthetic search rom test needs ONEWIRE_USE_SEARCH_ROM"
+#endif
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
-
#if !HAL_USE_PWM
#error "1-wire Driver requires HAL_USE_PWM"
#endif
@@ -328,7 +330,6 @@ extern onewireDriver OWD1;
#ifdef __cplusplus
extern "C" {
#endif
- void onewireInit(void);
void onewireObjectInit(onewireDriver *owp);
void onewireStart(onewireDriver *owp, const onewireConfig *config);
void onewireStop(onewireDriver *owp);
@@ -352,7 +353,7 @@ extern "C" {
#endif /* HAL_USE_ONEWIRE */
-#endif /* _ONEWIRE_H_ */
+#endif /* HAL_ONEWIRE_H_ */
/** @} */
diff --git a/os/hal/include/hal_rng.h b/os/hal/include/hal_rng.h
index 0e3c484..dc146c7 100644
--- a/os/hal/include/hal_rng.h
+++ b/os/hal/include/hal_rng.h
@@ -14,8 +14,8 @@
limitations under the License.
*/
-#ifndef _RNG_H_
-#define _RNG_H_
+#ifndef HAL_RNG_H_
+#define HAL_RNG_H_
#if (HAL_USE_RNG == TRUE) || defined(__DOXYGEN__)
@@ -131,6 +131,6 @@ extern "C" {
#endif /* HAL_USE_RNG */
-#endif /* _RNG_H_ */
+#endif /* HAL_RNG_H_ */
/** @} */
diff --git a/os/hal/include/hal_timcap.h b/os/hal/include/hal_timcap.h
index bd43dd1..61c7fc5 100644
--- a/os/hal/include/hal_timcap.h
+++ b/os/hal/include/hal_timcap.h
@@ -19,15 +19,15 @@
*/
/**
- * @file timcap.h
+ * @file hal_timcap.h
* @brief TIMCAP Driver macros and structures.
*
* @addtogroup TIMCAP
* @{
*/
-#ifndef _TIMCAP_H_
-#define _TIMCAP_H_
+#ifndef HAL_TIMCAP_H_
+#define HAL_TIMCAP_H_
#include "ch.h"
#include "hal.h"
@@ -201,6 +201,6 @@ extern "C" {
#endif /* HAL_USE_TIMCAP */
-#endif /* _TIMCAP_H_ */
+#endif /* HAL_TIMCAP_H_ */
/** @} */
diff --git a/os/hal/include/hal_usb_msd.h b/os/hal/include/hal_usb_msd.h
new file mode 100644
index 0000000..08241df
--- /dev/null
+++ b/os/hal/include/hal_usb_msd.h
@@ -0,0 +1,192 @@
+/*
+ ChibiOS/HAL - Copyright (C) 2016 Uladzimir Pylinsky aka barthess
+
+ 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.
+*/
+
+/**
+ * @file hal_usb_msd.h
+ * @brief USM mass storage device driver macros and structures.
+ *
+ * @addtogroup usb_msd
+ * @{
+ */
+
+#ifndef HAL_USB_MSD_H
+#define HAL_USB_MSD_H
+
+#if (HAL_USE_USB_MSD == TRUE) || defined(__DOXYGEN__)
+
+#include "lib_scsi.h"
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+#define USB_MSD_DATA_EP 0x01
+#define USB_MSD_EP_SIZE 0x40
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if !HAL_USE_USB
+#error "Mass storage Driver requires HAL_USE_USB"
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type of a structure representing an USB mass storage driver.
+ */
+typedef struct USBMassStorageDriver USBMassStorageDriver;
+
+/**
+ * @brief Type of a driver state machine possible states.
+ */
+typedef enum {
+ USB_MSD_UNINIT = 0,
+ USB_MSD_STOP,
+ USB_MSD_READY,
+} usbmsdstate_t;
+
+/**
+ * @brief Represents command block wrapper structure.
+ * @details See USB Mass Storage Class Specification.
+ */
+typedef struct PACKED_VAR {
+ uint32_t signature;
+ uint32_t tag;
+ uint32_t data_len;
+ uint8_t flags;
+ uint8_t lun;
+ uint8_t cmd_len;
+ uint8_t cmd_data[16];
+} msd_cbw_t;
+
+/**
+ * @brief Represents command status wrapper structure.
+ * @details See USB Mass Storage Class Specification.
+ */
+typedef struct PACKED_VAR {
+ uint32_t signature;
+ uint32_t tag;
+ uint32_t data_residue;
+ uint8_t status;
+} msd_csw_t;
+
+/**
+ * @brief Transport handler passed to SCSI layer.
+ */
+typedef struct {
+ /**
+ * @brief Pointer to the @p USBDriver object.
+ */
+ USBDriver *usbp;
+ /**
+ * @brief USB endpoint number.
+ */
+ usbep_t ep;
+} usb_scsi_transport_handler_t;
+
+
+/**
+ * @brief Structure representing an USB mass storage driver.
+ */
+struct USBMassStorageDriver {
+ /**
+ * @brief Pointer to the @p USBDriver object.
+ */
+ USBDriver *usbp;
+ /**
+ * @brief Driver state.
+ */
+ usbmsdstate_t state;
+ /**
+ * @brief CBW structure.
+ */
+ msd_cbw_t cbw;
+ /**
+ * @brief CSW structure.
+ */
+ msd_csw_t csw;
+ /**
+ * @brief Thread working area.
+ */
+ THD_WORKING_AREA( waMSDWorker, 512);
+ /**
+ * @brief Worker thread handler.
+ */
+ thread_reference_t worker;
+ /**
+ * @brief SCSI target driver structure.
+ */
+ SCSITarget scsi_target;
+ /**
+ * @brief SCSI target configuration structure.
+ */
+ SCSITargetConfig scsi_config;
+ /**
+ * @brief SCSI transport structure.
+ */
+ SCSITransport scsi_transport;
+ /**
+ * @brief SCSI over USB transport handler structure.
+ */
+ usb_scsi_transport_handler_t usb_scsi_transport_handler;
+};
+
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern USBMassStorageDriver USBMSD1;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void msdObjectInit(USBMassStorageDriver *msdp);
+ void msdStart(USBMassStorageDriver *msdp, USBDriver *usbp,
+ BaseBlockDevice *blkdev, uint8_t *blkbuf,
+ const scsi_inquiry_response_t *scsi_inquiry_response);
+ void msdStop(USBMassStorageDriver *msdp);
+ bool msd_request_hook(USBDriver *usbp);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_USB_MSD */
+
+#endif /* HAL_USB_MSD_H */
+
+/** @} */
+
+
+
+
+
+
+
+
+
diff --git a/os/hal/include/hal_usbh.h b/os/hal/include/hal_usbh.h
index 5fd0047..63be93e 100644
--- a/os/hal/include/hal_usbh.h
+++ b/os/hal/include/hal_usbh.h
@@ -15,8 +15,8 @@
limitations under the License.
*/
-#ifndef USBH_H_
-#define USBH_H_
+#ifndef HAL_USBH_H_
+#define HAL_USBH_H_
#include "hal.h"
@@ -433,4 +433,4 @@ struct usbh_baseclassdriver {
#endif
-#endif /* USBH_H_ */
+#endif /* HAL_USBH_H_ */