From 9d74dd2661b80a5ae8598591f0251b197cc51756 Mon Sep 17 00:00:00 2001 From: barthess Date: Thu, 7 Apr 2016 16:39:12 +0300 Subject: STM32 mass update to current naming convention in ChibiOS --- os/hal/include/crc.h | 158 --------------- os/hal/include/ee24xx.h | 64 ------ os/hal/include/ee25xx.h | 63 ------ os/hal/include/eeprom.h | 147 -------------- os/hal/include/eicu.h | 191 ------------------ os/hal/include/hal_community.h | 16 +- os/hal/include/hal_crc.h | 158 +++++++++++++++ os/hal/include/hal_ee24xx.h | 64 ++++++ os/hal/include/hal_ee25xx.h | 63 ++++++ os/hal/include/hal_eeprom.h | 147 ++++++++++++++ os/hal/include/hal_eicu.h | 191 ++++++++++++++++++ os/hal/include/hal_nand.h | 137 +++++++++++++ os/hal/include/hal_onewire.h | 366 ++++++++++++++++++++++++++++++++++ os/hal/include/hal_rng.h | 136 +++++++++++++ os/hal/include/hal_timcap.h | 210 ++++++++++++++++++++ os/hal/include/hal_usbh.h | 439 +++++++++++++++++++++++++++++++++++++++++ os/hal/include/nand.h | 137 ------------- os/hal/include/onewire.h | 366 ---------------------------------- os/hal/include/rng.h | 136 ------------- os/hal/include/timcap.h | 210 -------------------- os/hal/include/usbh.h | 439 ----------------------------------------- os/hal/include/usbh/debug.h | 2 +- os/hal/include/usbh/dev/ftdi.h | 2 +- os/hal/include/usbh/dev/hub.h | 2 +- os/hal/include/usbh/dev/msd.h | 2 +- os/hal/include/usbh/internal.h | 2 +- 26 files changed, 1924 insertions(+), 1924 deletions(-) delete mode 100644 os/hal/include/crc.h delete mode 100644 os/hal/include/ee24xx.h delete mode 100644 os/hal/include/ee25xx.h delete mode 100644 os/hal/include/eeprom.h delete mode 100644 os/hal/include/eicu.h create mode 100644 os/hal/include/hal_crc.h create mode 100644 os/hal/include/hal_ee24xx.h create mode 100644 os/hal/include/hal_ee25xx.h create mode 100644 os/hal/include/hal_eeprom.h create mode 100644 os/hal/include/hal_eicu.h create mode 100644 os/hal/include/hal_nand.h create mode 100644 os/hal/include/hal_onewire.h create mode 100644 os/hal/include/hal_rng.h create mode 100644 os/hal/include/hal_timcap.h create mode 100644 os/hal/include/hal_usbh.h delete mode 100644 os/hal/include/nand.h delete mode 100644 os/hal/include/onewire.h delete mode 100644 os/hal/include/rng.h delete mode 100644 os/hal/include/timcap.h delete mode 100644 os/hal/include/usbh.h (limited to 'os/hal/include') diff --git a/os/hal/include/crc.h b/os/hal/include/crc.h deleted file mode 100644 index afa27e1..0000000 --- a/os/hal/include/crc.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - ChibiOS - Copyright (C) 2015 Michael D. Spradling - - 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 _CRC_H_ -#define _CRC_H_ - -#if (HAL_USE_CRC == TRUE) || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/** - * @name Configuration options - * @{ - */ - -/** - * @brief Enable DMA CRC - * @note Enables DMA when doing CRC calculations. This may be less - * efficient with smaller CRC calculations. - */ -#if !defined(CRC_USE_DMA) || defined(__DOXYGEN__) -#define CRC_USE_DMA FALSE -#endif - -/** - * @brief Enables the @p crcAcquireBus() and @p crcReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(CRC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define CRC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -#if STM32_CRC_USE_CRC1 != TRUE && CRCSW_USE_CRC1 != TRUE -#error "CRC requires at least one LLD driver." -#endif - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - CRC_UNINIT, /* Not initialized. */ - CRC_STOP, /* Stopped. */ - CRC_READY, /* Ready. */ - CRC_ACTIVE, /* Calculating CRC. */ - CRC_COMPLETE /* Asynchronous operation complete. */ -} crcstate_t; - -#include "crc_lld.h" -#include "crcsw.h" /* Include software LL driver */ - - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/** - * @name Low level driver helper macros - * @{ - */ - -/** - * @brief Wakes up the waiting thread. - * - * @param[in] crcp pointer to the @p CRCDriver object - * - * @notapi - */ -#define _crc_wakeup_isr(crcp) { \ - osalSysLockFromISR(); \ - osalThreadResumeI(&(crcp)->thread, MSG_OK); \ - osalSysUnlockFromISR(); \ -} - -/** - * @brief Common ISR code. - * @details This code handles the portable part of the ISR code: - * - Callback invocation. - * - Waiting thread wakeup, if any. - * - Driver state transitions. - * . - * @note This macro is meant to be used in the low level drivers - * implementation only. - * - * @param[in] crcp pointer to the @p CRCDriver object - * - * @notapi - */ -#define _crc_isr_code(crcp, crc) { \ - if ((crcp)->config->end_cb) { \ - (crcp)->state = CRC_COMPLETE; \ - (crcp)->config->end_cb(crcp, crc); \ - if ((crcp)->state == CRC_COMPLETE) \ - (crcp)->state = CRC_READY; \ - } \ - else \ - (crcp)->state = CRC_READY; \ - _crc_wakeup_isr(crcp); \ -} - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void crcInit(void); - void crcObjectInit(CRCDriver *crcp); - void crcStart(CRCDriver *crcp, const CRCConfig *config); - void crcStop(CRCDriver *crcp); - void crcReset(CRCDriver *crcp); - void crcResetI(CRCDriver *crcp); - uint32_t crcCalc(CRCDriver *crcp, size_t n, const void *buf); - uint32_t crcCalcI(CRCDriver *crcp, size_t n, const void *buf); -#if CRC_USE_DMA == TRUE - void crcStartCalc(CRCDriver *crcp, size_t n, const void *buf); - void crcStartCalcI(CRCDriver *crcp, size_t n, const void *buf); -#endif -#if CRC_USE_MUTUAL_EXCLUSION == TRUE - void crcAcquireUnit(CRCDriver *crcp); - void crcReleaseUnit(CRCDriver *crcp); -#endif -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_CRC */ - -#endif /* _CRC_H_ */ - -/** @} */ diff --git a/os/hal/include/ee24xx.h b/os/hal/include/ee24xx.h deleted file mode 100644 index ab12fd1..0000000 --- a/os/hal/include/ee24xx.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2012 Uladzimir Pylinski aka barthess. - You may use this work without restrictions, as long as this notice is included. - The work is provided "as is" without warranty of any kind, neither express nor implied. -*/ - -#ifndef EE24XX_H -#define EE24XX_H - -#include "hal.h" - -#if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE24XX - -#define EEPROM_DEV_24XX 24 - -/** - * @extends EepromFileConfig - */ -typedef struct { - _eeprom_file_config_data - /** - * Driver connected to IC. - */ - I2CDriver *i2cp; - /** - * Address of IC on I2C bus. - */ - i2caddr_t addr; - /** - * Pointer to write buffer. The safest size is (pagesize + 2) - */ - uint8_t *write_buf; -} I2CEepromFileConfig; - -/** - * @brief @p I2CEepromFileStream specific data. - */ -#define _eeprom_file_stream_data_i2c \ - _eeprom_file_stream_data - -/** - * @extends EepromFileStream - * - * @brief EEPROM file stream driver class for I2C device. - */ -typedef struct { - const struct EepromFileStreamVMT *vmt; - _eeprom_file_stream_data_i2c - /* Overwritten parent data member. */ - const I2CEepromFileConfig *cfg; -} I2CEepromFileStream; - - -/** - * Open I2C EEPROM IC as file and return pointer to the file stream object - * @note Fucntion allways successfully open file. All checking makes - * in read/write functions. - */ -#define I2CEepromFileOpen(efs, eepcfg, eepdev) \ - EepromFileOpen((EepromFileStream *)efs, (EepromFileConfig *)eepcfg, eepdev); - -#endif /* #if defined(EEPROM_USE_EE24XX) && EEPROM_USE_EE24XX */ - -#endif // EE24XX_H diff --git a/os/hal/include/ee25xx.h b/os/hal/include/ee25xx.h deleted file mode 100644 index fc2ad6f..0000000 --- a/os/hal/include/ee25xx.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2012 Uladzimir Pylinski aka barthess. - You may use this work without restrictions, as long as this notice is included. - The work is provided "as is" without warranty of any kind, neither express nor implied. -*/ - -#ifndef EE25XX_H -#define EE25XX_H - -#include "hal.h" - -#if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE25XX - -#define EEPROM_DEV_25XX 25 - -/** - * @extends EepromFileConfig - */ -typedef struct { - _eeprom_file_config_data - /** - * Driver connected to IC. - */ - SPIDriver *spip; - /** - * Config associated with SPI driver. - */ - const SPIConfig *spicfg; -} SPIEepromFileConfig; - -/** - * @brief @p SPIEepromFileStream specific data. - */ -#define _eeprom_file_stream_data_spi \ - _eeprom_file_stream_data - -/** - * @extends EepromFileStream - * - * @brief EEPROM file stream driver class for SPI device. - */ -typedef struct { - const struct EepromFileStreamVMT *vmt; - _eeprom_file_stream_data_spi - /* Overwritten parent data member. */ - const SPIEepromFileConfig *cfg; -} SPIEepromFileStream; - -/** - * Open SPI EEPROM IC as file and return pointer to the file stream object - * @note Fucntion allways successfully open file. All checking makes - * in read/write functions. - */ -EepromFileStream *SPIEepromFileOpen(SPIEepromFileStream *efs, - const SPIEepromFileConfig *eepcfg, - const EepromDevice *eepdev); - -#define SPIEepromFileOpen(efs, eepcfg, eepdev) \ - EepromFileOpen((EepromFileStream *)efs, (EepromFileConfig *)eepcfg, eepdev); - -#endif /* #if defined(EEPROM_USE_EE25XX) && EEPROM_USE_EE25XX */ - -#endif // EE25XX_H diff --git a/os/hal/include/eeprom.h b/os/hal/include/eeprom.h deleted file mode 100644 index b0fd360..0000000 --- a/os/hal/include/eeprom.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - Copyright (c) 2013 Timon Wong - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -/* - Copyright 2012 Uladzimir Pylinski aka barthess. - You may use this work without restrictions, as long as this notice is included. - The work is provided "as is" without warranty of any kind, neither express nor implied. -*/ - -#ifndef __EEPROM_H__ -#define __EEPROM_H__ - -#include "ch.h" -#include "hal.h" - -#ifndef HAL_USE_EEPROM -#define HAL_USE_EEPROM FALSE -#endif - -#ifndef EEPROM_USE_EE25XX -#define EEPROM_USE_EE25XX FALSE -#endif - -#ifndef EEPROM_USE_EE24XX -#define EEPROM_USE_EE24XX FALSE -#endif - -#if HAL_USE_EEPROM - -#if EEPROM_USE_EE25XX && EEPROM_USE_EE24XX -#define EEPROM_TABLE_SIZE 2 -#elif EEPROM_USE_EE25XX || EEPROM_USE_EE24XX -#define EEPROM_TABLE_SIZE 1 -#else -#error "No EEPROM device selected!" -#endif - -#if EEPROM_USE_EE25XX && !HAL_USE_SPI -#error "25xx enabled but SPI driver is disabled!" -#endif - -#if EEPROM_USE_EE24XX && !HAL_USE_I2C -#error "24xx enabled but I2C driver is disabled!" -#endif - -#define _eeprom_file_config_data \ - /* Lower barrier of file in EEPROM memory array. */ \ - uint32_t barrier_low; \ - /* Higher barrier of file in EEPROM memory array. */ \ - uint32_t barrier_hi; \ - /* Size of memory array in bytes. */ \ - uint32_t size; \ - /* Size of single page in bytes. */ \ - uint16_t pagesize; \ - /* Time needed by IC for single byte/page writing. */ \ - systime_t write_time; - -typedef uint32_t fileoffset_t; - -typedef struct { - _eeprom_file_config_data -} EepromFileConfig; - -/** - * @brief @p EepromFileStream specific data. - */ -#define _eeprom_file_stream_data \ - _base_sequential_stream_data \ - uint32_t errors; \ - uint32_t position; \ - -/** - * @extends BaseFileStreamVMT - * - * @brief @p EepromFileStream virtual methods table. - */ -struct EepromFileStreamVMT { - _file_stream_methods -}; - -/** - * @extends BaseFileStream - * - * @brief EEPROM file stream driver class. - * @details This class extends @p BaseFileStream by adding some fields. - */ -typedef struct { - /** @brief Virtual Methods Table.*/ - const struct EepromFileStreamVMT *vmt; - _eeprom_file_stream_data - /** pointer to config object, must be overwritten by all derived classes.*/ - const EepromFileConfig *cfg; -} EepromFileStream; - -/** - * @brief Low level device descriptor. - */ -typedef struct { - const uint8_t id; - const struct EepromFileStreamVMT *efsvmt; -} EepromDevice; - -const EepromDevice *EepromFindDevice(uint8_t id); - -EepromFileStream *EepromFileOpen(EepromFileStream *efs, - const EepromFileConfig *eepcfg, - const EepromDevice *eepdev); - -uint8_t EepromReadByte(EepromFileStream *efs); -uint16_t EepromReadHalfword(EepromFileStream *efs); -uint32_t EepromReadWord(EepromFileStream *efs); -size_t EepromWriteByte(EepromFileStream *efs, uint8_t data); -size_t EepromWriteHalfword(EepromFileStream *efs, uint16_t data); -size_t EepromWriteWord(EepromFileStream *efs, uint32_t data); - -msg_t eepfs_getsize(void *ip); -msg_t eepfs_getposition(void *ip); -msg_t eepfs_lseek(void *ip, fileoffset_t offset); -msg_t eepfs_close(void *ip); -msg_t eepfs_geterror(void *ip); -msg_t eepfs_put(void *ip, uint8_t b); -msg_t eepfs_get(void *ip); - -#include "ee24xx.h" -#include "ee25xx.h" - -#endif /* #if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM */ -#endif /* __EEPROM_H__ */ diff --git a/os/hal/include/eicu.h b/os/hal/include/eicu.h deleted file mode 100644 index d9e08de..0000000 --- a/os/hal/include/eicu.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - - 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. -*/ -/* - Rewritten by Emil Fresk (1/5 - 2014) for extended input capture - functionality. And fix for spurious callbacks in the interrupt handler. -*/ -/* - Improved by Uladzimir Pylinsky aka barthess (1/3 - 2015) for support of - 32-bit timers and timers with single capture/compare channels. -*/ - -#ifndef _EICU_H_ -#define _EICU_H_ - -#if (HAL_USE_EICU == TRUE) || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - EICU_UNINIT, /* Not initialized. */ - EICU_STOP, /* Stopped. */ - EICU_READY, /* Ready. */ - EICU_WAITING, /* Waiting for first edge. */ - EICU_ACTIVE, /* Active cycle phase. */ - EICU_IDLE /* Idle cycle phase. */ -} eicustate_t; - -/** - * @brief Channel state machine possible states. - */ -typedef enum { - EICU_CH_IDLE, /* Idle cycle phase. */ - EICU_CH_ACTIVE /* Active cycle phase. */ -} eicuchannelstate_t; - -/** - * @brief EICU channel selection definition - */ -typedef enum { - EICU_CHANNEL_1, - EICU_CHANNEL_2, - EICU_CHANNEL_3, - EICU_CHANNEL_4, - EICU_CHANNEL_ENUM_END -} eicuchannel_t; - -/** - * @brief Type of a structure representing an EICU driver. - */ -typedef struct EICUDriver EICUDriver; - -/** - * @brief EICU notification callback type. - * - * @param[in] eicup Pointer to a EICUDriver object - * @param[in] channel EICU channel that fired the interrupt - * @param[in] width Pulse width - * @param[in] period Pulse period - */ -typedef void (*eicucallback_t)(EICUDriver *eicup, eicuchannel_t channel, - uint32_t width, uint32_t period); - -#include "eicu_lld.h" - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/** - * @name Macro Functions - * @{ - */ -/** - * @brief Enables the extended input capture. - * - * @param[in] eicup Pointer to the @p EICUDriver object - * - * @iclass - */ -#define eicuEnableI(eicup) eicu_lld_enable(eicup) - -/** - * @brief Disables the extended input capture. - * - * @param[in] eicup Pointer to the @p EICUDriver object - * - * @iclass - */ -#define eicuDisableI(eicup) eicu_lld_disable(eicup) -/** @} */ - -/** - * @name Low Level driver helper macros - * @{ - */ -/** - * @brief Common ISR code, EICU PWM width event. - * - * @param[in] eicup Pointer to the @p EICUDriver object - * @param[in] channel The timer channel that fired the interrupt. - * - * @notapi - */ -static inline void _eicu_isr_invoke_pwm_width_cb(EICUDriver *eicup, - eicuchannel_t channel) { - if (eicup->state != EICU_WAITING) { - eicup->state = EICU_IDLE; - eicup->config->iccfgp[channel]->capture_cb(eicup, channel, 0, 0); - } -} - -/** - * @brief Common ISR code, EICU PWM period event. - * - * @param[in] eicup Pointer to the @p EICUDriver object - * @param[in] channel The timer channel that fired the interrupt. - * - * @notapi - */ -static inline void _eicu_isr_invoke_pwm_period_cb(EICUDriver *eicup, - eicuchannel_t channel) { - eicustate_t previous_state = eicup->state; - eicup->state = EICU_ACTIVE; - if (previous_state != EICU_WAITING) - eicup->channel[channel].config->capture_cb(eicup, channel, 0, 0); -} - -/** - * @brief Common ISR code, EICU timer overflow event. - * - * @param[in] eicup Pointer to the @p EICUDriver object - * - * @notapi - */ -#define _eicu_isr_invoke_overflow_cb(icup) do { \ - (eicup)->config->overflow_cb(eicup, 0, 0, 0); \ -} while (0) -/** @} */ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void eicuInit(void); - void eicuObjectInit(EICUDriver *eicup); - void eicuStart(EICUDriver *eicup, const EICUConfig *config); - void eicuStop(EICUDriver *eicup); - void eicuEnable(EICUDriver *eicup); - void eicuDisable(EICUDriver *eicup); -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_EICU */ - -#endif /* _EICU_H_ */ - -/** @} */ diff --git a/os/hal/include/hal_community.h b/os/hal/include/hal_community.h index 144e495..6420964 100644 --- a/os/hal/include/hal_community.h +++ b/os/hal/include/hal_community.h @@ -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. */ diff --git a/os/hal/include/hal_crc.h b/os/hal/include/hal_crc.h new file mode 100644 index 0000000..8c4c895 --- /dev/null +++ b/os/hal/include/hal_crc.h @@ -0,0 +1,158 @@ +/* + ChibiOS - Copyright (C) 2015 Michael D. Spradling + + 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 _CRC_H_ +#define _CRC_H_ + +#if (HAL_USE_CRC == TRUE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @name Configuration options + * @{ + */ + +/** + * @brief Enable DMA CRC + * @note Enables DMA when doing CRC calculations. This may be less + * efficient with smaller CRC calculations. + */ +#if !defined(CRC_USE_DMA) || defined(__DOXYGEN__) +#define CRC_USE_DMA FALSE +#endif + +/** + * @brief Enables the @p crcAcquireBus() and @p crcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(CRC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define CRC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +#if STM32_CRC_USE_CRC1 != TRUE && CRCSW_USE_CRC1 != TRUE +#error "CRC requires at least one LLD driver." +#endif + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + CRC_UNINIT, /* Not initialized. */ + CRC_STOP, /* Stopped. */ + CRC_READY, /* Ready. */ + CRC_ACTIVE, /* Calculating CRC. */ + CRC_COMPLETE /* Asynchronous operation complete. */ +} crcstate_t; + +#include "hal_crc_lld.h" +#include "crcsw.h" /* Include software LL driver */ + + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/** + * @name Low level driver helper macros + * @{ + */ + +/** + * @brief Wakes up the waiting thread. + * + * @param[in] crcp pointer to the @p CRCDriver object + * + * @notapi + */ +#define _crc_wakeup_isr(crcp) { \ + osalSysLockFromISR(); \ + osalThreadResumeI(&(crcp)->thread, MSG_OK); \ + osalSysUnlockFromISR(); \ +} + +/** + * @brief Common ISR code. + * @details This code handles the portable part of the ISR code: + * - Callback invocation. + * - Waiting thread wakeup, if any. + * - Driver state transitions. + * . + * @note This macro is meant to be used in the low level drivers + * implementation only. + * + * @param[in] crcp pointer to the @p CRCDriver object + * + * @notapi + */ +#define _crc_isr_code(crcp, crc) { \ + if ((crcp)->config->end_cb) { \ + (crcp)->state = CRC_COMPLETE; \ + (crcp)->config->end_cb(crcp, crc); \ + if ((crcp)->state == CRC_COMPLETE) \ + (crcp)->state = CRC_READY; \ + } \ + else \ + (crcp)->state = CRC_READY; \ + _crc_wakeup_isr(crcp); \ +} + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void crcInit(void); + void crcObjectInit(CRCDriver *crcp); + void crcStart(CRCDriver *crcp, const CRCConfig *config); + void crcStop(CRCDriver *crcp); + void crcReset(CRCDriver *crcp); + void crcResetI(CRCDriver *crcp); + uint32_t crcCalc(CRCDriver *crcp, size_t n, const void *buf); + uint32_t crcCalcI(CRCDriver *crcp, size_t n, const void *buf); +#if CRC_USE_DMA == TRUE + void crcStartCalc(CRCDriver *crcp, size_t n, const void *buf); + void crcStartCalcI(CRCDriver *crcp, size_t n, const void *buf); +#endif +#if CRC_USE_MUTUAL_EXCLUSION == TRUE + void crcAcquireUnit(CRCDriver *crcp); + void crcReleaseUnit(CRCDriver *crcp); +#endif +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_CRC */ + +#endif /* _CRC_H_ */ + +/** @} */ diff --git a/os/hal/include/hal_ee24xx.h b/os/hal/include/hal_ee24xx.h new file mode 100644 index 0000000..ab12fd1 --- /dev/null +++ b/os/hal/include/hal_ee24xx.h @@ -0,0 +1,64 @@ +/* + Copyright 2012 Uladzimir Pylinski aka barthess. + You may use this work without restrictions, as long as this notice is included. + The work is provided "as is" without warranty of any kind, neither express nor implied. +*/ + +#ifndef EE24XX_H +#define EE24XX_H + +#include "hal.h" + +#if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE24XX + +#define EEPROM_DEV_24XX 24 + +/** + * @extends EepromFileConfig + */ +typedef struct { + _eeprom_file_config_data + /** + * Driver connected to IC. + */ + I2CDriver *i2cp; + /** + * Address of IC on I2C bus. + */ + i2caddr_t addr; + /** + * Pointer to write buffer. The safest size is (pagesize + 2) + */ + uint8_t *write_buf; +} I2CEepromFileConfig; + +/** + * @brief @p I2CEepromFileStream specific data. + */ +#define _eeprom_file_stream_data_i2c \ + _eeprom_file_stream_data + +/** + * @extends EepromFileStream + * + * @brief EEPROM file stream driver class for I2C device. + */ +typedef struct { + const struct EepromFileStreamVMT *vmt; + _eeprom_file_stream_data_i2c + /* Overwritten parent data member. */ + const I2CEepromFileConfig *cfg; +} I2CEepromFileStream; + + +/** + * Open I2C EEPROM IC as file and return pointer to the file stream object + * @note Fucntion allways successfully open file. All checking makes + * in read/write functions. + */ +#define I2CEepromFileOpen(efs, eepcfg, eepdev) \ + EepromFileOpen((EepromFileStream *)efs, (EepromFileConfig *)eepcfg, eepdev); + +#endif /* #if defined(EEPROM_USE_EE24XX) && EEPROM_USE_EE24XX */ + +#endif // EE24XX_H diff --git a/os/hal/include/hal_ee25xx.h b/os/hal/include/hal_ee25xx.h new file mode 100644 index 0000000..fc2ad6f --- /dev/null +++ b/os/hal/include/hal_ee25xx.h @@ -0,0 +1,63 @@ +/* + Copyright 2012 Uladzimir Pylinski aka barthess. + You may use this work without restrictions, as long as this notice is included. + The work is provided "as is" without warranty of any kind, neither express nor implied. +*/ + +#ifndef EE25XX_H +#define EE25XX_H + +#include "hal.h" + +#if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM && EEPROM_USE_EE25XX + +#define EEPROM_DEV_25XX 25 + +/** + * @extends EepromFileConfig + */ +typedef struct { + _eeprom_file_config_data + /** + * Driver connected to IC. + */ + SPIDriver *spip; + /** + * Config associated with SPI driver. + */ + const SPIConfig *spicfg; +} SPIEepromFileConfig; + +/** + * @brief @p SPIEepromFileStream specific data. + */ +#define _eeprom_file_stream_data_spi \ + _eeprom_file_stream_data + +/** + * @extends EepromFileStream + * + * @brief EEPROM file stream driver class for SPI device. + */ +typedef struct { + const struct EepromFileStreamVMT *vmt; + _eeprom_file_stream_data_spi + /* Overwritten parent data member. */ + const SPIEepromFileConfig *cfg; +} SPIEepromFileStream; + +/** + * Open SPI EEPROM IC as file and return pointer to the file stream object + * @note Fucntion allways successfully open file. All checking makes + * in read/write functions. + */ +EepromFileStream *SPIEepromFileOpen(SPIEepromFileStream *efs, + const SPIEepromFileConfig *eepcfg, + const EepromDevice *eepdev); + +#define SPIEepromFileOpen(efs, eepcfg, eepdev) \ + EepromFileOpen((EepromFileStream *)efs, (EepromFileConfig *)eepcfg, eepdev); + +#endif /* #if defined(EEPROM_USE_EE25XX) && EEPROM_USE_EE25XX */ + +#endif // EE25XX_H diff --git a/os/hal/include/hal_eeprom.h b/os/hal/include/hal_eeprom.h new file mode 100644 index 0000000..b0fd360 --- /dev/null +++ b/os/hal/include/hal_eeprom.h @@ -0,0 +1,147 @@ +/* + Copyright (c) 2013 Timon Wong + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/* + Copyright 2012 Uladzimir Pylinski aka barthess. + You may use this work without restrictions, as long as this notice is included. + The work is provided "as is" without warranty of any kind, neither express nor implied. +*/ + +#ifndef __EEPROM_H__ +#define __EEPROM_H__ + +#include "ch.h" +#include "hal.h" + +#ifndef HAL_USE_EEPROM +#define HAL_USE_EEPROM FALSE +#endif + +#ifndef EEPROM_USE_EE25XX +#define EEPROM_USE_EE25XX FALSE +#endif + +#ifndef EEPROM_USE_EE24XX +#define EEPROM_USE_EE24XX FALSE +#endif + +#if HAL_USE_EEPROM + +#if EEPROM_USE_EE25XX && EEPROM_USE_EE24XX +#define EEPROM_TABLE_SIZE 2 +#elif EEPROM_USE_EE25XX || EEPROM_USE_EE24XX +#define EEPROM_TABLE_SIZE 1 +#else +#error "No EEPROM device selected!" +#endif + +#if EEPROM_USE_EE25XX && !HAL_USE_SPI +#error "25xx enabled but SPI driver is disabled!" +#endif + +#if EEPROM_USE_EE24XX && !HAL_USE_I2C +#error "24xx enabled but I2C driver is disabled!" +#endif + +#define _eeprom_file_config_data \ + /* Lower barrier of file in EEPROM memory array. */ \ + uint32_t barrier_low; \ + /* Higher barrier of file in EEPROM memory array. */ \ + uint32_t barrier_hi; \ + /* Size of memory array in bytes. */ \ + uint32_t size; \ + /* Size of single page in bytes. */ \ + uint16_t pagesize; \ + /* Time needed by IC for single byte/page writing. */ \ + systime_t write_time; + +typedef uint32_t fileoffset_t; + +typedef struct { + _eeprom_file_config_data +} EepromFileConfig; + +/** + * @brief @p EepromFileStream specific data. + */ +#define _eeprom_file_stream_data \ + _base_sequential_stream_data \ + uint32_t errors; \ + uint32_t position; \ + +/** + * @extends BaseFileStreamVMT + * + * @brief @p EepromFileStream virtual methods table. + */ +struct EepromFileStreamVMT { + _file_stream_methods +}; + +/** + * @extends BaseFileStream + * + * @brief EEPROM file stream driver class. + * @details This class extends @p BaseFileStream by adding some fields. + */ +typedef struct { + /** @brief Virtual Methods Table.*/ + const struct EepromFileStreamVMT *vmt; + _eeprom_file_stream_data + /** pointer to config object, must be overwritten by all derived classes.*/ + const EepromFileConfig *cfg; +} EepromFileStream; + +/** + * @brief Low level device descriptor. + */ +typedef struct { + const uint8_t id; + const struct EepromFileStreamVMT *efsvmt; +} EepromDevice; + +const EepromDevice *EepromFindDevice(uint8_t id); + +EepromFileStream *EepromFileOpen(EepromFileStream *efs, + const EepromFileConfig *eepcfg, + const EepromDevice *eepdev); + +uint8_t EepromReadByte(EepromFileStream *efs); +uint16_t EepromReadHalfword(EepromFileStream *efs); +uint32_t EepromReadWord(EepromFileStream *efs); +size_t EepromWriteByte(EepromFileStream *efs, uint8_t data); +size_t EepromWriteHalfword(EepromFileStream *efs, uint16_t data); +size_t EepromWriteWord(EepromFileStream *efs, uint32_t data); + +msg_t eepfs_getsize(void *ip); +msg_t eepfs_getposition(void *ip); +msg_t eepfs_lseek(void *ip, fileoffset_t offset); +msg_t eepfs_close(void *ip); +msg_t eepfs_geterror(void *ip); +msg_t eepfs_put(void *ip, uint8_t b); +msg_t eepfs_get(void *ip); + +#include "ee24xx.h" +#include "ee25xx.h" + +#endif /* #if defined(HAL_USE_EEPROM) && HAL_USE_EEPROM */ +#endif /* __EEPROM_H__ */ diff --git a/os/hal/include/hal_eicu.h b/os/hal/include/hal_eicu.h new file mode 100644 index 0000000..d4b0ed2 --- /dev/null +++ b/os/hal/include/hal_eicu.h @@ -0,0 +1,191 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + + 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. +*/ +/* + Rewritten by Emil Fresk (1/5 - 2014) for extended input capture + functionality. And fix for spurious callbacks in the interrupt handler. +*/ +/* + Improved by Uladzimir Pylinsky aka barthess (1/3 - 2015) for support of + 32-bit timers and timers with single capture/compare channels. +*/ + +#ifndef _EICU_H_ +#define _EICU_H_ + +#if (HAL_USE_EICU == TRUE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + EICU_UNINIT, /* Not initialized. */ + EICU_STOP, /* Stopped. */ + EICU_READY, /* Ready. */ + EICU_WAITING, /* Waiting for first edge. */ + EICU_ACTIVE, /* Active cycle phase. */ + EICU_IDLE /* Idle cycle phase. */ +} eicustate_t; + +/** + * @brief Channel state machine possible states. + */ +typedef enum { + EICU_CH_IDLE, /* Idle cycle phase. */ + EICU_CH_ACTIVE /* Active cycle phase. */ +} eicuchannelstate_t; + +/** + * @brief EICU channel selection definition + */ +typedef enum { + EICU_CHANNEL_1, + EICU_CHANNEL_2, + EICU_CHANNEL_3, + EICU_CHANNEL_4, + EICU_CHANNEL_ENUM_END +} eicuchannel_t; + +/** + * @brief Type of a structure representing an EICU driver. + */ +typedef struct EICUDriver EICUDriver; + +/** + * @brief EICU notification callback type. + * + * @param[in] eicup Pointer to a EICUDriver object + * @param[in] channel EICU channel that fired the interrupt + * @param[in] width Pulse width + * @param[in] period Pulse period + */ +typedef void (*eicucallback_t)(EICUDriver *eicup, eicuchannel_t channel, + uint32_t width, uint32_t period); + +#include "hal_eicu_lld.h" + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/** + * @name Macro Functions + * @{ + */ +/** + * @brief Enables the extended input capture. + * + * @param[in] eicup Pointer to the @p EICUDriver object + * + * @iclass + */ +#define eicuEnableI(eicup) eicu_lld_enable(eicup) + +/** + * @brief Disables the extended input capture. + * + * @param[in] eicup Pointer to the @p EICUDriver object + * + * @iclass + */ +#define eicuDisableI(eicup) eicu_lld_disable(eicup) +/** @} */ + +/** + * @name Low Level driver helper macros + * @{ + */ +/** + * @brief Common ISR code, EICU PWM width event. + * + * @param[in] eicup Pointer to the @p EICUDriver object + * @param[in] channel The timer channel that fired the interrupt. + * + * @notapi + */ +static inline void _eicu_isr_invoke_pwm_width_cb(EICUDriver *eicup, + eicuchannel_t channel) { + if (eicup->state != EICU_WAITING) { + eicup->state = EICU_IDLE; + eicup->config->iccfgp[channel]->capture_cb(eicup, channel, 0, 0); + } +} + +/** + * @brief Common ISR code, EICU PWM period event. + * + * @param[in] eicup Pointer to the @p EICUDriver object + * @param[in] channel The timer channel that fired the interrupt. + * + * @notapi + */ +static inline void _eicu_isr_invoke_pwm_period_cb(EICUDriver *eicup, + eicuchannel_t channel) { + eicustate_t previous_state = eicup->state; + eicup->state = EICU_ACTIVE; + if (previous_state != EICU_WAITING) + eicup->channel[channel].config->capture_cb(eicup, channel, 0, 0); +} + +/** + * @brief Common ISR code, EICU timer overflow event. + * + * @param[in] eicup Pointer to the @p EICUDriver object + * + * @notapi + */ +#define _eicu_isr_invoke_overflow_cb(icup) do { \ + (eicup)->config->overflow_cb(eicup, 0, 0, 0); \ +} while (0) +/** @} */ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void eicuInit(void); + void eicuObjectInit(EICUDriver *eicup); + void eicuStart(EICUDriver *eicup, const EICUConfig *config); + void eicuStop(EICUDriver *eicup); + void eicuEnable(EICUDriver *eicup); + void eicuDisable(EICUDriver *eicup); +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_EICU */ + +#endif /* _EICU_H_ */ + +/** @} */ diff --git a/os/hal/include/hal_nand.h b/os/hal/include/hal_nand.h new file mode 100644 index 0000000..d5a1c04 --- /dev/null +++ b/os/hal/include/hal_nand.h @@ -0,0 +1,137 @@ +/* + ChibiOS/RT - Copyright (C) 2014 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 nand.h + * @brief NAND Driver macros and structures. + * + * @addtogroup NAND + * @{ + */ + +#ifndef _NAND_H_ +#define _NAND_H_ + +#if (HAL_USE_NAND == TRUE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/* + * Standard NAND flash commands + */ +#define NAND_CMD_READ0 0x00 +#define NAND_CMD_RNDOUT 0x05 +#define NAND_CMD_PAGEPROG 0x10 +#define NAND_CMD_READ0_CONFIRM 0x30 +#define NAND_CMD_READOOB 0x50 +#define NAND_CMD_ERASE 0x60 +#define NAND_CMD_STATUS 0x70 +#define NAND_CMD_STATUS_MULTI 0x71 +#define NAND_CMD_WRITE 0x80 +#define NAND_CMD_RNDIN 0x85 +#define NAND_CMD_READID 0x90 +#define NAND_CMD_ERASE_CONFIRM 0xD0 +#define NAND_CMD_RESET 0xFF + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ +/** + * @brief Enables the mutual exclusion APIs on the NAND. + */ +#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define NAND_USE_MUTUAL_EXCLUSION FALSE +#endif + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ +#if NAND_USE_MUTUAL_EXCLUSION && !CH_CFG_USE_MUTEXES && !CH_CFG_USE_SEMAPHORES +#error "NAND_USE_MUTUAL_EXCLUSION requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES" +#endif + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + NAND_UNINIT = 0, /**< Not initialized. */ + NAND_STOP = 1, /**< Stopped. */ + NAND_READY = 2, /**< Ready. */ + NAND_PROGRAM = 3, /**< Programming in progress. */ + NAND_ERASE = 4, /**< Erasing in progress. */ + NAND_WRITE = 5, /**< Writing to NAND buffer. */ + NAND_READ = 6, /**< Reading from NAND. */ + NAND_DMA_TX = 7, /**< DMA transmitting. */ + NAND_DMA_RX = 8, /**< DMA receiving. */ +} nandstate_t; + +/** + * @brief Type of a structure representing a NAND driver. + */ +typedef struct NANDDriver NANDDriver; + +#include "hal_nand_lld.h" + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void nandInit(void); + void nandObjectInit(NANDDriver *nandp); + void nandStart(NANDDriver *nandp, const NANDConfig *config, bitmap_t *bb_map); + void nandStop(NANDDriver *nandp); + void nandReadPageWhole(NANDDriver *nandp, uint32_t block, uint32_t page, + uint8_t *data, size_t datalen); + void nandMarkBad(NANDDriver *nandp, uint32_t block); + void nandReadPageData(NANDDriver *nandp, uint32_t block, uint32_t page, + uint8_t *data, size_t datalen, uint32_t *ecc); + void nandReadPageSpare(NANDDriver *nandp, uint32_t block, uint32_t page, + uint8_t *spare, size_t sparelen); + uint8_t nandWritePageWhole(NANDDriver *nandp, uint32_t block, uint32_t page, + const uint8_t *data, size_t datalen); + uint8_t nandWritePageData(NANDDriver *nandp, uint32_t block, uint32_t page, + const uint8_t *data, size_t datalen, uint32_t *ecc); + uint8_t nandWritePageSpare(NANDDriver *nandp, uint32_t block, uint32_t page, + const uint8_t *spare, size_t sparelen); + uint8_t nandReadBadMark(NANDDriver *nandp, uint32_t block, uint32_t page); + uint8_t nandErase(NANDDriver *nandp, uint32_t block); + bool nandIsBad(NANDDriver *nandp, uint32_t block); +#if NAND_USE_MUTUAL_EXCLUSION + void nandAcquireBus(NANDDriver *nandp); + void nandReleaseBus(NANDDriver *nandp); +#endif /* NAND_USE_MUTUAL_EXCLUSION */ +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_NAND */ + +#endif /* _NAND_H_ */ + +/** @} */ diff --git a/os/hal/include/hal_onewire.h b/os/hal/include/hal_onewire.h new file mode 100644 index 0000000..2d27f48 --- /dev/null +++ b/os/hal/include/hal_onewire.h @@ -0,0 +1,366 @@ +/* + ChibiOS/RT - Copyright (C) 2014 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 onewire.h + * @brief 1-wire Driver macros and structures. + * + * @addtogroup onewire + * @{ + */ + +#ifndef _ONEWIRE_H_ +#define _ONEWIRE_H_ + +#if (HAL_USE_ONEWIRE == TRUE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ +/** + * @brief Enable synthetic test for 'search ROM' procedure. + * @note Only for debugging/testing! + */ +#define ONEWIRE_SYNTH_SEARCH_TEST FALSE + +/** + * @brief Aliases for 1-wire protocol. + */ +#define ONEWIRE_CMD_READ_ROM 0x33 +#define ONEWIRE_CMD_SEARCH_ROM 0xF0 +#define ONEWIRE_CMD_MATCH_ROM 0x55 +#define ONEWIRE_CMD_SKIP_ROM 0xCC +#define ONEWIRE_CMD_CONVERT_TEMP 0x44 +#define ONEWIRE_CMD_READ_SCRATCHPAD 0xBE + +/** + * @brief How many bits will be used for transaction length storage. + */ +#define ONEWIRE_REG_BYTES_WIDTH 16U + +/** + * @brief Precalculated maximum transaction length. + */ +#define ONEWIRE_MAX_TRANSACTION_LEN ((1U << ONEWIRE_REG_BYTES_WIDTH) - 1U) + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +#if !HAL_USE_PWM +#error "1-wire Driver requires HAL_USE_PWM" +#endif + +#if !HAL_USE_PAL +#error "1-wire Driver requires HAL_USE_PAL" +#endif + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ +#if ONEWIRE_USE_STRONG_PULLUP +/** + * @brief 1-wire strong pull up assert callback type. + */ +typedef void (*onewire_pullup_assert_t)(void); + +/** + * @brief 1-wire strong pull up release callback type. + */ +typedef void (*onewire_pullup_release_t)(void); +#endif /* ONEWIRE_USE_STRONG_PULLUP */ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + ONEWIRE_UNINIT = 0, /**< Not initialized. */ + ONEWIRE_STOP = 1, /**< Stopped. */ + ONEWIRE_READY = 2, /**< Ready. */ +#if ONEWIRE_USE_STRONG_PULLUP + ONEWIRE_PULL_UP /**< Pull up asserted. */ +#endif +} onewire_state_t; + +#if ONEWIRE_USE_SEARCH_ROM +/** + * @brief Search ROM procedure possible state. + */ +typedef enum { + ONEWIRE_SEARCH_ROM_SUCCESS = 0, /**< ROM successfully discovered. */ + ONEWIRE_SEARCH_ROM_LAST = 1, /**< Last ROM successfully discovered. */ + ONEWIRE_SEARCH_ROM_ERROR = 2 /**< Error happened during search. */ +} search_rom_result_t; + +/** + * @brief Search ROM procedure iteration enum. + */ +typedef enum { + ONEWIRE_SEARCH_ROM_FIRST = 0, /**< First search run. */ + ONEWIRE_SEARCH_ROM_NEXT = 1 /**< Next search run. */ +} search_iteration_t; +#endif /* ONEWIRE_USE_SEARCH_ROM */ + +/** + * @brief Driver configuration structure. + */ +typedef struct { + /** + * @brief Pointer to @p PWM driver used for communication. + */ + PWMDriver *pwmd; + /** + * @brief Pointer to configuration structure for underlying PWM driver. + * @note It is NOT constant because 1-wire driver needs to change them + * during normal functioning. + */ + PWMConfig *pwmcfg; + /** + * @brief Active logic level for master channel. + * @details Just set it to @p PWM_OUTPUT_ACTIVE_LOW when 1-wire bus + * connected to direct (not complementary) output of the timer. + * In opposite case you need to check documentation to choose + * correct value. + */ + pwmmode_t pwmmode; + /** + * @brief Number of PWM channel used as master pulse generator. + */ + size_t master_channel; + /** + * @brief Number of PWM channel used as sample interrupt generator. + */ + size_t sample_channel; + /** + * @brief Port Identifier. + * @details This type can be a scalar or some kind of pointer, do not make + * any assumption about it, use the provided macros when populating + * variables of this type. + */ + ioportid_t port; + /** + * @brief Digital I/O port pad. + */ + ioportmask_t pad; +#if defined(STM32F1XX) + /** + * @brief Digital I/O mode for idle bus. + * @details This is a kind of workaround against F1x realization of alternate + * function. Alternate function mode will be activated only + * when you starts appropriate peripheral. + */ + iomode_t pad_mode_idle; +#endif + /** + * @brief Digital I/O mode for active bus. + */ + iomode_t pad_mode_active; +#if ONEWIRE_USE_STRONG_PULLUP + /** + * @brief Pointer to function asserting of strong pull up. + */ + onewire_pullup_assert_t pullup_assert; + /** + * @brief Pointer to function releasing of strong pull up. + */ + onewire_pullup_release_t pullup_release; +#endif +} onewireConfig; + +#if ONEWIRE_USE_SEARCH_ROM +/** + * @brief Search ROM registry. Contains small variables used + * in 'search ROM' procedure. + */ +typedef struct { + /** + * @brief Bool flag. True when bus has single slave device. + */ + uint32_t single_device: 1; + /** + * @brief Search iteration (@p search_iteration_t enum). + */ + uint32_t search_iter: 1; + /** + * @brief Result of discovery procedure (@p search_rom_result_t enum). + */ + uint32_t result: 2; + /** + * @brief One of 3 steps of bit discovery. + * @details 0 - direct, 1 - complemented, 2 - generated by master. + */ + uint32_t bit_step: 2; + /** + * @brief Values acquired during bit discovery. + */ + uint32_t bit_buf: 2; + /** + * @brief Currently processing ROM bit. + * @note Must be big enough to store number 64. + */ + uint32_t rombit: 7; + /** + * @brief Total device count discovered on bus. + * @note Maximum 256. + */ + uint32_t devices_found: 8; +} search_rom_reg_t; + +/** + * @brief Helper structure for 'search ROM' procedure + */ +typedef struct { + /** + * @brief Search ROM registry. + */ + search_rom_reg_t reg; + /** + * @brief Pointer to buffer with currently discovering ROM + */ + uint8_t *retbuf; + /** + * @brief Previously discovered ROM. + */ + uint8_t prev_path[8]; + /** + * @brief Last zero turn branch. + * @note Negative values use to point out of device tree's root. + */ + int8_t last_zero_branch; + /** + * @brief Previous zero turn branch. + * @note Negative values use to point out of device tree's root. + */ + int8_t prev_zero_branch; +} onewire_search_rom_t; +#endif /* ONEWIRE_USE_SEARCH_ROM */ + +/** + * @brief Onewire registry. Some small variables combined + * in single machine word to save RAM. + */ +typedef struct { +#if ONEWIRE_USE_STRONG_PULLUP + /** + * @brief This flag will be asserted by driver to signalizes + * ISR part when strong pull up needed. + */ + uint32_t need_pullup: 1; +#endif + /** + * @brief Bool flag. If @p true than at least one device presence on bus. + */ + uint32_t slave_present: 1; + /** + * @brief Driver internal state (@p onewire_state_t enum). + */ + uint32_t state: 2; + /** + * @brief Bit number in currently receiving/sending byte. + * @note Must be big enough to store 8. + */ + uint32_t bit: 4; + /** + * @brief Bool flag for premature timer stop prevention. + */ + uint32_t final_timeslot: 1; + /** + * @brief Bytes number to be processing in current transaction. + */ + uint32_t bytes: ONEWIRE_REG_BYTES_WIDTH; +} onewire_reg_t; + +/** + * @brief Structure representing an 1-wire driver. + */ +typedef struct { + /** + * @brief Onewire registry. + */ + onewire_reg_t reg; + /** + * @brief Onewire config. + */ + const onewireConfig *config; + /** + * @brief Pointer to I/O data buffer. + */ + uint8_t *buf; +#if ONEWIRE_USE_SEARCH_ROM + /** + * @brief Search ROM helper structure. + */ + onewire_search_rom_t search_rom; +#endif /* ONEWIRE_USE_SEARCH_ROM */ + /** + * @brief Thread waiting for I/O completion. + */ + thread_reference_t thread; +} onewireDriver; + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +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); + bool onewireReset(onewireDriver *owp); + void onewireRead(onewireDriver *owp, uint8_t *rxbuf, size_t rxbytes); + uint8_t onewireCRC(const uint8_t *buf, size_t len); + void onewireWrite(onewireDriver *owp, uint8_t *txbuf, + size_t txbytes, systime_t pullup_time); +#if ONEWIRE_USE_SEARCH_ROM + size_t onewireSearchRom(onewireDriver *owp, + uint8_t *result, size_t max_rom_cnt); +#endif /* ONEWIRE_USE_SEARCH_ROM */ +#if ONEWIRE_SYNTH_SEARCH_TEST + void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit); + uint_fast8_t _synth_ow_read_bit(void); + void synthSearchRomTest(onewireDriver *owp); +#endif /* ONEWIRE_SYNTH_SEARCH_TEST */ +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_ONEWIRE */ + +#endif /* _ONEWIRE_H_ */ + +/** @} */ + + + + + + + + + diff --git a/os/hal/include/hal_rng.h b/os/hal/include/hal_rng.h new file mode 100644 index 0000000..4730f7b --- /dev/null +++ b/os/hal/include/hal_rng.h @@ -0,0 +1,136 @@ +/* + RNG for ChibiOS - Copyright (C) 2016 Stephane D'Alu + + 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 _RNG_H_ +#define _RNG_H_ + +#if (HAL_USE_RNG == TRUE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @name Configuration options + * @{ + */ + +/** + * @brief Enables the @p rngAcquireBus() and @p rngReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(RNG_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define RNG_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + RNG_UNINIT, /* Not initialized. */ + RNG_STOP, /* Stopped. */ + RNG_READY, /* Ready. */ +} rngstate_t; + +#include "rng_lld.h" + + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/** + * @name Low level driver helper macros + * @{ + */ + +/** + * @brief Wakes up the waiting thread. + * + * @param[in] rngp pointer to the @p RNGDriver object + * + * @notapi + */ +#define _rng_wakeup_isr(rngp) { \ + osalSysLockFromISR(); \ + osalThreadResumeI(&(rngp)->thread, MSG_OK); \ + osalSysUnlockFromISR(); \ +} + +/** + * @brief Common ISR code. + * @details This code handles the portable part of the ISR code: + * - Callback invocation. + * - Waiting thread wakeup, if any. + * - Driver state transitions. + * . + * @note This macro is meant to be used in the low level drivers + * implementation only. + * + * @param[in] rngp pointer to the @p RNGDriver object + * + * @notapi + */ +#define _rng_isr_code(rngp, rng) { \ + if ((rngp)->config->end_cb) { \ + (rngp)->state = RNG_COMPLETE; \ + (rngp)->config->end_cb(rngp, rng); \ + if ((rngp)->state == RNG_COMPLETE) \ + (rngp)->state = RNG_READY; \ + } \ + else \ + (rngp)->state = RNG_READY; \ + _rng_wakeup_isr(rngp); \ +} + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void rngInit(void); + void rngObjectInit(RNGDriver *rngp); + void rngStart(RNGDriver *rngp, const RNGConfig *config); + void rngStop(RNGDriver *rngp); + msg_t rngWriteI(RNGDriver *rngp, uint8_t *buf, size_t n, systime_t timeout); + msg_t rngWrite(RNGDriver *rngp, uint8_t *buf, size_t n, systime_t timeout); +#if RNG_USE_MUTUAL_EXCLUSION == TRUE + void rngAcquireUnit(RNGDriver *rngp); + void rngReleaseUnit(RNGDriver *rngp); +#endif +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_RNG */ + +#endif /* _RNG_H_ */ + +/** @} */ diff --git a/os/hal/include/hal_timcap.h b/os/hal/include/hal_timcap.h new file mode 100644 index 0000000..a848783 --- /dev/null +++ b/os/hal/include/hal_timcap.h @@ -0,0 +1,210 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012,2013 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file timcap.h + * @brief TIMCAP Driver macros and structures. + * + * @addtogroup TIMCAP + * @{ + */ + +#ifndef _TIMCAP_H_ +#define _TIMCAP_H_ + +#include "ch.h" +#include "hal.h" + +#ifndef HAL_USE_TIMCAP +#define HAL_USE_TIMCAP FALSE +#endif + +#if HAL_USE_TIMCAP || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Driver state machine possible states. + */ +typedef enum { + TIMCAP_UNINIT = 0, /**< Not initialized. */ + TIMCAP_STOP = 1, /**< Stopped. */ + TIMCAP_READY = 2, /**< Ready. */ + TIMCAP_WAITING = 3, /**< Waiting first edge. */ + TIMCAP_ACTIVE = 4, /**< Active cycle phase. */ + TIMCAP_IDLE = 5, /**< Idle cycle phase. */ +} timcapstate_t; + +/** + * @brief Type of a structure representing an TIMCAP driver. + */ +typedef struct TIMCAPDriver TIMCAPDriver; + + +/** + * @brief TIMCAP notification callback type. + * + * @param[in] timcapp pointer to a @p TIMCAPDriver object + */ +typedef void (*timcapcallback_t)(TIMCAPDriver *timcapp); + +#include "timcap_lld.h" + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/** + * @name Macro Functions + * @{ + */ +/** + * @brief Enables the input capture. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @iclass + */ +#define timcapEnableI(timcapp) timcap_lld_enable(timcapp) + +/** + * @brief Disables the input capture. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @iclass + */ +#define timcapDisableI(timcapp) timcap_lld_disable(timcapp) + + + + +/** @} */ + +/** + * @name Low Level driver helper macros + * @{ + */ + + +/** + * @brief Common ISR code, TIMCAP channel 1 event. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @notapi + */ +#define _timcap_isr_invoke_channel1_cb(timcapp) { \ + timcapstate_t previous_state = (timcapp)->state; \ + (timcapp)->state = TIMCAP_ACTIVE; \ + if (previous_state != TIMCAP_WAITING) \ + (timcapp)->config->capture_cb_array[0](timcapp); \ +} + +/** + * @brief Common ISR code, TIMCAP channel 2 event. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @notapi + */ +#define _timcap_isr_invoke_channel2_cb(timcapp) { \ + timcapstate_t previous_state = (timcapp)->state; \ + (timcapp)->state = TIMCAP_ACTIVE; \ + if (previous_state != TIMCAP_WAITING) \ + (timcapp)->config->capture_cb_array[1](timcapp); \ +} + +/** + * @brief Common ISR code, TIMCAP channel 3 event. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @notapi + */ +#define _timcap_isr_invoke_channel3_cb(timcapp) { \ + timcapstate_t previous_state = (timcapp)->state; \ + (timcapp)->state = TIMCAP_ACTIVE; \ + if (previous_state != TIMCAP_WAITING) \ + (timcapp)->config->capture_cb_array[2](timcapp); \ +} + +/** + * @brief Common ISR code, TIMCAP channel 4 event. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @notapi + */ +#define _timcap_isr_invoke_channel4_cb(timcapp) { \ + timcapstate_t previous_state = (timcapp)->state; \ + (timcapp)->state = TIMCAP_ACTIVE; \ + if (previous_state != TIMCAP_WAITING) \ + (timcapp)->config->capture_cb_array[3](timcapp); \ +} + +/** + * @brief Common ISR code, TIMCAP timer overflow event. + * + * @param[in] timcapp pointer to the @p TIMCAPDriver object + * + * @notapi + */ +#define _timcap_isr_invoke_overflow_cb(timcapp) { \ + (timcapp)->config->overflow_cb(timcapp); \ +} +/** @} */ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void timcapInit(void); + void timcapObjectInit(TIMCAPDriver *timcapp); + void timcapStart(TIMCAPDriver *timcapp, const TIMCAPConfig *config); + void timcapStop(TIMCAPDriver *timcapp); + void timcapEnable(TIMCAPDriver *timcapp); + void timcapDisable(TIMCAPDriver *timcapp); +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TIMCAP */ + +#endif /* _TIMCAP_H_ */ + +/** @} */ diff --git a/os/hal/include/hal_usbh.h b/os/hal/include/hal_usbh.h new file mode 100644 index 0000000..8029be8 --- /dev/null +++ b/os/hal/include/hal_usbh.h @@ -0,0 +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 "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 /* descriptor iterators */ +#include /* debug */ + +#endif + +#endif /* USBH_H_ */ diff --git a/os/hal/include/nand.h b/os/hal/include/nand.h deleted file mode 100644 index ffd5de7..0000000 --- a/os/hal/include/nand.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2014 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 nand.h - * @brief NAND Driver macros and structures. - * - * @addtogroup NAND - * @{ - */ - -#ifndef _NAND_H_ -#define _NAND_H_ - -#if (HAL_USE_NAND == TRUE) || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/* - * Standard NAND flash commands - */ -#define NAND_CMD_READ0 0x00 -#define NAND_CMD_RNDOUT 0x05 -#define NAND_CMD_PAGEPROG 0x10 -#define NAND_CMD_READ0_CONFIRM 0x30 -#define NAND_CMD_READOOB 0x50 -#define NAND_CMD_ERASE 0x60 -#define NAND_CMD_STATUS 0x70 -#define NAND_CMD_STATUS_MULTI 0x71 -#define NAND_CMD_WRITE 0x80 -#define NAND_CMD_RNDIN 0x85 -#define NAND_CMD_READID 0x90 -#define NAND_CMD_ERASE_CONFIRM 0xD0 -#define NAND_CMD_RESET 0xFF - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ -/** - * @brief Enables the mutual exclusion APIs on the NAND. - */ -#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define NAND_USE_MUTUAL_EXCLUSION FALSE -#endif - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ -#if NAND_USE_MUTUAL_EXCLUSION && !CH_CFG_USE_MUTEXES && !CH_CFG_USE_SEMAPHORES -#error "NAND_USE_MUTUAL_EXCLUSION requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES" -#endif - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - NAND_UNINIT = 0, /**< Not initialized. */ - NAND_STOP = 1, /**< Stopped. */ - NAND_READY = 2, /**< Ready. */ - NAND_PROGRAM = 3, /**< Programming in progress. */ - NAND_ERASE = 4, /**< Erasing in progress. */ - NAND_WRITE = 5, /**< Writing to NAND buffer. */ - NAND_READ = 6, /**< Reading from NAND. */ - NAND_DMA_TX = 7, /**< DMA transmitting. */ - NAND_DMA_RX = 8, /**< DMA receiving. */ -} nandstate_t; - -/** - * @brief Type of a structure representing a NAND driver. - */ -typedef struct NANDDriver NANDDriver; - -#include "nand_lld.h" - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void nandInit(void); - void nandObjectInit(NANDDriver *nandp); - void nandStart(NANDDriver *nandp, const NANDConfig *config, bitmap_t *bb_map); - void nandStop(NANDDriver *nandp); - void nandReadPageWhole(NANDDriver *nandp, uint32_t block, uint32_t page, - uint8_t *data, size_t datalen); - void nandMarkBad(NANDDriver *nandp, uint32_t block); - void nandReadPageData(NANDDriver *nandp, uint32_t block, uint32_t page, - uint8_t *data, size_t datalen, uint32_t *ecc); - void nandReadPageSpare(NANDDriver *nandp, uint32_t block, uint32_t page, - uint8_t *spare, size_t sparelen); - uint8_t nandWritePageWhole(NANDDriver *nandp, uint32_t block, uint32_t page, - const uint8_t *data, size_t datalen); - uint8_t nandWritePageData(NANDDriver *nandp, uint32_t block, uint32_t page, - const uint8_t *data, size_t datalen, uint32_t *ecc); - uint8_t nandWritePageSpare(NANDDriver *nandp, uint32_t block, uint32_t page, - const uint8_t *spare, size_t sparelen); - uint8_t nandReadBadMark(NANDDriver *nandp, uint32_t block, uint32_t page); - uint8_t nandErase(NANDDriver *nandp, uint32_t block); - bool nandIsBad(NANDDriver *nandp, uint32_t block); -#if NAND_USE_MUTUAL_EXCLUSION - void nandAcquireBus(NANDDriver *nandp); - void nandReleaseBus(NANDDriver *nandp); -#endif /* NAND_USE_MUTUAL_EXCLUSION */ -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_NAND */ - -#endif /* _NAND_H_ */ - -/** @} */ diff --git a/os/hal/include/onewire.h b/os/hal/include/onewire.h deleted file mode 100644 index 2d27f48..0000000 --- a/os/hal/include/onewire.h +++ /dev/null @@ -1,366 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2014 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 onewire.h - * @brief 1-wire Driver macros and structures. - * - * @addtogroup onewire - * @{ - */ - -#ifndef _ONEWIRE_H_ -#define _ONEWIRE_H_ - -#if (HAL_USE_ONEWIRE == TRUE) || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ -/** - * @brief Enable synthetic test for 'search ROM' procedure. - * @note Only for debugging/testing! - */ -#define ONEWIRE_SYNTH_SEARCH_TEST FALSE - -/** - * @brief Aliases for 1-wire protocol. - */ -#define ONEWIRE_CMD_READ_ROM 0x33 -#define ONEWIRE_CMD_SEARCH_ROM 0xF0 -#define ONEWIRE_CMD_MATCH_ROM 0x55 -#define ONEWIRE_CMD_SKIP_ROM 0xCC -#define ONEWIRE_CMD_CONVERT_TEMP 0x44 -#define ONEWIRE_CMD_READ_SCRATCHPAD 0xBE - -/** - * @brief How many bits will be used for transaction length storage. - */ -#define ONEWIRE_REG_BYTES_WIDTH 16U - -/** - * @brief Precalculated maximum transaction length. - */ -#define ONEWIRE_MAX_TRANSACTION_LEN ((1U << ONEWIRE_REG_BYTES_WIDTH) - 1U) - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -#if !HAL_USE_PWM -#error "1-wire Driver requires HAL_USE_PWM" -#endif - -#if !HAL_USE_PAL -#error "1-wire Driver requires HAL_USE_PAL" -#endif - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ -#if ONEWIRE_USE_STRONG_PULLUP -/** - * @brief 1-wire strong pull up assert callback type. - */ -typedef void (*onewire_pullup_assert_t)(void); - -/** - * @brief 1-wire strong pull up release callback type. - */ -typedef void (*onewire_pullup_release_t)(void); -#endif /* ONEWIRE_USE_STRONG_PULLUP */ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - ONEWIRE_UNINIT = 0, /**< Not initialized. */ - ONEWIRE_STOP = 1, /**< Stopped. */ - ONEWIRE_READY = 2, /**< Ready. */ -#if ONEWIRE_USE_STRONG_PULLUP - ONEWIRE_PULL_UP /**< Pull up asserted. */ -#endif -} onewire_state_t; - -#if ONEWIRE_USE_SEARCH_ROM -/** - * @brief Search ROM procedure possible state. - */ -typedef enum { - ONEWIRE_SEARCH_ROM_SUCCESS = 0, /**< ROM successfully discovered. */ - ONEWIRE_SEARCH_ROM_LAST = 1, /**< Last ROM successfully discovered. */ - ONEWIRE_SEARCH_ROM_ERROR = 2 /**< Error happened during search. */ -} search_rom_result_t; - -/** - * @brief Search ROM procedure iteration enum. - */ -typedef enum { - ONEWIRE_SEARCH_ROM_FIRST = 0, /**< First search run. */ - ONEWIRE_SEARCH_ROM_NEXT = 1 /**< Next search run. */ -} search_iteration_t; -#endif /* ONEWIRE_USE_SEARCH_ROM */ - -/** - * @brief Driver configuration structure. - */ -typedef struct { - /** - * @brief Pointer to @p PWM driver used for communication. - */ - PWMDriver *pwmd; - /** - * @brief Pointer to configuration structure for underlying PWM driver. - * @note It is NOT constant because 1-wire driver needs to change them - * during normal functioning. - */ - PWMConfig *pwmcfg; - /** - * @brief Active logic level for master channel. - * @details Just set it to @p PWM_OUTPUT_ACTIVE_LOW when 1-wire bus - * connected to direct (not complementary) output of the timer. - * In opposite case you need to check documentation to choose - * correct value. - */ - pwmmode_t pwmmode; - /** - * @brief Number of PWM channel used as master pulse generator. - */ - size_t master_channel; - /** - * @brief Number of PWM channel used as sample interrupt generator. - */ - size_t sample_channel; - /** - * @brief Port Identifier. - * @details This type can be a scalar or some kind of pointer, do not make - * any assumption about it, use the provided macros when populating - * variables of this type. - */ - ioportid_t port; - /** - * @brief Digital I/O port pad. - */ - ioportmask_t pad; -#if defined(STM32F1XX) - /** - * @brief Digital I/O mode for idle bus. - * @details This is a kind of workaround against F1x realization of alternate - * function. Alternate function mode will be activated only - * when you starts appropriate peripheral. - */ - iomode_t pad_mode_idle; -#endif - /** - * @brief Digital I/O mode for active bus. - */ - iomode_t pad_mode_active; -#if ONEWIRE_USE_STRONG_PULLUP - /** - * @brief Pointer to function asserting of strong pull up. - */ - onewire_pullup_assert_t pullup_assert; - /** - * @brief Pointer to function releasing of strong pull up. - */ - onewire_pullup_release_t pullup_release; -#endif -} onewireConfig; - -#if ONEWIRE_USE_SEARCH_ROM -/** - * @brief Search ROM registry. Contains small variables used - * in 'search ROM' procedure. - */ -typedef struct { - /** - * @brief Bool flag. True when bus has single slave device. - */ - uint32_t single_device: 1; - /** - * @brief Search iteration (@p search_iteration_t enum). - */ - uint32_t search_iter: 1; - /** - * @brief Result of discovery procedure (@p search_rom_result_t enum). - */ - uint32_t result: 2; - /** - * @brief One of 3 steps of bit discovery. - * @details 0 - direct, 1 - complemented, 2 - generated by master. - */ - uint32_t bit_step: 2; - /** - * @brief Values acquired during bit discovery. - */ - uint32_t bit_buf: 2; - /** - * @brief Currently processing ROM bit. - * @note Must be big enough to store number 64. - */ - uint32_t rombit: 7; - /** - * @brief Total device count discovered on bus. - * @note Maximum 256. - */ - uint32_t devices_found: 8; -} search_rom_reg_t; - -/** - * @brief Helper structure for 'search ROM' procedure - */ -typedef struct { - /** - * @brief Search ROM registry. - */ - search_rom_reg_t reg; - /** - * @brief Pointer to buffer with currently discovering ROM - */ - uint8_t *retbuf; - /** - * @brief Previously discovered ROM. - */ - uint8_t prev_path[8]; - /** - * @brief Last zero turn branch. - * @note Negative values use to point out of device tree's root. - */ - int8_t last_zero_branch; - /** - * @brief Previous zero turn branch. - * @note Negative values use to point out of device tree's root. - */ - int8_t prev_zero_branch; -} onewire_search_rom_t; -#endif /* ONEWIRE_USE_SEARCH_ROM */ - -/** - * @brief Onewire registry. Some small variables combined - * in single machine word to save RAM. - */ -typedef struct { -#if ONEWIRE_USE_STRONG_PULLUP - /** - * @brief This flag will be asserted by driver to signalizes - * ISR part when strong pull up needed. - */ - uint32_t need_pullup: 1; -#endif - /** - * @brief Bool flag. If @p true than at least one device presence on bus. - */ - uint32_t slave_present: 1; - /** - * @brief Driver internal state (@p onewire_state_t enum). - */ - uint32_t state: 2; - /** - * @brief Bit number in currently receiving/sending byte. - * @note Must be big enough to store 8. - */ - uint32_t bit: 4; - /** - * @brief Bool flag for premature timer stop prevention. - */ - uint32_t final_timeslot: 1; - /** - * @brief Bytes number to be processing in current transaction. - */ - uint32_t bytes: ONEWIRE_REG_BYTES_WIDTH; -} onewire_reg_t; - -/** - * @brief Structure representing an 1-wire driver. - */ -typedef struct { - /** - * @brief Onewire registry. - */ - onewire_reg_t reg; - /** - * @brief Onewire config. - */ - const onewireConfig *config; - /** - * @brief Pointer to I/O data buffer. - */ - uint8_t *buf; -#if ONEWIRE_USE_SEARCH_ROM - /** - * @brief Search ROM helper structure. - */ - onewire_search_rom_t search_rom; -#endif /* ONEWIRE_USE_SEARCH_ROM */ - /** - * @brief Thread waiting for I/O completion. - */ - thread_reference_t thread; -} onewireDriver; - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -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); - bool onewireReset(onewireDriver *owp); - void onewireRead(onewireDriver *owp, uint8_t *rxbuf, size_t rxbytes); - uint8_t onewireCRC(const uint8_t *buf, size_t len); - void onewireWrite(onewireDriver *owp, uint8_t *txbuf, - size_t txbytes, systime_t pullup_time); -#if ONEWIRE_USE_SEARCH_ROM - size_t onewireSearchRom(onewireDriver *owp, - uint8_t *result, size_t max_rom_cnt); -#endif /* ONEWIRE_USE_SEARCH_ROM */ -#if ONEWIRE_SYNTH_SEARCH_TEST - void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit); - uint_fast8_t _synth_ow_read_bit(void); - void synthSearchRomTest(onewireDriver *owp); -#endif /* ONEWIRE_SYNTH_SEARCH_TEST */ -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_ONEWIRE */ - -#endif /* _ONEWIRE_H_ */ - -/** @} */ - - - - - - - - - diff --git a/os/hal/include/rng.h b/os/hal/include/rng.h deleted file mode 100644 index 4730f7b..0000000 --- a/os/hal/include/rng.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - RNG for ChibiOS - Copyright (C) 2016 Stephane D'Alu - - 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 _RNG_H_ -#define _RNG_H_ - -#if (HAL_USE_RNG == TRUE) || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/** - * @name Configuration options - * @{ - */ - -/** - * @brief Enables the @p rngAcquireBus() and @p rngReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(RNG_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define RNG_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - RNG_UNINIT, /* Not initialized. */ - RNG_STOP, /* Stopped. */ - RNG_READY, /* Ready. */ -} rngstate_t; - -#include "rng_lld.h" - - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/** - * @name Low level driver helper macros - * @{ - */ - -/** - * @brief Wakes up the waiting thread. - * - * @param[in] rngp pointer to the @p RNGDriver object - * - * @notapi - */ -#define _rng_wakeup_isr(rngp) { \ - osalSysLockFromISR(); \ - osalThreadResumeI(&(rngp)->thread, MSG_OK); \ - osalSysUnlockFromISR(); \ -} - -/** - * @brief Common ISR code. - * @details This code handles the portable part of the ISR code: - * - Callback invocation. - * - Waiting thread wakeup, if any. - * - Driver state transitions. - * . - * @note This macro is meant to be used in the low level drivers - * implementation only. - * - * @param[in] rngp pointer to the @p RNGDriver object - * - * @notapi - */ -#define _rng_isr_code(rngp, rng) { \ - if ((rngp)->config->end_cb) { \ - (rngp)->state = RNG_COMPLETE; \ - (rngp)->config->end_cb(rngp, rng); \ - if ((rngp)->state == RNG_COMPLETE) \ - (rngp)->state = RNG_READY; \ - } \ - else \ - (rngp)->state = RNG_READY; \ - _rng_wakeup_isr(rngp); \ -} - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void rngInit(void); - void rngObjectInit(RNGDriver *rngp); - void rngStart(RNGDriver *rngp, const RNGConfig *config); - void rngStop(RNGDriver *rngp); - msg_t rngWriteI(RNGDriver *rngp, uint8_t *buf, size_t n, systime_t timeout); - msg_t rngWrite(RNGDriver *rngp, uint8_t *buf, size_t n, systime_t timeout); -#if RNG_USE_MUTUAL_EXCLUSION == TRUE - void rngAcquireUnit(RNGDriver *rngp); - void rngReleaseUnit(RNGDriver *rngp); -#endif -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_RNG */ - -#endif /* _RNG_H_ */ - -/** @} */ diff --git a/os/hal/include/timcap.h b/os/hal/include/timcap.h deleted file mode 100644 index a848783..0000000 --- a/os/hal/include/timcap.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file timcap.h - * @brief TIMCAP Driver macros and structures. - * - * @addtogroup TIMCAP - * @{ - */ - -#ifndef _TIMCAP_H_ -#define _TIMCAP_H_ - -#include "ch.h" -#include "hal.h" - -#ifndef HAL_USE_TIMCAP -#define HAL_USE_TIMCAP FALSE -#endif - -#if HAL_USE_TIMCAP || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @brief Driver state machine possible states. - */ -typedef enum { - TIMCAP_UNINIT = 0, /**< Not initialized. */ - TIMCAP_STOP = 1, /**< Stopped. */ - TIMCAP_READY = 2, /**< Ready. */ - TIMCAP_WAITING = 3, /**< Waiting first edge. */ - TIMCAP_ACTIVE = 4, /**< Active cycle phase. */ - TIMCAP_IDLE = 5, /**< Idle cycle phase. */ -} timcapstate_t; - -/** - * @brief Type of a structure representing an TIMCAP driver. - */ -typedef struct TIMCAPDriver TIMCAPDriver; - - -/** - * @brief TIMCAP notification callback type. - * - * @param[in] timcapp pointer to a @p TIMCAPDriver object - */ -typedef void (*timcapcallback_t)(TIMCAPDriver *timcapp); - -#include "timcap_lld.h" - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/** - * @name Macro Functions - * @{ - */ -/** - * @brief Enables the input capture. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @iclass - */ -#define timcapEnableI(timcapp) timcap_lld_enable(timcapp) - -/** - * @brief Disables the input capture. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @iclass - */ -#define timcapDisableI(timcapp) timcap_lld_disable(timcapp) - - - - -/** @} */ - -/** - * @name Low Level driver helper macros - * @{ - */ - - -/** - * @brief Common ISR code, TIMCAP channel 1 event. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @notapi - */ -#define _timcap_isr_invoke_channel1_cb(timcapp) { \ - timcapstate_t previous_state = (timcapp)->state; \ - (timcapp)->state = TIMCAP_ACTIVE; \ - if (previous_state != TIMCAP_WAITING) \ - (timcapp)->config->capture_cb_array[0](timcapp); \ -} - -/** - * @brief Common ISR code, TIMCAP channel 2 event. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @notapi - */ -#define _timcap_isr_invoke_channel2_cb(timcapp) { \ - timcapstate_t previous_state = (timcapp)->state; \ - (timcapp)->state = TIMCAP_ACTIVE; \ - if (previous_state != TIMCAP_WAITING) \ - (timcapp)->config->capture_cb_array[1](timcapp); \ -} - -/** - * @brief Common ISR code, TIMCAP channel 3 event. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @notapi - */ -#define _timcap_isr_invoke_channel3_cb(timcapp) { \ - timcapstate_t previous_state = (timcapp)->state; \ - (timcapp)->state = TIMCAP_ACTIVE; \ - if (previous_state != TIMCAP_WAITING) \ - (timcapp)->config->capture_cb_array[2](timcapp); \ -} - -/** - * @brief Common ISR code, TIMCAP channel 4 event. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @notapi - */ -#define _timcap_isr_invoke_channel4_cb(timcapp) { \ - timcapstate_t previous_state = (timcapp)->state; \ - (timcapp)->state = TIMCAP_ACTIVE; \ - if (previous_state != TIMCAP_WAITING) \ - (timcapp)->config->capture_cb_array[3](timcapp); \ -} - -/** - * @brief Common ISR code, TIMCAP timer overflow event. - * - * @param[in] timcapp pointer to the @p TIMCAPDriver object - * - * @notapi - */ -#define _timcap_isr_invoke_overflow_cb(timcapp) { \ - (timcapp)->config->overflow_cb(timcapp); \ -} -/** @} */ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void timcapInit(void); - void timcapObjectInit(TIMCAPDriver *timcapp); - void timcapStart(TIMCAPDriver *timcapp, const TIMCAPConfig *config); - void timcapStop(TIMCAPDriver *timcapp); - void timcapEnable(TIMCAPDriver *timcapp); - void timcapDisable(TIMCAPDriver *timcapp); -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_TIMCAP */ - -#endif /* _TIMCAP_H_ */ - -/** @} */ diff --git a/os/hal/include/usbh.h b/os/hal/include/usbh.h deleted file mode 100644 index 2f8f3dd..0000000 --- a/os/hal/include/usbh.h +++ /dev/null @@ -1,439 +0,0 @@ -/* - 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 /* descriptor iterators */ -#include /* debug */ - -#endif - -#endif /* USBH_H_ */ diff --git a/os/hal/include/usbh/debug.h b/os/hal/include/usbh/debug.h index 219eeb1..5120121 100644 --- a/os/hal/include/usbh/debug.h +++ b/os/hal/include/usbh/debug.h @@ -19,7 +19,7 @@ #ifndef USBH_DEBUG_H_ #define USBH_DEBUG_H_ -#include "usbh.h" +#include "hal_usbh.h" #if HAL_USE_USBH diff --git a/os/hal/include/usbh/dev/ftdi.h b/os/hal/include/usbh/dev/ftdi.h index 678a521..ad6b4cd 100644 --- a/os/hal/include/usbh/dev/ftdi.h +++ b/os/hal/include/usbh/dev/ftdi.h @@ -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 diff --git a/os/hal/include/usbh/dev/hub.h b/os/hal/include/usbh/dev/hub.h index 28a0681..07e88e6 100644 --- a/os/hal/include/usbh/dev/hub.h +++ b/os/hal/include/usbh/dev/hub.h @@ -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 diff --git a/os/hal/include/usbh/dev/msd.h b/os/hal/include/usbh/dev/msd.h index 2ca8817..d164618 100644 --- a/os/hal/include/usbh/dev/msd.h +++ b/os/hal/include/usbh/dev/msd.h @@ -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 diff --git a/os/hal/include/usbh/internal.h b/os/hal/include/usbh/internal.h index 6811e20..baa477f 100644 --- a/os/hal/include/usbh/internal.h +++ b/os/hal/include/usbh/internal.h @@ -18,7 +18,7 @@ #ifndef USBH_INTERNAL_H_ #define USBH_INTERNAL_H_ -#include "usbh.h" +#include "hal_usbh.h" #if HAL_USE_USBH -- cgit v1.2.3