|
From: <ak...@us...> - 2008-02-06 12:48:47
|
Revision: 828
http://can.svn.sourceforge.net/can/?rev=828&view=rev
Author: akhe
Date: 2008-02-06 04:48:42 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
Added templates for all STR7 uP's
Modified Paths:
--------------
trunk/firmware/arm/str/common/str71x_lib/libSTR71x_lib.a
Added Paths:
-----------
trunk/firmware/arm/str/common/str72x_lib/
trunk/firmware/arm/str/common/str72x_lib/Makefile
trunk/firmware/arm/str/common/str72x_lib/include/
trunk/firmware/arm/str/common/str72x_lib/include/720_a3brg.h
trunk/firmware/arm/str/common/str72x_lib/include/720_adc.h
trunk/firmware/arm/str/common/str72x_lib/include/720_agcr.h
trunk/firmware/arm/str/common/str72x_lib/include/720_ahb.h
trunk/firmware/arm/str/common/str72x_lib/include/720_bspi.h
trunk/firmware/arm/str/common/str72x_lib/include/720_can.h
trunk/firmware/arm/str/common/str72x_lib/include/720_cgc.h
trunk/firmware/arm/str/common/str72x_lib/include/720_conf.h
trunk/firmware/arm/str/common/str72x_lib/include/720_dmac.h
trunk/firmware/arm/str/common/str72x_lib/include/720_dramc.h
trunk/firmware/arm/str/common/str72x_lib/include/720_eft.h
trunk/firmware/arm/str/common/str72x_lib/include/720_eic.h
trunk/firmware/arm/str/common/str72x_lib/include/720_emi.h
trunk/firmware/arm/str/common/str72x_lib/include/720_gpio.h
trunk/firmware/arm/str/common/str72x_lib/include/720_ide.h
trunk/firmware/arm/str/common/str72x_lib/include/720_it.h
trunk/firmware/arm/str/common/str72x_lib/include/720_lib.h
trunk/firmware/arm/str/common/str72x_lib/include/720_map.h
trunk/firmware/arm/str/common/str72x_lib/include/720_rccu.h
trunk/firmware/arm/str/common/str72x_lib/include/720_rtc.h
trunk/firmware/arm/str/common/str72x_lib/include/720_sapb.h
trunk/firmware/arm/str/common/str72x_lib/include/720_type.h
trunk/firmware/arm/str/common/str72x_lib/include/720_uart.h
trunk/firmware/arm/str/common/str72x_lib/include/720_wdg.h
trunk/firmware/arm/str/common/str72x_lib/include/720_wiu.h
trunk/firmware/arm/str/common/str72x_lib/libSTR72x_lib.a
trunk/firmware/arm/str/common/str72x_lib/src/
trunk/firmware/arm/str/common/str72x_lib/src/720_a3brg.c
trunk/firmware/arm/str/common/str72x_lib/src/720_adc.c
trunk/firmware/arm/str/common/str72x_lib/src/720_bspi.c
trunk/firmware/arm/str/common/str72x_lib/src/720_can.c
trunk/firmware/arm/str/common/str72x_lib/src/720_cgc.c
trunk/firmware/arm/str/common/str72x_lib/src/720_dmac.c
trunk/firmware/arm/str/common/str72x_lib/src/720_dramc.c
trunk/firmware/arm/str/common/str72x_lib/src/720_eft.c
trunk/firmware/arm/str/common/str72x_lib/src/720_eic.c
trunk/firmware/arm/str/common/str72x_lib/src/720_emi.c
trunk/firmware/arm/str/common/str72x_lib/src/720_gpio.c
trunk/firmware/arm/str/common/str72x_lib/src/720_ide.c
trunk/firmware/arm/str/common/str72x_lib/src/720_lib.c
trunk/firmware/arm/str/common/str72x_lib/src/720_rccu.c
trunk/firmware/arm/str/common/str72x_lib/src/720_rtc.c
trunk/firmware/arm/str/common/str72x_lib/src/720_uart.c
trunk/firmware/arm/str/common/str72x_lib/src/720_wdg.c
trunk/firmware/arm/str/common/str72x_lib/src/720_wiu.c
Modified: trunk/firmware/arm/str/common/str71x_lib/libSTR71x_lib.a
===================================================================
(Binary files differ)
Added: trunk/firmware/arm/str/common/str72x_lib/Makefile
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/Makefile (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/Makefile 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,37 @@
+# efsl library Makefile for STR720 by Giacomo Fazio and Antonio Nasca
+# (based on efsl library makefile for AT91SAM7S by Martin Thomas)
+
+MCU = arm7tdmi
+#THUMB = -mthumb -mthumb-interwork
+THUMB =
+
+LIBNAME = libSTR72x_lib.a
+
+COPT= -mcpu=$(MCU) $(THUMB) -gdwarf-2 -Wall -Os
+INCLUDEDIRS=-Iinclude
+CFLAGS=$(COPT) $(INCLUDEDIRS)
+# gcc4 unused code-removal:
+CFLAGS += -ffunction-sections -fdata-sections
+
+CC=arm-elf-gcc
+AR=arm-elf-ar
+OBJCOPY=arm-elf-objcopy
+
+OBJ=src/720_a3brg.o src/720_adc.o src/720_bspi.o src/720_can.o
+OBJ+=src/720_cgc.o src/720_dmac.o src/720_dramc.o src/720_eft.o
+OBJ+=src/720_eic.o src/720_emi.o src/720_gpio.o src/720_ide.o src/720_lib.o
+OBJ+=src/720_rccu.o src/720_rtc.o src/720_uart.o src/720_wdg.o src/720_wiu.o
+
+
+all: lib
+
+libandclean: lib srcclean
+
+lib: $(OBJ)
+ $(AR) rcs $(LIBNAME) $(OBJ)
+
+srcclean :
+ rm -f $(OBJ)
+
+clean :
+ rm -f $(OBJ) $(LIBNAME)
Added: trunk/firmware/arm/str/common/str72x_lib/include/720_a3brg.h
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/include/720_a3brg.h (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/include/720_a3brg.h 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,138 @@
+/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
+* File Name : 720_a3brg.h
+* Author : MCD Application Team
+* Date First Issued : 08/02/2004
+* Description : This file provides all the Asynchronous AHB-APB bridge
+* software functions headers
+**********************************************************************************
+* History:
+* 12/20/2004 : V1.1
+* 08/02/2004 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+/* Standard include ----------------------------------------------------------*/
+/* Include of other module interface headers ---------------------------------*/
+/* Local includes ------------------------------------------------------------*/
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Interface functions -------------------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+/* Includes ------------------------------------------------------------------*/
+
+#ifndef _720_A3BRG_H
+#define _720_A3BRG_H
+
+#include "720_lib.h"
+/* define the A3BRG Peripherals' clock and reset line masks*/
+
+typedef enum
+ {
+ GPIO2_RC = 0x04,
+ BSPI1_RC = 0x08,
+ BSPI2_RC = 0x10,
+ UART1_RC = 0x20,
+ UART2_RC = 0x40,
+ EFT1_RC = 0x80,
+ EFT2_RC = 0x100,
+ ADC_RC = 0x200,
+ CAN_RC = 0x400,
+ USB_RC = 0x800
+ }A3BRG_Peripherals;
+/*******************************************************************************
+* Function Name : A3BRG_ClkConfig
+* Description : This routine is used to enable or disable the clock signal
+* for the specified peripheral.
+* Input : Periph: the peripheral to enable or disable the clock
+* signal.
+* refer to the values defines above for more details on
+* the allowed values of this parameter.
+*
+* NewState: The reset line Status
+* Return : None
+*******************************************************************************/
+void A3BRG_ClkConfig( A3BRG_Peripherals Periph, FunctionalState NewState );
+/*******************************************************************************
+* Function Name : A3BRG_ResetConfig
+* Description : This routine is used to activate or deactivate the reset
+* line for the specified peripheral.
+* Input : Periph: the peripheral to activate or deactivate the
+* reset line.
+* refer to the values defines above for more details on
+* the allowed values of this parameter.
+*
+* NewState: The reset line Status
+* Return : None
+*******************************************************************************/
+void A3BRG_ResetConfig( A3BRG_Peripherals Periph, FunctionalState NewState );
+/*******************************************************************************
+* Function Name : A3BRG_ClkEmuConfig
+* Description : This routine is used to configure the status of the clock for
+* the peripheral controlled by the bridge while the application
+* is stopped due to a debug request.
+* Input : Periph: the peripheral to activate or deactivate the
+* reset line.
+* refer to the values defines above for more details on
+* the allowed values of this parameter.
+*
+* NewState: The reset line Status
+* Return : None
+*******************************************************************************/
+void A3BRG_ClkEmuConfig( A3BRG_Peripherals Periph, FunctionalState NewState );
+/*******************************************************************************
+* Function Name : A3BRG_AbortError
+* Description : This routine is used to indicate if a previous AHB access has
+* been aborted because it generates an error.
+* Input : NONE
+* Return : status of the previous access
+* if 0 : No error
+* !0 : an error takes place during the pervious access.
+*******************************************************************************/
+u32 A3BRG_AbortError ( void );
+/*******************************************************************************
+* Function Name : A3BRG_ErrorSource
+* Description : This routine is used to return the error source of the
+* previous access if it has been aborted otherwise it retunrs 0
+* Input : NONE
+* Return : source of the error
+* if 00 : No error
+* 10 : An access out of memory
+* 40 : an access to a protected peripheral
+* 80 : an access to a non clocked peripheral
+* 100 : an access to a peripheral under reset
+*******************************************************************************/
+u32 A3BRG_ErrorSource ( void );
+/*******************************************************************************
+* Function Name : A3BRG_AccessType
+* Description : This routine is used to return the type of access that
+* generated the error
+* Input : NONE
+* Return : access type
+* if 0 : Read Accesss
+* 1 : Write access
+*******************************************************************************/
+u32 A3BRG_AccessType ( void );
+/*******************************************************************************
+* Function Name : A3BRG_AddressError
+* Description : This routine is used to return the address of the location
+* whose previous access has generated an error.
+* Input : NONE
+* Return : Location address offset
+*******************************************************************************/
+u32 A3BRG_AddressError ( void );
+
+#endif /* _720_A3BRG_H*/
+
+
+/******************* (C) COPYRIGHT 2004 STMicroelectronics *****END OF FILE****/
Added: trunk/firmware/arm/str/common/str72x_lib/include/720_adc.h
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/include/720_adc.h (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/include/720_adc.h 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,199 @@
+/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
+* File Name : 720_adc.h
+* Author : MCD Application Team
+* Date First Issued : 08/02/2004
+* Description : This file provides all the ADC software functions headers
+**********************************************************************************
+* History:
+* 12/20/2004 : V1.1
+* 08/02/2004 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+#ifndef __720_ADC_H
+#define __720_ADC_H
+
+#include "720_lib.h"
+
+#ifndef _RCCU
+ #error _RCCU Must be Defined in "720_conf.h"
+#endif
+
+
+
+
+//--------------------ADC Conversion modes-----------------------------------
+typedef enum
+{
+ ADC_SINGLE,
+ ADC_ROUND
+} ADC_Modes;
+
+//--------------------ADC Channels-------------------------------------------
+typedef enum
+{
+ ADC_CHANNEL0 = 0x00,
+ ADC_CHANNEL1 = 0x10,
+ ADC_CHANNEL2 = 0x20,
+ ADC_CHANNEL3 = 0x30
+} ADC_Channels;
+
+//--------------------ADC control status register flag-----------------------
+
+#define ADC_DA0 0x01
+#define ADC_DA1 0x02
+#define ADC_DA2 0x04
+#define ADC_DA3 0x08
+#define ADC_OR 0x2000
+#define ADC_DEC 0x4000
+
+// Masks for the update of interrupt bit for channel n
+#define ADC_IT0_Mask 0x0100
+#define ADC_IT1_Mask 0x0200
+#define ADC_IT2_Mask 0x0400
+#define ADC_IT3_Mask 0x0800
+
+//Mask for the update of all the interrupt bit in the CSR
+#define ADC_IT_Mask 0x0F00
+
+//Mask for Selecting mode
+#define ADC_Mode_Mask 0x0040
+
+//Mask for configuring the converter
+#define ADC_Start_Mask 0x0000
+#define ADC_Stop_Mask 0x0004
+#define ADC_Decimation_Mask 0x4000
+
+/*******************************************************************************
+* Function Name : ADC_Init
+* Description : Intialize the ADC
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void ADC_Init(void);
+
+/*******************************************************************************
+* Function Name : ADC_DecimationMode
+* Description : Select the decimation mode .
+* Input : None
+* Return : None
+*******************************************************************************/
+static inline void ADC_DecimationMode (void)
+{
+ // Set the ADC_DEC bit of the ADCCSR register
+ ADC->CSR |= ADC_Decimation_Mask;
+}
+
+/*******************************************************************************
+* Function Name : ADC_ConvertsionStart
+* Description : Declenche the Conversion.
+* Input : None
+* Return : None
+*******************************************************************************/
+static inline void ADC_ConvertionStart(void)
+{
+ // Clear the ADC_STOP bit of the AGCR1 register
+ AGCR->CR1 &= ADC_Start_Mask;
+}
+
+/*******************************************************************************
+* Function Name : ADC_ConversionStop
+* Description : Stop the ADC
+* Input : None.
+* Return : None.
+*******************************************************************************/
+static inline void ADC_ConversionStop(void)
+{
+ // Set the ADC_STOP bit of the AGCR1 register
+ AGCR->CR1 |= ADC_Stop_Mask;
+}
+
+/*******************************************************************************
+* Function Name : ADC_ModeConfig
+* Description : Configure the mode of conversion
+* Input : ADC_SINGLE: single channel mode
+* ADC_ROUND : round robin mode
+* Return : None
+*******************************************************************************/
+static inline void ADC_ModeConfig (ADC_Modes Mode)
+{
+ // Select the mode of conversion and update the CSR[6]
+ ADC->CSR= Mode == ADC_SINGLE ? ADC->CSR | ADC_Mode_Mask : ADC->CSR & ~ADC_Mode_Mask;
+}
+
+/*******************************************************************************
+* Function Name : ADC_PrescalerConfig
+* Description : Configure the prescaler
+* Input : ADC_clk: Sampling frequency.
+* Return : None.
+*******************************************************************************/
+void ADC_PrescalerConfig(vu32 ADC_clk);
+
+/*******************************************************************************
+* Function Name : ADC_ChannelSelect
+* Description : select the channel passed as parameter to be converted.
+* Input : ADC_Channel: channel selected to be converted it may be
+* ADC_CHANNEL0 : select channel 0
+* ADC_CHANNEL1 : select channel 1
+* ADC_CHANNEL2 : select channel 2
+* ADC_CHANNEL3 : select channel 3
+* Return : None
+*******************************************************************************/
+static inline void ADC_ChannelSelect(ADC_Channels ADC_Channel)
+{
+ // Update the CSR by the value of the selected channel
+ ADC->CSR |= ADC_Channel;
+}
+
+/*******************************************************************************
+* Function Name : ADC_GetStatus
+* Description : test if the flag passed in parameter is set or not
+* Input : ADC_DA0 :Data Available on Channel 0
+* ADC_DA1 :Data Available on Channel 1
+* ADC_DA2 :Data Available on Channel 2
+* ADC_DA3 :Data Available on Channel 3
+* ADC_OR :Overrun
+* ADC_DEC :Decimation
+* Return : SET: if the flag is set
+* RESET: if the flag is clear
+*******************************************************************************/
+static inline u16 ADC_GetStatus (vu16 ADC_Flag)
+{
+ // Test on the flag status and return set or RESET
+ return ADC->CSR & ADC_Flag ? SET : RESET;
+}
+
+/*******************************************************************************
+* Function Name : ADC_ConversionValue
+* Description : Read the conversion result from the data register.
+* Input : ADC_Channel :number of the register to read
+* ADC_CHANNEL0 : read the DATA0 register
+* ADC_CHANNEL1 : read the DATA1 register
+* ADC_CHANNEL2 : read the DATA2 register
+* ADC_CHANNEL3 : read the DATA3 register
+* Return : the register value of the channel converted
+*******************************************************************************/
+static inline u16 ADC_ConversionValue( ADC_Channels ADC_Channel)
+{
+ // Only the 12 MSB of the DATAn Register are taken
+ return *(u16 *)(ADC_BASE + (ADC_Channel >> 1)) >> 4;
+}
+
+/*******************************************************************************
+* Function Name : ADC_ITConfig
+* Description : enable or disable the interruption
+* Input : NewState=ENABLE=>enable interrupt
+* NewState=DISABLE=>disable interrupt
+* Return : None
+*******************************************************************************/
+void ADC_ITConfig (FunctionalState NewState);
+
+#endif // __720_ADC_H
+
+/******************* (C) COPYRIGHT 2004 STMicroelectronics *****END OF FILE****/
Added: trunk/firmware/arm/str/common/str72x_lib/include/720_agcr.h
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/include/720_agcr.h (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/include/720_agcr.h 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,66 @@
+/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
+* File Name : 720_agcr.h
+* Author : MCD Application Team
+* Date First Issued : 08/02/2004
+* Description : This file provides all the AGCR software functions headers
+**********************************************************************************
+* History:
+* 12/20/2004 : V1.1
+* 08/02/2004 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+
+/* Standard include ----------------------------------------------------------*/
+/* Include of other module interface headers ---------------------------------*/
+/* Local includes ------------------------------------------------------------*/
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Interface functions -------------------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef _720_AGCR_H
+#define _720_AGCR_H
+/* Includes ------------------------------------------------------------------*/
+#include "720_lib.h"
+/* Exported types ------------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : AGCR_Init
+* Description : Init AGCR register
+* Input 1 : None
+* Input 2 : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void AGCR_Init(void);
+/*******************************************************************************
+* Function Name : AGCR_ADCStopConfig
+* Description : Stop/Run ADC Operations
+* Input 1 : ENABLE/DISABLE
+* Output : None
+* Return : None
+*******************************************************************************/
+void AGCR_ADCStopConfig(FunctionalState Xstatus);
+/*******************************************************************************
+* Function Name : AGCR_ADCOffConfig
+* Description : Switch off/on ADC Analog section
+* Input 1 : ENABLE/DISABLE
+* Output : None
+* Return : None
+*******************************************************************************/
+void AGCR_ADCOffConfig(FunctionalState Xstatus);
+
+#endif /* _720_AGCR_H */
+
+/******************* (C) COPYRIGHT 2004 STMicroelectronics *****END OF FILE****/
Added: trunk/firmware/arm/str/common/str72x_lib/include/720_ahb.h
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/include/720_ahb.h (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/include/720_ahb.h 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,51 @@
+/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
+* File Name : 720_ahb.h
+* Author : MCD Application Team
+* Date First Issued : 08/02/2004
+* Description : This file provides all the wiu software functions headers
+**********************************************************************************
+* History:
+* 12/20/2004 : V1.1
+* 08/02/2004 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+/* Standard include ----------------------------------------------------------*/
+/* Include of other module interface headers ---------------------------------*/
+/* Local includes ------------------------------------------------------------*/
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Interface functions -------------------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __720_AHB_H
+#define __720_AHB_H
+/* Includes ------------------------------------------------------------------*/
+#include "720_lib.h"
+/* Exported types ------------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : AHB_Init
+* Description : Init AHB Block
+* Input 1 : None
+* Input 2 : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void AHB_Init(void);
+
+
+
+#endif /* __720_AHB_H */
+
+/******************* (C) COPYRIGHT 2004 STMicroelectronics *****END OF FILE****/
Added: trunk/firmware/arm/str/common/str72x_lib/include/720_bspi.h
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/include/720_bspi.h (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/include/720_bspi.h 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,425 @@
+/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
+* File Name : bspi.h
+* Author : MCD Application Team
+* Date First Issued : 08/02/2004
+* Description : This file contains all the functions prototypes for the
+* BSPI software library.
+**********************************************************************************
+* History:
+* 12/20/2004 : V1.1
+* 08/02/2004 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+#ifndef __720_BSPI_H
+#define __720_BSPI_H
+
+#include "720_lib.h"
+
+typedef enum {
+ BSPI_MASTER = 0x0002,
+ BSPI_SLAVE
+} BSPIMode_TypeDef;
+
+typedef enum {
+ BSPI_16b = 0x0400,
+ BSPI_8b = 0x0C00
+} BSPIWord_TypeDef;
+
+typedef enum {
+ BSPI_FirstEdge = 0xFDFF,
+ BSPI_SecondEdge=0x0200
+} BSPICLKPhase_TypeDef;
+
+typedef enum {
+ BSPI_LOW = 0x0100,
+ BSPI_HIGH
+} BSPICLKPolarity_TypeDef;
+
+typedef enum {
+ BSPI_BERIT = 0x0080,
+ BSPI_RxIT = 0x0010,
+ BSPI_ALL = 0x0090
+} BSPIITConfig_TypeDef;
+
+typedef enum {
+ BSPI_BERR = 0x004,
+ BSPI_RxFNE = 0x008,
+ BSPI_RxFF = 0x010,
+ BSPI_RxOFL = 0x020,
+ BSPI_TxFE = 0x040,
+ BSPI_TxUFL = 0x080,
+ BSPI_TxFF = 0x100,
+ BSPI_TxFNE = 0x200
+} BSPIFlags_TypeDef ;
+
+typedef enum {
+ BSPI_TxITFE = 0x4000 ,
+ BSPI_TxITUFL = 0x8000,
+ BSPI_TxITFF = 0xC000,
+ BSPI_TxITDIS
+} BSPITxIT_TypeDef;
+
+typedef enum {
+ BSPI_RxITFNE = 0x0004,
+ BSPI_RxITFF = 0x000C,
+ BSPI_RxITDIS
+} BSPIRxIT_TypeDef;
+
+typedef enum {
+ BSPI_Tx1Word = 0x00F3,
+ BSPI_Tx4Word = 0x0004,
+ BSPI_Tx8Word = 0x0008,
+ BSPI_Tx16Word = 0x000C
+} BSPITxBurst_TypeDef;
+
+typedef enum {
+ BSPI_Rx1Word = 0x00CF,
+ BSPI_Rx4Word = 0x0010,
+ BSPI_Rx8Word = 0x0020,
+ BSPI_Rx16Word = 0x0030
+} BSPIRxBurst_TypeDef;
+
+#define BSPI_BSPE 0x01
+#define BSPI_DFIFO 0x0001
+#define BSPI_MaskSlave 0x0001
+#define BSPI_MaskDMAConfig 0x0002
+#define BSPI_TREQ 0x0040
+#define BSPI_RREQ 0x0080
+
+/*******************************************************************************
+* Function Name : BSPI_Init
+* Description : Initializes BSPI peripheral control and registers to their
+* : default reset values.
+* Input : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Output : BSPI peripheral registers and BSPI global variables are
+* : initialized.
+* Return : None.
+*******************************************************************************/
+void BSPI_Init( BSPI_TypeDef *BSPIx);
+/*******************************************************************************
+* Function Name : BSPI_Config
+* Description : Enables/disables the specified BSPI peripheral.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral to
+* : be enabled or disabled.
+* Input 2 : NewState: specifies the status of the BSPI
+* : New State value must be either ENABLE or DISABLE:
+* : ENABLE: the specified BSPI peripheral will be enabled.
+* : DISABLE: the specified BSPI peripheral will be disabled.
+* Output : BSPE bit in BSPCSR1.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_Config( BSPI_TypeDef *BSPIx, FunctionalState NewState)
+{
+ if (NewState == ENABLE) BSPIx->CSR1 |= BSPI_BSPE;
+ else BSPIx->CSR1 &= ~BSPI_BSPE;
+}
+/*******************************************************************************
+* Function Name : BSPI_ModeConfig
+* Description : Configures the BSPI as a master or a slave.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : ModeConfig: specifies the BSPI mode.
+* : Refer to the section \x91Mode Configuration\x92 for more details
+* : on the allowed values of this parameter.
+* Output : MSTR bit in BSPCSR1 is modified register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_ModeConfig(BSPI_TypeDef *BSPIx,BSPIMode_TypeDef Mode)
+{
+ if (Mode == BSPI_MASTER) BSPIx->CSR1 |= BSPI_MASTER;
+ else BSPIx->CSR1 &= ~BSPI_MASTER;
+}
+/*******************************************************************************
+* Function Name : WordConfig
+* Description : Configure the word length of the receive FIFO and transmit data
+* : registers to either 8 or 16 bits.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI.
+* Input 2 : WordConfig: specifies the word length.
+* : Refer to the section \x91Word Configuration\x92 for more details
+* : on the allowed values of this parameter.
+* Output : WL bits in BSPCSR1 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_WordConfig(BSPI_TypeDef *BSPIx,BSPIWord_TypeDef Word)
+{
+ if( Word == BSPI_16b) BSPIx->CSR1 |= BSPI_16b; else BSPIx->CSR1 &= ~BSPI_8b;
+}
+/*******************************************************************************
+* Function Name : BSPI_CLKPhaseConfig
+* Description : Configure capturing the first data sample on the first edge
+* : of clock or on the second edge.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : CLKPhase: specifies the mode of capturing the first data.
+* : Refer to the section \x91Clock Phase Configuration\x92 for more
+* : details on the allowed values of this parameter.
+* Output : CPHA bits in BSPCSR1 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_CLKPhaseConfig(BSPI_TypeDef *BSPIx, BSPICLKPhase_TypeDef CLKPhase)
+{
+ if (CLKPhase == BSPI_FirstEdge) BSPIx->CSR1&=BSPI_FirstEdge;
+ else BSPIx->CSR1 |=BSPI_SecondEdge;
+}
+/*******************************************************************************
+* Function Name : BSPI_CLKPolarity
+* Description : Configures the clock to be active high or low.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : CLKPolarity: specifies the clock as a active high or a low.
+* : Refer to the section \x91Clock Polarity Config\x92 for more details
+* : on the allowed values of this parameter.
+* Output : CPOL bits in BSPCSR1 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_CLKPolarityConfig(BSPI_TypeDef *BSPIx, BSPICLKPolarity_TypeDef CLKPolarity)
+{
+ if (CLKPolarity == BSPI_LOW) BSPIx->CSR1 |= BSPI_LOW;
+ else BSPIx->CSR1 &= ~BSPI_LOW;
+}
+/*******************************************************************************
+* Function Name : BSPI_CLKDividerConfig
+* Description : Configure BSPI clock divider
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI.
+* Input 2 : Div: holds the value of the clock divider.
+* Output : Div [7:0] bits in BSPCLK register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_CLKDividerConfig(BSPI_TypeDef *BSPIx, vu8 CLKDivider)
+{
+ BSPIx->CLK = CLKDivider;
+}
+/*******************************************************************************
+* Function Name : BSPI_WordSend.
+* Description : Transmit a single Word.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : holds the word which will be transmitted.
+* Output : BSPTXR register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_WordSend(BSPI_TypeDef *BSPIx, vu16 Data)
+{
+ if ((BSPIx->CSR1 & 0x0400) == 0) Data <<= 8;
+ BSPIx->TXR = Data;
+}
+/*******************************************************************************
+* Function Name : BSPI_WordReceive.
+* Description : Returns the recent received word.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Output : None.
+* Return : The value of the received word.
+*******************************************************************************/
+static inline u16 BSPI_WordReceive(BSPI_TypeDef *BSPIx)
+{
+ return (BSPIx->CSR1 & 0x0400) == 0 ? BSPIx->RXR >> 8 : BSPIx->RXR;
+}
+/*******************************************************************************
+* Function Name : BSPI_ITConfig.
+* Description : Enable or disable interrupt.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : ITConfig: specifies the BSPI interrupt.
+* : Refer to the section \x91Interrupt Configuration\x92 for more details on
+* : the allowed values of this parameter..
+* Input 3 : NewState: specified whether the BSPI interrupt is enabled or
+* : disabled.
+* : New State value must be either ENABLE or DISABLE.
+* : ENABLE: to enable interrupt
+* : DISABLE: to disable interrupt.
+* Output : BSPCSR1 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_ITConfig(BSPI_TypeDef *BSPIx, BSPIITConfig_TypeDef ITConfig, FunctionalState NewState)
+{
+ if (NewState == ENABLE) BSPIx->CSR1 |= ITConfig; else BSPIx->CSR1 &= ~ITConfig;
+}
+/*******************************************************************************
+* Function Name : BSPI_FifoDisable
+* Description : Configure the BSPI FIFO.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Output : DFIFO bit in BSPCSR2 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_FifoDisable(BSPI_TypeDef *BSPIx)
+{
+ BSPIx->CSR2 |= BSPI_DFIFO;
+}
+/*******************************************************************************
+* Function Name : BSPI_FlagStatus.
+* Description : Check whether the specified BSPI Flag is set or not.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : Flag: specifies the flag to see the status.
+* : Refer to the section \x91BSPI Flags\x92 for more details on the
+* : allowed values of this parameter.
+* Output : None.
+* Return : FlagStatus type
+* : SET: if the tested flag is set.
+* : RESET: if the corresponding flag is reset.
+*******************************************************************************/
+static inline FlagStatus BSPI_FlagStatus(BSPI_TypeDef *BSPIx, BSPIFlags_TypeDef Flag)
+{
+ return (BSPIx->CSR2 &= Flag) != 0 ? SET : RESET;
+}
+/*******************************************************************************
+* Function Name : BSPI_MaskSlaveConfig
+* Description : Enable/Disable mask of salve select pin.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : NewState: specfied whether the BSPI mask slave select is enabled
+* : or disabled.
+* : New State value must be ENABLE or DISABLE.
+* : ENABLE: to enable mask slave select.
+* : DISABLE: to disable mask slave select.
+* Output : MASK_SS bit in BSPCSR3 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_MaskSlaveConfig(BSPI_TypeDef *BSPIx, FunctionalState NewState )
+{
+ if ( NewState == ENABLE) BSPIx->CSR3 |= BSPI_MaskSlave;
+ else BSPIx->CSR3 &= ~BSPI_MaskSlave;
+}
+/*******************************************************************************
+* Function Name : BSPI_DMAConfig
+* Description : Enable/disable DMA interface.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : NewState: specfied whether the BSPI DMA interface is enabled
+* : or disabled.
+* : New State value must be ENABLE or DISABLE.
+* : ENABLE: to enable DMA interface.
+* : DISABLE: to disable DMA interface.
+* Output : DMA_EN bit in BSPCSR3 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_DMAConfig(BSPI_TypeDef *BSPIx, FunctionalState NewState )
+{
+ if ( NewState == ENABLE) BSPIx->CSR3 |= BSPI_MaskDMAConfig;
+ else BSPIx->CSR1 &= ~BSPI_MaskDMAConfig;
+}
+/*******************************************************************************
+* Function Name : BSPI_TxReqConfig
+* Description : Enable/disable the transmission DMA request.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : NewState: specfied whether the BSPI transmit request is enabled
+* : or disabled.
+* : New State value must be ENABLE or DISABLE.
+* : ENABLE: to enable transmit request.
+* : DISABLE: to disable transmit request.
+* Output : TREQ_EN bit in BSPCSR3 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_TxReqConfig(BSPI_TypeDef *BSPIx,FunctionalState NewState)
+{
+ if ( NewState == ENABLE) BSPIx->CSR3 |= BSPI_TREQ;
+ else BSPIx->CSR3 &= ~BSPI_TREQ;
+}
+/*******************************************************************************
+* Function Name : BSPI_RxReqConfig
+* Description : Enable/disable the reception DMA request.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : NewState: specfied whether the BSPI transmit request is enabled
+* : or disabled.
+* : New State value must be ENABLE or DISABLE.
+* : ENABLE: to enable transmit request.
+* : DISABLE: to disable transmit request.
+* Output : RREQ_EN bit in BSPCSR3 register.
+* Return : None.
+*******************************************************************************/
+static inline void BSPI_RxReqConfig(BSPI_TypeDef *BSPIx,FunctionalState NewState)
+{
+ if ( NewState == ENABLE) BSPIx->CSR3 |= BSPI_RREQ;
+ else BSPIx->CSR3 &= ~BSPI_RREQ;
+}
+/*******************************************************************************
+* Function Name : BSPI_TxITConfig.
+* Description : Configures the transmit interrupt source.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : TxIT: specifies the transmit interrupt source.
+* : Refer to the section \x91Transmit Interrupt Configuration\x92 for
+* : more details on the allowed values of this parameter.
+* Output : TIE bit in BSPCSR2 register.
+* Return : None.
+*******************************************************************************/
+void BSPI_TxITConfig(BSPI_TypeDef *BSPIx, BSPITxIT_TypeDef TxIT);
+/*******************************************************************************
+* Function Name : BSPI_RxITConfig.
+* Description : Configures the receive interrupt source.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : RxIT: specifies the source for the receive interrupt.
+* : Refer to the section \x91Receive Interrupt Configuration\x92 for
+* : more details on the allowed values of this parameter.
+* Output : RIE bit in BSPCSR1 is register.
+* Return : None.
+*******************************************************************************/
+void BSPI_RxITConfig(BSPI_TypeDef *BSPIx, BSPIRxIT_TypeDef RxIT);
+/*******************************************************************************
+* Function Name : BSPI_TxFifoConfig
+* Description : Configures BSPI transmission FIFO number of words.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI.
+* Input 2 : TxDepth:specifies the depth of the transmit FIFO.
+* Output : TFE bit in BSPCSR2 register.
+* Return : None.
+*******************************************************************************/
+void BSPI_TxFifoConfig(BSPI_TypeDef *BSPIx, vu8 TxDepth);
+/*******************************************************************************
+* Function Name : BSPI_RxFifoDepth
+* Description : Configures BSPI reception FIFO number of words.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : RxDepth:specifies the depth of the receive FIFO.
+* Output : RFE bits [3:0] in BSPCSR1 register.
+* Return : None.
+*******************************************************************************/
+void BSPI_RxFifoConfig(BSPI_TypeDef *BSPIx, vu8 RxDepth);
+/*******************************************************************************
+* Function Name : BSPI_BufferSend.
+* Description : Transmits data from a buffer.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : PtrToBuffer is an \x91u16\x92 pointer to the first word of the
+* : buffer to be transmitted.
+* Input 3 : NbOfWords parameter indicates the number of words saved in
+* : the buffer to be sent.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void BSPI_BufferSend(BSPI_TypeDef *BSPIx, vu16 *PtrToBuffer, vu8 NbOfWords);
+/*******************************************************************************
+* Function Name : BSPI_BufferReceive.
+* Description : Receives number of data words and stores them in user defined
+* : area.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : PtrToBuffer is an \x91u16\x92 pointer to the first word of the
+* : defined area to save the received buffer.
+* Input 3 : NbOfWords parameter indicates the number of words to be
+* : received in the buffer.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void BSPI_BufferReceive(BSPI_TypeDef *BSPIx, vu16 *PtrToBuffer, vu8 NbOfWords);
+/*******************************************************************************
+* Function Name : BSPI_TxBurstConfig.
+* Description : Configure the burst length when the BSPI transmit data.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : TxBurst: specifies the burst length.
+* : Refer to the section \x91Transmit Burst Length Configuration\x92
+* : for more details on the allowed values of this parameter.
+* Output : TBUSRT_LEN [1:0 ] bits in BSPCSR3 register.
+* Return : None.
+*******************************************************************************/
+void BSPI_TxBurstConfig(BSPI_TypeDef *BSPIx, BSPITxBurst_TypeDef TxBurst);
+/*******************************************************************************
+* Function Name : BSPI_RxBurstConfig.
+* Description : Configure the burst length when the BSPI receive data.
+* Input 1 : BSPIx where x can be 1 or 2 to select the BSPI peripheral.
+* Input 2 : RxBurst: specifies the burst length.
+* : Refer to the section \x91Receive Burst Length Configuration\x92
+* : for more details on the allowed values of this parameter.
+* Output : RBUSRT_LEN [1:0 ] bits in BSPCSR3 register.
+* Return : None.
+*******************************************************************************/
+void BSPI_RxBurstConfig(BSPI_TypeDef *BSPIx, BSPIRxBurst_TypeDef RxBurst);
+#endif /* __720_BSPI_H */
+
+/******************* (C) COPYRIGHT 2004 STMicroelectronics *****END OF FILE****/
+
+
Added: trunk/firmware/arm/str/common/str72x_lib/include/720_can.h
===================================================================
--- trunk/firmware/arm/str/common/str72x_lib/include/720_can.h (rev 0)
+++ trunk/firmware/arm/str/common/str72x_lib/include/720_can.h 2008-02-06 12:48:42 UTC (rev 828)
@@ -0,0 +1,407 @@
+/******************** (C) COPYRIGHT 2004 STMicroelectronics ********************
+* File Name : 720_can.h
+* Author : MCD Application Team
+* Date First Issued : 08/02/2004
+* Description : This file contains all the functions prototypes for the
+* CAN bus software library.
+**********************************************************************************
+* History:
+* 12/20/2004 : V1.1
+* 08/02/2004 : V1.0
+**********************************************************************************
+* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
+* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
+* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
+* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*********************************************************************************/
+
+#ifndef __720_CAN_H
+#define __720_CAN_H
+
+#include "720_lib.h"
+
+#ifndef _WIU
+ #error _WIU Must be Defined in "720_conf.h"
+#endif
+
+// Standard bitrates available
+enum
+{
+ CAN_BITRATE_100K,
+ CAN_BITRATE_125K,
+ CAN_BITRATE_250K,
+ CAN_BITRATE_500K,
+ CAN_BITRATE_1M
+};
+
+// Control register
+#define CAN_CTL_TEST 0x0080
+#define CAN_CTL_CCE 0x0040
+#define CAN_CTL_DAR 0x0020
+#define CAN_CTL_EIE 0x0008
+#define CAN_CTL_SIE 0x0004
+#define CAN_CTL_IE 0x0002
+#define CAN_CTL_INIT 0x0001
+
+// Status register
+#define CAN_STS_LEC 0x0007
+#define CAN_STS_TXOK 0x0008
+#define CAN_STS_RXOK 0x0010
+#define CAN_STS_EPASS 0x0020
+#define CAN_STS_EWARN 0x0040
+#define CAN_STS_BOFF 0x0080
+
+// Test register
+#define CAN_TST_RX 0x0080
+#define CAN_TST_TX1 0x0040
+#define CAN_TST_TX0 0x0020
+#define CAN_TST_LBACK 0x0010
+#define CAN_TST_SILENT 0x0008
+#define CAN_TST_BASIC 0x0004
+
+// IFx / Command Request register
+#define CAN_CRQ_BUSY 0x8000
+
+// IFx / Command Mask register
+#define CAN_COM_WRITE 0x0080
+#define CAN_COM_MASK 0x0040
+#define CAN_COM_ARB 0x0020
+#define CAN_COM_CTRL 0x0010
+#define CAN_COM_CLRINT 0x0008
+#define CAN_COM_TXRQST 0x0004
+#define CAN_COM_DATAA 0x0002
+#define CAN_COM_DATAB 0x0001
+
+// IFx / Mask1,2 register
+#define CAN_MSK_MXTD 0x8000
+#define CAN_MSK_MDIR 0x4000
+
+// IFx / Arbitration1,2 register
+#define CAN_ARB_MSGVAL 0x8000
+#define CAN_ARB_XTD 0x4000
+#define CAN_ARB_DIR 0x2000
+
+// IFx / Message Control register
+#define CAN_CTL_NEWDAT 0x8000
+#define CAN_CTL_MSGLST 0x4000
+#define CAN_CTL_INTPND 0x2000
+#define CAN_CTL_UMASK 0x1000
+#define CAN_CTL_TXIE 0x0800
+#define CAN_CTL_RXIE 0x0400
+#define CAN_CTL_RMTEN 0x0200
+#define CAN_CTL_TXRQST 0x0100
+#define CAN_CTL_EOB 0x0080
+
+
+// Wake-up modes
+enum
+{
+ CAN_WAKEUP_ON_EXT,
+ CAN_WAKEUP_ON_CAN
+};
+
+
+// CAN message structure
+typedef struct
+{
+ int IdType;
+ vu32 Id;
+ vu8 Dlc;
+ vu8 Data[8];
+} canmsg;
+
+// message ID types
+enum
+{
+ CAN_STD_ID,
+ CAN_EXT_ID
+};
+
+// message ID limits
+#define CAN_LAST_STD_ID ((1<<11) - 1)
+#define CAN_LAST_EXT_ID ((1L<<29) - 1)
+
+/*******************************************************************************
+* Function Name : CAN_EnterInitMode
+* Description : Switch the CAN into initialization mode
+* Input 1 : any binary value formed from the CAN_CTL_xxx defines
+* Output : None
+* Return : None
+* Note : CAN_LeaveInitMode must be called when all is done
+*******************************************************************************/
+static inline void CAN_EnterInitMode(vu8 mask)
+{
+ CAN->CR = mask | CAN_CTL_INIT;
+ CAN->SR = 0; // reset the status
+}
+
+/*******************************************************************************
+* Function Name : CAN_LeaveInitMode
+* Description : Leave the initialization mode (switch into normal mode)
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+static inline void CAN_LeaveInitMode(void)
+{
+ CAN->CR &= ~(CAN_CTL_INIT | CAN_CTL_CCE);
+}
+
+/*******************************************************************************
+* Function Name : CAN_EnterTestMode
+* Description : Switch the CAN into test mode
+* Input 1 : any binary value formed from the CAN_TST_xxx defines
+* Output : None
+* Return : None
+* Note : CAN_LeaveTestMode must be called when all is done
+*******************************************************************************/
+static inline void CAN_EnterTestMode(vu8 mask)
+{
+ CAN->CR |= CAN_CTL_TEST;
+ CAN->TESTR |= mask;
+}
+
+/*******************************************************************************
+* Function Name : CAN_LeaveTestMode
+* Description : Leave the current test mode (switch into normal mode)
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+static inline void CAN_LeaveTestMode(void)
+{
+ CAN->CR |= CAN_CTL_TEST;
+ CAN->TESTR &= ~(CAN_TST_LBACK | CAN_TST_SILENT | CAN_TST_BASIC);
+ CAN->CR &= ~CAN_CTL_TEST;
+}
+
+/*******************************************************************************
+* Function Name : CAN_SetBitrate
+* Description : Setup a standard CAN bitrate
+* Input 1 : one of the CAN_BITRATE_xxx defines
+* Output : None
+* Return : None
+* Note : CAN must be in initialization mode
+*******************************************************************************/
+void CAN_SetBitrate(int bitrate);
+
+/*******************************************************************************
+* Function Name : CAN_SetTiming
+* Description : Setup the CAN timing with specific parameters
+* Input 1 : Time Segment before the sample point position, from 1 to 16
+* Input 2 : Time Segment after the sample point position, from 1 to 8
+* Input 3 : Synchronisation Jump Width, from 1 to 4
+* Input 4 : Baud Rate Prescaler, from 1 to 1024
+* Output : None
+* Return : None
+* Note : CAN must be in initialization mode
+*******************************************************************************/
+void CAN_SetTiming(int tseg1, int tseg2, int sjw, int brp);
+
+/*******************************************************************************
+* Function Name : CAN_SleepRequest
+* Description : Request the CAN cell to enter Sleep mode
+* Input 1 : CAN_WAKEUP_ON_EXT or CAN_WAKEUP_ON_CAN
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_SleepRequest(int WakeupMode);
+
+/*******************************************************************************
+* Function Name : CAN_SetUnusedMsgObj
+* Description : Configure the message object as unused
+* Input 1 : message object number, from 0 to 31
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_SetUnusedMsgObj(int msgobj);
+
+/*******************************************************************************
+* Function Name : CAN_SetTxMsgObj
+* Description : Configure the message object as TX
+* Input 1 : message object number, from 0 to 31
+* Input 2 : CAN_STD_ID or CAN_EXT_ID
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_SetTxMsgObj(int msgobj, int idType);
+
+/*******************************************************************************
+* Function Name : CAN_SetRxMsgObj
+* Description : Configure the message object as RX
+* Input 1 : message object number, from 0 to 31
+* Input 2 : CAN_STD_ID or CAN_EXT_ID
+* Input 3 : low part of the identifier range used for acceptance filtering
+* Input 4 : high part of the identifier range used for acceptance filtering
+* Input 5 : 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 : None
+* Return : None
+*******************************************************************************/
+void CAN_SetRxMsgObj(int msgobj, int idType, vu32 idLow, vu32 idHigh, bool singleOrFifoLast);
+
+/*******************************************************************************
+* Function Name : CAN_InvalidateAllMsgObj
+* Description : Configure all the message objects as unused
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_InvalidateAllMsgObj(void);
+
+/*******************************************************************************
+* Function Name : CAN_Init
+* Description : Initialize the CAN cell and set the bitrate
+* Input 1 : any binary value formed from the CAN_CTL_xxx defines
+* Input 2 : one of the CAN_BITRATE_xxx defines
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_Init(vu8 mask, int bitrate);
+
+/*******************************************************************************
+* Function Name : CAN_ReleaseMessage
+* Description : Release the message object
+* Input 1 : message object number, from 0 to 31
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_ReleaseMessage(int msgobj);
+
+/*******************************************************************************
+* Function Name : CAN_ReleaseTxMessage
+* Description : Release the transmit message object
+* Input 1 : message object number, from 0 to 31
+* Output : None
+* Return : None
+* Note : assume that message interface 0 is free
+*******************************************************************************/
+static inline void CAN_ReleaseTxMessage(int msgobj)
+{
+ CAN->sMsgObj[0].COMM = CAN_COM_CLRINT | CAN_COM_TXRQST;
+ CAN->sMsgObj[0].COMR = 1 + msgobj;
+}
+
+/*******************************************************************************
+* Function Name : CAN_ReleaseRxMessage
+* Description : Release the receive message object
+* Input 1 : message object number, from 0 to 31
+* Output : None
+* Return : None
+* Note : assume that message interface 1 is free
+*******************************************************************************/
+static inline void CAN_ReleaseRxMessage(int msgobj)
+{
+ CAN->sMsgObj[1].COMM = CAN_COM_CLRINT | CAN_COM_TXRQST;
+ CAN->sMsgObj[1].COMR = 1 + msgobj;
+}
+
+/*******************************************************************************
+* Function Name : CAN_SendMessage
+* Description : Start transmission of a message
+* Input 1 : message object number, from 0 to 31
+* Input 2 : pointer to the message structure containing data to transmit
+* Output : None
+* Return : 1 if transmission was OK, else 0
+*******************************************************************************/
+int CAN_SendMessage(int msgobj, canmsg* pCanMsg);
+
+/*******************************************************************************
+* Function Name : CAN_ReceiveMessage
+* Description : Get the message, if received
+* Input 1 : message object number, from 0 to 31
+* Input 2 : if TRUE, the message object is released when getting the data
+* if FALSE, the message object is not released
+* Input 3 : pointer to the message structure where received data is stored
+* Output : None
+* Ret...
[truncated message content] |