Fixed flash state machine, removed EXT remains.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12572 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
a3e9966359
commit
d8af50ca0d
|
@ -18,5 +18,35 @@
|
||||||
* @defgroup HAL_FLASH Generic NOR Flash Interface
|
* @defgroup HAL_FLASH Generic NOR Flash Interface
|
||||||
* @brief HAL Generic NOR Flash Driver Interface.
|
* @brief HAL Generic NOR Flash Driver Interface.
|
||||||
*
|
*
|
||||||
|
* @section flash_1 Driver State Machine
|
||||||
|
* The flash driver implements a state machine internally, not all the driver
|
||||||
|
* functionalities can be used in any moment, any transition not explicitly
|
||||||
|
* shown in the following diagram has to be considered an error and shall
|
||||||
|
* be captured by an assertion (if enabled).
|
||||||
|
* @dot
|
||||||
|
digraph example {
|
||||||
|
rankdir="LR";
|
||||||
|
node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
|
||||||
|
edge [fontname=Helvetica, fontsize=8];
|
||||||
|
stop [label="FLS_STOP\nLow Power"];
|
||||||
|
uninit [label="FLS_UNINIT", style="bold"];
|
||||||
|
ready [label="FLS_READY\nClock Enabled"];
|
||||||
|
read [label="FLS_READ\nReading"];
|
||||||
|
pgm [label="FLS_PGM\nProgramming"];
|
||||||
|
erase [label="FLS_ERASE\nErasing"];
|
||||||
|
uninit -> stop [label=" xxxInit()", constraint=false];
|
||||||
|
stop -> stop [label=" xxxStop()"];
|
||||||
|
stop -> ready [label=" xxxStart()"];
|
||||||
|
ready -> stop [label=" xStop()"];
|
||||||
|
ready -> read [label=" flashRead()\nflashVerifyErase()"];
|
||||||
|
read -> ready [label=" return"];
|
||||||
|
ready -> pgm [label=" flashProgram()"];
|
||||||
|
pgm -> ready [label=" return"];
|
||||||
|
ready -> erase [label=" \n\nflashEraseAll()\nflashEraseSector()"];
|
||||||
|
erase -> ready [label=" flashQueryErase()\nFLASH_NO_ERROR\nFLASH_ERROR_*"];
|
||||||
|
erase -> erase [label=" flashQueryErase()\nflashProgram()\nflashRead()\nFLASH_BUSY_ERASING"];
|
||||||
|
}
|
||||||
|
* @enddot
|
||||||
|
*
|
||||||
* @ingroup HAL_ABSTRACT_PERIPHERALS
|
* @ingroup HAL_ABSTRACT_PERIPHERALS
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* @details This module implements a generic driver for serial NOR Flash
|
* @details This module implements a generic driver for serial NOR Flash
|
||||||
* devices.
|
* devices.
|
||||||
*
|
*
|
||||||
* @section flash_1 Driver State Machine
|
* @section snorflash_1 Driver State Machine
|
||||||
* The flash driver implements a state machine internally, not all the driver
|
* The flash driver implements a state machine internally, not all the driver
|
||||||
* functionalities can be used in any moment, any transition not explicitly
|
* functionalities can be used in any moment, any transition not explicitly
|
||||||
* shown in the following diagram has to be considered an error and shall
|
* shown in the following diagram has to be considered an error and shall
|
||||||
|
@ -34,23 +34,19 @@
|
||||||
uninit [label="FLS_UNINIT", style="bold"];
|
uninit [label="FLS_UNINIT", style="bold"];
|
||||||
ready [label="FLS_READY\nClock Enabled"];
|
ready [label="FLS_READY\nClock Enabled"];
|
||||||
read [label="FLS_READ\nReading"];
|
read [label="FLS_READ\nReading"];
|
||||||
program [label="FLS_PGM\nProgramming"];
|
pgm [label="FLS_PGM\nProgramming"];
|
||||||
erasea [label="FLS_ERASEA\nErasing All"];
|
erase [label="FLS_ERASE\nErasing"];
|
||||||
erases [label="FLS_ERASES\nErasing Sector"];
|
uninit -> stop [label=" snorInit()", constraint=false];
|
||||||
uninit -> stop [label=" flashInit()", constraint=false];
|
stop -> stop [label=" snorStop()"];
|
||||||
stop -> stop [label=" flashStop()"];
|
stop -> ready [label=" snorStart()"];
|
||||||
stop -> ready [label=" flashStart()"];
|
ready -> stop [label=" snorStop()"];
|
||||||
ready -> stop [label=" flashStop()"];
|
|
||||||
ready -> read [label=" flashRead()\nflashVerifyErase()"];
|
ready -> read [label=" flashRead()\nflashVerifyErase()"];
|
||||||
read -> ready [label=" return"];
|
read -> ready [label=" return"];
|
||||||
ready -> program [label=" flashProgram()"];
|
ready -> pgm [label=" flashProgram()"];
|
||||||
program -> ready [label=" return"];
|
pgm -> ready [label=" return"];
|
||||||
ready -> erasea [label=" flashEraseAll)"];
|
ready -> erase [label=" \n\nflashEraseAll()\nflashEraseSector()"];
|
||||||
erasea -> ready [label=" flashQueryErase()\nFLASH_NO_ERROR\nFLASH_ERROR_*"];
|
erase -> ready [label=" flashQueryErase()\nFLASH_NO_ERROR\nFLASH_ERROR_*"];
|
||||||
erasea -> erasea [label=" flashQueryErase()\nflashProgram()\nflashRead()\nFLASH_BUSY_ERASE"];
|
erase -> erase [label=" flashQueryErase()\nflashProgram()\nflashRead()\nFLASH_BUSY_ERASING"];
|
||||||
ready -> erases [label=" flashEraseSector()"];
|
|
||||||
erases -> ready [label=" flashQueryErase()\nFLASH_NO_ERROR\nFLASH_ERROR_*"];
|
|
||||||
erases -> erases [label=" flashQueryErase()\nflashProgram()\nflashRead()\nFLASH_BUSY_ERASE"];
|
|
||||||
}
|
}
|
||||||
* @enddot
|
* @enddot
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,9 +30,6 @@ endif
|
||||||
ifneq ($(findstring HAL_USE_DAC TRUE,$(HALCONF)),)
|
ifneq ($(findstring HAL_USE_DAC TRUE,$(HALCONF)),)
|
||||||
HALSRC += $(CHIBIOS)/os/hal/src/hal_dac.c
|
HALSRC += $(CHIBIOS)/os/hal/src/hal_dac.c
|
||||||
endif
|
endif
|
||||||
ifneq ($(findstring HAL_USE_EXT TRUE,$(HALCONF)),)
|
|
||||||
HALSRC += $(CHIBIOS)/os/hal/src/hal_ext.c
|
|
||||||
endif
|
|
||||||
ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),)
|
ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),)
|
||||||
HALSRC += $(CHIBIOS)/os/hal/src/hal_gpt.c
|
HALSRC += $(CHIBIOS)/os/hal/src/hal_gpt.c
|
||||||
endif
|
endif
|
||||||
|
@ -99,7 +96,6 @@ HALSRC = $(CHIBIOS)/os/hal/src/hal.c \
|
||||||
$(CHIBIOS)/os/hal/src/hal_can.c \
|
$(CHIBIOS)/os/hal/src/hal_can.c \
|
||||||
$(CHIBIOS)/os/hal/src/hal_crypto.c \
|
$(CHIBIOS)/os/hal/src/hal_crypto.c \
|
||||||
$(CHIBIOS)/os/hal/src/hal_dac.c \
|
$(CHIBIOS)/os/hal/src/hal_dac.c \
|
||||||
$(CHIBIOS)/os/hal/src/hal_ext.c \
|
|
||||||
$(CHIBIOS)/os/hal/src/hal_gpt.c \
|
$(CHIBIOS)/os/hal/src/hal_gpt.c \
|
||||||
$(CHIBIOS)/os/hal/src/hal_i2c.c \
|
$(CHIBIOS)/os/hal/src/hal_i2c.c \
|
||||||
$(CHIBIOS)/os/hal/src/hal_i2s.c \
|
$(CHIBIOS)/os/hal/src/hal_i2s.c \
|
||||||
|
|
|
@ -140,7 +140,6 @@
|
||||||
#include "hal_can.h"
|
#include "hal_can.h"
|
||||||
#include "hal_crypto.h"
|
#include "hal_crypto.h"
|
||||||
#include "hal_dac.h"
|
#include "hal_dac.h"
|
||||||
#include "hal_ext.h"
|
|
||||||
#include "hal_gpt.h"
|
#include "hal_gpt.h"
|
||||||
#include "hal_i2c.h"
|
#include "hal_i2c.h"
|
||||||
#include "hal_i2s.h"
|
#include "hal_i2s.h"
|
||||||
|
|
|
@ -1,151 +0,0 @@
|
||||||
/*
|
|
||||||
ChibiOS - Copyright (C) 2006..2018 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.
|
|
||||||
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_ext.h
|
|
||||||
* @brief EXT Driver macros and structures.
|
|
||||||
*
|
|
||||||
* @addtogroup EXT
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HAL_EXT_H
|
|
||||||
#define HAL_EXT_H
|
|
||||||
|
|
||||||
#if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver constants. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @name EXT channel modes
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define EXT_CH_MODE_EDGES_MASK 3U /**< @brief Mask of edges field. */
|
|
||||||
#define EXT_CH_MODE_DISABLED 0U /**< @brief Channel disabled. */
|
|
||||||
#define EXT_CH_MODE_RISING_EDGE 1U /**< @brief Rising edge callback. */
|
|
||||||
#define EXT_CH_MODE_FALLING_EDGE 2U /**< @brief Falling edge callback. */
|
|
||||||
#define EXT_CH_MODE_BOTH_EDGES 3U /**< @brief Both edges callback. */
|
|
||||||
#define EXT_CH_MODE_LOW_LEVEL 5U /**< @brief low level callback. */
|
|
||||||
|
|
||||||
#define EXT_CH_MODE_AUTOSTART 4U /**< @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 "hal_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)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Changes the operation mode of a channel.
|
|
||||||
* @note This function attempts to write over the current configuration
|
|
||||||
* structure that must have been not declared constant. This
|
|
||||||
* violates the @p const qualifier in @p extStart() but it is
|
|
||||||
* intentional. This function cannot be used if the configuration
|
|
||||||
* structure is declared @p const.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] channel channel to be changed
|
|
||||||
* @param[in] extcp new configuration for the channel
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
#define extSetChannelMode(extp, channel, extcp) { \
|
|
||||||
osalSysLock(); \
|
|
||||||
extSetChannelModeI(extp, channel, extcp); \
|
|
||||||
osalSysUnlock(); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* 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);
|
|
||||||
void extSetChannelModeI(EXTDriver *extp,
|
|
||||||
expchannel_t channel,
|
|
||||||
const EXTChannelConfig *extcp);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAL_USE_EXT == TRUE */
|
|
||||||
|
|
||||||
#endif /* HAL_EXT_H */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -80,9 +80,6 @@ void halInit(void) {
|
||||||
#if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
|
#if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
|
||||||
dacInit();
|
dacInit();
|
||||||
#endif
|
#endif
|
||||||
#if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
|
|
||||||
extInit();
|
|
||||||
#endif
|
|
||||||
#if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
|
#if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
|
||||||
gptInit();
|
gptInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,206 +0,0 @@
|
||||||
/*
|
|
||||||
ChibiOS - Copyright (C) 2006..2018 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.
|
|
||||||
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_ext.c
|
|
||||||
* @brief EXT Driver code.
|
|
||||||
*
|
|
||||||
* @addtogroup EXT
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "hal.h"
|
|
||||||
|
|
||||||
#if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local definitions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver exported variables. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local variables and types. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local functions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver exported functions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXT Driver initialization.
|
|
||||||
* @note This function is implicitly invoked by @p halInit(), there is
|
|
||||||
* no need to explicitly initialize the driver.
|
|
||||||
*
|
|
||||||
* @init
|
|
||||||
*/
|
|
||||||
void extInit(void) {
|
|
||||||
|
|
||||||
ext_lld_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the standard part of a @p EXTDriver structure.
|
|
||||||
*
|
|
||||||
* @param[out] extp pointer to the @p EXTDriver object
|
|
||||||
*
|
|
||||||
* @init
|
|
||||||
*/
|
|
||||||
void extObjectInit(EXTDriver *extp) {
|
|
||||||
|
|
||||||
extp->state = EXT_STOP;
|
|
||||||
extp->config = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configures and activates the EXT peripheral.
|
|
||||||
* @post After activation all EXT channels are in the disabled state,
|
|
||||||
* use @p extChannelEnable() in order to activate them.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] config pointer to the @p EXTConfig object
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void extStart(EXTDriver *extp, const EXTConfig *config) {
|
|
||||||
|
|
||||||
osalDbgCheck((extp != NULL) && (config != NULL));
|
|
||||||
|
|
||||||
osalSysLock();
|
|
||||||
osalDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
|
|
||||||
"invalid state");
|
|
||||||
extp->config = config;
|
|
||||||
ext_lld_start(extp);
|
|
||||||
extp->state = EXT_ACTIVE;
|
|
||||||
osalSysUnlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deactivates the EXT peripheral.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void extStop(EXTDriver *extp) {
|
|
||||||
|
|
||||||
osalDbgCheck(extp != NULL);
|
|
||||||
|
|
||||||
osalSysLock();
|
|
||||||
|
|
||||||
osalDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
|
|
||||||
"invalid state");
|
|
||||||
|
|
||||||
ext_lld_stop(extp);
|
|
||||||
extp->config = NULL;
|
|
||||||
extp->state = EXT_STOP;
|
|
||||||
|
|
||||||
osalSysUnlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables an EXT channel.
|
|
||||||
* @pre The channel must not be in @p EXT_CH_MODE_DISABLED mode.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] channel channel to be enabled
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void extChannelEnable(EXTDriver *extp, expchannel_t channel) {
|
|
||||||
|
|
||||||
osalDbgCheck((extp != NULL) && (channel < (expchannel_t)EXT_MAX_CHANNELS));
|
|
||||||
|
|
||||||
osalSysLock();
|
|
||||||
osalDbgAssert((extp->state == EXT_ACTIVE) &&
|
|
||||||
((extp->config->channels[channel].mode &
|
|
||||||
EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED),
|
|
||||||
"invalid state");
|
|
||||||
extChannelEnableI(extp, channel);
|
|
||||||
osalSysUnlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables an EXT channel.
|
|
||||||
* @pre The channel must not be in @p EXT_CH_MODE_DISABLED mode.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] channel channel to be disabled
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void extChannelDisable(EXTDriver *extp, expchannel_t channel) {
|
|
||||||
|
|
||||||
osalDbgCheck((extp != NULL) && (channel < (expchannel_t)EXT_MAX_CHANNELS));
|
|
||||||
|
|
||||||
osalSysLock();
|
|
||||||
osalDbgAssert((extp->state == EXT_ACTIVE) &&
|
|
||||||
((extp->config->channels[channel].mode &
|
|
||||||
EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED),
|
|
||||||
"invalid state");
|
|
||||||
extChannelDisableI(extp, channel);
|
|
||||||
osalSysUnlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Changes the operation mode of a channel.
|
|
||||||
* @note This function attempts to write over the current configuration
|
|
||||||
* structure that must have been not declared constant. This
|
|
||||||
* violates the @p const qualifier in @p extStart() but it is
|
|
||||||
* intentional.
|
|
||||||
* @note This function cannot be used if the configuration structure is
|
|
||||||
* declared @p const.
|
|
||||||
* @note The effect of this function on constant configuration structures
|
|
||||||
* is not defined.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] channel channel to be changed
|
|
||||||
* @param[in] extcp new configuration for the channel
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
void extSetChannelModeI(EXTDriver *extp,
|
|
||||||
expchannel_t channel,
|
|
||||||
const EXTChannelConfig *extcp) {
|
|
||||||
EXTChannelConfig *oldcp;
|
|
||||||
|
|
||||||
osalDbgCheck((extp != NULL) &&
|
|
||||||
(channel < (expchannel_t)EXT_MAX_CHANNELS) &&
|
|
||||||
(extcp != NULL));
|
|
||||||
|
|
||||||
osalDbgAssert(extp->state == EXT_ACTIVE, "invalid state");
|
|
||||||
|
|
||||||
/* Note that here the access is enforced as non-const, known access
|
|
||||||
violation.*/
|
|
||||||
/*lint -save -e9005 [11.8] Known issue, the driver needs rework here.*/
|
|
||||||
oldcp = (EXTChannelConfig *)&extp->config->channels[channel];
|
|
||||||
/*lint -restore*/
|
|
||||||
|
|
||||||
/* Overwriting the old channels configuration then the channel is
|
|
||||||
reconfigured by the low level driver.*/
|
|
||||||
*oldcp = *extcp;
|
|
||||||
ext_lld_channel_enable(extp, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAL_USE_EXT == TRUE */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -1,147 +0,0 @@
|
||||||
/*
|
|
||||||
ChibiOS - Copyright (C) 2006..2018 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.
|
|
||||||
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_ext_lld.c
|
|
||||||
* @brief PLATFORM EXT subsystem low level driver source.
|
|
||||||
*
|
|
||||||
* @addtogroup EXT
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "hal.h"
|
|
||||||
|
|
||||||
#if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local definitions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver exported variables. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXT1 driver identifier.
|
|
||||||
*/
|
|
||||||
#if (PLATFORM_EXT_USE_EXT1 == TRUE) || defined(__DOXYGEN__)
|
|
||||||
EXTDriver EXTD1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local variables and types. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver local functions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver interrupt handlers. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver exported functions. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Low level EXT driver initialization.
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
void ext_lld_init(void) {
|
|
||||||
|
|
||||||
#if PLATFORM_EXT_USE_EXT1 == TRUE
|
|
||||||
/* Driver initialization.*/
|
|
||||||
extObjectInit(&EXTD1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configures and activates the EXT peripheral.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
void ext_lld_start(EXTDriver *extp) {
|
|
||||||
|
|
||||||
if (extp->state == EXT_STOP) {
|
|
||||||
/* Enables the peripheral.*/
|
|
||||||
#if PLATFORM_EXT_USE_EXT1 == TRUE
|
|
||||||
if (&EXTD1 == extp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* Configures the peripheral.*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deactivates the EXT peripheral.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
void ext_lld_stop(EXTDriver *extp) {
|
|
||||||
|
|
||||||
if (extp->state == EXT_ACTIVE) {
|
|
||||||
/* Resets the peripheral.*/
|
|
||||||
|
|
||||||
/* Disables the peripheral.*/
|
|
||||||
#if PLATFORM_EXT_USE_EXT1 == TRUE
|
|
||||||
if (&EXTD1 == extp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enables an EXT channel.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] channel channel to be enabled
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel) {
|
|
||||||
|
|
||||||
(void)extp;
|
|
||||||
(void)channel;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables an EXT channel.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXTDriver object
|
|
||||||
* @param[in] channel channel to be disabled
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel) {
|
|
||||||
|
|
||||||
(void)extp;
|
|
||||||
(void)channel;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAL_USE_EXT == TRUE */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -1,150 +0,0 @@
|
||||||
/*
|
|
||||||
ChibiOS - Copyright (C) 2006..2018 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.
|
|
||||||
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_ext_lld.h
|
|
||||||
* @brief PLATFORM EXT subsystem low level driver header.
|
|
||||||
*
|
|
||||||
* @addtogroup EXT
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HAL_EXT_LLD_H
|
|
||||||
#define HAL_EXT_LLD_H
|
|
||||||
|
|
||||||
#if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver constants. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Available number of EXT channels.
|
|
||||||
*/
|
|
||||||
#define EXT_MAX_CHANNELS 20
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver pre-compile time settings. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @name PLATFORM configuration options
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @brief EXT driver enable switch.
|
|
||||||
* @details If set to @p TRUE the support for EXT1 is included.
|
|
||||||
* @note The default is @p FALSE.
|
|
||||||
*/
|
|
||||||
#if !defined(PLATFORM_EXT_USE_EXT1) || defined(__DOXYGEN__)
|
|
||||||
#define PLATFORM_EXT_USE_EXT1 FALSE
|
|
||||||
#endif
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Derived constants and error checks. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver data structures and types. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief EXT channel identifier.
|
|
||||||
*/
|
|
||||||
typedef uint32_t expchannel_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Type of an EXT generic notification callback.
|
|
||||||
*
|
|
||||||
* @param[in] extp pointer to the @p EXPDriver object triggering the
|
|
||||||
* callback
|
|
||||||
*/
|
|
||||||
typedef void (*extcallback_t)(EXTDriver *extp, expchannel_t channel);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Channel configuration structure.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/**
|
|
||||||
* @brief Channel mode.
|
|
||||||
*/
|
|
||||||
uint32_t mode;
|
|
||||||
/**
|
|
||||||
* @brief Channel callback.
|
|
||||||
* @details In the STM32 implementation a @p NULL callback pointer is
|
|
||||||
* valid and configures the channel as an event sources instead
|
|
||||||
* of an interrupt source.
|
|
||||||
*/
|
|
||||||
extcallback_t cb;
|
|
||||||
} EXTChannelConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Driver configuration structure.
|
|
||||||
* @note It could be empty on some architectures.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
/**
|
|
||||||
* @brief Channel configurations.
|
|
||||||
*/
|
|
||||||
EXTChannelConfig channels[EXT_MAX_CHANNELS];
|
|
||||||
/* End of the mandatory fields.*/
|
|
||||||
} EXTConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Structure representing an EXT driver.
|
|
||||||
*/
|
|
||||||
struct EXTDriver {
|
|
||||||
/**
|
|
||||||
* @brief Driver state.
|
|
||||||
*/
|
|
||||||
extstate_t state;
|
|
||||||
/**
|
|
||||||
* @brief Current configuration data.
|
|
||||||
*/
|
|
||||||
const EXTConfig *config;
|
|
||||||
/* End of the mandatory fields.*/
|
|
||||||
};
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Driver macros. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* External declarations. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
#if (PLATFORM_EXT_USE_EXT1 == TRUE) && !defined(__DOXYGEN__)
|
|
||||||
extern EXTDriver EXTD1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
void ext_lld_init(void);
|
|
||||||
void ext_lld_start(EXTDriver *extp);
|
|
||||||
void ext_lld_stop(EXTDriver *extp);
|
|
||||||
void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel);
|
|
||||||
void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAL_USE_EXT == TRUE */
|
|
||||||
|
|
||||||
#endif /* HAL_EXT_LLD_H */
|
|
||||||
|
|
||||||
/** @} */
|
|
|
@ -22,9 +22,6 @@ endif
|
||||||
ifneq ($(findstring HAL_USE_DAC TRUE,$(HALCONF)),)
|
ifneq ($(findstring HAL_USE_DAC TRUE,$(HALCONF)),)
|
||||||
PLATFORMSRC += ${CHIBIOS}/os/hal/templates/hal_dac_lld.c
|
PLATFORMSRC += ${CHIBIOS}/os/hal/templates/hal_dac_lld.c
|
||||||
endif
|
endif
|
||||||
ifneq ($(findstring HAL_USE_EXT TRUE,$(HALCONF)),)
|
|
||||||
PLATFORMSRC += ${CHIBIOS}/os/hal/templates/hal_ext_lld.c
|
|
||||||
endif
|
|
||||||
ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),)
|
ifneq ($(findstring HAL_USE_GPT TRUE,$(HALCONF)),)
|
||||||
PLATFORMSRC += ${CHIBIOS}/os/hal/templates/hal_gpt_lld.c
|
PLATFORMSRC += ${CHIBIOS}/os/hal/templates/hal_gpt_lld.c
|
||||||
endif
|
endif
|
||||||
|
@ -82,7 +79,6 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/templates/hal_lld.c \
|
||||||
${CHIBIOS}/os/hal/templates/hal_can_lld.c \
|
${CHIBIOS}/os/hal/templates/hal_can_lld.c \
|
||||||
${CHIBIOS}/os/hal/templates/hal_crypto_lld.c \
|
${CHIBIOS}/os/hal/templates/hal_crypto_lld.c \
|
||||||
${CHIBIOS}/os/hal/templates/hal_dac_lld.c \
|
${CHIBIOS}/os/hal/templates/hal_dac_lld.c \
|
||||||
${CHIBIOS}/os/hal/templates/hal_ext_lld.c \
|
|
||||||
${CHIBIOS}/os/hal/templates/hal_gpt_lld.c \
|
${CHIBIOS}/os/hal/templates/hal_gpt_lld.c \
|
||||||
${CHIBIOS}/os/hal/templates/hal_i2c_lld.c \
|
${CHIBIOS}/os/hal/templates/hal_i2c_lld.c \
|
||||||
${CHIBIOS}/os/hal/templates/hal_i2s_lld.c \
|
${CHIBIOS}/os/hal/templates/hal_i2s_lld.c \
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** Next ***
|
*** Next ***
|
||||||
|
- NEW: Removed deprecated EXT driver.
|
||||||
- NEW: Added a new function chMtxGetOwnerI() to RT mutexes subsystem.
|
- NEW: Added a new function chMtxGetOwnerI() to RT mutexes subsystem.
|
||||||
- NEW: STM32L433 added to STM32L4xx HAL.
|
- NEW: STM32L433 added to STM32L4xx HAL.
|
||||||
- CHG: chFifoObjectInit() renamed to chFifoObjectInitAligned(). Added a new
|
- CHG: chFifoObjectInit() renamed to chFifoObjectInitAligned(). Added a new
|
||||||
|
|
Loading…
Reference in New Issue