git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7461 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2014-11-02 15:24:30 +00:00
parent 359413415a
commit a94bfc5f71
9 changed files with 135 additions and 147 deletions

View File

@ -437,7 +437,7 @@ typedef struct {
} SPIConfig; } SPIConfig;
/** /**
* @brief Structure representing a SPI driver. * @brief Structure representing an SPI driver.
*/ */
struct SPIDriver { struct SPIDriver {
/** /**

View File

@ -275,7 +275,7 @@ typedef struct {
} SPIConfig; } SPIConfig;
/** /**
* @brief Structure representing a SPI driver. * @brief Structure representing an SPI driver.
*/ */
struct SPIDriver { struct SPIDriver {
/** /**

View File

@ -388,20 +388,6 @@ struct USBDriver {
#define usb_lld_get_transaction_size(usbp, ep) \ #define usb_lld_get_transaction_size(usbp, ep) \
((usbp)->epc[ep]->out_state->rxcnt) ((usbp)->epc[ep]->out_state->rxcnt)
/**
* @brief Returns the exact size of a received packet.
* @pre The OUT endpoint must have been configured in packet mode
* in order to use this function.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @return Received data size.
*
* @notapi
*/
#define usb_lld_get_packet_size(usbp, ep) \
((size_t)USB_GET_DESCRIPTOR(ep)->RXCOUNT & RXCOUNT_COUNT_MASK)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,14 +15,13 @@
*/ */
/** /**
* @file templates/sdc_lld.c * @file PLATFORM/sdc_lld.c
* @brief SDC Driver subsystem low level driver source template. * @brief PLATFORM SDC subsystem low level driver source.
* *
* @addtogroup SDC * @addtogroup SDC
* @{ * @{
*/ */
#include "ch.h"
#include "hal.h" #include "hal.h"
#if HAL_USE_SDC || defined(__DOXYGEN__) #if HAL_USE_SDC || defined(__DOXYGEN__)
@ -183,20 +182,17 @@ void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg) {
* @param[out] resp pointer to the response buffer (one word) * @param[out] resp pointer to the response buffer (one word)
* *
* @return The operation status. * @return The operation status.
* @retval CH_SUCCESS operation succeeded. * @retval HAL_SUCCESS operation succeeded.
* @retval CH_FAILED operation failed. * @retval HAL_FAILED operation failed.
* *
* @notapi * @notapi
*/ */
bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, bool sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp) { uint32_t *resp) {
(void)sdcp; (void)sdcp;
(void)cmd;
(void)arg;
(void)resp;
return CH_SUCCESS; return HAL_SUCCESS;
} }
/** /**
@ -208,20 +204,17 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
* @param[out] resp pointer to the response buffer (one word) * @param[out] resp pointer to the response buffer (one word)
* *
* @return The operation status. * @return The operation status.
* @retval CH_SUCCESS operation succeeded. * @retval HAL_SUCCESS operation succeeded.
* @retval CH_FAILED operation failed. * @retval HAL_FAILED operation failed.
* *
* @notapi * @notapi
*/ */
bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, bool sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp) { uint32_t *resp) {
(void)sdcp; (void)sdcp;
(void)cmd;
(void)arg;
(void)resp;
return CH_SUCCESS; return HAL_SUCCESS;
} }
/** /**
@ -233,20 +226,17 @@ bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
* @param[out] resp pointer to the response buffer (four words) * @param[out] resp pointer to the response buffer (four words)
* *
* @return The operation status. * @return The operation status.
* @retval CH_SUCCESS operation succeeded. * @retval HAL_SUCCESS operation succeeded.
* @retval CH_FAILED operation failed. * @retval HAL_FAILED operation failed.
* *
* @notapi * @notapi
*/ */
bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, bool sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp) { uint32_t *resp) {
(void)sdcp; (void)sdcp;
(void)cmd;
(void)arg;
(void)resp;
return CH_SUCCESS; return HAL_SUCCESS;
} }
/** /**
@ -258,20 +248,20 @@ bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
* @param[in] n number of blocks to read * @param[in] n number of blocks to read
* *
* @return The operation status. * @return The operation status.
* @retval CH_SUCCESS operation succeeded. * @retval HAL_SUCCESS operation succeeded.
* @retval CH_FAILED operation failed. * @retval HAL_FAILED operation failed.
* *
* @notapi * @notapi
*/ */
bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk, bool sdc_lld_read_aligned(SDCDriver *sdcp, uint32_t startblk,
uint8_t *buf, uint32_t n) { uint8_t *buf, uint32_t n) {
(void)sdcp; (void)sdcp;
(void)startblk; (void)startblk;
(void)buf; (void)buf;
(void)n; (void)n;
return CH_SUCCESS; return HAL_SUCCESS;
} }
/** /**
@ -283,20 +273,58 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
* @param[in] n number of blocks to write * @param[in] n number of blocks to write
* *
* @return The operation status. * @return The operation status.
* @retval CH_SUCCESS operation succeeded. * @retval HAL_SUCCESS operation succeeded.
* @retval CH_FAILED operation failed. * @retval HAL_FAILED operation failed.
* *
* @notapi * @notapi
*/ */
bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk, bool sdc_lld_write_aligned(SDCDriver *sdcp, uint32_t startblk,
const uint8_t *buf, uint32_t n) { const uint8_t *buf, uint32_t n) {
(void)sdcp; (void)sdcp;
(void)startblk; (void)startblk;
(void)buf; (void)buf;
(void)n; (void)n;
return CH_SUCCESS; return HAL_SUCCESS;
}
/**
* @brief Reads one or more blocks.
*
* @param[in] sdcp pointer to the @p SDCDriver object
* @param[in] startblk first block to read
* @param[out] buf pointer to the read buffer
* @param[in] n number of blocks to read
*
* @return The operation status.
* @retval HAL_SUCCESS operation succeeded.
* @retval HAL_FAILED operation failed.
*
* @notapi
*/
bool sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
uint8_t *buf, uint32_t n) {
}
/**
* @brief Writes one or more blocks.
*
* @param[in] sdcp pointer to the @p SDCDriver object
* @param[in] startblk first block to write
* @param[out] buf pointer to the write buffer
* @param[in] n number of blocks to write
*
* @return The operation status.
* @retval HAL_SUCCESS operation succeeded.
* @retval HAL_FAILED operation failed.
*
* @notapi
*/
bool sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
const uint8_t *buf, uint32_t n) {
} }
/** /**
@ -305,16 +333,15 @@ bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
* @param[in] sdcp pointer to the @p SDCDriver object * @param[in] sdcp pointer to the @p SDCDriver object
* *
* @return The operation status. * @return The operation status.
* @retval CH_SUCCESS the operation succeeded. * @retval HAL_SUCCESS the operation succeeded.
* @retval CH_FAILED the operation failed. * @retval HAL_FAILED the operation failed.
* *
* @api * @api
*/ */
bool_t sdc_lld_sync(SDCDriver *sdcp) { bool sdc_lld_sync(SDCDriver *sdcp) {
(void)sdcp; (void)sdcp;
return HAL_SUCCESS;
return CH_SUCCESS;
} }
#endif /* HAL_USE_SDC */ #endif /* HAL_USE_SDC */

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,8 +15,8 @@
*/ */
/** /**
* @file templates/sdc_lld.h * @file PLATFORM/sdc_lld.h
* @brief SDC Driver subsystem low level driver header template. * @brief PLATFORM SDC subsystem low level driver header.
* *
* @addtogroup SDC * @addtogroup SDC
* @{ * @{
@ -39,13 +39,6 @@
* @name Configuration options * @name Configuration options
* @{ * @{
*/ */
/**
* @brief SDC driver enable switch.
* @details If set to @p TRUE the support for SDC1 is included.
*/
#if !defined(PLATFORM_SDC_USE_SDC1) || defined(__DOXYGEN__)
#define PLATFORM_SDC_USE_SDC1 TRUE
#endif
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/
@ -85,7 +78,7 @@ typedef struct SDCDriver SDCDriver;
* @note It could be empty on some architectures. * @note It could be empty on some architectures.
*/ */
typedef struct { typedef struct {
uint32_t dummy; uint32_t dummy;
} SDCConfig; } SDCConfig;
/** /**
@ -135,37 +128,11 @@ struct SDCDriver {
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @name R1 response utilities
* @{
*/
/**
* @brief Evaluates to @p TRUE if the R1 response contains error flags.
*
* @param[in] r1 the r1 response
*/
#define MMCSD_R1_ERROR(r1) (((r1) & MMCSD_R1_ERROR_MASK) != 0)
/**
* @brief Returns the status field of an R1 response.
*
* @param[in] r1 the r1 response
*/
#define MMCSD_R1_STS(r1) (((r1) >> 9) & 15)
/**
* @brief Evaluates to @p TRUE if the R1 response indicates a locked card.
*
* @param[in] r1 the r1 response
*/
#define MMCSD_R1_IS_CARD_LOCKED(r1) (((r1) >> 21) & 1)
/** @} */
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
#if PLATFORM_SDC_USE_SDC1 && !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
extern SDCDriver SDCD1; extern SDCDriver SDCD1;
#endif #endif
@ -180,19 +147,19 @@ extern "C" {
void sdc_lld_stop_clk(SDCDriver *sdcp); void sdc_lld_stop_clk(SDCDriver *sdcp);
void sdc_lld_set_bus_mode(SDCDriver *sdcp, sdcbusmode_t mode); void sdc_lld_set_bus_mode(SDCDriver *sdcp, sdcbusmode_t mode);
void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg); void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg);
bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, bool sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp); uint32_t *resp);
bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, bool sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp); uint32_t *resp);
bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, bool sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
uint32_t *resp); uint32_t *resp);
bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk, bool sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
uint8_t *buf, uint32_t n); uint8_t *buf, uint32_t n);
bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk, bool sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
const uint8_t *buf, uint32_t n); const uint8_t *buf, uint32_t n);
bool_t sdc_lld_sync(SDCDriver *sdcp); bool sdc_lld_sync(SDCDriver *sdcp);
bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp); bool sdc_lld_is_card_inserted(SDCDriver *sdcp);
bool_t sdc_lld_is_write_protected(SDCDriver *sdcp); bool sdc_lld_is_write_protected(SDCDriver *sdcp);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,14 +15,13 @@
*/ */
/** /**
* @file templates/spi_lld.c * @file PLATFORM/SPIv2/spi_lld.c
* @brief SPI Driver subsystem low level driver source template. * @brief PLATFORM SPI subsystem low level driver source.
* *
* @addtogroup SPI * @addtogroup SPI
* @{ * @{
*/ */
#include "ch.h"
#include "hal.h" #include "hal.h"
#if HAL_USE_SPI || defined(__DOXYGEN__) #if HAL_USE_SPI || defined(__DOXYGEN__)
@ -102,8 +101,6 @@ void spi_lld_start(SPIDriver *spip) {
void spi_lld_stop(SPIDriver *spip) { void spi_lld_stop(SPIDriver *spip) {
if (spip->state == SPI_READY) { if (spip->state == SPI_READY) {
/* Resets the peripheral.*/
/* Disables the peripheral.*/ /* Disables the peripheral.*/
#if PLATFORM_SPI_USE_SPI1 #if PLATFORM_SPI_USE_SPI1
if (&SPID1 == spip) { if (&SPID1 == spip) {

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,8 +15,8 @@
*/ */
/** /**
* @file templates/spi_lld.h * @file PLATFORM/spi_lld.h
* @brief SPI Driver subsystem low level driver header template. * @brief PLATFORM SPI subsystem low level driver header.
* *
* @addtogroup SPI * @addtogroup SPI
* @{ * @{
@ -40,11 +40,10 @@
* @{ * @{
*/ */
/** /**
* @brief SPI driver enable switch. * @brief SPI1 driver enable switch.
* @details If set to @p TRUE the support for SPI1 is included.
*/ */
#if !defined(PLATFORM_SPI_USE_SPI1) || defined(__DOXYGEN__) #if !defined(PLATFORM_SPI_USE_SPI1) || defined(__DOXYGEN__)
#define PLATFORM_SPI_USE_SPI1 FALSE #define PLATFORM_SPI_USE_SPI1 FALSE
#endif #endif
/** @} */ /** @} */
@ -76,9 +75,9 @@ typedef void (*spicallback_t)(SPIDriver *spip);
*/ */
typedef struct { typedef struct {
/** /**
* @brief Operation complete callback. * @brief Operation complete callback or @p NULL.
*/ */
spicallback_t end_cb; spicallback_t end_cb;
/* End of the mandatory fields.*/ /* End of the mandatory fields.*/
} SPIConfig; } SPIConfig;
@ -91,26 +90,22 @@ struct SPIDriver {
/** /**
* @brief Driver state. * @brief Driver state.
*/ */
spistate_t state; spistate_t state;
/** /**
* @brief Current configuration data. * @brief Current configuration data.
*/ */
const SPIConfig *config; const SPIConfig *config;
#if SPI_USE_WAIT || defined(__DOXYGEN__) #if SPI_USE_WAIT || defined(__DOXYGEN__)
/** /**
* @brief Waiting thread. * @brief Waiting thread.
*/ */
Thread *thread; thread_reference_t thread;
#endif /* SPI_USE_WAIT */ #endif /* SPI_USE_WAIT */
#if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__) #if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
/** /**
* @brief Mutex protecting the bus. * @brief Mutex protecting the peripheral.
*/ */
Mutex mutex; mutex_t mutex;
#elif CH_USE_SEMAPHORES
Semaphore semaphore;
#endif
#endif /* SPI_USE_MUTUAL_EXCLUSION */ #endif /* SPI_USE_MUTUAL_EXCLUSION */
#if defined(SPI_DRIVER_EXT_FIELDS) #if defined(SPI_DRIVER_EXT_FIELDS)
SPI_DRIVER_EXT_FIELDS SPI_DRIVER_EXT_FIELDS

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,14 +15,13 @@
*/ */
/** /**
* @file templates/usb_lld.c * @file PLATFORM/usb_lld.c
* @brief USB Driver subsystem low level driver source template. * @brief PLATFORM USB subsystem low level driver source.
* *
* @addtogroup USB * @addtogroup USB
* @{ * @{
*/ */
#include "ch.h"
#include "hal.h" #include "hal.h"
#if HAL_USE_USB || defined(__DOXYGEN__) #if HAL_USE_USB || defined(__DOXYGEN__)

View File

@ -1,5 +1,5 @@
/* /*
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio ChibiOS/HAL - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,8 +15,8 @@
*/ */
/** /**
* @file templates/usb_lld.h * @file PLATFORM/usb_lld.h
* @brief USB Driver subsystem low level driver header template. * @brief PLATFORM USB subsystem low level driver header.
* *
* @addtogroup USB * @addtogroup USB
* @{ * @{
@ -36,10 +36,15 @@
*/ */
#define USB_MAX_ENDPOINTS 4 #define USB_MAX_ENDPOINTS 4
/**
* @brief Status stage handling method.
*/
#define USB_EP0_STATUS_STAGE USB_EP0_STATUS_STAGE_SW
/** /**
* @brief The address can be changed immediately upon packet reception. * @brief The address can be changed immediately upon packet reception.
*/ */
#define USB_SET_ADDRESS_MODE USB_EARLY_SET_ADDRESS #define USB_SET_ADDRESS_MODE USB_LATE_SET_ADDRESS
/*===========================================================================*/ /*===========================================================================*/
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
@ -54,7 +59,7 @@
* @details If set to @p TRUE the support for USB1 is included. * @details If set to @p TRUE the support for USB1 is included.
*/ */
#if !defined(PLATFORM_USB_USE_USB1) || defined(__DOXYGEN__) #if !defined(PLATFORM_USB_USE_USB1) || defined(__DOXYGEN__)
#define PLATFORM_USB_USE_USB1 FALSE #define PLATFORM_USB_USE_USB1 FALSE
#endif #endif
/** @} */ /** @} */
@ -73,7 +78,7 @@ typedef struct {
/** /**
* @brief Buffer mode, queue or linear. * @brief Buffer mode, queue or linear.
*/ */
bool_t txqueued; bool txqueued;
/** /**
* @brief Requested transmit transfer size. * @brief Requested transmit transfer size.
*/ */
@ -93,8 +98,9 @@ typedef struct {
/** /**
* @brief Pointer to the output queue. * @brief Pointer to the output queue.
*/ */
OutputQueue *txqueue; output_queue_t *txqueue;
} queue; } queue;
/* End of the mandatory fields.*/
} mode; } mode;
} USBInEndpointState; } USBInEndpointState;
@ -105,7 +111,7 @@ typedef struct {
/** /**
* @brief Buffer mode, queue or linear. * @brief Buffer mode, queue or linear.
*/ */
bool_t rxqueued; bool rxqueued;
/** /**
* @brief Requested receive transfer size. * @brief Requested receive transfer size.
*/ */
@ -125,9 +131,10 @@ typedef struct {
/** /**
* @brief Pointer to the input queue. * @brief Pointer to the input queue.
*/ */
InputQueue *rxqueue; input_queue_t *rxqueue;
} queue; } queue;
} mode; } mode;
/* End of the mandatory fields.*/
} USBOutEndpointState; } USBOutEndpointState;
/** /**
@ -294,6 +301,16 @@ struct USBDriver {
/* Driver macros. */ /* Driver macros. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Returns the current frame number.
*
* @param[in] usbp pointer to the @p USBDriver object
* @return The current frame number.
*
* @notapi
*/
#define usb_lld_get_frame_number(usbp) 0
/** /**
* @brief Returns the exact size of a receive transaction. * @brief Returns the exact size of a receive transaction.
* @details The received size can be different from the size specified in * @details The received size can be different from the size specified in