Added elfAcquireBus()/eflReleaseBus() functions to EFL driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15070 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-11-13 12:40:02 +00:00
parent eb47d2ca91
commit 655ea2923c
3 changed files with 62 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
ChibiOS - Copyright (C) 2006..2021 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.
@ -35,6 +35,14 @@
/* Driver pre-compile time settings. */
/*===========================================================================*/
/**
* @brief Enables the @p eflAcquireUse() and @p eflReleaseUse() APIs.
* @note Disabling this option saves both code and data space.
*/
#if !defined(EFL_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
#define EFL_USE_MUTUAL_EXCLUSION TRUE
#endif
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@ -96,10 +104,16 @@ typedef struct hal_efl_config {
*/
struct hal_efl_driver {
/**
* @brief SNORDriver Virtual Methods Table.
* @brief EFlashDriver Virtual Methods Table.
*/
const struct EFlashDriverVMT *vmt;
_efl_driver_data
#if (EFL_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
/**
* @brief Mutex protecting EFL.
*/
mutex_t mutex;
#endif /* EFL_USE_MUTUAL_EXCLUSION == TRUE */
/* End of the mandatory fields.*/
efl_lld_driver_fields;
};
@ -115,10 +129,12 @@ struct hal_efl_driver {
#ifdef __cplusplus
extern "C" {
#endif
void eflInit(void);
void eflObjectInit(EFlashDriver *eflp);
void eflInit(void);
void eflObjectInit(EFlashDriver *eflp);
msg_t eflStart(EFlashDriver *eflp, const EFlashConfig *config);
void eflStop(EFlashDriver *eflp);
void eflStop(EFlashDriver *eflp);
void eflAcquireBus(EFlashDriver *eflp);
void eflReleaseBus(EFlashDriver *eflp);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
ChibiOS - Copyright (C) 2006..2021 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.
@ -80,6 +80,9 @@ void eflObjectInit(EFlashDriver *eflp) {
eflp->vmt = &vmt;
eflp->state = FLASH_STOP;
#if EFL_USE_MUTUAL_EXCLUSION == TRUE
osalMutexObjectInit(&eflp->mutex);
#endif
}
/**
@ -145,6 +148,42 @@ void eflStop(EFlashDriver *eflp) {
osalSysUnlock();
}
#if (EFL_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
/**
* @brief Gains exclusive access to EFL.
* @details This function tries to gain ownership of EFL. If EFL
* is already being used then the invoking thread is queued.
* @pre In order to use this function the option @p EFL_USE_MUTUAL_EXCLUSION
* must be enabled.
*
* @param[in] eflp pointer to the @p EFlashDriver object
*
* @api
*/
void eflAcquireBus(EFlashDriver *eflp) {
osalDbgCheck(eflp != NULL);
osalMutexLock(&eflp->mutex);
}
/**
* @brief Releases exclusive access to EFL.
* @pre In order to use this function the option @p EFL_USE_MUTUAL_EXCLUSION
* must be enabled.
*
* @param[in] eflp pointer to the @p EFlashDriver object
*
* @api
*/
void eflReleaseBus(EFlashDriver *eflp) {
osalDbgCheck(eflp != NULL);
osalMutexUnlock(&eflp->mutex);
}
#endif /* EFL_USE_MUTUAL_EXCLUSION == TRUE */
#endif /* HAL_USE_EFL == TRUE */
/** @} */

View File

@ -74,6 +74,7 @@
*****************************************************************************
*** Next ***
- NEW: Added elfAcquireBus()/eflReleaseBus() functions to EFL driver.
- NEW: Increased stacks size in RT test suite from 128 to 192. added an
option to override the stack size by defining THREADS_STACK_SIZE
in the makefile.