CMSIS2000  0.0.7
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USART_Interrupt
Collaboration diagram for USART_Interrupt:

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

Detailed Description

USART Interrupts example

  ******************** (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.
  ******************************************************************************
Example Description

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:

Directory contents
Hardware and Software environment
How to use it ?

In order to make the program work, you must do the following :

Note
  • Low-density Value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
  • Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
  • Medium-density Value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
  • Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
  • High-density Value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes.
  • High-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes.
  • XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 512 and 1024 Kbytes.
  • Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.

    © COPYRIGHT 2011 STMicroelectronics

Macro Definition Documentation

#define countof (   a)    (sizeof(a) / sizeof(*(a)))

Definition at line 53 of file main.c.

#define RxBufferSize1   TxBufferSize2

Definition at line 49 of file main.c.

Referenced by main().

#define RxBufferSize2   TxBufferSize1

Definition at line 50 of file main.c.

Referenced by main().

#define TxBufferSize1   (countof(TxBuffer1) - 1)

Definition at line 47 of file main.c.

#define TxBufferSize2   (countof(TxBuffer2) - 1)

Definition at line 48 of file main.c.

Enumeration Type Documentation

enum TestStatus
Enumerator:
FAILED 
PASSED 

Definition at line 44 of file main.c.

Function Documentation

TestStatus Buffercmp ( uint8_t pBuffer1,
uint8_t pBuffer2,
uint16_t  BufferLength 
)

Compares two buffers.

Parameters
pBuffer1,pBuffer2,:buffers to be compared.
BufferLength,:buffer's length
Return values
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().

Here is the caller graph for this function:

void BusFault_Handler ( void  )

This function handles Bus Fault exception.

Parameters
None
Return values
None

Definition at line 100 of file stm32f10x_it.c.

void DebugMon_Handler ( void  )

This function handles Debug Monitor exception.

Parameters
None
Return values
None

Definition at line 135 of file stm32f10x_it.c.

void GPIO_Configuration ( void  )

Configures the different GPIO ports.

Parameters
None
Return values
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().

Here is the caller graph for this function:

void HardFault_Handler ( void  )

This function handles Hard Fault exception.

Parameters
None
Return values
None

Definition at line 74 of file stm32f10x_it.c.

int main ( void  )

Main program.

Parameters
None
Return values
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.

Here is the call graph for this function:

void MemManage_Handler ( void  )

This function handles Memory Manage exception.

Parameters
None
Return values
None

Definition at line 87 of file stm32f10x_it.c.

void NMI_Handler ( void  )

This function handles NMI exception.

Parameters
None
Return values
None

Definition at line 65 of file stm32f10x_it.c.

void NVIC_Configuration ( void  )

Configures the nested vectored interrupt controller.

Parameters
None
Return values
None

Definition at line 230 of file main.c.

References USARTy_IRQn, and USARTz_IRQn.

Referenced by main().

Here is the caller graph for this function:

void PendSV_Handler ( void  )

This function handles PendSV_Handler exception.

Parameters
None
Return values
None

Definition at line 144 of file stm32f10x_it.c.

void RCC_Configuration ( void  )

Configures the different system clocks.

Parameters
None
Return values
None

Definition at line 169 of file main.c.

References USARTy_CLK, USARTy_GPIO_CLK, USARTz_CLK, and USARTz_GPIO_CLK.

Referenced by main().

Here is the caller graph for this function:

void SVC_Handler ( void  )

This function handles SVCall exception.

Parameters
None
Return values
None

Definition at line 126 of file stm32f10x_it.c.

void SysTick_Handler ( void  )

This function handles SysTick Handler.

Parameters
None
Return values
None

Definition at line 153 of file stm32f10x_it.c.

References interrupt_register.

void UsageFault_Handler ( void  )

This function handles Usage Fault exception.

Parameters
None
Return values
None

Definition at line 113 of file stm32f10x_it.c.

void USARTy_IRQHandler ( void  )

This function handles USARTy global interrupt request.

Parameters
None
Return values
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.

Parameters
None
Return values
None

Definition at line 198 of file stm32f10x_it.c.

References NbrOfDataToRead1, NbrOfDataToTransfer2, RESET, RxBuffer2, RxCounter2, TxBuffer2, TxCounter2, and USARTz.

Variable Documentation

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

Definition at line 68 of file main.c.

uint8_t NbrOfDataToRead2 = RxBufferSize2

Definition at line 68 of file main.c.

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().

__IO uint8_t RxCounter1

Definition at line 63 of file main.c.

Referenced by USARTy_IRQHandler().

__IO uint8_t RxCounter1 = 0x00

Definition at line 63 of file main.c.

Referenced by USARTy_IRQHandler().

__IO uint8_t RxCounter2

Definition at line 64 of file main.c.

Referenced by USARTz_IRQHandler().

__IO uint8_t RxCounter2 = 0x00

Definition at line 64 of file main.c.

Referenced by USARTz_IRQHandler().

__IO TestStatus TransferStatus1 = FAILED

Definition at line 69 of file main.c.

__IO TestStatus TransferStatus2 = FAILED

Definition at line 70 of file main.c.

uint8_t TxBuffer1[]

Definition at line 57 of file main.c.

Referenced by USARTy_IRQHandler().

uint8_t TxBuffer1[] = "USART Interrupt Example: USARTy -> USARTz using Interrupt"

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().

uint8_t TxBuffer2[] = "USART Interrupt Example: USARTz -> USARTy using Interrupt"

Definition at line 58 of file main.c.

Referenced by USARTz_IRQHandler().

__IO uint8_t TxCounter1

Definition at line 61 of file main.c.

Referenced by USARTy_IRQHandler().

__IO uint8_t TxCounter1 = 0x00

Definition at line 61 of file main.c.

Referenced by USARTy_IRQHandler().

__IO uint8_t TxCounter2

Definition at line 62 of file main.c.

Referenced by USARTz_IRQHandler().

__IO uint8_t TxCounter2 = 0x00

Definition at line 62 of file main.c.

Referenced by USARTz_IRQHandler().

USART_InitTypeDef USART_InitStructure

Definition at line 56 of file main.c.