From 1351fded5a9c460166637d276616a73be0b72392 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 5 Oct 2011 17:00:13 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3426 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/DMAv1/stm32_dma.c | 4 +- os/hal/platforms/STM32/DMAv1/stm32_dma.h | 55 ++++++++++++++++++++++++ os/ports/GCC/ARMCMx/crt0.c | 7 +-- readme.txt | 4 +- todo.txt | 44 ++++++++----------- 5 files changed, 82 insertions(+), 32 deletions(-) diff --git a/os/hal/platforms/STM32/DMAv1/stm32_dma.c b/os/hal/platforms/STM32/DMAv1/stm32_dma.c index 3fb1b2dc6..84e372c26 100644 --- a/os/hal/platforms/STM32/DMAv1/stm32_dma.c +++ b/os/hal/platforms/STM32/DMAv1/stm32_dma.c @@ -100,8 +100,8 @@ const stm32_dma_stream_t _stm32_dma_streams[STM32_DMA_STREAMS] = { * @brief DMA ISR redirector type. */ typedef struct { - stm32_dmaisr_t dma_func; - void *dma_param; + stm32_dmaisr_t dma_func; /**< @brief DMA callback function. */ + void *dma_param; /**< @brief DMA callback parameter. */ } dma_isr_redir_t; /** diff --git a/os/hal/platforms/STM32/DMAv1/stm32_dma.h b/os/hal/platforms/STM32/DMAv1/stm32_dma.h index 22be4a67e..f209898d4 100644 --- a/os/hal/platforms/STM32/DMAv1/stm32_dma.h +++ b/os/hal/platforms/STM32/DMAv1/stm32_dma.h @@ -153,6 +153,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief Associates a peripheral data register to a DMA stream. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @param[in] addr value to be written in the CPAR register @@ -166,6 +168,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief Associates a memory destination to a DMA stream. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @param[in] addr value to be written in the CMAR register @@ -179,6 +183,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief Sets the number of transfers to be performed. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @param[in] size value to be written in the CNDTR register @@ -192,6 +198,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief Returns the number of transfers to be performed. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @return The number of transfers to be performed. @@ -203,6 +211,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief Programs the stream mode settings. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @param[in] mode value to be written in the CCR register @@ -216,6 +226,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief DMA stream enable. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @@ -228,6 +240,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief DMA stream disable. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @@ -240,6 +254,8 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); /** * @brief DMA stream interrupt sources clear. * @note This function can be invoked in both ISR or thread context. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). * * @param[in] dmastp pointer to a stm32_dma_stream_t structure * @@ -249,6 +265,45 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags); *(dmastp)->ifcr = STM32_DMA_ISR_MASK << (dmastp)->ishift; \ } +/** + * @brief Starts a memory to memory operation using the specified stream. + * @note The default transfer data mode is "byte to byte" but it can be + * changed by specifying extra options in the @p mode parameter. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). + * + * @param[in] dmastp pointer to a stm32_dma_stream_t structure + * @param[in] mode value to be written in the CCR register, this value + * is implicitly ORed with: + * - @p STM32_DMA_CR_MINC + * - @p STM32_DMA_CR_PINC + * - @p STM32_DMA_CR_DIR_M2M + * - @p STM32_DMA_CR_EN + * . + * @param[in] src source address + * @param[in] dst destination address + * @param[in] n number of data units to copy + */ +#define dmaStartMemCopy(dmastp, mode, src, dst, n) { \ + dmaStreamSetPeripheral(dmastp, src); \ + dmaStreamSetMemory0(dmastp, dst); \ + dmaStreamGetTransactionSize(dmastp, n); \ + dmaStreamSetMode(dmastp, (mode) | \ + STM32_DMA_CR_MINC | STM32_DMA_CR_PINC | \ + STM32_DMA_CR_DIR_M2M | STM32_DMA_CR_EN); \ +} + +/** + * @brief Polled wait for DMA transfer end. + * @pre The stream must have been allocated using @p dmaStreamAllocate(). + * @post After use the stream can be released using @p dmaStreamRelease(). + * + * @param[in] dmastp pointer to a stm32_dma_stream_t structure + */ +#define dmaWaitCompletion(dmastp) \ + while (((dmastp)->channel->CNDTR > 0) && \ + ((dmastp)->channel->CCR & STM32_DMA_CR_EN)) + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ diff --git a/os/ports/GCC/ARMCMx/crt0.c b/os/ports/GCC/ARMCMx/crt0.c index e2cb2b3de..0737c467b 100644 --- a/os/ports/GCC/ARMCMx/crt0.c +++ b/os/ports/GCC/ARMCMx/crt0.c @@ -251,13 +251,14 @@ __attribute__((naked)) void ResetHandler(void) { uint32_t psp, ctl; - /* Process Stack initialization, it is allocated below the main stack. The - main stack is assumed to be allocated starting from @p __ram_end__ - extending downward.*/ + /* Process Stack initialization, it is allocated starting from the + symbol __process_stack_end__ and its lower limit is the symbol + __process_stack_base__.*/ asm volatile ("cpsid i"); psp = SYMVAL(__process_stack_end__); asm volatile ("msr PSP, %0" : : "r" (psp)); + /* CPU mode initialization.*/ ctl = CRT0_CONTROL_INIT; asm volatile ("msr CONTROL, %0" : : "r" (ctl)); asm volatile ("isb"); diff --git a/readme.txt b/readme.txt index d4ea10acd..155ae8506 100644 --- a/readme.txt +++ b/readme.txt @@ -63,7 +63,8 @@ +--testhal/ - HAL integration test demos. | +--LPC11xx/ - LPC11xx HAL test demos. | +--LPC13xx/ - LPC13xx HAL test demos. - | +--STM32/ - STM32 HAL test demos. + | +--STM32F1xx/ - STM32F1xx HAL test demos. + | +--STM32L1xx/ - STM32L1xx HAL test demos. | +--STM8S/ - STM8S HAL test demos. +--tools - Various tools. +--eclipse - Eclipse enhancements. @@ -75,6 +76,7 @@ *** 2.3.4 *** - FIX: Fixed broken TIM8 support in STM32 PWM driver (bug 3418620). - FIX: Fixed halconf.h file corrupted in some STM32 demos (bug 3418626). +- NEW: Added memory copy functionality to the STM32 DMA driver. *** 2.3.3 *** - FIX: Fixed uninitialized variable in STM32 PWM and ICU drivers (bug 3413558). diff --git a/todo.txt b/todo.txt index 5f38eb2a1..51f3c6795 100644 --- a/todo.txt +++ b/todo.txt @@ -6,39 +6,31 @@ X = In progress, some work done. N = Decided against. Current Pipeline (2.3.x): -* lwIP 1.4.0 integration and test. -* Named threads. -* Call protocol check debug option. -* Improved stack overflow checking, support main() thread. - * Move main stack to low memory in ARMCMx ports. -* Eclipse plugin. -* FatFs 0.8x integration. -* Kernel-only demo for users not interested in HAL (Cortex-Mx only). -- USB and USB_SERIAL APIs reclassification (if needed), incorporate the USB - bus attach/detach handling in usbStart()/usbStop(). -- USB double buffering support for STM32 implementation. -X STM32L1xx support (verify and test existing STM32F1xx drivers). - - Specific ADC driver for STM32L1xx. - X STM32L-Discovery demo and article. -X STM32F2xx support (adapt and re-verify all drivers). - * New STM32 DMA helper driver abstracting differences between STM32F2xx and - other sub-families. - ? Specific ADC driver for STM32F2xx. +- USB driver enhancements. + - USB and USB_SERIAL APIs reclassification. + - Incorporate the USB bus attach/detach handling in usbStart()/usbStop(). + - Fix zero size packets handling in USB_SERIAL driver. + - USB double buffering support for STM32 implementation. + - Evaluate using DMA channels for buffer copy. +X I2C device driver class support and at least one implementation. + X Evaluate a modified I2C API where the synchronous mode is default and the + callback mode optional. + - Software I2C implementation using a GPT instance for timings. +X STM32F2xx/STM32F4xx support (adapt and re-verify all drivers). + * New STM32 DMA helper driver abstracting differences between + STM32F2xx/STM32F4xx and other sub-families. + - Specific ADC driver for STM32F2xx/STM32F4xx. - MMC_SPI driver revision and speedup. +- FatFs 0.9x integration. + +Within 2.x.x +X File System infrastructure. X Implement the "transmission end" serial driver event on those platforms supporting the feature, so far only done in STM32 driver. -X I2C device driver class support and at least one implementation. -X Evaluate a modified I2C API where the synchronous mode is default and the - callback mode optional. This would allow a portable I2C driver based on - a GPT instance. - - Software I2C implementation. - Add a CH_THREAD macro for threads declaration in order to hide compiler-specific optimizations for thread functions. All demos will have to be updated. - LPC17xx support. - -Within 2.x.x -X File System infrastructure. - Test suite overhaul, the API should be more generic in order to be used with different subsystems and not just the kernel. - Reduce number of demos globally, add demos to a repository or on web site.