Home

User manual - STMicroelectronics

image

Contents

1. UM0097 Peripheral firmware overview EIC_IRQChannelIPriorityConfig Function Name EIC_IRQChanneIPriorityConfig void EIC_ IRQChannelPriorityConfig Function Prototype IRQChannel_TypeDef IRQChannel u8 Priority Behavior Description Configures the selected IRQ channel priority IRQChannel the channel to be configured Input Parameter 1 Refer to IRQ channel enumeration on page 54 for details on allowed values of RQChannel parameter Input Parameter 2 Priority specifies the priority of the channel Priority variable must take an integer value in the range 0 15 Output Parameter None Return Value None Required Preconditions None Called Functions None EIC_IRQConfi i Sanaise gt _IRQConfig on page 58 EIC_IRQChannelConfig on page 59 Caution If you select a priority level equal to 0 this channel will not be served by the EIC Example This example show how to enable timer O global interrupts with a priority level equal to 5 Set the timer 0 global interrupts priority level to 5 EIC_IRQChannelPriorityConfig TOTIMI_IRQChannel 0x05 Enable interrupts not the timer 0 global interrupts channel Z EIC _IRQChannelConfig TOTIMI_IRQChannel ENABLE Enable IRQ interrupts EIC_IRQConfig ENABLE 61 229 Peripheral firmware overview UM0097 Note 1 2 3 4 Caution 62 229 EIC_CurrentPriorityLevelValue Function Name Function Prototype EIC_CurrentPriori
2. UM0097 Peripheral firmware overview PCU_LPModesConfig Function Name PCU_LPModesConfig void PCU_LPModesConfig FunctionalState PLL1_ State FunctionalState MVR_State FunctionalState FLASH State FunctionalState LPWFI_ State LPWFI_Clock_Typedef LPWFI_Clock Function Prototype Behavior Description This routine configures the different STR71x low power mode options PLL1_ State the state of PLL1 when CK_AF selected ENABLE PLL1 is not disabled when CK_AF is selected DISABLE PLL1 is disabled automatically when CK_AF is selected as system clock Input Parameter 1 MVR_ State the state of the Main Voltage Regulator when CK_AF is selected ENABLE MVREG is enabled during LPWFI and STOP modes DISABLE MVREG is disabled during LPWFI and STOP modes FLASH_State the state of the flash during LPWFI and STOP modes Input Parameter 3 ENABLE Flash Stand by mode during LPWFI and STOP modes DISABLE FLASH in powerdown during LPWFI and STOP modes LPWFI_State the state of low power mode during LPWFI Input Parameter 4 ENABLE Enable Low power mode during WFI mode DISABLE Disable Low power mode disabled during WFI mode LPWFI_Clock the selected clock during LPWFI Input Parameter 5 LPWFI_CLK2_16 CLK2 16 is selected during LPWFI LPWFI_CK_AF CK_AF is selected during LPWFI Input Parameter 2 Output Parameter None Return Value No
3. BSPI_TR_FE Transmit FIFO empty BSPI_TR_UFL Transmit underflow BSPI_TR_FF Transmit FIFO full BSPI_TR_DIS All interrupts disabled Receive interrupt sources The following enumeration defines the BSP receive interrupt sources The RC_IR_SRCS is defined in the file 77x_bspi h as follows typedef enum BSPI_RC_FNE BSPI_RC FF BSPI_RC_DIS BSPI_IT_RC Table 67 enumerates the BSP receive interrupt sources Table 61 BSPI receive interrupt sources Receive interrupt source Description BSPI_RC_FNE Receive FIFO not empty BSPI_RC_FF Receive FIFO full BSPI_RC_DIS All interrupts disabled Firmware library functions Table 62 enumerates the different functions of the BSP library Table 62 Function Name BSPI_BSP 0Conf BSPI library functions Description Enable or disable BSPIO interface BSPI_Init Initializes BSPI peripheral control and registers to their default reset values BSPI_Enable Enables disables the specified BSP peripheral BSPI_MasterEnable Selects or deselects BSP master mode BSPI_TrltSre Configures the transmit interrupt source BSPI_ReltSre Configures the receive interrupt source BSPI_TrFifoDepth Configures the number of the words for the BSP transmit FIFO ky UM0097 Peripheral firmware overview Table 62 BSPI library functions continued Func
4. 38 229 UM0097 Peripheral firmware overview RCCU_PCLK2Config Function Name RCCU_PCLK2Config Function Prototype void RCCU_PCLK2Config Clock Div New_Clock This routine is used to select the division factor for RCLK to obtain the PCLK2 clock for the APB2 peripherals PCLK2 New_Clock specifies the PCLK2 clock divider value Refer to Clock Input Parameter divider parameters on page 30 for more details on the allowed values of this parameter Behavior Description Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to set the PCLK2 clock to RCLK 2 RCCU_PCLK2 Config RCCU_RCLK_ 2 RCCU_PLL1Config Function Name RCCU_PLL1Config void RCCU_PLLIConfig RCCU_PLL1 Mul New Mul Function Protot neto ee RCCU_PLL Div New Div Behavior Description This routine configures the PLL1 division and multiplication factors New_Mul the PLL1 clock multiplication factor Refer to PLL1 Input Parameter 1 multiplication factors on page 31 for more details on the allowed values of this parameter New_Div the PLL1 clock division factor Refer to PLL division factors on input Parameter 2 page 32 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This exam
5. BSPI_WordReceive Example This example illustrates how to receive 5 word from a buffer u8 pBuffer 10 Receive 5 8 bit data and stores them in user defined area BSPI_ ByteBufferReceive BSPIO pBuffer 5 BSPI_WordBufferReceive Function Name Function Prototype BSPI_ByteBufferReceive void BSPI_WordBufferReceive BSPI_ TypeDef BSPIx ul6 PtrToBuffer u8 NbOfWords Description Input Parameter 1 Input Parameter 2 Receives number of data words and stores them in user defined area BSPIx selects BSPI peripheral to be used where x can be 0 or 1 PtrToBuffer is an u16 pointer to the first word of the defined area to save the received buffer Input Parameter 3 NbOfWords indicates the number of words to be received in the buffer Output Parameter None Return Value None Required Preconditions None Called Functions BSPI_WordReceive lt UM0097 Peripheral firmware overview Example This example illustrates how to receive 5 word from a buffer ul6 pBuffer 10 Receive 5 16 bit data and stores them in user defined area BSPI_WordBufferReceive BSPIO pBuffer 5 BSPIL ErritSre Function Name BSPI_ErrltSre void BSPI_ ErritSrce BSPI TypeDef BSPIx Function Protot DGMO otoy pS BSPI_IT_ERR BSPI_IE FunctionalState NewState Description Enables or disables the specified error interrupt Input
6. Behavior Description This routine gets and returns the clock active level when using an external clock source Input Parameter TIMx specifies the TIM to be configured Refer to T M values on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value The external clock level of the specified timer Refer to Clock edges enumeration on page 104 for more details on the allowed values of this parameter Required preconditions None Called Functions None Example This example illustrates how to get the current clock level of the T MO TIM Clock Edges CurrentLevel CurrentLevel TIM ClockLevelValue TIMO TIM_ICAPModeConfig Function Name Function Prototype TIM_ICAPModeConfig void TIM_ICAPModeConfig TIM _TypeDef TIMx TIM Channels Xchannel Clock_Edges Xedge Behavior Description Input Parameter 1 TIMx specifies the TIM to be initialized Refer to TIM values on This routine is used to configure the Input capture mode page 103 for more details on the allowed values of this parameter Input Parameter 2 Xchannel specifies the input capture channels Refer to TIM channels enumeration on page 104 for more details on the allowed values of this parameter Input Parameter 3 Xedge specifies the input capture sensitive edge Refer to Clock edges enumeration on page 104 for more details on the allowe
7. 97 229 Peripheral firmware overview UM0097 WDG_CntReloadUpdate Function Name WDG_CntReloadUpdate Function Prototype void WDG CntReloadUpdate u16 PreLoadValue Behavior Description This routine is used to update the counter pre load value Input Parameter PreLoadValue specifies the pre load value 16 bit Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the WDG pre load value void WDG CntReloadUpdate 0x1234 WDG_PeriodValueConfig Function Name WDG_PeriodValueConfig Function Prototype void WDG_PeriodValueConfig u32 Time Behavior Description This routine is used to set the prescaler and counter reload value Input Parameter Time the amount of time needed in microseconds Output Parameter None Return Value None Required preconditions None Called Functions RCCU_FrequencyValue FindFactors Example This example illustrates how to set the needed time us WDG PeriodValueConfig 2589 98 229 UM0097 Peripheral firmware overview WDG_CntOnOffConfig Function Name WDG_CntOnOffConfig Function Prototype void WDG CntOnoffConfig FunctionalState NewState Behavior Description This routine is used to start or stop the free auto reload timer counting down Input Parameter NewSiate specifies how the timer has to
8. Function Name EIC_FIQConfig Function Prototype void EIC_FIQConfig FunctionalState NewState Behavior Description Sets or clears the FIQ_EN bit located in E C CIR register NewSiate the F Q interrupt new status to be set Input Parameter ENABLE enables the FIQ interrupt DISABLE disables the FIQ interrupt Output Parameter None Return Value None Required Preconditions None Called Functions None See also EIC_IRQConfig on page 58 Example This example shows how to enable the F Q interrupts Enable FIQ interrupts EIC_FIQConfig ENABLE 58 229 UM0097 Peripheral firmware overview EIC_IRQChannelIConfig Function Name EIC_IRQChannelIConfig void EIC_ IRQChannelConfig IRQChannel_ TypeDef Function Prototype i uncio yp IRQChannel FunctionalState NewState Behavior Description Configures the specified IRQ Channel IRQChannel the channel to be configured Input Parameter 1 Refer to RQ channel enumeration on page 54 for details on allowed values of RQChannel parameter NewSiate specifies whether the RQ channel interrupt will be enabled or disabled ENABLE enables the channel interrupt DISABLE disables the channel interrupt Input Parameter 2 Output Parameter None Return Value None Required Preconditions None Called Functions None EIC_IRQConfig on page 58 SASAS EIC_IRQChannelPriorityConfig on page 61 Example This e
9. Lines value Corresponding Line XTI_Line3 Line 3 External interrupt XTI_Line4 Line 4 External interrupt XTI_Line5 Line 5 External interrupt XTI_Line6 Line 6 CAN module receive pin XTI_Line7 Line 7 HDLC clock or I2CO clock XTI_Line8 amp Line 8 HDLC receive pin or 12C0 Data XTI_Line9 Line 9 BSPIO slave input data or UART3 receive data input XTI_Line10 Line 10 BSPIO slave input serial clock or 12C1 clock XTI_Line11 Line 11 BSPI7 Slave input serial clock XTI_Line12 Line 12 UARTO receive data input XTI_Line13 Line 13 UART1 receive data input XTI_Line14 Line 14 UART2 receive data input XTI_Line15 Line 15 WakeUp pin or RTC ALARM 3 6 3 Firmware library functions Table 38 enumerates the different functions of the X77 library Table 38 XTI library functions Function Name XTI_Init Description Initializes the XT to the default configuration XTI_ModeConfig Enables or disables the Interrupt and Wake Up modes XTI_LineModeContig XTI_LineConfig XTI_InterruptLine Value Selects the line trigger edge polarity Enables or disables the selected line interrupt Returns the wake up line number that generates the interrupt XTI_PendingBitClear Clears the XT pending bit XTI_SWIRQGenerate Generates a software IRQ interrupt on the XTI channel 78 229 lt UM0097 Peripheral firmware overview XTI_Init Function Name XTIL_Init Function Prototype void XTI_Init void This ro
10. RCCU_PLL1_Mul_16 Multiplication factor equal to 16 RCCU_PLL1_Mul_20 Multiplication factor equal to 20 RCCU_PLL1_Mul_24 Multiplication factor equal to 24 PLL2 multiplication factors The following enumeration defines the PLL2 multiplication factors RCCU_PLL2_Mul enumeration is declared in the file 77x_rccu h typedef enum RCCU_PLL2 Mul_12 0x01 RCCU_PLL2 Mul_16 0x03 RCCU_PLL2 Mul_20 0x00 RCCU_PLL2 Mul_28 0x02 RCCU_PLL2_ Mul Table 14 lists the different values of the PLL2 multiplication factor 1 Table 14 PLL2 multiplication factors PLL Multiplication factor RCCU_PLL2_Mul_12 Multiplication factor equal to 12 Description RCCU_PLL2_Mul_16 RCCU_PLL2_Mul_20 Multiplication factor equal to 16 Multiplication factor equal to 20 RCCU_PLL2_Mul_28 Multiplication factor equal to 28 PLL division factors The following enumeration defines the PLL division factors RCCU_PLL_Div enumeration is declared in the file 77x_rccu h typedef enum RCCU_Div_1 0x00 RCCU Div 2 RCCU Div 3 RCCU Div 4 RCCU Div 5 RCCU Div 6 RCCU Div 7 RCCU_PLL Div 32 229 0x01 0x02 0x03 0x04 0x05 0x06 UM0097 Peripheral firmware overview Table 15 lists the different values of the PLL division factor Table 15 PLL division factors PLL Division factor Description RCCU_Div_1 Division fact
11. TIM_PWMOModeContig Configures the PWM output mode TIM_PWMIModeConfig Configures the PWM input mode TIM_PWMI Value TIM_ITConfig Reads and returns the PWM input parameters Configures the TIM interrupts TIM_FlagStatus Gets the TIM flag Status TIM_FlagClear Clears the TIM pending flag TIM_CounterContig Configures the T M counter TIM_CounterValue This routine returns the timer counter value 107 229 Peripheral firmware overview UM0097 TIM_Init Function Name TIM_Init Function Prototype void TIM Init TIM _TypeDef TIMx This routine is used to Initialize the TIM peripheral registers to their Behavior Description deta lt values TIMx specifies the TIM to be initialized Input Parameter Refer to TIM values on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to initialize all the T M peripherals Initialize the TIMO peripheral TIM Init TIMO Initialize the TIM1 peripheral TIM Init IM1 Initialize the TIM2 peripheral TIM Init IM2 Initialize the TIM3 peripheral TIM Init TIM3 108 229 Peripheral firmware overview TIM_ClockSourceConfig Function Name Function Prototype TIM_ClockSour
12. UM0097 Y User manual STR71x firmware library Introduction About this manual This document is the STR71x firmware library user manual It describes the STR71x peripheral firmware library a collection of routines data structures and macros that cover the features of each peripheral The firmware library user manual is structured as follows e Definitions document conventions and firmware library rules Overview of the firmware library package content library structure installation guidelines and examples of how to use the library e Detailed description the firmware library configuration structure and function descriptions for each peripheral in detail About STR71x firmware library The STR71x firmware library is a firmware package consisting of device drivers for all standard STR71x peripherals You can use any STR71x device in applications without in depth study of each peripheral specification As a result using this library can save you a lot of the time that you would otherwise spend in coding and also the cost of developing and integrating your application Each device driver consists of a set of functions covering the functionality of the peripheral Since all the STR71x peripherals and their corresponding registers are memory mapped a peripheral can be easily controlled using C code The source code developed in C is fully documented A basic knowledge of C programming is require
13. ADC12 Channels Description ADC12_CHANNELO Channel 0 ADC12_CHANNEL1 Channel 1 ADC12_CHANNEL2 Channel 2 ADC12_CHANNEL3 Channel 3 215 229 Peripheral firmware overview UM0097 ADC12 flags The following enumeration defines the ADC 72 flags ADC 12_Flags enumeration is defined in the file 77x_adc12 h typedef enum ADC12_ DAO 0x01 ADC12_DA1 0x02 ADC12_DA2 0x04 ADC12_DA3 0x08 ADC12_OR 0x2000 ADC12_Flags Table 93 presents the ADC 72 flags Table 93 ADC12 flags ADC12 Flags Description ADC12_DA0 Data available in Channel 0 ADC12_DA1 Data available in Channel 1 ADC12_DA2 Data available in Channel 2 ADC12_DA3 Data available in Channel 3 ADC12_OR i beater ere seer on one of the channels has been 3 14 2 Firmware library functions Table 94 enumerates the different functions of the ADC 72 library Table 94 ADC12 library functions Function Name Description ADC12_Init Initializes the ADC 12 Configures the conversion mode single channel or round ADE MOCO ORNS robin operation Configures the prescaler to define an oversampling ADC 12_PrescalerContig frequency ADC12_ChannelSelect Selects the channel to be converted in single channel operation ADC 12_ConversionStart Starts the ADC 12 conversion in the selected mode ADC 12_ConversionStop Stops the ADC 12 conversion ADC12_ConversionValue Gets the result of conversion from the selected da
14. Gets the CAN receive Error counter 193 229 Peripheral firmware overview UM0097 CAN_EnterlInitMode Function Name Function Prototype CAN_EnterInitMode void CAN EnterInitMode u8s mask Behavior Description Switches the CAN into initialization mode This function must be used in conjunction with CAN_LeavelnitMode Input Parameter mask any binary value formed using the values defined in CAN control register bits on page 187 Output Parameter None Return Value None Required preconditions None Called Functions None See also CAN_Init on page 202 CAN_LeavelnitMode on page 194 Example This example illustrates one method to initialize the CAN Initialize the CAN and enable interrupts CAN_EnterInitMode CAN CR_IE CAN_LeavelnitMode Function Name Function Prototype CAN_LeavelnitMode void CAN LeaveInitMode void Behavior Description Leaves the initialization mode switch into normal mode This function must be used in conjunction with CAN_EnterInitMode Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None See also CAN_EnterInitMode on page 194 Example This example illustrates how to leave the initialization mode CAN LeaveInitMode UM0097 Peripheral firmware overview CAN_EnterTestMode
15. Input Parameter 1 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 Data a pointer on the buffer where the data will be stored Input Parameter 3 DataLength the number of bytes to receive Input Parameter 4 TimeOut the time out period value Output Parameter The received 9 bit data buffer Return Value The status register value before reading the received data Required preconditions The selected UART must be properly configured and enabled Called Functions UART_9BitByteReceive See also UART_Config on page 149 UART_OnOffConfig on page 154 Example This example illustrates how to read several 9 bit bytes from the UARTO define DataLength 16 ul6 wRxData DataLength ul6 wUART Status Read the received data ul6 UART_ 9BitDataReceive UARTO wRxData DataLength Oxff Check if data received without error if wUART_Status amp UART_ParityError UART_FrameError UART_OverrunError UART_TimeOutIdle handles the error UM0097 Peripheral firmware overview UART_StringReceive Function Name Function Prototype UART_StringReceive ul6 UART_StringReceive UART TypeDef UARTx u8 Data Behavior Description This function gets a string which ends with End of
16. Output Parameter None Return Value None Required preconditions None Called Functions None All the UART flags are listed in the 71x_uart h file can be selected as interrupt source except the UART_TxFull flag which is not affected by this function Example This example illustrates how to enable and disable the Receiver Buffer Full Interrupt sources in the UART Enable Receiver Buffer Full interrupt UART_ItConfig UARTO UART_RxBufFull ENABLE Disable Receiver Buffer Full interrupt UART_ItConfig UARTO UART_RxBufFull DISABLE Peripheral firmware overview UART_FifoConfig Function Name Function Prototype UART_FifoConfig void UART_FifoConfig UART_TypeDef UARTx FunctionalState NewState Behavior Description This routine Enables or Disables the Rx and Tx FIFOs of the selected UART Input Parameter 1 UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 NewSiatus specifies whether the FIFOs are enabled or disabled ENABLE enables FIFOs DISABLE disables FIFOs Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enable the UARTO FIFOs Enable the UART 0 FIFOs UART_FifoConfig UARTO ENABLE UART_FifoRe
17. Table 39 RTC structure fields continued Register Description DIVH Prescaler Divider Value High register DIVL Prescaler Divider Value Low register CNTH Counter High register CNTL Counter Low register ALRH Alarm High register ALRL Alarm Low register The ATC peripheral is declared in the same file define RTC BASE OxE000D000 ifndef DEBUG ifdef RTC define RTC RTC_TypeDef RTC_ BASE endif RTC else DEBUG ifdef RTC EXT RTC_TypeDef RTC endif RTC endif When debug mode is used RTC pointer is initialized in the file 71x_lib c ifdef RTC RTC RTC_TypeDef RTC_BASE endif In debug mode _RTC must be defined in the file 77x_conf h to access the peripheral registers as follows define RTC RTC flags The following enumeration defines the different RTC flags The RTC_FLAGS enumeration is defined in the file 71x_rtc h typedef enum RTC_GIR 0x0008 RTC _OWIR 0x0004 RTC _ ATR 0x0002 RTC_SIR 0x0001 RTC_FLAGS lt 85 229 Peripheral firmware overview UM0097 Table 40 describes the states of RTC flags Table 40 RTC flags RTC Flags Description RTC_GIR RTC Global Interrupt Request flag RTC_OWIR RTC overflow interrupt request RTC_AIR RTC Alarm interrupt request RTC_SIR RTC Second interrupt request RTC interrupts The following enumeration defines the real time clock interrupts The RTC_ T enumeration
18. This routine turns On Off the selected UART Input Parameter 1 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 NewSiate specifies whether the UART is enabled or disabled ENABLE enables the UART DISABLE disables the UART Output Parameter None Return Value None Required preconditions None Called Functions None UM0097 Peripheral firmware overview Example This example illustrates how to turn the UARTO On Turn the UART On UART_OnOffConfig UARTO ENABLE UART_ByteSend Function Name UART_ByteSend Function Prototype void UART_ ByteSend UART_TypeDef UARTx u8 Data Behavior Description This function sends a 7 bit byte or an 8 bit byte using the selected UART UARTx Selects the UART to be configured x can be 0 1 2 or 3 Input Parameter 1 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 Data a pointer on the data byte to send Output Parameter None Return Value None The selected UART must be properly configured and enabled See Required preconditions UART Config and UART_OnOffConfig functions Called Functions None Example This example illustrates how to send an 8 bit byte using the UARTO u8 Data 0x55 UART
19. XTI_WakeUp 1 XTI_ Interrupt XTI_WakeUpInterrupt XTIMode_TypeDef Table 35 describes the XT modes Table 35 XTI modes Pin mode Description XTI_WakeUp The interrupt lines are used to Wake Up the system from the STOP mode The interrupt lines are used to generate an IRQ interrupt on the XTI XTI_Interrupt cha n l Interrupt lines are used to generate an IRQ interrupt on the XTI channel XTI_WakeUpinterrupt and to wake up the system from the STOP mode Trigger edge polarity The following enumeration defines the values of the trigger edge polarity XTITriggerEdge_TypeDef enumeration is defined in 71x_xti h file typedef enum XTI_FallingEdge XTI_RisingEdge XTITriggerEdge TypeDef Table 36 lists the trigger edge polarity values Table 36 Trigger Edge Polarity Trigger edge polarity values Description XTI_FallingEdge The Wake Up interrupt will be set on the falling edge XTI_RisingEdge The Wake Up interrupt will be set on the rising edge Common parameter values Lines Table 37 shows the Lines parameter value for each interrupt line Table 37 Lines values Lines value Corresponding Line XTI_Lineo Line 0 Software interrupt XTI_Line1 Line 1 USB wake up event XTI_Line2 Line 2 External interrupt 77 229 Peripheral firmware overview UM0097 Table 37 Lines values continued
20. Behavior Description Disables the FIFO of the specified BSPI Input Parameter BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to disable the BSPIO FIFO BSPI_FifoDisable BSPIO 133 229 Peripheral firmware overview UM0097 BSPI_ClockDividerConfig Function Name Function Prototype BSPI_ClockDividerConfig void BSPI_ClockDividerConfig BSPI_TypeDef BSPIx u8 Div Behavior Description Configures BSPI clock divider Input Parameter 1 BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 to select the BSPI Input Parameter 2 Div holds the value of the clock divider Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to set BSPIO clock divider to 8 BSPI_ ClockDividerConfig BSPIO 8 BSPI_FlagStatus Function Name Function Prototype BSPI_FlagStatus FlagStatus BSPI FlagStatus BSPI TypeDef BSPIx BSPI Flags flag Description Checks whether the specified BSP Flag is set or not Input Parameter 1 Input Parameter 2 BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 flag specifies the flag to see the statu
21. StopBits Selects the number of the stop bits Refer to UART stop bits on page 142 for details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None 148 229 lt UM0097 Peripheral firmware overview Example This example illustrates how to configure the UARTO stop bits number to 1 stop bit Configure the UARTO stop bits to 1 stop bit UART_StopBitsConfig UARTO UART_1 StopBits UART_Config Function Name UART_Config void UART_Config UART_TypeDef UARTx u32 BaudRate Function Prototype UARTParity TypeDef Parity UARTStopBits TypeDef StopBits UARTMode_ TypeDef Mode This function configures the Baud rate parity mode the number of stop Behavior Description bits and the UART mode of the selected UART UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values Input Parameter on page 145 for details on the allowed values of this parameter Input Parameter 2 BaudRate the baudrate value in bps Parity selects the parity type Refer to UART parity modes on page 143 Input Parameter 3 for details on the allowed values of this parameter StopBits selects the number of the stop bits Refer to UART stop bits on Input P ter 4 f ieee arameo page 142 for details on the allowed values of this parameter Mode selects the UART mode Refer to UART modes on page 14
22. The first section describes the data structures used in the PCU firmware library The second section presents the PCU firmware library functions Data structures PCU register structure The PCU register structure PCU_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vul6 MDIVR ul6 EMPTY1 vul6 PDIVR ul6 EMPTY2 vul6 RSTR ul6 EMPTY3 vul6 PLL2CR ul6 EMPTY4 vul6 BOOTCR ul6 EMPTYS 17 229 Peripheral firmware overview UM0097 18 229 vul6 PWRCR ul6 EMPTY6 PCU_TypeDef Table 4 describes the PCU structure fields Table 4 PCU structure fields Register Description MDIVR CPU frequency division factor PDIVR APB frequency division factor RSTR Peripheral Reset Control Register PLL2CR PLL2 Control Register BOOTCR Boot Configuration Register PWRCR Power Control Register The PCU peripheral is declared in the same file define PCU BASE 0xA0000040 ifndef DEBUG ifdef _PCU define PCU PCU_TypeDef PCU BASE endif PCU else DEBUG ifdef _PCU EXT PCU_TypeDef PCU endif PCU endif When debug mode is used PCU pointer is initialized in the file 71x_lib c ifdef _PCU define PCU PCU_TypeDef PCU_BASE endif PCU In debug mode _PCU must be defined in the file 77x_conf h to access the peripheral registers as follows define _PCU Some PCU functions use the RCCU and the XTI registers and fu
23. ttt 185 CAN message interface structure fieldS 0 000 cc eee eee 186 Standard CAN bitrates 0 0 0 tees 187 CAN control register bits 0 0 ete 188 CAN status register bits 0 0 0 ee 188 CAN test register bits 0 0 6 teen 189 CAN message interface register bits 0c cece ee 190 CAN wake up modes 06 0c 191 CAN message structure parameters 000 cece 191 CAN message identifier types 0 0c ects 192 CAN identifier limit values 0 0 0 0 cette 192 CAN library functions 0 00000 192 ADG12 registers iii eeg Set deals Sheed weet LY Me A Pee Pe aad baie ot oak OS 214 ADC12 conversion modes auauna eaea 215 ADC12 channels nananana uaaa 215 ADG12 1lagS iiaa araa si arici de Paes a edhe doe Y i Eaa a ed 216 ADC12 library functions 0 0 0 tte 216 EMI MOJE S ta cccc5 eked te Pee eae ed Done ei ed dy eee aw eee 223 EMI library functions 0 0 0 raritet re eee 224 Document revision history 0 0 0 e ee ete 226 5 229 Document and library rules UM0097 1 Document and library rules The user manual and the firmware library use the conventions described in the sections below 1 1 Abbreviations Table 1 describes the different abbreviations used in this document Table 1 List of acronyms Acronym Peripheral Unit ADC12 12 bit Analog to Digital Converter APB Advanced Peripheral
24. 0x00000200 RCCU_WKPReset 0x00000400 RCCU_ResetSources Table 20 describes the RCCU reset sources Table 20 RCCU reset sources RCCU reset sources Description RCCU_ExternalReset Reset caused by external pin RCCU_SoftwareReset Reset caused by software RCCU_WDGReset Reset caused by Watchdog RCCU_RTCAlarmReset Reset caused by ATC to wake up the system from StandBy mode RCCU_LVDReset Reset caused by LVD RCCU_WKPReset eas caused by wake up pin to wake up the system from StandBy PLL1 free running modes The following enumeration defines the PLL1 free dunning modes RCCU_PLL1FreeRunningModes enumeration is declared in the file 71x_rccu h typedef enum RCCU_PLL1FreeRunning125 RCCU_PLL1FreeRunning250 RCCU_PLL1FreeRunning500 RCCU_PLL1FreeRunningModes lt 35 229 Peripheral firmware overview UM0097 3 2 2 36 229 Table 21 describes the PLL1 free running modes Table 21 PLL1 free running modes RCCU_PLL1FreeRunning125 PLL1 free running modes Description PLL1 provides 125 kHz RCCU_PLL1FreeRunning250 PLL1 provides 250 kHz RCCU_PLL1FreeRunning500 PLL1 provides 500 kHz Firmware library functions The following table enumerates the different functions of the RCCU library Function Name RCCU_Div2Contig Description Enables Disables the programmable clock division by two RCCU_Div2Status Checks if the programmable cl
25. Called Functions None Example This example illustrates how to configure the EMI u8 data Configure the EMI bank 1 7 wait states 16 bit wide external memory device EMI_Config EMI_BANK1 EMI SIZE 16 EMI_7 WaitStates Enable EMI bank 1 EMI_Enable EMI_BANK1 ENABLE Write data to the external memory u32 0x62000000 0x12345678 write 12345678 in bank 1 Read data from the external memory data u8 0x62000008 read from bank 1 225 229 Revision history UM0097 4 226 229 Revision history Table 97 Document revision history Date 24 Jan 2006 Revision 1 0 Changes Initial release 31 Jan 04 1 1 Changed file description in Section 2 1 on page 11 below figure 1 Changed RCCU_RCLK_Clocks enum type in RCLK clock source on page 31 Added RCCU_RTC_CLOCK row in RCLK clock source on page 31 27 Mar 04 1 2 Added Register name differences Section 3 10 Jul 04 1 3 New types are defined in Section 1 4 on page 7 How to use the STR71x Library in Section 2 3 on page 14 PCU_EnterWFI function renamed to PCU_WFlEnter in Section 5 1 2 7 PCU_EnterLPM function renamed to PCU_LPMEnter in Section 5 1 2 8 FLASH_AccessPrConfig function deleted in Section 3 16 on page 241 FLASH_EraseSector function renamed to FLASH_SectorErase in Section on page 248 FLASH_EraseBank function renamed to FLASH_BankErase in FLASH_BankErase on page 24
26. RCCU_PLL1Disable Function Name RCCU_PLL1Disable Function Prototype void RCCU_PLL1Disable void Behavior Description This routine is used to switch off the PLL1 Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to switch off the PLL1 switch off the PLL1 RCCU_PLL1Disable RCCU_PLL2Disable Function Name RCCU_PLL2Disable Function Prototype void RCCU_PLL2Disable void Behavior Description This routine is used to switch off the PLL2 Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to switch off the PLL2 switch off the PLL2 RCCU_PLL2Disable lt 46 229 UM0097 Peripheral firmware overview RCCU_GenerateSWReset Function Name RCCU_GenerateSWReset Function Prototype void RCCU_GenerateSWReset void Behavior Description This routine is used to generate a software reset Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to generate the software reset Generate Software Reset RCCU_GenerateSWReset 3 3 Advanced peripheral bus bridges APB The APB driver may be used for a variety of pur
27. UM0097 Peripheral firmware overview ADC12_ ConversionStart Function Name ADC12_ConversionStart Function Prototype void ADC12_ConversionStart void Behavior Description This routine is used to launch the conversion Input Parameter None Output Parameter None Return Value None Required preconditions Mode of conversion and prescaler configured Called Functions None See also ADC12_ConversionStop on page 219 Example This example shows how to start the ADC 72 conversion configure the prescaler ADC12_ PrescalerConfig configure the mode ADC12 ModeConfig ADC12_ SINGLE select the channel 3 to be converted ADC12_ ChannelSelect ADC12_CHANNEL3 f Enable the ADC12 and Start the conversion ADC12_ConversionStart ADC12_ConversionStop Function Name ADC12_ConversionStop Function Prototype void ADC12_ ConversionStop void Behavior Description This routine is used to disable the ADC12 cell Input Parameter None Output Parameter None Return Value None Required preconditions Conversion started Called Functions None See also ADC12_ConversionStart on page 219 Example This example shows how to end the ADC 12 conversion start the conversion 219 229 Peripheral firmware overview UM0097 ADC12_ConversionStart Stop the conversion ADC12_ ConversionStop ADC12_ Conve
28. int main void ifdef DEBUG debug endif EIC configuration Set Timer 0 interrupt channel priority level to 2 EIC_ IRQChannelPriorityConfig TOTIMI IRQChannel 2 Enable Timer 0 IRQ channel interrupts EIC_IRQChannelConfig TOTIMI_IRQChannel ENABLE Set Timer 1 interrupt channel priority level to 1 15 229 Firmware library UM0097 16 229 EIC_ IRQChannelPriorityConfig T1ITIMI_ IRQChannel 1 Enable Timer 1 IRQ channel interrupts EIC_ IRQChannelConfig T1ITIMI_IRQChannel ENABLE configure GPIOO pins as push pull output mode GPIO Config GPIOO OxFFFF GPIO OUT PP Set GPIOO pins to low level GPIO WordWrite GPIOO 0x0000 configure GPIO1 pins as push pull output mode GPIO Config GPIO1 OxFFFF GPIO OUT PP Set GPIO1 pins to low level GPIO WordWrite GPIO1 0x0000 Timer 0 Configuration E Initialize the Timer TIM Init TIMO Configure Timer 0 Prescaler IM PrescalerConfig TIMO 0xOF Enable Timer 0 Overflow Interrupt TIM ITConfig TIMO TIM TO IT ENABLE Timer 1 Configuration Initialize the Timer TIM Init TIM1 T Configure Timer 1 Prescaler IM PrescalerConfig TIM1 0xFF Enable Timer 1 Overflow Interrupt TIM ITConfig TIM1 TIM_ TO IT ENABLE T T Enable IRQ interrupts EIC_IRQConfig ENABLE Start Timer 0 IM_CounterConfig
29. Function Name CAN_EnterTestMode Function Prototype void CAN EnterTestMode u8s mask Behavior Description Switches the CAN into test mode mask any binary value formed using the values defined in CAN test Input Parameter register bits on page 188 Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enter any test mode Switch the CAN into Loopback mode i e RX is disconnected from the bus and TX is internally linked to RX CAN EnterTestMode CAN TESTR_LBACK CAN_LeaveTestMode Function Name CAN_LeaveTestMode Function Prototype void CAN LeaveTestMode void Behavior Description Leaves the current test mode switch into normal mode Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to leave the current test mode CAN _LeaveTestMode 195 229 Peripheral firmware overview UM0097 196 229 CAN_ SetBitrate Function Name Function Prototype CAN_SetBitrate void CAN SetBitrate int bitrate Behavior Description Sets up a standard CAN bitrate Input Parameter bitrate one of the CAN_BITRATE_xxx defines Refer to CAN standard bitrates on page 187 for more details on the allowed values of this parameter Output Parameter
30. None Example This example illustrates how to get the T M2 prescaler value vu8 bCurrentPrescaler bCurrentPrescaler TIM PrescalerConfig TIM2 UM0097 Peripheral firmware overview TIM_ClockLevelConfig Function Name TIM_ClockLevelConfig void TIM ClockLevelConfig TIM _TypeDef TIMx Function Prototype Clock Levels Xlevel This routine configures the active level when using an external clock Behavior Description source TIMx specifies the TIM to be configured Refer to T M values on Input Parameter page 103 for more details on the allowed values of this parameter Xlevel specifies the active edge of the external clock Refer to Clock Input Parameter 2 edges enumeration on page 104 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the TIMO to be clocked by an external clock source and the active edge to falling edge Configure the Active Clock edge TIM ClockLevelConfig TIMO TIM FALLING Configure the TIMO source clock TIM _ClockSourceConfig TIMO TIM _EXTERNAL 111 229 Peripheral firmware overview UM0097 112 229 TIM_ClockLevelValue Function Name Function Prototype TIM_ClockLevelValue Clock Levels TIM ClockLevelValue TIM _TypeDef TIMx
31. TIM _TypeDef TIMx TIM Channels Xchannel ul6 XpulseLength TIM_OC_ Modes Xmode TIM Logic Levels Xlevel Behavior Description This routine is used to configure the output compare mode Input Parameter 1 TIMx specifies the T M to be initialized Refer to T M values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xchannel specifies the output compare channel Refer to TIM channels enumeration on page 104 for more details on the allowed values of this parameter Input Parameter 3 XpulseLength specifies the pulse length Input Parameter 4 Input Parameter 5 Xmode specifies the output compare mode Refer to Output compare modes enumeration on page 105 for more details on the allowed values of this parameter Xlevel specifies the level of the external signal after the match occurs Refer to Logic levels enumeration on page 105 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the TIM3 output compare channel A to generate an external wave which toggle from low level to high level after Ox7FFF timer period TIM _OCMPModeConfig TIM3 TIM CHANNEL A OxX7FFF TIM WAVE TIM HIGH 114 229 lt UM0097 Peripheral firmware overview TIM_OPModeConfig Fun
32. Table 52 enumerates the logic levels Table 52 Logic levels Logic level Description The output compare is forced to the high level after the match between TIM_HIGH the counter and the output compare register TIM_LOW The output compare is forced to the low level after the match between the counter and the output compare register Counter operations enumeration The following enumeration defines the different counter operations The CounterOperations enumeration is defined in the file 71x_tim h typedef enum TIM START TIM STOP TIM CLEAR TIM_CounterOperations 105 229 Peripheral firmware overview UM0097 Table 53 enumerates the counter operations Table 53 Counter operations Counter Operation Description TIM_START Enables or resumes the counter TIM_STOP Stops the TIM counter TIM_CLEAR Clears the TIM counter value and set its value to FFFCh PWM input parameters structure The following structure defines the different PWM input parameters The PWMI_parameters structure is defined in the file 77x_tim h typedef struct ul6 Pulse ul6 Period PWMI_ parameters Table 54 defines the PWM input parameters Table 54 PWM input parameters Structure Field Description Pulse The pulse of the external signal Period The period of the external signal TIM interrupts The following section lists the different TIM interrupts Those interrupts are declare
33. The first and the second sections describe the data structure and the common parameter values The second one presents the EIC firmware library functions UM0097 Peripheral firmware overview 3 4 1 Data structures EIC register structure The EIC peripheral register structure E C_TypeDef is defined in the file 71x_map h as follows typedef volatile struct vu32 ICR vu32 CICR vu32 CIPR u32 EMPTY1 3 vu32 IVR vu32 FIR vu32 IER u32 EMPTY2 7 vu32 IPR u32 EMPTY3 7 u32 SIR 32 EIC_TypeDef Table 26 presents the EIC peripheral registers Table 26 EIC peripheral registers Register Description ICR Interrupt Control Register CICR Current Interrupt Channel Register CIPR Current Interrupt Priority Register IVR Interrupt Vector Register FIR Fast Interrupt Register IER Interrupt Enable Register IPR Interrupt Pending Register SIR Source Interrupt Registers EIC peripheral is declared in the 77x_map h file as follows EIC Base Address Definition define EIC BASE OxFFFFF800 ifndef DEBUG ifdef EIC define EIC EIC_TypeDef EIC BASE endif EIC else DEBUG ifdef EIC EXT EIC TypeDef EIC endif EIC endif 53 229 Peripheral firmware overview UM0097 54 229 When debug mode is used EIC pointer is initialized in 71x_lib c file as follows ifdef EIC EIC EIC TypeDef EIC_ BASE endif In debug mode _EIC variable mu
34. endif GPIO2 endif GPIO TypeDef GPIOO BASE GPIO TypeDef GPIO1 BASE GPIO TypeDef GPIO2 BASE GPIOO GPIO1 GPIO2 lt UM0097 Peripheral firmware overview When debug mode is used GPIO pointer is initialized in 71x_lib c file ifdef _GPIOO GPIOO GPIO TypeDef GPIOO BASE endif ifdef _GPIO1 GPIO1 GPIO TypeDef GPIO1 BASE endif ifdef _GPIO2 GPIO2 GPIO TypeDef GPIO2 BASE endif In debug mode the following variables are defined in 71x_confh file e _GP Ois defined to include the GPIO library e _GPIOO _GPIO1 and _GPIO2 are defined to access the peripheral registers define TQFP144 define _GPIO define _GPIOO define GPIO1 ifdef TOQFP144 define GPIO2 Hendif TOFP144 GPIO pin mode enumeration The following enumeration defines the different possible pin modes for GP O peripheral GpioPinMode_TypeDef enumeration is defined in 71x_gpio h file typedef enum GPIO HI AIN TRI GPIO_ IN TRI TTL GPIO IN TRI CMOS GPIO_IPUPD WP GPIO OUT_OD GPIO OUT PP GPIO AF OD GPIO AF PP GpioPinMode TypeDef Table 30 describes the pin modes Table 30 GPIO pin modes Pin mode Description GPIO_HI_AIN_TRI High impedance Analog Input Tristate GPIO_IN_TRI_TTL Input Tristate TTL GPIO_IN_TRI_LCMOS INPUT Tristate CMOS GPIO_IPUPD_WP Input Pull Up Pull Down Configuration GPIO_OUT_OD Open Drain Output Ky 67 229 Peripheral firmwa
35. 0 ee 14 3 Peripheral firmware overview 000000 e eee eee eee 17 3 1 Power control unit PCU 25 6 0x22 00 ten ee Mee poe epee he e ee key be 17 3 1 1 Data StructlreS cnc ecb a ta eet doo a ea a 17 3 1 2 Firmware library functions 0 c cee eee 20 3 2 Reset and clock control unit RCCU 002s 29 3 2 1 Data structures 2 0 eee 29 3 2 2 Firmware library functions 0 c cee eee 36 3 3 Advanced peripheral bus bridges APB 000 0 ce eee 47 3 3 1 Data structures icc crer etiara ERINE E ANREDE EREE oda 47 3 3 2 Common parameter values 0 0 00 cece tees 50 3 3 3 Firmware library functions 0 0 0 0 eee eee 50 3 4 Enhanced interrupt controller EIC 2 0 00 c eee eee 52 3 4 1 Data SUCIOS sor becca este eedteee baw deen rae ee ibaa eek eee 53 3 4 2 Firmware library functions 00 c cee eee 56 3 5 General purpose input output GPIO 0c eee eee 65 3 5 1 Data structures 2 0 tee 65 3 5 2 Common parameter values 0 000 cece eee eens 68 3 5 3 Firmware library functions 00 0 0 cee eee 69 3 6 External Interrupts XTl 0 000 cece ees 75 2 229 ky UM0097 Contents 3 6 1 Data structures 22 40s ceed cee ede te eee e eee besa eae 75 3 6 2 Common parameter values 00 00 c eee eee eee 77 3 6 3 Firmware library functions 000 c cee eee 78 3 7 Real time clock RTC 12442824 24202204508 ce8
36. 1 Input Parameter 2 Flag specifies the flag to check Refer to 2C flags on page 167 for more details on allowed values of Flag parameter Output Parameter None Return Value The specified flag status SET if the tested flag is set RESET if the tested flag is reset Required Preconditions None Called Functions None Example This example illustrates how to get flag status u32 I2CStatus do I2C_STARTGenerate I2C0 ENABLE while I2C_FlagStatus I2C0 I2C_SB RESET I2C AddressSend I2C0 M24C08 Block3ADDRESS I2C Mode7 I2C_TX while I2CStatus I2C GetStatus I2C0 amp I2C_EVF while I2C FlagStatus I2C0 I2C_ENDAD RESET I2C_FlagClear I2C0 I2C_ENDAD while I2C_FlagStatus I2C0 I2C_AF I2CStatus SET lt UM0097 Peripheral firmware overview I2C_FlagClear Function Name 12C_FlagClear l id I2C FlagCl I2C_TypeDef I2Cx Function Prototype Kas FlagClear 12C_TypeDe x u32 Flag Behavior Description Clears the 12C Flag passed as a parameter Input Parameter 1 12Cx specifies the 12C to clear its flags where x can be 0 or 1 Flag the flag to be read Refer to 2C flags on page 167 for more Inport Parameter 2 details on allowed values of Flag parameter Output Parameter None Return Value None Required Preconditions None Call
37. 12COITERR_IRQChannel C 0 error interrupt 7 12C1ITERR_IRQChannel C 1 error interrupt 8 UARTO_IRQChannel UART 0 global interrupt 9 UART1_IRQChannel UART 1 global interrupt 10 UART2_IRQChannel UART 2 global interrupt 11 UART3_IRQChannel UART 3 global interrupt 12 SPIO_IRQChannel BSPI 0 global interrupt 13 SPI1_IRQChannel BSPI 1 global interrupt 14 12C0_IRQChannel IC 0 global interrupt 15 12C1_IRQChannel IC 1 global interrupt 16 CAN_IRQChannel CAN module global interrupt 17 ADC_IRQChannel ADC sample ready interrupt 18 T1TIMI_IRQChannel Timer 1 global interrupt 19 T2TIMI_IRQChannel Timer 2 global interrupt 20 T3TIMI_IRQChannel Timer 3 global interrupt 21 HDLC_IRQChannel HDLC global interrupt 25 USBLP_IRQChannel USB low priority event interrupt 26 TOTOI_IRQChannel Timer 0 overflow interrupt 29 TOOC1_IRQChannel Timer 0 output compare 1 interrupt 30 TOOC2_IRQChannel Timer 0 output compare 2 interrupt 31 FIQ channel enumeration The following enumeration defines the different values of the F Q channel FIQChannel_TypeDef enumeration is defined in the file eic h typedef enum TOTIMI_ FIQChannel 0x00000001 WDG_FIQChannel WDGTOTIMI_ FIQChannels 0x00000003 0x00000002 Il FIQChannel_TypeDef 55 229 Peripheral firmware overview UM0097 3 4 2 56 229 Table 28 describes the different values of FIQChannel Table 28 FiQChannel values FIQChannel Interrupt Source Value TOTIMI_FIQChannel
38. 7 or 8 bit bytes from the selected UART UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 1 Input Parameter 2 Data A pointer to the received data Input Parameter 3 DataLength The number of bytes to receive Input Parameter 4 TimeOut The Time out value Output Parameter The received 8 bit data buffer Return Value The UARTx_SR register content before reading the received data Required preconditions The selected UART must be properly configured and enabled Called Functions UART_ByteReceive UART_Config on page 149 See also m A j UART_OnOffConfig on page 154 Example This example illustrates how to read several data from the UARTO define DataLength 16 u8 bRxData DataLength ul6 wUART Status Read the received data ul6 UART DataReceive UARTO bRxData DataLength Oxff Check if data received without error if wUART_Status amp UART_ParityError UART_FrameError UART_OverrunError UART_TimeOutIdle handles the error lt 161 229 Peripheral firmware overview UM0097 162 229 UART_9BitDataReceive Function Name Function Prototype UART_9BitDataReceive ul6 UART_9BitDataReceive UART_TypeDef UARTx ul6 Data u8 DataLength u8 TimeOut Behavior Description This routine gets several 9 bit bytes from the selected UART
39. Bus bridges BSPI Buffered Serial Peripheral Interface CAN Controller Area Network TIM Timer EIC Enhanced Interrupt Controller XTI External Interrupts EMI External Memory Interface FLASH Embedded Flash GPIO General Purpose Input Output 12C Inter Integrated Circuit PCU Power Control Unit RCCU Reset amp Clock Control Unit RTC Real Time Clock UART Universal Asynchronous Receiver Transmitter USB Universal Serial Bus WDG Watchdog Timer 1 2 Styles and symbols The firmware library uses the following style conventions e Program listings program examples structure definitions and function prototypes are shown in a special typeface This example is a function prototype shown in courier typeface int PPP Config int pPointer Program portions variables and function names quoted in a paragraph are in italic typeface For example bVariable is used as local variable in the function PPP_Config e Acomment ina program listing is shown in italic typeface For example int PPP Config int pPointer this is a comment 6 229 ky UM0097 Document and library rules 1 3 1 4 Naming conventions The Firmware Library uses the following naming conventions PPP is used to reference to any peripheral acronym e g ADC See the section above for more information on peripheral acronyms System and source header file names must be preceded by 71x e g 71x_conf h except driver source code and header fi
40. Command Request Register CMR Command Mask Register M1R Mask 1 Register M2R Mask 2 Register A1R Message Arbitration 1 Register A2R Message Arbitration 2 Register MCR Message Control Register DA1R Data A 1 Register DA2R Data A 2 Register DB1R Data B 1 Register DB2R Data B 2 Register The CAN peripheral is also declared in the 71x_map h file faerie APB1 BASE 0xC0000000 peer ine CAN BASE APB1 BASE 0x9000 ifndef DEBUG ifdef CAN define CAN CAN_TypeDef CAN BASE endif else ifdef _CAN EXT CAN TypeDef CAN endif endif When debug mode is used CAN pointer is initialized in the file 71x_lib c ifdef _CAN CAN CAN_TypeDef CAN BASE endif CAN lt 186 229 UM0097 Peripheral firmware overview In order to access the peripheral registers CAN must be defined in the file 77x_conf has follows define _CAN Some XT and PCU functions are called _XTI and _PCU must be defined in 71x_confh file to make the XT and PCU functions accessible define _PCU define XTI CAN standard bitrates The following enumeration defines the different standard bitrates available It is defined in the file can h enum CAN BITRATE 100K CAN BITRATE 125K CAN BITRATE 250K CAN BITRATE 500K CAN BITRATE 1M ie Table 80 describes the standard bitrates of the CAN with their timing parameters Table 80 Standard CAN bitrates Bitrate name Bi
41. Description updated for T M_ TConfig on page 119 Input parameters corrected for T M_OPModeConfig on page 115 Description updated for T M_ITConfig on page 119 Renamed function TIM_TOE_Mask to TIM_TOIE_Mask Renamed function T IM_OCAIE_mask to TIM_OCAIE_Mask Renamed function T M_OCBIE_mask to TIM_OCBIE_Mask lt 227 229 Revision history UM0097 228 229 Table 97 Document revision history continued Date 17 Sep 07 Revision 3 cont d Changes In Section 3 10 Buffered serial peripheral interface BSP Renamed the typedef BSPI_ITS to BSPI_IT_ERR Renamed the interrupt error sources BSPI_BERIT by BSPI_BEIE BSPI_RCIT by BSPI_REIE and BSPI_ALL by BSPI_ALL_ERR Changed typedef BSP _TR_IT_SRCS to BSPI_IT_TR Changed typedef BSP _RC_IR_SRCS to BSPI_IT_RC Changed BSPI_ItEnable function name to BSPI_ErrltSrc Added new function BSPI_WordBufferSend Added new function BSPI_WordBufferReceive Changed BSPI_BufferSend function to BSPI_ByteBufferSend Changed BSPI_BufferReceive function to BSPI_ByteBufferReceive In Section 3 11 Universal asynchronous receiver transmitter UART Changed UART_RxBufFull to VART_RxBufNotEmpty Changed sendchar function name to SendChar In Section 3 12 Inter integrated circuit I2C I C Flags updated 2C flags on page 167 I2C_FlagStatus example modified 2C_FlagStatus on page 176 Note 2 added for GP O_BitWrite and GPIO_ByteWrite tables Repeated I2C registers table deleted Sectio
42. GPIO1 GPIO MSB 0x00 74 229 UM0097 Peripheral firmware overview GPIO_WordWrite Function Name GPIO_WordWrite void GPIO WordWrite GPIO TypeDef GPIOx Function Prototype ul6 Port Val Behavior Description Writes a value in to the selected data port register GPIOx selects the port x can be 0 1 or 2 Input Parameter 1 Refer to GP Ox values on page 68 for details on the allowed values of this parameter Input Parameter 2 Port_Val holds the word value to be written to the selected data port Output Parameter None Return Value None Required preconditions The port pin must be configured as GPIO_OUT_OD or as GPIO_OUT_PP Called Functions None GPIO_BitWrite on page 73 See also s GPIO_ByteWrite on page 74 Example This example sets all the GPIOO port pins Set all the GPIOO port pins GPIO WordWrite GPIOO OxFFFF 3 6 External Interrupts XTI The XT driver may be used for several purposes such as firmware IRQ generation enabling and disabling interrupt lines selecting the edge sensitivity interrupt or Wake up mode The first section describes the data structure used in the XTI firmware library The second section presents the XTI firmware library functions 3 6 1 Data structures XTI register structure The XT peripheral register structure XT _TypeDef is defined in the file 77x_map h as follows typedef volatile struct
43. I2C0 I2C_ EVENT MASTER BYTE TRANSMITTED 183 229 Peripheral firmware overview UM0097 3 13 3 13 1 184 229 Controller area network CAN The CAN driver may be used to exchange data between interconnected devices sharing a CAN bus compliant with the CAN 2 0 B standard The application can use either polling mode or interrupt mode to handle the transmission and reception of frames The first section describes the data structures used in the CAN firmware library The second section presents the CAN firmware library functions In this chapter the terms message and frame will be alternatively used they both designate a standard data packet of variable length Data structures CAN registers structure The CAN registers structure CAN_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vul6 CR vul6 EMPTY1 vul6 SR vul6 EMPTY2 vul6 ERR vul6 EMPTY3 vul6 BTR vul6 EMPTY4 vul6 IDR vul6 EMPTY5 vul6 TESTR vul6 EMPTY6 vul6 BRPR vul6 EMPTY7 3 Obj_TypeDef sMsgObj 2 PTY8 16 1R PTY9 2R MPTY10 13 1R PTY11 2R MPTY12 13 1R PTY13 2R MPTY14 13 1R MPTY15 V2R MPTY16 CAN_TypeDef Q as zg S U U0 tg lt lt 0D H os E SAHAMH MASS T Ha E w AHHH a UM0097 Peripheral firmware overview This structure embeds another structure named
44. LP_WFI mode with FLASH in PWD mode and MVR disabled RCLK CLK2_16 Set the MVR disabled and the FLASH in PWD mode during LP_WFI mode PCU_LPModesConfig DISABLE DISABLE DISABLE ENABLE LPWFI_CLK2_ 16 1 CLK2 16 selected during LPWFI Enable low power mode during WFI mode FLASH in powerdown during LPWFI and STOP modes MVREG is disabled during LPWFI and STOP modes PLL1 is disabled automatically when CK_AF is selected Enter LPWFI mode PCU_WFI UM0097 Peripheral firmware overview Example 3 This example configures LP_WFI mode with FLASH in PWD mode and MVR disabled RCLK CK_AF Set the MVR disabled and the FLASH in PWD mode during LP WFI mode PCU_LPModesConfig DISABLE DISABLE DISABLE ENABLE LPWFI_CK AF _CK_AF is selected during LPWFI _Enable Low power mode during WFI mode FLASH in powerdown during LPWFI and STOP modes MVREG is disabled during LPWFI and STOP modes PLL1 is disabled automatically when CK_AF is selected Go into LPWFI mode PCU WFI be PCU_STOP Function Name PCU_STOP Function Prototype void PCU_WFI void Behavior Description This routine is used to enter STOP mode Input Parameter None Output Parameter None Return Value None Required preconditions PCU_LPModesConfig function should be called to configure the STOP mode options Called Functions
45. None Example This example configures STOP FLASH in PWD mode and MVR disabled Set the MVR disabled and the FLASH in PWD mode during STOP mode PCU_LPModesConfig DISABLE DISABLE DISABLE ENABLE LPWFI_CK_AF CK AF is selected during LPWFI Enable Low power mode during WFI mode FLASH in powerdown during LPWFI and STOP modes MVREG is disabled during LPWFI and STOP modes PLL1 is disabled automatically when CK_AF is selected Go into STOP mode PCU_STOP 27 229 Peripheral firmware overview UM0097 28 229 PCU_STANDBY Function Name PCU_STANDBY Function Prototype void PCU_STANDBY void Behavior Description This routine is used to enter STANDBY mode Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This examples configures the RTC alarm then goes into STANDBY mode Configure RTC alarm after RTC_ALARM DELAY s RTC_AlarmConfig RTC_CounterValue RTC_ALARM DELAY Go into Standby PCU_STANDBY PCU_FlashBurstCmd Function Name PCU_FlashBurstCmd Function Prototype PCU_FlashBurstCmd FunctionalState NewState Behavior Description This routine is used to set the FLASH to LP BURST mode NewSiatus specifies whether the FLASH BURST mode is enabled or disabled Input Parameter ENABLE FLASH in BURST mode de
46. None Required preconditions None Called Functions None Example This example illustrates how to enable the TIM3 overflow and input capture A interrupts TIM ITConfig TIM3 TIM_TO IT TIM_ICA_IT ENABLE TIM_FlagStatus Function Name Function Prototype Behavior Description TIM_FlagStatus FlagStatus TIM FlagStatus TIM TypeDef TIMx TIM Flags Xflag This routine is used to check aT M flag status Input Parameter 1 TIMx specifies the TIM to check a flag Refer to TIM values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xflag specifies the TIM flag to be tested Refer to TIM flags enumeration on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value The flag status passed in parameter Required preconditions None Called Functions None 119 229 Peripheral firmware overview UM0097 Example This example illustrates how to check whether the Timer overflow interrupt of the T M3 is set FlagStatus TOF Status TIM FlagStatus TIM_FlagClear TIM FlagStatus TIM3 TIM_TOF Function Name Function Prototype TIM_FlagClear void TIM FlagClear TIM_TypeDef TIMx TIM Flags Xflag Behavior Description This routine is used to clear the TIM flags Input Parameter 1 TIMx specifies the TIM to clear a flag Refer to
47. Parameter 1 BSPIx selects BSPI peripheral to be used where x can be 0 or 1 BSPI_IE specifies the BSPI error interrupt to be enabled or disabled Refer to BSPI interrupts on page 123 for more details on the allowed values of this parameter Input Parameter 2 NewState specified whether the BSP error interrupt is enabled or disabled ENABLE to enable interrupt DISABLE to disable interrupt Input Parameter 3 Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to enable the interrupt feature in the BSP O peripheral BSPI ErriItSre BSPI0O BSPI BEIE ENABLE 139 229 Peripheral firmware overview UM0097 3 11 3 11 1 140 229 Universal asynchronous receiver transmitter UART The UART driver may be used for a variety of purposes including mode selection Baud rate configuration and 8 and 9 bit byte reception and transmission The first section describes the data structures used in the UAAT firmware library The second section presents the UAAT firmware library functions Data structures UART register structure The UART register structure UART_TypeDef is defined in the 71x_map h file as follows typedef struct vul BR MPTY1 xBUFR MPTY2 BUFR PTY3 MPTY4 ER MPTY5 a ON za J SA a Ez HA R O R a HAMHAHAQDQAND
48. T M values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xflag specifies the TIM flag to be cleared Refer to T M flags enumeration on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to clear the Timer overflow interrupt flag TIM FlagClear TIM3 TIM TOF 3 10 Buffered serial peripheral interface BSPI The BSP driver may be used for a variety of purposes including allowing several external peripherals to be linked through an SPI protocol bus The first section describes the data structures used in the BSP firmware library The second section presents the BSP firmware library functions 120 229 UM0097 Peripheral firmware overview 3 10 1 Data structures BSPI register structure The BSPI peripheral register structure BSPI_TypeDef is defined in the file 71x_map h as follows typedef struct vul6 RXR ul6 EMPTY1 vul6 TXR ul6 EMPTY2 vul6 CSR1 ul6 EMPTY3 vul6 CSR2 ul6 EMPTY4 vul6 CLK ul6 EMPTY5 BSPI_TypeDef Table 57 describes the BSPI registers Table 57 BSPI registers Register Description RXR Receive Register TXR Transmit Register CSR1 Control Status Register 1 CSR2 Control Status Register 2 CLK Master Clock Divi
49. TIMO TIM_ START Start Timer 1 IM_CounterConfig TIM1 TIM_ START pel Infinite loop while 1 UM0097 Peripheral firmware overview 3 3 1 Peripheral firmware overview This chapter describes in detail each peripheral firmware library The related functions are fully documented An example of use of the function is given and some important considerations to take into account to avoid failure are also provided This chapter describes each peripheral firmware library in detail The related functions are fully documented An example of use of the function is given and some important considerations to take into account to avoid failure are also provided Table 3 describes peripheral firmware functions Table 3 Peripheral firmware functions Function name Description Function prototype Prototype declaration Behavior Description Brief explanation of how the functions are executed Input Parameter x Description of the input parameters Output parameter x Description of the output parameters Return Value Value returned by the function Required Preconditions Conditions required before calling the function Called Functions Other library functions called by the function See also Related functions for reference Power control unit PCU The PCU driver may be used for a variety of purposes including power management configuration and low power mode selection
50. Table 84 CAN message interface register bits Bit mnemonic CAN_CRR_BUSY Description Command Request register Busy flag CAN_CMR_WRRD Command Mask register Write access CAN_CMR_MASK Command Mask register Mask access CAN_CMR_ARB Command Mask register Arbitration access CAN_CMR_CONTROL Command Mask register Control access CAN_CMR_CLRINTPND Command Mask register Clear interrupt pending CAN_CMR_TXRQST CAN_CMR_DATAA Command Mask register Transmit request release and New data access Command Mask register Data bytes 0 3 access CAN_CMR_DATAB Command Mask register Data bytes 4 7 access CAN_M2R_MXTD Mask register Mask extended identifier CAN_M2R_MDIR Mask register Mask message direction CAN_A2R_MSGVAL Arbitration register Message valid flag CAN_A2R_XTD CAN_A2R_DIR Arbitration register Extended identifier Arbitration register Message direction CAN_MCR_NEWDAT Message Control register New Data CAN_MCR_MSGLST Message Control register Message Lost CAN_MCR_INTPND Message Control register Interrupt Pending CAN_MCR_UMASK Message Control register Use Acceptance Mask CAN_MCR_TXIE CAN_MCR_RXIE CAN_MCR_RMTEN Message Control register Transmit Interrupt Enable Message Control register Receive Interrupt Enable Message Control register Remote frame Enable CAN_MCR_TXRQST Message C
51. UART Input Parameter 1 UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 Data A pointer to the received data Input Parameter 3 TimeOut The Time out value Output Parameter The received 9 bit data Return Value he UARTx_SR register contents before reading the received data Required preconditions The selected UART must be properly configured and enabled Called Functions None See also UART_Config on page 149 UART_OnOffConfig on page 154 Example This example illustrates how to read the received data on the UARTO ul6 wRxData ul6 wUART Status Read the received data WUART_ Status UART_ 9BitByteReceive UARTO amp wRxData OXFF Check if data received without error if wUART Status amp UART ParityError handles UART_FrameError UART_OverrunError UART_TimeOutIdle the error while UART_FlagStatus UARTO amp UART_RxBufFull while the receive empty wUART_Status 160 229 buffer is UART_9BitByteReceive UARTO amp bRxData OXFF UM0097 Peripheral firmware overview UART_DataReceive Function Name UART_DataReceive ul6 UART DataReceive UART_TypeDef UARTx Function Prototype u8 Data u8 DataLength u8 TimeOut Behavior Description Gets several
52. WFI_Ck_AF The RTC clock is selected during LPWFI 19 229 Peripheral firmware overview UM0097 PCU flags The following enumeration defines the PCU flags PCU_Flags enumeration is defined in the file 71x_pcu h typedef enum PCU WREN 0x8s000 PCU_VROK 0x1000 PCU Flags Table 8 lists the different PCU flags Table 8 PCU flags PCU Flags Description PCU_WREN Power Control Unit register Write Enable flag PCU_VROK Main Voltage Regulator OK flag 3 1 2 Firmware library functions Table 9 enumerates the different functions of the PCU library Table 9 PCU library functions Function Name Description PCU_MVRStatus Reads and returns the PCU main voltage regulator status PCU_FlagStatus Reads and returns the status of a specified PCU flag PCU_VRConfig Configures Enables Disables the PCU voltage regulators PCU_VRStatus Reads and returns the PCU voltage regulator status PCU_LVDDisable Disables the Low Voltage Detector PCU_LVDStatus Reads and returns the LVD status PCU_LPModesContig Configures the different STR71x low power mode options PCU_WFI Used to enter WFI and LPWFI modes PCU_STOP Used to enter STOP mode PCU_STANDBY Used to enter STANDBY mode PCU_FlashBurstCmd This routine is used to set the FLASH to LP BURST mode PCU_320SCCmd This routine is used to enable disable the 32 kHz oscillator 20 229 ky UM0097 Peripheral firmware overview PCU_MVRSt
53. been enabled Called Functions None Example This example illustrates how to test the waiting status of a message Send a message using object 0 CAN SendMessage 0 amp CanMsg Wait for the TX interrupt while CAN GetMsgInterruptStatus 0 210 229 UM0097 Peripheral firmware overview CAN_GetMsgValidStatus Function Name CAN_GetMsgValidStatus Function Prototype FlasgStatus CAN GetMsgValidStatus u32 msgobj Tests the validity of a message object ready to use Behavior Description A valid object means that it has been set up either as TX or as RX and so is used by the hardware Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value 1 if the corresponding message object is valid else 0 Required preconditions None Called Functions None Example This example illustrates how to test the validity of a message object if CAN _GetMsgValidStatus 10 Do something with message object 10 CAN_GetFlagStatus Function Name CAN_GetFlagStatus Prototype FlasgStatus CAN GetFlagStatus u32 CAN Flag Returns the state of the CAN flags TXOK RxOK EPASS EWARN and BOFF One of the following CAN_SR_TXOK CAN_SR_RXOK CAN_SR_EPASS CAN_SR_EWARN Behavior Description Input Parameter CAN_SR_BOFF Output Parameter None Return Value 1 if the flag passed in parameter is s
54. bus Basic mode This mode is used to minimize the resources needed to exchange data CAN_TESTR_BASIC frames for a given node The message RAM is not used anymore and there are only two dedicated message objects the first one to transmit the second to receive CAN message interface registers The following defines list the bit fields accessible in the CAN Message Interface registers They are declared in the file can h IFx Command Request register define CAN _CRR_BUSY 0x8000 IFn Command Mask register define CAN CMR_WRRD 0x0080 define CAN CMR_MASK 0x0040 define CAN _CMR_ARB 0x0020 define CAN CMR CONTROL 0x0010 define CAN CMR _CLRINTPND 0x0008 define CAN _CMR_TXROQST 0x0004 define CAN CMR_DATAA 0x0002 define CAN CMR_DATAB Ox0001 IFn Mask 2 register define CAN M2R_MXTD 0x8000 define CAN M2R MDIR 0x4000 IFn Arbitration 2 register define CAN A2R MSGVAL 0x8000 define CAN A2R_ XTD 0x4000 define CAN A2R DIR 0x2000 IFn Message Control register define CAN MCR _NEWDAT 0x8000 lt 189 229 Peripheral firmware overview UM0097 190 229 define CAN MCR _MSGLST define CAN MCR_INTPND define CAN MCR_UMASK define CAN MCR_TXIE define CAN MCR_RXIE define CAN MCR_RMTEN define CAN MCR_TXRQST define CAN MCR_EOB 0x4000 0x2000 0x1000 0x0800 0x0400 0x0200 0x0100 0x0080 Table 84 describes the CAN message interface register bits
55. describes the BSPI flags Table 58 BSPI flags BSPI Register Register Offset BSP_SR2 0x0C Flag Flag Index Flag Code BSPI_BERR Bus error flag 2 0x04 BSPI_RFNE Receive FIFO not empty flag 3 0x08 BSPI_RFF Receive FIFO full flag 4 0x10 BSPI_ROFL Receive overflow flag 5 0x20 BSPI_TFE Transmit FIFO empty flag 6 0x40 BSPI_TUFL Transmit underflow flag 7 0x80 BSPI_TFF Transmit FIFO full flag 8 0x100 BSPI_TFNE Transmit FIFO not empty flag 9 0x200 BSPI interrupts The following enumeration defines the BSPI interrupts The BSP _ITS_ERRis defined in the file 71x_bspi h as follows typedef enum BSPI BEIE 0x80 BSPI REIE 0x10 BSPI ALL ERR 0x90 BSPI_IT_ERR Table 59 enumerates the BSP interrupts Table 59 BSPl interrupts BSPI Interrupt Flags Description Transmit interrupt sources BSPI_BEIE Bus Error Interrupt BSPI_REIE Receive Error Interrupt BSPI_ALL_ERR All Error interrupts BSPI_BEIE and BSPI_REIE The following enumeration defines the BSP transmit interrupt sources The TR_IT_SRCSis defined in the file 717x_bspi h as follows typedef enum BSPI_TR FE BSPI_TR_UFL BSPI_TR FF BSPI_TR_DIS BSPI_IT_TR 123 229 Peripheral firmware overview UM0097 3 10 2 124 229 Table 60 enumerates the BSP transmit interrupt sources Table 60 BSPI transmit interrupt sources Transmit interrupt source Description
56. follows typedef enum I2C RX I2c_ TX I2C_ Direction Table 73 defines the C transfer direction Table 73 I C transfer direction IC direction Description I2C_TX Transmission I2C_RX Reception I7C flags The following definitions defines the PC flags 12C flags are defined in the file 71x_i2c h define I2C SB Ox00001 define I2C M SL 0x00002 167 229 Peripheral firmware overview UM0097 define I2C ADSL 0x00004 define I2C BTF 0x00008 define I2C BUSY 0x00010 define I2C TRA 0x00020 define I2C ADD10 0x00040 define I2C_EVF 0x00080 define I2C GCAL 0x00100 define I2C BERR 0x00200 define I2C ARLO 0x00400 define I2C STOPF 0x00800 define I2C AF 0x01000 define I2C_ENDAD 0x02000 define I2C STOP 0x08000 define I2C ACK 0x10000 define I2C START 0x20000 define I2C_PESET Mask 0x20 define I2C_ PERESET OxDF define I2C_ENGC Mask 0x10 define I2C_START_ Mask 0x08 define I2C_ STOP Mask 0x02 define I2C ACK Mask 0x04 define I2C_ ITE Mask 0x01 define I2C_Event_Mask Ox3 FFF Table 74 describes C flags Table 74 IC flags Flag Flag Code 12C_SB Start Master mode flag 0x00001 12C_M_SL Master Slave flag 0x00002 I2C_ADSL Address matched Slave mode flag 0x00004 12C_BTF Byte transfer finished flag 0x00008 12C_BUSY Bus busy flag 0x00010 I2C_TRA Transmitter Receiver flag 0x00020 I2C_ADD10 10 Bit addressing in master
57. is declared in the file 77x_rtc h typedef enum RTC_GIT 0x0008 RTC_OWIT 0x0004 RTC_AIT 0x0002 RTC_SIT 0x0001 RTC_IT Table 41 describes the ATC interrupts Table 41 RTC interrupts Constant Name Description RTC_GIT The RTC Global Interrupt RTC_OWIT The RTC overflow interrupt RTC_AIT The RTC Alarm interrupt RTC_SIT The RTC Second interrupt 3 7 2 Firmware library functions Table 42 enumerates the different functions of the RTC library Table 42 RTC library functions Function Name Description RTC_PrescalerValue Reads and returns the prescaler value RTC_PrescalerContig Configures the prescaler RTC_CounterValue Reads and returns the counter value RTC_CounterContig Update the RTC counter value RTC_AlarmValue Reads and returns the Alarm time value RTC_AlarmContig Configures the alarm time value RTC_FlagStatus Reads and returns the status of the specified RTC flag RTC_FlagClear Clears the specified RTC flag passed in parameter RTC_ITConftig Enables Disables the specified RTC interrupt 86 229 ky UM0097 Peripheral firmware overview Note Table 42 RTC library functions continued Function Name RTC_ITStatus Description Checks the status of the specified RTC interrupt RTC_ITClear Clears the specified RTC interrupt RTC_EnterCfgMode Enters the RTC configuration mode RTC_ExitCfgMode Exit from the con
58. message identifier types Table 87 CAN message identifier types ID type Description CAN_STD_ID Standard identifier 11 bit CAN_EXT_ID Extended identifier 29 bit CAN message identifier limits The identifier limit values for each type are listed below and are declared in the file can h define CAN LAST STD ID 1 lt lt 11 1 define CAN LAST EXT _ID 1L lt lt 29 1 Table 88 describes the CAN identifier limit values Table 88 CAN identifier limit values ID value Description CAN_LAST_STD_ID Maximum standard identifier Ox7FF CAN_LAST_EXT_ID Maximum extended identifier 0x1 FFFFFFF Firmware library functions Table 89 enumerates the different functions of the CAN library Table 89 CAN library functions Function Name Description CAN_EnterInitMode Switches the CAN into initialization mode CAN_LeavelnitMode Leaves the initialization mode switch into normal mode CAN_EnterTestMode Switches the CAN into test mode CAN_LeaveTestMode Leaves the current test mode switch into normal mode CAN_SetBitrate Sets up a standard CAN bitrate CAN_SetTiming Sets up the CAN timing with specific parameters CAN_SleepRequest Requests the CAN cell to enter sleep mode CAN_SetUnusedMsgObj Configures the message object as unused CAN_SetTxMsgObj Configures the message object as TX UM0097 Peripheral firmware overview Table 89 CAN library function
59. of the peripheral control registers A structure should be defined for each peripheral in 71x_map h file The example below illustrates the GPIO register structure declaration typedef volatile struct vul6 PCO vul EMPTY1 vul6 PC1 vul EMPTY2 vul6 PC2 vul 6 EMPTY3 vul6 PD GPIO_TypeDef Register names are the register acronyms written in upper case for each peripheral EMPTYi iis an integer that indexes the reserved field replaces a reserved field and is never used Sometimes an enumeration is needed for a peripheral This enumeration is called PPP_Registers and is declared in the file 77x_ppp h e g typedef enum GPIO PCO 0x00 GPIO PC1 0x04 GPIO PC2 0x08 GPIO PD 0x0C GPIO Registers 8 229 ky UM0097 Document and library rules Peripherals are declared in 71x_map h file This example shows the declaration of the GPIO peripheral ifndef EXT define EXT extern endif APB2 Base Address definition define APB2 BASE 0xE0000000 define GPIOO BASE APB2 BASE 0x3000 define GPIO1 BASE APB2 BASE 0x4000 GPIOO and GPIO1 peripherals declaration ifndef DEBUG ifdef _GPIOO define GPIOO GPIO_TypeDef GPIOO BASE endif GPIOO ifdef _GPIO1 define GPIO1 GPIO_TypeDef GPIO1_ BASE Hendif GPIO1 else DEBUG ifdef _GPIOO EXT GPIO TypeDef GPIOO Hendif GPIOO ifdef _GPIO1 EXT GPIO TypeDef GPIO1 en
60. or disable the programmable clock Behavior Description division of the CLOCK7 input clock signal by 2 It sets or clears the Div2 flag in the CLK_FLAG register NewSiate specifies whether the programmable divider can divide the CLOCK input clock signal by two or not niput Parameter ENABLE enables the clock division by two of of CLK signal DISABLE disables the clock division by two of of CLK signal Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enable the clock division by two RCCU_Div2Config ENABLE Sets the Div2 flag in the CLK_FLAG register RCCU_Div2Status Function Name RCCU_Div2Status Function Prototype FlagStatus RCCU_Div2Status void This routine gets the current status of the programmable clock division Penaviot Description by two It checks the status of the Div2 flag in the CLK_FLAG register Input Parameter None Output Parameter None The Div2 Flag status Return Value SET The division by 2 is enabled RESET The division by 2 is disabled Required preconditions None Called Functions None Example This example illustrates how to enable the programmable clock divider if it is not enabled FlagStatus Current Div2Flag if Current _Div2Flag RESET RCCU_Div2Config ENABLE PPE Ne weiss B ETEN EEEE EN User COGS ise oso t6 53 35 a facie i a
61. registers as follows define TIMx x 0 3 TIM values Table 46 enumerates the different values of the TIMx Table 46 TIMx values TIM Value Description TIMO Timer 0 TIM1 Timer 1 TIM2 Timer 2 TIM3 Timer 3 TIM flags enumeration The following enumeration defines the different TIM flags The TIM_Flags enumeration is defined in the file 71x_tim h typedef enum TIM ICFA 0x8000 TIM OCFA 0x4000 TIM TOF 0x2000 TIM ICFB 0x1000 TIM OCFB 0x0800 TIM Flags Table 47 describes the states of T M flags Table 47 TIM flags TIM Flags Description TIM_ICFA TIM Input Capture channel A flag TIM_OCFA TIM Output Compare channel A flag TIM_TOF TIM Timer Overflow flag TIM_ICFB TIM Input Capture channel B flag TIM_OCFB TIM Output Compare channel B flag ky 103 229 Peripheral firmware overview UM0097 Clock sources enumeration The following enumeration defines the different TIM clock sources The T M_Clocks enumeration is defined in the file 77x_tim h typedef enum TIM EXTERNAL TIM INTERNAL TIM Clocks Table 48 enumerates the clock sources Table 48 TIM clock sources Clock Source Description TIM_EXTERNAL The TIM peripheral is clocked by the external clock The TIM peripheral is clocked by APB clock TIM_INTERNAL Clock edges enumeration The following enumeration defines the different TIM clock edges The TIM_Clock_Edges enumerat
62. string or Carriage return characters from the selected UART Input Parameter UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter2 Data a pointer on the buffer where the data will be stored Output Parameter The received string Return Value The UARTX_SR register contents before reading the received data Required preconditions The selected UART must be properly configured and enabled Called Functions None See also UART_Config on page 149 UART_OnOffConfig on page 154 Example This example illustrates how to get a string from the UARTO u8 bRxData 10 ul6 wUART Status Read the received data UART _ StringReceive UARTO amp bRxData Check if data received without error if wUART Status amp UART ParityError UART_FrameError UART_OverrunError UART_TimeOutIdle handles error 163 229 Peripheral firmware overview UM0097 164 229 UART_FlagStatus Function Name UART _FlagStatus Function Prototype ul6 UART_FlagStatus UART_TypeDef UARTx This routine returns the UARTx_SR register content of the selected UART UARTXx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Behavior Description Inpu
63. the UARTO baud rate to 9600 bps UART_BaudRateConfig UARTO 9600 147 229 Peripheral firmware overview UM0097 UART_ParityConfig Function Name Function Prototype UART_ParityConfig void UART _ ParityConfig UART_TypeDef UARTx UARTParity TypeDef Parity Behavior Description This function configures the data parity of the selected UART Input Parameter 1 UARTXx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 Parity the parity type Refer to UART parity modes on page 143 for details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the UARTO parity mode to Odd parity Configure the UARTO parity mode to odd parity UART_ParityConfig UARTO UART_ODD PARITY UART_StopBitsConfig Function Name Function Prototype UART_StopBitsConfig void UART_StopBitsConfig UART_ TypeDef UARTx UARTStopBits TypeDef StopBits Behavior Description This routine configures the number of stop bits of the selected UART Input Parameter 1 Input Parameter 2 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter
64. tte 78 RTC structure fields 0 0 tte 84 PTC TAGS iis fects tats aai acne edt don aad cm athe dette ASE ea Gl a ates Bae aah 86 RTO interrupts sictccenatdila ih maa as aed vata geared a aaa Gaudaed Beds 86 RTC library functions 0 0 0 tte 86 WDG structure fields 0 0 0 tte eee 95 WDG library functions 0 0 0 0 000 6 96 TIM structure fieldS 0 0 00 0c eee 101 TIMX VAGOS aeurt Meee eedan hae eed ate ba EEP ewe be Week Va Ge ee 103 TIM TlaQS sos Sante eee Shand oy ede Pw dee eee bee ace rea ees Sate ae 103 TIM clock SOUrCES onere eee 104 UM0097 List of tables Table 49 Table 50 Table 51 Table 52 Table 53 Table 54 Table 55 Table 56 Table 57 Table 58 Table 59 Table 60 Table 61 Table 62 Table 63 Table 64 Table 65 Table 66 Table 67 Table 68 Table 69 Table 70 Table 71 Table 72 Table 73 Table 74 Table 75 Table 76 Table 77 Table 78 Table 79 Table 80 Table 81 Table 82 Table 83 Table 84 Table 85 Table 86 Table 87 Table 88 Table 89 Table 90 Table 91 Table 92 Table 93 Table 94 Table 95 Table 96 Table 97 TIM lock eds ce ca eee ee ewe he LG Ga dee Ree eed ge bbe a eee eee 104 TIM ChANNGIS face 64 ioe cette See die Sak eee Bee eee Bee Re ae ee ee EAE 104 Output compare modes 0 6 0 ce eee 105 Logic levels s ererek ba det ned Ee eed keene eee a HES Ea ee eee 105 Counter operations 2 2 0 2 nauau 106 PWM input p
65. ul6 wiInterruptLine Read the line number that generates the interrupt winterruptLine 82 229 XTI_InterruptLineValue UM0097 Peripheral firmware overview XTI_PendingBitClear Function Name XTI_PendingBitClear Function Prototype void XTI_PendingBitClear ul6 Lines Behavior Description This routine is used to clear the XTI interrupt pending bits Lines specifies the input wake up lines interrupt the input wake up lines interrupt You can select more than one line by logically OR ing them Refer to Section 3 6 2 Common parameter values on page 77 for details on the allowed values of Lines parameter Input Parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to clear the pending bits in the XTI void XTI_IRQHandler void Read the line number that caused the interrupt then clear the pending bit XTI_PendingBitClear XTI_InterruptLineValue XTI_SWIRQGenerate Function Name XTI_SWIRQGenerate Function Prototype void XTI_SWIRQGenerate void Behavior Description This routine is used to generate a software IRQ interrupt Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example generates an IRQ interrupt in the XTI channel int main void Enable interr
66. values of this parameter Direction specifies the communication direction Input Parameter 4 Refer to 2C transfer direction on page 167 for more details on the allowed values of this parameter Output Parameter None Return Value None Required Preconditions None Called Functions 12C_STARTGenerate Example This example illustrates how to send the address to slave in case of transmission direction and 7 bit addressing mode I2C AddressSend I2C0 0x43 I2C Mode7 I2C TX lt 179 229 Peripheral firmware overview UM0097 I2C_ByteSend Function Name Function Prototype 12C_ByteSend void I2C ByteSend I12C TypeDef I2Cx u8 Data Behavior Description Transmits a single byte Input Parameter 1 12Cx specifies the 12C which will send the single byte where x can be Oor 1 Input Parameter 2 Data the byte to be transmitted Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to use the 2C_ByteSend function to send a byte I2C _ByteSend I2C0 0x5D I2C_TransmissionStatus Function Name Function Prototype 12C_TransmissionStatus I2C_ Tx Status I2C_TransmissionStatus I2C TypeDef I2Cx Behavior Description Reports the current transmission status Input Parameter 12Cx specifies the 12C whose transmission st
67. x can be Oor 1 Input Parameter 2 TritSrc specifies the transmit interrupt source Refer to Transmit interrupt sources on page 123 for more details on the allowed values of this parameter Output Parameter None Return Value None Required Preconditions BSPI system must be enabled Called Functions None Example This example illustrates how to configure the transmit interrupt source in the BSPIO peripheral Enable BSPIO peripheral BSPI_ Enable BSPIO ENABLE Enable BSPIO to generate an interrupt when a transmit underflow occurs BSPI TritSrc BSPI0O BSPI TR _UFL UM0097 Peripheral firmware overview BSPIL ReltSrc Function Name Function Prototype BSPI_ReltSrce void BSPI_RcItSre BSPI_TypeDef BSPIx RC_IT_SRCS RcItSrc Behavior Description Configures the receive interrupt source Input Parameter 1 BSPkx selects the BSPI peripheral to be configured where x can be Oor 1 Input Parameter 2 ReltSrc specifies the source for the receive interrupt Refer to Receive interrupt sources on page 124 for more details on the allowed values of this parameter Output Parameter None Return Value None Required Preconditions BSPI system must be enabled Called Functions None Example This example illustrates how to configure the receive interrupt source in the BSP O p
68. 1 11 TSEG2 4 SJW 4 BRP 5 CAN_EnterInitMode CAN _CR_ CCE CAN SetTiming 11 4 4 5 CAN LeaveInitMode CAN_SleepRequest Function Name CAN_SleepRequest Function Prototype void CAN SleepRequest u32 WakeupMode Behavior Description Requests the CAN cell to enter sleep mode WakeupMode using one of the values defined in Wake up modes on Input Parameter page 191 Output Parameter None Return Value None Required preconditions None XTI_Init on page 79 XTI_LineModeConfig on page 81 XTI_LineConfig on page 82 Called Functions XTI_ModeConfig on page 80 XTI_InterruptLine Value on page 82 XTI_PendingBitClear on page 83 PCU_STOP on page 27 Example This example illustrates how to activate the CAN cell sleep mode CAN SleepRequest CAN WAKEUP_ON_ CAN Note that the XTI interrupt handler is called as soon as the wake up condition is reached 197 229 Peripheral firmware overview UM0097 CAN_SetUnusedMsgObj Function Name Function Prototype CAN_SetUnusedMsgObj u32 CAN SetUnusedMsgObj u32 msgobj Behavior Description Configures the message object as unused The hardware will not process it until it is setup as RX or TX Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value 1 if interface is found O if no interface is available Required preconditions No
69. 20 define CAN SR_EWARN 0x0040 define CAN SR_BOFF 0x0080 Table 82 describes the CAN status register bits Table 82 CAN status register bits Bit mnemonic Description CAN_SR_LEC Last Error Code mask CAN_SR_TXOK Transmission successful CAN_SR_RXOK Reception successful CAN_SR_EPASS Error Passive State CAN_SR_EWARN Warning State CAN_SR_BOFF Busoff State CAN test register bits The following defines list the bit fields accessible in the CAN test register They are declared in the file can h define CAN TESTR_RX 0x0080 define CAN TESTR_TX1 0x0040 define CAN TESTR_TX0O 0x0020 define CAN TESTR_LBACK 0x0010 define CAN TESTR_ SILENT 0x0008 define CAN TESTR BASIC 0x0004 lt UM0097 Peripheral firmware overview Table 83 describes the CAN test register bits Table 83 CAN test register bits Bit mnemonic Description CAN_TESTR_RX CAN RX pin monitoring CAN_TESTR_TX1 CAN_TESTR_TX0O CAN TX pin monitoring Loopback mode In this mode the CAN core has an internal loopback of TX to RX and CAN_TESTR_LBACK T the CAN RX pin is logically disconnected from the bus However the CAN TX pin is still connected to the bus Silent mode In this mode the CAN core has an internal loopback of TX to RX and CAN_TESTR_SILENT i T the CAN TX pin is logically disconnected from the bus and stuck to a recessive state However the CAN RX pin is still connected to the
70. 3 for input Parameters details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None UART_ModeConfig on page 147 UART_BaudRateConftig on page 147 UART_ParityConfig on page 148 UART_StopBitsConfig on page 148 Called Functions Example This example illustrates how to configure the UARTO Configure the UARTO as following Baudrate 9600 Bps No parity 8 data bits 1 stop bit UART Config UARTO 9600 UART_NO PARITY UART_1 StopBits UARTM_ 8D 149 229 Peripheral firmware overview UM0097 Note 150 229 UART_ItConfig Function Name Function Prototype UART_ItConfig void UART_ItConfig UART_TypeDef UARTx ul6 UART_ Flag FunctionalState NewState Behavior Description This function enables or disables one or several interrupt sources of the selected UART Input Parameter 1 UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 UART_Flag selects one or several UART interrupt sources Refer to Interrupt and status flags on page 144 for details on the allowed values of this parameter Input Parameter 3 NewSiatus specifies whether the interrupt source is enabled or disabled ENABLE enables the IRQ interrupt DISABLE disables the IRQ interrupt
71. 48 edeshegeee anes 84 3 7 1 Data Structures 224 66th ee eee ey dor doe ee a 84 3 7 2 Firmware library functions 0 0 0 cee ee 86 3 8 Watchdog timer WDG lt 20cc4scbees be eeeeewee eee ne biwew at 94 3 8 1 Data SUCIOS sorri retak Sr ERRANEN bw ded eeed sae dea eeeu es 94 3 8 2 Firmware library functions 0 0 0 0 cece eee 96 39 Tier MiM sccacses disene Seeeeteekas elses bee Beka caw RGAE 101 3 9 1 Data structures 0 0 ee eee 101 3 9 2 Firmware library functions 0 00 0 eee 107 3 10 Buffered serial peripheral interface BSPI 2 0 120 3 10 1 Datastructures 0 0 cee 121 3 10 2 Firmware library functions 0 eee ee 124 3 11 Universal asynchronous receiver transmitter UART 140 3 11 1 Data structures n cc2s eee eke riante E eat ede vee ted wer yes 140 3 11 2 Firmware library functions 0 eee 145 3 12 Inter integrated circuit I2C 0 ee ee 165 3 12 1 Datastructures 0 eee 165 3 12 2 Firmware library functions 0 0 eee 170 3 13 Controller area network CAN 0 0000 e eee eee 184 3 13 1 Datastructures 0 ee eee 184 3 13 2 Firmware library functions 0 0 eee eee 192 3 14 12 bit analog to digital converter ADC12 000085 213 3 14 1 Data structures 0 eee 213 3 14 2 Firmware library functions 00 e eee eee 216 3 15 Ext
72. 9 FLASH_EraseModule renamed to FLASH_ModuleErase in Section 5 16 2 8 New Function RCCU_ResetSources added in RCCU_ResetSource on page 45 31 Mar 05 2 0 Package Description Section 2 1 on page 11 How to use the STR71x Library Section 2 3 on page 14 STR71xDL7 renamed to 71xLibraryD Section 3 3 1 on page 18 STR71xnDL renamed to 71xLibraryR lib Section 3 3 1 on page 18 newDL prj amp newnDL prj renamed to debug prj amp release prj Section 3 3 1 on page 18 New Enumerations PLL1 Multiplication factors and PLL2 Multiplication factors Section 3 2 on page 29 RCCU_PLL1Config amp ROCCU_PLL2Config prototype modified Section 3 2 on page 29 RTC_SetTime amp RTC_SetAlarmTime functions deleted see AN 1780 Section 3 7 on page 84 FLASH_BlockWrite deleted Section 3 16 on page 241 FLASH_BlockRead deleted Section 3 16 on page 241 TIM_CounterConfig function behaviour description modified TIM_CounterConfig on page 118 TIM_CounterValue function added T M_CounterValue on page 118 ADC12_PrescalerConfig equation corrected ADC 12_PrescalerContig on page 218 x UM0097 Revision history Table 97 Document revision history continued Date 17 Sep 07 Revision Changes Changed document title to STR71x firmware library Added List of tables Removed Flash and USB sections Removed Section 4 16 1 Write Operation States Section 2 Environment overview removed Section 2 1 Package descri
73. A SE ws dart ach cae x 37 229 Peripheral firmware overview UM0097 RCCU_MCLKConfig Function Name Function Prototype RCCU_MCLKConfig void RCCU_MCLKConfig Clock Div New_Clock Behavior Description This routine is used to configure the MCLK clock divider New_Clock Specifies the MCLK clock divider value Refer to Clock divider parameters on page 30 for more details on the allowed values of this parameter Input Parameter Output Parameter None Return Value None Required preconditions None Called Functions None Note The MCLK frequency must be greater or equal to the frequency of APB1 and APB2 bridges Example This kal illustrates how to set the MCLK clock to RCLK 1 RCCU_MCLKConfig RCCU_ DEFAULT RCCU_PCLK1Config Function Name RCCU_PCLK1Config Function Prototype void RCCU_PCLK1Config Clock Div New_Clock This routine is used to select the division factor for RCLK to obtain the Behavior Description PCLK1 clock for the APB1 fast peripherals PCLK1 New_Clock Specifies the PCLK1 clock divider value Refer to Clock divider parameters on page 30 for more details on the allowed values of this parameter Input Parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to set the PCLK1 clock to RCLK 8 RCCU_PCLK1Config RCCU_RCLK 8
74. CAN_MsgObj_ TypeDef to implement the message interface registers defined as follows typedef volatile struct vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 vul6 R y K M 1 v N M H Teo ee eae e ee sPSEQEN wW s W zs H o a g m 5 HOW Ss a R APTY1 R APTY2 R APTY3 R APTY4 R PTY5 R PTY6 R PTY7 1R PTY8 2R PTY9 1R PTY10 2R MPTY11 27 CAN MsgObj_TypeDef Table 78 describes the CAN structure fields Table 78 CAN structure fields Register Description CR Control Register SR Status Register ERR Error Counter BTR Bit Timing Register IDR Interrupt Identifier Register TESTR Test Register BRPR BRP Extension Register TRIR Transmission Request 1 TR2R Transmission Request 2 ND1R New Data 1 ND2R New Data 2 IP1R Interrupt Pending 1 Register IP2R Interrupt Pending 2 Register lt 185 229 Peripheral firmware overview UM0097 Table 78 CAN structure fields continued Register Description MV1R Message Valid 1 Register MV2R Message Valid 2 Register Table 79 describes the CAN message interface structure fields Table 79 CAN message interface structure fields Register Description CRR
75. CCU peripheral register structure RCCU_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vu32 CCR u32 EMPTY1 vu32 CFR u32 EMPTY2 3 vu32 PLLICR vu32 PER vu32 SMR RCCU_TypeDef Ky 29 229 Peripheral firmware overview UM0097 30 229 Table 10 presents the RCCU registers Table 10 RCCU registers Register Description CCR Clock Control Register CFR Clock Flag Register PLL1iCR PLL1 configuration Register PER Peripheral Clock Enable Register SMR System Mode Register The RCCU peripheral is declared in the same file define RCCU BASE 0xA0000000 ifndef DEBUG ifdef RCCU define RCCU RCCU_TypeDef RCCU_BASE Hendif RCCU else DEBUG ifdef RCCU EXT RCCU_TypeDef RCCU endif RCCU endif When debug mode is used RCCU pointer is initialized in 77x_lib c file ifdef _RCCU ifdef _RCCU RCCU RCCU_TypeDef RCCU_BASE endif In debug mode the following macro is defined in 71x_conth file _RCCUis defined to access the corresponding peripheral registers define _RCCU Clock divider parameters The following enumeration defines the clock divider parameters Clock_Div enumeration is defined in the file 77x_rccu h typedef enum RCCU_DEFAULT 0x00 RCCU_RCLK 2 0x01 RCCU_RCLK 4 0x02 RCCU_RCLK 8 0x03 RCCU_Clock_Div lt UM0097 Peripheral firmware overview Table 11 lists the different values of
76. ECStatus Function Name Function Prototype Behavior Description WDG_ECStatus ul6 WDG ECStatus void Read the status register Input Parameter None Output Parameter None Return Value The end of count status Required preconditions None Called Functions Example None This example illustrates how to get the end of count status ul hStatus hStatus WDG_ECStatus UM0097 Peripheral firmware overview 3 9 Timer TIM The TIM driver may be used for a variety of purposes including timing operations external wave generation and measurement The first section describes the data structures used in the TIM firmware library The second section presents the T M firmware library functions 3 9 1 Data structures TIM register structure The TIM register structure T M_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vul6 ICAR ul6 EMPTY1 vul6 ICBR ul6 EMPTY2 vul6 OCAR vul6 OCBR vul6 CNTR vul6 CR1 vul6 CR2 ul6 EMPTY7 vul6 SR ul6 EMPTY8 TIM_TypeDef ul6 EMPTY3 ul6 EMPTY4 ul6 EMPTY5 ul6 EMPTY6 Table 45 describes the TIM structure fields Table 45 TIM structure fields Register Description ICAR Input capture A register ICBR Input capture B register OCAR Output Compare A register OCBR Output Compare B reg
77. FC interrupt feature Output Parameter None Return Value None Required Preconditions P Cx peripheral should be enabled Called Functions None Example This example illustrates how to enable the interrupt feature in the 2CO peripheral I2C OnoffConfig I2C0 ENABLE I2C ITConfig I2C0 ENABLE I2C_RegisterRead Function Name Function Prototype 12C_RegisterRead u8 I2C RegisterRead I2C_ TypeDef I2Cx I2C Registers reg Behavior Description Input Parameter 1 Reads any 12C register and returns its value 12Cx specifies the 12C to read its register where x can be 0 or 1 Input Parameter 2 Output Parameter reg specifies the register to read For more details on the allowed values of this parameter refer to 2C registers on page 166 None Return Value The value of the register passed as parameter Required Preconditions None Called Functions None Example This example illustrates how to get a register value vu8 Register Value Register Value I2C_RegisterRead I2C0 I2C_ CCR 175 229 Peripheral firmware overview UM0097 I2C_FlagStatus Function Name Function Prototype I2C_FlagStatus FlagStatus I2C FlagStatus I2C TypeDef I2Cx u32 Flag Behavior Description Checks whether the C flag is set or not Input Parameter 1 12Cx specifies the 12C to read its flags where x can be 0 or
78. FlagStatus RCCU_ Flags RCCU_ flag Behavior Description Checks whether the specified interrupt is enabled or disabled Input Parameter RCCU_flag the flag to see its status Refer to RCCU flags on page 34 for more details on the allowed values of this parameter Output Parameter None Return Value The specified interrupt status SET The specified flag is set RESET The specified flag is reset Required preconditions None Called Functions None Example This example illustrates how to check if the PLL7 is locked while RCCU_FlagStatus RCCU_PLL1 LOCK_IT RESET RCCU_FlagClear Function Name Function Prototype RCCU_FlagClear void RCCU_FlagClear RCCU_Flags RCCU_flag Behavior Description This routine is used to clear the specified interrupt flag in the RCCU registers passed in parameter Input Parameter RCCU_flag Specifies the flag to clear Refer to RCCU flags on page 34 for more details on the allowed values of this parameter Example Output Parameter None Return Value None Required preconditions None Called Functions None This example illustrates how to clear PLL1 lock pending interrupt flag RCCU_FlagClear RCCU_PLL1_LOCK_ I lt UM0097 Peripheral firmware overview RCCU_ResetSource Function Name Function Prototype RCCU_ResetSource RCCU_ResetSources RCCU_ ResetSourc
79. Function Prototype BSPI_Init void BSPI Init BSPI TypeDef BSPIx Behavior Description Initializes the BSPI peripheral control and registers to their default reset values Input Parameter BSPIx selects the BSPI peripheral to be initialized where x can be oori Output Parameters None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to initialize the BSPIO BSPI_Init BSPIO BSPI_Enable Function Name Function Prototype BSPI_Enable void BSPI Enable BSPI_TypeDef BSPIx FunctionalState NewState Behavior Description Enables disables the specified BSPI peripheral Input Parameter 1 Input Parameter 2 BSPIx selects the BSPI peripheral to be enabled or disabled where x can be 0 or 1 NewState specifies the status of the BSP ENABLE the specified BSP peripheral will be enabled DISABLE the specified BSP peripheral will be disabled Output Parameter Return Value Required Preconditions None None I O ports should be configured in their reset states and clock divider must be configured Called Functions None Example This example illustrates how to enable and disable the BSPIO interface Configures BSPI clock divider BSPI_ ClockDividerConfig BSPIO 8 126 229 UM0097 Peripheral firmware overview Enable BSPIO periph
80. I SIZE 16 0x0001 Table 95 describes the EMI modes Table 95 EMI modes Pin mode Description EMI_SIZE_8 Configures the EMI to work in 8 bit data bus EMI_SIZE_16 Configures the EMI to work in 16 bit data bus EMI enable The following definition is used to enable the EMI define EMI ENABLE 0x8000 EMI number of wait states The following definitions are used to configure the number of the EMI wait states define EMI 0 WaitState 0x00 define EMI_1 WaitState 0x01 define EMI_2_WaitStates 0x02 define EMI 3 WaitStates 0x03 define EMI 4 WaitStates 0x04 define EMI 5 WaitStates 0x05 define EMI 6 WaitStates 0x06 define EMI 7 WaitStates 0x07 define EMI 8 WaitStates 0x08 define EMI 9 WaitStates 0x09 define EMI 10 WaitStates Ox0A define EMI 11 WaitStates 0x0B define EMI_12 WaitStates Ox0C define EMI_13 WaitStates 0x0D define EMI_14 WaitStates Ox0E define EMI_15 WaitStates Ox0F lt 223 229 Peripheral firmware overview UM0097 3 15 2 Firmware library functions 224 229 Table 96 enumerates the different functions of the EMI library Table 96 EMI library functions Function Name Description EMI_Config Configures the EMI peripheral EMI_Enable Enables or disables the EMI peripheral EMI_Config Function Name Function Prototype EMI_Config void EMI Config u8 Bank_n ul6 B SIZE ul6 C_LENGTH Behavior Description This routine is used for each bank to c
81. IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2007 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 229 229
82. IOL 15 1 73 229 Peripheral firmware overview UM0097 GPIO_ByteWrite Function Name Function Prototype GPIO_ByteWrite void GPIO ByteWrite GPIO TypeDef GPIOx u8 Port _Byte u8 Port Val Behavior Description Write byte value to the selected GPIOx PD register Input Parameter 1 GPIOx selects the port x can be 0 1 or 2 Refer to GP Ox values on page 68 for details on the allowed values of this parameter Input Parameter 2 Port_Byte specifies which byte to be written It must be one of the following GPIO_MSB corresponds to the upper byte GPIO_LSB corresponds to the lower byte Input Parameter 3 Port_Val the value of the byte to be written Output Parameter None Return Value None Required preconditions Called Functions The port pin must be configured as OUT_OD or as OUT_PP None See also GPIO_BitWrite on page 73 GPIO_WordWrite on page 75 Note 1 When a port byte value is changed the other port byte value stay unchanged 2 The Input Pull Up Pull Down Configuration may change according to the related input pin value Example This example shows how to set all the GP OO 0 7 port pins and clear all the GP IO1 8 15 port pins the GP OO 8 15 and GP O1 0 7 remain unchanged Set all the GPIOO 0 7 port pins GPIO ByteWrite GPIOO GPIO_ LSB OxFF Clear all the GPI1 8 15 port pins GPIO ByteWrite
83. Interrupt DISABLE Enable Interrupt mode XTI_ModeConfig XTI_Interrupt ENABLE lt UM0097 Peripheral firmware overview XTI_LineModeConfig Function Name Function Prototype XTI_LineModeConfig void XTI_LineModeConfig ul6 Lines XTITriggerEdge TypeDef TriggerEdge Behavior Description This routine is used to configure the trigger edge Input Parameter 1 Lines this parameter specifies the input wake up line You can select more than one line by logically OR ing them Refer to Section 3 6 2 Common parameter values on page 77 for details on the allowed values of Lines parameter Input Parameter 2 TriggerEdge specifies the trigger edge polarity of the specified wake up lines Refer to Trigger edge polarity on page 77 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to set on the rising edge of the input wake up line 3 and set on the falling edge of the input wake up lines 1 and 2 Configure the line 3 edge XTI_LineModeConfig XTI_Line3 XTI_RisingEdge Configure the lines 2 and 1 edge XTI_LineModeConfig XTI_Line2 XTI_Linel XTI_FallingEdge 81 229 Peripheral firmware overview UM0097 XTI_LineConfig Function Name Function Prototype XTI_LineConfig void XTI_L
84. Loop back Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to loop back in the UARTO Enable loop back on the UART 0 UART_LoopBackConfig UARTO ENABLE 152 229 UM0097 Peripheral firmware overview UART_TimeOutPeriodConfig Function Name UART_TimeOutPeriodConfig void UART_TimeOutPeriodConfig UART_TypeDef UARTx Function Prototype ul6 TimeOutPeriod Behavior Description This routine configures the time out period of the selected UART UARTXx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 1 Input Parameter 2 TimeOutPeriod the time out period value Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the UARTO time out period Configure the UARTO time out period UART_TimeOut PeriodConfig UARTO OxFF UART_GuardTimeConfig Function Name UART_GuardTimeConfig void UART GuardTimeConfig UART_ TypeDef UARTx Function Prototype aie GuardTinej Behavior Description This routine configures the guard time of the selected UART UARTx Selects the UART to be configured x can be 0 1 2 or 3 Input Parameter 1 Refer to UARTx values on
85. M0097 Peripheral firmware overview Table 65 describes the UART Stop Bits Table 65 UART stop bits Stop Bits Description UART_0_5_StopBits 0 5 stop bits UART_1_StopBits 1 stop bit UART_1_5_StopBits 1 5 stop bits UART_2_StopBits 2 stop bits UART parity modes The following enumeration defines the UART parity modes The UARTParity_TypeDef enumeration is declared in the 71x_uart h file typedef enum UART_EVEN PARITY 0x0000 UART_ODD PARITY 0x0020 UART_NO PARITY 0x0000 UARTParity_TypeDef Table 66 describes the UART parity modes Table 66 UART parity modes Parity Mode Description UART_NO_PARITY No parity mode UART_ODD_PARITY Odd parity mode UART_EVEN_PARITY Even parity mode UART modes The following enumeration defines the UART modes WFI_CLOCKS enumeration is declared in the 77x_uart h file typedef enum UARTM 8D 0x0001 UARTM_7D P 0x0003 UARTM 9D 0x0004 UARTM 8D W 0x0005 UARTM 8D P 0x0007 UARTMode_TypeDef 143 229 Peripheral firmware overview UM0097 Table 67 lists the different UART modes Table 67 UART modes UART Modes Description UARTM_8D 8 bit data without parity mode UARTM_7D_P 7 bit data mode with parity UARTM_9D 9 bit data mode without parity UARTM_8D_W 8 bit data mode with wake up bit UARTM_8D_P 8 bit data mode with parity Interrupt and status flags The following def
86. None Note 1 When you change a port pin mode the other port pins modes stay unchanged 2 You can configure more than one pin of the same GPIO peripheral It is not possible to configure pins of more than one GPIO peripheral at the same call of GPIO_Config function Moreover it is not possible to configure more than one pin of the same GPIO peripheral in more than one mode by calling once the GPIO_Config function lt 69 229 Peripheral firmware overview UM0097 Example This example illustrates how to configure GPIOO GPIO1 and GP O2 port pins define GPIO PIN4 0x04 define GPIO PINS 0x05 Configure the GPIOO pin 0 as Open Drain Output GPIO Config GPIOO 0x0001 GPIO OUT OD Configure the GPIOO pins 4 and 5 as a Push Pull Output GPIO Config GPIOO 0x0001 lt lt GPIO PIN4 0x0001 lt lt GPIO PINS GPIO_OUT_PP Configure the GPIOO pin 15 as standard TTL input GPIO Config GPIOO 0x8000 GPIO IN TRI TTL Configure the GPIO1 pins 0 1 2 and 3 as High impedance Analog Input GPIO Config GPIO1 Ox000F GPIO HI AIN TRI Configure all the GPIO2 pins as Push Pull Output GPIO Config GPIO2 OxFFFF GPIO OUT PP GPIO_BitRead Function Name GPIO_BitRead Function Prototype u8 GPIO BitRead GPIO TypeDef GPIOx u8 Port Pin Behavior Description Reads the specified data port bit and returns its value GPIOx selects the port to be read x can be 0 1 or 2 Input P
87. None Return Value None Required preconditions The CAN must be in initialization mode PCLK1 must be at 8 MHz otherwise refer to CAN_SetTiming on page 196 Called Functions None Example This example illustrates how to set a standard bitrate for the CAN Enable the configuration change bit to set the bitrate CAN_EnterInitMode CAN CR CCE CAN SetBitrate CAN BITRATE 100K CAN LeaveInitMode CAN_SetTiming Function Name Function Prototype CAN_SetTiming void CAN SetTiming u32 tsegl u32 tseg2 u32 sjw int brp Behavior Description Sets up the CAN timing with specific parameters Input Parameter 1 Input Parameter 2 tseg1 Time Segment before the sample point position It can take values from 1 to 16 tseg2 Time Segment after the sample point position It can take values from 1 to 8 Input Parameter 3 sjw Synchronisation Jump Width It can take values from 1 to 4 Input Parameter 4 brp Baud Rate Prescaler It can take values from 1 to 1024 Output Parameter None Return Value None Required preconditions The CAN must be in initialization mode Called Functions None lt UM0097 Peripheral firmware overview Example This example illustrates how to set specific timing parameters for the CAN Enable the configuration change bit to set the specific timing parameters TSEG
88. PIx u8 PtrToBuffer u8 NbOfWords Behavior Description Transmits 8 bit data format from a buffer Input Parameter 1 BSPIx selects BSPI peripheral to be used where x can be 0 or 1 Input Parameter 2 PtrToBuffer is an u8 pointer to the first byte of the buffer to be transmitted Input Parameter 3 NbOfWords the number of bytes saved in the buffer to be sent Output Parameter None Return Value None Required Preconditions None Called Functions BSPI_WordSend Example This example illustrates how to send a buffer vu8 pBuffer Hello Transmit 5 bytes data BSPI_ ByteBufferSend BSPIO pBuffer 5 UM0097 Peripheral firmware overview BSPI_WordBufferSend Function Name Function Prototype BSPI_WordBufferSend void BSPI_WordBufferSend BSPI_TypeDef BSPIx ul6 PtrToBuffer u8 NbOfWords Description Transmits 16 bits data format from a buffer Input Parameter 1 BSPIx selects BSPI peripheral to be used where x can be 0 or 1 Input Parameter 2 PtrToBuffer is an u16 pointer to the first word of the buffer to be transmitted Input Parameter 3 NbOfWords indicates the number of words saved in the buffer to be sent Output Parameter None Return Value None Required Preconditions None Called Functions BSPI_WordSend Example This example illustrat
89. Refer to CAN message identifier limits on page 192 for more details on the allowed values of this parameter Input Parameter 5 singleOrFifoLast End of buffer indicator it can take the following values TRUE for a single receive object or a FIFO receive object that is the last one of the FIFO FALSE for a FIFO receive object that is not the last one Output Parameter Return Value None 1 if interface is found O if no interface is available Required preconditions None Called Functions None Example This example describes how to configure a receive message object Define a receive FIFO of depth 2 objects 0 and 1 for standard identifiers in which IDs are filtered in the range 0x400 0Ox5FF CAN SetRxMsgObj 0 CAN STD ID 0x400 Ox5FF FALSE CAN SetRxMsgObj 1 CAN STD ID 0x400 Ox5FF TRUE Define a single receive object for extended identifiers in which all IDs are filtered in CAN SetRxMsgObj 2 CAN EXT_ID 0 CAN LAST EXT ID TRUE UM0097 Peripheral firmware overview Note Care must be taken when defining an ID range all combinations of idLow and idHigh will not always produce the expected result because of the way identifiers are filtered by the hardware The criteria applied to keep a received frame is as follows received ID AND ID mask ID arbitration where AND is a bitwise operator Consequently it is generally
90. This routine is used to initialize the selected UART UART_ModeContig This routine configures the UART mode UART_BaudRateConfig This routine configures the baud rate of the selected UART UART_ParityConftig This routine configures the UART parity mode UART_StopBitsConftig This routine configures the number of stop bits of the selected UART This routine configures the Baud rate parity mode the number of sl la stop bits and the UART mode of the selected UART UART_ItConfig This routine enables disables the interrupts sources of the selected UART UART_FifoContig This routine enables disables the FIFOs of the selected UART UART_FifoReset This routine resets the selected FIFO of the selected UART UART_LoopBackConfig This routine enables disables loop back in the selected UART UART_TimeOutPeriodContig This routine configures the time out Period of the selected UART UART_GuardTimeConfig This routine configures the guard time of the selected UART UART_RxConftig This routine enables disables reception on the selected UART UART_OnOffContig This turns the selected UART On Off UART_ByteSend This routine sends a 7 bit byte or an 8 bit byte UART_9BitByteSend This routine sends a 9 bit byte UART_DataSend This routine sends several 7 bit bytes or 8 bit bytes UART_9BitDataSend This routine sends several 9 bit bytes UART_StringSend This routine sends a 7 bit or 8 bit string UART_ByteReceive This rou
91. Timer 0 global interrupt 1 WDG_FIQChannel Watchdog timer interrupt 2 Both timer 0 global interrupt and watchdog WDGTOTIMI_FlQChannel interrupt The two FIQs take place at the 3 same time Firmware library functions The table below enumerates the different functions of the EIC library Function Name EIC_Init Function Description Initializes the Enhanced Interrupt Controller EIC_IRQConfig Enables or Disables IRQ interrupts in the EIC EIC_FIQConfig Enables or Disables FIQ interrupts in the EIC EIC_IRQChannelConfig EIC_FlIQChannelConfig Enables or Disables the selected IRQ channel interrupts Enables or Disables the selected FIQ channel interrupts EIC_IRQChannelIPriorityContig Sets the IRQ channel priority level EIC_CurrentPriorityLevelValue Returns the current priority level EIC_CurrentPriorityLevelContig Changes the current priority level EIC_CurrentlIRQChannelValue Returns the current served IRQ channel number EIC_CurrentFlQChannelValue EIC_FlQPendingBitClear Returns the FIQ channel number causing the FIQ interrupt Clears FIQ Pending bit according to the input passed parameter UM0097 Peripheral firmware overview EIC_Init Function Name EIC_Init Function Prototype void EIC Init void Initializes the Interrupt Controller as following FIQ and IRQ are disabled All channel inter
92. _ByteSend UARTO amp Data 155 229 Peripheral firmware overview UM0097 156 229 UART_9BitByteSend Function Name UART_9BitByteSend void UART_9BitByteSend UART_TypeDef UARTx Function Prototype ul6 Data Behavior Description This function sends a 9 bit data using the selected UART UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 1 Input Parameter 2 Data a pointer on the 9 bit data to send Output Parameter None Return Value None Required preconditions The selected UART must be properly configured and enabled Called Functions None UART_Confi 149 See also obi oe UART_OnOffConfig on page 154 Example This example illustrates how to send a 9 bit byte using the UARTO ul6 Data 0x0155 UART_9BitByteSend UARTO amp Data UART_DataSend Function Name UART_DataSend void UART_DataSend UART_TypeDef UARTx u8 Data Function Prototype us Datalength This routine sends several 7 bit bytes or 8 bit bytes using the selected UART UARTXx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Behavior Description Input Parameter 1 Input Parameter 2 Data The bytes start address Input Parameter 3 DataLength The data bytes number Out
93. _ClockConfig function call ky UM0097 Peripheral firmware overview Example This example enables clock gating for 2CO and UART1 peripherals on the APB7 bridge and disables the clock for GP O2 ADC 12 peripherals on the APB2 bridge Enables the clock signal to the I2C0 peripheral APB ClockConfig APB1 ENABLE I2C0O Periph Enables the clock signal to the UART1 peripheral APB ClockConfig APB1 ENABLE UART1_ Periph Disables the clock signal to the GPIO2 peripheral APB ClockConfig APB2 DISABLE GPIO2 Periph Disables the clock signal to the ADC12 peripheral APB ClockConfig APB2 DISABLE ADC12_ Periph The APB_ClockConfig parameter 3 can accept several peripherals using the logical operator OR Enables the clock signal to the I2CO amp UART1 peripherals APB _ClockConfig APB1 ENABLE I2C0_ Periph UART1_Periph Disables the clock signal to the GPIO2 amp ADC12 peripherals APB ClockConfig APB2 DISABLE GPIO2 Periph ADC12 Periph 51 229 Peripheral firmware overview UM0097 Note 3 4 52 229 1 APB_SwResetConfig Function Name APB_SwResetConfig void APB SwResetConfig APB TypeDef APBx Function Prototype f FunctionalState New_Status ul6 Periph This function enables disables the software reset for the specified Behavior Description peripheral on the specified APB Bridge It updates the bits 14 0
94. _conf h and 71x_it c files should be modified to link the application with the library How to use the STR71x library This section describes how to implement an application using the STR7 1x firmware library Example The application initializes and starts two timer overflow interrupts When a timer expires an interrupt handled in 71x_it c is generated Timer 0 generates an overflow interrupt every 130 ms and toggles the GP O0 pin level on off Timer 1 is configured to generate an interrupt every 2 1s and to set GP O7 pin to high level for 1 05 s The chip is clocked by an external oscillator at a frequency of 16 MHz Timer 0 interrupt priority is set to be higher than Timer 1 interrupt priority to allow the Timer 0 TOTIMI_IRQHandler interrupt routine to be served during the execution of the Timer 1 interrupt routine The following figure shows the behavior of the GP OO and GPIO1 pins and Timer 0 and Timer 1 interrupts Figure 3 TimerO and Timer1 interrupt handling TimerO interrupt GPIOO pin GPIO1 pin imer1 interrupt The following steps explain how to use the STR71x library to build the user application e Edit the 71x_conf h file and uncomment the _GP O and _ TIM labels this allows you to include the firmware libraries of the GP O and the T M peripherals in your firmware Uncomment the _GP O0 _GPIO1 _ TIMO and _ TIM1 labels to be able to access the periph
95. ace is found O if no interface is available Required preconditions It is assumed that message interface 0 is used to update a can message object Called Functions None Example This example illustrates how to update a message object already configured to transmit canmsg CanMsg CAN STD ID 0x111 4 0x10 0x20 0x40 0x80 ie Update CAN Message 0 CAN UpdateMsgObj 0 amp CanMsg CAN_TransmitRequest Function Name Prototype CAN_TransmitRequest u32 CAN TransmitRequest u32 msgobj Behavior Description Input Parameter Starts the transmission of a messsage object A data frame is transmitted if the message object is configured in transmission mode A remote frame is transmitted if the message object is configured in reception mode msgobj The message object number from 0 to 31 Output Parameter None Return Value 1 if interface is found O if no interface is available Required preconditions The message object must have been set up properly 204 229 UM0097 Peripheral firmware overview Example This example illustrates how to request the transmission of a data frame Message object 0 is already configured for transmission Request the transmission of a data frame CAN TransmitRequest 0 CAN_SendMessage Function Name CAN_SendMessage Function Prototype u32 CAN SendMessage u32 m
96. alled Functions None Example This example illustrates how to read the current RTC alarm value u32 wCurrent_Alarm_Time wCurrent Alarm Time RTC AlarmValue 89 229 Peripheral firmware overview UM0097 RTC_AlarmConfig Function Name RTC_AlarmConfig Function Prototype void RTC_AlarmConfig u32 Xalarm Behavior Description This routine sets the alarm time value It updates AH amp ALO register values Input Parameter Xalarm specifies the new RTC alarm time value Output Parameter None Return Value None Required preconditions None Called Functions RTC_WaitForLastTask RTC_EnterCfgMode and RTC_ExitCfgMode Example This example illustrates how to configure a new alarm time u32 wAlarm_Time wAlarm Time Ox00O7FFFFF RTC_AlarmConfig wAlarm_Time RTC_FlagStatus Function Name RTC_FlagStatus Function Prototype FlagStatus RTC_FlagStatus RTC_FLAGS Xflag Behavior Description This routine is used to check if the specified RTC flag is set or not Xflag Designates an RTC flag Refer to RTC flags on page 85 for more Input Parameter details on the allowed values of this parameter Output Parameter None The specified flag status Return Value SET The corresponding flag is SET RESET The corresponding flag is RESET Required preconditions None Called Functions None Example This example illustrates how to check the RTC S
97. ameter None The status of reception Refer to 2C reception status on page 170 for more details on the allowed values of this parameter START generation Send slave address Return Value Required Preconditions Called Functions None Example This example illustrates how to return the status of reception progress I2C_Rx Status ReceptionStatus ReceptionStatus I2C ReceptionStatus I2C0 181 229 Peripheral firmware overview UM0097 I2C_ErrorClear Function Name Function Prototype 12C_ErrorClear void I2C ErrorClear I12C_ TypeDef I2Cx Behavior Description Clears any error flag Input Parameter I2Cx specifies the I2C which error flags will be cleared where x can be 0 or 1 Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to clear all error flags I2C ErrorClear I2C0 I2C_ GetStatus Function Name Function Prototype 12C_GetStatus u32 I2C GetStatus I2C TypeDef 1I2Cx Behavior Description Reads the I2C status registers Input Parameter I2Cx specifies the 12C to get its status registers where x can be 0 or 1 Output Parameter None Return Value Required Preconditions Called Functions The I2C status registers value None None Example This example illustrates how to r
98. arameter 1 Refer to GP Ox values on page 68 for details on the allowed values of this parameter Port_Pin Specifies the pin to see the value Input Parameter 2 p Refer to Port pin values on page 68 for more details on this parameter Output Parameter None The selected port pin value Return Value It may be 0x00 if the port pin is reset or 0x01 if the port pin is set The port pin must be configured as GPIO_ N_TRI_TTL or as Required preconditions GPIO_IN_TRI_CMOS mode Called Functions None GPIO_ByteRead on page 71 GPIO_WordRead on page 72 See also lt 70 229 UM0097 Peripheral firmware overview Example In This example the values of GP OO port pin 0 GP O7 port pin 2 and GP O2 port pin 15 are read vu8 bValue Get the P0 0 bit value bValue GPIO BitRead GPIOO 0 Get the P1 2 bit value bValue GPIO BitRead GPIO1 2 Get the P2 15 bit value bValue GPIO BitRead GPIO2 15 GPIO_ByteRead Function Name Function Prototype GPIO_ByteRead u8 GPIO ByteRead GPIO TypeDef GPIOx u8 Port Byte Behavior Description Reads the specified data port byte and returns its value Input Parameter 1 Input Parameter 2 Output Parameter GPIOx selects the port to be configured x can be 0 1 or 2 Refer to GP Ox values on page 68 for details on the allowed values of this parameter Port_Byte specifies
99. arameters 0 0 0 ce eee 106 TIM interrupts ereitera ditame ee ee er a eh ee a ea 106 TIM library functions 00 tte 107 BSPI regiStefSi risame cap iatg ethan eres bo Rae Ee eee Hebets se 121 BOP I TAGS ia cac taint carat ite orn ecco gree rata gd a Gite AAE G aka ee ee 123 BSPI interrupts ssai date beded sh oeed Gedaghe eee VED A ered Ged a iia 123 BSPI transmit interrupt Sources 0 00 000 c ete 124 BSPI receive interrupt SourceS 2 2 0 0000 eet eee 124 BSPI library functions 0 0 0 0 00 ttt 124 UART structure fields 0 20 0 c cee ee aa 140 UART FIROS ir ccs na eta att eae Dacian ed Okeke aida dr Wee anes oe Se A 142 UART Stop DIIS erresta Sa ais ni le soe a ear aed gan eee eae a Site ade a wi 143 UART parity Modes n 0c eed ce oe ea eben ee Re sae Se ea ee Oe ee EE 143 UART MOdES civ ddd eee bead tratante E eee ee Rea Ge dee Gad ware 144 Interrupt and status flags 1 eee 144 UARIXValUCSicyc ca iva derana neha dea Pee ee PPP ead eed 145 UART library functions 0 0 0 0 tte ee 145 PU TCGISIElS scat dedaedbies oad e hd a KEAR years eee ea daw baie bebo 165 I2 C addressing MOdeS 1 2 0 cette 167 2C transfer direction 0 0 0 tte ae 167 PC NAGS ori ites Caches ob be ee wee Sake Lee ea ee a a ee eb ee 168 l2C transmission status messages 0 169 I2 C reception status MeSSAgeS 0 6 tee 170 I C library functions 0 0 0 0 teeta 170 CAN structure fields 20 0 0
100. atus Function Name PCU_MVRStatus Function Prototype PCU_VR_Status PCU_MVRStatus void ae i i i ilit Behavior Description This routine checks and returns the main voltage regulator stability status Input Parameter None Output Parameter None The stability status of the Main Voltage Regulator Refer to Voltage Return Value regulator status on page 19 for more details on the allowed values of this parameter Required preconditions None Called Functions None Example This example illustrates how to check the main voltage regulator status PCU_VR_Status MainVR_ Status MainVR_ Status PCU_MVRStatus PCU_FlagStatus Function Name PCU_FlagStatus Function Prototype FlagStatus PCU_FlagStatus PCU_Flags Xflag Behavior Description This routine is used to check the status of the specified PCU flag Xflag specifies the PCU flag Refer to PCU flags on page 20 for more Input Parameter details on the allowed values of this parameter Output Parameter None The specified flag status Return Value SET The PCU flag is set RESET The PCU flag is reset Required preconditions None Called Functions None Example This example illustrates how to check the PCU flag status FlagStatus WREN Status FlagStatus VROK Status WREN Status holds the WEN flag status WREN Status PCU_FlagStatus PCU_WREN 21 229 Peripheral firmwar
101. atus will be tested where x can be 0 or 1 Output Parameter Return Value None The transmission status Refer to 2C transmission status on page 169 for more details on the allowed values of this parameter Required Preconditions START generation Send slave address Called Functions None Example This example illustrates how to report the status of transmission progress of 2CO I2C_Tx Status TransmissionStatus TransmissionStatus I2C TransmissionStatus I2C0 180 229 UM0097 Peripheral firmware overview I2C_ByteReceive Function Name I2C_ByteReceive Function Prototype u8 I2C ByteReceive I2C_TypeDef 12Cx Behavior Description Returns the most recent received byte Input Parameter 12Cx specifies the I2C peripheral to get a received data where x can be 0 or 1 Output Parameter None Return Value The value of the received byte Required Preconditions None Called Functions None Example This example illustrates how to get the byte received u8 received byte received byte I2C_ByteReceive I2C0 I2C_ReceptionStatus Function Name I2C_ReceptionStatus I2C_Rx_ Status I2C ReceptionStatus I2C_TypeDef Function Prototype T2Cx Behavior Description Reports the reception status 2Cx where x can be 0 or 1 to select the C peripheral which input Parameter reception status will be tested Output Par
102. be started or stopped Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the WDG in order to start or stop the timer stop the counter WDG_ CntOnoffConfig DISABLE Start the counter WDG_CntOnoffConfig ENABLE WDG_ECITConfig Function Name WDG_ECITConfig Function Prototype void WDG_ECITConfig FunctionalState NewState Behavior Description Enable or Disable the WDG end of count interrupt NewSiate specifies whether the WDG end of count interrupt is enabled or disabled ENABLE enables the WDG IRQ interrupt DISABLE disables the WDG IRQ interrupt Input Parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enable the WDG end of count interrupt WDG_ECITConfig ENABLE 99 229 Peripheral firmware overview UM0097 WDG_ECFlagClear Function Name Function Prototype WDG_ECFlagClear void WDG ECFlagClear void Behavior Description This routine is used to clear the end of count flag Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how clear the end of count pending bit WDG_ECFlagClear WDG_
103. better to choose for idLow a value with some LSBs cleared and for idHigh a value that logically contains idLow and with the same LSBs set Example the range 0x100 0x3FF will work but the range 0x100 0x2FF will not because 0x100 is not logically contained in Ox2FF that is 0x100 and Ox2FF 0 CAN_SetUnusedAlIMsgObj Function Name CAN_SetUnusedAIlIMsgObj Function Prototype u32 CAN InvalidateAl1MsgObj void Behavior Description Configures all the message objects as unused Input Parameter None Output Parameter None Return Value 1 if all message objects are set to unused Otherwise 0 Required preconditions None Called Functions CAN_SetUnusedMsgObj on page 198 Example This example describes how to invalidate all the message objects CAN SetUnusedAl11MsgObj now some objects can be set up 201 229 Peripheral firmware overview UM0097 CAN_Init Function Name Function Prototype CAN_Init void CAN Init u8 mask u32 bitrate Behavior Description Initializes the CAN cell and set the bitrate Input Parameter 1 mask any binary value defined using the values described in CAN control register bits on page 187 Input Parameter 2 bitrate one of the CAN_BITRATE_xxx defines Refer to CAN standard bitrates on page 187 for more details on the allowed values of this parameter Output Parameter None Return Value None Req
104. case of multiple interrupt requests mapped 71x_it c on the same interrupt vector the function performs a polling on interrupt flags contained inside the peripheral in order to establish the exact source of the interrupt The names of these functions are already provided in the firmware library 71x_it h Header file including the definition of interrupt functions Debug mode initialization file It includes the definition of variable pointers pointing 71x lib c each one to the first address of the dedicated peripheral and the definition of one ae function called when you choose to enter in debug mode This function initializes the defined pointers Header file including all the peripherals header files It is the unique file to be included 71x_lib h ae j in the user application to interface with the library Hise nao This file implements memory mapping and physical registers address definition for MaP both development and debug modes This file is supplied with all peripherals Common declarations file It includes common types and constants which are used by 71x_type h all peripheral drivers 71x_ppp c_ Driver source code file of the PPP peripheral written in C language 71x h Header file of the PPP peripheral It includes the functions prototypes data structures PPP and enumerations used by the driver and also available for the user Figure 2 shows the firmware library architecture and file inclusion relatio
105. ceConfig void TIM ClockSourceConfig TIM_TypeDef TIMx TIM Clocks Xclock Behavior Description This routine configures the source clock of the T M peripheral Input Parameter 1 TIMx specifies the T M to be configured Refer to T M values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xclock specifies the TIM source clock Refer to Clock sources enumeration on page 104 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the TIMO timer to be clocked by an external source TIM ClockSourceConfig TIMO TIM EXTERNAL TIM_ClockSourceValue Function Name Function Prototype TIM_ClockSourceValue TIM Clocks TIM_ClockSourceValue TIM _TypeDef TIMx Behavior Description This routine gets the source clock of the TIM peripheral Input Parameter Output Parameter TIMx specifies the TIM to check its source clock Refer to T M values on page 103 for more details on the allowed values of this parameter None Return Value Required preconditions The TIM source clock Refer to Clock sources enumeration on page 104 for more details on the allowed values of this parameter None Called Functions None Example This example illustrates how to g
106. clock source on page 31 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None 40 229 lt UM0097 Peripheral firmware overview Example This example illustrates how to set the PLL7 multiplication factor to 20 and the divider factor to 4 then select PLL7 output as clock source of RCLK clock RCCU_PLL1Config RCCU_Mul_20 RCCU Div 4 Wait PLL to lock while RCCU_FlagStatus RCCU_PLL1 LOCK RESET RCCU_RCLKSourceConfig RCCU_PLL1 Output RCCU_RCLKClockSource Function Name RCCU_RCLKClockSource Function Prototype RCLK_ Clocks RCCU_RCLKClockSource void Behavior Description This routine gets and returns the current clock source of the RCLK Input Parameter None Output Parameter None The current RCLK clock source Return Value Refer to RCLK clock source on page 31 for more details on the allowed values of this parameter Required preconditions None Called Functions None Example This example illustrates how to get the RCLK clock source RCLK Clocks RCLK_CLOCK SOURCE RCLK CLOCK SOURCE RCCU_RCLKClockSource lt 41 229 Peripheral firmware overview UM0097 RCCU_USBCLKConfig Function Name Function Prototype RCCU_USBCLKConfig void RCCU_USBCLKConfig USB_Clocks New _Clock Behavior Description This routin
107. ction Name Function Prototype TIM_OPModeConfig void TIM OPModeConfig TIM TypeDef TIMx ul6 XpulseLength TIM Logic Levels XLevell TIM Logic Levels XLevel2 TIM Clock Edges Xedge Behavior Description This routine is used to configure the one pulse mode Input Parameter 1 TIMx specifies the TIM to be configured Refer to TIM values on page 103 for more details on the allowed values of this parameter Input Parameter 2 XpulseLength specifies the pulse length Input Parameter 3 XLevel1 specifies the output level on the OCMPA pin during the pulse Refer to Logic levels enumeration on page 105 for more details on the allowed values of this parameter Input Parameter 4 XLevel2 specifies the output level on the OCMPB pin after the pulse Refer to Logic levels enumeration on page 105 for more details on the allowed values of this parameter Input Parameter 5 Xedge specifies the edge to be detected by the input capture A pin Refer to Clock edges enumeration on page 104 for more details on the allowed values of this parameter TIM_RISING a rising edge will activate the one pulse mode TIM_FALLING a falling edge will activate the one pulse mode Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the 7 M3 one pulse mode to generate an external wave with a pulse leng
108. ction have a name that ends with a verb describing that action e g activate clear send write Functions clearing specific peripheral flags are called PPP_FlagClear C coding rules The following rules are used in the Firmware Library 12 generic types are defined for variables whose type and size are fixed and are typically used for register access These types are defined in the file 71x_type h typedef unsigned long u32 typedef unsigned short ul6 typedef unsigned char u8 typedef signed long s32 typedef signed short s16 typedef signed char s8 typedef volatile unsigned long vu32 typedef volatile unsigned short vul6 typedef volatile unsigned char vu8 7 229 Document and library rules UM0097 typedef volatile signed long VS32 typedef volatile signed short vs16 typedef volatile signed char vs8 bool type is defined in the file 77x_type h as typedef enum FALSE 0 TRUE FALSE bool e FlagStatus type is defined in the file 71x_type h Two values can be assigned to this variable SET or RESET typedef enum RESET 0 SET RESET FlagStatus e FunctionalState type is defined in the file 71x_type h Two values can be assigned to this variable ENABLE or DISABLE typedef enum DISABLE 0 ENABLE DISABLE FunctionalState e Pointers to peripherals are used to access the peripheral control registers Peripheral pointers point to data structures that represent the mapping
109. d The library contains a complete firmware in C and it is independent from any software tool chains Only the start up files are tool chain dependent Since the library is generic and covers all of the capabilities of each peripheral it may not be as efficient as it could be from a code size and or execution speed point of view For many applications the library may be used as is However for applications with strong constraints in terms of code size and or execution speed the library drivers should be used as a reference to show you how to configure the peripheral and which you can then tailor to your specific application requirements September 2007 Rev 3 1 229 www st com Contents UM0097 Contents 1 Document and library rules 2 0 0 cee 6 1 1 Abbreviati nS 2 4ccncneeeneeeeyeeweedn tkeneeawe yeaa ewereada 6 1 2 Styles and symbols ove eieee rene nwe eee ee ees dw eee te eee hee enw es 6 1 3 Naming conventions 201i c2 08scetencdaseeeetaeae 1S eeew dae ee on 7 1a ACOGINGWUIES cnx gt ee deteute teehotaeees heri e kenbe artek wee ex 7 2 Firmware library skcixdane oe eee enon eewee wi ewec ees 11 2 1 Package description 22 i cscs 4sbca bide dbbeeed FORE SS eee a deweds 11 2 1 1 EXAMPIES oroerirrerwir riria ddia E EAE E E 11 2 1 2 CDIA os croruarie detr aiidas EE A EEE 12 2 1 3 PIO GCE it wns eet AEREE ae ERE EA 12 2 2 File des riptiON 225k xeon eee eR See wees Kaas Res 12 2 3 How to use the STR71x library 0
110. d in the file 71x_tim h define TIM ICA IT 0x8000 define TIM OCA IT 0x4000 define TIM TO IT 0x2000 define TIM _ICB IT 0x1000 define TIM OCB IT 0x0800 Table 55 describes the TIM interrupts Table 55 TIM interrupts TIM Interrupts Description TIM_ICA_IT TIM Input Capture Channel A interrupt TIM_OCA_IT TIM Output Compare channel A interrupt TIM_TO_IT TIM Timer Overflow interrupt TIM_ICB_IT TIM Input Capture Channel A interrupt TIM_OCB_IT TIM Output Compare channel B interrupt lt UM0097 Peripheral firmware overview 3 9 2 Firmware library functions Table 56 enumerates the different functions of the T M library Table 56 TIM library functions Function Name TIM_Init Description Initializes the TIM peripheral TIM_ClockSourceConfig Configures the TIM clock source TIM_ClockSource Value Gets the T M clock source TIM_PrescalerConfig Configures the TIM prescaler Value TIM_PrescalerValue Gets the TIM prescaler Value TIM_ClockLevelConfig Configures the active clock level when the TIM is clocked by an external source TIM_ClockLevelValue Gets the active clock level when the TIM is clocked by an external source TIM_ICAPModeConfig Configures the Input capture mode TIM_ICAPValue Gets the Input capture values TIM_OCMPModeConfig Configures the Output compare mode TIM_OPModeConfig Configures the One pulse mode
111. d of OxFFF timer period and a duty cycle of 50 TIM PWMOModeConfig TIM3 Ox7FF TIM_HIGH OxFFF TIM LOW lt Peripheral firmware overview lt TIM_PWMIModeConfig Function Name Function Prototype TIM_PWMIModeConfig void TIM_PWMIModeConfig TIM_TypeDef TIMx TIM Clock Edges Xedge Behavior Description This routine is used to configure the PWM input mode Input Parameter 1 TIMx specifies the TIM to be initialized Refer to TIM values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xedge specifies the first edge of the external PWM signal Refer to Clock edges enumeration on page 104 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the T M3 to measure an external PWM signal TIM PWMIModeConfig TIM3 TIM RISING TIM_PWMIValue Function Name Function Prototype TIM_PWMIValue PWMI_ parameters TIM PWMIValue TIM TypeDef TIMx Behavior Description This routine is used to configure the PWM input mode Input Parameter TIMx specifies the TIM to be initialized Refer to TIM values on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value The PWM input parameters pulse and p
112. d on page 71 Example This example illustrates how to read the GPIOO port pin values ul6 wValue Get all PO pin value wValue GPIO WordRead GPIOO UM0097 Peripheral firmware overview GPIO_BitWrite Function Name GPIO_BitWrite f void GPIO BitWrite GPIO TypeDef GPIOx MungHon Mrototype u8 Port_Pin u8 Bit_val Behavior Description Sets or clears the selected data port bit Input Parameter i GPIOx selects the port x can be 0 1 or 2 Refer to GPIOx values on P page 68 for details on the allowed values of this parameter Port_Pin Specifies the pin to set or clear the value Input Parameter 2 i Refer to Port pin values on page 68 for more details on this parameter Bit_Val the value to be written Input Parameter 3 0 clear the port pin 1 set the port pin Output Parameter None Return Value None Required preconditions The port pin must be configured as OUT_OD or as OUT_PP Called Functions None GPIO_ByteWrite on page 74 See also pag GPIO_WordWrite on page 75 Note When a port pin value is changed the other port pins values stay unchanged The Input Pull Up Pull Down Configuration may change according to the related input pin value Example This example shows how to clear the GPIO port pin O and sets the GP O7 port pin 15 Clear the P0 0 bits GPIO BitWrite GPIOO 0 0 Set the P1 15 bits GPIO BitWrite GP
113. d preconditions must be configured Called Functions None ADC 12_ITConfig enables or disables either one channel interrupt or all the channels If the mode of conversion is the single mode only the interrupt of the channel whose conversion has been activated can be enabled or disabled In the case of the round robin mode of conversion all the channels interrupts can be either enabled or disabled together Example Enable interrupt ADC12_ ITConfig ENABLE ADC12_ ITConfig DISABLE External memory interface EMl The EMI driver may be used to access any memory bank external to the chip via the EMI interface The first section describes the data structure used in the EMI firmware library The second section presents the EMI firmware library functions Data structures EMI peripheral is declared in the 71x_map h file as follows define EXTMEM BASE 0x60000000 define EMI BASE EXTMEM BASE 0x0C000000 ifndef DEBUG ifdef EMI define EMI EMI_TypeDef EMI_ BASE endif EMI UM0097 Peripheral firmware overview else DEBUG ifdef EMI EXT EMI_TypeDef EMI endif EMI endif EMI Banks The following definitions are used to specify which EMI bank is to be used define EMI BANKO 0x00 define EMI BANK1 0x01 define EMI BANK2 0x02 define EMI BANK3 0x03 EMI bus size The following definitions defines the EMI data bus size define EMI SIZE 8 0x0000 define EM
114. d values of this parameter Called Functions Output Parameter None Return Value None Required preconditions None None UM0097 Peripheral firmware overview Example This example illustrates how to configure the TIM3 input capture channel A to detect Rising edge TIM_ICAPModeConfig TIM3 TIM_CHANNEL A TIM_RISING TIM_ICAPValue Function Name Function Prototype TIM_ICAPValue ul6 TIM_ICAPValue TIM TypeDef TIMx TIM Channels Xchannel Behavior Description This routine gets the input capture value Input Parameter 1 Input Parameter 2 TIMx specifies the TIM to check its Input Capture value Refer to T M values on page 103 for more details on the allowed values of this parameter Xchannel specifies the Input Capture channel Refer to TIM channels enumeration on page 104 for more details on the allowed values of this parameter Output Parameter None Return Value The input capture value of the specified timer and channel Required preconditions None Called Functions None Example This example illustrates how to get the input capture value of the TIM3 ul6 hICAPValue hICAPValue TIM _ICAPValue TIM3 TIM CHANNEL A 113 229 Peripheral firmware overview UM0097 TIM_OCMPModeConfig Function Name Function Prototype TIM_OCMPModeConfig void TIM_OCMPModeConfig
115. decrease the current priority level you must ensure that all pending bits are cleared If the EIC_Init function is used after the EIC_CurrentPriorityLevelConfig function the current priority level is reset to zero If this function is used in a non interrupt service routine all IRQ channels with a priority level lower or equal to the new priority level will be disabled ky UM0097 Peripheral firmware overview Examples The current priority level is increased by 1 void an_IRQ Routine void EIC CurrentPriorityLevelConfig EIC_ CurrentPriorityLevelValue 1 This example shows how to disable all RQ channel with a priority level lower or equal to 3 int main void EIC CurrentPriorityLevelConfig 3 EIC_CurrentIRQChannelValue Function Name EIC_CurrentIRQChannelValue Function Prototype IRQChannel TypeDef EIC_CurrentIRQChannelValue void Behavior Description Returns the current served IRQ channel number Input Parameter None Output Parameter None The current served IRQ channel number Return Value Refer to IRQ channel enumeration on page 54 for details on allowed values of RQChannel parameter Required Preconditions None Called Functions None Example This example shows how to get the current RQ channel level value IRQChannel TypeDef bCurrentIRQChannelValue bCurrentIRQChannelValue EIC CurrentIRQChannelValue lt 63 229 Peri
116. der Register The two BSPI interfaces are declared in the same file 71x_map h APB1 Base Address definition define APB1 BASE 0xc0000000 BSPI Base Address definition define BSPIO BASE APB1 BASE OxA000 define BSPI1 BASE APB1 BASE 0xB000 BSPI peripheral pointer declaration ifndef DEBUG ifdef BSPIO define BSPIO BSPI_TypeDef BSPIO BASE endif BSPIO ifdef BSPI1 define BSPI1 BSPI_TypeDef BSPI1 BASE Hendif BSPI1 else DEBUG 121 229 Peripheral firmware overview UM0097 122 229 ifdef _BSPIO EXT BSPI_TypeDef BSPIO Hendif BSPIO ifdef BSPI1 EXT BSPI_TypeDef BSPT1 Hendif BSPI1 endif When debug mode is used BSP pointer is initialized in 77x_lib c file ifdef BSPIO BSPIO BSPI_ TypeDef BSPIO BASE endif BSPIO ifdef BSPI1 BSPI1 BSPI_ TypeDef BSPI1 BASE endif BSPI1 In debug mode _BSP O and _BSPI1 must be defined in 71x_cont h file to access the peripheral registers as follows define _BSPI define _BSPIO define BSPI1 BSPI flags The following enumeration defines the BSP flags BSPI_Flags enumeration is defined in the file 71x_bspi h typedef enum BSPI_BERR 0x04 BSPI_RFNE 0x08 BSPI_RFF 0x10 BSPI_ROFL 0x20 BSPI_TFE 0x40 BSPI_TUFL 0x80 BSPI_TFF 0x100 BSPI_TFNE 0x200 BSPI_Flags UM0097 Peripheral firmware overview Table 58
117. details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions RTC_WaitForLastTask RTC_EnterCfgMode and RTC_ExitCfgMode Example This example illustrates how to clear the second interrupt request RTC_ITClear RTC_SIT 92 229 UM0097 Peripheral firmware overview RTC_EnterCfgMode Function Name RTC_EnterCfgMode Function Prototype void RTC_EnterCfgMode void Behavior Description This routine is used to enter the RTC configuration mode Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions RTC_WaitForLastTask Example This example illustrates how to enter in configuration mode RTC_EnterCfgMode RTC_ExitCfgMode Function Name RTC_ExitCfgMode Function Prototype void RTC_ExitCfgMode void Behavior Description This routine is used to exit from the RTC configuration mode Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions RTC_WaitForLastTask Example This example illustrates how to exit from configuration mode RTC_ExitCfgMode 93 229 Peripheral firmware overview UM0097 3 8 3 8 1 94 229 RTC_WaitForLastTask Function Name RTC_WaitForLastTask Function Prototype
118. dge APB2 Selects APB2 bridge Firmware library functions Table 25 enumerates the different functions of the APB library Table 25 APB library functions Function Name Description APB_ClockContig Enables Disables the peripheral clock gating on the specified APB bridge APB_SwResetContig al foe software reset for peripherals on the APB_ClockConfig Function Name APB_ClockConfig void APB ClockConfig APB TypeDef APBx Function Prototype i yp FunctionalState NewState ul6 Periph Enables Disables the peripheral clock gating on the specified APB bridge Input Parameter 1 APBx selects the APB bridge APB1 or APB2 Behavior Description NewSiatus specifies if the peripheral clock is running or stopped Input Parameter 2 ENABLE The peripheral clock is running DISABLE The peripheral clock is stopped Periph specifies the APB bridge peripheral Input Parameter 3 Refer to Bridge peripheral codes on page 49 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None One or more peripheral clocks can be enabled on the same APB bridge with a single APB_ClockConfig function call One or more peripheral clocks can be disabled with another APB_ClockConfig function call It is not possible to simultaneously enable and disable several peripheral clocks in a single APB
119. dif GPIO1 endif DEBUG To enter debug mode you have to define the label DEBUG in 71X_conf h file Debug mode allows you to watch the peripheral registers in a debugger window but it uses up some additional memory space and makes the code less efficient In both cases GP OO is a pointer to the first address of GP OO port EXT variable is defined in the file 71x_lib c as follows define EXT DEBUG mode is initialized as follows in the 71x_lib c file define DEBUG ifdef DEBUG void debug void ifdef _GPIOO GPIOO GPIO TypeDef GPIOO BASE endif lt 9 229 Document and library rules UM0097 ifdef _GPIO1 GPIO1 GPIO TypeDef GPIO1 BASE endif ifdef _GPIO2 GPIO2 GPIO TypeDef GPIO2 BASE endif endif DEBUG Note Debug mode increases the code size and reduces the code performance For this reason it is recommended to use it only when debugging the application and to remove it from the final application code Each peripheral has several dedicated registers which contain different flags Registers are defined within a dedicated structure for each peripheral Flag definition is adapted to each peripheral case defined in 71x_ppp h file Flags are defined as acronyms written in upper case and prefixed by PPP_ prefix PPP is the acronym of the corresponding peripheral The flags of each peripheral are included in an enumeration named PPP_Flags Some peripherals adopt this naming c
120. dress transmission is correctly completed I2C_Rx_DATA_OK Last Received data is correctly completed I2C_Rx_ONGOING The current reception is occurring 3 12 2 Firmware library functions Table 77 enumerates the different functions of the 7C library Table 77 IC library functions Function Name Description 12C_Init ao FC peripheral control and registers to their default reset 12C_OnOffContig Enables or disables C peripheral 12C_GeneralCallContig Enables or disables C general call option 12C_STARTGenerate Generates IC communication START condition 12C_STOPGenerate Generates C communication STOP condition l12C_AcknowledgeConfig Enables or disables FC acknowledge feature 12C_ITContig Enables or disables C interrupt feature 12C_RegisterRead Reads any C register and returns its value 12C_FlagStatus Checks whether any C Flag is set or not 12C_FlagClear Clears any C Flag x 170 229 UM0097 Peripheral firmware overview Table 77 I C library functions continued Function Name 12C_SpeedConfig Description Selects FC clock speed and configures its corresponding mode 12C_AddressContig Defines the 7C bus address of the interface 12C_FCLKConfig Configures frequency bits according to RCLK frequency 12C_AddressSend Transmits the address byte to select the slave device 12C_ByteSend Transmits single byte of data 12C_Tran
121. e PCU_LVDDisable j PCU_VRStatus Function Name PCU_VRStatus Function Prototype FunctionalState PCU_VRStatus PCU_VR xVR Behavior Description This routine gets the PCU voltage regulator status XVR specifies the PCU voltage regulator Input Parameter Refer to PCU voltage regulators on page 19 for more details on the allowed values of this parameter Output Parameter None The state of the specified voltage regulator Return Value ENABLE The voltage regulator is enabled DISABLE The voltage regulator is bypassed Required preconditions None Called Functions None Example This example illustrates how to check the PCU voltage regulator status FlagStatus MVR_Status FlagStatus LPVR_Status MVR_Status PCU_VRStatus PCU_MVR LPVR_Status PCU_VRStatus PCU_LPR 23 229 Peripheral firmware overview UM0097 PCU_LVDStatus Function Name Function Prototype PCU_LVDStatus FunctionalState PCU_LVDStatus void Behavior Description This routine gets and returns the LVD status Input Parameter None Output Parameter None Return Value The LVD status ENABLE the LVD is enabled DISABLE Required preconditions None Called Functions None Example This example illustrates how to check the LVD feature status FunctionalState LVD Status LVD_Status 24 229 PCU_LVDStatus
122. e void Behavior Description This routine is used to return the system reset source Input Parameter None Output Parameter None Return Value The reset source Required preconditions None Called Functions None Example This example illustrates how to define the system reset source RCCU_ResetSources ResetSource ResetSource RCCU_ResetSource switch ResetSource case RCCU_RTCAlarmReset GPIO BitWrite GPIOO 0 1 break case RCCU WKPReset GPIO BitWrite GPIO0O 1 1 break default GPIO BitWrite GPIO0O 3 1 break RCCU_PLL1FreeRunningModeConfig Function Name RCCU_PLL1FreeRunningModeConfig RCCU_PLL1FreeRunningModeConfig RCCU_PLL1FreeRunningM Function Prototype odes NewP111FreeRunningMode Behavior Description This routine is used to configure the PLL1 in free running mode RCCU_PLL1FreeRunningModes PLL1 in free running mode Input Parameter p Refer to PLL1 free running modes on page 35 Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to clock the system with the PLL1 configured in free running mode Configure the PLL in free running mode at 125kHz RCCU_PLL1FreeRunningModeConfig RCCU_PLL1FreeRunning125 Set the RCLK to the PLL1 output RCCU_RCLKSourceConfig RCCU_PLL1 Output 45 229 Peripheral firmware overview UM0097
123. e error counter if CAN GetReceiveErrorCounter gt 20 Error handling 3 14 12 bit analog to digital converter ADC12 The ADC 72 driver may be used to manage the ADC72 in its two modes of conversion single or round robin and to generate a maskable interrupt when a sample is ready The first section describes the data structures used in the ADC 72 firmware library The second one presents the firmware library functions 3 14 1 Data structures ADC12 register structure the ADC12 peripheral registers structure ADC 12_TypeDef is defined in the 71x_map h file as follows typedef struct vul6 DATAO ul6 EMPTY1 3 vul6 DATA Ky 213 229 Peripheral firmware overview UM0097 u16 EMPTY5 7 vul6 CPR ul6 EMPTY6 ADC12_ TypeDef Table 90 presents the ADC 72 registers Table 90 ADC12 registers Register Description DATAO ADC 12 data register for Channel 0 DATA1 ADC 12 data register for Channel 1 DATA2 ADC 12 data register for Channel 2 DATA3 ADC12 data register for Channel 3 CSR ADC 12 control status register CPR ADC12 prescaler register The ADC 72 peripheral is declared in the same file define APB2 BASE 0xE0000000 define ADC12 BASE APB2 BASE 0x7000 ifndef DEBUG ifdef ADC12 define ADC12 ADC12_ TypeDef ADC12 BASE endif ADC12 else DEBUG ifdef ADC12 EXT ADC12 TypeDef ADC12 endif endif When debug mode i
124. e is used to select the clock source of the USB peripheral Input Parameter New_Clock the USB clock source Refer to USB clock source on page 33 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the USB peripheral source clock as PLL2 output RCCU_USBCLKConfig RCCU_PLL2 Output RCCU_USBClockSource Function Name Function Prototype RCCU_USBClockSource USB _ Clocks RCCU_USBClockSource void Behavior Description This routine gets the clock source of the USB peripheral Input Parameter None Output Parameter None Return Value Required preconditions Called Functions The USB clock source Refer to USB clock source on page 33 for more details on the allowed values of this parameter None None Example This example illustrates how to get the USB clock source RCCU_USB Clocks Current _USBClock Current _USBClock RCCU_USBClockSource UM0097 Peripheral firmware overview RCCU_FrequencyValue Function Name RCCU_FrequencyValue Function Prototype u32 RCCU_FrequencyValue RCCU_Clocks Internal_ Clk This routine computes any internal RCCU clock frequency value passed Behavior Description in parameters Internal_Clk the RCCU internal clock to c
125. e overview UM0097 VROK_Status holds the Main VR_OK flag status VROK_Status PCU_VRConfig PCU_FlagStatus PCU_VROK Function Name Function Prototype PCU_VRConfig void PCU_VRConfig PCU_VR Xvr FunctionalState NewState Behavior Description This routine is used to configure enable bypass the PCU voltage regulators Input Parameter 1 Xvr Specifies the PCU voltage regulator Refer to PCU voltage regulators on page 19 for more details on the allowed values of this parameter Input Parameter 2 NewSiate Specifies whatever the corresponding voltage regulator is enabled or bypassed ENABLE Enable the corresponding PCU voltage regulator DISABLE Bypass the corresponding PCU voltage regulator Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to bypass the main voltage regulator PCU_VRConfig PCU_MVR DISABLE PCU_LVDDisable Function Name Function Prototype PCU_LVDDisable void PCU_LVDDisable void Behavior Description This routine is used to disable the Low Voltage Detector 22 229 Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None UM0097 Peripheral firmware overview Example This example illustrates how to disable the LVD featur
126. e received message is copied Refer to CAN message structure on page 191 for more details Output Parameter None Return Value 1 if reception was OK else 0 no message pending Required preconditions The CAN must have been switched into BASIC mode Called Functions Example None This example illustrates how to receive a single message in Basic mode canmsg CanMsg Receive a message if CAN BasicReceiveMessage amp CanMsg Check or copy the message contents else Error handling 208 229 UM0097 Peripheral firmware overview CAN_GetMsgReceiveStatus Function Name Function Prototype CAN_GetMsgReceiveStatus FlasgStatus CAN GetMsgReceiveStatus u32 msgobj Behavior Description Tests the waiting status of a received message Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value 1 if the corresponding message object has received a message waiting to be copied else 0 Required preconditions The corresponding message object must have been set as RX None This example illustrates how to test the waiting status of a message Test if a message is pending in the receive message if CAN _GetMsgReceiveStatus 0 Receive the message from this message object i e get its data from message RAM Called Functi
127. eDef UARTx UARTMode_ TypeDef UART_ Mode Behavior Description This routine configures the UART mode Input Parameter 1 UARTx selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 UART_Mode selects the UART mode Refer to UART modes on page 143 for details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the UARTO mode Configure the UARTO mode to 8 bit data without parity UART_ModeConfig UARTO UARTM_8D UART_BaudRateConfig Function Name Function Prototype UART_BaudRateConfig void UART BaudRateConfig UART TypeDef UARTx u32 BaudRate Behavior Description This routine configures the baud rate of the selected UART Input Parameter 1 UARTx selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 BaudRate The baud rate value in bps Output Parameter None Return Value None Required preconditions None Called Functions RCCU_FrequencyValue RCCU_PCLK1 gets the APB1 frequency Example This example illustrates how to configure the UARTO baud rate Set
128. ead all status registers u32 12C Status_registers I2C_ Status_registers I2C GetStatus I2C0 182 229 UM0097 Peripheral firmware overview I2C_ GetLastEvent Function Name 12C_GetLastEvent Function Prototype ul6 I2C _GetLastEvent I2C_TypeDef I2Cx Behavior Description Gets the last I2Cx event that has occurred I2Cx specifies the 12C to get its status registers where x can be 0 Input Parameter or 1 Output Parameter None Return Value The last happened Event Required Preconditions None Called Functions None Example This example illustrates how to get the last 2CO event that has occurred ul6 I2C Event I2C_Event 12C GetLastEvent I2C0 I2C_CheckEvent Function Name 12C_CheckEvent FlagStatus I2C CheckEvent I2C_TypeDef I2Cx ul6 Function Prototype 12C_EVENT Checks whether the Last 12C Event is equal to the one passed as Behavior Description parameter I2Cx specifies the 12C to get its status registers where x can be 0 or 1 I2C_EVENT specifies the event to be checked Refer to 2C events on page 169 for more details on this parameter Input Parameter 1 Input Parameter 2 Output Parameter None Return Value The I2C status registers value Required Preconditions None Called Functions None Example This example illustrates how to wait for EV8 event using I2CO while I2C_ CheckEvent
129. ecified flag flag specifies the flag to get the status Input Parameter Refer to ADC 12 flags on page 216 for more details on the allowed values of this parameter Output Parameter None The status of the specified flag Its value can be Return Value SET The corresponding Flag is Set RESET The corresponding Flag is cleared Required preconditions Conversion started Called Functions None See also ADC12_ConversionValue on page 220 Example This example illustrates an example of use of the ADC 12_flagStatus function ul6 test Test if the conversion on the Channel 3 has finished or not xf while ADC12_FlagStatus ADC12_DA3 RESET Test the overrun bit if ADC12_ FlagStatus ADC12_ OR RESET Get the conversion result test ADC12 ConversionValue 3 221 229 Peripheral firmware overview UM0097 Note 3 15 3 15 1 222 229 ADC12_ITConfig Function Name ADC12_ITConfig void ADC12 ITConfig FunctionalState Function Prototype NewState Behavior Description This routine is used to enable or disable the interrupt routine NewSiate specifies whether the interrupt will be enabled or disabled ENABLE enable the interrupt routine DISABLE disable the interrupt routine Input Parameter Output Parameter None Return Value None The modes of conversion and the channel to be converted Require
130. econd interrupt flag Test if the Second interrupt request is set if RTC_FlagStatus RTC_SIR 90 229 UM0097 Peripheral firmware overview RTC_FlagClear Function Name Function Prototype RTC_FlagClear void RTC FlagClear RTC_FLAGS Xflag Behavior Description This routine is used to clear the specified RTC flag Input Parameter Xflag Designates an ATC flag Refer to RTC flags on page 85 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions RTC_WaitForLastTask RTC_EnterCfgMode and RTC_ExitCfgMode Example This example illustrates how to clear an RTC pending flag Clear the Alarm request pending flag RTC FlagClear RTC AIR RTC_ITConfig Function Name RTC_ITConfig Function Prototype void RTC_ITConfig RTC_IT Xrtcit FunctionalState NewState Behavior Description This routine is used to enable or disable the specified RTC interrupt Input Parameter 1 Xrtcit Designates an ATC interrupts Refer to RTC interrupts on page 86 for more details on the allowed values of this parameter Input Parameter 2 NewSiate designates the new interrupt status ENABLE The corresponding interrupt is enabled DISABLE The corresponding interrupt is disabled Output Parameter None Return Value None Re
131. ed Functions 12C_OnOffConfig Example This example illustrates how to clear the 2C_STOPF flag I2C FlagClear 12C0 I2C STOPF I2C_SpeedConfig Function Name I2C_SpeedConfig void I2C SpeedConfig I2C_TypeDef I2Cx Function Prototype u32 Clock Behavior Description Configures the FC clock speed Input Parameter 1 12Cx specifies the 12C to be configured where x can be 0 or 1 Input Parameter 2 Clock the PC expected clock in Hertz Output Parameter None Return Value None Required Preconditions None Called Functions RCCU_FrequencyValue on page 43 Example This example illustrates how to configure the clock speed I2C SpeedConfig I2C0 150000 177 229 Peripheral firmware overview UM0097 I2C_AddressConfig Function Name Function Prototype 12C_AddressConfig void I2C_AddressConfig I2C_TypeDef I2Cx ul Address I2C Addressing Mode Behavior Description Configures the C bus address of the interface Input Parameter 1 12Cx specifies the 12C to be configured where x can be 0 or 1 Input Parameter 2 Address the C bus address of the interface Input Parameter 3 Mode specifies the addressing mode Refer to 2C addressing modes on page 167 for more details on the allowed values of this parameter Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to conf
132. eral BSPI_ Enable BSPIO ENABLE User code Disable BSPIO peripheral BSPI_ Enable BSPIO DISABLE BSPIL MasterEnable Function Name BSPI_MasterEnable void BSPI MasterEnable BSPI_ TypeDef BSPIx Function Protot unctio ototype FunctionalState NewState Behavior Description Configures the BSP as a Master or a Slave BSPkx selects the BSPI peripheral to be configured as master or aput Parameter slave where x can be 0 or 1 NewState specifies whether BSPI will be configured as master or slave ENABLE the specified BSPI will be configured as a master DISABLE the specified BSPI will be configured as a slave Input Parameter 2 Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to configure the BSP O as a master or a slave Enable BSPIO interface BSPI_BSPIOCon ENABLE Configure BSPIO as a master BSPI MasterEnable BSPIO ENABLE Enable BSPIO peripheral BSPI_ Enable BSPIO ENABLE 127 229 Peripheral firmware overview UM0097 128 229 BSPIL TritSrc Function Name Function Prototype BSPIL_TritSrc void BSPI_TrITSrc BSPI_TypeDef BSPIx TR_IT_SRCS TrItSrc Behavior Description Configures the transmit interrupt source Input Parameter 1 BSPIx selects the BSPI peripheral to be configured where
133. eral registers Uncomment the DEBUG label this allows you to see the peripheral registers content in the watch window ky UM0097 Firmware library ifndef __71x_CONF_H define 71x CONF _H define DEBUG define TIM to include the TIM library define TIMO to access the TIMO registers define TIM1 to access the TIM1 registers define GPIO to include the GPIO library define GPIOO to access the GPIOO registers define GPIO1 to access the GPIO1 registers endif 71x CONF H Edit the file 77x_it c and add the following code to the Timer 0 interrupt handler routine TOTIMI_IRQHandler void TOTIMI_IRQHandler void TIM FlagClear TIMO TIM_TOF to clear the TIMO interrupt flag GPIO WordWrite GPIO0 GPIO WordRead GPIO0O invert the GPIOO output level e Add the following code to the Timer 1 interrupt handler routine T1TIMI_IRQHandler void T1ITIMI_IRQHandler void u32 i TIM FlagClear TIM1 TIM TOF to clear the TIM1 interrupt flag GPIO WordWrite GPIO1 GPIO WordRead GPIO1 for i 0 i lt OxOOOFFFFF i delay GPIO WordWrite GPIO1 GPIO WordRead GPIO1 e The initialization of the GPIOO GPIO1 TIMO and TIM1 peripherals is done in the application source file main c in our case The configuration of the EIC and the IRQ channels priority is also done in this file e Edit the main c file and add the following code include 71x_lib h
134. erate void I2C_STARTGenerate I2C_ TypeDef I2Cx Function Protot nau SPs FunctionalState NewState Behavior Description Enables or disables C start generation Input Parameter 1 12Cx specifies the 12C to be configured where x can be 0 or 1 NewSiate specifies the new status to set Input Parameter 2 ENABLE enables the PC start generation DISABLE disables the C start generation Output Parameter None Return Value None Required Preconditions PCx peripheral should be enabled Called Functions None Example This example illustrates how to enable the start generation in the 2CO peripheral I2c OnoffConfig I2C0 ENABLE I2C_ STARTGenerate I2C0 ENABLE 173 229 Peripheral firmware overview UM0097 I2C_ STOPGenerate Function Name Function Prototype 12C_STOPGenerate void I2C_STOPGenerate I12C_TypeDef I2Cx FunctionalState NewState Behavior Description Enables or disables C stop generation Input Parameter 1 12Cx specifies the 12C to be configured where x can be 0 or 1 Input Parameter 2 NewSiate specifies the new status to set ENABLE enables the FC stop generation DISABLE disables the C stop generation Output Parameter None Return Value None Required Preconditions PCx peripheral should be enabled Called Functions None Example This example illustrates how t
135. eriod Refer to PWM input parameters structure on page 106 for more details on the allowed values of this parameter Required preconditions None Called Functions None Example This example illustrates how to get the PWM input signal parameters PWMI_ parameters PWM InputSignal PWM _InputSignal TIM _PWMIValue TIM3 117 229 Peripheral firmware overview UM0097 TIM_CounterConfig Function Name Function Prototype TIM_CounterConfig void TIM CounterConfig TIM TypeDef TIMx CounterOperations Xoperation Behavior Description This routine is used to start stop and clear the selected timer counter Input Parameter 1 TIMx specifies the TIM to be initialized Refer to TIM values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xoperation specifies the operation of the counter Refer to Counter operations enumeration on page 105 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to stop the 7 M3 counter TIM CounterConfig TIM3 TIM_STOP TIM_CounterValue Function Name Function Prototype TIM_CounterValue ul6 TIM CounterValue TIM TypeDef TIMx Behavior Description Input Parameter 1 This routine returns the timer counter val
136. eripheral Enable BSPIO peripheral BSPI_ Enable BSPIO ENABLE Enable BSPIO to generate an interrupt when the FIFO is not empty BSPI_RcItSre BSPIO BSPI_RC_FNE 129 229 Peripheral firmware overview UM0097 BSPI_TrFifoDepth Function Name Function Prototype BSPI_TrFifoDepth void BSPI TrFifoDepth BSPI TypeDef BSPIx u8 TDepth Behavior Description Configures the depth of the BSPI transmission FIFO Input Parameter 1 BSPIx selects the BSPI peripheral to be configured where x can be Oor 1 Input Parameter 2 TDepth specifies the depth of the transmit FIFO Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to set the depth of the transmit F FO to 8 words BSPI_ TrFifoDepth BSPIO 8 BSPI_RcFifoDepth Function Name Function Prototype BSPI_RcFifoDepth void BSPI_ RcFifoDepth BSPI TypeDef BSPIx u8 RDepth Behavior Description Configures the depth of the BSPI reception FIFO Input Parameter 1 Input Parameter 2 BSPIkx selects BSPI peripheral to be configured where x can be 0 or 1 RDepth specifies the depth of the receive FIFO Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to set the de
137. ernal memory interface EMI 00 c eee eee 222 3 15 1 Datastructures 0 eee 222 3 15 2 Firmware library functions 0 e eee eee 224 4 REVISION history ccssace ch ciate ade eekeue od Chentad odeaeee ee 226 ky 3 229 List of tables UM0097 List of tables Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 Table 7 Table 8 Table 9 Table 10 Table 11 Table 12 Table 13 Table 14 Table 15 Table 16 Table 17 Table 18 Table 19 Table 20 Table 21 Table 22 Table 23 Table 24 Table 25 Table 26 Table 27 Table 28 Table 29 Table 30 Table 31 Table 32 Table 33 Table 34 Table 35 Table 36 Table 37 Table 38 Table 39 Table 40 Table 41 Table 42 Table 43 Table 44 Table 45 Table 46 Table 47 Table 48 4 229 LIST Of ACKONYINS 0 5 c deve cttw cae tes wes GRY ered EEEa bea ages ade a a cece Bo Th 6 Source header file list 0 tetas 12 Peripheral firmware functions 1 0 0 00 eee 17 PCU structure fields 0 0 0 0 ete 18 PCU voltage regulator status 0 0 0 tte ee 19 PCU voltage regulator descriptions 0 0000 tenes 19 WEI COCKS cu overdone Eki eek ghee ee ke dee eee be Hie doe wae oe 19 PCUMAGS ticked et cee ate a eee awk ohne E E winded iu eae Mae eae bes 20 PCU library functions 0 0 0 0 cee eee 20 RCC registers 0 0 0 eee ee 30 Clock divider parameters 000 cette eee 31 RCLK clock source
138. es how to send a buffer vul pBuffer 0x1234 0xAAAA 0x5555 Transmit 3 16 bit data format BSPI_ ByteBufferSend BSPI_WordReceive BSPIO pBuffer 3 Function Name Function Prototype BSPI_BufferReceive ul6 BSPI WordReceive BSPI TypeDef BSPIx Description Returns the recent received word Input Parameter 1 BSPIx selects BSPI peripheral to be used where x can be 0 or 1 Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to receive a data from the BSPIO ul6 data Receive a data from BSPIO data BSPI_ WordReceive BSPIO 137 229 Peripheral firmware overview UM0097 138 229 BSPI_ByteBufferReceive Function Name Function Prototype BSPI_ByteBufferReceive void BSPI ByteBufferReceive BSPI TypeDef BSPIx u8 PtrToBuffer u8 NbOfWords Description Receives number of data words and stores them in user defined area Input Parameter 1 BSPIx selects BSPI peripheral to be used where x can be 0 or 1 Input Parameter 2 PtrToBuffer is an u8 pointer to the first word of the defined area to save the received buffer Input Parameter 3 NbOfWords indicates the number of bytes to be received in the buffer Output Parameter None Return Value None Required Preconditions None Called Functions
139. escaler OxFF Configures the new prescaler value RTC_PrescalerConfig wNew_Prescaler RTC_CounterValue Function Name RTC_CounterValue Function Prototype u32 RTC_CounterValue void Behavior Description This routine gets the current RTC counter value Input Parameter None Output Parameter None Return Value The current RTC counter value Required preconditions None Called Functions None Example This example illustrates how to get the RTC counter value u32 wCounter wCounter RTC CounterValue 88 229 lt UM0097 Peripheral firmware overview RTC_CounterConfig Function Name RTC_CounterConfig Function Prototype void RTC_CounterConfig void Behavior Description This routine is used to update the RTC counter with a new value Input Parameter The new ATC counter value Output Parameter None Return Value None Required preconditions None Called Functions RTC_EnterCfgMode RTC_WaitForLastTask and RTC_ExitCfgMode Example This example illustrates how to update the RTC counter with 0x23F value RTC_CounterConfig 0x23F RTC_AlarmValue Function Name RTC_AlarmValue Function Prototype u32 RTC AlarmValue void Behavior Description This routine gets the current RTC alarm value Input Parameter None Output Parameter None Return Value The current RTC alarm value u32 format Required preconditions None C
140. et else 0 Required preconditions None Called Functions None lt 211 229 Peripheral firmware overview UM0097 Example This example illustrates how to read the Ewarning status of the CAN cell if CAN cell has reached the Ewarning status if CAN _GetFlagStatus CAN _SR_EWARN Error handling else continue CAN_GetTransmitErrorCounter Function Name CAN_GetTransmitErrorCounter Prototype u32 CAN GetTransmitErrorCounter void j Behavior Description Returns the transmit error counter content Input Parameter None Output Parameter None Return Value Transmit Error Counter value Required preconditions None Called Functions None Example This example illustrates how to read the CAN transmit error counter raed the transmit error counter if CAN GetTransmitErrorCounter gt 10 Error handling 212 229 UM0097 Peripheral firmware overview CAN_GetReceiveErrorCounter Function Name CAN_GetReceiveErrorCounter Prototype u32 CAN GetReceiveErrorCounter void Behavior Description Returns the receive error counter content Input Parameter None Output Parameter None Return Value Receive Error Counter value Required preconditions None Called Functions None Example This example illustrates how to read the CAN receive error counter raed the receiv
141. et the TIMO timer source clock TIM Clocks CurrentTIMClock CurrentTIMClock TIM _ClockSourceValue TIMO 109 229 Peripheral firmware overview UM0097 110 229 TIM_PrescalerConfig Function Name Function Prototype TIM_PrescalerConfig void TIM PrescalerConfig TIM _TypeDef TIMx u8 Xprescaler Behavior Description This routine configures the TIM prescaler value to divide the internal clock Input Parameter 1 TIMx specifies the TIM to be configured Refer to TIM values on page 103 for more details on the allowed values of this parameter Input Parameter 2 Xprescaler specifies the TIM prescaler value 8bit Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the T M3 prescaler TIM PrescalerConfig TIM3 0x5 TIM_PrescalerValue Function Name Function Prototype Behavior Description TIM_PrescalerValue u8 TIM PrescalerValue TIM TypeDef TIMx This routine gets the T M prescaler value when the internal clock is used Input Parameter TIMx specifies the timer to get its prescaler value Refer to T M values on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value The Current T M prescaler Value 8bit Required preconditions None Called Functions
142. fault mode DISABLE FLASH in LP mode the maximum allowed execution frequency 33 MHz Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to enable disable FLASH Burst mode Set the FLASH in LP mode PCU_FlashBurstCmd DISABLE Set the FLASH in BURST mode PCU_FlashBurstCmd ENABLE UM0097 Peripheral firmware overview PCU_320SCCmd Function Name PCU_320SCCmd Function Prototype void PCU_320SCCmd FunctionalState NewState Behavior Description Enables or disables the 32 kHz oscillator NewSiate specifies whether the 32 kHz oscillator is enabled or disabled ENABLE enables the 32 kHz oscillator DISABLE disables the 32 kHz oscillator Input Parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enable the 32 kHz oscillator Enable the 32 kHz oscillator PCU_320SCCmd ENABLE 3 2 Reset and clock control unit RCCU The RCCU driver may be used for a variety of purposes including internal clock configuration and clock source selection The first section describes the data structure members used in the RCCU firmware library The second section presents the RCCU firmware library functions 3 2 1 Data structures RCCU register structure The R
143. figuration mode RTC_WaitForLastTask Waits for last task to be finished RTC_PrescalerValue Function Name Function Prototype RTC_PrescalerValue u32 RTC PrescalerValue void Behavior Description This routine gets the RTC prescaler value Input Parameter None Output Parameter None Return Value The current RTC prescaler value Required preconditions None Called Functions Example None This example illustrates how to get the current RTC prescaler value u32 wCurrent_Prescaler wCurrent_Prescaler RTC_PrescalerValue RTC_PrescalerConfig Function Name Function Prototype Behavior Description RTC_PrescalerConfig void RTC PrescalerConfig u32 Xprescaler This routine is used to configure the prescaler Input Parameter Xprescaler specifies the new ATC prescaler value Output Parameter None Return Value None Required preconditions None Called Functions RTC_WaitForLastTask RTC_EnterCfgMode and RTC_ExitCfgMode The prescaler is a 20 bit value the RTC_PrescalerConfig truncates any value passed in parameter that exceeds 20 bits 87 229 Peripheral firmware overview UM0097 Example This example illustrates how to configure the RTC prescaler value u32 wNew_Prescaler Reads the previous prescaler value wNew_Prescaler RTC_PrescalerValue Add OxFF wNew Pr
144. file 77x_lib c ifdef _UARTO UARTO UART TypeDef UARTO BASE endif _UARTO ifdef UART1 UART1 UART TypeDef UART1_ BASE endif _UARTI1 lt 141 229 Peripheral firmware overview UM0097 142 229 ifdef _UART2 UART2 UART_TypeDef UART2_BASE endif _UART2 ifdef _UART3 UART3 UART_TypeDef UART3 BASE endif _UART3 In debug mode _UART0O UART1 UART2 and _UART3 must be defined in the file 71x_cont h to access the peripheral registers as follows define _UART define _UARTO define _UART1 define _UART2 define _UART3 The UART library use the RCCU and PCU library The _RCCU and _PCU must be defined in the 71x_confh to access the RCCU and PCU registers and library functions as follows define _RCCU define _PCU FIFOs The following enumeration defines the UART FIFOs The UARTFIFO_TypeDef enumeration is defined in the 71x_uart h file typedef enum UART_RxFIFO UART_TxFIFO UARTFIFO_TypeDef Table 64 describes the UART FIFOs Table 64 UART FIFOs Regulator State Description UART_RxFIFO Receive FIFO UART_TxFIFO Transmit FIFO UART stop bits The following enumeration defines the UART Stop Bits selection The UARTStopBits_ TypeDef enumeration is declared in the 71x_uart h file typedef enum UART_0 5 StopBits 0x0000 UART_1 StopBits 0x0008 UART_1_5 StopBits 0x0010 UART_2 StopBits 0x0018 UARTStopBits TypeDef U
145. frames using message object 0 for i 0 i lt 10 i CAN SendMessage 0 CanMsgTable i j CAN WaitEndOfTx r CAN_BasicSendMessage Function Name Function Prototype Behavior Description CAN_BasicSendMessage u32 CAN BasicSendMessage canmsg pCanMsg Starts transmission of a message in BASIC mode Refer to CAN test register bits on page 188 for more details on the Basic mode Input Parameter pCanMsg pointer to the canmsg structure that contains the data to transmit ID type ID value data length data values Refer to CAN message structure on page 191 for more details Output Parameter None Return Value 1 if transmission was OK else 0 Required preconditions The CAN must have been switched into BASIC mode Called Functions None 207 229 Peripheral firmware overview UM0097 Example This example illustrates how to send a single message canmsg CanMsg 0x80 CAN STD ID 0x111 4 0x10 0x20 0x40 CAN BasicSendMessage 0 amp CanMsg CAN_BasicReceiveMessage Function Name Function Prototype CAN_BasicReceiveMessage u32 CAN BasicReceiveMessage canmsg pCanMsg Behavior Description Gets the message in BASIC mode if received Refer to CAN test register bits on page 188 for more details on the Basic mode Input Parameter pCanMszg pointer to the canmsg structure where th
146. gisters typedef enum I2C_ CR 0x00 The two C interfaces are declared in the same file 0xC0000000 APB1 BASE 0x1000 APB1 BASE 0x2000 I2C_TypeDef I2CO_ BASE I2C_TypeDef 1I2C1_ BASE I2CO0 T2Ci 5 When debug mode is used C pointer is initialized in 71x_lib c file I2CO_ BASE I2C1_ BASE _I2C0and__I2C1 must be defined in 71x_conf h file to access the peripheral registers as follows When RCCU functions are called _RCCU must be defined in 71x_confh file to make the RCCU functions accessible The following enumeration defines the registers of the C and their offset 2C_Registers enumeration is defined in the file 77x_i2c h as follows lt UM0097 Peripheral firmware overview I2C SR1 0x04 I2C SR2 0x08 I2C_ CCR Ox0C I2C_ OAR1 0x10 I2C OAR2 0x14 I2C DR 0x18 I2C_ECCR Ox1C I2C_Registers I C addressing modes The following enumeration defines the C addressing mode The 2C_Addressing enumeration is defined in the file 71x_i2c h as follows typedef enum I2C Modelo I2C_Mode7 I2C Addressing Table 72 defines the C addressing modes Table 72 C addressing modes Addressing mode Description I2C_Mode10 10 bit addressing mode I2C_Mode7 7 bit addressing mode 12C transfer direction The following enumeration defines the PC transfer direction The 2C_Direction enumeration is defined in the file 71x_i2c h as
147. has the lowest priority whatever their type It is also not recommended to have holes in the objects list for optimal performance A typical usage of the message objects is from low to high numbers transmit objects receive objects with filtering fixed ID receive objects with filtering ID range receive objects without filtering unused objects independently of the FIFO depth 199 229 Peripheral firmware overview UM0097 200 229 CAN_SetRxMsgObj Function Name Function Prototype CAN_SetRxMsgObj u32 CAN SetRxMsgObj u32 msgobj u32 idType u32 idLow u32 idHigh bool singleOrFifoLast Behavior Description Configures the message object as RX Input Parameter 1 msgobj message object number from 0 to 31 Input Parameter 2 idType message identifier type defined using the values described in CAN message identifier types on page 192 Input Parameter 3 idLow low part of the identifier range used for acceptance filtering It can take values from 0 to Ox7FF for standard ID and values from 0 to Ox1FFFFFFF for extended ID Input Parameter 4 idHigh high part of the identifier range used for acceptance filtering It can take values from 0 to Ox7FF for standard ID and values from 0 to Ox1FFFFFFF for extended ID idHigh must be above idLow For more convenience use one of the following values to set the maximum ID CAN_LAST_STD_ID or CAN_LAST_EXT_ID
148. igure the address of the interface in the case of 7 bit addressing mode I2C AddressConfig I2C0 OxA0O I2C Mode 7 I2C_FCLKConfig Function Name Function Prototype I2C_FCLKConfig void I2C FCLKConfig I12C_ TypeDef I2Cx Behavior Description Configures PC frequency bits according to PCLK1 frequency The selected I2C must be disabled Input Parameter 12Cx specifies the 12C to be configured where x can be 0 or 1 Output Parameter None Return Value None Required Preconditions The C module is disabled PE 0 Called Functions Example RCCU_FrequencyValue This example illustrates how to configure the 2C frequency according to to PCLK1 frequency the I2C module must be disabled PE 0 I2C_FCLKConfig I2C0 lt UM0097 Peripheral firmware overview I2C_AddressSend Function Name 12C_AddressSend void I2C_AddressSend I2C_ TypeDef I2Cx Function Prototype ul6 Address I2C Addressing Mode I2C_ Direction Direction Sends the slave address with which the next communication will be Behavior Description performed 12Cx where x can be 0 or 1 to select the 7C peripheral which will Input Parameter send the slave address Input Parameter 2 Address Indicates the slave address which will be transmitted Mode Refer to I2C addressing modes on page 167 for more Input Parameters details on the allowed
149. ihe te aks User code break case WDGTOTIMI FIQChannels WDG gt SR 0x000 Clear the WDG interrupt flag TIMO gt SR amp 0x2000 Clear the Timer 0 interrupt flag Clear the FIQ pending bits EIC_FIQPendingBitClear WDGTOTIMI_FIQChannels ee User code 64 229 UM0097 Peripheral firmware overview EIC_FlQPendingBitClear Function Name EIC_FlQPendingBitClear void EIC FIQPendingBitClear FIQChannel TypeDef Function Prototype FIQChannel Clears the selected FIQ Pending bit located in FIR register by writing 1 Bolavigh DESCrIpUoN to the corresponding bit FIQChannel specifies the FIQ channel to be configured Input Parameter Refer to FIQ channel enumeration on page 55 for details on allowed values of FIQChannel parameter Output Parameter None Return Value None Required Preconditions None Called Functions None See also EIC_CurrentFlQChannelValue on page 64 Example This example shows how to use of the E C_FlQPendingBitClear function in the FIQ interrupts service routine to define the source of F Q interrupts void FIQ Handler void TIMO gt SR amp 0x2000 Clear the Timer 0 interrupt flag Clear the corresponding FIQ pending bit EIC FIQPendingBitClear TOTIMI_ FIQChannel 3 5 General purpose input output GPIO The GPIO driver may be used for several purposes including pin configuration readi
150. ineConfig ul6 Lines FunctionalState NewState Behavior Description This routine is used to enable and disable the interrupts lines Input Parameter 1 Lines specifies the lines to be configured You can select more than one line by logically OR ing them Refer to Section 3 6 2 Common parameter values on page 77 for details on the allowed values of Lines parameter Input Parameter 2 NewSiatus the input line interrupt new status to be set ENABLE to enable the input line interrupt DISABLE to disable the input line interrupt Example Output Parameter None Return Value None Required preconditions None Called Functions None This example shows how to enable the line 2 and 1 Wake Up interrupts and disable the line 3 Wake Up interrupts XTI_LineConfig XTI_Line3 DISABLE XTI_LineConfig XTI_Line2 XTI_Linel ENABLE XTI_InterruptLineValue Function Name Function Prototype XTI_InterruptLineValue ul6 XTI_InterruptLineValue void Behavior Description Gets and returns the input line number that generates an Interrupt Input Parameter Output Parameter None None Return Value The line number that generates the interrupt Required preconditions None Called Functions None Example This example shows how to get the line number that generates the Wake Up interrupt void XTI_IRQHandler void
151. ing on the input passed parameters Reads the specified data port byte upper or lower eight bits and GPIO_ByteRead returns its value GPIO_WordRead Reads the specified data port and returns its value GPIO_BitWrite Sets or clears the selected data port bit GPIO_ByteWrite Writes a byte value into the selected port register byte upper or lower eight bits GPIO_WordWrite Writes a word value into the selected port register GPIO_Config Function Name GPIO_Config void GPIO Config GPIO TypeDef GPIOx Function Protot kaan unction Frototype ul6 Port_Pins GpioPinMode_TypeDef GPIO Mode Configures the selected GPIO I O pins according to the input passed Behavior Description parameters Refer to the datasheet for more details on input modes output modes and port names GPIOx selects the port to be configured x can be 0 1 or 2 Refer to Input Parameter 1 GPIOx values on page 68 for details on the allowed values of this parameter Port_Pins this parameter specifies the port pin placement You can Input Parameter 2 select more than one pin Refer to Port pin values on page 68 for more details on the allowed values of this parameter GPIO_Mode specifies the pin mode Refer to GPIO pin mode Input Parameter 3 enumeration on page 67 for more information on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions
152. initions define the UART Interrupt and status flags The interrupt and status flags are defined in the 71x_uart h file define UART_TxFull 0x0200 define UART_ RxHalfFull 0x0100 define UART_TimeOutIdle 0x0080 define UART_TimeOutNotEmpty 0x0040 define UART _OverrunError 0x0020 define UART FrameError 0x0010 define UART ParityError 0x0008 define UART_TxHalfEmpty 0x0004 define UART_TxEmpty 0x0002 define UART RxBufNotEmpty 0x0001 Table 68 describes the Interrupt and status flags Table 68 Interrupt and status flags Interrupt and Status Flags Description UART_TxFull Transmit Buffer Full Status register only UART_RxHalfFull Receiver buffer Half Full UART_TimeOutldle Time out Idle UART_TimeOutNotEmpty Time out Not Empty UART_OverrunError Overrun Error UART_FrameError Framing Error UART_ParityError Parity Error UART_TxHalfEmpty Transmit buffer Half Empty UART_TxEmpty Transmit buffer Empty UART_RxBufNotEmpty Receive Buffer Not Empty lt UM0097 Peripheral firmware overview UARTx values Table 69 shows the allowed values of UARTx variable Table 69 UARTx values UARTx Description UARTO To select VARTO UART1 To select UART1 UART2 To select UART2 UART3 To select UARTS3 3 11 2 Firmware library functions Table 70 enumerates the different functions of the UAAT library Table 70 UART library functions Function Name Description UART_Init
153. ion is defined in the file 71x_tim h typedef enum TIM RISING TIM FALLING TIM Clock Edges Table 49 enumerates the clock edges Table 49 TIM clock edges clock Edge Description TIM_RISING The active edge is the rising edge TIM_FALLING The active edge is the falling edge TIM channels enumeration The following enumeration defines the different TIM channels The T M_Channels enumeration is defined in the file 77x_tim h typedef enum TIM CHANNEL A TIM CHANNEL B TIM Channels Table 50 enumerates the TIM channels Table 50 TIM channels TIM Channel Description TIM_CHANNEL_A Channel A TIM_CHANNEL_B Channel B 104 229 UM0097 Peripheral firmware overview lt Output compare modes enumeration The following enumeration defines the Output Compare modes The OC_Modes enumeration is defined in the file 71x_tim h typedef enum TIM TIMING TIM WAVE TIM_OC Modes Table 51 enumerates the output compare modes Table 51 Output compare modes Output Compare Mode Description TIM_TIMING The output compare mode is used for internal operations The output compare mode is only used for external wave generation TIM_WAVE f operations Logic levels enumeration The following enumeration defines the different logic levels The Logic_Levels enumeration is defined in the file 71x_tim h typedef enum TIM_HIGH TIM_LOW TIM_Logic_Levels
154. iption This routine is used to enable Watchdog mode Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enable Watchdog mode Enable the watchdog mode WDG Enable UM0097 Peripheral firmware overview WDG_CntRefresh Function Name Function Prototype WDG_CntRefresh void WDG CntRefresh void Behavior Description This routine is used to refresh the counter to prevent a reset being generated by the Watchdog It writes OxA55A then 0x5AA5 in the key register Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to refresh the watchdog counter WDG CntRefresh WDG_PrescalerConfig Function Name Function Prototype WDG_PrescalerConfig void WDG PrescalerConfig u8 Prescaler Behavior Description This routine is used to set the the counter prescaler value The clock to Timer Counter is divided by Prescaler 1 Input Parameter Prescaler specifies the prescaler value 8 bit Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to set the prescaler value WDG PrescalerConfig 0x62
155. is function is used to configure the ADC sampling frequency by Behavior Description i Pane eee setting the prescaler register Input Parameter Adc12_clk specifies the ADC12 sampling frequency Hz Output Parameter None Return Value None Required preconditions Call of the RCCU library to get the APB2 frequency Called Functions RCCU_FrequencyValue on page 43 Example This example shows how to configure the prescaler Configure the ADC sampling frequency to 500Hz ADC12_ PrescalerConfig 500 ADC12_ChannelSelect Function Name ADC12_ChannelSelect void ADC12_ChannelSelect ADC_Channels Function Prototype ADC12 Channel This function selects the channel to be converted in single Behavior Description channel mode of conversion ADC12_Channel specifies the channel to be converted Input Parameter Refer to ADC12 channels on page 215 for more details on the allowed values of this parameter Output Parameter None Return Value None Called only if the mode of conversion selected is the single Required preconditions Channel mod Called Functions None See also ADC12_ModeConfig on page 217 Example This example shows how and when to use the ADC12_ChannelSelect function configure the single channel mode ADC12_ModeConfig ADC12_SINGLE select the channel 3 to be converted ADC12_ChannelSelect ADC12_CHANNEL3 218 229
156. ister CNTR Counter Register CR1 Control Register 1 CR2 Control Register 2 SR Status Register The TIM peripherals are declared in the same file define TIMO BASE APB2 BASE 0x9000 define TIM1 BASE APB2 BASE 0xA000 101 229 Peripheral firmware overview UM0097 102 229 define TIM2_BASE define TIM3 BASE ifndef DEBUG ifdef _TIMO define TIMO endif TIMO ifdef TIM1 define TIM1 Hendif TIM1 ifdef TIM2 define TIM2 Hendif TIM2 ifdef _TIM3 define TIM3 endif TIM3 else DEBUG ifdef _TIMO EXT TIM TypeDef endif TIMO ifdef TIM1 EXT TIM TypeDef endif TIM1 ifdef TIM2 EXT TIM TypeDef endif TIM2 ifdef _TIM3 EXT TIM TypeDef endif TIM3 endif APB2 BASE 0xB000 APB2 BASE 0xC000 TIM_TypeDef TIMO_ BASE TIM_TypeDef TIM1_ BASE TIM_TypeDef TIM2_ BASE TIM_TypeDef TIM3_ BASE TIMO TIM1 TIM2 TIM3 When debug mode is used TIM pointers are initialized in the file 71x_lib c ifdef _TIMO TIMO TIM TypeDef TIMO_ BASE endif ifdef TIM1 TIM1 TIM TypeDef TIM1_BASE endif ifdef TIM2 TIM2 TIM TypeDef TIM2_ BASE endif UM0097 Peripheral firmware overview ifdef _TIM3 TIM3 TIM_TypeDef TIM3_ BASE endif TIMO TIM_TypeDef TIMO_ BASE In debug mode _ T Mx must be defined in the file 77x_conf h to access the peripheral
157. les for PPP peripheral e g 71x_tim h Only lower case letters digits underscore and at most one suffix are allowed in filenames Constants used in one file are defined at the head of that file A constant used in more than one file should be defined in a header file All constants use upper case characters Registers are considered as constants Their names are in upper case letters and have in most case the same acronyms as in the STR71x reference manual document Variable names are preceded with a letter which indicates the type size of the variable b 8 bits w 16 bits d 32 bits p pointer The variables are in lower case and each word begins with an upper case e g bVariable pPointer Peripheral function names are preceded with the corresponding peripheral acronym in upper case followed by an underscore The first letter in each word is upper case e g EIC_CurrentIRQChannelValue Only one underscore is allowed in a function name to separate the peripheral acronym from the rest of the function name Functions declared locally don t have any prefix Functions used to initialize a peripheral are named PPP_lInit e g PCU_Init Functions for checking whether the specified PPP flag is set or not end with status e g TIM_FlagStatus Functions used to configure a peripheral functionality end with config e g WDG_PrescalerConfig Functions that configure a peripheral interrupt are called PPP_ITConfig Functions performing a specific a
158. mode 0x00040 12C_EVF Event flag 0x00080 I2C_GCAL General call slave mode flag 0x00100 12C_BERR Bus error flag 0x00200 12C_ARLO Arbitration lost flag 0x00400 12C_STOPF Stop detection slave mode 0x00800 I2C_AF Acknowledge failure flag 0x01000 I2C_ENDAD End of address transmission 0x02000 12C_STOP Generation of a Stop condition 0x08000 I2C_ACK Acknowledge enable 0x10000 12C_START Generation of a Start condition 0x20000 168 229 UM0097 Peripheral firmware overview Table 75 I2C_Tx_Status 12C events define define define define define define define define define define define define define I2C_EVENT_ SLAVE ADDRESS MATCHED I2C_EVENT SLAVE BYTE RECEIVED I2C_EVENT SLAVE BYTE TRANSMITTED I2C_EVENT MASTER MODE SELECT I2C_EVENT MASTER MODE SELECTED I2C_EVENT MASTER BYTE RECEIVED I2C_EVENT MASTER BYTE TRANSMITTED I2C_EVENT_ MASTER MODE ADDRESS10 I2C_EVENT SLAVE STOP DETECTED I2C_EVENT SLAVE ACK FAILURE I2C_BUS ERROR_DETECTED I2C_ARBITRATION_LOST I2C_SLAVE GENERAL CALL 12C transmission status The following enumeration defines the different types of message returned to define the status of transmission The 2C_Tx_Status enumeration is declared in the file 71x_i2c h typedef enum I2C_TX_NO I2C_TX_SB I2C_ TX AF I2C_TX ARLO I2C_TX BERR I2C_TX ADD OK I2C_TX DATA OK I2C_TX ONGOING I2C_Tx Status Table 75 describes C tra
159. n 3 12 1 on page 165 I2C_StringSend I2C_BufferSend I12C_BufferReceive removed Added new functions 2C_GetLastEvent and 12C_CheckEvent Added Section 12C events on page 169 In Section 3 13 Controller area network CAN Preconditions updated for CAN_SetBitrate on page 196 Preconditions updated for CAN_Init on page 202 Changed CAN_InvalidateAllMsgObj function name to CAN_SetUnusedAllMsgObj Changed CAN_IsMessageWaiting function name to CAN_GetMsgReceiveStatus Changed CAN_I sTransmitRequested function name to CAN_GetMsgTransmitRequestStatus Changed CAN_IsObjectValid function name to CAN_GetMsgValidStatus Changed CAN_IsinterruptPending function name to CAN_GetMsginterruptStatus Added new function CAN_UpdateMsgObj Added new function CAN_TransmitRequest Added new function CAN_GetFlagStatus Added new function CAN_GetTransmitErrorCounter Added new function CAN_GetReceiveErrorCounter In Section 3 15 External memory interface EMI Modified EMI_Config on page 224 Modified the define values in EMI Banks on page 223 Added a new function EMI_Enable on page 225 lt UM0097 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant
160. nARAH ROAD es MPTY6 MPTY7 MPTY8 xRSTR MPTY9 xRSTR MPTY10 UART_TypeDef Table 63 describes the UART structure fields Table 63 UART structure fields Register Description BR Baud Rate Register TxBUFR Transmit Buffer Register RxBUFR Receive Buffer Register CR Control Register IER Interrupt Enable Register SR Status Register GTR Guard Time Register TOR Time Out Register TxRSTR Tx FIFO Reset Register RxRSTR Rx FIFO Reset Register UM0097 Peripheral firmware overview The UARTs peripherals are declared in the same file define APB1 BASE 0xC0000000 define UARTO BASE APB1 BASE 0x4000 define UART1_BASE APB1 BASE 0x5000 define UART2_BASE APB1 BASE 0x6000 define UART3_ BASE APB1 BASE 0x7000 ifndef DEBUG ifdef _UARTO define UARTO UART_TypeDef UARTO BASE endif UARTO ifdef _UART1 define UART1 UART_TypeDef UART1_BASE endif UART1 ifdef _UART2 define UART2 UART_TypeDef UART2 BASE Hendif UART2 ifdef _UART3 define UART3 UART_TypeDef UART3_BASE Hendif UART3 else DEBUG ifdef _UARTO EXT UART_TypeDef UARTO endif UARTO ifdef _UART1 EXT UART_TypeDef UART1 Hendif UART1 ifdef _UART2 EXT UART_TypeDef UART2 endif UART2 ifdef _UART3 EXT UART_TypeDef UART3 endif UART3 endif When debug mode is used the UART pointers are initialized in the
161. nctions RCCU and _XTI must be defined in 71x_cont h file to make the RCCU and the XT functions accessible define _RCCU define XTI UM0097 Peripheral firmware overview Voltage regulator status The following enumeration defines the states of the voltage regulator The VR_Status enumeration is defined in the file 77x_pcu h typedef enum PCU _ STABLE PCU _ UNSTABLE PCU_VR_Status Table 5 describes the status of PCU voltage regulator Table 5 PCU voltage regulator status Regulator State Description PCU_STABLE The Main Voltage Regulator is stable and can be used to power the device PCU_UNSTABLE The Main Voltage Regulator is not yet stable PCU voltage regulators The following enumeration defines the power control unit voltage regulators The PCU_VR enumeration is declared in the file 71x_pcu h typedef enum PCU_MVR 0x0008 PCU_LPR 0x0010 PCU VR Table 6 describes the PCU voltage regulators Table 6 PCU voltage regulator descriptions Voltage Regulators Description PCU_MVR The Main Voltage Regulator PCU_LPR The Low Power Voltage Regulator WFI clocks The following enumeration defines the WFI mode clocks WFI_CLOCKS enumeration is declared in the file 71x_pcu h typedef enum WFI CLOCK2 16 WFI Ck AF WFI_CLOCKS Table 7 lists the different WFI Clocks Table 7 WEI clocks WFI Clocks Description WFI_CLOCK2_16 CLOCK2 16 clock is selected during LPWFI
162. ndif WDG Helse DEBUG ifdef WDG EXT WDG_TypeDef WDG endif WDG endif When debug mode is used WDG pointers are initialized in the file 71x_lib c ifdef _WDG WDG WDG_TypeDef WDG_ BASE endif In debug mode _ WDG must be defined in the file 77x_conf h to access the peripheral registers as follows define _WDG Some RCCU functions are called _RCCU must be defined in 71x_conf h file to make the RCCU functions accessible define _RCCU Ky 95 229 Peripheral firmware overview UM0097 3 8 2 Firmware library functions Table 44 enumerates the different functions of the WDG library Table 44 WDG library functions Function Name WDG_Enable Description Enable Watchdog Mode WDG_CntRefresh Refresh and update the WDG counter to avoid a system reset WDG_PrescalerContig Set the counter prescaler value Divide the counter clock by Prescaler 1 WDG_CntReloadUpdate Update the counter pre load value WDG_PeriodValueConfig Set the prescaler and counter reload value based on the time needed WDG_CntOnOffContig Start or stop the free auto reload timer to countdown WDG_ECI TConfig Enable or Disable the end of count interrupt WDG_ECFlagClear Clear the end of count flag WDG_ECStatus Return the end of count status WDG_Enable Function Name Function Prototype WDG_Enable void WDG Enable void Behavior Descr
163. ne Called Functions None Example This example illustrates how to configure some message objects so that they will not be used for i 16 1 lt 31 i CAN SetUnusedMsgObj i CAN_SetTxMsgObj Function Name Function Prototype CAN_SetTxMsgObj u32 CAN SetTxMsgObj u32 msgobj u32 idType FunctionalState RemoteEN Behavior Description Input Parameter 1 Input Parameter 2 Configures the message object as TX msgobj message object number from 0 to 31 idType message identifier type defined using the values described in CAN message identifier types on page 192 Input Parameter 3 RemoteEN If set to 1 the remote function is enabled Otherwise the remote function is disabled Output Parameter None Return Value 1 if interface is found O if no interface is available Required preconditions None Called Functions None 198 229 UM0097 Peripheral firmware overview Note Example This example describes how to configure a transmit message object Defines the transmit message object 0 with standard identifiers and disable the remote function CAN SetTxMsgObj 0 CAN STD _ID DISABLE When defining which message object number to use for TX or RX you must take into account the priority levels in the objects processing The lower number 0 has the highest priority and the higher number 31
164. ne Required preconditions None Called Functions None Example This example disables the PLL1 automatically when CK_AF is selected is selected as source clock puts the FLASH in PWD mode disables the MVR during STOP and WFI mode enables low power mode during WFI mode LPWI and selects CK_AF as source clock during LPWFI mode User code Set the MVR disabled and the FLASH in PWD mode during STOP mode PCU_LPModesConfig DISABLE DISABLE DISABLE ENABLE LPWFI_CK_ AF CK_AF is selected during LPWFI Enable Low power mode during WFI mode FLASH in powerdown during LPWFI and STOP modes MVREG is disabled during LPWFI and STOP modes PLL1 is disabled automatically when CK_AF is selected User code 25 229 Peripheral firmware overview UM0097 26 229 Go into STOP mode PCU_STOP User code Go into LPWFI mode PCU_WFI User code PCU_WFI Function Name PCU_WFI Function Prototype void PCU_WFI void Behavior Description This routine is used to enter WFI and LPWFI modes Input Parameter None Output Parameter None Return Value None Required preconditions PCU_LPModesContig function should be called to configure the WFI mode options Called Functions None Example 1 This example configures WFI mode Go into LPWFI mode PCU_WFI Example 2 This example configures
165. ng a port pin and writing data into the port pin The first section describes the data structure used in the GPIO firmware library The second section presents the GPIO firmware library functions 3 5 1 Data structures GPIO register structure The GPIO peripheral register structure GPIO_TypeDef is defined in the file 77x_map h as follows typedef struct vul6 PCO vul6 EMPTY1 vul6 PC1 vul6 EMPTY2 vul6 PC2 vul6 EMPTY3 Ky 65 229 Peripheral firmware overview UM0097 66 229 vul6 PD vul6 EMPTY4 GPIO TypeDef Table 29 describes the GPIO registers Table 29 GPIO registers Register Description PCO Port Configuration Register 0 PC1 Port Configuration Register 1 PC2 Port Configuration Register 2 PD Data Register GPIO peripheral is declared in the 71x_map h file as follows APB2 Base Address definition define APB2 BASE 0xE0000000 GPIOO and GPIO1 Base Address definitions define GPIOO BASE APB2 BASE 0x3000 define GPIO1 BASE APB2_ BASE 0x4000 define GPIO2_ BASE APB2_ BASE 0x5000 GPIOO and GPIO1 peripherals declaration ifndef DEBUG ifdef _GPIOO define GPIOO endif GPIOO ifdef _GPIO1 define GPIO1 endif GPIO1 ifdef GPIO2 define GPIO2 endif GPIO2 else DEBUG ifdef _GPIOO EXT GPIO TypeDef endif GPIOO ifdef GPIO1 EXT GPIO TypeDef endif GPIO1 ifdef GPIO2 EXT GPIO TypeDef
166. ng the example and how to make it work e 71x_conf h the header file to configure used peripherals and miscellaneous defines e 71x_it c the source file containing the interrupt handlers the function bodies may be empty if not used 71x_it h header file including all interrupt handler prototypes main c the example program All examples are independent from any software toolchain and running on STMicroelectronics STR71x EVAL board and can be easily tailored to any other hardware 11 229 Firmware library UM0097 2 1 2 Note 2 2 12 229 Library This directory contains all the subdirectories and files that form the core of the library inc sub directory contains the firmware library header files that do not need to be modified by the user 71x_type h Contains the common data types and enumeration used in all other files 71x_map h Contains the peripherals memory mapping and registers data structures 71x_lib h Main header file including all other headers 71x_ppp h one header file per peripheral contains the function prototypes data structures and enumeration sre sub directory contains the firmware library source files that do not need to be modified by the user 71x_ppp c one source file per peripheral contains the function bodies of each peripheral All library files are coded in Strict ANSI C and are independent from any firmware toolchain Project This directory co
167. nships Figure 2 Firmware library file structure application c Application Layer Software Layer 71x_type h y 71x_lib c 71x_it h y Hardware Layer Peripheral X For each peripheral a source code file 71x_ppp c and a header file 71x_ppp h are provided the 71x_ppp c file contains all the firmware functions required to use the peripheral e the 71x_ppp h file contains all the functions prototypes data structures data types and enumeration needed It contains also the inline functions code if any 13 229 Firmware library UM0097 Note 2 3 14 229 One memory mapping file 77x_map h is supplied for all peripherals This file contains all the register declarations for both development and debug modes The header file 71x_lib h includes all the peripheral header files This is the only file that has to be included in the user application to interface with the library You can modify the 71x_conf h to define which peripherals need to be included in the application to make it run Other files are also provided 71x_it h and 71x_it c These files contain all the firmware functions required to handle the STR71x interrupts If you want to handle an interrupt routine you should modify the appropriate function in the file 71x_it c the body of each function is empty by default Only the 71x
168. nsmission status messages lC transmission status messages Description No start condition is generated or detected so no transmission is I2C_TX_NO occurring I2C_TX_SB START condition is generated I2C_TX_AF Acknowledge Failure is detected I2C_TX_ARLO Arbitration Lost error is detected in multimaster mode l2C_TX_BERR Bus Error is detected 12C_TX_ADD_OK Slave address transmission is correctly completed in master mode or address matched in slave mode 12C_TX_DATA_OK Last transmitted data is correctly completed 12C_TX_ONGOING The current transmission is occurring 169 229 Peripheral firmware overview UM0097 I C reception status The following enumeration defines the different types of message returned to define the status of the reception The 2C_Rx_Status enumeration is declared in the file 77x_i2c h typedef enum I2C RX _NO I2C RX SB I2C RX AF I2C RX ARLO I2C RX BERR 2C RX ADD OK 2C RX DATA OK 2C_ RX ONGOING I2C_Rx Status Table 76 describes C reception status messages Table 76 C reception status messages 12C_Rx_Status Description I2C_Rx_NO No start condition is generated or detected so no reception is occurring 12C_Rx_SB START condition is generated I2C_Rx_AF Acknowledge Failure is detected I2C_Rx_ARLO Arbitration Lost error is detected in multimaster mode I2C_Rx_BERR Bus Error is detected I2C_Rx_ADD_OK Slave ad
169. ntains a standard template project program that compiles all library files and also all the user modifiable files needed to create a new project 71x_conf h The configuration header file with all peripherals defined by default 71x_it c The source file containing the interrupt handlers the function bodies are empty in this template 71x_it h header file including all interrupt handlers prototypes main c The main program body EWARM RVDK RVMDK RIDE For each toolchain usage refer to Readme txt file available in the same sub directory File description Several files are used in the firmware library Table 2 enumerates and describes the different files used in the firmware library Table 2 Source header file list Filename Description 71x_conf h You can enable or disable peripherals if you use the template and you can Parameter configuration file It should be modified by the user to specify several parameters to interface with the library before running any application also change the value of your external crystal oscillator value Using this file you can select to compile the library in DEBUG or RELEASE mode main c The main example program body UM0097 Firmware library Table 2 Source header file list continued Filename Description Peripheral interrupt functions file It is modified by you by including the interrupt functions code used in your application In
170. o enable the STOP Generation in the 2CO peripheral I2C OnoffConfig 12C0 ENABLE I2C_ STOPGenerate I2C0 ENABLE I2C_AcknowledgeConfig Function Name Function Prototype Behavior Description 12C_AcknowledgeConfig void I2C AcknowledgeConfig I12C_ TypeDef 1I2Cx FunctionalState NewState Enables or disables C acknowledge feature Input Parameter 1 Input Parameter 2 Output Parameter 12Cx specifies the 12C to be configured where x can be 0 or 1 NewSiate specifies the new status to set ENABLE enables the FC acknowledge feature DISABLE disables the FC acknowledge feature None Return Value Required Preconditions None PCx peripheral should be enabled Called Functions None Example This example illustrates how to enable the acknowledge feature in the 2CO peripheral I2C OnOffConfig I2C0 ENABLE I2C AcknowledgeConfig I2C0 ENABLE 174 229 lt UM0097 Peripheral firmware overview I2C_ITConfig Function Name Function Prototype 12C_ITConfig void I2C ITConfig I2C TypeDef I2Cx FunctionalState NewState Behavior Description Enables or disables C interrupt feature Input Parameter 1 12Cx specifies the 12C to be configured where x can be 0 or 1 Input Parameter 2 NewSiate specifies the new status to set ENABLE enables the C interrupt feature DISABLE disables the
171. ock division by 2 is enabled or not RCCU_MCLKConftig Configures the MCLK clock divider coefficient RCCU_PCLK1Config Configures the PCLK1 clock divider coefficient RCCU_PCLK2Contig Configures the PCLK2 clock divider coefficient RCCU_PLL1Conftig RCCU_PLL2Config Configures the PLL7 multiplication and divider parameters Configures the PLL2 multiplication and divider parameters RCCU_RCLKSourceContig Configures the RCLK clock source RCCU_RCLKClockSource Reads and returns the RCLK clock source RCCU_USBCLkConfig Configures the USB clock source RCCU_USBClockSource Reads and returns the USB clock source RCCU_FrequencyValue RCCU_ITConfig Computes any internal RCCU clock frequency Configures the RCCU interrupts RCCU_FlagStatus Checks the RCCU interrupt status RCCU_FlagClear Clears an RCCU flag RCCU_ResetSource Returns the source of the system reset RCCU_PLL1FreeRunningModeC onfig RCCU_PLL1Disable RCCU_PLL2Disable This routine is used to configures the PLL1 in free running mode This routine is used to switch off the PLL1 This routine is used to switch off the PLL2 RCCU_GenerateSWReset This routine generates software reset UM0097 Peripheral firmware overview RCCU_Div2Config Function Name RCCU_Div2Config Function Prototype void RCCU_Div2Config FunctionalState NewState This routine is used to enable
172. of the SWRES register with the value of the input parameter Input Parameter 1 APBx selects the APB bridge APB1 or APB2 New_Siatus the peripheral software reset new status to be set Input Parameter 2 ENABLE The peripheral is kept under reset DISABLE The peripheral is reset by the system wide reset Periph specifies the APB bridge peripheral Input Parameter 3 Refer to Bridge peripheral codes on page 49 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None One or more peripheral software resets can be enabled on the same APB bridge with a single APB_SwResetConfig function call One or more peripheral software resets can be disabled with another APB_SwResetConfig function call It is not possible to simultaneously enable and disable several peripheral software resets in a single APB_SwResetConfig function call Example This example illustrates how to configure the BSP O and the BSPI1 peripherals to be kept always under reset APB _SwResetConfig APB1 ENABLE BSPIO Periph BSPI1_ Periph Enhanced interrupt controller EIC The driver may be used for several purposes such as enabling and disabling interrupts IRQ and fast interrupts FIQ enabling and disabling individual RQ channels changing IRQ channel priorities saving and restoring context and installing RQ handlers
173. ompute the frequency Input Parameter Refer to RCCU internal clocks on page 33 for more details on the allowed values of this parameter Output Parameter None The frequency value of the specified clock in Hz of the internal clock Return Value passed in parameter Required preconditions None Called Functions None Example This example illustrates how get the MCLK clock frequency value u32 MCLK Freq MCLK Freq RCCU_FrequencyValue RCCU_MCLK RCCU_ITConfig Function Name RCCU_ITConfig void RCCU_ITConfig RCCU_Interrupts RCCU_IT Function Protot i angio RIO FunctionalState NewState Behavior Description This routine configures the specified RCCU interrupts RCCU_IT specifies the RCCU interrupt to configure Refer to RCCU Input Parameter 1 interrupts on page 34 for more details on the allowed values of this parameter NewSiate Indicates the new status of the RCCU interrupt Input Parameter 2 ENABLE to enable the specified interrupt DISABLE to disable the specified interrupt Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the PLL7 lock interrupt RCCU_ITConfig RCCU_PLL1 LOCK IT ENABLE 43 229 Peripheral firmware overview UM0097 RCCU_FlagStatus Function Name Function Prototype RCCU_FlagStatus FlagStatus RCCU_
174. onfigure cycle length and bus size Input Parameter 1 Bank_n selects the bank to be configured Refer to Data structures on page 222 for more details on the allowed values of this parameter Input Parameter 2 B_SIZE specifies the effective external bus size for an access to Bank n Refer to Data structures on page 222 for more details on the allowed values of this parameter Input Parameter 3 C_LENGTH specifies the number of wait states to be inserted in any read write cycle performed in Bank n Refer to Data structures on page 222 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None lt UM0097 Peripheral firmware overview EMI Enable Function Name EMI_Enable void EMI_ Enable u8 Bank_n FunctionalState Function Prototype NewState This routine is used for each bank to configure cycle length Behavior Description and bile sive Bank_n selects the bank to be enabled or disabled Input Parameter 1 Refer to Data structures on page 222 for more details on the allowed values of this parameter NewSiate specifies wether the EMI bank will be enabled or disabled ENABLE enable the specified EMI bank DISABLE disable the specified EMI bank Input Parameter 2 Output Parameter None Return Value None Required preconditions None
175. ons Example object 0 CAN_GetMsgTransmitRequestStatus Function Name Function Prototype CAN_GetMsgTransmitRequestStatus FlasgStatus CAN GetMsgTransmitRequestStatus u32 msgobj Behavior Description Tests the request status of a transmitted message Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value 1 if the corresponding message is requested to transmit else 0 Required preconditions A message must have been sent before Called Functions None 209 229 Peripheral firmware overview UM0097 Example This example illustrates how to test transmit request status of a message Send a message using object 0 CAN SendMessage 0 amp CanMsg Wait for the end of transmit request while CAN GetMsgTransmitRequestStatus 0 Now the message is being processed by the priority handler of the CAN cell and ready to be emitted on the bus CAN_GetMsginterruptStatus Function Name CAN_GetMsglnterruptStatus Function Prototype FlagStatus CAN GetMsgInterruptStatus u32 msgobj Behavior Description Tests the interrupt status of a message object Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value 1 if the corresponding message has an interrupt pending else 0 Required preconditions The interrupts must have
176. ontrol register Transmit Request CAN_MCR_EOB Message Control register End of Buffer lt UM0097 Peripheral firmware overview Wake up modes The following defines list wake up modes available on the CAN cell They are declared in the file can h enum CAN WAKEUP_ON EXT CAN WAKEUP_ON CAN Fi Table 85 describes the CAN wake up modes Table 85 CAN wake up modes Wake up mode Description Wake up on external event AN_WAKEUP_ON_EXT CAN_ The CAN cell is woken up by a falling edge on the I O port 2 8 Wake up on CAN bus activity CAN_WAKEUP_ON_CAN The CAN cell is woken up by a dominant state of the CAN bus i e falling edge on the CAN RX pin port 1 11 CAN message structure The structure that contains message data is defined as follows and is declared in the file can h typedef struct int IdType u32 Id u8 Dic u8 Data 8 canmsg Table 86 describes the CAN message structure parameters Table 86 CAN message structure parameters CAN message parameter Description IdType Identifier type Id Identifier value Dic Data Length Code Datal Array containing data values 191 229 Peripheral firmware overview UM0097 3 13 2 192 229 CAN message identifier types The different CAN message identifier types are listed below and are declared in the file can h enum CAN STD ID CAN EXT _ID Table 87 describes the CAN
177. onvention Each flag label is defined as a byte divided into two parts The 3 MSB bits are allocated to identify the register to which the flag belongs it is possible to number registers from 0 to 7 The 5 LSB bits are allocated to identify the flag position in the register to which it belongs it is possible to number flags from 0 to 31 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Register Bit position The following gives an example of flag definitions typedef enum APB APBT 0x26 APB OUTM 0x25 APB ABORT 0x21 APB ABTEN 0x49 APB OMnRW 0x68 APB TOnRW 0x88 APB Flags 10 229 ky UM0097 Firmware library 2 2 1 Note ky Firmware library Package description The firmware library is supplied in one single zip package The extraction of the zip file will give the one folder STR71xFWLib FWLib containing the following sub directories Figure 1 Firmware library directory structure FwLib 5 examples adel2 apb bspi can emi gpio 46 i2c peu recu 45 rte 4 tim uart wdg 5 sti library inc sic project EWARM RIDE RVDK RVMDK B 71x_cont h E 71xite E 7x ith B main c Examples This directory contains for each peripheral sub directory the minimum set of files needed to run a typical example on how to use a peripheral Readme txt a brief text file describi
178. or equal to 1 RCCU_Div_2 Division factor equal to 2 RCCU_Div_3 Division factor equal to 3 RCCU_Div_4 Division factor equal to 4 RCCU_Div_5 Division factor equal to 5 RCCU_Div_6 Division factor equal to 6 RCCU_Div_7 Division factor equal to 7 USB clock source The following enumeration defines the USB clock sources USB_Clocks enumeration is defined in the file 71x_rccu h typedef enum RCCU_PLL2 Output 0x01 RCCU_USBCK 0x00 RCCU_USB_ Clocks Table 16 describes the USB clock sources Table 16 USB clock sources USB Clock Source Description RCCU_PLL2_Output Select the PLL2 output as USB clock source RCCU_USBCK Select the USBCK as USB clock source RCCU internal clocks The following enumeration defines the RCCU internal clocks RCCU_Clocks enumeration is defined in the file 77x_rccu h typedef enum RCCU_CLK2 RCCU_RCLK RCCU_MCLK RCCU_PCLK2 RCCU_PCLK1 RCCU Clocks Ky 33 229 Peripheral firmware overview UM0097 Table 17 describes the RCCU internal clocks Table 17 RCCU internal clocks RCCU Clock Description RCCU_CLK2 a ae to the programmable Phase Locked Loop RCCU_RCLK Clock Output from RCCU RCCU_MCLK Main system clock to ARM amp memory RCCU_PCLK1 APB1 peripheral clock RCCU_PCLK2 APB2 peripheral clock RCCU interrupts The following enumeration defines the RCCU interrupt source RCCU_Interrupts enumeration is defined in the file 71x_rccu h ty
179. page 145 for details on the allowed values of this parameter Input Parameter 2 GuardTime the guard time value Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to configure the UARTO guard time Configure the guard time UART GuardTimeConfig UARTO OxFF lt 153 229 Peripheral firmware overview UM0097 154 229 UART_RxConfig Function Name Function Prototype UART_RxConfig void UART_RxConfig UART_TypeDef UARTx FunctionalState NewState Behavior Description This function enables or disables the selected UART data reception Input Parameter 1 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 NewState specifies whether the reception is enabled or disabled ENABLE enables reception DISABLE disables reception Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to enable reception on the UARTO Enable reception UART_RxConfig UARTO ENABLE UART_OnOffConfig Function Name Function Prototype Behavior Description UART_OnOffConfig void UART_OnoOffConfig UART TypeDef UARTx FunctionalState NewState
180. pedef enum RCCU_PLL1 LOCK IT RCCU_CKAF IT RCCU_CK2 16 IT RCCU_STOP IT RCCU_Interrupts Table 18 describes the RCCU interrupts Table 18 RCCU interrupts RCCU Interrupt Description RCCU_PLL1_LOCK_IT PLL1 lock interrupt RCCU_CKAF_IT Clock alternate function switching interrupt RCCU_CK2_16_IT Clock2 16 switching interrupt RCCU_STOP_IT Stop interrupt RCCU flags The following enumeration defines the RCCU flags RCCU_Flags enumeration is defined in the file 71x_rccu h typedef enum 34 229 RCCU_PLL1_ LOCK 0x0002 RCCU_CKAF ST 0x0004 RCCU_PLL1_ LOCK I 0x0800 RCCU_CKAF I 0x1000 RCCU_CK2_ 16 I 0x2000 RCCU_STOP_I 0x4000 RCCU_Flags UM0097 Peripheral firmware overview Table 19 describes the RCCU flags Table 19 RCCU flags RCCU flag Description RCCU_PLL1_LOCK PLL1 lock interrupt pending flag RCCU_CKAF_ST CK_AF Status RCCU_PLL1_LOCK_I PLL1 Lock Interrupt pending bit RCCU_CKAF_ Clock alternate function switching interrupt pending flag RCCU_CK2_16_ Clock2 16 switching interrupt pending flag RCCU_STOP_ Stop Interrupt pending bit Reset sources The following enumeration defines the RCCU reset sources RCCU_ResetSources enumeration is defined in the file 71x_rccu h typedef enum RCCU_ExternalReset 0x00000000 RCCU_SoftwareReset 0x00000020 RCCU_WDGReset 0x00000040 RCCU_RTCAlarmReset 0x00000080 RCCU_LVDReset
181. pheral firmware overview UM0097 EIC_CurrentFlQChannelValue Function Name EIC_FIlQChannelValue Function Prototype FIQChannel TypeDef EIC_CurrentFIQChannelValue void Behavior Description This function gets and return the current served FIQ channel number Input Parameter None Output Parameter None The current served FIQ channel number Return Value Refer to FIQ channel enumeration on page 55 for details on allowed values of FIQChanne parameter Required Preconditions None Called Functions None See also EIC_FlQPendingBitClear on page 65 Note When you use both Timer 0 and Watchdog Timer FIQ interrupts in your application this function is required in the FIQ interrupts service routine for software prioritization and to define which FIQ pending bit you have to clear Example This example shows how to use the E C_FlQChannelValue function in the FIQ interrupts service routine to define the source of F Q interrupts void FIQ Handler void switch EIC _ CurrentFIQChannelValue case TOTIMI_FIQChannel TIMO gt SR amp 0x2000 Clear the Timer 0 interrupt flag Clear the corresponding FIQ pending bit EIC FIQPendingBitClear TOTIMI_ FIQChannel Tiana eee Sob Rees User code break case WDG FIQChannel WDG gt SR 0x0000 Clear the WDG interrupt flag Clear the corresponding FIQ pending bit EIC FIQPendingBitClear WDG FIQChannel Piathe dk
182. ple illustrates how to set the PLL1 multiplication factor to 20 and the divider factor to 5 RCCU_PLL1Config RCCU_PLL1_Mul_20 RCCU Div 5 lt 39 229 Peripheral firmware overview UM0097 RCCU_PLL2Config Function Name Function Prototype RCCU_PLL2Config void RCCU_PLL2Config RCCU_PLL2 Mul New Mul RCCU_PLL_ Div New Div u32 HCLK Clock Behavior Description Configures the PLL2 division and multiplication factors Input Parameter 1 New_Mul the PLL2 clock multiplication factor Refer to PLL2 multiplication factors on page 32 for more details on the allowed values of this parameter Input Parameter 2 New_Div the PLL2 clock division factor Refer to PLL division factors on page 32 for more details on the allowed values of this parameter Input Parameter 3 HCLK_Clock the clock value present on HCLK pin in Hz Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to set the PLL2 multiplication factor to 28 and the divider factor to 7 RCCU_PLL2Config RCCU_PLL2 Mul_28 RCCU Div 7 4000000 RCCU_RCLKSourceConfig Function Name Function Prototype Behavior Description Input Parameter RCCU_RCLKSourceConfig void RCCU_RCLKSourceConfig RCLK_ Clocks New_Clock This routine selects the clock source for the RCLK New_Clock the RCLK clock source Refer to RCLK
183. poses including APB bridges configuration and error status reporting The first section describes the data structure members used in the APB firmware library The second section presents the APB firmware library functions 3 3 1 Data structures APB register structure The APB peripheral register structure APB_TypeDef is defined in the 71x_map h file as follows typedef struct vu32 CKDIS vu32 SWRES APB TypeDef Table 22 presents the APB registers Table 22 APB registers Register Description CKDIS APB Clock Disable Register SWRES APB Software Reset Register ky 47 229 Peripheral firmware overview UM0097 The APB bridges are declared in the same file define APB1 BASE define APB2 BASE ifndef DEBUG ifdef APB1 define APB1 endif APB1 ifdef APB2 define APB2 endif APB2 else DEBUG ifdef _APB1 EXT APB TypeDef endif APB1 ifdef APB2 EXT APB TypeDef endif APB2 endif 0xC0000000 OxE0000000 APB TypeDef APB1 BASE 0x10 APB TypeDef APB2 BASE 0x10 APB1 APB2 When debug mode is used APB pointer is initialized in 71x_lib c file ifdef APB1 ifdef _APB1 APB1 APB TypeDef APB1 BASE 0x10 endif endif _APB1 ifdef _APB2 APB2 APB TypeDef APB2 BASE 0x10 endif APB2 In debug mode the following macros are defined in 71x_cont h file e _APBis defined to include the APB libra
184. pth of the receive FIFO to 5 words BSPI_ RcFifoDepth BSPIO 5 130 229 UM0097 Peripheral firmware overview BSPI_8bLEn Function Name Function Prototype BSPI_8bLEn void BSPI_ 8bLEn BSPI TypeDef BSPIx FunctionalState NewState Behavior Description Sets the word length of the receive FIFO and transmit data registers to either 8 or 16 bits Input Parameter 1 BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 Input Parameter 2 NewState specifies if the word length is 8 or 16 bits ENABLE enables setting the word length to 8 bits DISABLE disables setting the word length to 8 bits the word length will be set to 16 bits Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to set word length to16 bits for the BSP O peripheral BSPI_ 8bLEn BSPIO DISABLE 131 229 Peripheral firmware overview UM0097 132 229 BSPI_CIkFEdge Function Name Function Prototype BSPI_CIkFEdge void BSPI ClkFEdge BSPI TypeDef BSPIx FunctionalState NewState Behavior Description Enables capturing the first data sample on the first edge of SCK or on the second edge Input Parameter 1 BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 Input Parameter 2 NewState specifies whether cap
185. ption on page 11 updated System file list updated in Section 2 2 on page 12 Modified Section 3 1 Power control unit PCU Example code updated for WFI clocks on page 19 Description table updated for WFI clocks on page 19 Low power modes section removed Renamed the following file names ppp c by 71x_ppp c ppp h by 71x_ppp h adc12 h by 71x_adc12 h pcu h by 71x_pcu h rccu h by 71x_recu h emi h by 71x_emi h apb h by 71x_apb h bspi h by 71x_bspi h can h by 71x_can h gpio h by 71x_gpio h i2c h by 71x_i2c h rtc h by 71x_rtc h tim h by 71x_tim h uart h by 71x_uart h wdg h by 71x_wdg h and xti h by 71x_xti h Removed functions PCU_WFlEnter and PCU_LPMEnter Added functions PCU_LPModesConfig PCU_WFI PCU_STOP PCU_STANDBY PCU_FlashBurstCmd In Section 3 2 Reset and clock control unit RCCU Example code updated for RCLK clock source on page 31 New section added PLL1 free running modes on page 35 RCCU_PLL1FreeRunningModeContig RCCU_PLL 1Disable RCCU_PLL2Disable PCU_320SCCmd added Renamed function RCCU_PCLK to RCCU_PCLk2 Renamed function RCCU_FCLK to RCCU_PCLK1 Renamed function RCCU_RTC_CLOCK to RCCU_CK_AF Changed function RCCU_PCLKConfig to RCCU_PCLK2Config Renamed function RCCU_FCLKConfig to RCCU_PCLK1Config Added new function RCCU_PLL1FreeRunningModeConftig Added new function RCCU_PLL1Disable Added new function RCCU_PLL2Disable Added new function RCCU_GenerateSWReset Renamed WFI_EXTERNAL to WFI_Ck_AF Modified Section 3 9 Timer TIM
186. put Parameter None Return Value None Required preconditions The selected UART must be properly configured and enabled Called Functions None UART_Config on page 149 ee UART_OnOffContig on page 154 UM0097 Peripheral firmware overview Example This example illustrates how to send several 8 bit bytes using the UARTO define DATA LENGTH 16 u8 pDataToSend DATA LENGTH A B C D E F nat H VE Ure eee RY ia MM EN O p UART DataSend UART0 pDataToSend DATA LENGTH UART_9BitDataSend Function Name UART_9BitDataSend void UART_9BitDataSend UART_TypeDef UARTx Function Protot pices anes ul6 Data u8 DataLength Behavior Description This function sends several 9 bit data using the selected UART UARTx the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 1 Input Parameter 2 Data the bytes start address Input Parameter 3 DataLength the data bytes number Output Parameter None Return Value None Required preconditions The selected UART must be properly configured and enabled Called Functions None See als UART_Config on page 149 UART_OnOffConfig on page 154 Example This example illustrates how to send several 9 bit bytes using the UARTO define DATA LENGTH 16 ul6 pwDataToSend DATA LENGTH 0x0101 0x0002 0
187. quired preconditions None Called Functions None Example This example illustrates how to enable the RTC second interrupt Enable the global interrupt RTC_ITConfig RTC_GIT ENABLE Enable the Second interrupt RTC_ITConfig RTC_SIT ENABLE 91 229 Peripheral firmware overview UM0097 RTC_ITStatus Function Name RTC_ITStatus Function Prototype FunctionalState RTC_ITStatus RTC_IT Xrtcit This routine checks whether the specified RTC interrupt is enabled or Benavior Description not It reads and returns the CRH flags status Xrtcit Designates an RTC interrupts Refer to RTC interrupts on Input Parameter page 86 for more details on the allowed values of this parameter Output Parameter None The interrupt status Return Value ENABLE the corresponding interrupt is enabled DISABLE the corresponding interrupt is disabled Required preconditions None Called Functions None Example This example illustrates how to check the alarm interrupt status test if the Alarm interrupt is enabled if RTC_ITStatus RTC_AIT RTC_ITClear Function Name RTC_ITClear Function Prototype void RTC_ITClear RTC_IT Xrtcit Behavior Description This routine is used to clear the specified interrupt pending request Xrtcit designates an ATC interrupt Input Parameter Refer to RTC interrupts on page 86 for more
188. r disabled where x can be 0 or 1 Input Parameter 2 NewSiate specifies the new status to set ENABLE enables the 1 C peripheral DISABLE disables the 1 C peripheral Output Parameter None Return Value None Required Preconditions I O ports should be configured in their reset states Called Functions None Example This example illustrates how to enable and disable the 2C0 interface I2C OnoffConfig I2C0 ENABLE user code I2C OnoOffConfig 12C0 DISABLE I2C_GeneralCallConfig Function Name Function Prototype I2C_GeneralCallConfig void I2C GeneralCallConfig I12C_ TypeDef 1I2Cx FunctionalState NewState Behavior Description Enables or disables I2C general call option Input Parameter 1 12Cx specifies the 12C to be configured where x can be 0 or 1 Input Parameter 2 NewState specifies the new status to set ENABLE enables the 1 C general call option DISABLE disables the 1 C general call option Output Parameter None Return Value None Required Preconditions P Cx peripheral should be enabled Called Functions None UM0097 Peripheral firmware overview Example This example illustrates how to enable the General Call option I2C OnoffConfig 12C0 ENABLE I2C GeneralCallConfig I2C0 ENABLE I2C_ STARTGenerate Function Name 12C_STARTGen
189. r to do it Input Parameter 3 pCanMszg pointer to the canmsg structure where the received message is copied Refer to CAN message structure on page 191 for more details Output Parameter None Return Value 1 if reception was OK else 0 no message pending Required preconditions The message object must have been set up properly Called Functions CAN_GetMsgReceiveStatus on page 209 Example This example illustrates how to receive a single message canmsg CanMsg Receive a message in the object 0 and ask for release if CAN _ReceiveMessage 0 TRUE amp CanMsg Check or copy the message contents else Error handling UM0097 Peripheral firmware overview CAN_WaitEndOfTx Function Name Function Prototype CAN_WaitEndOfTx void CAN WaitEndOfTx void Behavior Description Waits until current transmission is finished This function should be called between two consecutive transmissions to ensure the latest frame has been completely emitted on the bus and therefore cannot be aborted anymore Input Parameter None Output Parameter None Return Value None Required preconditions A message must have been sent before Called Functions None Example This example illustrates how to wait for the end of transmission of the latest frame sent Send consecutive data
190. re overview UM0097 3 5 2 68 229 Table 30 GPIO pin modes continued Pin mode Description GPIO_OUT_PP Push Pull Output GPIO_AF_OD Open Drain Output Alternate Function GPIO_AF_PP Push Pull Output Alternate Function Common parameter values Port pin values Table 31 shows the Port_Pins parameter value for each pin Table 31 Port_Pins parameter value Port_Pin value Corresponding pin 0x0001 Port pin number 0 0x0002 Port pin number 1 0x0004 Port pin number 2 0x0008 Port pin number 3 0x0010 Port pin number 4 0x0020 Port pin number 5 0x0040 Port pin number 6 0x0080 Port pin number 7 0x0100 Port pin number 8 0x0200 Port pin number 9 0x0400 Port pin number 10 0x0800 Port pin number 11 0x1000 Port pin number 12 0x2000 Port pin number 13 0x4000 Port pin number 14 0x8000 Port pin number 15 GPIOx values Table 32 shows the allowed values of GP Ox variable Table 32 GPIOx values GPIOx Description GPIOO To select GPIO 0 GPIO1 To select GPIO 1 GPIO2 To select GPIO 2 lt UM0097 Peripheral firmware overview 3 5 3 Firmware library functions Table 33 enumerates the different functions of the GPIO library Table 33 GPIO library functions Function Name Description Configures the selected GPIO I O pins according to the input GPIO_Contig passed in parameter GPIO_BitRead Returns a port pin value depend
191. rsionValue Function Name ADC12_ConversionValue ul6 ADC12_ ConversionValue ADC12_ Channels Function Prototype ADC12 Channel This functions gets the conversion result from the data register Behavior Description of the specified channel It returns the value of the corresponding data register ADC12_Channel specifies the channel to get its result of Input Parameter conversion Refer to ADC12 channels on page 215 for more details on the allowed values of this parameter Output Parameter None Return Value The result of conversion of the specified channel The conversion of the selected channel was finished and no Required preconditions ov rr rdetected Called Functions None See also ADC12_FlagStatus on page 221 Example This example shows how to get the result of conversion It tests whether the end of conversion has been reached or not ul6 data Test if the conversion of the channel 3 has finished while ADC12_FlagStatus ADC12_DA3 RESET Test the overrun bit if ADC12_FlagStatus ADC12_OR RESET Get the conversion result data ADC12_ ConversionValue ADC12_ CHANNEL3 ADC12_ ConversionStop 220 229 UM0097 Peripheral firmware overview ADC12_FlagStatus Function Name ADC12_FlagStatus Function Prototype FlagStatus ADC12 FlagStatus ADC12_ Flags flag Behavior Description This function is used to test the status of the sp
192. rupts are disabled All pending bits are cleared Behavior Description The current priority level set to zero IVR register initialized with the upper half of the load PC instruction op code All S R registers are initialized with the offset to the corresponding IRQ routine vector Input Parameter None Output Parameter None Return Value None Required Preconditions None Called Functions None Note The EIC is initialized in the 71x_init s before entering the C code so you don t need to initialize the EIC after a system reset This function is required if a software reset is performed Example This example shows how to initialize the interrupt controller Initialize the interrupt controller EIC Init 57 229 Peripheral firmware overview UM0097 EIC_IRQConfig Function Name EIC_IRQConfig Function Prototype void EIC_IRQConfig FunctionalState NewState Behavior Description Enables or Disables IRQ interrupts NewSiate specifies whether the RQ is enabled or disabled Input Parameter ENABLE enables the IRQ interrupt DISABLE disables the RQ interrupt Output Parameter None Return Value None Required Preconditions None Called Functions None See also EIC_FIlQConfig on page 58 Example This example shows how to enable the ARQ interrupts Enable IRQ interrupts EIC IRQConfig ENABLE EIC_FIQConfig
193. ry e _APB1and_APB2 are defined to access the corresponding peripheral registers define APB define _APB1 define _APB2 48 229 UM0097 Peripheral firmware overview Bridge peripheral codes Table 23 enumerates the various peripherals and their defined codes depending on which bridge they belong Table 23 Bridge peripheral codes Peripheral Bridge Code definition 12CO_Periph 0x0001 12C1_Periph 0x0002 UARTO_Periph 0x0008 UART1_Periph 0x0010 UART2_Periph 0x0020 UART3_Periph 0x0040 USB_Periph Cena 0x0080 CAN_Periph 0x0100 BSPIO_Periph 0x0200 BSPI1_Periph 0x0400 HDLC_Periph 0x2000 APB1_ALL_Periph 0x27FB XTI_Periph 0x0001 GPIOO_Periph 0x0004 GPIO1_Periph 0x0008 GPIO2_Periph 0x0010 ADC12_Periph 0x0040 CKOUT_Periph 0x0080 TIMO_Periph APB2 Bridge 0x0400 TIM1_Periph 0x0200 TIM2_Periph 0x0400 TIM3_Periph 0x0800 RTC_Periph 0x1000 EIC_Periph 0x8000 APB2_ALL_Periph 0x5FDD Each peripheral code is defined in the 71x_apb h file The example below illustrates the definition of 2CO peripheral code define I2CO Periph 49 229 Peripheral firmware overview UM0097 3 3 2 3 3 3 Note 50 229 1 Common parameter values APBx values Table 24 shows the allowed values of the APBx variable Table 24 APBx values APBx Description APB1 Selects APB1 bri
194. s tet 31 PELI multiplication factors oeaan eens 32 PLL2 multiplication factors sos eera eee 32 PLL division factors 2 reri nwt eeraa Pad nea ed pee toad ce eee ade de easier 33 USB clock SOUrCES 0 ttt eee 33 RCCU internal clocks r ratiuni n eaa aar K E a D aE E EE E 34 RCCUINIEMUP S iia isea See eh da ad ana me aon dee E EE A E oai ee ee 34 ACCU flags i 6 fhe g a iaai E Ei a e ieh EE E a ieie aa i hae araa e oe 35 RCCU reset SourceS 2 tet 35 PLL1 free running MOdeS 0 ce nia EE Een a 36 APB registos 5 ose eedan Yi Sa id nual we Stig a a ee ge ed Bena EEA ee Hele 47 Bridge peripheral codes 2 eee eee 49 APBX VAOS vet cnet ewan a AA a et ede Bete ee ee beeen ee ee Boe 50 APB library functions 0020 0 ete 50 EIC peripheral registers 0 0 0 0 cece eee 53 IRQChannel values 0 0 00 eee 55 FIQChannel valueS 0 0 6 cee 56 GPIO regIStErS vein reide srania ia de de heed Geen taeda yeh bos het aaa ds 66 GPIO pin modes 1 1 unanunua aa 67 Port_Pins parameter value 1 eee ee 68 GPIOX ValUGS bio a yoii ina dened eat gue ah ace Sac mea ee ee ae eee ek Be 68 GPIO library functions 000 00 cee eae 69 XTIVOGISICNS is ascends ae en nh eae oY Aa ae eR baa a a ee ee eG ne eng ees 76 XTLMOGOS 22 seca eee ea ae ee EEEE E Maeda ares waa ee eae eae 77 Trigger edge polarity values 6 tees 77 Lines VAlUCS estenensa ee ee ee eo ee gabon Bao bee Ge ee wat 77 XTI library functions 0
195. s Refer to BSPI flags on page 122 for more details on the allowed values of this parameter Output Parameter None Return Value The status of the specified flag SET if the tested flag is set RESET if the tested flag is reset Required Preconditions None Called Functions None 134 229 UM0097 Peripheral firmware overview Example This example illustrates how to test if the BSPIO TFE Transmit FIFO Empty is set FlagStatus bStatus1 Get the status of the BSPI transmit Fifo not empty flag bStatusl BSPI FlagStatus BSPIO BSPI TFE BSPI_WordSend Function Name Function Prototype BSPI_WordSend void BSPI WordSend BSPI TypeDef BSPIx ul6 Data Description Transmits a single Word Input Parameter 1 BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 Input Parameter 2 Data the word which will be transmitted Example Output Parameter None Return Value None Required Preconditions None Called Functions None This example illustrates how to use the BSPI_WordSend function to send a word Ox5D in the Transmit a single Word BSPI_ WordSend BSPIO Ox5D 135 229 Peripheral firmware overview UM0097 136 229 BSPI_ByteBufferSend Function Name Function Prototype BSPI_ByteBufferSend void BSPI ByteBufferSend BSPI TypeDef BS
196. s continued Function Name CAN_SetRxMsgObj Description Configures the message object as RX CAN_SetUnusedAllMsgObj Configures all the message objects as unused CAN_Init Initializes the CAN cell and set the bitrate CAN_ReleaseMessage Releases the message object CAN_ReleaseTxMessage Releases the transmit message object CAN_ReleaseRxMessage Releases the receive message object CAN_UpdateMsgObj Updates the message object CAN_TransmitRequest Requests the transmission of a message object A data or remote frame is sent CAN_SendMessage Starts transmission of a message CAN_ReceiveMessage Gets the message if received CAN_WaitEndOfTx Waits until current transmission is finished CAN_BasicSendMessage Starts transmission of a message in BASIC mode CAN_BasicReceiveMessage Gets the message in BASIC mode if received CAN_GetMsgReceiveStatus Tests the waiting status of a received message CAN_GetMsgTransmitRequestSt atus Tests the request status of a transmitted message CAN_GetMsginterruptStatus CAN_GetMsgValidStatus Tests the interrupt status of a message object Tests the validity of a message object ready to use CAN_GetFlagStatus Returns the state of the CAN flags TXOK RxOK EPASS EWARN and BOFF CAN_GetTransmitErrorCounter Gets the CAN transmit Error counter CAN_GetReceiveErrorCounter
197. s used ADC 12 pointer is initialized in 71x_lib c file void debug void ifdef _ADC12 ADC12 ADC12 TypeDef ADC12 BASE endif _ADC12 In debug mode _ADC12 must be defined in 71x_confh file to access the peripheral registers as follows define ADC12 lt 214 229 UM0097 Peripheral firmware overview When ACCU functions are called RCCU must be defined in 71x_conf h file to make the RCCU functions accessible define _RCCU The ADC12 function accede to the Bootconf Register defined in the PCU structure _PCU must be defined in 71x_conf h file to make the PCU register accessible define _PCU Modes of conversion The following enumeration defines the modes of conversion ADC 12_Modes enumeration is defined in the file 71x_adc12 h typedef enum ADC12_ SINGLE ADC12_ROUND ADC12 Modes Table 91 presents the ADC 12 conversion modes Table 91 ADC12 conversion modes Type Description ADC12_SINGLE Enables the single channel mode of conversion ADC12_ROUND Enables the round robin multi channel mode of conversion ADC12 channels The following enumeration defines the ADC 12 channels ADC 12_Channels enumeration is defined in the file 77x_adc12 h as follows typedef enum ADC12_ CHANNELO 0x00 ADC12_ CHANNEL1 0x10 ADC12_ CHANNEL2 0x20 ADC12_ CHANNEL3 0x30 ADC12_ Channels Table 92 defines the ADC 12 channels Table 92 ADC12 channels
198. s used for transmission Called Functions None Example This example illustrates how to release a transmit message object Release the transmit message object 0 CAN ReleaseTxMessage 0 CAN_ReleaseRxMessage Function Name Function Prototype CAN_ReleaseRxMessage void CAN ReleaseRxMessage u32 msgobj Behavior Description Releases the receive message object Input Parameter Output Parameter Return Value msgobj message object number from 0 to 31 None None Required preconditions It is assumed that message interface 1 is always used for reception Called Functions None Example This example illustrates how to release a receive message object Release the receive message object 0 CAN ReleaseTxMessage 0 203 229 Peripheral firmware overview UM0097 CAN_UpdateMsgObj Function Name Function Prototype CAN_UpdateMsgObj u32 CAN UpdateMsgObj u32 msgobj canmsg pCanMsg Behavior Description Updates the message object passed in parameter with the pCanMsg Input Parameter 1 msgobj message object number from 0 to 31 Input Parameter 2 pCanMsg pointer to the canmsg structure that contains the data to transmit ID type ID value data length data values Refer to CAN message structure on page 191 for more details Output Parameter None Return Value 1 if interf
199. set Function Name Function Prototype UART_FifoReset void UART_FifoReset UART_ TypeDef UARTx UARTFIFO TypeDef FIFO Behavior Description This function resets the Rx and the Tx FIFOs of the selected UART Input Parameter 1 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 FIFO Selects the FIFO to reset Refer to FIFOs on page 142 for details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None 151 229 Peripheral firmware overview UM0097 Example This example illustrates how to reset the UARTO receive FIFO Reset the UARTO receive FIFO UART_FifoReset UARTO UART_RxXFIFO UART_LoopBackConfig Function Name Function Prototype UART_LoopBackConfig void UART_LoopBackConfig UART_TypeDef UARTx FunctionalState NewState Behavior Description This function enables or disables the loop back mode of the selected UART Input Parameter 1 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 NewSiate specifies whether loop back is enabled or disabled ENABLE enables Loop back DISABLE disables
200. sgobj canmsg pCanMsg Behavior Description Starts transmission of a message Input Parameter 1 msgobj message object number from 0 to 31 pCanMszg pointer to the canmsg structure that contains the data to Input Parameter 2 transmit ID type ID value data length data values Refer to CAN message structure on page 191 for more details Output Parameter None Return Value 1 if transmission was OK else 0 Required preconditions The message object must have been set up properly CAN _UpdateMsgObj CAN TransmitRequest Called Functions Example This example illustrates how to send a single message canmsg CanMsg CAN STD ID 0x111 4 0x10 0x20 0x40 0x80 Send a standard ID data frame containing 4 data values CAN SendMessage 0 amp CanMsg 205 229 Peripheral firmware overview UM0097 206 229 CAN_ReceiveMessage Function Name Function Prototype CAN_ReceiveMessage u32 CAN ReceiveMessage u32 msgobj bool release canmsg pCanMsg Behavior Description Gets the message if received Input Parameter 1 msgobj message object number from 0 to 31 Input Parameter 2 release message release indicator it can take the following values TRUE the message object is released at the same time as it is copied from message RAM then it is free for next reception FALSE the message object is not released it is to the calle
201. smissionStatus Checks for any error during transmission and returns the error status It also checks for any pending requests 12C_ByteReceive Returns the most recently received byte 12C_ReceptionStatus Checks the completion of reception and returns the reception status 12C_ErrorClear Clears any error flags 12C_GetStatus Reads the status registers of the specified 12C 12C_GetLastEvent Gets the last 12C event that has occurred 12C_CheckEvent Checks whether the last 12C event is equal to the one passed as parameter I2C_Init Function Name Function Prototype 12C_Init void I2C Init I2C TypeDef I2Cx Behavior Description Input Parameter Initializes C peripheral control and registers to their default reset values 12Cx specifies the 12C to be initialized where x can be 0 or 1 Output Parameters None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to initialize the 2CO register to their reset value I2C Init 12C0 171 229 Peripheral firmware overview UM0097 172 229 I2C_OnOffConfig Function Name Function Prototype 12C_OnOffConfig void I2C OnoOffConfig I12C TypeDef I2Cx FunctionalState NewState Behavior Description Enables or disables the I2C peripheral Input Parameter 1 12Cx specifies the 12C to be enabled o
202. st be defined in 71x_confh file to include the EIC library define _EIC IRQ channel enumeration The following enumeration defines the different values of the RQ channels IRQChannel_TypeDef enumeration id defined id eic h file typedef enum IRQChannel TypeDef TOTIMI_ IRQChannel FLASH TRQChannel RCCU_IRQChannel RTC_TRQChannel WDG_TRQChannel XTI_TRQChannel USBHP_IRQChannel I2COITERR_IRQChannel I2C1ITERR_IRQChannel UARTO_ IRQChannel UART1_IRQChannel UART2_TIRQChannel UART3_ IRQChannel SPIO IRQChannel SPI1 IRQChannel I2CO_TRQChannel I2C1_TRQChannel CAN _IRQChannel ADC_IRQChannel HDLC_TIRQChannel USBLP_IRQChannel TOTOI IRQChannel TOOC1_TIRQChannel TOOC2_ TRQChannel TITIMI_TIRQChannel T2TIMI_TRQChannel T3TIMI_TRQChannel oss oss oo yAn FWNFEF O WWNHNNNNKFPPHPEPBPHEP EHP PO POWUONUFCOAINHUKRWNEHOS UM0097 Peripheral firmware overview Table 27 describes the different values of IRQChannel variable Table 27 IRQChannel values IRQChannel Peripheral Interrupt Value TOTIMI_IRQChannel Timer 0 global interrupt 0 FLASH_IRQChannel Embedded Flash global interrupt 1 RCCU_IRQChannel RCCU global interrupt 2 RTC_IRQChannel Real Time Clock global interrupts 3 WDG_IRQChannel Watchdog timer interrupts 4 XTI_IRQChannel WIU Wake up event interrupt 5 USBHP_IRQChannel USB high priority event interrupt 6
203. t Parameter Output Parameter None Return Value The status register content of the selected UART Required preconditions None Called Functions None Example This example illustrates how to get the status of the UARTO ul6 wUART Status WUART Status UART_FlagStatus UARTO SendChar Function Name SendChar Function Prototype void SendChar u8 ch Behavior Description This function sends a character to the defined UART Input Parameter ch a pointer to the character to send Output Parameter None Return Value None Define USE_SERIAL_PORT in 71x_conf h file Required preconditions define USE SERIAL PORT Then define the UART to be used ex define USE_UARTO Called Functions UART_ByteSend Example This example illustrates how to send a char with the SendChar function in71x_conf h file define define USE_SERIAL_PORT define USE UARTO char c c A WUART Status SendChar u8 c j UM0097 Peripheral firmware overview 3 12 Inter integrated circuit I7C The I C Bus interface module serves as interface between the microcontroller and the serial IC bus It provides both multi master and slave functions and controls all 2C bus specific sequencing protocol arbitration and timing The I C driver may be used to manage the I C functionality in transmission and reception and it report the status of the action done The first section describes the da
204. ta register ADC12_FlagStatus Returns the status of the specified flag ADC12_ITConfig Enables Disables the ADC 72 interrupt lt 216 229 UM0097 Peripheral firmware overview ADC12_Init Function Name ADC12_Init Function Prototype void ADC12_Init void This routine is used to initialize the ADC12 registers to Behavior Description P their reset values Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to initialize the ADC 12 Initialize the converter registers ADC12 Init ADC12_ModeConfig Function Name ADC12_ModeConfig Function Prototype void ADC12 ModeConfig ADC12 Modes Mode Behavior Description This routine is used to select the mode of conversion Mode specifies the conversion mode Input Parameter Refer to Modes of conversion on page 215 for more details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example shows how to configure the mode of conversion Enable single channel mode of conversion ADC12 ModeConfig ADC12_ SINGLE 217 229 Peripheral firmware overview UM0097 ADC12_PrescalerConfig Function Name ADC12_PrescalerConfig Function Prototype void ADC12_ PrescalerConfig u32 Adc12_clk Th
205. ta structures used in the I C firmware library The second one presents the firmware library functions 3 12 1 Data structures I7C register structure The I C registers structure 2C_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 vu8 Q R MPTY1 3 wa H MPTY2 3 2 MPTY3 3 R MPTY4 3 R1 MPTY5 3 R2 MPTY6 3 R EMPTY7 3 ECCR EMPTY8 3 wy D D HOH O H a H un an we is I2C_TypeDef Table 71 presents the Fe registers Table 71 C registers Register Description CR IC Control Register SR1 IC Status Register1 SR2 IC Status Register2 CCR IC Clock Control Register ECCR I C Extended Clock Control Register OAR1 IC Own Address Register1 OAR2 IC Own Address Register2 DR IC Data Register 165 229 Peripheral firmware overview UM0097 166 229 define APB1_ BASE define I2CO_ BASE define I2Cl_BASE ifndef DEBUG ifdef _I2C0 define I2C0 endif I2C0 ifdef _I2C1 define I2C1 endif I2C1 else DEBUG ifdef _I2C0 EXT I2C_TypeDef Hendif I2C0 ifdef _I2C1 EXT I2C_TypeDef Hendif I2C1 endif ifdef _I2C0 I2C0 I2C TypeDef endif _I2C0 ifdef _I2C1 I2C1 I2C TypeDef endif _I2C1 define _I2C define _I2C0 define _I2C1 define _RCCU I C re
206. th of OxABC in terms of timer period The pulse generation is activated by a rising edge on the input capture A pin TIM OPModeConfig TIM3 OxABC TIM_HIGH TIM LOW TIM RISING lt 115 229 Peripheral firmware overview UM0097 116 229 TIM_PWMOModeConfig Function Name Function Prototype TIM_PWMOModeConfig void TIM_PWMOModeConfig TIM_TypeDef TIMx ul6 XDutyCycle TIM Logic Levels XLevell ul6 XFullperiod TIM_Logic_ Levels XLevel2 Behavior Description This routine is used to configure the PWM output mode Input Parameter 1 TIMx specifies the TIM to be initialized Refer to TIM values on page 103 for more details on the allowed values of this parameter Input Parameter 2 XDutyCycle specifies the PWM signal duty cycle Input Parameter 3 XLevel1 specifies the PWM signal level during the duty cycle Refer to Logic levels enumeration on page 105 for more details on the allowed values of this parameter Input Parameter 4 XFullperiod specifies the PWM signal full period Input Parameter 5 XLevel2 specifies the PWM signal level out of the duty cycle Refer to Logic levels enumeration on page 105 for more details on the allowed values of this parameter Example Output Parameter None Return Value None Required preconditions None Called Functions None This example illustrates how to configure the T M3 to generate a PWM with a perio
207. the clock divider parameter Table 11 Clock divider parameters Clock Divider RCCU_DEFAULT Description The default divider reset value division by 1 RCCU_RCLK_2 Divide the RCLK by 2 RCCU_RCLK_4 Divide the RCLK by 4 RCCU_RCLK_8 Divide the RCLK by 8 RCLK clock source The following enumeration defines the RCLK clock sources RCLK_Clocks enumeration is defined in the file 77x_rccu h typedef enum RCCU_PLL1 Output RCCU_CLOCK2_16 RCCU_CLOCK2 RCCU_CK_AF RCCU_RCLK_ Clocks Table 12 describes the RCLK clock sources Table 12 RCLK clock sources RCLK Clock Source RCCU_PLL1_ Output Description Select the PLL1 output as RCLK clock source RCCU_CLOCK2_16 RCCU_CLOCK2 Select the RCLK2 16 as RCLK clock source Select the Clock2 as RCLK clock source RCCU_CK_AF Select the RTC as RCLK clock source PLL1 multiplication factors The following enumeration defines the PLL1 multiplication factors RCCU_PLL1_Mul enumeration is declared in the file 77x_rccu h typedef enum RCCU_PLL1 Mul_12 0x01 RCCU_PLL1 Mul_16 0x03 RCCU_PLL1 Mul _20 0x00 RCCU_PLL1 Mul_24 0x02 RCCU_PLL1 Mul 31 229 Peripheral firmware overview UM0097 Table 13 lists the different values of the PLL7 multiplication factor Table 13 PLL1 multiplication factors PLL Multiplication factor RCCU_PLL1_Mul_12 Multiplication factor equal to 12 Description
208. tine gets a 7 or an 8 bit byte from the selected UART UART_9BitByteReceive This routine gets a 9 bit byte from the selected UART UART_DataReceive This routine gets several 7 or 8 bit bytes from the selected UART ky 145 229 Peripheral firmware overview UM0097 146 229 Table 70 UART library functions continued Function Name UART_9BitDataReceive Description This routine gets several 9 bit bytes from the selected UART UART_StringReceive This routine gets several 7 or 8 bit bytes from the selected UART UART_FlagStatus This routine return the status of the selected UART SendChar This routine sends a character to the defined UART UART_Init Function Name Function Prototype UART_Init void UART_Init UART_TypeDef UARTx Behavior Description This function initializes the selected UART registers to their reset values Input Parameter UARTx selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to initialize the UARTO UART_Init UARTO UM0097 Peripheral firmware overview lt UART_ModeConfig Function Name Function Prototype UART_ModeConfig void UART ModeConfig UART_Typ
209. tion Name Description BSPI_ReFifoDepth ae the number of the words for the BSPI receive BSPI_8bLEn Sets the word length to 8 or 16 bits BSPI_ClkFEdge E e e eens idy a ae sample on the first edge of BSPI_ClkActiveHigh Configures the clock to be active high or low BSPI_FifoDisable Disables BSPI FIFO BSPI_ClockDividerContig Configures BSPI clock divider BSPI_FlagStatus Checks whether the specified Flag is set or not BSPI_WordSend Transmits a single word of data BSPI_WordReceive Returns the recent received word BSPI_ByteBufferSend Transmits 8 bits data from a buffer BSPI_ByteBufferReceive Returns the recent 8 bits data received BSPI_WordBufferSend Transmits 16 bits of data from a buffer BSPI_WordBufferReceive Returns the recent 16 bits data received BSPI_ErrltSrc Enables the specified error interrupt BSPI_BSP1I0Conf Function Name BSPI_BSP10Conf Function Prototype void BSPI_BSPIOConf FunctionalState NewState Description Configure BSPIO to be available on GPIOO 0 to GPIOO 3 pins NewState specified the status of the BSPIO Input Parameter ENABLE BSPIO interface will be enabled DISABLE BSPIO interface will be enabled Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to enable the BSPIO interface BSPI BSPIOConf ENABLE 125 229 Peripheral firmware overview UM0097 BSPI_ Init Function Name
210. to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT
211. trate NTQ TSEG1 TSEG2 SJW BRP CAN_BITRATE_100K 100 kbit s 16 11 4 4 5 CAN_BITRATE_125K 125 kbit s 16 11 4 4 4 CAN_BITRATE_250K 250 kbit s 8 4 3 3 4 CAN_BITRATE_500K 500 kbit s 16 16 2 1 1 CAN_BITRATE_1M 1 Mbit s 8 4 3 1 1 Where NTQ Number of Time Quantum TSEG1 Time Segment before the sampling point TSEG2 Time Segment after the sampling point SJW Synchronization Jump Width BRP Baud Rate Prescaler CAN control register bits The following defines list the bit fields accessible in the CAN control register They are declared in the file can h define CAN CR TEST define CAN CR CCE define CAN CR DAR define CAN CR EIE define CAN CR SIE define CAN CR_IE define CAN CR_ INIT 0x0080 0x0040 0x0020 0x0008 0x0004 0x0002 0x0001 187 229 Peripheral firmware overview UM0097 Table 81 describes the CAN control register bits Table 81 CAN control register bits Bit mnemonic Description CAN_CR_TEST Test mode CAN_CR_CCE Configuration Change Enable CAN_CR_DAR Disable Automatic Retransmission CAN_CR_EIE Error Interrupt Enable CAN_CR_SIE Status Interrupt Enable CAN_CR_IE Interrupt Enable CAN_CR_INIT Initialization CAN status register bits The following defines list the bit fields accessible in the CAN status register They are declared in the file can h define CAN SR_LEC 0x0007 define CAN SR_TXOK 0x0008 define CAN SR RXOK 0x0010 define CAN SR_EPASS 0x00
212. turing the first data sample on the first edge of SCK is enabled or disabled ENABLE enables capturing the first data sample on the first edge of SCK DISABLE enables capturing the first data sample on the second edge of SCK Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to configure BSP O to capture the first data sample on the first edge of SCK BSPI_ClkFEdge BSPIO ENABLE UM0097 Peripheral firmware overview BSPI_ClkActiveHigh Function Name Function Prototype BSPI_ClkActiveHigh void BSPI ClkActiveHigh BSPI TypeDef BSPIx FunctionalState NewState Behavior Description Configures the clock to be active high or low Input Parameter 1 BSPIx selects BSPI peripheral to be configured where x can be 0 or 1 Input Parameter 2 Status specifies whether the clock is active high or low ENABLE configures the clock to be active high DISABLE configures the clock to be active low Output Parameter None Return Value None Required Preconditions None Called Functions None Example This example illustrates how to configure BSPI O clock to be active high BSPI_ClkActiveHigh BSPIO ENABLE BSPI_FifoDisable Function Name Function Prototype BSPI_FifoDisable void BSPI FifoDisable BSPI TypeDef BSPIx
213. tyLevelValue u8 EIC Current PriorityLevelValue void Behavior Description Returns the current priority level of the current served IRQ routine Input Parameter None Output Parameter None Return Value The current priority level Required Preconditions None Called Functions None See also ElC_CurrentPriorityLevelConfig on page 62 Example This example shows how to get the priority level of the current interrupt service routine vu8 bCurrentPriorityLevelValue Get the current served IRQ channel priority level bCurrentPriorityLevelValue EIC CurrentPriorityLevelValue EIC_CurrentPriorityLevelConfig Function Name Function Prototype EIC_CurrentPriorityLevelConfig void EIC CurrentPriorityLevelConfig u8 NewPriorityLevel Behavior Description This function changes the current priority level of the served IRQ routine Input Parameter NewPriorityLevel specifies the new priority level It must be an integer in the range 0 15 Output Parameter None Return Value None Required Preconditions None Called Functions None See also EIC_CurrentPriorityLevelValue on page 62 This function changes the current priority level but doesn t change the channel priority level If this function is used in an interrupt service routine the new priority level must be higher than the current priority level To
214. ue TIMx specifies the TIM to get its counter value Refer to T M values on page 103 for more details on the allowed values of this parameter Output Parameter None Return Value The selected timer counter value Required preconditions None Called Functions None Example This example illustrates how get the TIMO timer counter value ul6 wTIMCounterValue wTIMCounterValue TIM CounterValue TIMO x Peripheral firmware overview TIM_ITConfig Function Name Function Prototype TIM_ITConfig void TIM ITConfig TIM _TypeDef TIMx ul 6 New_IT FunctionalState NewState Behavior Description This routine is used to configure the TIM interrupt Input Parameter 1 TIMx specifies the TIM to be configured Refer to T M values on page 103 for more details on the allowed values of this parameter Input Parameter 2 New_IT specifies the TIM interrupt to be configured You can specify one or more TIM interrupts to be configured using the logical operator OR Refer to TIM interrupts on page 106 for more details on the allowed values of this parameter Input Parameter 3 NewSiate specifies the TIM interrupt state whether it would be enabled or disabled ENABLE the corresponding TIM interrupt s will be enabled DISABLE the corresponding TIM interrupt s will be disabled Output Parameter None Return Value
215. uired preconditions PCLK1 must be 8 MHz Otherwise refer to CAN_SetTiming on page 196 Called Functions CAN_EnterInitMode on page 194 CAN_SetBitrate on page 196 CAN_LeavelnitMode on page 194 CAN_LeaveTestMode on page 195 Example This example illustrates a typical CAN initialization Initialize the CAN at 100 kbit s and enable interrupts CAN Init CAN _CR_IE CAN BITRATE 100K CAN_ReleaseMessage Function Name Function Prototype CAN_ReleaseMessage u32 CAN ReleaseMessage u32 msgobj Behavior Description Releases the message object Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value 1 if interface is found O if no interface is available Required preconditions None Called Functions None Example This example illustrates how to release a message object 202 229 UM0097 Peripheral firmware overview Release the message object 0 CAN ReleaseMessage 0 CAN_ReleaseTxMessage Function Name Function Prototype CAN_ReleaseTxMessage void CAN_ReleaseTxMessage u32 msgob j Behavior Description Releases the transmit message object Input Parameter msgobj message object number from 0 to 31 Output Parameter None Return Value None Required preconditions It is assumed that message interface 0 is alway
216. upts in the XTI XTI_ModeConfig Interrupt ENABLE Configure the XTI channel priority level EIC_IRQChannelPriorityConfig XTI_IRQChannel 1 Enable XTI interrupts EIC_IRQChannelConfig XTI_IRQChannel ENABLE Enable IRQ interrupts lt 83 229 Peripheral firmware overview UM0097 EIC_IRQConfig ENABLE Generate a software IRQ interrupt XTI_SWIRQGenerate 3 7 Real time clock RTC The ATC driver may be used for a variety of purposes including real time clock management and precise timing operations The first section describes the data structures used in the RTC firmware library The second section presents the ATC firmware library functions 3 7 1 Data structures RTC register structure The ATC register structure RTC_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vul6 CRH ul6 EMPTY1 vul6 CRL ul6 EMPTY2 vul6 PRLH ul6 EMPTY3 vul6 PRLL ul6 EMPTY4 vul6 DIVH ul6 EMPTYS5 vul6 DIVL ul6 EMPTY6 vul6 CNTH ul6 EMPTY7 vul6 CNTL ul6 EMPTY8 vul6 ALRH ul6 EMPTY9 vul6 ALRL ul6 EMPTY10 RTC_TypeDef Table 39 describes the RTC structure fields Table 39 RTC structure fields Register Description CRH Control High register CRL Control Low register PRLH Prescaler load value High register PRLL Prescaler load value Low register 84 229 UM0097 Peripheral firmware overview
217. utine is used to initialize the XTI cell All Wake Up Lines are disabled Interrupt disabled Walk up mode disabled Set on the falling edge of the input wake up line All pending bits are cleared Behavior Description Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to initialize the XTI Initialize the XTI XTI_ Init 79 229 Peripheral firmware overview UM0097 80 229 XTI_ModeConfig Function Name Function Prototype XTI_ModeConfig void XTI_ModeConfig XTIMode_ TypeDef Mode FunctionalState NewState Behavior Description This function is used to enable or disable the interrupt and the wake up mode of the specified input line Input Parameter 1 Mode this parameter specifies the input line Refer to Wake up line mode on page 77 for more details on the allowed values of this parameter Input Parameter 2 NewState Used to enable or disable the selected mode ENABLE enables the selected mode DISABLE disables the selected mode Example Output Parameter None Return Value None Required preconditions None Called Functions None This example illustrates how to enable and disable Interrupt and Wake up modes Disable the Interrupt and WakeUp modes XTI_ModeConfig XTI_WakeUp
218. void RTC _WaitForLastTask void Behavior Description This routine waits for the task to be completed on the ATC registers Input Parameter None Output Parameter None Return Value None Required preconditions None Called Functions None Example This example illustrates how to use the RTC_WaitForLastTask function RTC_WaitForLastTask Watchdog timer WDG The WDG driver may be used for a variety of purposes including timing operations and watchdog functions The first section describes the data structures used in the WDG firmware library The second section presents the WDG firmware library functions Data structures WDG register structure The WDG register structure WDG_TypeDef is defined in the 71x_map h file as follows typedef volatile struct vul6 CR ul6 EMPTY1 vul6 PR ul6 EMPTY2 vul6 VR ul6 EMPTY3 vul6 CNT ul6 EMPTY4 vul6 SR ul6 EMPTY5 vul6 MR ul6 EMPTY6 vul6 KR ul6 EMPTY7 WDG_TypeDef UM0097 Peripheral firmware overview Table 43 describes the WDG structure fields Table 43 WDG structure fields Register Description CR Control register PR Prescaler register VR Pre load Value register CNT Counter register SR Status Register MR Mask Register KR Key Register The WDG peripherals are declared in the same file define WDG BASE APB2 BASE 0xE000 ifndef DEBUG ifdef WDG define WDG WDG_TypeDef WDG BASE e
219. vu8 SR u8 EMPTY1 7 vu8 CTRL u8 EMPTY2 3 vu8 MRH Ky 75 229 Peripheral firmware overview UM0097 u8 EMPTY3 3 vu8 MRL u8 EMPTY4 3 vu8 TRH u8 EMPTY5 3 vu8 TRL u8 EMPTY6 3 vu8 PRH u8 EMPTY7 3 vu8 PRL XTI_TypeDef Table 34 describes the XTI registers Table 34 XTI registers Register Description SR Wake Up Software Interrupt Register Low CTRL Wake Up Control Register MRH Wake Up Mask Register High MRL Wake Up Mask Register Low TRH Wake Up Trigger Register High TRL Wake Up Trigger Register Low PRH Wake Up Pending Register High PRL Wake Up Pending Register Low XTI peripheral is declared in the 71x_map h file as follows APB2 Base Address definition define APB2 BASE 0xE0000000 XTI Base Address definition define XTI_ BASE APB2 BASE 0x101C XTI peripheral pointer declaration ifndef DEBUG EXT XTI_TypeDef XTI else define XTI XTI_TypeDef XTI_BASE endif When debug mode is used XTI pointer is initialized in 71x_lib c file ifdef XTI XTI XTI_TypeDef XTI_BASE endif XTI In debug mode _XTI must be defined in 71x_confh file to include the XTI library define XTI 76 229 UM0097 Peripheral firmware overview 3 6 2 Wake up line mode The following enumeration defines the input wake up line modes XT Mode_TypeDef enumeration is defined in 71x_xti h file typedef enum
220. which byte to be read upper or lower eight bits It must be one of the following GPIO_MSB corresponds to the upper byte GPIo_LSB corresponds to the lower byte None Return Value The selected port byte value Required preconditions The port pin must be configured as GP IO_IN_TRI_TTL or as GPIO_IN_TRI_CMOS mode Called Functions None See also GPIO_BitRead on page 70 GPIO_WordRead on page 72 Example In This example GPIOO port lower byte and GP O7 port upper byte values are read vu8 bValue lt Get PO 0 7 bits value bValue GPIO ByteRead GPIOO GPIO_ LSB Get P1 8 15 bits value bValue GPIO_ByteRead GPIO1 GPIO_ MSB 71 229 Peripheral firmware overview UM0097 72 229 GPIO_WordRead Function Name Function Prototype GPIO_WordRead ul6 GPIO WordRead GPIO TypeDef GPIOx Behavior Description Reads the value of the specified GP Ox PD data port register and returns its value Input Parameter GPIOx selects the port to be read x can be 0 1 or 2 Refer to GP Ox values on page 68 for details on the allowed values of this parameter Output Parameter None Return Value The specified port data value Required preconditions The port pin must be configured as IN_TRI_TTL or as IN_TRI_LCMOS mode Called Functions None See also GPIO_BitRead on page 70 GPIO_ByteRea
221. x the selected UART x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Data a pointer on the data where the data will be stored TimeOut The Time out value Output Parameter The received 8 bit data Return Value The UARTX_SR register content before reading the received data Required preconditions The selected UART must be properly configured and enabled Called Functions None See also UART_Config on page 149 UART_OnOffConfig on page 154 UM0097 Peripheral firmware overview Example This example illustrates how to read the received data on the UARTO u8 bRxData ul6 wUART Status Read the received data WUART Status UART ByteReceive UARTO amp bRxData OXxFF Check if data received without error if wUART Status amp UART ParityError UART_FrameError UART_OverrunError UART_TimeOutIdle handles the error while UART_FlagStatus UARTO amp UART_RxBufFull while the receive buffer is empty WUART Status UART ByteReceive UARTO amp bRxData OXxFF 159 229 Peripheral firmware overview UM0097 UART_9BitByteReceive Function Name Function Prototype UART_9BitByteReceive ul6 UART_9BitByteReceive UART_TypeDef UARTX ul6 Data u8 TimeOut Behavior Description This routine gets a 9 bit byte from the selected
222. x0103 0x0004 0x0105 Ox0006 0x0107 0x0008 0x0109 0x000A 0x010B Ox000C 0x010D 0x000E Ox010F 0x000F UART 9BitDataSend UARTO pwDataToSend DATA LENGTH 157 229 Peripheral firmware overview UM0097 158 229 UART_StringSend Function Name Function Prototype UART_SiringSend void UART_ StringSend UART_TypeDef UARTx u8 String Behavior Description This routine sends a 7 bit byte or 8 bit string using the selected UAAT Input Parameter 1 UARTx Selects the UART to be configured x can be 0 1 2 or 3 Refer to UARTx values on page 145 for details on the allowed values of this parameter Input Parameter 2 String The string start address Output Parameter None Return Value None Required preconditions The selected UART must be properly configured and enabled Called Functions UART_ByteSend See also UART_Config on page 149 UART_OnOffConfig on page 154 Example This example illustrates how to send a string using the UARTO Send Hello World UART_StringSend UARTO UART_ByteReceive u8 amp Hello World Function Name Function Prototype UART_ByteReceive ul6 UART_ByteReceive UART_TypeDef UARTx u8 Data u8 TimeOut Behavior Description This routine gets a 7 or an 8 bit byte from the selected UART Input Parameter 1 Input Parameter 2 Input Parameter 3 UART
223. xample shows how to enable the Timer 0 global interrupts and disable the UARTO interrupts Enable Timer 0 global interrupts EIC _IRQChannelConfig TOTIMI_IRQChannel ENABLE Disable UART 0 global interrupts EIC_IRQChannelConfig UARTO IRQChannel DISABLE 59 229 Peripheral firmware overview UM0097 60 229 EIC_FlQChannelConfig Function Name Function Prototype EIC_FIQChannel Config void EIC_ FIQChannelConfig FIQChannel_ TypeDef FIQChannel FunctionalState NewState Behavior Description Sets or clears the corresponding channel bit located in E C FIR register Input Parameter 1 FIQChannel the FIQ channel to be configured Refer to FIQ channel enumeration on page 55 for details on allowed values of FIQChannel parameter Input Parameter 2 NewState specifies whether the FIQ channel interrupt will be enabled or disabled ENABLE enables the F Q channel interrupt DISABLE disables the F Q channel interrupt See also Output Parameter None Return Value None Required Preconditions None Called Functions None EIC_FlQConfig on page 58 Example This example how to disable the WDG FIQ interrupts and enable Timer 0 FIQ interrupts Disable WDG FIQ interrupts EIC FIQChannelConfig WDG_FIQChannel DISABLE Enable Timer 0 FIQ interrupts EIC FIQChannelConfig TOTIMI_FIQChannel ENABLE lt

Download Pdf Manuals

image

Related Search

Related Contents

Gefen EXT-DVIKVM-241DL KVM switch  Benutzerhandbuch Durchflussmengenmessung        

Copyright © All rights reserved.
Failed to retrieve file