From 7ab18994e7ac71872b9aa4684546dffe01c5c3f0 Mon Sep 17 00:00:00 2001 From: Konstantin Oblaukhov Date: Mon, 24 Sep 2018 20:29:02 +0700 Subject: Adopt sources to new HAL. --- os/hal/src/hal_ee24xx.c | 1 + os/hal/src/hal_ee25xx.c | 1 + os/hal/src/usbh/hal_usbh_aoa.c | 11 ++++++++++- os/hal/src/usbh/hal_usbh_ftdi.c | 11 ++++++++++- os/hal/src/usbh/hal_usbh_msd.c | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) (limited to 'os/hal/src') diff --git a/os/hal/src/hal_ee24xx.c b/os/hal/src/hal_ee24xx.c index 725258c..1df1b9f 100644 --- a/os/hal/src/hal_ee24xx.c +++ b/os/hal/src/hal_ee24xx.c @@ -334,6 +334,7 @@ static size_t read(void *ip, uint8_t *bp, size_t n) { } static const struct EepromFileStreamVMT vmt = { + (size_t)0, write, read, eepfs_put, diff --git a/os/hal/src/hal_ee25xx.c b/os/hal/src/hal_ee25xx.c index 8c35976..2849e66 100644 --- a/os/hal/src/hal_ee25xx.c +++ b/os/hal/src/hal_ee25xx.c @@ -383,6 +383,7 @@ static size_t read(void *ip, uint8_t *bp, size_t n) { } static const struct EepromFileStreamVMT vmt = { + (size_t)0, write, read, eepfs_put, diff --git a/os/hal/src/usbh/hal_usbh_aoa.c b/os/hal/src/usbh/hal_usbh_aoa.c index d565595..1447bdb 100644 --- a/os/hal/src/usbh/hal_usbh_aoa.c +++ b/os/hal/src/usbh/hal_usbh_aoa.c @@ -498,7 +498,15 @@ static size_t _read(USBHAOAChannel *aoacp, uint8_t *bp, size_t n) { return _read_timeout(aoacp, bp, n, TIME_INFINITE); } +static msg_t _ctl(USBHAOAChannel *ftdipp, unsigned int operation, void *arg) { + (void)ftdipp; + (void)operation; + (void)arg; + return MSG_OK; +} + static const struct AOADriverVMT async_channel_vmt = { + (size_t)0, (size_t (*)(void *, const uint8_t *, size_t))_write, (size_t (*)(void *, uint8_t *, size_t))_read, (msg_t (*)(void *, uint8_t))_put, @@ -506,7 +514,8 @@ static const struct AOADriverVMT async_channel_vmt = { (msg_t (*)(void *, uint8_t, systime_t))_put_timeout, (msg_t (*)(void *, systime_t))_get_timeout, (size_t (*)(void *, const uint8_t *, size_t, systime_t))_write_timeout, - (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout + (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout, + (msg_t (*)(void *, unsigned int, void *))_ctl }; static void _stop_channelS(USBHAOAChannel *aoacp) { diff --git a/os/hal/src/usbh/hal_usbh_ftdi.c b/os/hal/src/usbh/hal_usbh_ftdi.c index 6966028..7bd8f2d 100644 --- a/os/hal/src/usbh/hal_usbh_ftdi.c +++ b/os/hal/src/usbh/hal_usbh_ftdi.c @@ -600,6 +600,13 @@ static size_t _read(USBHFTDIPortDriver *ftdipp, uint8_t *bp, size_t n) { return _read_timeout(ftdipp, bp, n, TIME_INFINITE); } +static msg_t _ctl(USBHFTDIPortDriver *ftdipp, unsigned int operation, void *arg) { + (void)ftdipp; + (void)operation; + (void)arg; + return MSG_OK; +} + static void _vt(void *p) { USBHFTDIPortDriver *const ftdipp = (USBHFTDIPortDriver *)p; osalSysLockFromISR(); @@ -615,6 +622,7 @@ static void _vt(void *p) { } static const struct FTDIPortDriverVMT async_channel_vmt = { + (size_t)0, (size_t (*)(void *, const uint8_t *, size_t))_write, (size_t (*)(void *, uint8_t *, size_t))_read, (msg_t (*)(void *, uint8_t))_put, @@ -622,7 +630,8 @@ static const struct FTDIPortDriverVMT async_channel_vmt = { (msg_t (*)(void *, uint8_t, systime_t))_put_timeout, (msg_t (*)(void *, systime_t))_get_timeout, (size_t (*)(void *, const uint8_t *, size_t, systime_t))_write_timeout, - (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout + (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout, + (msg_t (*)(void *, unsigned int, void *))_ctl }; diff --git a/os/hal/src/usbh/hal_usbh_msd.c b/os/hal/src/usbh/hal_usbh_msd.c index 7233a0b..fe97ff0 100644 --- a/os/hal/src/usbh/hal_usbh_msd.c +++ b/os/hal/src/usbh/hal_usbh_msd.c @@ -683,6 +683,7 @@ static msd_result_t scsi_write10(USBHMassStorageLUNDriver *lunp, uint32_t lba, u USBHMassStorageLUNDriver MSBLKD[HAL_USBHMSD_MAX_LUNS]; static const struct USBHMassStorageDriverVMT blk_vmt = { + (size_t)0, (bool (*)(void *))usbhmsdLUNIsInserted, (bool (*)(void *))usbhmsdLUNIsProtected, (bool (*)(void *))usbhmsdLUNConnect, -- cgit v1.2.3 From 33375fb281b05ac493ce3ff34deaf21c15565157 Mon Sep 17 00:00:00 2001 From: Konstantin Oblaukhov Date: Sun, 7 Oct 2018 18:39:36 +0700 Subject: Fix USB HID driver. --- os/hal/src/hal_usb_hid.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'os/hal/src') diff --git a/os/hal/src/hal_usb_hid.c b/os/hal/src/hal_usb_hid.c index d9d671b..305fe8d 100644 --- a/os/hal/src/hal_usb_hid.c +++ b/os/hal/src/hal_usb_hid.c @@ -128,15 +128,23 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t timeout) { return ibqReadTimeout(&((USBHIDDriver *)ip)->ibqueue, bp, n, timeout); } +static msg_t ctl(void *ip, unsigned int operation, void *arg) { + (void)ip; + (void)operation; + (void)arg; + return MSG_OK; +} + static void flush(void *ip) { obqFlush(&((USBHIDDriver *)ip)->obqueue); } static const struct USBHIDDriverVMT vmt = { + (size_t)0, write, read, put, get, putt, gett, writet, readt, - flush + ctl, flush }; /** -- cgit v1.2.3 From 91e635b08a57e44ce1f7deb0328a5ae78117f8d4 Mon Sep 17 00:00:00 2001 From: Fabien Poussin Date: Tue, 8 Jan 2019 20:02:45 +0100 Subject: Adding rudimentary OPAMP Driver --- os/hal/src/hal_opamp.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 os/hal/src/hal_opamp.c (limited to 'os/hal/src') diff --git a/os/hal/src/hal_opamp.c b/os/hal/src/hal_opamp.c new file mode 100644 index 0000000..ba718a7 --- /dev/null +++ b/os/hal/src/hal_opamp.c @@ -0,0 +1,155 @@ +/* + ChibiOS - Copyright (C) 2006..2019 Giovanni Di Sirio + Copyright (C) 2019 Fabien Poussin (fabien.poussin (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. +*/ + +/** + * @file hal_opamp.c + * @brief OPAMP Driver code. + * + * @addtogroup OPAMP + * @{ + */ + +#include "hal_opamp.h" + +#if HAL_USE_OPAMP || defined(__DOXYGEN__) + + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** + * @brief OPAMP Driver initialization. + * @note This function is implicitly invoked by @p halInit(), there is + * no need to explicitly initialize the driver. + * + * @init + */ +void opampInit(void) { + + opamp_lld_init(); +} + +/** + * @brief Initializes the standard part of a @p OPAMPDriver structure. + * + * @param[out] opampp pointer to the @p OPAMPDriver object + * + * @init + */ +void opampObjectInit(OPAMPDriver *opampp) { + + opampp->state = OPAMP_STOP; + opampp->config = NULL; +} + +/** + * @brief Configures and activates the OPAMP peripheral. + * + * @param[in] opampp pointer to the @p OPAMPDriver object + * @param[in] config pointer to the @p OPAMPConfig object + * + * @api + */ +void opampStart(OPAMPDriver *opampp, const OPAMPConfig *config) { + + osalDbgCheck((opampp != NULL) && (config != NULL)); + + osalSysLock(); + osalDbgAssert((opampp->state == OPAMP_STOP) || (opampp->state == OPAMP_READY), + "invalid state"); + opampp->config = config; + opamp_lld_start(opampp); + opampp->state = OPAMP_READY; + osalSysUnlock(); +} + +/** + * @brief Deactivates the OPAMP peripheral. + * + * @param[in] opampp pointer to the @p OPAMPDriver object + * + * @api + */ +void opampStop(OPAMPDriver *opampp) { + + osalDbgCheck(opampp != NULL); + + osalSysLock(); + osalDbgAssert((opampp->state == OPAMP_STOP) || (opampp->state == OPAMP_READY), + "invalid state"); + opamp_lld_stop(opampp); + opampp->state = OPAMP_STOP; + osalSysUnlock(); +} + +/** + * @brief Activates the opamp. + * + * @param[in] opampp pointer to the @p OPAMPDriver object + * + * @api + */ +void opampEnable(OPAMPDriver *opampp) { + + osalDbgCheck(opampp != NULL); + + osalSysLock(); + osalDbgAssert(opampp->state == OPAMP_READY, "invalid state"); + opamp_lld_enable(opampp); + opampp->state = OPAMP_ACTIVE; + osalSysUnlock(); +} + +/** + * @brief Deactivates the opamp. + * + * @param[in] opampp pointer to the @p OPAMPDriver object + * + * @api + */ +void opampDisable(OPAMPDriver *opampp) { + + osalDbgCheck(opampp != NULL); + + osalSysLock(); + osalDbgAssert((opampp->state == OPAMP_READY) || (opampp->state == OPAMP_ACTIVE), + "invalid state"); + opamp_lld_disable(opampp); + opampp->state = OPAMP_READY; + osalSysUnlock(); +} + +#endif /* HAL_USE_OPAMP */ + +/** @} */ -- cgit v1.2.3 From 6076bdf27d3c70675dff3b1866a3bbc82aa1eb00 Mon Sep 17 00:00:00 2001 From: Fabien Poussin Date: Thu, 31 Jan 2019 17:52:13 +0100 Subject: Updating OpAmp code with calibration functions, cleaning. --- os/hal/src/hal_opamp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'os/hal/src') diff --git a/os/hal/src/hal_opamp.c b/os/hal/src/hal_opamp.c index ba718a7..79a5ec8 100644 --- a/os/hal/src/hal_opamp.c +++ b/os/hal/src/hal_opamp.c @@ -86,11 +86,11 @@ void opampStart(OPAMPDriver *opampp, const OPAMPConfig *config) { osalDbgCheck((opampp != NULL) && (config != NULL)); osalSysLock(); - osalDbgAssert((opampp->state == OPAMP_STOP) || (opampp->state == OPAMP_READY), + osalDbgAssert((opampp->state == OPAMP_STOP) || (opampp->state == OPAMP_ACTIVE), "invalid state"); opampp->config = config; opamp_lld_start(opampp); - opampp->state = OPAMP_READY; + opampp->state = OPAMP_ACTIVE; osalSysUnlock(); } @@ -106,7 +106,7 @@ void opampStop(OPAMPDriver *opampp) { osalDbgCheck(opampp != NULL); osalSysLock(); - osalDbgAssert((opampp->state == OPAMP_STOP) || (opampp->state == OPAMP_READY), + osalDbgAssert((opampp->state == OPAMP_STOP) || (opampp->state == OPAMP_ACTIVE), "invalid state"); opamp_lld_stop(opampp); opampp->state = OPAMP_STOP; @@ -125,7 +125,7 @@ void opampEnable(OPAMPDriver *opampp) { osalDbgCheck(opampp != NULL); osalSysLock(); - osalDbgAssert(opampp->state == OPAMP_READY, "invalid state"); + osalDbgAssert(opampp->state == OPAMP_ACTIVE, "invalid state"); opamp_lld_enable(opampp); opampp->state = OPAMP_ACTIVE; osalSysUnlock(); @@ -143,10 +143,10 @@ void opampDisable(OPAMPDriver *opampp) { osalDbgCheck(opampp != NULL); osalSysLock(); - osalDbgAssert((opampp->state == OPAMP_READY) || (opampp->state == OPAMP_ACTIVE), + osalDbgAssert((opampp->state == OPAMP_ACTIVE), "invalid state"); opamp_lld_disable(opampp); - opampp->state = OPAMP_READY; + opampp->state = OPAMP_ACTIVE; osalSysUnlock(); } -- cgit v1.2.3 From f014b8da68f162bb06ca88acf0085382a76d8dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 26 Feb 2019 22:38:30 +0000 Subject: Fixes for USB MSD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix return value on succesfull scsi_requestsense. - Fix calls to LL SMT32 API for OTG2. - Port changes from ChibiOS fatfs_diskio. - Rework checks to allow simultaneous use of SD Card and USB MSD. Signed-off-by: José Simões --- os/hal/src/usbh/hal_usbh_msd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'os/hal/src') diff --git a/os/hal/src/usbh/hal_usbh_msd.c b/os/hal/src/usbh/hal_usbh_msd.c index fe97ff0..3d57934 100644 --- a/os/hal/src/usbh/hal_usbh_msd.c +++ b/os/hal/src/usbh/hal_usbh_msd.c @@ -516,6 +516,8 @@ static msd_result_t _scsi_perform_transaction(USBHMassStorageLUNDriver *lunp, if (scsi_requestsense(lunp, &sense) == MSD_RESULT_OK) { uwarnf("\tMSD: REQUEST SENSE: Sense key=%x, ASC=%02x, ASCQ=%02x", sense.byte[2] & 0xf, sense.byte[12], sense.byte[13]); + + return MSD_RESULT_OK; } } return MSD_RESULT_FAILED; -- cgit v1.2.3