Skip to content

Commit

Permalink
- added workaround for timing oddity with EVE_cs_clear() / EVE_cs_set…
Browse files Browse the repository at this point in the history
…() as found in #136
  • Loading branch information
RudolphRiedel committed Oct 17, 2024
1 parent 3a484e2 commit 6afba51
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
15 changes: 10 additions & 5 deletions src/EVE_target/EVE_target_STM32.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file EVE_target_STM32.h
@brief target specific includes, definitions and functions
@version 5.0
@date 2024-07-21
@date 2024-10-17
@author Rudolph Riedel
@section LICENSE
Expand Down Expand Up @@ -35,6 +35,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- basic maintenance: checked for violations of white space and indent rules
- added STM32WB55xx
- reworked
- fix: switched EVE_cs_clear() and EVE_cs_set() from using LL to using HAL after making
the very weird observation that CS was not rising high in between two consecutive
host commands while sending three host commands was just fine - see issue #136
*/

Expand Down Expand Up @@ -311,14 +314,15 @@ void EVE_start_dma_transfer(void);

#endif /* EVE_DMA */

#define DELAY_MS(ms) HAL_Delay(ms)

static inline void EVE_cs_clear(void)
{
while (LL_SPI_IsActiveFlag_BSY(EVE_SPI)) {}
LL_GPIO_SetOutputPin(EVE_CS_PORT, EVE_CS);
// LL_GPIO_SetOutputPin(EVE_CS_PORT, EVE_CS);
HAL_GPIO_WritePin(EVE_CS_PORT, EVE_CS, GPIO_PIN_SET);
}

#define DELAY_MS(ms) HAL_Delay(ms)

static inline void EVE_pdn_clear(void)
{
HAL_GPIO_WritePin(EVE_PD_PORT, EVE_PD, GPIO_PIN_SET);
Expand All @@ -331,7 +335,8 @@ static inline void EVE_pdn_set(void)

static inline void EVE_cs_set(void)
{
LL_GPIO_ResetOutputPin(EVE_CS_PORT, EVE_CS);
// LL_GPIO_ResetOutputPin(EVE_CS_PORT, EVE_CS);
HAL_GPIO_WritePin(EVE_CS_PORT, EVE_CS, GPIO_PIN_RESET);
}

static inline void spi_transmit(uint8_t data)
Expand Down
35 changes: 20 additions & 15 deletions src/EVE_target/EVE_target_STM32H7.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@file EVE_target_STM32H7.h
@brief target specific includes, definitions and functions
@version 5.0
@date 2024-07-21
@date 2024-10-17
@author Rudolph Riedel
@section LICENSE
Expand Down Expand Up @@ -32,6 +32,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5.0
- split from EVE_target_STM32.h
- fix: switched EVE_cs_clear() and EVE_cs_set() from using LL to using HAL after making
the very weird observation that CS was not rising high in between two consecutive
host commands while sending three host commands was just fine - see issue #136
*/

Expand Down Expand Up @@ -178,28 +181,28 @@ extern SPI_HandleTypeDef eve_spi_handle;
#if EVE_DMA_UNIT_NUM == 1U
#if EVE_DMA_STREAM_NUM == 0U
#define EVE_DMA_INSTANCE DMA1_Stream0
#define EVE_DMA_IRQ DMA1_Stream0_IRQn
#define EVE_DMA_IRQ DMA1_Stream0_IRQn
#elif EVE_DMA_STREAM_NUM == 1U
#define EVE_DMA_INSTANCE DMA1_Stream1
#define EVE_DMA_IRQ DMA1_Stream1_IRQn
#define EVE_DMA_IRQ DMA1_Stream1_IRQn
#elif EVE_DMA_STREAM_NUM == 2U
#define EVE_DMA_INSTANCE DMA1_Stream2
#define EVE_DMA_IRQ DMA1_Stream2_IRQn
#define EVE_DMA_IRQ DMA1_Stream2_IRQn
#elif EVE_DMA_STREAM_NUM == 3U
#define EVE_DMA_INSTANCE DMA1_Stream3
#define EVE_DMA_IRQ DMA1_Stream3_IRQn
#define EVE_DMA_IRQ DMA1_Stream3_IRQn
#elif EVE_DMA_STREAM_NUM == 4U
#define EVE_DMA_INSTANCE DMA1_Stream4
#define EVE_DMA_IRQ DMA1_Stream4_IRQn
#define EVE_DMA_IRQ DMA1_Stream4_IRQn
#elif EVE_DMA_STREAM_NUM == 5U
#define EVE_DMA_INSTANCE DMA1_Stream5
#define EVE_DMA_IRQ DMA1_Stream5_IRQn
#define EVE_DMA_IRQ DMA1_Stream5_IRQn
#elif EVE_DMA_STREAM_NUM == 6U
#define EVE_DMA_INSTANCE DMA1_Stream6
#define EVE_DMA_IRQ DMA1_Stream6_IRQn
#define EVE_DMA_IRQ DMA1_Stream6_IRQn
#elif EVE_DMA_STREAM_NUM == 7U
#define EVE_DMA_INSTANCE DMA1_Stream7
#define EVE_DMA_IRQ DMA1_Stream7_IRQn
#define EVE_DMA_IRQ DMA1_Stream7_IRQn
#endif
#elif EVE_DMA_UNIT_NUM == 2U
#if EVE_DMA_STREAM_NUM == 0U
Expand All @@ -217,7 +220,7 @@ extern SPI_HandleTypeDef eve_spi_handle;
#elif EVE_DMA_STREAM_NUM == 4U
#define EVE_DMA_INSTANCE DMA2_Stream4
#define EVE_DMA_IRQ DMA2_Stream4_IRQn
#elif EVE_DMA_STREAM_NUM == 5U
#elif EVE_DMA_STREAM_NUM == 5U
#define EVE_DMA_INSTANCE DMA2_Stream5
#define EVE_DMA_IRQ DMA2_Stream5_IRQn
#elif EVE_DMA_STREAM_NUM == 6U
Expand All @@ -226,7 +229,7 @@ extern SPI_HandleTypeDef eve_spi_handle;
#elif EVE_DMA_STREAM_NUM == 7U
#define EVE_DMA_INSTANCE DMA2_Stream7
#define EVE_DMA_IRQ DMA2_Stream7_IRQn
#endif
#endif
#endif

#if EVE_SPI_NUM == 1U
Expand All @@ -252,14 +255,15 @@ void EVE_start_dma_transfer(void);

#endif /* EVE_DMA */

#define DELAY_MS(ms) HAL_Delay(ms)

static inline void EVE_cs_clear(void)
{
while (0 == LL_SPI_IsActiveFlag_TXC(EVE_SPI)) {} /* wait for the last transfer to complete */
LL_GPIO_SetOutputPin(EVE_CS_PORT, EVE_CS);
// LL_GPIO_SetOutputPin(EVE_CS_PORT, EVE_CS);
HAL_GPIO_WritePin(EVE_CS_PORT, EVE_CS, GPIO_PIN_SET);
}

#define DELAY_MS(ms) HAL_Delay(ms)

static inline void EVE_pdn_clear(void)
{
HAL_GPIO_WritePin(EVE_PD_PORT, EVE_PD, GPIO_PIN_SET);
Expand All @@ -272,7 +276,8 @@ static inline void EVE_pdn_set(void)

static inline void EVE_cs_set(void)
{
LL_GPIO_ResetOutputPin(EVE_CS_PORT, EVE_CS);
// LL_GPIO_ResetOutputPin(EVE_CS_PORT, EVE_CS);
HAL_GPIO_WritePin(EVE_CS_PORT, EVE_CS, GPIO_PIN_RESET);
}

static inline void spi_transmit(uint8_t data)
Expand Down

0 comments on commit 6afba51

Please sign in to comment.