CMSIS2000
0.0.7
|
Macros | |
#define | countof(a) (sizeof(a) / sizeof(*(a))) |
#define | RxBufferSize1 TxBufferSize2 |
#define | RxBufferSize2 TxBufferSize1 |
#define | TxBufferSize1 (countof(TxBuffer1) - 1) |
#define | TxBufferSize2 (countof(TxBuffer2) - 1) |
Enumerations | |
enum | TestStatus { FAILED = 0, PASSED = !FAILED } |
Functions | |
TestStatus | Buffercmp (uint8_t *pBuffer1, uint8_t *pBuffer2, uint16_t BufferLength) |
Compares two buffers. | |
void | BusFault_Handler (void) |
This function handles Bus Fault exception. | |
void | DebugMon_Handler (void) |
This function handles Debug Monitor exception. | |
void | GPIO_Configuration (void) |
Configures the different GPIO ports. | |
void | HardFault_Handler (void) |
This function handles Hard Fault exception. | |
int | main (void) |
Main program. | |
void | MemManage_Handler (void) |
This function handles Memory Manage exception. | |
void | NMI_Handler (void) |
This function handles NMI exception. | |
void | NVIC_Configuration (void) |
Configures the nested vectored interrupt controller. | |
void | PendSV_Handler (void) |
This function handles PendSV_Handler exception. | |
void | RCC_Configuration (void) |
Configures the different system clocks. | |
void | SVC_Handler (void) |
This function handles SVCall exception. | |
void | SysTick_Handler (void) |
This function handles SysTick Handler. | |
void | UsageFault_Handler (void) |
This function handles Usage Fault exception. | |
void | USARTy_IRQHandler (void) |
This function handles USARTy global interrupt request. | |
void | USARTz_IRQHandler (void) |
This function handles USARTz global interrupt request. |
Variables | |
uint8_t | NbrOfDataToRead1 |
uint8_t | NbrOfDataToRead1 = RxBufferSize1 |
uint8_t | NbrOfDataToRead2 |
uint8_t | NbrOfDataToRead2 = RxBufferSize2 |
uint8_t | NbrOfDataToTransfer1 |
uint8_t | NbrOfDataToTransfer1 = TxBufferSize1 |
uint8_t | NbrOfDataToTransfer2 |
uint8_t | NbrOfDataToTransfer2 = TxBufferSize2 |
uint8_t | RxBuffer1 [] |
uint8_t | RxBuffer1 [RxBufferSize1] |
uint8_t | RxBuffer2 [] |
uint8_t | RxBuffer2 [RxBufferSize2] |
__IO uint8_t | RxCounter1 |
__IO uint8_t | RxCounter1 = 0x00 |
__IO uint8_t | RxCounter2 |
__IO uint8_t | RxCounter2 = 0x00 |
__IO TestStatus | TransferStatus1 = FAILED |
__IO TestStatus | TransferStatus2 = FAILED |
uint8_t | TxBuffer1 [] |
uint8_t | TxBuffer1 [] = "USART Interrupt Example: USARTy -> USARTz using Interrupt" |
uint8_t | TxBuffer2 [] |
uint8_t | TxBuffer2 [] = "USART Interrupt Example: USARTz -> USARTy using Interrupt" |
__IO uint8_t | TxCounter1 |
__IO uint8_t | TxCounter1 = 0x00 |
__IO uint8_t | TxCounter2 |
__IO uint8_t | TxCounter2 = 0x00 |
USART_InitTypeDef | USART_InitStructure |
******************** (C) COPYRIGHT 2011 STMicroelectronics ******************* * @file Device/ST/STM32F10x/Examples/UART_INTERRUPT/readme.txt * @author MCD Application Team * @version V3.5.0 * @date 08-April-2011 * @brief Description of the USART Interrupts example. ****************************************************************************** * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. ******************************************************************************
This example provides a basic communication between USARTy and USARTz using interrupts. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3, depending on the STMicroelectronics EVAL board you are using.
USARTz sends TxBuffer2 to USARTy which sends TxBuffer1 to USARTz. The data received by USARTy and USARTz are stored respectively in RxBuffer1 and RxBuffer2. The data transfer is managed in USARTy_IRQHandler and USARTz_IRQHandler in stm32f10x_it.c file.
USARTy and USARTz configured as follow:
In order to make the program work, you must do the following :
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
#define RxBufferSize1 TxBufferSize2 |
#define RxBufferSize2 TxBufferSize1 |
enum TestStatus |
TestStatus Buffercmp | ( | uint8_t * | pBuffer1, |
uint8_t * | pBuffer2, | ||
uint16_t | BufferLength | ||
) |
Compares two buffers.
pBuffer1,pBuffer2,: | buffers to be compared. |
BufferLength,: | buffer's length |
PASSED,: | pBuffer1 identical to pBuffer2 FAILED: pBuffer1 differs from pBuffer2 |
Definition at line 257 of file main.c.
References FAILED, and PASSED.
Referenced by main().
void BusFault_Handler | ( | void | ) |
This function handles Bus Fault exception.
None |
None |
Definition at line 100 of file stm32f10x_it.c.
void DebugMon_Handler | ( | void | ) |
This function handles Debug Monitor exception.
None |
None |
Definition at line 135 of file stm32f10x_it.c.
void GPIO_Configuration | ( | void | ) |
Configures the different GPIO ports.
None |
None |
Definition at line 190 of file main.c.
References USARTy_GPIO, USARTy_RxPin, USARTy_TxPin, USARTz_GPIO, USARTz_RxPin, and USARTz_TxPin.
Referenced by main().
void HardFault_Handler | ( | void | ) |
This function handles Hard Fault exception.
None |
None |
Definition at line 74 of file stm32f10x_it.c.
int main | ( | void | ) |
Main program.
None |
None |
< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file
Definition at line 85 of file main.c.
References Buffercmp(), GPIO_Configuration(), NVIC_Configuration(), RCC_Configuration(), RxBufferSize1, RxBufferSize2, USARTy, and USARTz.
void MemManage_Handler | ( | void | ) |
This function handles Memory Manage exception.
None |
None |
Definition at line 87 of file stm32f10x_it.c.
void NMI_Handler | ( | void | ) |
This function handles NMI exception.
None |
None |
Definition at line 65 of file stm32f10x_it.c.
void NVIC_Configuration | ( | void | ) |
Configures the nested vectored interrupt controller.
None |
None |
Definition at line 230 of file main.c.
References USARTy_IRQn, and USARTz_IRQn.
Referenced by main().
void PendSV_Handler | ( | void | ) |
This function handles PendSV_Handler exception.
None |
None |
Definition at line 144 of file stm32f10x_it.c.
void RCC_Configuration | ( | void | ) |
Configures the different system clocks.
None |
None |
Definition at line 169 of file main.c.
References USARTy_CLK, USARTy_GPIO_CLK, USARTz_CLK, and USARTz_GPIO_CLK.
Referenced by main().
void SVC_Handler | ( | void | ) |
This function handles SVCall exception.
None |
None |
Definition at line 126 of file stm32f10x_it.c.
void SysTick_Handler | ( | void | ) |
This function handles SysTick Handler.
None |
None |
Definition at line 153 of file stm32f10x_it.c.
References interrupt_register.
void UsageFault_Handler | ( | void | ) |
This function handles Usage Fault exception.
None |
None |
Definition at line 113 of file stm32f10x_it.c.
void USARTy_IRQHandler | ( | void | ) |
This function handles USARTy global interrupt request.
None |
None |
Definition at line 166 of file stm32f10x_it.c.
References NbrOfDataToRead1, NbrOfDataToTransfer1, RESET, RxBuffer1, RxCounter1, TxBuffer1, TxCounter1, and USARTy.
void USARTz_IRQHandler | ( | void | ) |
This function handles USARTz global interrupt request.
None |
None |
Definition at line 198 of file stm32f10x_it.c.
References NbrOfDataToRead1, NbrOfDataToTransfer2, RESET, RxBuffer2, RxCounter2, TxBuffer2, TxCounter2, and USARTz.
uint8_t NbrOfDataToRead1 |
Definition at line 67 of file main.c.
Referenced by USARTy_IRQHandler(), and USARTz_IRQHandler().
uint8_t NbrOfDataToRead1 = RxBufferSize1 |
Definition at line 67 of file main.c.
Referenced by USARTy_IRQHandler(), and USARTz_IRQHandler().
uint8_t NbrOfDataToRead2 = RxBufferSize2 |
uint8_t NbrOfDataToTransfer1 |
Definition at line 65 of file main.c.
Referenced by USARTy_IRQHandler().
uint8_t NbrOfDataToTransfer1 = TxBufferSize1 |
Definition at line 65 of file main.c.
Referenced by USARTy_IRQHandler().
uint8_t NbrOfDataToTransfer2 |
Definition at line 66 of file main.c.
Referenced by USARTz_IRQHandler().
uint8_t NbrOfDataToTransfer2 = TxBufferSize2 |
Definition at line 66 of file main.c.
Referenced by USARTz_IRQHandler().
uint8_t RxBuffer1[] |
Definition at line 59 of file main.c.
Referenced by USARTy_IRQHandler().
uint8_t RxBuffer1[RxBufferSize1] |
Definition at line 59 of file main.c.
Referenced by USARTy_IRQHandler().
uint8_t RxBuffer2[] |
Definition at line 60 of file main.c.
Referenced by USARTz_IRQHandler().
uint8_t RxBuffer2[RxBufferSize2] |
Definition at line 60 of file main.c.
Referenced by USARTz_IRQHandler().
Definition at line 63 of file main.c.
Referenced by USARTy_IRQHandler().
Definition at line 63 of file main.c.
Referenced by USARTy_IRQHandler().
Definition at line 64 of file main.c.
Referenced by USARTz_IRQHandler().
Definition at line 64 of file main.c.
Referenced by USARTz_IRQHandler().
__IO TestStatus TransferStatus1 = FAILED |
__IO TestStatus TransferStatus2 = FAILED |
uint8_t TxBuffer1[] |
Definition at line 57 of file main.c.
Referenced by USARTy_IRQHandler().
Definition at line 57 of file main.c.
Referenced by USARTy_IRQHandler().
uint8_t TxBuffer2[] |
Definition at line 58 of file main.c.
Referenced by USARTz_IRQHandler().
Definition at line 58 of file main.c.
Referenced by USARTz_IRQHandler().
Definition at line 61 of file main.c.
Referenced by USARTy_IRQHandler().
Definition at line 61 of file main.c.
Referenced by USARTy_IRQHandler().
Definition at line 62 of file main.c.
Referenced by USARTz_IRQHandler().
Definition at line 62 of file main.c.
Referenced by USARTz_IRQHandler().