diff options
Diffstat (limited to 'os/hal/include')
-rw-r--r-- | os/hal/include/adc.h | 54 | ||||
-rw-r--r-- | os/hal/include/ext.h | 130 | ||||
-rw-r--r-- | os/hal/include/hal.h | 2 | ||||
-rw-r--r-- | os/hal/include/i2c.h | 105 | ||||
-rw-r--r-- | os/hal/include/mac.h | 36 | ||||
-rw-r--r-- | os/hal/include/mii.h | 1 | ||||
-rw-r--r-- | os/hal/include/rtc.h | 104 | ||||
-rw-r--r-- | os/hal/include/usb.h | 96 |
8 files changed, 454 insertions, 74 deletions
diff --git a/os/hal/include/adc.h b/os/hal/include/adc.h index 53c7c199a..9ebe3754c 100644 --- a/os/hal/include/adc.h +++ b/os/hal/include/adc.h @@ -80,7 +80,8 @@ typedef enum { ADC_STOP = 1, /**< Stopped. */
ADC_READY = 2, /**< Ready. */
ADC_ACTIVE = 3, /**< Converting. */
- ADC_COMPLETE = 4 /**< Conversion complete. */
+ ADC_COMPLETE = 4, /**< Conversion complete. */
+ ADC_ERROR = 5 /**< Conversion complete. */
} adcstate_t;
#include "adc_lld.h"
@@ -133,21 +134,41 @@ typedef enum { * @notapi
*/
#define _adc_wakeup_isr(adcp) { \
+ chSysLockFromIsr(); \
if ((adcp)->thread != NULL) { \
Thread *tp; \
- chSysLockFromIsr(); \
tp = (adcp)->thread; \
(adcp)->thread = NULL; \
tp->p_u.rdymsg = RDY_OK; \
chSchReadyI(tp); \
- chSysUnlockFromIsr(); \
} \
+ chSysUnlockFromIsr(); \
+}
+
+/**
+ * @brief Wakes up the waiting thread with a timeout message.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+#define _adc_timeout_isr(adcp) { \
+ chSysLockFromIsr(); \
+ if ((adcp)->thread != NULL) { \
+ Thread *tp; \
+ tp = (adcp)->thread; \
+ (adcp)->thread = NULL; \
+ tp->p_u.rdymsg = RDY_TIMEOUT; \
+ chSchReadyI(tp); \
+ } \
+ chSysUnlockFromIsr(); \
}
#else /* !ADC_USE_WAIT */
#define _adc_reset_i(adcp)
#define _adc_reset_s(adcp)
#define _adc_wakeup_isr(adcp)
+#define _adc_timeout_isr(adcp)
#endif /* !ADC_USE_WAIT */
/**
@@ -220,6 +241,33 @@ typedef enum { _adc_wakeup_isr(adcp); \
} \
}
+
+/**
+ * @brief Common ISR code, error event.
+ * @details This code handles the portable part of the ISR code:
+ * - Callback invocation.
+ * - Waiting thread timeout signaling, if any.
+ * - Driver state transitions.
+ * .
+ * @note This macro is meant to be used in the low level drivers
+ * implementation only.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ * @param[in] err platform dependent error code
+ *
+ * @notapi
+ */
+#define _adc_isr_error_code(adcp, err) { \
+ adc_lld_stop_conversion(adcp); \
+ if ((adcp)->grpp->error_cb != NULL) { \
+ (adcp)->state = ADC_ERROR; \
+ (adcp)->grpp->error_cb(adcp, err); \
+ if ((adcp)->state == ADC_ERROR) \
+ (adcp)->state = ADC_READY; \
+ } \
+ (adcp)->grpp = NULL; \
+ _adc_timeout_isr(adcp); \
+}
/** @} */
/*===========================================================================*/
diff --git a/os/hal/include/ext.h b/os/hal/include/ext.h new file mode 100644 index 000000000..852c3d07f --- /dev/null +++ b/os/hal/include/ext.h @@ -0,0 +1,130 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 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 <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file ext.h
+ * @brief EXT Driver macros and structures.
+ *
+ * @addtogroup EXT
+ * @{
+ */
+
+#ifndef _EXT_H_
+#define _EXT_H_
+
+#if HAL_USE_EXT || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @name EXT channels modes
+ * @{
+ */
+#define EXT_CH_MODE_EDGES_MASK 3 /**< @brief Mask of edges field. */
+#define EXT_CH_MODE_DISABLED 0 /**< @brief Channel disabled. */
+#define EXT_CH_MODE_RISING_EDGE 1 /**< @brief Rising edge callback. */
+#define EXT_CH_MODE_FALLING_EDGE 2 /**< @brief Falling edge callback. */
+#define EXT_CH_MODE_BOTH_EDGES 3 /**< @brief Both edges callback. */
+
+#define EXT_CH_MODE_AUTOSTART 4 /**< @brief Channel started
+ automatically on driver start. */
+/** @} */
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Driver state machine possible states.
+ */
+typedef enum {
+ EXT_UNINIT = 0, /**< Not initialized. */
+ EXT_STOP = 1, /**< Stopped. */
+ EXT_ACTIVE = 2, /**< Active. */
+} extstate_t;
+
+/**
+ * @brief Type of a structure representing a EXT driver.
+ */
+typedef struct EXTDriver EXTDriver;
+
+#include "ext_lld.h"
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/**
+ * @name Macro Functions
+ * @{
+ */
+/**
+ * @brief Enables an EXT channel.
+ *
+ * @param[in] extp pointer to the @p EXTDriver object
+ * @param[in] channel channel to be enabled
+ *
+ * @iclass
+ */
+#define extChannelEnableI(extp, channel) ext_lld_channel_enable(extp, channel)
+
+/**
+ * @brief Disables an EXT channel.
+ *
+ * @param[in] extp pointer to the @p EXTDriver object
+ * @param[in] channel channel to be disabled
+ *
+ * @iclass
+ */
+#define extChannelDisableI(extp, channel) ext_lld_channel_disable(extp, channel)
+/** @} */
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void extInit(void);
+ void extObjectInit(EXTDriver *extp);
+ void extStart(EXTDriver *extp, const EXTConfig *config);
+ void extStop(EXTDriver *extp);
+ void extChannelEnable(EXTDriver *extp, expchannel_t channel);
+ void extChannelDisable(EXTDriver *extp, expchannel_t channel);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_EXT */
+
+#endif /* _EXT_H_ */
+
+/** @} */
diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h index 1ed893aab..8d7214325 100644 --- a/os/hal/include/hal.h +++ b/os/hal/include/hal.h @@ -37,6 +37,7 @@ #include "pal.h"
#include "adc.h"
#include "can.h"
+#include "ext.h"
#include "gpt.h"
#include "i2c.h"
#include "icu.h"
@@ -49,6 +50,7 @@ #include "usb.h"
#include "mmc_spi.h"
#include "serial_usb.h"
+#include "rtc.h"
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h index acf09ec9c..cf4d47713 100644 --- a/os/hal/include/i2c.h +++ b/os/hal/include/i2c.h @@ -34,24 +34,27 @@ /*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
+
/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/
-#define I2CD_NO_ERROR 0
-/** @brief Bus Error.*/
-#define I2CD_BUS_ERROR 0x01
-/** @brief Arbitration Lost (master mode).*/
-#define I2CD_ARBITRATION_LOST 0x02
-/** @brief Acknowledge Failure.*/
-#define I2CD_ACK_FAILURE 0x04
-/** @brief Overrun/Underrun.*/
-#define I2CD_OVERRUN 0x08
-/** @brief PEC Error in reception.*/
-#define I2CD_PEC_ERROR 0x10
-/** @brief Timeout or Tlow Error.*/
-#define I2CD_TIMEOUT 0x20
-/** @brief SMBus Alert.*/
-#define I2CD_SMB_ALERT 0x40
+
+/**
+ * @name I2C bus error conditions
+ * @{
+ */
+#define I2CD_NO_ERROR 0x00 /**< @brief No error. */
+#define I2CD_BUS_ERROR 0x01 /**< @brief Bus Error. */
+#define I2CD_ARBITRATION_LOST 0x02 /**< @brief Arbitration Lost
+ (master mode). */
+#define I2CD_ACK_FAILURE 0x04 /**< @brief Acknowledge Failure.*/
+#define I2CD_OVERRUN 0x08 /**< @brief Overrun/Underrun. */
+#define I2CD_PEC_ERROR 0x10 /**< @brief PEC Error in
+ reception. */
+#define I2CD_TIMEOUT 0x20 /**< @brief Timeout Error. */
+#define I2CD_SMB_ALERT 0x40 /**< @brief SMBus Alert. */
+/** @} */
+
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
@@ -66,6 +69,7 @@ /*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
+
#if I2C_USE_MUTUAL_EXCLUSION && !CH_USE_MUTEXES && !CH_USE_SEMAPHORES
#error "I2C_USE_MUTUAL_EXCLUSION requires CH_USE_MUTEXES and/or CH_USE_SEMAPHORES"
#endif
@@ -78,27 +82,20 @@ * @brief Driver state machine possible states.
*/
typedef enum {
- /* master part */
- I2C_UNINIT = 0, /**< @brief Not initialized. */
- I2C_STOP = 1, /**< @brief Stopped. */
- I2C_READY = 2, /**< @brief Ready. */
- I2C_ACTIVE_TRANSMIT = 3, /**< @brief Transmit in progress. */
- I2C_ACTIVE_RECEIVE = 4, /**< @brief Receive in progress. */
- I2C_ACTIVE_TRANSCEIVE = 5, /**< @brief Receive after transmit in progress. */
-
- /* Slave part. Not realized. */
- I2C_SACTIVE = 10,
- I2C_STRANSMIT = 11,
- I2C_SRECEIVE = 12,
+ I2C_UNINIT = 0, /**< Not initialized. */
+ I2C_STOP = 1, /**< Stopped. */
+ I2C_READY = 2, /**< Ready. */
+ I2C_ACTIVE_TRANSMIT = 3, /**< Transmitting. */
+ I2C_ACTIVE_RECEIVE = 4, /**< Receiving. */
+ I2C_ACTIVE_TRANSCEIVE = 5, /**< Receiving after transmit. */
} i2cstate_t;
-
#include "i2c_lld.h"
/**
* @brief I2C notification callback type.
* @details This callback invoked when byte transfer finish event occurs,
- * No matter sending or reading.
+ * no matter if sending or reading.
*
* @param[in] i2cp pointer to the @p I2CDriver object triggering the
* callback
@@ -107,7 +104,6 @@ typedef enum { */
typedef void (*i2ccallback_t)(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg);
-
/**
* @brief I2C error notification callback type.
*
@@ -119,13 +115,11 @@ typedef void (*i2ccallback_t)(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg); typedef void (*i2cerrorcallback_t)(I2CDriver *i2cp,
const I2CSlaveConfig *i2cscfg);
-
/**
- * @brief I2C transmission data block size.
+ * @brief I2C transmission data block size.
*/
typedef uint8_t i2cblock_t;
-
/**
* @brief Structure representing an I2C slave configuration.
* @details Each slave device has its own config structure with input and
@@ -138,7 +132,6 @@ struct I2CSlaveConfig{ * If set to @p NULL then the callback is disabled.
*/
i2ccallback_t id_callback;
-
/**
* @brief Callback pointer.
* @note This callback will be invoked when error condition occur.
@@ -150,7 +143,6 @@ struct I2CSlaveConfig{ #endif
};
-
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
@@ -209,17 +201,18 @@ struct I2CSlaveConfig{ * implementation only.
*
* @param[in] i2cp pointer to the @p I2CDriver object
+ * @param[in] i2cscfg pointer to the @p I2CSlaveConfig object
*
* @notapi
*/
-#define _i2c_isr_code(i2cp, i2cscfg) { \
- if(((i2cp)->id_slave_config)->id_callback) { \
- ((i2cp)->id_slave_config)->id_callback(i2cp, i2cscfg); \
- (i2cp)->id_state = I2C_READY; \
- } \
- else \
- (i2cp)->id_state = I2C_READY; \
- _i2c_wakeup_isr(i2cp); \
+#define _i2c_isr_code(i2cp, i2cscfg) { \
+ if(((i2cp)->id_slave_config)->id_callback) { \
+ ((i2cp)->id_slave_config)->id_callback(i2cp, i2cscfg); \
+ (i2cp)->id_state = I2C_READY; \
+ } \
+ else \
+ (i2cp)->id_state = I2C_READY; \
+ _i2c_wakeup_isr(i2cp); \
}
/**
@@ -233,22 +226,24 @@ struct I2CSlaveConfig{ * implementation only.
*
* @param[in] i2cp pointer to the @p I2CDriver object
+ * @param[in] i2cscfg pointer to the @p I2CSlaveConfig object
*
* @notapi
*/
-#define _i2c_isr_err_code(i2cp, i2cscfg) { \
- if(((i2cp)->id_slave_config)->id_err_callback) { \
- ((i2cp)->id_slave_config)->id_err_callback(i2cp, i2cscfg); \
- (i2cp)->id_state = I2C_READY; \
- } \
- else \
- (i2cp)->id_state = I2C_READY; \
- _i2c_wakeup_isr(i2cp); \
+#define _i2c_isr_err_code(i2cp, i2cscfg) { \
+ if(((i2cp)->id_slave_config)->id_err_callback) { \
+ ((i2cp)->id_slave_config)->id_err_callback(i2cp, i2cscfg); \
+ (i2cp)->id_state = I2C_READY; \
+ } \
+ else \
+ (i2cp)->id_state = I2C_READY; \
+ _i2c_wakeup_isr(i2cp); \
}
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -257,11 +252,11 @@ extern "C" { void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
void i2cStop(I2CDriver *i2cp);
void i2cMasterTransmit(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg,
- uint16_t slave_addr,
- uint8_t *txbuf, size_t txbytes,
- uint8_t *rxbuf, size_t rxbytes);
+ uint16_t slave_addr,
+ uint8_t *txbuf, size_t txbytes,
+ uint8_t *rxbuf, size_t rxbytes);
void i2cMasterReceive(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg,
- uint16_t slave_addr, uint8_t *rxbuf, size_t rxbytes);
+ uint16_t slave_addr, uint8_t *rxbuf, size_t rxbytes);
void i2cMasterStart(I2CDriver *i2cp);
void i2cMasterStop(I2CDriver *i2cp);
void i2cAddFlagsI(I2CDriver *i2cp, i2cflags_t mask);
diff --git a/os/hal/include/mac.h b/os/hal/include/mac.h index 37d6bbe9b..c716796f8 100644 --- a/os/hal/include/mac.h +++ b/os/hal/include/mac.h @@ -38,18 +38,48 @@ /* Driver pre-compile time settings. */
/*===========================================================================*/
+/**
+ * @name MAC configuration options
+ * @{
+ */
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
+#define MAC_USE_EVENTS TRUE
+#endif
+/** @} */
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
#if !CH_USE_SEMAPHORES || !CH_USE_EVENTS
-#error "the MAC driver requires CH_USE_SEMAPHORES and CH_USE_EVENTS"
+#error "the MAC driver requires CH_USE_SEMAPHORES"
+#endif
+
+#if MAC_USE_EVENTS && !CH_USE_EVENTS
+#error "the MAC driver requires CH_USE_EVENTS"
#endif
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
+/**
+ * @brief Driver state machine possible states.
+ */
+typedef enum {
+ MAC_UNINIT = 0, /**< Not initialized. */
+ MAC_STOP = 1, /**< Stopped. */
+ MAC_ACTIVE = 2, /**< Active. */
+} macstate_t;
+
+/**
+ * @brief Type of a structure representing a MAC driver.
+ */
+typedef struct MACDriver MACDriver;
+
#include "mac_lld.h"
/*===========================================================================*/
@@ -68,7 +98,7 @@ *
* @api
*/
-#if CH_USE_EVENTS || defined(__DOXYGEN__)
+#if MAC_USE_EVENTS || defined(__DOXYGEN__)
#define macGetReceiveEventSource(macp) (&(macp)->rdevent)
#endif
@@ -113,6 +143,8 @@ extern "C" { #endif
void macInit(void);
void macObjectInit(MACDriver *macp);
+ void macStart(MACDriver *macp, const MACConfig *config);
+ void macStop(MACDriver *macp);
void macSetAddress(MACDriver *macp, const uint8_t *p);
msg_t macWaitTransmitDescriptor(MACDriver *macp,
MACTransmitDescriptor *tdp,
diff --git a/os/hal/include/mii.h b/os/hal/include/mii.h index 89ba69810..969f4a9d5 100644 --- a/os/hal/include/mii.h +++ b/os/hal/include/mii.h @@ -178,6 +178,7 @@ #define MII_DM9161_ID 0x0181b8a0
#define MII_AM79C875_ID 0x00225540
#define MII_KS8721_ID 0x00221610
+#define MII_STE101P_ID 0x00061C50
#endif /* _MII_H_ */
diff --git a/os/hal/include/rtc.h b/os/hal/include/rtc.h new file mode 100644 index 000000000..1264c5bd8 --- /dev/null +++ b/os/hal/include/rtc.h @@ -0,0 +1,104 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 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 <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file rtc.h
+ * @brief RTC Driver macros and structures.
+ *
+ * @addtogroup RTC
+ * @{
+ */
+
+#ifndef _RTC_H_
+#define _RTC_H_
+
+#if HAL_USE_RTC || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @name Date/Time bit masks
+ * @{
+ */
+#define RTC_TIME_SECONDS_MASK 0x0000001F /* @brief Seconds mask. */
+#define RTC_TIME_MINUTES_MASK 0x000007E0 /* @brief Minutes mask. */
+#define RTC_TIME_HOURS_MASK 0x0000F800 /* @brief Hours mask. */
+#define RTC_DATE_DAYS_MASK 0x001F0000 /* @brief Days mask. */
+#define RTC_DATE_MONTHS_MASK 0x01E00000 /* @brief Months mask. */
+#define RTC_DATE_YEARS_MASK 0xFE000000 /* @brief Years mask. */
+/** @} */
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type of a structure representing an RTC driver.
+ */
+typedef struct RTCDriver RTCDriver;
+
+/**
+ * @brief Type of a structure representing an RTC time stamp.
+ */
+typedef struct RTCTime RTCTime;
+
+#include "rtc_lld.h"
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void rtcInit(void);
+ void rtcSetTime(RTCDriver *rtcp, const RTCTime *timespec);
+ void rtcGetTime(RTCDriver *rtcp, RTCTime *timespec);
+#if RTC_ALARMS > 0
+ void rtcSetAlarm(RTCDriver *rtcp,
+ rtcalarm_t alarm,
+ const RTCAlarm *alarmspec);
+ void rtcGetAlarm(RTCDriver *rtcp, rtcalarm_t alarm, RTCAlarm *alarmspec);
+#endif
+#if RTC_SUPPORTS_CALLBACKS
+ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_RTC */
+#endif /* _RTC_H_ */
+
+/** @} */
diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h index 884b11e8d..bc4418f6b 100644 --- a/os/hal/include/usb.h +++ b/os/hal/include/usb.h @@ -173,11 +173,6 @@ /** @} */
/**
- * @brief Returned by some functions to report a busy endpoint.
- */
-#define USB_ENDPOINT_BUSY ((size_t)0xFFFFFFFF)
-
-/**
* @name Endpoint types and settings
* @{
*/
@@ -327,6 +322,16 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp, * @{
*/
/**
+ * @brief Connects the USB device.
+ */
+#define usbConnectBus(usbp) usb_lld_connect_bus(usbp)
+
+/**
+ * @brief Disconnect the USB device.
+ */
+#define usbDisconnectBus(usbp) usb_lld_disconnect_bus(usbp)
+
+/**
* @brief Returns the current frame number.
*
* @param[in] usbp pointer to the @p USBDriver object
@@ -363,6 +368,75 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp, #define usbGetReceiveStatusI(usbp, ep) ((usbp)->receiving & (1 << (ep)))
/**
+ * @brief Reads from a dedicated packet buffer.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in packet mode.
+ * @note This function can be invoked both in thread and IRQ context.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[out] buf buffer where to copy the packet data
+ * @param[in] n maximum number of bytes to copy. This value must
+ * not exceed the maximum packet size for this endpoint.
+ * @return The received packet size regardless the specified
+ * @p n parameter.
+ * @retval 0 Zero size packet received.
+ *
+ * @special
+ */
+#define usbReadPacketBuffer(usbp, ep, buf, n) \
+ usb_lld_read_packet_buffer(usbp, ep, buf, n)
+
+/**
+ * @brief Writes to a dedicated packet buffer.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in packet mode.
+ * @note This function can be invoked both in thread and IRQ context.
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] buf buffer where to fetch the packet data
+ * @param[in] n maximum number of bytes to copy. This value must
+ * not exceed the maximum packet size for this endpoint.
+ *
+ * @special
+ */
+#define usbWritePacketBuffer(usbp, ep, buf, n) \
+ usb_lld_write_packet_buffer(usbp, ep, buf, n)
+
+/**
+ * @brief Prepares for a receive transaction on an OUT endpoint.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in transaction mode.
+ * @post The endpoint is ready for @p usbStartReceiveI().
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[out] buf buffer where to copy the received data
+ * @param[in] n maximum number of bytes to copy
+ *
+ * @special
+ */
+#define usbPrepareReceive(usbp, ep, buf, n) \
+ usb_lld_prepare_receive(usbp, ep, buf, n)
+
+/**
+ * @brief Prepares for a transmit transaction on an IN endpoint.
+ * @pre In order to use this function he endpoint must have been
+ * initialized in transaction mode.
+ * @post The endpoint is ready for @p usbStartTransmitI().
+ *
+ * @param[in] usbp pointer to the @p USBDriver object
+ * @param[in] ep endpoint number
+ * @param[in] buf buffer where to fetch the data to be transmitted
+ * @param[in] n maximum number of bytes to copy
+ *
+ * @special
+ */
+#define usbPrepareTransmit(usbp, ep, buf, n) \
+ usb_lld_prepare_transmit(usbp, ep, buf, n)
+
+/**
* @brief Returns the exact size of a receive transaction.
* @details The received size can be different from the size specified in
* @p usbStartReceiveI() because the last packet could have a size
@@ -417,7 +491,7 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp, * callback in order to read the received setup packet.
* @pre In order to use this function the endpoint must have been
* initialized as a control endpoint.
- * @post The endpoint is ready to accept another packet.
+ * @note This function can be invoked both in thread and IRQ context.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
@@ -511,14 +585,8 @@ extern "C" { const USBEndpointConfig *epcp);
void usbDisableEndpointsI(USBDriver *usbp);
void usbReadSetupI(USBDriver *usbp, usbep_t ep, uint8_t *buf);
- size_t usbReadPacketI(USBDriver *usbp, usbep_t ep,
- uint8_t *buf, size_t n);
- size_t usbWritePacketI(USBDriver *usbp, usbep_t ep,
- const uint8_t *buf, size_t n);
- bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep,
- uint8_t *buf, size_t n);
- bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep,
- const uint8_t *buf, size_t n);
+ bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep);
+ bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep);
bool_t usbStallReceiveI(USBDriver *usbp, usbep_t ep);
bool_t usbStallTransmitI(USBDriver *usbp, usbep_t ep);
void _usb_reset(USBDriver *usbp);
|