Fixed few newly introduced documentation errors. Improved card detection.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4364 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2012-06-30 14:41:51 +00:00
parent 503e05816d
commit bfa477e96d
4 changed files with 74 additions and 58 deletions

View File

@ -56,9 +56,11 @@ void __early_init(void) {
* Card detection through the card internal pull-up on D3. * Card detection through the card internal pull-up on D3.
*/ */
bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp) { bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp) {
static bool_t last_status = FALSE;
(void)sdcp; if (blkIsTransferring(sdcp))
return (bool_t)palReadPad(GPIOC, GPIOC_SD_D3); return last_status;
return last_status = (bool_t)palReadPad(GPIOC, GPIOC_SD_D3);
} }
/* /*

View File

@ -59,28 +59,20 @@ static EventSource inserted_event, removed_event;
static void tmrfunc(void *p) { static void tmrfunc(void *p) {
BaseBlockDevice *bbdp = p; BaseBlockDevice *bbdp = p;
/* The presence check is performed only while the driver is not in a
transfer state because it is often performed by changing the mode of
the pin connected to the CS/D3 contact of the card, this could disturb
the transfer.*/
blkstate_t state = blkGetDriverState(bbdp);
chSysLockFromIsr(); chSysLockFromIsr();
if ((state != BLK_READING) && (state != BLK_WRITING)) { if (cnt > 0) {
/* Safe to perform the check.*/ if (blkIsInserted(bbdp)) {
if (cnt > 0) { if (--cnt == 0) {
if (blkIsInserted(bbdp)) { chEvtBroadcastI(&inserted_event);
if (--cnt == 0) {
chEvtBroadcastI(&inserted_event);
}
} }
else
cnt = POLLING_INTERVAL;
} }
else { else
if (!blkIsInserted(bbdp)) { cnt = POLLING_INTERVAL;
cnt = POLLING_INTERVAL; }
chEvtBroadcastI(&removed_event); else {
} if (!blkIsInserted(bbdp)) {
cnt = POLLING_INTERVAL;
chEvtBroadcastI(&removed_event);
} }
} }
chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, bbdp); chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, bbdp);

View File

@ -113,17 +113,39 @@ typedef struct {
*/ */
/** /**
* @brief Returns the driver state. * @brief Returns the driver state.
* @note Can be called in ISR context.
* *
* @param[in] ip pointer to a @p BaseBlockDevice or derived class * @param[in] ip pointer to a @p BaseBlockDevice or derived class
* *
* @return The driver state. * @return The driver state.
* *
* @api * @special
*/ */
#define blkGetDriverState(ip) ((ip)->state) #define blkGetDriverState(ip) ((ip)->state)
/**
* @brief Determines if the device is transferring data.
* @note Can be called in ISR context.
*
* @param[in] ip pointer to a @p BaseBlockDevice or derived class
*
* @return The driver state.
* @retval FALSE the device is not transferring data.
* @retval TRUE the device not transferring data.
*
* @special
*/
#define blkIsTransferring(ip) ((((ip)->state) == BLK_CONNECTING) || \
(((ip)->state) == BLK_DISCONNECTING) || \
(((ip)->state) == BLK_READING) || \
(((ip)->state) == BLK_WRITING))
/** /**
* @brief Returns the media insertion status. * @brief Returns the media insertion status.
* @note On some implementations this function can only be called if the
* device is not transferring data.
* The function @p blkIsTransferring() should be used before calling
* this function.
* *
* @param[in] ip pointer to a @p BaseBlockDevice or derived class * @param[in] ip pointer to a @p BaseBlockDevice or derived class
* *
@ -157,8 +179,8 @@ typedef struct {
* @param[in] ip pointer to a @p BaseBlockDevice or derived class * @param[in] ip pointer to a @p BaseBlockDevice or derived class
* *
* @return The operation status. * @return The operation status.
* @retval FALSE operation succeeded. * @retval CH_SUCCESS operation succeeded.
* @retval TRUE operation failed. * @retval CH_FAILED operation failed.
* *
* @api * @api
*/ */
@ -171,8 +193,8 @@ typedef struct {
* @param[in] ip pointer to a @p BaseBlockDevice or derived class * @param[in] ip pointer to a @p BaseBlockDevice or derived class
* *
* @return The operation status. * @return The operation status.
* @retval FALSE operation succeeded. * @retval CH_SUCCESS operation succeeded.
* @retval TRUE operation failed. * @retval CH_FAILED operation failed.
* *
* @api * @api
*/ */
@ -187,8 +209,8 @@ typedef struct {
* @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 FALSE operation succeeded. * @retval CH_SUCCESS operation succeeded.
* @retval TRUE operation failed. * @retval CH_FAILED operation failed.
* *
* @api * @api
*/ */
@ -204,8 +226,8 @@ typedef struct {
* @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 FALSE operation succeeded. * @retval CH_SUCCESS operation succeeded.
* @retval TRUE operation failed. * @retval CH_FAILED operation failed.
* *
* @api * @api
*/ */
@ -218,8 +240,8 @@ typedef struct {
* @param[in] ip pointer to a @p BaseBlockDevice or derived class * @param[in] ip pointer to a @p BaseBlockDevice or derived class
* *
* @return The operation status. * @return The operation status.
* @retval FALSE operation succeeded. * @retval CH_SUCCESS operation succeeded.
* @retval TRUE operation failed. * @retval CH_FAILED operation failed.
* *
* @api * @api
*/ */
@ -232,8 +254,8 @@ typedef struct {
* @param[out] bdip pointer to a @p BlockDeviceInfo structure * @param[out] bdip pointer to a @p BlockDeviceInfo structure
* *
* @return The operation status. * @return The operation status.
* @retval FALSE operation succeeded. * @retval CH_SUCCESS operation succeeded.
* @retval TRUE operation failed. * @retval CH_FAILED operation failed.
* *
* @api * @api
*/ */

View File

@ -293,8 +293,8 @@ static uint8_t send_command_R3(MMCDriver *mmcp, uint8_t cmd, uint32_t arg,
* @param[out] csd pointer to the CSD buffer * @param[out] csd pointer to the CSD buffer
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @notapi * @notapi
*/ */
@ -431,9 +431,9 @@ void mmcStop(MMCDriver *mmcp) {
* @param[in] mmcp pointer to the @p MMCDriver object * @param[in] mmcp pointer to the @p MMCDriver object
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded and the driver is now * @retval CH_SUCCESS the operation succeeded and the driver is now
* in the @p MMC_READY state. * in the @p MMC_READY state.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -538,9 +538,9 @@ failed:
* @param[in] mmcp pointer to the @p MMCDriver object * @param[in] mmcp pointer to the @p MMCDriver object
* @return The operation status. * @return The operation status.
* *
* @retval CH_FAILED the operation succeeded and the driver is now * @retval CH_SUCCESS the operation succeeded and the driver is now
* in the @p MMC_INSERTED state. * in the @p MMC_INSERTED state.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -573,8 +573,8 @@ bool_t mmcDisconnect(MMCDriver *mmcp) {
* @param[in] startblk first block to read * @param[in] startblk first block to read
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -611,8 +611,8 @@ bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
* @param[out] buffer pointer to the read buffer * @param[out] buffer pointer to the read buffer
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -645,8 +645,8 @@ bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
* @param[in] mmcp pointer to the @p MMCDriver object * @param[in] mmcp pointer to the @p MMCDriver object
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -677,8 +677,8 @@ bool_t mmcStopSequentialRead(MMCDriver *mmcp) {
* @param[in] startblk first block to write * @param[in] startblk first block to write
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -713,8 +713,8 @@ bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk) {
* @param[out] buffer pointer to the write buffer * @param[out] buffer pointer to the write buffer
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -748,8 +748,8 @@ bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {
* @param[in] mmcp pointer to the @p MMCDriver object * @param[in] mmcp pointer to the @p MMCDriver object
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -775,8 +775,8 @@ bool_t mmcStopSequentialWrite(MMCDriver *mmcp) {
* @param[in] mmcp pointer to the @p MMCDriver object * @param[in] mmcp pointer to the @p MMCDriver object
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -798,8 +798,8 @@ bool_t mmcSync(MMCDriver *mmcp) {
* @param[out] bdip pointer to a @p BlockDeviceInfo structure * @param[out] bdip pointer to a @p BlockDeviceInfo structure
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */
@ -824,8 +824,8 @@ bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip) {
* @param[in] endblk ending block number * @param[in] endblk ending block number
* *
* @return The operation status. * @return The operation status.
* @retval CH_FAILED the operation succeeded. * @retval CH_SUCCESS the operation succeeded.
* @retval CH_SUCCESS the operation failed. * @retval CH_FAILED the operation failed.
* *
* @api * @api
*/ */